From 617f7d4701d7a970b90f9330fc4c7149b8be414a Mon Sep 17 00:00:00 2001 From: YunHorn Technology Date: Thu, 7 Mar 2024 12:33:51 +0800 Subject: [PATCH] ADD STANDBY code --- Core/Inc/sys_conf.h | 6 +++--- Core/Src/stm32_lpm_if.c | 4 +++- Core/Src/sys_app.c | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Core/Inc/sys_conf.h b/Core/Inc/sys_conf.h index 16d0145..e75e803 100644 --- a/Core/Inc/sys_conf.h +++ b/Core/Inc/sys_conf.h @@ -47,12 +47,12 @@ extern "C" { /** * @brief Verbose level for all trace logs */ -#define VERBOSE_LEVEL VLEVEL_OFF +#define VERBOSE_LEVEL VLEVEL_H /** * @brief Enable trace logs */ -#define APP_LOG_ENABLED 0 +#define APP_LOG_ENABLED 1 /** * @brief Activate monitoring (probes) of some internal RF signals for debug purpose @@ -75,7 +75,7 @@ extern "C" { * @brief Enable/Disable MCU Debugger pins (dbg serial wires) * @note by HW serial wires are ON by default, need to put them OFF to save power */ -#define DEBUGGER_ENABLED 0 +#define DEBUGGER_ENABLED 1 /** * @brief Disable Low Power mode diff --git a/Core/Src/stm32_lpm_if.c b/Core/Src/stm32_lpm_if.c index 213b006..bab7243 100644 --- a/Core/Src/stm32_lpm_if.c +++ b/Core/Src/stm32_lpm_if.c @@ -80,6 +80,7 @@ void PWR_EnterOffMode(void) /* USER CODE BEGIN EnterOffMode_1 */ /* USER CODE END EnterOffMode_1 */ + HAL_SuspendTick(); //HAL_PWREx_EnableGPIOPullUp(PWR_GPIO_A, PWR_GPIO_BIT_0); //HAL_PWREx_EnablePullUpPullDownConfig(); /* USER CODE BEGIN EnterOffMode_2 */ @@ -89,13 +90,14 @@ void PWR_EnterOffMode(void) /* USER CODE BEGIN EnterOffMode_3 */ //HAL_PWR_EnableWakeUpPin(PWR_WAKEUP_PIN1_LOW); //__HAL_PWR_CLEAR_FLAG(PWR_FLAG_WU); - //HAL_PWR_EnterSTANDBYMode(); + HAL_PWR_EnterSTANDBYMode(); /* USER CODE END EnterOffMode_3 */ } void PWR_ExitOffMode(void) { /* USER CODE BEGIN ExitOffMode_1 */ + HAL_ResumeTick(); //__HAL_PWR_CLEAR_FLAG(PWR_FLAG_SB); /* USER CODE END ExitOffMode_1 */ } diff --git a/Core/Src/sys_app.c b/Core/Src/sys_app.c index f070666..8fac290 100644 --- a/Core/Src/sys_app.c +++ b/Core/Src/sys_app.c @@ -121,7 +121,7 @@ void SystemApp_Init(void) /*Init low power manager*/ UTIL_LPM_Init(); /* Disable Stand-by mode */ - UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE); + //UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_DISABLE); //UTIL_LPM_SetOffMode((1 << CFG_LPM_APPLI_Id), UTIL_LPM_ENABLE); #if defined (LOW_POWER_DISABLE) && (LOW_POWER_DISABLE == 1)