Firmware SDK
|
Driver for LIS2DH12 3-axis MEMS accelerometer. More...
Data Structures | |
struct | twr_lis2dh12_result_raw_t |
LIS2DH12 result in raw values. More... | |
struct | twr_lis2dh12_result_g_t |
LIS2DH12 result in g. More... | |
struct | twr_lis2dh12_alarm_t |
LIS2DH12 alarm set structure. More... | |
Typedefs | |
typedef struct twr_lis2dh12_t | twr_lis2dh12_t |
LIS2DH12 instance. | |
Enumerations | |
enum | twr_lis2dh12_event_t { TWR_LIS2DH12_EVENT_ERROR = 0 , TWR_LIS2DH12_EVENT_UPDATE = 1 , TWR_LIS2DH12_EVENT_ALARM = 2 } |
Callback events. More... | |
enum | twr_lis2dh12_resolution_t { TWR_LIS2DH12_RESOLUTION_10BIT = 0 , TWR_LIS2DH12_RESOLUTION_12BIT = 1 , TWR_LIS2DH12_RESOLUTION_8BIT = 2 } |
Resolution and mode. More... | |
enum | twr_lis2dh12_scale_t { TWR_LIS2DH12_SCALE_2G = 0 , TWR_LIS2DH12_SCALE_4G = 1 , TWR_LIS2DH12_SCALE_8G = 2 , TWR_LIS2DH12_SCALE_16G = 3 } |
Driver for LIS2DH12 3-axis MEMS accelerometer.
enum twr_lis2dh12_event_t |
Callback events.
Enumerator | |
---|---|
TWR_LIS2DH12_EVENT_ERROR | Error event. |
TWR_LIS2DH12_EVENT_UPDATE | Update event. |
TWR_LIS2DH12_EVENT_ALARM | Alarm event. |
Definition at line 14 of file twr_lis2dh12.h.
Resolution and mode.
Definition at line 29 of file twr_lis2dh12.h.
enum twr_lis2dh12_scale_t |
Enumerator | |
---|---|
TWR_LIS2DH12_SCALE_2G | ±2 g (Default) |
TWR_LIS2DH12_SCALE_4G | ±4 g. |
TWR_LIS2DH12_SCALE_8G | ±8 g. |
TWR_LIS2DH12_SCALE_16G | ±16 g. |
Definition at line 42 of file twr_lis2dh12.h.
bool twr_lis2dh12_get_result_g | ( | twr_lis2dh12_t * | self, |
twr_lis2dh12_result_g_t * | result_g | ||
) |
Get measured acceleration in g.
[in] | self | Instance |
[in] | result_g | Pointer to structure where result will be stored |
Definition at line 100 of file twr_lis2dh12.c.
bool twr_lis2dh12_get_result_raw | ( | twr_lis2dh12_t * | self, |
twr_lis2dh12_result_raw_t * | result_raw | ||
) |
Get measured acceleration as raw value.
[in] | self | Instance |
[in] | result_raw | Pointer to structure where result will be stored |
Definition at line 93 of file twr_lis2dh12.c.
Referenced by twr_lis2dh12_get_result_g().
bool twr_lis2dh12_init | ( | twr_lis2dh12_t * | self, |
twr_i2c_channel_t | i2c_channel, | ||
uint8_t | i2c_address | ||
) |
Initialize LIS2DH12.
[in] | self | Instance |
[in] | i2c_channel | I2C channel |
[in] | i2c_address | I2C device address |
Definition at line 33 of file twr_lis2dh12.c.
bool twr_lis2dh12_measure | ( | twr_lis2dh12_t * | self | ) |
Start measurement manually.
[in] | self | Instance |
Definition at line 79 of file twr_lis2dh12.c.
Referenced by twr_lis2dh12_set_alarm(), and twr_lis2dh12_set_update_interval().
bool twr_lis2dh12_set_alarm | ( | twr_lis2dh12_t * | self, |
twr_lis2dh12_alarm_t * | alarm | ||
) |
Enable or disable accelerometer threshold alarm.
[in] | self | Instance |
[in] | alarm | Pointer to structure with alarm configuration, if null then disable the alarm |
Definition at line 308 of file twr_lis2dh12.c.
void twr_lis2dh12_set_event_handler | ( | twr_lis2dh12_t * | self, |
void(*)(twr_lis2dh12_t *, twr_lis2dh12_event_t, void *) | event_handler, | ||
void * | event_param | ||
) |
Set callback function.
[in] | self | Instance |
[in] | event_handler | Function address |
[in] | event_param | Optional event parameter (can be NULL) |
Definition at line 57 of file twr_lis2dh12.c.
bool twr_lis2dh12_set_resolution | ( | twr_lis2dh12_t * | self, |
twr_lis2dh12_resolution_t | resolution | ||
) |
Set resolution.
[in] | self | Instance |
[in] | resolution |
Definition at line 400 of file twr_lis2dh12.c.
bool twr_lis2dh12_set_scale | ( | twr_lis2dh12_t * | self, |
twr_lis2dh12_scale_t | scale | ||
) |
Set scale.
[in] | self | Instance |
[in] | scale |
Definition at line 411 of file twr_lis2dh12.c.
void twr_lis2dh12_set_update_interval | ( | twr_lis2dh12_t * | self, |
twr_tick_t | interval | ||
) |
Set measurement interval.
[in] | self | Instance |
[in] | interval | Measurement interval |
Definition at line 63 of file twr_lis2dh12.c.