Firmware SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
bc_mpl3115a2.h
1 #ifndef _BC_MPL3115A2_H
2 #define _BC_MPL3115A2_H
3 
4 #include <bc_i2c.h>
5 #include <bc_scheduler.h>
6 
10 
12 
13 typedef enum
14 {
17 
20 
22 
24 
26 
28 
29 typedef enum
30 {
31  BC_MPL3115A2_STATE_ERROR = -1,
32  BC_MPL3115A2_STATE_INITIALIZE = 0,
33  BC_MPL3115A2_STATE_MEASURE_ALTITUDE = 1,
34  BC_MPL3115A2_STATE_READ_ALTITUDE = 2,
35  BC_MPL3115A2_STATE_MEASURE_PRESSURE = 3,
36  BC_MPL3115A2_STATE_READ_PRESSURE = 4,
37  BC_MPL3115A2_STATE_UPDATE = 5
38 
39 } bc_mpl3115a2_state_t;
40 
41 struct bc_mpl3115a2_t
42 {
43  bc_i2c_channel_t _i2c_channel;
44  uint8_t _i2c_address;
45  bc_scheduler_task_id_t _task_id_interval;
46  bc_scheduler_task_id_t _task_id_measure;
47  void (*_event_handler)(bc_mpl3115a2_t *, bc_mpl3115a2_event_t, void *);
48  void *_event_param;
49  bool _measurement_active;
50  bc_tick_t _update_interval;
51  bc_mpl3115a2_state_t _state;
52  bc_tick_t _tick_ready;
53  bool _altitude_valid;
54  bool _pressure_valid;
55  uint8_t _reg_out_p_msb_altitude;
56  uint8_t _reg_out_p_csb_altitude;
57  uint8_t _reg_out_p_lsb_altitude;
58  uint8_t _reg_out_t_msb_altitude;
59  uint8_t _reg_out_t_lsb_altitude;
60  uint8_t _reg_out_p_msb_pressure;
61  uint8_t _reg_out_p_csb_pressure;
62  uint8_t _reg_out_p_lsb_pressure;
63  uint8_t _reg_out_t_msb_pressure;
64  uint8_t _reg_out_t_lsb_pressure;
65 };
66 
68 
73 
74 void bc_mpl3115a2_init(bc_mpl3115a2_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address);
75 
80 
81 void bc_mpl3115a2_set_event_handler(bc_mpl3115a2_t *self, void (*event_handler)(bc_mpl3115a2_t *, bc_mpl3115a2_event_t, void *), void *event_param);
82 
86 
88 
93 
95 
101 
102 bool bc_mpl3115a2_get_altitude_meter(bc_mpl3115a2_t *self, float *meter);
103 
109 
110 bool bc_mpl3115a2_get_pressure_pascal(bc_mpl3115a2_t *self, float *pascal);
111 
113 
114 #endif // _BC_MPL3115A2_H
uint64_t bc_tick_t
Timestamp data type.
Definition: bc_tick.h:16
struct bc_mpl3115a2_t bc_mpl3115a2_t
MPL3115A2 instance.
Definition: bc_mpl3115a2.h:25
bool bc_mpl3115a2_get_pressure_pascal(bc_mpl3115a2_t *self, float *pascal)
Get measured pressured in Pascal.
Definition: bc_mpl3115a2.c:76
bc_mpl3115a2_event_t
Callback events.
Definition: bc_mpl3115a2.h:13
void bc_mpl3115a2_init(bc_mpl3115a2_t *self, bc_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize MPL3115A2.
Definition: bc_mpl3115a2.c:11
size_t bc_scheduler_task_id_t
Task ID assigned by scheduler.
Definition: bc_scheduler.h:18
bool bc_mpl3115a2_get_altitude_meter(bc_mpl3115a2_t *self, float *meter)
Get measured altitude in meters.
Definition: bc_mpl3115a2.c:62
bc_i2c_channel_t
I2C channels.
Definition: bc_i2c.h:15
void bc_mpl3115a2_set_event_handler(bc_mpl3115a2_t *self, void(*event_handler)(bc_mpl3115a2_t *, bc_mpl3115a2_event_t, void *), void *event_param)
Set callback function.
Definition: bc_mpl3115a2.c:26
bool bc_mpl3115a2_measure(bc_mpl3115a2_t *self)
Start measurement manually.
Definition: bc_mpl3115a2.c:48
void bc_mpl3115a2_set_update_interval(bc_mpl3115a2_t *self, bc_tick_t interval)
Set measurement interval.
Definition: bc_mpl3115a2.c:32