00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 #ifndef DS1631_H
00036 #define DS1631_H
00037
00038 #include "global.h"
00039
00040
00041 #define DS1631_I2C_ADDR 0x90 //< Base I2C address of DS1631 devices
00042
00043 #define DS1631_CMD_STARTCONV 0x51 //< DS1631 Start conversion command byte
00044 #define DS1631_CMD_STOPCONV 0x22 //< DS1631 Stop conversion command byte
00045 #define DS1631_CMD_READTEMP 0xAA //< DS1631 Read Temperature command byte
00046 #define DS1631_CMD_ACCESSTH 0xA1 //< DS1631 TH read/write command byte
00047 #define DS1631_CMD_ACCESSTL 0xA2 //< DS1631 TL read/write command byte
00048 #define DS1631_CMD_ACCESSCONFIG 0xAC //< DS1631 Config read/write command byte
00049 #define DS1631_CMD_SWPOR 0x54 //< DS1631 Software Reset command byte
00050
00051 #define DS1631_CONFIG_1SHOT 0x01
00052 #define DS1631_CONFIG_POL 0x02
00053 #define DS1631_CONFIG_R0 0x04
00054 #define DS1631_CONFIG_R1 0x08
00055 #define DS1631_CONFIG_NVB 0x10
00056 #define DS1631_CONFIG_TLF 0x20
00057 #define DS1631_CONFIG_THF 0x40
00058 #define DS1631_CONFIG_DONE 0x80
00059
00060
00061
00062
00063 u08 ds1631Init(u08 i2cAddr);
00064
00065
00066 u08 ds1631Reset(u08 i2cAddr);
00067
00068
00069 void ds1631SetConfig(u08 i2cAddr, u08 config);
00070
00071
00072 u08 ds1631GetConfig(u08 i2cAddr);
00073
00074
00075 void ds1631StartConvert(u08 i2cAddr);
00076
00077
00078 void ds1631StopConvert(u08 i2cAddr);
00079
00080
00081 s16 ds1631ReadTemp(u08 i2cAddr);
00082
00083
00084 void ds1631SetTH(u08 i2cAddr, s16 value);
00085
00086
00087 void ds1631SetTL(u08 i2cAddr, s16 value);
00088
00089
00090 s16 ds1631GetTH(u08 i2cAddr);
00091
00092
00093 s16 ds1631GetTL(u08 i2cAddr);
00094
00095 void ds1631WriteTempReg(u08 i2cAddr, u08 cmd, s16 value);
00096 s16 ds1631ReadTempReg(u08 i2cAddr, u08 cmd);
00097
00098
00099 #endif