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 07e05b8591fd538ab0920bfa8121485686e797ca
Author: wangchengdong <[email protected]>
AuthorDate: Mon Nov 10 10:51:48 2025 +0800

    sched/wdog: Add wd_restart_next() for precise wdog restart upon expiration
    
        This patch introduces wd_restart_next(), which enables precise and
        convenient watchdog restarts upon expiration. It is designed to be
        invoked within the watchdog expiration callback to facilitate accurate
        periodic events.
    
    Signed-off-by: Chengdong Wang <[email protected]>
---
 include/nuttx/wdog.h | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h
index 0a7958fe0f6..cca5e90c43f 100644
--- a/include/nuttx/wdog.h
+++ b/include/nuttx/wdog.h
@@ -336,6 +336,41 @@ int wd_start_next(FAR struct wdog_s *wdog, clock_t delay,
   return wd_start_abstick(wdog, wdog->expired + delay, wdentry, arg);
 }
 
+/****************************************************************************
+ * Name: wd_restart_next
+ *
+ * Description:
+ *   This function restarts the specified watchdog timer using a new delay
+ *   value, but schedules the next expiration based on the previous
+ *   expiration time (wdog->expired + delay).  This allows the watchdog to
+ *   maintain a consistent periodic interval even if there is some delay in
+ *   handling the expiration callback.
+ *
+ *   It can be used when the user wants to restart a watchdog for a different
+ *   purpose or continue periodic timing based on the previous timeout point.
+ *
+ * Input Parameters:
+ *   wdog  - Pointer to the watchdog timer to restart
+ *   delay - Delay time in system ticks to add after the previous expiration
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; a negated errno value is returned
+ *   to indicate the nature of any failure.
+ *
+ * Assumptions:
+ *   - The watchdog must already have expired or been started before calling
+ *     this function so that wdog->expired is valid.
+ *   - The watchdog routine runs in the context of the timer interrupt
+ *     handler and is subject to all ISR restrictions.
+ *
+ ****************************************************************************/
+
+static inline_function
+int wd_restart_next(FAR struct wdog_s *wdog, clock_t delay)
+{
+  return wd_start_next(wdog, delay, wdog->func, wdog->arg);
+}
+
 /****************************************************************************
  * Name: wd_restart
  *

Reply via email to