Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_hdc2080.h
1 #ifndef _BC_HDC2080_H
2 #define _BC_HDC2080_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_hdc2080_t bc_hdc2080_t;
26 
28 
29 typedef enum
30 {
31  BC_HDC2080_STATE_ERROR = -1,
32  BC_HDC2080_STATE_INITIALIZE = 0,
33  BC_HDC2080_STATE_MEASURE = 1,
34  BC_HDC2080_STATE_READ = 2,
35  BC_HDC2080_STATE_UPDATE = 3
36 
37 } bc_hdc2080_state_t;
38 
39 struct bc_hdc2080_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_hdc2080_t *, bc_hdc2080_event_t, void *);
46  void *_event_param;
47  bool _measurement_active;
48  bc_tick_t _update_interval;
49  bc_hdc2080_state_t _state;
50  bc_tick_t _tick_ready;
51  bool _humidity_valid;
52  bool _temperature_valid;
53  uint16_t _reg_humidity;
54  uint16_t _reg_temperature;
55 };
56 
58 
63 
64 void bc_hdc2080_init(bc_hdc2080_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
65 
70 
71 void bc_hdc2080_set_event_handler(bc_hdc2080_t *self, void (*event_handler)(bc_hdc2080_t *, bc_hdc2080_event_t, void *), void *event_param);
72 
76 
78 
83 
85 
91 
92 bool bc_hdc2080_get_humidity_raw(bc_hdc2080_t *self, uint16_t *raw);
93 
99 
100 bool bc_hdc2080_get_humidity_percentage(bc_hdc2080_t *self, float *percentage);
101 
107 
108 bool bc_hdc2080_get_temperature_raw(bc_hdc2080_t *self, uint16_t *raw);
109 
115 
116 bool bc_hdc2080_get_temperature_celsius(bc_hdc2080_t *self, float *celsius);
117 
119 
120 #endif // _BC_HDC2080_H
void bc_hdc2080_init(bc_hdc2080_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize HDC2080.
Definition: bc_hdc2080.c:12
struct bc_hdc2080_t bc_hdc2080_t
HDC2080 instance.
Definition: bc_hdc2080.h:25
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
bc_hdc2080_event_t
Callback events.
Definition: bc_hdc2080.h:13
void bc_hdc2080_set_event_handler(bc_hdc2080_t *self, void(*event_handler)(bc_hdc2080_t *, bc_hdc2080_event_t, void *), void *event_param)
Set callback function.
Definition: bc_hdc2080.c:27
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
Error event.
Definition: bc_hdc2080.h:16
bool bc_hdc2080_get_humidity_raw(bc_hdc2080_t *self, uint16_t *raw)
Get measured humidity as raw value.
Definition: bc_hdc2080.c:63
bool bc_hdc2080_get_humidity_percentage(bc_hdc2080_t *self, float *percentage)
Get measured humidity as percentage.
Definition: bc_hdc2080.c:75
bool bc_hdc2080_measure(bc_hdc2080_t *self)
Start measurement manually.
Definition: bc_hdc2080.c:49
Update event.
Definition: bc_hdc2080.h:19
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bool bc_hdc2080_get_temperature_raw(bc_hdc2080_t *self, uint16_t *raw)
Get measured temperature as raw value.
Definition: bc_hdc2080.c:94
bool bc_hdc2080_get_temperature_celsius(bc_hdc2080_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
Definition: bc_hdc2080.c:106
void bc_hdc2080_set_update_interval(bc_hdc2080_t *self, bc_tick_t interval)
Set measurement interval.
Definition: bc_hdc2080.c:33