8000 nrf5/hal: Adding initialization of LFCLK if not already enabled in ha… · godlygeek/circuitpython@87e1616 · GitHub
[go: up one dir, main page]

Skip to content

Commit 87e1616

Browse files
committed
nrf5/hal: Adding initialization of LFCLK if not already enabled in hal_rtc.
1 parent 7000e0a commit 87e1616

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

nrf5/hal/hal_rtc.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ void hal_rtc_callback_set(hal_rtc_app_callback callback) {
3939
void hal_rtc_init(hal_rtc_conf_t const * p_rtc_conf) {
4040
p_rtc_conf->p_instance->PRESCALER = (32768 / p_rtc_conf->frequency) - 1; // approx correct.
4141
hal_irq_priority(p_rtc_conf->irq_num, p_rtc_conf->irq_priority);
42+
43+
// start LFCLK if not already started
44+
if (NRF_CLOCK->LFCLKSTAT == 0) {
45+
NRF_CLOCK->TASKS_LFCLKSTART = 1;
46+
while (NRF_CLOCK->EVENTS_LFCLKSTARTED == 0);
47+
NRF_CLOCK->EVENTS_LFCLKSTARTED = 0;
48+
}
4249
}
4350

4451
void hal_rtc_start(hal_rtc_conf_t const * p_rtc_conf, uint16_t period) {

0 commit comments

Comments
 (0)
0