Skip to content

Commit 87d6eb0

Browse files
committed
Improved error looking to show error code
Added call mask to watchdog hook
1 parent d5f16a3 commit 87d6eb0

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

source/application/nrfx_config.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,5 @@
4848
#define NRFX_TWIM0_ENABLED 1
4949

5050
#define NRFX_WDT_ENABLED 1
51-
#define NRFX_WDT_CONFIG_NO_IRQ 1
5251

5352
#include "templates/nrfx_config_nrf52840.h"

source/application/watchdog.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ void init_watchdog(void)
3232
nrfx_wdt_config_t watchdog_config = {
3333
.behaviour = NRF_WDT_BEHAVIOUR_RUN_SLEEP_MASK,
3434
.reload_value = 6000,
35+
.interrupt_priority = NRFX_WDT_DEFAULT_CONFIG_IRQ_PRIORITY,
3536
};
3637

3738
nrfx_wdt_channel_id watchdog_channel = NRF_WDT_RR0;
@@ -50,5 +51,5 @@ void reload_watchdog(lua_State *L, lua_Debug *ar)
5051

5152
void sethook_watchdog(lua_State *L)
5253
{
53-
lua_sethook(L, reload_watchdog, LUA_MASKCOUNT, 2000);
54+
lua_sethook(L, reload_watchdog, LUA_MASKCALL | LUA_MASKCOUNT, 2000);
5455
}

source/error_logging.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,15 @@ void _check_error(nrfx_err_t error_code, const char *file, const int line)
146146
{
147147
if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk)
148148
{
149-
LOG("Crashed at %s:%u - %s",
149+
LOG("Crashed at %s:%u - %s (0x%02x)",
150150
file,
151151
line,
152-
lookup_error_code(error_code));
152+
lookup_error_code(error_code),
153+
error_code);
154+
155+
for (size_t i = 0; i < 1000; i++)
156+
{
157+
}
153158

154159
__BKPT();
155160
}

source/nrfx_glue.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
#define nrfx_gpiote_0_irq_handler GPIOTE_IRQHandler
3434
#define nrfx_rtc_1_irq_handler RTC1_IRQHandler
3535
#define nrfx_pdm_irq_handler PDM_IRQHandler
36+
#define nrfx_wdt_0_irq_handler WDT_IRQHandler
3637

3738
#define NRFX_ASSERT(expression) \
3839
do \

0 commit comments

Comments
 (0)