00001 #ifndef __ds1631_h 00002 #define __ds1631_h defined 00003 00004 #include "pic_utils.h" 00005 #include "config.h" 00006 00007 // For config.h 00008 /* 00009 00010 // - - - - - - - - - - - - - - 00011 // ds1631 details 00012 // - - - - - - - - - - - - - - 00013 00014 #define ds1631_scl_port PORTA 00015 #define ds1631_sda_port PORTA 00016 #define ds1631_scl_pin 0 00017 #define ds1631_sda_pin 1 00018 00019 // - - - - - - - - - - - - - - 00020 00021 */ 00022 #define ds1631_start_convert 0x51 00023 #define ds1631_stop_convert 0x22 00024 #define ds1631_read_temp 0xAA 00025 #define ds1631_access_th 0xA1 00026 #define ds1631_access_tl 0xA2 00027 #define ds1631_access_config 0xAC 00028 #define ds1631_software_por 0x54 00029 00030 00031 #define ds1631_bit_delay() delay_us(20) 00032 00033 void ds1631_setup(); 00034 uns16 ds1631_get_temp(uns8 control, uns8 command ); 00035 void ds1631_write_convert(uns8 control, uns8 command); 00036 uns8 ds1631_read_config(uns8 control, uns8 command); 00037 void ds1631_write_config(uns8 control, uns8 command, uns8 data); 00038 00039 void ds1631_start(); 00040 void ds1631_stop(); 00041 void ds1631_get_temp(); 00042 void ds1631_get_config(); 00043 void ds1631_set_config(); 00044 uns8 convert_to_dec2b(uns8 data); 00045 uns8 convert_to_dec1(uns8 data); 00046 uns8 convert_to_dec2(uns8 data); 00047 void ds1631_write_and_ack(uns8 data); 00048 uns8 ds1631_read_and_ack(uns8 last); 00049 00050 00051 00052 #endif