wangchdo commented on code in PR #17295:
URL: https://github.com/apache/nuttx/pull/17295#discussion_r2509188036
##########
include/nuttx/wdog.h:
##########
@@ -325,6 +325,48 @@ 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)
+{
+ /* Ensure delay is within the range the watchdog can handle */
+
+ if (delay >= WDOG_MAX_DELAY)
+ {
+ return -EINVAL;
+ }
+
+ /* Restart the watchdog using its previously saved callback and argument */
+
+ return wd_start_abstick(wdog, clock_delay2abstick(delay),
Review Comment:
Done
##########
include/nuttx/wdog.h:
##########
@@ -325,6 +325,51 @@ 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)
+{
+ /* Ensure delay is within the range the watchdog can handle */
+
+ if (delay > WDOG_MAX_DELAY)
+ {
+ return -EINVAL;
+ }
+
+ /* Restart the watchdog based on the previous expiration time */
+
+ return wd_start_abstick(wdog, wdog->expired + delay,
Review Comment:
Done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]