mirror of
https://github.com/apache/nuttx.git
synced 2025-12-11 21:20:26 +08:00
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 <wangchengdong@lixiang.com>
This commit is contained in:
committed by
Xiang Xiao
parent
387803e958
commit
07e05b8591
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user