hts221.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
24 #ifndef HTS221_H
25 #define HTS221_H
26 
27 #include <stdint.h>
28 
29 #include "periph/i2c.h"
30 #include "hts221_regs.h"
31 
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35 
39 #define HTS221_I2C_ADDRESS (0x5F)
40 
44 typedef struct {
46  uint8_t addr;
47  uint8_t avgx;
48  uint8_t rate;
50 
54 enum {
55  HTS221_OK = 0,
56  HTS221_ERROR,
57  HTS221_NOBUS,
58  HTS221_NODEV,
59 };
60 
64 typedef struct {
66  int16_t h0_rh;
67  int16_t h1_rh;
68  int16_t h0_t0_out;
69  int16_t h1_t0_out;
70  int16_t t0_degc;
71  int16_t t1_degc;
72  int16_t t0_out;
73  int16_t t1_out;
74 } hts221_t;
75 
86 int hts221_init(hts221_t *dev, const hts221_params_t *params);
87 
95 int hts221_reboot(const hts221_t *dev);
96 
104 int hts221_one_shot(const hts221_t *dev);
105 
114 int hts221_set_rate(const hts221_t *dev, const uint8_t rate);
115 
123 int hts221_power_on(const hts221_t *dev);
124 
132 int hts221_power_off(const hts221_t *dev);
133 
142 int hts221_get_state(const hts221_t *dev);
143 
152 int hts221_read_humidity(const hts221_t *dev, uint16_t *val);
153 
162 int hts221_read_temperature(const hts221_t *dev, int16_t *val);
163 
164 #ifdef __cplusplus
165 }
166 #endif
167 
168 #endif /* HTS221_H */
169 
hts221_params_t::avgx
uint8_t avgx
average sampling of humidity and temperature
Definition: hts221.h:47
hts221_one_shot
int hts221_one_shot(const hts221_t *dev)
Set device to one shot measurement.
hts221_params_t
Parameters needed for device initialization.
Definition: hts221.h:44
i2c_t
unsigned int i2c_t
Default i2c_t type definition.
Definition: i2c.h:151
hts221_t::h1_t0_out
int16_t h1_t0_out
upper humitidy to temperature reference
Definition: hts221.h:69
hts221_t::t1_out
int16_t t1_out
upper temperature reference raw value
Definition: hts221.h:73
hts221_params_t::i2c
i2c_t i2c
bus the device is connected to
Definition: hts221.h:45
hts221_t::t1_degc
int16_t t1_degc
upper temperature reference in degC
Definition: hts221.h:71
hts221_read_temperature
int hts221_read_temperature(const hts221_t *dev, int16_t *val)
Reading humidity and temperature.
hts221_init
int hts221_init(hts221_t *dev, const hts221_params_t *params)
Initialize the given HTS221 device.
hts221_power_on
int hts221_power_on(const hts221_t *dev)
Set device to active.
hts221_params_t::addr
uint8_t addr
address on that bus
Definition: hts221.h:46
hts221_set_rate
int hts221_set_rate(const hts221_t *dev, const uint8_t rate)
Set device to continuous measurements.
hts221_read_humidity
int hts221_read_humidity(const hts221_t *dev, uint16_t *val)
Reading humidity and temperature.
hts221_t::h0_t0_out
int16_t h0_t0_out
lower humitidy to temperature reference
Definition: hts221.h:68
hts221_params_t::rate
uint8_t rate
output data rate
Definition: hts221.h:48
hts221_t::h0_rh
int16_t h0_rh
lower humitidy reference
Definition: hts221.h:66
hts221_t::t0_degc
int16_t t0_degc
lower temperature reference in degC
Definition: hts221.h:70
hts221_t
Device descriptor for HTS221 sensors.
Definition: hts221.h:64
hts221_t::h1_rh
int16_t h1_rh
upper humitidy reference
Definition: hts221.h:67
hts221_regs.h
Register definitions for ST HTS221 devices.
hts221_t::t0_out
int16_t t0_out
lower temperature reference raw value
Definition: hts221.h:72
hts221_t::p
hts221_params_t p
Configuration parameters.
Definition: hts221.h:65
hts221_reboot
int hts221_reboot(const hts221_t *dev)
Reboot device and reload base configuration.
hts221_power_off
int hts221_power_off(const hts221_t *dev)
Set device to power down.
hts221_get_state
int hts221_get_state(const hts221_t *dev)
Set device to power down.
i2c.h
Low-level I2C peripheral driver interface definition.