Skip to content

Commit 0ce8780

Browse files
committed
cpu/saml1x: avoid the use of bitfield
Signed-off-by: Dylan Laduranty <[email protected]>
1 parent 67f183d commit 0ce8780

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

cpu/saml1x/cpu.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static void _osc32k_setup(void)
6464
| OSC32KCTRL_OSC32K_ENABLE;
6565

6666
/* Wait OSC32K Ready */
67-
while (!OSC32KCTRL->STATUS.bit.OSC32KRDY) {}
67+
while (!(OSC32KCTRL->STATUS.reg & OSC32KCTRL_STATUS_OSC32KRDY)) {}
6868
#endif /* INTERNAL_OSC32_SOURCE */
6969
}
7070

@@ -78,7 +78,7 @@ static void _xosc32k_setup(void)
7878
| OSC32KCTRL_XOSC32K_ENABLE;
7979

8080
/* Wait XOSC32K Ready */
81-
while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) {}
81+
while (!(OSC32KCTRL->STATUS.reg & OSC32KCTRL_STATUS_XOSC32KRDY)) {}
8282
#endif
8383
}
8484

@@ -145,9 +145,10 @@ void cpu_init(void)
145145
/* Disable the RTC module to prevent synchronization issues during CPU init
146146
if the RTC was running from a previous boot (e.g wakeup from backup)
147147
as the module will be re-init during the boot process */
148-
if (RTC->MODE2.CTRLA.bit.ENABLE && IS_ACTIVE(MODULE_PERIPH_RTC_RTT)) {
148+
if ((RTC->MODE2.CTRLA.reg & RTC_MODE2_CTRLA_ENABLE) &&
149+
IS_ACTIVE(MODULE_PERIPH_RTC_RTT)) {
149150
while (RTC->MODE2.SYNCBUSY.reg) {}
150-
RTC->MODE2.CTRLA.bit.ENABLE = 0;
151+
RTC->MODE2.CTRLA.reg &= ~ RTC_MODE2_CTRLA_ENABLE;
151152
while (RTC->MODE2.SYNCBUSY.reg) {}
152153
}
153154
/* Software reset the GCLK module to ensure it is re-initialized correctly */
@@ -156,16 +157,14 @@ void cpu_init(void)
156157
while (GCLK->SYNCBUSY.reg & GCLK_SYNCBUSY_SWRST) {}
157158

158159
PM->PLCFG.reg = PM_PLCFG_PLSEL_PL2;
159-
while (!PM->INTFLAG.bit.PLRDY) {}
160+
while (!(PM->INTFLAG.reg & PM_INTFLAG_PLRDY)) {}
160161

161162
MCLK->APBBMASK.reg |= MCLK_APBBMASK_NVMCTRL;
162163
_NVMCTRL->CTRLB.reg |= NVMCTRL_CTRLB_RWS(1);
163164
MCLK->APBBMASK.reg &= ~MCLK_APBBMASK_NVMCTRL;
164165

165166
/* set OSC16M to 16MHz */
166-
OSCCTRL->OSC16MCTRL.bit.FSEL = 3;
167-
OSCCTRL->OSC16MCTRL.bit.ONDEMAND = 0;
168-
OSCCTRL->OSC16MCTRL.bit.RUNSTDBY = 0;
167+
OSCCTRL->OSC16MCTRL.reg = (OSCCTRL_OSC16MCTRL_FSEL_16 | OSCCTRL_OSC16MCTRL_ENABLE);
169168

170169
_osc32k_setup();
171170
_xosc32k_setup();

cpu/saml1x/periph/pm.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ void pm_set(unsigned mode)
4343
}
4444

4545
/* write sleep configuration */
46-
PM->SLEEPCFG.bit.SLEEPMODE = _mode;
46+
PM->SLEEPCFG.reg = _mode;
4747
/* make sure value has been set */
48-
while (PM->SLEEPCFG.bit.SLEEPMODE != _mode) {}
48+
while ((PM->SLEEPCFG.reg & PM_SLEEPCFG_SLEEPMODE_Msk) != _mode) {}
4949

5050
sam0_cortexm_sleep(deep);
5151
}

0 commit comments

Comments
 (0)