mirror of https://github.com/ARMmbed/mbed-os.git
[STM32L4xx] 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
75bbc0a3e1
commit
f7120413ec
|
@ -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);
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
|
@ -32,28 +32,20 @@
|
|||
#if DEVICE_SLEEP
|
||||
|
||||
#include "cmsis.h"
|
||||
#include "hal_tick.h"
|
||||
|
||||
static TIM_HandleTypeDef TimMasterHandle;
|
||||
|
||||
void sleep(void)
|
||||
{
|
||||
// Disable HAL tick interrupt
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
__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)
|
||||
{
|
||||
// Disable HAL tick interrupt
|
||||
TimMasterHandle.Instance = TIM_MST;
|
||||
__HAL_TIM_DISABLE_IT(&TimMasterHandle, TIM_IT_CC2);
|
||||
// Stop HAL systick
|
||||
HAL_SuspendTick();
|
||||
|
||||
// Request to enter STOP mode with regulator in low power mode
|
||||
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
|
||||
|
@ -61,8 +53,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