Skip to content

Commit cd20154

Browse files
Thomas Schranzfabiobaltieri
authored andcommitted
soc: sam0: samd5x: xosc32 configurable startup time
Adds Kconfig option to configure the startup time of the external 32KHz crystal oscillator. Signed-off-by: Thomas Schranz <[email protected]>
1 parent 26e0aa2 commit cd20154

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

soc/atmel/sam0/common/Kconfig.samd5x

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ config SOC_ATMEL_SAMD5X_XOSC32K
1010
startup. This can then be selected as the main clock source
1111
for the SOC.
1212

13+
config SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
14+
depends on SOC_ATMEL_SAMD5X_XOSC32K
15+
hex "Startup time external 32 kHz crystal oscillator"
16+
range 0x0 0x6
17+
default 0x1
18+
help
19+
Selects the startup time for the external 32 kHz crystal oscillator.
20+
1321
choice
1422
prompt "Main clock source"
1523
default SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN

soc/atmel/sam0/common/soc_samd5x.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
#define SAM0_DFLL_FREQ_HZ (48000000U)
1919
#define SAM0_DPLL_FREQ_MIN_HZ (96000000U)
2020
#define SAM0_DPLL_FREQ_MAX_HZ (200000000U)
21+
#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
2122

2223
#if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN
2324
static void osc32k_init(void)
2425
{
25-
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN
26-
| OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_RUNSTDBY
27-
| OSC32KCTRL_XOSC32K_STARTUP(0) | OSC32KCTRL_XOSC32K_CGM_XT;
26+
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE
27+
| OSC32KCTRL_XOSC32K_XTALEN
28+
| OSC32KCTRL_XOSC32K_CGM_XT
29+
| OSC32KCTRL_XOSC32K_EN32K
30+
| OSC32KCTRL_XOSC32K_RUNSTDBY
31+
| OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME)
32+
;
2833

2934
while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) {
3035
}

0 commit comments

Comments
 (0)