1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/drivers/include/sht11.h
Oliver Hahm f38f32f6cc * added support for sht11 for msb-430-common
* fixed some jamfile isssues for msb-430
* fixed arch32 detection for scheduler
* changed sht11 driver to be platform independent
2010-10-29 17:32:03 +02:00

116 lines
3.4 KiB
C

/******************************************************************************
Copyright 2009, Freie Universitaet Berlin (FUB). All rights reserved.
These sources were developed at the Freie Universitaet Berlin, Computer Systems
and Telematics group (http://cst.mi.fu-berlin.de).
-------------------------------------------------------------------------------
This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
FeuerWare is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, see http://www.gnu.org/licenses/ .
--------------------------------------------------------------------------------
For further information and questions please use the web site
http://scatterweb.mi.fu-berlin.de
and the mailinglist (subscription via web site)
scatterweb@lists.spline.inf.fu-berlin.de
*******************************************************************************/
#ifndef SHT11_H_
#define SHT11_H_
/**
* @defgroup sht11 Sensirion SHT11 Driver
* @ingroup dev
* @{
*/
/**
* @file
* @brief SHT11 Device Driver
*
* @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project
* @version $Revision: 667 $
*
* @note $Id: sht11.h 667 2009-02-19 15:06:38Z baar $
*/
#define SHT11_NO_ACK (0)
#define SHT11_ACK (1)
//adr command r/w
#define SHT11_STATUS_REG_W (0x06) //000 0011 0
#define SHT11_STATUS_REG_R (0x07) //000 0011 1
#define SHT11_MEASURE_TEMP (0x03) //000 0001 1
#define SHT11_MEASURE_HUMI (0x05) //000 0010 1
#define SHT11_RESET (0x1E) //000 1111 0
/* time to wait after toggling the data line */
#define SHT11_DATA_WAIT (HWTIMER_TICKS(5))
/* time to wait after toggling the clock line */
#define SHT11_CLK_WAIT (HWTIMER_TICKS(1))
/* set measurement timeout to 1 second */
#define SHT11_MEASURE_TIMEOUT (1000)
/** sht11 measureable data */
typedef struct {
/* temperature value */
float temperature;
/* linear relative humidity */
float relhum;
/* temperature compensated relative humidity */
float relhum_temp;
} sht11_val_t;
/**
* @brief SHT11 modes that can be measured
*/
typedef enum {
TEMPERATURE = 1,
HUMIDITY = 2
} sht11_mode_t;
/**
* @brief Initialize SHT11 ports
*/
void sht11_init(void);
/**
* @brief Read sensor
*
* Example:
* \code struct sht11_val sht11;
* sht11_Read_Sensor(&sht11, HUMIDITY|TEMPERATURE);
* printf("%-6.2f °C %5.2f %% %5.2f %%\n", sht11.temperature, sht11.relhum, sht11.relhum_temp); \endcode
*/
uint8_t sht11_read_sensor(sht11_val_t *value, sht11_mode_t mode);
/**
* @brief Write status register
*
* @param p_value The value to write
*
* @return 1 on success, 0 otherwise
*/
uint8_t sht11_write_status(uint8_t *p_value);
/**
* @brief Read status register with checksum
*
* @param p_value The read value
* @param p_checksum The received checksum
*
* return 1 on success, 0 otherwise
*/
uint8_t sht11_read_status(uint8_t *p_value, uint8_t *p_checksum);
/** @} */
#endif /*SHT11_H_*/