aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClyne Sullivan <clyne@bitgloo.com>2020-09-01 20:13:38 -0400
committerClyne Sullivan <clyne@bitgloo.com>2020-09-01 20:13:38 -0400
commit89ebe6413ef88398b54d956448e5762506f6f44f (patch)
tree28efabf041bb4f73b698f4c7c26d4038509ea5a8
parentd568f7ca9d7bf2d9dbf0b58d011ae8693ed6703e (diff)
recover from custom code faults
-rw-r--r--source/main.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/source/main.cpp b/source/main.cpp
index 4bdd5a2..596991d 100644
--- a/source/main.cpp
+++ b/source/main.cpp
@@ -160,3 +160,28 @@ void port_syscall(struct port_extctx *ctxp, uint32_t n)
chSysHalt("svc");
}
+void conversion_abort()
+{
+ elf_entry = nullptr;
+ dac::write_stop();
+ adc::read_stop();
+ signal_operate_done = true;
+}
+
+extern "C" {
+
+__attribute__((naked))
+void HardFault_Handler()
+{
+ uint32_t *stack;
+ asm("mrs %0, msp" : "=r" (stack));
+ stack[6] = stack[5];
+ stack[7] |= (1 << 24);
+
+ asm("push {lr}");
+ conversion_abort();
+ asm("pop {lr}; bx lr");
+}
+
+} // extern "C"
+