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