1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-22 15:38:11 +00:00

feat(core): add power button wakeup functionality

[no changelog]
This commit is contained in:
cepetr 2024-11-20 16:24:20 +01:00
parent 5d64a67479
commit bf23f9ecd2
2 changed files with 15 additions and 3 deletions

View File

@ -21,6 +21,11 @@
#include <trezor_rtl.h> #include <trezor_rtl.h>
#include <io/button.h> #include <io/button.h>
#include <sys/irq.h>
#ifdef USE_POWERCTL
#include <sys/wakeup_flags.h>
#endif
#ifdef KERNEL_MODE #ifdef KERNEL_MODE
@ -89,7 +94,7 @@ bool button_init(void) {
EXTI_Config.Trigger = EXTI_TRIGGER_FALLING; EXTI_Config.Trigger = EXTI_TRIGGER_FALLING;
HAL_EXTI_SetConfigLine(&EXTI_Handle, &EXTI_Config); HAL_EXTI_SetConfigLine(&EXTI_Handle, &EXTI_Config);
NVIC_SetPriority(BTN_EXTI_INTERRUPT_NUM, IRQ_PRI_NORMAL); NVIC_SetPriority(BTN_EXTI_INTERRUPT_NUM, IRQ_PRI_NORMAL);
__HAL_GPIO_EXTI_CLEAR_FLAG(BTN_INT_PIN); __HAL_GPIO_EXTI_CLEAR_FLAG(BTN_EXTI_INTERRUPT_PIN);
NVIC_EnableIRQ(BTN_EXTI_INTERRUPT_NUM); NVIC_EnableIRQ(BTN_EXTI_INTERRUPT_NUM);
#endif // BTN_EXTI_INTERRUPT_HANDLER #endif // BTN_EXTI_INTERRUPT_HANDLER
@ -180,10 +185,12 @@ void BTN_EXTI_INTERRUPT_HANDLER(void) {
// button_driver_t *drv = &g_button_driver; // button_driver_t *drv = &g_button_driver;
// Clear the EXTI line pending bit // Clear the EXTI line pending bit
__HAL_GPIO_EXTI_CLEAR_FLAG(BTN_INT_PIN); __HAL_GPIO_EXTI_CLEAR_FLAG(BTN_EXTI_INTERRUPT_PIN);
#ifdef USE_POWERCTL
// Inform the powerctl module about button press // Inform the powerctl module about button press
// wakeup_flags_set(WAKEUP_FLAGS_BUTTON); wakeup_flags_set(WAKEUP_FLAG_BUTTON);
#endif
} }
#endif #endif

View File

@ -6,6 +6,11 @@
#define BTN_POWER_PIN GPIO_PIN_5 #define BTN_POWER_PIN GPIO_PIN_5
#define BTN_POWER_PORT GPIOE #define BTN_POWER_PORT GPIOE
#define BTN_POWER_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE #define BTN_POWER_CLK_ENA __HAL_RCC_GPIOE_CLK_ENABLE
#define BTN_EXTI_INTERRUPT_GPIOSEL EXTI_GPIOE
#define BTN_EXTI_INTERRUPT_LINE EXTI_LINE_5
#define BTN_EXTI_INTERRUPT_PIN GPIO_PIN_5
#define BTN_EXTI_INTERRUPT_NUM EXTI5_IRQn
#define BTN_EXTI_INTERRUPT_HANDLER EXTI5_IRQHandler
#define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565 #define DISPLAY_COLOR_MODE DMA2D_OUTPUT_RGB565