diff --git a/drivers/timer/Kconfig.nrf_rtc b/drivers/timer/Kconfig.nrf_rtc index 36c99900adc..fc26e3982ab 100644 --- a/drivers/timer/Kconfig.nrf_rtc +++ b/drivers/timer/Kconfig.nrf_rtc @@ -23,6 +23,17 @@ config NRF_RTC_TIMER_USER_CHAN_COUNT help Use nrf_rtc_timer.h API. Driver is not managing allocation of channels. +config NRF_RTC_TIMER_LOCK_ZERO_LATENCY_IRQS + # hidden option + bool + depends on ZERO_LATENCY_IRQS + default y + help + Enable use of __disable_irq() to disable Zero Latency IRQs to prevent + higher priority contexts (including ZLIs) that might preempt the + handler and call nrf_rtc_timer API from destroying the internal state + in nrf_rtc_timer. + choice prompt "Clock startup policy" default SYSTEM_CLOCK_WAIT_FOR_STABILITY diff --git a/drivers/timer/nrf_rtc_timer.c b/drivers/timer/nrf_rtc_timer.c index dc4976cb8f0..fdcd9920a97 100644 --- a/drivers/timer/nrf_rtc_timer.c +++ b/drivers/timer/nrf_rtc_timer.c @@ -98,7 +98,7 @@ static uint32_t full_int_lock(void) { uint32_t mcu_critical_state; - if (IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)) { + if (IS_ENABLED(CONFIG_NRF_RTC_TIMER_LOCK_ZERO_LATENCY_IRQS)) { mcu_critical_state = __get_PRIMASK(); __disable_irq(); } else { @@ -110,7 +110,7 @@ static uint32_t full_int_lock(void) static void full_int_unlock(uint32_t mcu_critical_state) { - if (IS_ENABLED(CONFIG_ZERO_LATENCY_IRQS)) { + if (IS_ENABLED(CONFIG_NRF_RTC_TIMER_LOCK_ZERO_LATENCY_IRQS)) { __set_PRIMASK(mcu_critical_state); } else { irq_unlock(mcu_critical_state);