From b8527e4f4505e2a935bb7a571fb943c505d0df87 Mon Sep 17 00:00:00 2001 From: cepetr Date: Mon, 25 Nov 2024 09:10:29 +0100 Subject: [PATCH] feat(core): add power button wakeup functionality [no changelog] --- core/embed/io/button/stm32/button.c | 13 ++++++++++--- core/embed/models/T3W1/boards/trezor_t3w1_revA.h | 5 +++++ core/site_scons/models/T3W1/trezor_t3w1_revA.py | 7 ++++--- 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/core/embed/io/button/stm32/button.c b/core/embed/io/button/stm32/button.c index 55cdfc65e3..c80bcea958 100644 --- a/core/embed/io/button/stm32/button.c +++ b/core/embed/io/button/stm32/button.c @@ -21,6 +21,11 @@ #include #include +#include + +#ifdef USE_POWERCTL +#include +#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 diff --git a/core/embed/models/T3W1/boards/trezor_t3w1_revA.h b/core/embed/models/T3W1/boards/trezor_t3w1_revA.h index 6245945306..57173e8a38 100644 --- a/core/embed/models/T3W1/boards/trezor_t3w1_revA.h +++ b/core/embed/models/T3W1/boards/trezor_t3w1_revA.h @@ -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 diff --git a/core/site_scons/models/T3W1/trezor_t3w1_revA.py b/core/site_scons/models/T3W1/trezor_t3w1_revA.py index 0564ac7fa2..05e89c4613 100644 --- a/core/site_scons/models/T3W1/trezor_t3w1_revA.py +++ b/core/site_scons/models/T3W1/trezor_t3w1_revA.py @@ -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",