Main Page   Modules   Data Structures   File List   Data Fields   Globals  

ds1631.h

Go to the documentation of this file.
00001 /*! \file ds1631.h \brief Dallas DS1631 Temperature Sensor Driver Library. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'ds1631.h'
00005 // Title        : Dallas DS1631 Temperature Sensor Driver Library
00006 // Author       : Pascal Stang - Copyright (C) 2004
00007 // Created      : 2004.02.10
00008 // Revised      : 2004.02.19
00009 // Version      : 0.1
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // NOTE: This code is currently below version 1.0, and therefore is considered
00014 // to be lacking in some functionality or documentation, or may not be fully
00015 // tested.  Nonetheless, you can expect most functions to work.
00016 //
00017 // This code is distributed under the GNU Public License
00018 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00019 //
00020 //*****************************************************************************
00021 
00022 #ifndef DS1631_H
00023 #define DS1631_H
00024 
00025 #include "global.h"
00026 
00027 // constants/macros/typdefs
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 // functions
00048 
00049 //! Initialize the DS1631 chip
00050 u08 ds1631Init(u08 i2cAddr);
00051 
00052 //! Reset the DS1631 chip to its power-on defaults
00053 u08 ds1631Reset(u08 i2cAddr);
00054 
00055 //! Set the configuration byte of the DS1631
00056 void ds1631SetConfig(u08 i2cAddr, u08 config);
00057 
00058 //! Get the configuration byte of the DS1631
00059 u08 ds1631GetConfig(u08 i2cAddr);
00060 
00061 //! Start a temperature conversion
00062 void ds1631StartConvert(u08 i2cAddr);
00063 
00064 //! Stop a temperature conversion (or stop continuous conversion mode)
00065 void ds1631StopConvert(u08 i2cAddr);
00066 
00067 //! Read the result of a temperature conversion
00068 s16 ds1631ReadTemp(u08 i2cAddr);
00069 
00070 //! Set the Temp-High threshold
00071 void ds1631SetTH(u08 i2cAddr, s16 value);
00072 
00073 //! Set the Temp-Low threshold
00074 void ds1631SetTL(u08 i2cAddr, s16 value);
00075 
00076 //! Get the Temp-High threshold
00077 s16 ds1631GetTH(u08 i2cAddr);
00078 
00079 //! Get the Temp-Low threshold
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

Generated on Sun Feb 22 19:12:31 2004 for Procyon AVRlib by doxygen1.3-rc2