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

Merge pull request #14678 from dylad/cpu/saml1x/rtt-init-fix

cpu/saml1x: fix RTT issue in init process
This commit is contained in:
benpicco 2020-09-09 22:47:51 +02:00 committed by GitHub
commit be3667bfdd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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) {}