| Line No. | Rev | Author | Line |
|---|---|---|---|
| 1 | 6 | kaklik | /*! \file ds1631.h \brief Dallas DS1631 Temperature Sensor Driver Library. */ |
| 2 | //***************************************************************************** |
||
| 3 | // |
||
| 4 | // File Name : 'ds1631.h' |
||
| 5 | // Title : Dallas DS1631 Temperature Sensor Driver Library |
||
| 6 | // Author : Pascal Stang - Copyright (C) 2004 |
||
| 7 | // Created : 2004.02.10 |
||
| 8 | // Revised : 2004.02.19 |
||
| 9 | // Version : 0.1 |
||
| 10 | // Target MCU : Atmel AVR Series |
||
| 11 | // Editor Tabs : 4 |
||
| 12 | // |
||
| 13 | // NOTE: This code is currently below version 1.0, and therefore is considered |
||
| 14 | // to be lacking in some functionality or documentation, or may not be fully |
||
| 15 | // tested. Nonetheless, you can expect most functions to work. |
||
| 16 | // |
||
| 17 | /// \ingroup driver_hw |
||
| 18 | /// \defgroup ds1631 Dallas DS1631 Temperature Sensor Driver (ds1631.c) |
||
| 19 | /// \code #include "ds1632.h" \endcode |
||
| 20 | /// \par Overview |
||
| 21 | /// This library provides high-level functions for accessing the Dallas |
||
| 22 | /// Semiconductor DS1631 I2C Temperature Sensor. |
||
| 23 | /// |
||
| 24 | /// The basic specs of the DS1631 are: |
||
| 25 | /// - operating temperature range -55 to +125 degrees C |
||
| 26 | /// - high accuracy of +/-0.5C over 0 to +70 degrees C |
||
| 27 | /// - 8 to 12-bit signed output |
||
| 28 | /// - thermostat functionality |
||
| 29 | // |
||
| 30 | // This code is distributed under the GNU Public License |
||
| 31 | // which can be found at http://www.gnu.org/licenses/gpl.txt |
||
| 32 | // |
||
| 33 | //***************************************************************************** |
||
| 34 | |||
| 35 | #ifndef DS1631_H |
||
| 36 | #define DS1631_H |
||
| 37 | |||
| 38 | #include "global.h" |
||
| 39 | |||
| 40 | // constants/macros/typdefs |
||
| 41 | #define DS1631_I2C_ADDR 0x90 ///< Base I2C address of DS1631 devices |
||
| 42 | |||
| 43 | #define DS1631_CMD_STARTCONV 0x51 ///< DS1631 Start conversion command byte |
||
| 44 | #define DS1631_CMD_STOPCONV 0x22 ///< DS1631 Stop conversion command byte |
||
| 45 | #define DS1631_CMD_READTEMP 0xAA ///< DS1631 Read Temperature command byte |
||
| 46 | #define DS1631_CMD_ACCESSTH 0xA1 ///< DS1631 TH read/write command byte |
||
| 47 | #define DS1631_CMD_ACCESSTL 0xA2 ///< DS1631 TL read/write command byte |
||
| 48 | #define DS1631_CMD_ACCESSCONFIG 0xAC ///< DS1631 Config read/write command byte |
||
| 49 | #define DS1631_CMD_SWPOR 0x54 ///< DS1631 Software Reset command byte |
||
| 50 | |||
| 51 | #define DS1631_CONFIG_1SHOT 0x01 |
||
| 52 | #define DS1631_CONFIG_POL 0x02 |
||
| 53 | #define DS1631_CONFIG_R0 0x04 |
||
| 54 | #define DS1631_CONFIG_R1 0x08 |
||
| 55 | #define DS1631_CONFIG_NVB 0x10 |
||
| 56 | #define DS1631_CONFIG_TLF 0x20 |
||
| 57 | #define DS1631_CONFIG_THF 0x40 |
||
| 58 | #define DS1631_CONFIG_DONE 0x80 |
||
| 59 | |||
| 60 | // functions |
||
| 61 | |||
| 62 | //! Initialize the DS1631 chip |
||
| 63 | u08 ds1631Init(u08 i2cAddr); |
||
| 64 | |||
| 65 | //! Reset the DS1631 chip to its power-on defaults |
||
| 66 | u08 ds1631Reset(u08 i2cAddr); |
||
| 67 | |||
| 68 | //! Set the configuration byte of the DS1631 |
||
| 69 | void ds1631SetConfig(u08 i2cAddr, u08 config); |
||
| 70 | |||
| 71 | //! Get the configuration byte of the DS1631 |
||
| 72 | u08 ds1631GetConfig(u08 i2cAddr); |
||
| 73 | |||
| 74 | //! Start a temperature conversion |
||
| 75 | void ds1631StartConvert(u08 i2cAddr); |
||
| 76 | |||
| 77 | //! Stop a temperature conversion (or stop continuous conversion mode) |
||
| 78 | void ds1631StopConvert(u08 i2cAddr); |
||
| 79 | |||
| 80 | //! Read the result of a temperature conversion |
||
| 81 | s16 ds1631ReadTemp(u08 i2cAddr); |
||
| 82 | |||
| 83 | //! Set the Temp-High threshold |
||
| 84 | void ds1631SetTH(u08 i2cAddr, s16 value); |
||
| 85 | |||
| 86 | //! Set the Temp-Low threshold |
||
| 87 | void ds1631SetTL(u08 i2cAddr, s16 value); |
||
| 88 | |||
| 89 | //! Get the Temp-High threshold |
||
| 90 | s16 ds1631GetTH(u08 i2cAddr); |
||
| 91 | |||
| 92 | //! Get the Temp-Low threshold |
||
| 93 | s16 ds1631GetTL(u08 i2cAddr); |
||
| 94 | |||
| 95 | void ds1631WriteTempReg(u08 i2cAddr, u08 cmd, s16 value); |
||
| 96 | s16 ds1631ReadTempReg(u08 i2cAddr, u08 cmd); |
||
| 97 | |||
| 98 | |||
| 99 | #endif |
Powered by WebSVN v2.8.3