Unverified Commit 02dcc235 authored by Gregor Hartmann's avatar Gregor Hartmann Committed by GitHub
Browse files

Allow turning off softwd again as documented (#3327)

* Allow turning off softwd again as documented

* fix luacheck warnings

* fix outcome of review
parent d279ba2f
......@@ -257,9 +257,9 @@ inline static uint64_t rtc_timer_update(bool do_calibration){
void rtc_callback(void *arg){
rtc_timer_update(true);
if(soft_watchdog > 0){
if(soft_watchdog >= 0){
soft_watchdog--;
if(soft_watchdog == 0)
if(soft_watchdog < 0)
system_restart();
}
}
......@@ -273,9 +273,8 @@ static int tmr_time( lua_State* L ){
// Lua: tmr.softwd( value )
static int tmr_softwd( lua_State* L ){
int t = luaL_checkinteger(L, 1);
luaL_argcheck(L, t>0 , 2, "invalid time");
soft_watchdog = t;
soft_watchdog = luaL_checkinteger(L, 1);
// NO check is required as negative Values mean that the timer is disabled.
return 0;
}
......
......@@ -89,3 +89,10 @@ N.testco('AUTO alarm coroutine', function(getCB, waitCB)
ok(true, "coroutine end")
end)
N.test('softwd set positive and negative values', function()
tmr.softwd(22)
tmr.softwd(0)
tmr.softwd(-1) -- disable it again
tmr.softwd(-22) -- disable it again
end)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment