Skip to content

Commit c4748e2

Browse files
authored
Merge pull request #2771 from svastm/fix_deepsleep_l4
STM32L4 - Update deepsleep implementation
2 parents 35a8b1f + 6d73dd3 commit c4748e2

File tree

1 file changed

+12
-2
lines changed
  • hal/targets/hal/TARGET_STM/TARGET_STM32L4

1 file changed

+12
-2
lines changed

hal/targets/hal/TARGET_STM/TARGET_STM32L4/sleep.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,18 @@ void deepsleep(void)
4848
// Stop HAL systick
4949
HAL_SuspendTick();
5050

51-
// Request to enter STOP mode with regulator in low power mode
52-
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
51+
// Request to enter STOP mode 1 with regulator in low power mode
52+
if (__HAL_RCC_PWR_IS_CLK_ENABLED()) {
53+
HAL_PWREx_EnableLowPowerRunMode();
54+
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
55+
HAL_PWREx_DisableLowPowerRunMode();
56+
} else {
57+
__HAL_RCC_PWR_CLK_ENABLE();
58+
HAL_PWREx_EnableLowPowerRunMode();
59+
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
60+
HAL_PWREx_DisableLowPowerRunMode();
61+
__HAL_RCC_PWR_CLK_DISABLE();
62+
}
5363

5464
// After wake-up from STOP reconfigure the PLL
5565
SetSysClock();

0 commit comments

Comments
 (0)