From 803d337748a7f0bcc2b06166721aa84e991e7a13 Mon Sep 17 00:00:00 2001 From: Marco Widmer Date: Mon, 17 Mar 2025 15:38:32 +0100 Subject: [PATCH] drivers: counter: nrfx_timer: Use shutdown task if available Add a workaround for NRF52 anomaly 78: "High current consumption when using timer STOP task only". Use the SHUTDOWN task instead. For consistency, CLEAR the timer timer after STOPPING on devices that lack the SHUTDOWN task. This also aligns the behavior with nrfx_timer_disable(). For devices with the SHUTDOWN task, this restores the behavior previous to e92323f. Fixes #87224 Signed-off-by: Marco Widmer (cherry picked from commit 491e2974188a170ea03d5de5ceade66b7415470d) --- drivers/counter/counter_nrfx_timer.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/counter/counter_nrfx_timer.c b/drivers/counter/counter_nrfx_timer.c index afbdb4ed1adac..94780172d2c03 100644 --- a/drivers/counter/counter_nrfx_timer.c +++ b/drivers/counter/counter_nrfx_timer.c @@ -109,7 +109,13 @@ static int stop(const struct device *dev) { const struct counter_nrfx_config *config = dev->config; +#if NRF_TIMER_HAS_SHUTDOWN + nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_SHUTDOWN); +#else nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_STOP); + nrf_timer_task_trigger(config->timer, NRF_TIMER_TASK_CLEAR); +#endif + #ifdef COUNTER_ANY_FAST struct counter_nrfx_data *data = dev->data;