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 <electronics@wandfluh.com>
This commit is contained in:
parent
26e0aa268f
commit
cd20154bc7
2 changed files with 16 additions and 3 deletions
|
@ -10,6 +10,14 @@ config SOC_ATMEL_SAMD5X_XOSC32K
|
|||
startup. This can then be selected as the main clock source
|
||||
for the SOC.
|
||||
|
||||
config SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
|
||||
depends on SOC_ATMEL_SAMD5X_XOSC32K
|
||||
hex "Startup time external 32 kHz crystal oscillator"
|
||||
range 0x0 0x6
|
||||
default 0x1
|
||||
help
|
||||
Selects the startup time for the external 32 kHz crystal oscillator.
|
||||
|
||||
choice
|
||||
prompt "Main clock source"
|
||||
default SOC_ATMEL_SAMD5X_DEFAULT_AS_MAIN
|
||||
|
|
|
@ -18,13 +18,18 @@
|
|||
#define SAM0_DFLL_FREQ_HZ (48000000U)
|
||||
#define SAM0_DPLL_FREQ_MIN_HZ (96000000U)
|
||||
#define SAM0_DPLL_FREQ_MAX_HZ (200000000U)
|
||||
#define SAM0_XOSC32K_STARTUP_TIME CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_STARTUP
|
||||
|
||||
#if CONFIG_SOC_ATMEL_SAMD5X_XOSC32K_AS_MAIN
|
||||
static void osc32k_init(void)
|
||||
{
|
||||
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE | OSC32KCTRL_XOSC32K_XTALEN
|
||||
| OSC32KCTRL_XOSC32K_EN32K | OSC32KCTRL_XOSC32K_RUNSTDBY
|
||||
| OSC32KCTRL_XOSC32K_STARTUP(0) | OSC32KCTRL_XOSC32K_CGM_XT;
|
||||
OSC32KCTRL->XOSC32K.reg = OSC32KCTRL_XOSC32K_ENABLE
|
||||
| OSC32KCTRL_XOSC32K_XTALEN
|
||||
| OSC32KCTRL_XOSC32K_CGM_XT
|
||||
| OSC32KCTRL_XOSC32K_EN32K
|
||||
| OSC32KCTRL_XOSC32K_RUNSTDBY
|
||||
| OSC32KCTRL_XOSC32K_STARTUP(SAM0_XOSC32K_STARTUP_TIME)
|
||||
;
|
||||
|
||||
while (!OSC32KCTRL->STATUS.bit.XOSC32KRDY) {
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue