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){ ...@@ -257,9 +257,9 @@ inline static uint64_t rtc_timer_update(bool do_calibration){
void rtc_callback(void *arg){ void rtc_callback(void *arg){
rtc_timer_update(true); rtc_timer_update(true);
if(soft_watchdog > 0){ if(soft_watchdog >= 0){
soft_watchdog--; soft_watchdog--;
if(soft_watchdog == 0) if(soft_watchdog < 0)
system_restart(); system_restart();
} }
} }
...@@ -273,9 +273,8 @@ static int tmr_time( lua_State* L ){ ...@@ -273,9 +273,8 @@ static int tmr_time( lua_State* L ){
// Lua: tmr.softwd( value ) // Lua: tmr.softwd( value )
static int tmr_softwd( lua_State* L ){ static int tmr_softwd( lua_State* L ){
int t = luaL_checkinteger(L, 1); soft_watchdog = luaL_checkinteger(L, 1);
luaL_argcheck(L, t>0 , 2, "invalid time"); // NO check is required as negative Values mean that the timer is disabled.
soft_watchdog = t;
return 0; return 0;
} }
......
...@@ -89,3 +89,10 @@ N.testco('AUTO alarm coroutine', function(getCB, waitCB) ...@@ -89,3 +89,10 @@ N.testco('AUTO alarm coroutine', function(getCB, waitCB)
ok(true, "coroutine end") ok(true, "coroutine end")
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