Loading...
Searching...
No Matches
hts221.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 HAW Hamburg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
22
23#include <stdint.h>
24
25#include "periph/i2c.h"
26#include "hts221_regs.h"
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
35#define HTS221_I2C_ADDRESS (0x5F)
36
40typedef struct {
42 uint8_t addr;
43 uint8_t avgx;
44 uint8_t rate;
46
50enum {
51 HTS221_OK = 0,
52 HTS221_ERROR,
53 HTS221_NOBUS,
54 HTS221_NODEV,
55};
56
60typedef struct {
62 int16_t h0_rh;
63 int16_t h1_rh;
64 int16_t h0_t0_out;
65 int16_t h1_t0_out;
66 int16_t t0_degc;
67 int16_t t1_degc;
68 int16_t t0_out;
69 int16_t t1_out;
70} hts221_t;
71
82int hts221_init(hts221_t *dev, const hts221_params_t *params);
83
91int hts221_reboot(const hts221_t *dev);
92
100int hts221_one_shot(const hts221_t *dev);
101
110int hts221_set_rate(const hts221_t *dev, const uint8_t rate);
111
119int hts221_power_on(const hts221_t *dev);
120
129
139
148int hts221_read_humidity(const hts221_t *dev, uint16_t *val);
149
158int hts221_read_temperature(const hts221_t *dev, int16_t *val);
159
160#ifdef __cplusplus
161}
162#endif
163
int hts221_power_off(const hts221_t *dev)
Set device to power down.
int hts221_read_humidity(const hts221_t *dev, uint16_t *val)
Reading humidity and temperature.
int hts221_init(hts221_t *dev, const hts221_params_t *params)
Initialize the given HTS221 device.
int hts221_reboot(const hts221_t *dev)
Reboot device and reload base configuration.
int hts221_read_temperature(const hts221_t *dev, int16_t *val)
Reading humidity and temperature.
int hts221_set_rate(const hts221_t *dev, const uint8_t rate)
Set device to continuous measurements.
int hts221_power_on(const hts221_t *dev)
Set device to active.
int hts221_one_shot(const hts221_t *dev)
Set device to one shot measurement.
int hts221_get_state(const hts221_t *dev)
Set device to power down.
uint_fast8_t i2c_t
Default i2c_t type definition.
Definition i2c.h:155
Register definitions for ST HTS221 devices.
Low-level I2C peripheral driver interface definition.
Parameters needed for device initialization.
Definition hts221.h:40
i2c_t i2c
bus the device is connected to
Definition hts221.h:41
uint8_t avgx
average sampling of humidity and temperature
Definition hts221.h:43
uint8_t rate
output data rate
Definition hts221.h:44
uint8_t addr
address on that bus
Definition hts221.h:42
Device descriptor for HTS221 sensors.
Definition hts221.h:60
int16_t h0_t0_out
lower humitidy to temperature reference
Definition hts221.h:64
int16_t t1_degc
upper temperature reference in degC
Definition hts221.h:67
int16_t t0_degc
lower temperature reference in degC
Definition hts221.h:66
int16_t t1_out
upper temperature reference raw value
Definition hts221.h:69
int16_t h1_t0_out
upper humitidy to temperature reference
Definition hts221.h:65
int16_t t0_out
lower temperature reference raw value
Definition hts221.h:68
int16_t h0_rh
lower humitidy reference
Definition hts221.h:62
int16_t h1_rh
upper humitidy reference
Definition hts221.h:63
hts221_params_t p
Configuration parameters.
Definition hts221.h:61