Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_hts221.h
1 #ifndef _BC_HTS221_H
2 #define _BC_HTS221_H
3 
4 #include <bc_i2c.h>
5 #include <bc_scheduler.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
22 
24 
25 typedef struct bc_hts221_t bc_hts221_t;
26 
28 
29 typedef enum
30 {
31  BC_HTS221_STATE_ERROR = -1,
32  BC_HTS221_STATE_INITIALIZE = 0,
33  BC_HTS221_STATE_MEASURE = 1,
34  BC_HTS221_STATE_READ = 2,
35  BC_HTS221_STATE_UPDATE = 3
36 
37 } bc_hts221_state_t;
38 
39 struct bc_hts221_t
40 {
41  bc_i2c_channel_t _i2c_channel;
42  uint8_t _i2c_address;
43  bc_scheduler_task_id_t _task_id_interval;
44  bc_scheduler_task_id_t _task_id_measure;
45  void (*_event_handler)(bc_hts221_t *, bc_hts221_event_t, void *);
46  void *_event_param;
47  bool _measurement_active;
48  bc_tick_t _update_interval;
49  bc_hts221_state_t _state;
50  bc_tick_t _tick_ready;
51  bool _humidity_valid;
52  int16_t _reg_humidity;
53  int16_t _h0_rh;
54  int16_t _h0_t0_out;
55  float _h_grad;
56 };
57 
59 
64 
65 void bc_hts221_init(bc_hts221_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
66 
71 
72 void bc_hts221_set_event_handler(bc_hts221_t *self, void (*event_handler)(bc_hts221_t *, bc_hts221_event_t, void *), void *event_param);
73 
77 
79 
84 
85 bool bc_hts221_measure(bc_hts221_t *self);
86 
92 
93 bool bc_hts221_get_humidity_percentage(bc_hts221_t *self, float *percentage);
94 
96 
97 #endif // _BC_HTS221_H
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
bc_hts221_event_t
Callback events.
Definition: bc_hts221.h:13
Update event.
Definition: bc_hts221.h:19
void bc_hts221_set_update_interval(bc_hts221_t *self, bc_tick_t interval)
Set measurement interval.
Definition: bc_hts221.c:77
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
bool bc_hts221_measure(bc_hts221_t *self)
Start measurement manually.
Definition: bc_hts221.c:93
void bc_hts221_init(bc_hts221_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize HTS221.
Definition: bc_hts221.c:53
bool bc_hts221_get_humidity_percentage(bc_hts221_t *self, float *percentage)
Get measured humidity as percentage.
Definition: bc_hts221.c:107
Error event.
Definition: bc_hts221.h:16
struct bc_hts221_t bc_hts221_t
HTS221 instance.
Definition: bc_hts221.h:25
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
void bc_hts221_set_event_handler(bc_hts221_t *self, void(*event_handler)(bc_hts221_t *, bc_hts221_event_t, void *), void *event_param)
Set callback function.
Definition: bc_hts221.c:71