From 91e8d5ac644c4da3e5a99c4bb6004a9aecb8a70f Mon Sep 17 00:00:00 2001 From: rusefillc Date: Sat, 22 Jan 2022 16:50:58 -0500 Subject: [PATCH] https://github.com/rusefi/alphax-2chan/issues/22 --- .../boards/hellen/alphax-2chan/board_configuration.cpp | 8 ++++++++ firmware/config/boards/proteus/board_configuration.cpp | 2 +- firmware/hw_layer/ports/stm32/stm32_common.cpp | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp index a979ea18d3..3e7a90b4c8 100644 --- a/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp +++ b/firmware/config/boards/hellen/alphax-2chan/board_configuration.cpp @@ -185,3 +185,11 @@ void setSdCardConfigurationOverrides() { engineConfiguration->sdCardCsPin = H_SPI2_CS; engineConfiguration->is_enabled_spi_2 = true; } + +void boardPrepareForStandby() { + PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0 + PWR->CSR |= PWR_CSR_EWUP; //Enable Wakeup Pin for PA0 + + palSetPadMode(GPIOA, 0, PAL_MODE_INPUT); //Select Pin 0 on A Port - PA0, Wkup + palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_FALLING_EDGE); // Set PA0 to interrupt on rising edge +} diff --git a/firmware/config/boards/proteus/board_configuration.cpp b/firmware/config/boards/proteus/board_configuration.cpp index f054007315..50329798f3 100644 --- a/firmware/config/boards/proteus/board_configuration.cpp +++ b/firmware/config/boards/proteus/board_configuration.cpp @@ -224,7 +224,7 @@ void boardPrepareForStop() { #ifdef STM32F4XX // enable EXTI on PA0 - The only WKUP pin F4 has. PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0 - palSetPadMode(GPIOA, 0, PAL_MODE_INPUT); //Select Pin 0 on D Port - PA0, Wkup + palSetPadMode(GPIOA, 0, PAL_MODE_INPUT); //Select Pin 0 on A Port - PA0, Wkup palEnableLineEvent(PAL_LINE(GPIOA, 0), PAL_EVENT_MODE_RISING_EDGE); // Set PA0 to interrupt on rising edge #endif diff --git a/firmware/hw_layer/ports/stm32/stm32_common.cpp b/firmware/hw_layer/ports/stm32/stm32_common.cpp index 78c9fb7c7c..0bf9a3ce5d 100644 --- a/firmware/hw_layer/ports/stm32/stm32_common.cpp +++ b/firmware/hw_layer/ports/stm32/stm32_common.cpp @@ -807,6 +807,7 @@ void boardPreparePA0ForStandby() { #ifdef STM32F4XX PWR->CR |= PWR_CR_CWUF; //Clear Wakeup Pin flag for PA0 PWR->CSR |= PWR_CSR_EWUP; //Enable Wakeup Pin for PA0 + // why do we not enable PAL event like in boardPrepareForStop? #endif #ifdef STM32F7XX