mirror of
https://github.com/joeycastillo/second-movement.git
synced 2026-02-04 10:35:28 +00:00
Explicitly set interrupt type to latched
This commit is contained in:
committed by
Alessandro Genova
parent
7526b30b3d
commit
c5fe350fa1
@ -284,12 +284,12 @@ static uint32_t _movement_get_accelerometer_events() {
|
||||
|
||||
if (int_src & LIS2DW_REG_ALL_INT_SRC_DOUBLE_TAP) {
|
||||
accelerometer_events |= 1 << EVENT_DOUBLE_TAP;
|
||||
printf("Double tap!\n");
|
||||
printf("Double tap!\r\n");
|
||||
}
|
||||
|
||||
if (int_src & LIS2DW_REG_ALL_INT_SRC_SINGLE_TAP) {
|
||||
accelerometer_events |= 1 << EVENT_SINGLE_TAP;
|
||||
printf("Single tap!\n");
|
||||
printf("Single tap!\r\n");
|
||||
}
|
||||
|
||||
return accelerometer_events;
|
||||
@ -1118,6 +1118,7 @@ void app_setup(void) {
|
||||
watch_register_interrupt_callback(HAL_GPIO_A3_pin(), cb_accelerometer_event, INTERRUPT_TRIGGER_RISING);
|
||||
|
||||
// Enable the interrupts...
|
||||
lis2dw_latched_interrupts();
|
||||
lis2dw_enable_interrupts();
|
||||
|
||||
// At first boot, this next line sets the accelerometer's sampling rate to 0, which is LIS2DW_DATA_RATE_POWERDOWN.
|
||||
|
||||
@ -425,6 +425,20 @@ void lis2dw_disable_interrupts(void) {
|
||||
#endif
|
||||
}
|
||||
|
||||
void lis2dw_pulsed_interrupts(void) {
|
||||
#ifdef I2C_SERCOM
|
||||
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7);
|
||||
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7, configuration | LIS2DW_CTRL7_VAL_DRDY_PULSED);
|
||||
#endif
|
||||
}
|
||||
|
||||
void lis2dw_latched_interrupts(void) {
|
||||
#ifdef I2C_SERCOM
|
||||
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7);
|
||||
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7, configuration & ~LIS2DW_CTRL7_VAL_DRDY_PULSED);
|
||||
#endif
|
||||
}
|
||||
|
||||
lis2dw_wakeup_source_t lis2dw_get_wakeup_source() {
|
||||
#ifdef I2C_SERCOM
|
||||
return (lis2dw_wakeup_source_t) watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_WAKE_UP_SRC);
|
||||
|
||||
@ -375,6 +375,10 @@ void lis2dw_enable_interrupts(void);
|
||||
|
||||
void lis2dw_disable_interrupts(void);
|
||||
|
||||
void lis2dw_pulsed_interrupts(void);
|
||||
|
||||
void lis2dw_latched_interrupts(void);
|
||||
|
||||
lis2dw_interrupt_source_t lis2dw_get_interrupt_source(void);
|
||||
|
||||
lis2dw_wakeup_source_t lis2dw_get_wakeup_source(void);
|
||||
|
||||
Reference in New Issue
Block a user