Skip to content

Commit

Permalink
Improved error looking to show error code
Browse files Browse the repository at this point in the history
Added call mask to watchdog hook
  • Loading branch information
siliconwitch committed Aug 14, 2024
1 parent d5f16a3 commit 87d6eb0
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
1 change: 0 additions & 1 deletion source/application/nrfx_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
3 changes: 2 additions & 1 deletion source/application/watchdog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
9 changes: 7 additions & 2 deletions source/error_logging.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
1 change: 1 addition & 0 deletions source/nrfx_glue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 87d6eb0

Please sign in to comment.