implement INT2, accelerometer test shows sleep state on LED
This commit is contained in:
parent
9c0330f247
commit
dd8599a5e1
@ -36,6 +36,15 @@ void accel_interrupt_handler(void) {
|
||||
(*ptr_to_count)++;
|
||||
}
|
||||
|
||||
void sleep_interrupt_handler(void);
|
||||
void sleep_interrupt_handler(void) {
|
||||
if (HAL_GPIO_A3_read()) {
|
||||
movement_force_led_on(255, 0, 0);
|
||||
} else {
|
||||
movement_force_led_on(0, 255, 0);
|
||||
}
|
||||
}
|
||||
|
||||
static void _accel_interrupt_count_face_update_display(accel_interrupt_count_state_t *state) {
|
||||
char buf[7];
|
||||
|
||||
@ -56,7 +65,8 @@ static void _accel_interrupt_count_face_update_display(accel_interrupt_count_sta
|
||||
static void _accel_interrupt_count_face_configure_threshold(uint8_t threshold) {
|
||||
lis2dw_enable_sleep();
|
||||
lis2dw_configure_wakeup_threshold(threshold);
|
||||
lis2dw_configure_int1(LIS2DW_CTRL4_INT1_WU);
|
||||
// lis2dw_configure_int1(LIS2DW_CTRL4_INT1_WU);
|
||||
lis2dw_configure_int2(LIS2DW_CTRL5_INT2_SLEEP_CHG);
|
||||
lis2dw_enable_interrupts();
|
||||
}
|
||||
|
||||
@ -92,6 +102,7 @@ void accel_interrupt_count_face_activate(void *context) {
|
||||
|
||||
state->running = true;
|
||||
watch_register_interrupt_callback(HAL_GPIO_A4_pin(), accel_interrupt_handler, INTERRUPT_TRIGGER_RISING);
|
||||
watch_register_interrupt_callback(HAL_GPIO_A3_pin(), sleep_interrupt_handler, INTERRUPT_TRIGGER_BOTH);
|
||||
}
|
||||
|
||||
bool accel_interrupt_count_face_loop(movement_event_t event, void *context) {
|
||||
|
||||
@ -237,6 +237,10 @@ void lis2dw_configure_int1(uint8_t sources) {
|
||||
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL4_INT1, sources);
|
||||
}
|
||||
|
||||
void lis2dw_configure_int2(uint8_t sources) {
|
||||
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL5_INT2, sources);
|
||||
}
|
||||
|
||||
void lis2dw_enable_interrupts(void) {
|
||||
uint8_t configuration = watch_i2c_read8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7);
|
||||
watch_i2c_write8(LIS2DW_ADDRESS, LIS2DW_REG_CTRL7, configuration | LIS2DW_CTRL7_VAL_INTERRUPTS_ENABLE);
|
||||
|
||||
@ -347,6 +347,8 @@ void lis2dw_configure_wakeup_threshold(uint8_t threshold);
|
||||
|
||||
void lis2dw_configure_int1(uint8_t sources);
|
||||
|
||||
void lis2dw_configure_int2(uint8_t sources);
|
||||
|
||||
void lis2dw_enable_interrupts(void);
|
||||
|
||||
void lis2dw_disable_interrupts(void);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user