-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from brilliantlabsAR/watchdog
Watchdog
- Loading branch information
Showing
10 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* This file is a part of: https://github.com/brilliantlabsAR/frame-codebase | ||
* | ||
* Authored by: Raj Nakarja / Brilliant Labs Ltd. ([email protected]) | ||
* Rohit Rathnam / Silicon Witchery AB ([email protected]) | ||
* Uma S. Gupta / Techno Exponent ([email protected]) | ||
* | ||
* ISC Licence | ||
* | ||
* Copyright © 2023 Brilliant Labs Ltd. | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
* PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#include "lua.h" | ||
#include "nrfx_wdt.h" | ||
|
||
static nrfx_wdt_t watchdog = NRFX_WDT_INSTANCE(0); | ||
|
||
void init_watchdog(void) | ||
{ | ||
nrfx_wdt_config_t watchdog_config = { | ||
.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK, | ||
.reload_value = 6000, | ||
.interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY, | ||
}; | ||
|
||
nrfx_wdt_channel_id watchdog_channel = NRF_WDT_RR0; | ||
|
||
check_error(nrfx_wdt_init(&watchdog, &watchdog_config, NULL)); | ||
check_error(nrfx_wdt_channel_alloc(&watchdog, &watchdog_channel)); | ||
|
||
nrfx_wdt_enable(&watchdog); | ||
nrfx_wdt_feed(&watchdog); | ||
} | ||
|
||
void reload_watchdog(lua_State *L, lua_Debug *ar) | ||
{ | ||
nrfx_wdt_channel_feed(&watchdog, NRF_WDT_RR0); | ||
} | ||
|
||
void sethook_watchdog(lua_State *L) | ||
{ | ||
lua_sethook(L, reload_watchdog, LUA_MASKCALL | LUA_MASKCOUNT, 2000); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* This file is a part of: https://github.com/brilliantlabsAR/frame-codebase | ||
* | ||
* Authored by: Raj Nakarja / Brilliant Labs Ltd. ([email protected]) | ||
* Rohit Rathnam / Silicon Witchery AB ([email protected]) | ||
* Uma S. Gupta / Techno Exponent ([email protected]) | ||
* | ||
* ISC Licence | ||
* | ||
* Copyright © 2023 Brilliant Labs Ltd. | ||
* | ||
* Permission to use, copy, modify, and/or distribute this software for any | ||
* purpose with or without fee is hereby granted, provided that the above | ||
* copyright notice and this permission notice appear in all copies. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
* REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
* AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
* INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
* LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
* PERFORMANCE OF THIS SOFTWARE. | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "lua.h" | ||
|
||
void init_watchdog(void); | ||
void reload_watchdog(lua_State *L, lua_Debug *ar); | ||
void sethook_watchdog(lua_State *L); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters