nrf: Start HFXO when LFCLK is synthesized from it.

A board that uses BLUETOOTH_LFCLK_SYNTH is expected to have a 32MHz crystal
(Do any without one exist at all? I guess not because it's required for
Bluetooth, which nRF microcontrollers are usually chosen for.), otherwise
BLUETOOTH_LFCLK_RC would be more appropriate, so start the crystal
oscillator together with LFCLK to have accurate timekeeping from the start.

Signed-off-by: Christian Walther <cwalther@gmx.ch>
pull/13340/head
Christian Walther 2024-03-29 17:07:41 +01:00
rodzic 6fa8becff5
commit 4cef128793
1 zmienionych plików z 8 dodań i 0 usunięć

Wyświetl plik

@ -82,6 +82,14 @@ void mp_nrf_start_lfclk(void) {
#endif
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_LFCLKSTART);
}
// When synthesizing LFCLK from HFCLK, start HFXO if it hasn't been started yet, otherwise we
// would be synthesizing from HFINT, which is pointless as it's even less accurate than LFRC.
// Must come after starting LFCLK, otherwise the LFCLK source reverts to RC.
#if BLUETOOTH_LFCLK_SYNTH
if (!nrf_clock_hf_start_task_status_get(NRF_CLOCK)) {
nrf_clock_task_trigger(NRF_CLOCK, NRF_CLOCK_TASK_HFCLKSTART);
}
#endif
}
#if MICROPY_PY_TIME_TICKS