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;
210 #endif // _TWR_LIS2DH12_H 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_set_scale(twr_lis2dh12_t *self, twr_lis2dh12_scale_t scale)
Set scale.
twr_lis2dh12_resolution_t
Resolution and mode.
twr_lis2dh12_event_t
Callback events.
float threshold
Alarm threshold in g.
bool twr_lis2dh12_get_result_g(twr_lis2dh12_t *self, twr_lis2dh12_result_g_t *result_g)
Get measured acceleration in g.
struct twr_lis2dh12_t twr_lis2dh12_t
LIS2DH12 instance.
8-bit data output (Low-power mode)
bool twr_lis2dh12_set_alarm(twr_lis2dh12_t *self, twr_lis2dh12_alarm_t *alarm)
Enable or disable accelerometer threshold alarm.
LIS2DH12 result in raw values.
void twr_lis2dh12_set_update_interval(twr_lis2dh12_t *self, twr_tick_t interval)
Set measurement interval.
12-bit data output (High-resolution mode)
LIS2DH12 alarm set structure.
size_t twr_scheduler_task_id_t
Task ID assigned by scheduler.
bool twr_lis2dh12_init(twr_lis2dh12_t *self, twr_i2c_channel_t i2c_channel, uint8_t i2c_address)
Initialize LIS2DH12.
bool twr_lis2dh12_set_resolution(twr_lis2dh12_t *self, twr_lis2dh12_resolution_t resolution)
Set resolution.
uint64_t twr_tick_t
Timestamp data type.
10-bit data output (Normal mode) (Default)
twr_i2c_channel_t
I2C channels.
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_measure(twr_lis2dh12_t *self)
Start measurement manually.