lis2dw driver: add stationary/motion detection
This commit is contained in:
parent
e34925139f
commit
dc40cc9cd1
@ -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);
|
||||
|
||||
@ -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);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user