Fixed a problem that the STOP2 was falling back to STOP1 because

the LPR was not turned on. Now the deepsleep mode only needs 1.6uA
instead of 10uA.
pull/3663/head
Helmut Tschemernjak 2017-01-31 11:44:41 +01:00
parent 450701f211
commit 605059e683
1 changed files with 11 additions and 8 deletions

View File

@ -52,17 +52,20 @@ void hal_deepsleep(void)
// Request to enter STOP mode with regulator in low power mode
#if TARGET_STM32L4
if (__HAL_RCC_PWR_IS_CLK_ENABLED()) {
HAL_PWREx_EnableLowPowerRunMode();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
HAL_PWREx_DisableLowPowerRunMode();
} else {
int pwrClockEnabled = __HAL_RCC_PWR_IS_CLK_ENABLED();
int lowPowerModeEnabled = PWR->CR1 & PWR_CR1_LPR;
if (!pwrClockEnabled)
__HAL_RCC_PWR_CLK_ENABLE();
HAL_PWREx_EnableLowPowerRunMode();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
if (lowPowerModeEnabled)
HAL_PWREx_DisableLowPowerRunMode();
HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
if (lowPowerModeEnabled)
HAL_PWREx_EnableLowPowerRunMode();
if (!pwrClockEnabled)
__HAL_RCC_PWR_CLK_DISABLE();
}
#else /* TARGET_STM32L4 */
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
#endif /* TARGET_STM32L4 */