mirror of
https://github.com/joeycastillo/gossamer.git
synced 2025-10-29 19:21:02 +00:00
sam d21: incorporate insights from Adafruit's Sleepydog library
This commit is contained in:
parent
1ff0cc58cf
commit
3b18ccb1f4
@ -211,6 +211,20 @@ bool set_cpu_frequency(uint32_t freq) {
|
||||
}
|
||||
|
||||
void _enter_standby_mode() {
|
||||
// Don't fully power down flash when in sleep
|
||||
NVMCTRL->CTRLB.bit.SLEEPPRM = NVMCTRL_CTRLB_SLEEPPRM_DISABLED_Val;
|
||||
|
||||
// Set deep sleep mode
|
||||
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
|
||||
|
||||
// Insight from Adafruit Sleepydog library: due to a hardware bug on the SAMD21,
|
||||
// the SysTick interrupts become active before the flash has powered up from
|
||||
// sleep, causing a hard fault. To prevent this the SysTick interrupts are disabled
|
||||
// before entering sleep mode.
|
||||
SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; // Disable SysTick interrupts
|
||||
|
||||
__DSB();
|
||||
__WFI();
|
||||
|
||||
SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; // Enable SysTick interrupts
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user