From 0b430cba4eb873b15bf38fb78d331b31b98c3f84 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Wed, 3 Apr 2024 19:07:30 +0800 Subject: [PATCH] try standby mode --- Core/Src/stm32_lpm_if.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index 66c1338..9d98b45 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -78,14 +78,30 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver = void PWR_EnterOffMode(void) { /* USER CODE BEGIN EnterOffMode_1 */ + /* Enable Power Clock */ + HAL_SuspendTick(); + /* Disable all used wakeup sources: Pin1(PA.0) */ + HAL_PWR_DisableWakeUpPin(PWR_WAKEUP_PIN1|PWR_WAKEUP_PIN2|PWR_WAKEUP_PIN3); + + /* Clear all related wakeup flags */ + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); + + /* Re-enable all used wakeup sources: Pin1(PA.0) */ + HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1); + + /*## Enter Standby Mode ####################################################*/ + /* Request to enter STANDBY mode */ + HAL_PWR_EnterSTANDBYMode(); /* USER CODE END EnterOffMode_1 */ } void PWR_ExitOffMode(void) { /* USER CODE BEGIN ExitOffMode_1 */ - + //HAL_ResumeTick(); + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); /* USER CODE END ExitOffMode_1 */ }