@ -18,27 +18,35 @@ DS1624 TEMP = DS1624();
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					void  DS1624 : : Init ( void ) 
 
					 
					 
					 
					void  DS1624 : : Init ( void ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					{ 
 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . send ( DS1624_CONFIG ) ; 
 
					 
					 
					 
						Wire . send ( DS1624_CONFIG _ADDR ) ; 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						Wire . send ( DS1624_CONFIGS ) ; 
 
					 
					 
					 
						Wire . send ( DS1624_CONFIGS ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						delay ( 10 ) ; 
 
					 
					 
					 
						delay ( 5 ) ; 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
					 
					 
					 
						if  ( DS1624_CONFIGS  = =  DS1624_CONFIG_CONT )  { 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . send ( DS1624_CONFIG ) ; 
 
					 
					 
					 
							startConversion ( ) ; 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
					 
					 
					 
						} 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
					} 
 
				
			 
			
				
				
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . requestFrom ( DS1624_ADDR ,  1 ) ; 
 
					 
					 
					 
					 
				
			 
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : startConversion ( void ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . send ( DS1624_SMPL_START ) ; 
 
					 
					 
					 
						Wire . send ( DS1624_SMPL_START ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					# ifdef DS1624_HANDLE_BOOT_DELAY 
 
					 
					 
					 
					# ifdef DS1624_HANDLE_BOOT_DELAY 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						delay ( 1 5 00) ; 
 
					 
					 
					 
						delay ( 1 0 00) ; 
 
				
			 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					 
					 
					 
					# endif 
 
					 
					 
					 
					# endif 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					} 
 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					
 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : stopConversion ( void ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . send ( DS1624_SMPL_STOP ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					uint16_t  DS1624 : : readTemp ( void ) 
 
					 
					 
					 
					uint16_t  DS1624 : : readTemp ( void ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					{ 
 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						uint16_t  res  =  0 ; 
 
					 
					 
					 
						uint16_t  res  =  0 ; 
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -46,6 +54,8 @@ uint16_t DS1624::readTemp(void)
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . send ( DS1624_READ_TEMP ) ; 
 
					 
					 
					 
						Wire . send ( DS1624_READ_TEMP ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						delay ( 5 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						Wire . requestFrom ( DS1624_ADDR ,  2 ) ; 
 
					 
					 
					 
						Wire . requestFrom ( DS1624_ADDR ,  2 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						while  ( ! Wire . available ( ) ) ; 
 
					 
					 
					 
						while  ( ! Wire . available ( ) ) ; 
 
				
			 
			
		
	
	
		
		
			
				
					
						
						
						
							
								 
							 
						
					 
					 
					@ -58,3 +68,107 @@ uint16_t DS1624::readTemp(void)
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						
 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
						return  res ; 
 
					 
					 
					 
						return  res ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					} 
 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					# ifdef DS1624_USE_EEPROM 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : writeData ( uint8_t  * data ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						writeData ( data ,  DS1624_EEPROM_SIZE ,  0 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : writeData ( uint8_t  * data ,  uint8_t  dataLength ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						writeData ( data ,  dataLength ,  0 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : writeData ( uint8_t  * data ,  uint8_t  dataLength ,  uint8_t  memoryPosition ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						// We can only write one page at a time!
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  ( memoryPosition % DS1624_EEPROM_PAGE  ! =  0 )  return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						// Make sure we don't overlap
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  ( dataLength  = =  0  | |  dataLength  >  ( DS1624_EEPROM_SIZE  -  memoryPosition ) )  return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						uint8_t 	buffer [ DS1624_EEPROM_PAGE ] ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						uint8_t 	pagePosition 	=  0 ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						uint8_t 	pageSize 		=  0 ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						uint8_t  buffLen 			=  0 ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						stopConversion ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						for  ( uint16_t  pageStart  =  0 ;  pageStart  <  dataLength ;  pageStart + = DS1624_EEPROM_PAGE ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						{ 	
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							if  ( pageStart + DS1624_EEPROM_PAGE  <  dataLength  | |  dataLength % DS1624_EEPROM_PAGE  = =  0 ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								pageSize 	=  DS1624_EEPROM_PAGE ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							else 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								pageSize 	=  dataLength % DS1624_EEPROM_PAGE ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							pagePosition  =  0 ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							while  ( pagePosition  <  pageSize ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								buffer [ pagePosition ] 	=  data [ pageStart + pagePosition ] ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
								pagePosition + + ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							writePage ( buffer ,  pageSize ,  ( memoryPosition  +  pageStart ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						startConversion ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : writePage ( uint8_t  * data ,  uint8_t  dataLength ,  uint8_t  pagePosition ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  ( dataLength  = =  0  | |  dataLength  >  DS1624_EEPROM_PAGE )  return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . beginTransmission ( DS1624_ADDR ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . send ( DS1624_ACCESS_MEM ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . send ( pagePosition ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . send ( data ,  dataLength ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						// Wait for the DS1624 to finish writing the eeprom
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						delay ( 50 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : readData ( uint8_t  * data ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						return  readData ( data ,  DS1624_EEPROM_SIZE ,  0 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : readData ( uint8_t  * data ,  uint8_t  dataLength ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						return  readData ( data ,  dataLength ,  0 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					void  DS1624 : : readData ( uint8_t  * data ,  uint8_t  dataLength ,  uint8_t  memoryPosition ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						// Make sure we don't overlap
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						if  ( dataLength  = =  0  | |  dataLength  >  ( DS1624_EEPROM_SIZE  -  memoryPosition ) )  return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						uint8_t  pagePosition ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						for  ( uint16_t  pagePosition  =  0 ;  pagePosition  <  dataLength ;  pagePosition + + ) 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						{ 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							// Send the access memory command along with the starting position
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							Wire . beginTransmission ( DS1624_ADDR ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							Wire . send ( DS1624_ACCESS_MEM ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							Wire . send ( ( int ) ( memoryPosition  +  pagePosition ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							Wire . endTransmission ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							// Wait for the DS1624 to set the position pointer
 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							delay ( 5 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							Wire . requestFrom ( DS1624_ADDR ,  1 ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							while  ( ! Wire . available ( ) ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
							data [ pagePosition ]  =  Wire . receive ( ) ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
						return ; 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					} 
 
				
			 
			
		
	
		
		
			
				
					
					 
					 
					 
					 
					 
					 
					 
					# endif