Skip to content

Commit 2e9cce6

Browse files
aurel32cfriedt
authored andcommitted
soc: arm: stm32wl: wakeup from stop clock selection based on sysclk
When exiting Stop mode, if system clock is MSI, MSI oscillator is selected as wakeup from stop clock; otherwise HSI16 oscillator is selected. It is otherwise reconfigured as MSI just after, but it slightly increases the wake-up time and power consumption. Signed-off-by: Aurelien Jarno <[email protected]>
1 parent 246ea73 commit 2e9cce6

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

soc/arm/st_stm32/stm32wl/power.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,24 @@
1515
#include <stm32wlxx_ll_rcc.h>
1616
#include <stm32wlxx_ll_system.h>
1717
#include <clock_control/clock_stm32_ll_common.h>
18+
#include <drivers/clock_control/stm32_clock_control.h>
1819

1920
#include <logging/log.h>
2021
LOG_MODULE_DECLARE(soc, CONFIG_SOC_LOG_LEVEL);
2122

23+
/* select MSI as wake-up system clock if configured, HSI otherwise */
24+
#if STM32_SYSCLK_SRC_MSI
25+
#define RCC_STOP_WAKEUPCLOCK_SELECTED LL_RCC_STOP_WAKEUPCLOCK_MSI
26+
#else
27+
#define RCC_STOP_WAKEUPCLOCK_SELECTED LL_RCC_STOP_WAKEUPCLOCK_HSI
28+
#endif
29+
2230
/* Invoke Low Power/System Off specific Tasks */
2331
__weak void pm_power_state_set(struct pm_state_info info)
2432
{
2533
switch (info.state) {
2634
case PM_STATE_SUSPEND_TO_IDLE:
27-
LL_RCC_SetClkAfterWakeFromStop(LL_RCC_STOP_WAKEUPCLOCK_HSI);
35+
LL_RCC_SetClkAfterWakeFromStop(RCC_STOP_WAKEUPCLOCK_SELECTED);
2836
LL_PWR_ClearFlag_WU();
2937
switch (info.substate_id) {
3038
case 1:

0 commit comments

Comments
 (0)