diff options
| author | Jean-François Milants <jf@codingfield.com> | 2022-09-11 14:59:49 +0200 |
|---|---|---|
| committer | Jean-François Milants <jf@codingfield.com> | 2022-09-11 14:59:49 +0200 |
| commit | ada2c09581d2d13acfa5ce9a97671c0ec17863f1 (patch) | |
| tree | 2f776adc59d0c63e403d2043cb8460e65d6c46fe /src/main.cpp | |
| parent | 18cff286c75f432095db4b188e0f9a8a9e2bd8e8 (diff) | |
| parent | c9a5c3fa5c930a5939d3114a6c6b48570d61ca24 (diff) | |
Merge branch 'develop' into infineat-external-resources
# Conflicts:
# src/displayapp/screens/Symbols.h
# src/displayapp/screens/settings/SettingWatchFace.cpp
# src/displayapp/screens/settings/SettingWatchFace.h
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/main.cpp b/src/main.cpp index 3d70af49..109971bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,10 +300,29 @@ void nimble_port_ll_task_func(void* args) { } } +void calibrate_lf_clock_rc(nrf_drv_clock_evt_type_t event) { + // 16 * 0.25s = 4s calibration cycle + // Not recursive, call is deferred via internal calibration timer + nrf_drv_clock_calibration_start(16, calibrate_lf_clock_rc); +} + int main(void) { logger.Init(); nrf_drv_clock_init(); + nrf_drv_clock_lfclk_request(NULL); + + // When loading the firmware via the Wasp-OS reloader-factory, which uses the used internal LF RC oscillator, + // the LF clock has to be explicitly restarted because InfiniTime uses the external crystal oscillator if available. + // If the clock is not restarted, the Bluetooth timers fail to initialize. + nrfx_clock_lfclk_start(); + while (!nrf_clock_lf_is_running()) { + } + +// The RC source for the LF clock has to be calibrated +#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) + nrf_drv_clock_calibration_start(0, calibrate_lf_clock_rc); +#endif // Unblock i2c? nrf_gpio_cfg(Pinetime::PinMap::TwiScl, |
