Modified for BG96

Fork of mbed-dev by mbed official

Revision:
156:95d6b41a828b
Parent:
154:37f96f9d4de2
Child:
160:d5399cc887bb
--- a/targets/TARGET_STM/sleep.c	Thu Jan 05 10:51:54 2017 +0000
+++ b/targets/TARGET_STM/sleep.c	Mon Jan 16 15:03:32 2017 +0000
@@ -52,7 +52,17 @@
 
     // Request to enter STOP mode with regulator in low power mode
 #if TARGET_STM32L4
-    HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
+    if (__HAL_RCC_PWR_IS_CLK_ENABLED()) {
+        HAL_PWREx_EnableLowPowerRunMode();
+        HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
+        HAL_PWREx_DisableLowPowerRunMode();
+    } else {
+        __HAL_RCC_PWR_CLK_ENABLE();
+        HAL_PWREx_EnableLowPowerRunMode();
+        HAL_PWREx_EnterSTOP2Mode(PWR_STOPENTRY_WFI);
+        HAL_PWREx_DisableLowPowerRunMode();
+        __HAL_RCC_PWR_CLK_DISABLE();
+    }
 #else /* TARGET_STM32L4 */
     HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
 #endif /* TARGET_STM32L4 */