From 506aed609d9cfe2c366443c94e7c98d2dec36672 Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Fri, 1 Mar 2024 16:02:02 +0800 Subject: [PATCH] try low power --- Core/Src/main.c | 7 +++---- Core/Src/stm32_lpm_if.c | 14 ++++++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Core/Src/main.c b/Core/Src/main.c index 151b3f4..f2085de 100644 --- a/Core/Src/main.c +++ b/Core/Src/main.c @@ -109,16 +109,15 @@ int main(void) MX_GPIO_Init(); MX_DMA_Init(); - MX_I2C2_Init(); + LED_ON; + MX_I2C2_Init(); MX_LoRaWAN_Init(); + /* USER CODE BEGIN 2 */ - - - /* USER CODE END 2 */ /* Infinite loop */ diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index bfa47d5..0743ca7 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -81,14 +81,24 @@ const struct UTIL_LPM_Driver_s UTIL_PowerDriver = void PWR_EnterOffMode(void) { /* USER CODE BEGIN EnterOffMode_1 */ - + HAL_SuspendTick(); + /* Clear Status Flag before entering STOP/STANDBY Mode */ + LL_PWR_ClearFlag_C1STOP_C1STB(); + //__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); + 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_SB); + __HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); + HAL_PWR_EnableBkUpAccess(); + __HAL_RCC_RTCAPB_CLK_ENABLE(); + */ /* USER CODE END ExitOffMode_1 */ }