Merge pull request #125 from 30Wedge/fix-crash-example
Add a user-defined HardFault handler to print ExceptionFrame in crash…
This commit is contained in:
@@ -82,8 +82,10 @@
|
|||||||
use panic_halt as _;
|
use panic_halt as _;
|
||||||
|
|
||||||
use core::ptr;
|
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]
|
#[entry]
|
||||||
fn main() -> ! {
|
fn main() -> ! {
|
||||||
@@ -94,3 +96,12 @@ fn main() -> ! {
|
|||||||
|
|
||||||
loop {}
|
loop {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[exception]
|
||||||
|
fn HardFault(ef: &ExceptionFrame) -> ! {
|
||||||
|
if let Ok(mut hstdout) = hio::hstdout() {
|
||||||
|
writeln!(hstdout, "{:#?}", ef).ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
loop {}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user