From eb294c8e1c5a36db62b0e55b4908e84e189cfaa2 Mon Sep 17 00:00:00 2001 From: Jared Boone Date: Sat, 27 Feb 2016 12:05:29 -0800 Subject: [PATCH] Add chDbgPanic for unhandled exceptions. --- .../os/ports/GCC/ARMCMx/LPC43xx_M4/vectors.c | 5 ++++- firmware/common/debug.cpp | 15 ++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/firmware/chibios-portapack/os/ports/GCC/ARMCMx/LPC43xx_M4/vectors.c b/firmware/chibios-portapack/os/ports/GCC/ARMCMx/LPC43xx_M4/vectors.c index 15881fec4..7561b3770 100755 --- a/firmware/chibios-portapack/os/ports/GCC/ARMCMx/LPC43xx_M4/vectors.c +++ b/firmware/chibios-portapack/os/ports/GCC/ARMCMx/LPC43xx_M4/vectors.c @@ -178,9 +178,12 @@ vectors_t _vectors = { __attribute__ ((naked)) #endif void _unhandled_exception(void) { - +#if CH_DBG_ENABLED + chDbgPanic("Unhandled"); +#else while (TRUE) ; +#endif } void NMIVector(void) __attribute__((weak, alias("_unhandled_exception"))); diff --git a/firmware/common/debug.cpp b/firmware/common/debug.cpp index 5ae27f7a8..886abeafa 100644 --- a/firmware/common/debug.cpp +++ b/firmware/common/debug.cpp @@ -81,18 +81,27 @@ void port_halt(void) { #if defined(LPC43XX_M4) CH_IRQ_HANDLER(MemManageVector) { - CH_IRQ_PROLOGUE(); +#if CH_DBG_ENABLED + chDbgPanic("MemManage"); +#else chSysHalt(); +#endif } CH_IRQ_HANDLER(BusFaultVector) { - CH_IRQ_PROLOGUE(); +#if CH_DBG_ENABLED + chDbgPanic("BusFault"); +#else chSysHalt(); +#endif } CH_IRQ_HANDLER(UsageFaultVector) { - CH_IRQ_PROLOGUE(); +#if CH_DBG_ENABLED + chDbgPanic("UsageFault"); +#else chSysHalt(); +#endif } #endif