1 #ifndef _TWR_LIS2DH12_H
2 #define _TWR_LIS2DH12_H
6 #include <twr_scheduler.h>
112 TWR_LIS2DH12_STATE_ERROR = -1,
113 TWR_LIS2DH12_STATE_INITIALIZE = 0,
114 TWR_LIS2DH12_STATE_MEASURE = 1,
115 TWR_LIS2DH12_STATE_READ = 2,
116 TWR_LIS2DH12_STATE_UPDATE = 3
118 } twr_lis2dh12_state_t;
123 uint8_t _i2c_address;
127 twr_lis2dh12_state_t _state;
128 bool _accelerometer_valid;
134 bool _measurement_active;
twr_i2c_channel_t
I2C channels.
twr_lis2dh12_resolution_t
Resolution and mode.
void twr_lis2dh12_set_event_handler(twr_lis2dh12_t *self, void(*event_handler)(twr_lis2dh12_t *, twr_lis2dh12_event_t, void *), void *event_param)
Set callback function.
bool twr_lis2dh12_measure(twr_lis2dh12_t *self)
Start measurement manually.
bool twr_lis2dh12_set_resolution(twr_lis2dh12_t *self, twr_lis2dh12_resolution_t resolution)
Set resolution.
twr_lis2dh12_event_t
Callback events.
void twr_lis2dh12_set_update_interval(twr_lis2dh12_t *self, twr_tick_t interval)
Set measurement interval.
bool twr_lis2dh12_init(twr_lis2dh12_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize LIS2DH12.
struct twr_lis2dh12_t twr_lis2dh12_t
LIS2DH12 instance.
bool twr_lis2dh12_get_result_g(twr_lis2dh12_t *self, twr_lis2dh12_result_g_t *result_g)
Get measured acceleration in g.
bool twr_lis2dh12_get_result_raw(twr_lis2dh12_t *self, twr_lis2dh12_result_raw_t *result_raw)
Get measured acceleration as raw value.
bool twr_lis2dh12_set_scale(twr_lis2dh12_t *self, twr_lis2dh12_scale_t scale)
Set scale.
bool twr_lis2dh12_set_alarm(twr_lis2dh12_t *self, twr_lis2dh12_alarm_t *alarm)
Enable or disable accelerometer threshold alarm.
@ TWR_LIS2DH12_RESOLUTION_12BIT
12-bit data output (High-resolution mode)
@ TWR_LIS2DH12_RESOLUTION_10BIT
10-bit data output (Normal mode) (Default)
@ TWR_LIS2DH12_RESOLUTION_8BIT
8-bit data output (Low-power mode)
@ TWR_LIS2DH12_EVENT_ALARM
Alarm event.
@ TWR_LIS2DH12_EVENT_ERROR
Error event.
@ TWR_LIS2DH12_EVENT_UPDATE
Update event.
@ TWR_LIS2DH12_SCALE_4G
±4 g.
@ TWR_LIS2DH12_SCALE_16G
±16 g.
@ TWR_LIS2DH12_SCALE_8G
±8 g.
@ TWR_LIS2DH12_SCALE_2G
±2 g (Default)
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
uint64_t twr_tick_t
Timestamp data type.
LIS2DH12 alarm set structure.
float threshold
Alarm threshold in g.
LIS2DH12 result in raw values.