mirror of https://github.com/ARMmbed/mbed-os.git
STM: Fix us_ticker timestamp after deep sleep
Use the `mbed_sdk_inited` flag to correct the `HAL_GetTick()` behavior after waking up from deep sleep mode. `ticker_read_us()` must not be used to read us_ticker timestamp after waking up until the us_ticker context is restored. More detailed description in issue #8117. Fixes #8117pull/8136/head
parent
2e5e23f7c1
commit
6821556b47
|
@ -158,6 +158,7 @@ void hal_sleep(void)
|
|||
}
|
||||
|
||||
extern int serial_is_tx_ongoing(void);
|
||||
extern int mbed_sdk_inited;
|
||||
|
||||
void hal_deepsleep(void)
|
||||
{
|
||||
|
@ -200,6 +201,10 @@ void hal_deepsleep(void)
|
|||
HAL_PWR_EnterSTOPMode(PWR_LOWPOWERREGULATOR_ON, PWR_STOPENTRY_WFI);
|
||||
#endif /* TARGET_STM32L4 */
|
||||
|
||||
/* Prevent HAL_GetTick() from using ticker_read_us() to read the
|
||||
* us_ticker timestamp until the us_ticker context is restored. */
|
||||
mbed_sdk_inited = 0;
|
||||
|
||||
// Verify Clock Out of Deep Sleep
|
||||
ForceClockOutofDeepSleep();
|
||||
|
||||
|
@ -214,6 +219,10 @@ void hal_deepsleep(void)
|
|||
|
||||
restore_timer_ctx();
|
||||
|
||||
/* us_ticker context restored, allow HAL_GetTick() to read the us_ticker
|
||||
* timestamp via ticker_read_us() again. */
|
||||
mbed_sdk_inited = 1;
|
||||
|
||||
// Enable IRQs
|
||||
core_util_critical_section_exit();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue