Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: SANFAN_read_analog_value nucleo-wdg Nucleo_sleep_copy
Fork of mbed-src by
Diff: targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/sleep.c
- Revision:
- 489:119543c9f674
- Parent:
- 402:09075a3b15e3
--- a/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/sleep.c Thu Mar 05 13:15:07 2015 +0000
+++ b/targets/hal/TARGET_STM/TARGET_NUCLEO_F103RB/sleep.c Thu Mar 12 14:30:49 2015 +0000
@@ -32,35 +32,31 @@
#if DEVICE_SLEEP
#include "cmsis.h"
+#include "hal_tick.h"
+
+static TIM_HandleTypeDef TimMasterHandle;
void sleep(void)
{
- // Disable us_ticker update interrupt
- TIM_ITConfig(TIM1, TIM_IT_Update, DISABLE);
+ TimMasterHandle.Instance = TIM_MST;
+
+ // Disable HAL tick and us_ticker update interrupts
+ __HAL_TIM_DISABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
- SCB->SCR = 0; // Normal sleep mode for ARM core
- __WFI();
+ // Request to enter SLEEP mode
+ HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
- // Re-enable us_ticker update interrupt
- TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
+ // Enable HAL tick and us_ticker update interrupts
+ __HAL_TIM_ENABLE_IT(&TimMasterHandle, (TIM_IT_CC2 | TIM_IT_UPDATE));
}
void deepsleep(void)
{
- // Disable us_ticker update interrupt
- TIM_ITConfig(TIM1, TIM_IT_Update, DISABLE);
-
- // Enable PWR clock
- RCC_APB1PeriphClockCmd(RCC_APB1Periph_PWR, ENABLE);
-
// Request to enter STOP mode with regulator in low power mode
- PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
+ HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
// After wake-up from STOP reconfigure the PLL
SetSysClock();
-
- // Re-enable us_ticker update interrupt
- TIM_ITConfig(TIM1, TIM_IT_Update, ENABLE);
}
#endif
