Add a user-defined HardFault handler to print ExceptionFrame in crash example

This commit is contained in:
30Wedge
2024-05-08 17:23:49 -04:00
parent cf52e9e29e
commit 6929b56b4a

View File

@@ -82,8 +82,10 @@
use panic_halt as _;
use core::ptr;
use core::fmt::Write;
use cortex_m_rt::entry;
use cortex_m_rt::{entry, exception, ExceptionFrame};
use cortex_m_semihosting::hio;
#[entry]
fn main() -> ! {
@@ -94,3 +96,12 @@ fn main() -> ! {
loop {}
}
#[exception]
fn HardFault(ef: &ExceptionFrame) -> ! {
if let Ok(mut hstdout) = hio::hstdout() {
writeln!(hstdout, "{:#?}", ef).ok();
}
loop {}
}