From 8b0559c4812d74b6307757135622975523c5a88d Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Tue, 10 May 2022 21:46:36 +0200 Subject: Add basic hardware configuration options for P8 This enables the configuration of the LFCLK source, as well as the target hardware board pin configuration. --- src/main.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 3d70af49..98d8cafb 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -300,10 +300,24 @@ 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); + +// The RC source for the LF clock has to be calibrated +#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) + while (!nrf_clock_lf_is_running()) { + } + nrf_drv_clock_calibration_start(0, calibrate_lf_clock_rc); +#endif // Unblock i2c? nrf_gpio_cfg(Pinetime::PinMap::TwiScl, -- cgit v1.2.3-70-g09d2 From e77d47e35c84e2942f689fd2a810bda0b7dce625 Mon Sep 17 00:00:00 2001 From: Christoph Honal Date: Wed, 25 May 2022 15:00:19 +0200 Subject: LFCLK: Add compatibility to wasp-os reloader-factory --- src/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp index 98d8cafb..109971bc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -312,10 +312,15 @@ int main(void) { nrf_drv_clock_init(); nrf_drv_clock_lfclk_request(NULL); -// The RC source for the LF clock has to be calibrated -#if (CLOCK_CONFIG_LF_SRC == NRF_CLOCK_LFCLK_RC) + // 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 -- cgit v1.2.3-70-g09d2