Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_tmp112.h
1 #ifndef _BC_TMP112_H
2 #define _BC_TMP112_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_tmp112_t bc_tmp112_t;
26 
28 
29 typedef enum
30 {
31  BC_TMP112_STATE_ERROR = -1,
32  BC_TMP112_STATE_INITIALIZE = 0,
33  BC_TMP112_STATE_MEASURE = 1,
34  BC_TMP112_STATE_READ = 2,
35  BC_TMP112_STATE_UPDATE = 3
36 
37 } bc_tmp112_state_t;
38 
39 struct bc_tmp112_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_tmp112_t *, bc_tmp112_event_t, void *);
46  void *_event_param;
47  bool _measurement_active;
48  bc_tick_t _update_interval;
49  bc_tmp112_state_t _state;
50  bc_tick_t _tick_ready;
51  bool _temperature_valid;
52  uint16_t _reg_temperature;
53 };
54 
56 
61 
62 void bc_tmp112_init(bc_tmp112_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
63 
64 
67 
68 void bc_tmp112_deinit(bc_tmp112_t *self);
69 
74 
75 void bc_tmp112_set_event_handler(bc_tmp112_t *self, void (*event_handler)(bc_tmp112_t *, bc_tmp112_event_t, void *), void *event_param);
76 
80 
82 
87 
88 bool bc_tmp112_measure(bc_tmp112_t *self);
89 
95 
96 bool bc_tmp112_get_temperature_raw(bc_tmp112_t *self, int16_t *raw);
97 
103 
104 bool bc_tmp112_get_temperature_celsius(bc_tmp112_t *self, float *celsius);
105 
111 
112 bool bc_tmp112_get_temperature_fahrenheit(bc_tmp112_t *self, float *fahrenheit);
113 
119 
120 bool bc_tmp112_get_temperature_kelvin(bc_tmp112_t *self, float *kelvin);
121 
123 
124 #endif // _BC_TMP112_H
void bc_tmp112_init(bc_tmp112_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize TMP112.
Definition: bc_tmp112.c:11
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
bc_tmp112_event_t
Callback events.
Definition: bc_tmp112.h:13
Update event.
Definition: bc_tmp112.h:19
bool bc_tmp112_get_temperature_fahrenheit(bc_tmp112_t *self, float *fahrenheit)
Get measured temperature in degrees of Fahrenheit.
Definition: bc_tmp112.c:97
void bc_tmp112_set_update_interval(bc_tmp112_t *self, bc_tick_t interval)
Set measurement interval.
Definition: bc_tmp112.c:41
struct bc_tmp112_t bc_tmp112_t
TMP112 instance.
Definition: bc_tmp112.h:25
Error event.
Definition: bc_tmp112.h:16
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
bool bc_tmp112_get_temperature_kelvin(bc_tmp112_t *self, float *kelvin)
Get measured temperature in kelvin.
Definition: bc_tmp112.c:111
bool bc_tmp112_get_temperature_celsius(bc_tmp112_t *self, float *celsius)
Get measured temperature in degrees of Celsius.
Definition: bc_tmp112.c:83
void bc_tmp112_set_event_handler(bc_tmp112_t *self, void(*event_handler)(bc_tmp112_t *, bc_tmp112_event_t, void *), void *event_param)
Set callback function.
Definition: bc_tmp112.c:35
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
bool bc_tmp112_measure(bc_tmp112_t *self)
Start measurement manually.
Definition: bc_tmp112.c:57
void bc_tmp112_deinit(bc_tmp112_t *self)
Deinitialize TMP112.
Definition: bc_tmp112.c:26
bool bc_tmp112_get_temperature_raw(bc_tmp112_t *self, int16_t *raw)
Get measured temperature as raw value.
Definition: bc_tmp112.c:71