Modified for BG96
Fork of mbed-dev by
Diff: targets/TARGET_STM/sleep.c
- Revision:
- 180:96ed750bd169
- Parent:
- 172:7d866c31b3c5
- Child:
- 181:57724642e740
--- a/targets/TARGET_STM/sleep.c Thu Dec 07 14:01:42 2017 +0000 +++ b/targets/TARGET_STM/sleep.c Wed Jan 17 15:23:54 2018 +0000 @@ -68,16 +68,16 @@ #if TARGET_STM32L4 int pwrClockEnabled = __HAL_RCC_PWR_IS_CLK_ENABLED(); int lowPowerModeEnabled = PWR->CR1 & PWR_CR1_LPR; - + if (!pwrClockEnabled) { __HAL_RCC_PWR_CLK_ENABLE(); } if (lowPowerModeEnabled) { HAL_PWREx_DisableLowPowerRunMode(); } - + HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI); - + if (lowPowerModeEnabled) { HAL_PWREx_EnableLowPowerRunMode(); } @@ -101,8 +101,15 @@ TimMasterHandle.Instance = TIM_MST; __HAL_TIM_SET_COUNTER(&TimMasterHandle, EnterTimeUS); -#if DEVICE_LOWPOWERTIMER - rtc_synchronize(); +#if DEVICE_RTC + /* Wait for RTC RSF bit synchro if RTC is configured */ +#if (TARGET_STM32F2) || (TARGET_STM32F4) || (TARGET_STM32F7) + if (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL)) { +#else /* (TARGET_STM32F2) || (TARGET_STM32F4) || (TARGET_STM32F7) */ + if (__HAL_RCC_GET_RTC_SOURCE()) { +#endif /* (TARGET_STM32F2) || (TARGET_STM32F4) || (TARGET_STM32F7) */ + rtc_synchronize(); + } #endif }