Skip to content

Commit 6e29472

Browse files
committed
Added support for crystalless D21
1 parent ac98e3d commit 6e29472

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/RTCZero.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,11 @@ void RTCZero::configureClock() {
449449
GCLK->GENDIV.reg = GCLK_GENDIV_ID(2)|GCLK_GENDIV_DIV(4);
450450
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY)
451451
;
452+
#ifdef CRYSTALLESS
453+
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_OSCULP32K | GCLK_GENCTRL_ID(2) | GCLK_GENCTRL_DIVSEL );
454+
#else
452455
GCLK->GENCTRL.reg = (GCLK_GENCTRL_GENEN | GCLK_GENCTRL_SRC_XOSC32K | GCLK_GENCTRL_ID(2) | GCLK_GENCTRL_DIVSEL );
456+
#endif
453457
while (GCLK->STATUS.reg & GCLK_STATUS_SYNCBUSY)
454458
;
455459
GCLK->CLKCTRL.reg = (uint32_t)((GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK2 | (RTC_GCLK_ID << GCLK_CLKCTRL_ID_Pos)));
@@ -464,12 +468,14 @@ void RTCZero::configureClock() {
464468
/* Configure the 32768Hz Oscillator */
465469
void RTCZero::config32kOSC()
466470
{
471+
#ifndef CRYSTALLESS
467472
SYSCTRL->XOSC32K.reg = SYSCTRL_XOSC32K_ONDEMAND |
468473
SYSCTRL_XOSC32K_RUNSTDBY |
469474
SYSCTRL_XOSC32K_EN32K |
470475
SYSCTRL_XOSC32K_XTALEN |
471476
SYSCTRL_XOSC32K_STARTUP(6) |
472477
SYSCTRL_XOSC32K_ENABLE;
478+
#endif
473479
}
474480

475481
/* Synchronise the CLOCK register for reading*/

0 commit comments

Comments
 (0)