#include <cfg/sht21.h>Go to the source code of this file.
Defines | |
| #define | I2C_SLA_SHT21 0x40 |
| #define | SHT_GET_TEMP 0xE3 |
| #define | SHT_GET_HUM 0xE5 |
| #define | SHT_SET_USER 0xE6 |
| #define | SHT_GET_USER 0xE7 |
| #define | SHT_SOFT_RESET 0xFE |
| #define | SHT_READ_OCM 0xFA |
| #define | SHT_GET_SERNR 0x0F |
| #define | SHT_RES_12_14 0x00 |
| #define | SHT_RES_8_12 0x01 |
| #define | SHT_RES_10_13 0x80 |
| #define | SHT_RES_11_11 0x81 |
| #define | SHT_RES_MASK 0x81 |
| #define | SHT_USER_EOB 0x40 |
| #define | SHT_USER_HTR 0x04 |
Functions | |
| int | ShtCrc (uint8_t *Data, uint8_t Size) |
| Calculate 8-Bit checksum with given polynomial. | |
| int | ShtCommand (uint8_t cmd, uint16_t *data) |
| Read data from sensor device. | |
| int | ShtRead (uint8_t cmd, int16_t *val) |
| Return real sensor value. | |
| int | ShtInit (void) |
| Register and initialize SHT2x sensor device. | |
| #define I2C_SLA_SHT21 0x40 |
Referenced by ShtCommand().
| #define SHT_GET_TEMP 0xE3 |
Referenced by ShtCommand(), and ShtRead().
| #define SHT_GET_HUM 0xE5 |
Referenced by ShtCommand(), and ShtRead().
| #define SHT_SET_USER 0xE6 |
Referenced by ShtCommand(), and ShtInit().
| #define SHT_GET_USER 0xE7 |
Referenced by ShtCommand(), and ShtInit().
| #define SHT_SOFT_RESET 0xFE |
Referenced by ShtCommand(), and ShtInit().
| #define SHT_READ_OCM 0xFA |
| #define SHT_GET_SERNR 0x0F |
| #define SHT_RES_12_14 0x00 |
| #define SHT_RES_8_12 0x01 |
| #define SHT_RES_10_13 0x80 |
| #define SHT_RES_11_11 0x81 |
| #define SHT_RES_MASK 0x81 |
Referenced by ShtInit().
| #define SHT_USER_EOB 0x40 |
| #define SHT_USER_HTR 0x04 |
Calculate 8-Bit checksum with given polynomial.
This function calculates the checksum of a sensirion device returned data and validates it against the last byte transmitted. P(x) = x^8 + x^5 + x^4 + 1 = 100110001
Data Pointer to data to be checked. Size Size of data.
References POLYNOMIAL.
Referenced by ShtCommand().
Read data from sensor device.
This function reads the raw value of a SHT2x sensor device. To get the real sensor value, the formulas given by the datasheet have to be applied to this raw value.
| cmd | can be SHT_GET_HUM or SHT_GET_TMP. |
| data | Pointer to data value. |
References I2C_SLA_SHT21, NULL, NutEventPost(), NutEventWait(), NutSleep(), rc, SHT_GET_HUM, SHT_GET_TEMP, SHT_GET_USER, sht_mutex, SHT_POLL_CYCLE, SHT_POLL_TOUT, SHT_READ_COUNT, SHT_SET_USER, SHT_SOFT_RESET, ShtCrc(), TwMasterRegRead, and TwMasterTransact.
Referenced by ShtInit(), and ShtRead().
Return real sensor value.
This function returns either the temperature or the humidity value to a supplied int16_t pointer. The value is decimal with 2 decimal digits: val=2604 -> 26.04°C val=2335 -> 23.35rH
| cmd | Either SHT_GET_TEMP or SHT_GET_HUM. |
| val | Pointer to store the value to. |
References H1x100, H2x100, rc, SHT_GET_HUM, SHT_GET_TEMP, ShtCommand(), T1x100, and T2x100.
| int ShtInit | ( | void | ) |
Register and initialize SHT2x sensor device.
This function initializes the structures and I2C bus for use with SHT2x sensor device. It checks communication too.
References NutEventPost(), rc, SHT21_PRECISION, SHT_GET_USER, sht_mutex, SHT_RES_MASK, SHT_SET_USER, SHT_SOFT_RESET, and ShtCommand().