Firmware SDK
twr_module_infra_grid.h
1 #ifndef _TWR_MODULE_INFRA_GRID_H
2 #define _TWR_MODULE_INFRA_GRID_H
3 
4 #include <twr_i2c.h>
5 #include <twr_tca9534a.h>
6 #include <twr_scheduler.h>
7 
11 
13 
14 typedef enum
15 {
18 
21 
23 
25 
27 
29 
30 typedef enum
31 {
34 
37 
39 
41 
42 typedef enum
43 {
44  TWR_MODULE_INFRA_GRID_STATE_ERROR = -1,
45  TWR_MODULE_INFRA_GRID_STATE_INITIALIZE = 0,
46  TWR_MODULE_INFRA_GRID_STATE_MODE_CHANGE = 1,
47  TWR_MODULE_INFRA_GRID_STATE_POWER_UP = 2,
48  TWR_MODULE_INFRA_GRID_STATE_INITIAL_RESET = 3,
49  TWR_MODULE_INFRA_GRID_STATE_FLAG_RESET = 4,
50  TWR_MODULE_INFRA_GRID_STATE_MEASURE = 5,
51  TWR_MODULE_INFRA_GRID_STATE_READ = 6,
52  TWR_MODULE_INFRA_GRID_STATE_UPDATE = 7
53 
54 } twr_module_infra_grid_state_t;
55 
57 {
58  int16_t _sensor_data[64];
59 
60  twr_tca9534a_t _tca9534;
62  twr_i2c_channel_t _i2c_channel;
63  uint8_t _i2c_address;
64  twr_scheduler_task_id_t _task_id_interval;
65  twr_scheduler_task_id_t _task_id_measure;
66  void (*_event_handler)(twr_module_infra_grid_t *, twr_module_infra_grid_event_t, void *);
67  void *_event_param;
68  bool _measurement_active;
69  twr_tick_t _update_interval;
70  twr_module_infra_grid_state_t _state;
71  twr_tick_t _tick_ready;
72  bool _temperature_valid;
73 
74  bool _enable_sleep;
75  bool _cmd_sleep;
76 
77 };
78 
80 
83 
85 
90 
92 
96 
98 
103 
105 
110 
112 
116 
118 
122 
124 
128 
130 
132 
133 #endif // _TWR_MODULE_INFRA_GRID_H
twr_i2c_channel_t
I2C channels.
Definition: twr_i2c.h:16
twr_module_infra_grid_revision_t twr_module_infra_grid_get_revision(twr_module_infra_grid_t *self)
Get module revision.
bool twr_module_infra_grid_get_temperatures_celsius(twr_module_infra_grid_t *self, float *values)
Get measured temperature in degrees of Celsius as a array of float numbers.
void twr_module_infra_grid_set_update_interval(twr_module_infra_grid_t *self, twr_tick_t interval)
Set measurement interval.
float twr_module_infra_grid_read_thermistor(twr_module_infra_grid_t *self)
Read and return thermistor temperature sensor value.
twr_module_infra_grid_event_t
Callback events.
bool twr_module_infra_grid_measure(twr_module_infra_grid_t *self)
Start measurement manually.
twr_module_infra_grid_revision_t
Infragrid Module Revision.
void twr_module_infra_grid_init(twr_module_infra_grid_t *self)
Initialize Infra Grid Module.
bool twr_module_infra_grid_read_values(twr_module_infra_grid_t *self)
Read measured data from sensor to the buffer.
void twr_module_infra_grid_set_event_handler(twr_module_infra_grid_t *self, void(*event_handler)(twr_module_infra_grid_t *, twr_module_infra_grid_event_t, void *), void *event_param)
Set callback function.
struct twr_module_infra_grid_t twr_module_infra_grid_t
Infra Grid Module instance.
@ TWR_MODULE_INFRA_GRID_EVENT_UPDATE
Update event.
@ TWR_MODULE_INFRA_GRID_EVENT_ERROR
Error event.
@ TWR_MODULE_INFRA_GRID_REVISION_R1_1
Revision 1.1.
@ TWR_MODULE_INFRA_GRID_REVISION_R1_0
Revision 1.0.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: twr_scheduler.h:22
uint64_t twr_tick_t
Timestamp data type.
Definition: twr_tick.h:16
Pin state.
Definition: twr_tca9534a.h:43