1
0
mirror of https://github.com/arduino-libraries/ArduinoLowPower.git synced 2025-04-19 11:42:14 +03:00

Fix SysTick timer lockup when waking from sleep (#17)

* fix SysTick timer lockup when waking from sleep
This commit is contained in:
sslupsky 2019-05-14 01:56:55 -06:00 committed by Martino Facchin
parent 4caff779d9
commit 892594adbc

View File

@ -23,9 +23,13 @@ void ArduinoLowPowerClass::sleep() {
USBDevice.detach(); USBDevice.detach();
restoreUSBDevice = true; restoreUSBDevice = true;
} }
// Disable systick interrupt: See https://www.avrfreaks.net/forum/samd21-samd21e16b-sporadically-locks-and-does-not-wake-standby-sleep-mode
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk; SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__DSB(); __DSB();
__WFI(); __WFI();
// Enable systick interrupt
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
if (restoreUSBDevice) { if (restoreUSBDevice) {
USBDevice.attach(); USBDevice.attach();
} }