1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

cpu/saml1x: fix RTT issue in init process

RTT module may get stuck during the init process if the RTC was running from
a previous boot. Unsure we don't remove the peripheral clock during the CPU
init if RTC is active from a previous boot and add a workaround to disable
this module as it will be re-init at some point later by the auto_init module
or by the user's application.
This commit is contained in:
Dylan Laduranty 2020-07-31 23:15:06 +02:00 committed by dylad
parent 4a1c33c323
commit 35536233f9

View File

@ -135,9 +135,21 @@ void cpu_init(void)
#endif
#ifdef MODULE_PERIPH_GPIO
| MCLK_APBAMASK_PORT
#endif
#ifdef MODULE_PERIPH_RTC_RTT
| MCLK_APBAMASK_RTC
#endif
;
/* Disable the RTC module to prevent synchronization issues during CPU init
if the RTC was running from a previous boot (e.g wakeup from backup)
as the module will be re-init during the boot process */
if (RTC->MODE2.CTRLA.bit.ENABLE && IS_ACTIVE(MODULE_PERIPH_RTC_RTT)) {
while (RTC->MODE2.SYNCBUSY.reg) {}
RTC->MODE2.CTRLA.bit.ENABLE = 0;
while (RTC->MODE2.SYNCBUSY.reg) {}
}
/* Software reset the GCLK module to ensure it is re-initialized correctly */
GCLK->CTRLA.reg = GCLK_CTRLA_SWRST;
while (GCLK->CTRLA.reg & GCLK_CTRLA_SWRST) {}