This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 47b0cae778e137b37ce6808bf77a138400782eb3
Author: Tiago Medicci Serrano <[email protected]>
AuthorDate: Thu Apr 18 17:55:44 2024 -0300

    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);
 }

Reply via email to