1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-26 09:28:13 +00:00

feat(core): add power button wakeup functionality

[no changelog]
This commit is contained in:
cepetr 2024-11-25 09:10:29 +01:00
parent 81f860e6f3
commit b8527e4f45
3 changed files with 19 additions and 6 deletions

View File

@ -21,6 +21,11 @@
#include <trezor_rtl.h>
#include <io/button.h>
#include <sys/irq.h>
#ifdef USE_POWERCTL
#include <sys/wakeup_flags.h>
#endif
#ifdef KERNEL_MODE
@ -89,7 +94,7 @@ bool button_init(void) {
EXTI_Config.Trigger = EXTI_TRIGGER_FALLING;
HAL_EXTI_SetConfigLine(&EXTI_Handle, &EXTI_Config);
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);
#endif // BTN_EXTI_INTERRUPT_HANDLER
@ -180,10 +185,12 @@ void BTN_EXTI_INTERRUPT_HANDLER(void) {
// button_driver_t *drv = &g_button_driver;
// 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
// wakeup_flags_set(WAKEUP_FLAGS_BUTTON);
wakeup_flags_set(WAKEUP_FLAG_BUTTON);
#endif
}
#endif

View File

@ -6,6 +6,11 @@
#define BTN_POWER_PIN GPIO_PIN_5
#define BTN_POWER_PORT GPIOE
#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

View File

@ -48,10 +48,8 @@ def configure(
defines += [("USE_BACKLIGHT", "1")]
if "input" in features_wanted:
sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"]
sources += ["embed/io/touch/ft6x36/ft6x36.c"]
sources += ["embed/io/touch/ft6x36/panels/lhs200kb-if21.c"]
paths += ["embed/io/i2c_bus/inc"]
paths += ["embed/io/touch/inc"]
features_available.append("touch")
sources += ["embed/io/button/stm32/button.c"]
@ -59,10 +57,13 @@ def configure(
features_available.append("button")
defines += [
("USE_TOUCH", "1"),
("USE_I2C", "1"),
("USE_BUTTON", "1"),
]
sources += ["embed/io/i2c_bus/stm32u5/i2c_bus.c"]
paths += ["embed/io/i2c_bus/inc"]
defines += [("USE_I2C", "1")]
if "haptic" in features_wanted:
sources += [
"embed/io/haptic/drv2625/drv2625.c",