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 */ }