lis2dw driver: add stationary/motion detection

This commit is contained in:
joeycastillo 2024-10-19 14:54:33 -04:00
parent e34925139f
commit dc40cc9cd1
2 changed files with 16 additions and 0 deletions

View File

@ -218,6 +218,16 @@ void lis2dw_disable_sleep(void) {
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS, configuration & ~LIS2DW_WAKE_UP_THS_VAL_SLEEP_ON);
}
void lis2dw_enable_stationary_motion_detection(void) {
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_DUR);
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_DUR, configuration | LIS2DW_WAKE_UP_DUR_STATIONARY);
}
void lis2dw_disable_stationary_motion_detection(void) {
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_DUR);
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_DUR, configuration & ~LIS2DW_WAKE_UP_DUR_STATIONARY);
}
void lis2dw_enable_tap_detection(void) {
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS);
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_THS, configuration | LIS2DW_WAKE_UP_THS_VAL_TAP_EVENT_ENABLED);

View File

@ -236,6 +236,8 @@ typedef enum {
#define LIS2DW_WAKE_UP_THS_VAL_SLEEP_ON 0b01000000
#define LIS2DW_REG_WAKE_UP_DUR 0x35
#define LIS2DW_WAKE_UP_DUR_STATIONARY 0b00010000
#define LIS2DW_REG_FREE_FALL 0x36
#define LIS2DW_REG_STATUS_DUP 0x37
@ -339,6 +341,10 @@ void lis2dw_enable_sleep(void);
void lis2dw_disable_sleep(void);
void lis2dw_enable_stationary_motion_detection(void);
void lis2dw_disable_stationary_motion_detection(void);
void lis2dw_enable_tap_detection(void);
void lis2dw_disable_tap_detection(void);