Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
Nodemcu Firmware
Commits
5c59c57a
Commit
5c59c57a
authored
Oct 22, 2021
by
Johny Mattsson
Browse files
Implement tmr.wdclr()
parent
a2ba49e3
Changes
2
Hide whitespace changes
Inline
Side-by-side
components/modules/tmr.c
View file @
5c59c57a
...
@@ -233,6 +233,15 @@ static int tmr_create( lua_State *L ) {
...
@@ -233,6 +233,15 @@ static int tmr_create( lua_State *L ) {
}
}
// Lua: tmr.wdclr()
static
int
tmr_wdclr
(
lua_State
*
L
)
{
// Suspend ourselves momentarily to let the IDLE task do its thing
vTaskDelay
(
1
);
return
0
;
}
// Module function map
// Module function map
LROT_BEGIN
(
tmr_dyn
,
NULL
,
LROT_MASK_GC_INDEX
)
LROT_BEGIN
(
tmr_dyn
,
NULL
,
LROT_MASK_GC_INDEX
)
...
@@ -249,6 +258,7 @@ LROT_END(tmr_dyn, NULL, LROT_MASK_GC_INDEX)
...
@@ -249,6 +258,7 @@ LROT_END(tmr_dyn, NULL, LROT_MASK_GC_INDEX)
LROT_BEGIN
(
tmr
,
NULL
,
0
)
LROT_BEGIN
(
tmr
,
NULL
,
0
)
LROT_FUNCENTRY
(
create
,
tmr_create
)
LROT_FUNCENTRY
(
create
,
tmr_create
)
LROT_FUNCENTRY
(
wdclr
,
tmr_wdclr
)
LROT_NUMENTRY
(
ALARM_SINGLE
,
TIMER_MODE_SINGLE
)
LROT_NUMENTRY
(
ALARM_SINGLE
,
TIMER_MODE_SINGLE
)
LROT_NUMENTRY
(
ALARM_SEMI
,
TIMER_MODE_SEMI
)
LROT_NUMENTRY
(
ALARM_SEMI
,
TIMER_MODE_SEMI
)
LROT_NUMENTRY
(
ALARM_AUTO
,
TIMER_MODE_AUTO
)
LROT_NUMENTRY
(
ALARM_AUTO
,
TIMER_MODE_AUTO
)
...
...
docs/modules/tmr.md
View file @
5c59c57a
...
@@ -212,3 +212,37 @@ none
...
@@ -212,3 +212,37 @@ none
#### See also
#### See also
[
`tmr.obj:register()`
](
#tmrobjregister
)
[
`tmr.obj:register()`
](
#tmrobjregister
)
## tmr.wdclr()
Resets the watchdog timer to prevent a reboot due to a perceived hung task.
Use with caution, as this could prevent a reboot to recover from a
genuinely hung task.
On the ESP32, the
`tmr.wdclr()`
function is implemented as a task yield
to let the system "IDLE" task do the necessary watchdog maintenance.
Overuse of this function is likely to result in degraded performance.
#### Syntax
`tmr.wdclr()`
#### Parameters
none
#### Returns
`nil`
#### Example
```
lua
function
long_running_function
()
while
1
do
if
some_condition
then
break
end
-- do some heavy calculation here, for example
tmr
.
wdclr
()
end
end
```
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment