1 #ifndef _TWR_MPL3115A2_H
2 #define _TWR_MPL3115A2_H
5 #include <twr_scheduler.h>
31 TWR_MPL3115A2_STATE_ERROR = -1,
32 TWR_MPL3115A2_STATE_INITIALIZE = 0,
33 TWR_MPL3115A2_STATE_MEASURE_ALTITUDE = 1,
34 TWR_MPL3115A2_STATE_READ_ALTITUDE = 2,
35 TWR_MPL3115A2_STATE_MEASURE_PRESSURE = 3,
36 TWR_MPL3115A2_STATE_READ_PRESSURE = 4,
37 TWR_MPL3115A2_STATE_UPDATE = 5
39 } twr_mpl3115a2_state_t;
49 bool _measurement_active;
51 twr_mpl3115a2_state_t _state;
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;
twr_i2c_channel_t
I2C channels.
void twr_mpl3115a2_init(twr_mpl3115a2_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize MPL3115A2.
bool twr_mpl3115a2_get_pressure_pascal(twr_mpl3115a2_t *self, float *pascal)
Get measured pressured in Pascal.
bool twr_mpl3115a2_measure(twr_mpl3115a2_t *self)
Start measurement manually.
void twr_mpl3115a2_set_event_handler(twr_mpl3115a2_t *self, void(*event_handler)(twr_mpl3115a2_t *, twr_mpl3115a2_event_t, void *), void *event_param)
Set callback function.
struct twr_mpl3115a2_t twr_mpl3115a2_t
MPL3115A2 instance.
twr_mpl3115a2_event_t
Callback events.
void twr_mpl3115a2_set_update_interval(twr_mpl3115a2_t *self, twr_tick_t interval)
Set measurement interval.
void twr_mpl3115a2_deinit(twr_mpl3115a2_t *self)
Deinitialize MPL3115A2.
bool twr_mpl3115a2_get_altitude_meter(twr_mpl3115a2_t *self, float *meter)
Get measured altitude in meters.
@ TWR_MPL3115A2_EVENT_ERROR
Error event.
@ TWR_MPL3115A2_EVENT_UPDATE
Update event.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
uint64_t twr_tick_t
Timestamp data type.