From 659db95e0b2d9fa97b39b33c890e9176b1cd8e71 Mon Sep 17 00:00:00 2001 From: Sachymetsu Date: Thu, 16 Jul 2026 12:25:32 +0200 Subject: [PATCH] Non-debug panic handler --- src/main.rs | 2 ++ src/panic_handler.rs | 15 +++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/panic_handler.rs diff --git a/src/main.rs b/src/main.rs index 2c67886..6d488ee 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,6 +7,8 @@ mod ble; mod client; mod error; mod locks; +#[cfg(not(feature = "defmt"))] +mod panic_handler; mod timer; extern crate alloc; diff --git a/src/panic_handler.rs b/src/panic_handler.rs new file mode 100644 index 0000000..0b7cddf --- /dev/null +++ b/src/panic_handler.rs @@ -0,0 +1,15 @@ +use core::{ + panic::PanicInfo, + sync::atomic::{Ordering, compiler_fence}, +}; + +#[cfg(not(feature = "defmt"))] +#[inline(never)] +#[panic_handler] +fn panic_reset(_info: &PanicInfo) -> ! { + cortex_m::interrupt::disable(); + + // Halt execution and reset the chip. + compiler_fence(Ordering::SeqCst); + cortex_m::peripheral::SCB::sys_reset(); +} -- 2.51.2