From 87d6eb073aba48db359c6563f2c84968c235dc3d Mon Sep 17 00:00:00 2001 From: Raj Nakarja Date: Wed, 14 Aug 2024 14:37:22 +0200 Subject: [PATCH] Improved error looking to show error code Added call mask to watchdog hook --- source/application/nrfx_config.h | 1 - source/application/watchdog.c | 3 ++- source/error_logging.c | 9 +++++++-- source/nrfx_glue.h | 1 + 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/source/application/nrfx_config.h b/source/application/nrfx_config.h index 89a11b46..274e59ed 100644 --- a/source/application/nrfx_config.h +++ b/source/application/nrfx_config.h @@ -48,6 +48,5 @@ #define NRFX_TWIM0_ENABLED 1 #define NRFX_WDT_ENABLED 1 -#define NRFX_WDT_CONFIG_NO_IRQ 1 #include "templates/nrfx_config_nrf52840.h" diff --git a/source/application/watchdog.c b/source/application/watchdog.c index 54380e58..1854c184 100644 --- a/source/application/watchdog.c +++ b/source/application/watchdog.c @@ -32,6 +32,7 @@ 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; @@ -50,5 +51,5 @@ void reload_watchdog(lua_State *L, lua_Debug *ar) void sethook_watchdog(lua_State *L) { - lua_sethook(L, reload_watchdog, LUA_MASKCOUNT, 2000); + lua_sethook(L, reload_watchdog, LUA_MASKCALL | LUA_MASKCOUNT, 2000); } \ No newline at end of file diff --git a/source/error_logging.c b/source/error_logging.c index c9144e5b..71435caf 100644 --- a/source/error_logging.c +++ b/source/error_logging.c @@ -146,10 +146,15 @@ void _check_error(nrfx_err_t error_code, const char *file, const int line) { if (CoreDebug->DHCSR & CoreDebug_DHCSR_C_DEBUGEN_Msk) { - LOG("Crashed at %s:%u - %s", + LOG("Crashed at %s:%u - %s (0x%02x)", file, line, - lookup_error_code(error_code)); + lookup_error_code(error_code), + error_code); + + for (size_t i = 0; i < 1000; i++) + { + } __BKPT(); } diff --git a/source/nrfx_glue.h b/source/nrfx_glue.h index 7f412ef5..0837acf9 100644 --- a/source/nrfx_glue.h +++ b/source/nrfx_glue.h @@ -33,6 +33,7 @@ #define nrfx_gpiote_0_irq_handler GPIOTE_IRQHandler #define nrfx_rtc_1_irq_handler RTC1_IRQHandler #define nrfx_pdm_irq_handler PDM_IRQHandler +#define nrfx_wdt_0_irq_handler WDT_IRQHandler #define NRFX_ASSERT(expression) \ do \