mirror of https://github.com/ARMmbed/mbed-os.git
[STM32L1xx] Sleep API factorization
In order to enable sleep API factorization, HAL_Suspend/ResumeTick functions have been implemented in hal_tick.c for each platform.pull/2192/head
parent
34c37c8b94
commit
75bbc0a3e1
|
@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
|||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
|||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -107,6 +107,21 @@ HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) {
|
|||
return HAL_OK;
|
||||
}
|
||||
|
||||
void HAL_SuspendTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Disable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
|
||||
void HAL_ResumeTick(void)
|
||||
{
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
// Enable HAL tick and us_ticker update interrupts (used for 32 bit counter)
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
*******************************************************************************
|
||||
*/
|
||||
#include "sleep_api.h"
|
||||
#include "hal_tick.h"
|
||||
|
||||
#if DEVICE_SLEEP
|
||||
|
||||
|
@ -35,28 +36,24 @@
|
|||
|
||||
static TIM_HandleTypeDef TimMasterHandle;
|
||||
|
||||
void sleep(void)
|
||||
{
|
||||
// Disable HAL tick interrupt
|
||||
TimMasterHandle.Instance = TIM5;
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
|
||||
void sleep(void) {
|
||||
// Stop HAL systick
|
||||
HAL_SuspendTick();
|
||||
// Request to enter SLEEP mode
|
||||
HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI);
|
||||
|
||||
// Enable HAL tick interrupt
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
// Restart HAL systick
|
||||
HAL_ResumeTick();
|
||||
}
|
||||
|
||||
|
||||
void deepsleep(void)
|
||||
{
|
||||
#if defined(TARGET_MOTE_L152RC)
|
||||
int8_t STOPEntry = PWR_STOPENTRY_WFI;
|
||||
#endif
|
||||
|
||||
// Disable HAL tick interrupt
|
||||
TimMasterHandle.Instance = TIM5;
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
// Stop HAL systick
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
|
||||
#if defined(TARGET_MOTE_L152RC)
|
||||
/* Select the regulator state in Stop mode: Set PDDS and LPSDSR bit according to PWR_Regulator value */
|
||||
|
@ -91,8 +88,8 @@ void deepsleep(void)
|
|||
// After wake-up from STOP reconfigure the PLL
|
||||
SetSysClock();
|
||||
|
||||
// Enable HAL tick interrupt
|
||||
__HAL_TIM_ENABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
// Restart HAL systick
|
||||
HAL_ResumeTick();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue