From 47b0cae778e137b37ce6808bf77a138400782eb3 Mon Sep 17 00:00:00 2001 From: Tiago Medicci Serrano Date: Thu, 18 Apr 2024 17:55:44 -0300 Subject: [PATCH] esp/hr_timer: Fix issue with timed-out timers --- arch/risc-v/src/common/espressif/esp_hr_timer.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/risc-v/src/common/espressif/esp_hr_timer.c b/arch/risc-v/src/common/espressif/esp_hr_timer.c index 786d689c1f..3fb7d133fd 100644 --- a/arch/risc-v/src/common/espressif/esp_hr_timer.c +++ b/arch/risc-v/src/common/espressif/esp_hr_timer.c @@ -491,6 +491,23 @@ void esp_hr_timer_stop(struct esp_hr_timer_s *timer) } } } + else if (timer->state == HR_TIMER_TIMEOUT) + { + /* If the timer is in the timeout list, remove it from the list, + * execute its callback function and set its state to idle. + */ + + DEBUGASSERT(!list_is_empty(&priv->toutlist)); + + list_delete(&timer->list); + timer->state = HR_TIMER_IDLE; + + spin_unlock_irqrestore(&priv->lock, flags); + + timer->callback(timer->arg); + + flags = spin_lock_irqsave(&priv->lock); + } spin_unlock_irqrestore(&priv->lock, flags); }