Skip to content

Commit e334df6

Browse files
GUIDINGLIxiaoxiang781216
authored andcommitted
wdog: add API wd_cancel_irq() support
Signed-off-by: ligd <[email protected]>
1 parent b7cd0ab commit e334df6

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

include/nuttx/wdog.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,25 @@ int wd_start_absolute(FAR struct wdog_s *wdog, clock_t ticks,
194194

195195
int wd_cancel(FAR struct wdog_s *wdog);
196196

197+
/****************************************************************************
198+
* Name: wd_cancel_irq
199+
*
200+
* Description:
201+
* This function cancels a currently running watchdog timer. Watchdog
202+
* timers may be cancelled from the interrupt level. This function is
203+
* intended to be called from critical sections.
204+
*
205+
* Input Parameters:
206+
* wdog - ID of the watchdog to cancel.
207+
*
208+
* Returned Value:
209+
* Zero (OK) is returned on success; A negated errno value is returned to
210+
* indicate the nature of any failure.
211+
*
212+
****************************************************************************/
213+
214+
int wd_cancel_irq(FAR struct wdog_s *wdog);
215+
197216
/****************************************************************************
198217
* Name: wd_gettime
199218
*

sched/wdog/wd_cancel.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,36 @@
5858
int wd_cancel(FAR struct wdog_s *wdog)
5959
{
6060
irqstate_t flags;
61+
int ret;
6162

63+
flags = enter_critical_section();
64+
65+
ret = wd_cancel_irq(wdog);
66+
67+
leave_critical_section(flags);
68+
69+
return ret;
70+
}
71+
72+
/****************************************************************************
73+
* Name: wd_cancel_irq
74+
*
75+
* Description:
76+
* This function cancels a currently running watchdog timer. Watchdog
77+
* timers may be cancelled from the interrupt level. This function is
78+
* intended to be called from critical sections.
79+
*
80+
* Input Parameters:
81+
* wdog - ID of the watchdog to cancel.
82+
*
83+
* Returned Value:
84+
* Zero (OK) is returned on success; A negated errno value is returned to
85+
* indicate the nature of any failure.
86+
*
87+
****************************************************************************/
88+
89+
int wd_cancel_irq(FAR struct wdog_s *wdog)
90+
{
6291
if (wdog == NULL)
6392
{
6493
return -EINVAL;
@@ -68,8 +97,6 @@ int wd_cancel(FAR struct wdog_s *wdog)
6897
* cancellation is complete
6998
*/
7099

71-
flags = enter_critical_section();
72-
73100
/* Make sure that the watchdog is still active. */
74101

75102
if (WDOG_ISACTIVE(wdog))
@@ -95,6 +122,5 @@ int wd_cancel(FAR struct wdog_s *wdog)
95122
}
96123
}
97124

98-
leave_critical_section(flags);
99125
return OK;
100126
}

0 commit comments

Comments
 (0)