You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2025/11/10 15:17:06 UTC
(nuttx) 02/06: sched/wdog: Add wd_restart() for convenient restart of a wdog
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 8696632abe42932c21ba6422500f427875a67612
Author: wangchengdong <wa...@lixiang.com>
AuthorDate: Mon Nov 10 09:27:08 2025 +0800
sched/wdog: Add wd_restart() for convenient restart of a wdog
Introduce wd_restart() to allow restarting an existing watchdog
with its previously configured callback and argument, making it
easier to refresh or reuse preconfigured watchdog timers.
Signed-off-by: Chengdong Wang <wa...@lixiang.com>
---
include/nuttx/wdog.h | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/include/nuttx/wdog.h b/include/nuttx/wdog.h
index 072632a6725..0a7958fe0f6 100644
--- a/include/nuttx/wdog.h
+++ b/include/nuttx/wdog.h
@@ -336,6 +336,38 @@ 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
+ *
+ * Description:
+ * This function restarts the specified watchdog timer using the same
+ * function and argument that were specified in the previous wd_start()
+ * call, but with a new delay value. It can be used when the user wants
+ * to restart the same watchdog with a different timeout value, or to
+ * refresh (feed) an existing watchdog before it expires.
+ *
+ * Input Parameters:
+ * wdog - Pointer to the watchdog timer to restart.
+ * delay - New delay time in system ticks before the watchdog expires.
+ *
+ * Returned Value:
+ * Zero (OK) is returned on success; a negated errno value is returned
+ * to indicate the nature of any failure.
+ *
+ * Assumptions:
+ * - The watchdog routine runs in the context of the timer interrupt
+ * handler and is subject to all ISR restrictions.
+ * - The watchdog must have been previously started so that the stored
+ * function (wdog->func) and argument (wdog->arg) are valid.
+ *
+ ****************************************************************************/
+
+static inline_function
+int wd_restart(FAR struct wdog_s *wdog, clock_t delay)
+{
+ return wd_start(wdog, delay, wdog->func, wdog->arg);
+}
+
/****************************************************************************
* Name: wd_cancel
*