diff --git a/core/embed/io/button/inc/io/button.h b/core/embed/io/button/inc/io/button.h index 4b69b2bd61..14a2259b11 100644 --- a/core/embed/io/button/inc/io/button.h +++ b/core/embed/io/button/inc/io/button.h @@ -49,6 +49,9 @@ typedef enum { // Returns true in case of success, false otherwise bool button_init(void); +// Deinitializes button driver +void button_deinit(void); + #endif // KERNEL_MODE // Get the last button event diff --git a/core/embed/io/button/stm32/button.c b/core/embed/io/button/stm32/button.c index c80bcea958..f22dec2dd8 100644 --- a/core/embed/io/button/stm32/button.c +++ b/core/embed/io/button/stm32/button.c @@ -22,6 +22,7 @@ #include #include +#include #ifdef USE_POWERCTL #include @@ -103,6 +104,12 @@ bool button_init(void) { return true; } +void button_deinit(void) { +#ifdef BTN_EXIT_INTERRUPT_HANDLER + NVIC_DisableIRQ(BTN_EXTI_INTERRUPT_NUM); +#endif +} + uint32_t button_get_event(void) { button_driver_t *drv = &g_button_driver; @@ -182,6 +189,9 @@ bool button_is_down(button_t button) { #ifdef BTN_EXTI_INTERRUPT_HANDLER void BTN_EXTI_INTERRUPT_HANDLER(void) { + IRQ_LOG_ENTER(); + mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT); + // button_driver_t *drv = &g_button_driver; // Clear the EXTI line pending bit @@ -191,6 +201,9 @@ void BTN_EXTI_INTERRUPT_HANDLER(void) { // Inform the powerctl module about button press wakeup_flags_set(WAKEUP_FLAG_BUTTON); #endif + + mpu_restore(mpu_mode); + IRQ_LOG_EXIT(); } #endif diff --git a/core/embed/projects/bootloader/main.c b/core/embed/projects/bootloader/main.c index 564a35fb06..2e4c495a7e 100644 --- a/core/embed/projects/bootloader/main.c +++ b/core/embed/projects/bootloader/main.c @@ -134,7 +134,9 @@ static void drivers_init(secbool *touch_initialized) { static void drivers_deinit(void) { #ifdef FIXED_HW_DEINIT - // TODO +#ifdef USE_BUTTON + button_deinit(); +#endif #endif gfx_bitblt_deinit(); display_deinit(DISPLAY_JUMP_BEHAVIOR);