Main Page | Modules | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

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 /// \ingroup driver_hw
00018 /// \defgroup ds1631 Dallas DS1631 Temperature Sensor Driver (ds1631.c)
00019 /// \code #include "ds1632.h" \endcode
00020 /// \par Overview
00021 ///     This library provides high-level functions for accessing the Dallas
00022 ///     Semiconductor DS1631 I2C Temperature Sensor.
00023 ///
00024 ///     The basic specs of the DS1631 are:
00025 ///     - operating temperature range -55 to +125 degrees C
00026 ///     - high accuracy of +/-0.5C over 0 to +70 degrees C
00027 ///     - 8 to 12-bit signed output
00028 ///     - thermostat functionality
00029 //
00030 // This code is distributed under the GNU Public License
00031 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00032 //
00033 //*****************************************************************************
00034 
00035 #ifndef DS1631_H
00036 #define DS1631_H
00037 
00038 #include "global.h"
00039 
00040 // constants/macros/typdefs
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 // functions
00061 
00062 //! Initialize the DS1631 chip
00063 u08 ds1631Init(u08 i2cAddr);
00064 
00065 //! Reset the DS1631 chip to its power-on defaults
00066 u08 ds1631Reset(u08 i2cAddr);
00067 
00068 //! Set the configuration byte of the DS1631
00069 void ds1631SetConfig(u08 i2cAddr, u08 config);
00070 
00071 //! Get the configuration byte of the DS1631
00072 u08 ds1631GetConfig(u08 i2cAddr);
00073 
00074 //! Start a temperature conversion
00075 void ds1631StartConvert(u08 i2cAddr);
00076 
00077 //! Stop a temperature conversion (or stop continuous conversion mode)
00078 void ds1631StopConvert(u08 i2cAddr);
00079 
00080 //! Read the result of a temperature conversion
00081 s16 ds1631ReadTemp(u08 i2cAddr);
00082 
00083 //! Set the Temp-High threshold
00084 void ds1631SetTH(u08 i2cAddr, s16 value);
00085 
00086 //! Set the Temp-Low threshold
00087 void ds1631SetTL(u08 i2cAddr, s16 value);
00088 
00089 //! Get the Temp-High threshold
00090 s16 ds1631GetTH(u08 i2cAddr);
00091 
00092 //! Get the Temp-Low threshold
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

Generated on Sun Oct 29 03:41:06 2006 for Procyon AVRlib by  doxygen 1.4.2