diff options
| author | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-03-06 20:06:47 +0100 |
|---|---|---|
| committer | Glenn Ruben Bakke <glennbakke@gmail.com> | 2017-03-06 20:06:47 +0100 |
| commit | 87e16164882eb990498da604594d11f4eb3fdf27 (patch) | |
| tree | f32d7b1ff8f12d3641f2292f2f4435e9dda2c49a | |
| parent | 7000e0a2a0dc3ac2ee874a15654d1debd556355d (diff) | |
nrf5/hal: Adding initialization of LFCLK if not already enabled in hal_rtc.
| -rw-r--r-- | nrf5/hal/hal_rtc.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/nrf5/hal/hal_rtc.c b/nrf5/hal/hal_rtc.c index 519de3eac..bf10dfc8d 100644 --- a/nrf5/hal/hal_rtc.c +++ b/nrf5/hal/hal_rtc.c @@ -39,6 +39,13 @@ void hal_rtc_callback_set(hal_rtc_app_callback callback) { void hal_rtc_init(hal_rtc_conf_t const * p_rtc_conf) { p_rtc_conf->p_instance->PRESCALER = (32768 / p_rtc_conf->frequency) - 1; // approx correct. hal_irq_priority(p_rtc_conf->irq_num, p_rtc_conf->irq_priority); + + // start LFCLK if not already started + if (NRF_CLOCK->LFCLKSTAT == 0) { + NRF_CLOCK->TASKS_LFCLKSTART = 1; + while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0); + NRF_CLOCK->EVENTS_LFCLKSTARTED = 0; + } } void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) { |
