Nut/OS  5.0.5
API Reference
sht21.h
Go to the documentation of this file.
00001 #ifndef _DEV_SHT21_H_
00002 #define _DEV_SHT21_H_
00003 /*
00004  * Copyright (C) 2010 by Rittal GmbH & Co. KG,
00005  * Dawid Sadji <sadji.d@rittal.de> All rights reserved.
00006  * Ulrich Prinz <prinz.u@rittal.de> All rights reserved.
00007  *
00008  * Redistribution and use in source and binary forms, with or without
00009  * modification, are permitted provided that the following conditions
00010  * are met:
00011  *
00012  * 1. Redistributions of source code must retain the above copyright
00013  *    notice, this list of conditions and the following disclaimer.
00014  * 2. Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the
00016  *    documentation and/or other materials provided with the distribution.
00017  * 3. Neither the name of the copyright holders nor the names of
00018  *    contributors may be used to endorse or promote products derived
00019  *    from this software without specific prior written permission.
00020  *
00021  * THIS SOFTWARE IS PROVIDED BY EMBEDDED IT AND CONTRIBUTORS
00022  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00023  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00024  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL EMBEDDED IT
00025  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00026  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00027  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00028  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00029  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00030  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00031  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00032  *
00033  * For additional information see http://www.ethernut.de/
00034  *
00035  */
00036 
00037 /*
00038  * \verbatim
00039  * $Id:$
00040  * \endverbatim
00041  */
00042 #include <cfg/sht21.h>
00043 
00044 #ifndef I2C_SLA_SHT21
00045 #define I2C_SLA_SHT21     0x40
00046 #endif
00047 
00048 /*
00049  * Sensirion common sensor commands
00050  */
00051 #ifdef SHT_ACK_POLLING
00052 #define SHT_GET_TEMP    0xF3    /* Get Temperature Command */
00053 #define SHT_GET_HUM     0xF5    /* Get Humidity Command */
00054 #else
00055 #define SHT_GET_TEMP    0xE3    /* Get Temperature Command */
00056 #define SHT_GET_HUM     0xE5    /* Get Humidity Command */
00057 #endif
00058 #define SHT_SET_USER    0xE6    /* Set User Register Command */
00059 #define SHT_GET_USER    0xE7    /* Get User Register Command */
00060 #define SHT_SOFT_RESET  0xFE    /* Soft Reset Command */
00061 #define SHT_READ_OCM    0xFA    /* Read On Chip Memory Command */
00062 #define SHT_GET_SERNR   0x0F    /* Read OCM: Serial Number */
00063 
00064 /* Bit definitions of User Register */
00065 #define SHT_RES_12_14   0x00    /* Resolution: RH=12bit, T=14bit */
00066 #define SHT_RES_8_12    0x01    /* Resolution: RH= 8bit, T=12bit */
00067 #define SHT_RES_10_13   0x80    /* Resolution: RH=10bit, T=13bit */
00068 #define SHT_RES_11_11   0x81    /* Resolution: RH=11bit, T=11bit */
00069 #define SHT_RES_MASK    0x81    /* Resolution: Mask for res. bits */
00070 
00071 #define SHT_USER_EOB    0x40    /* User Register: End Of Battery Flag */
00072 #define SHT_USER_HTR    0x04    /* User Register: Heater On Flag */
00073 
00074 int ShtCrc(uint8_t *Data, uint8_t Size);
00075 int ShtCommand(uint8_t cmd, uint16_t *data);
00076 int ShtRead( uint8_t cmd, int16_t *val);
00077 int ShtInit(void);
00078 
00079 #endif /* _DEV_SHT21_H_ */