diff options
author | 2018-08-07 18:57:41 -0500 | |
---|---|---|
committer | 2018-08-07 18:59:51 -0500 | |
commit | 335856a05a9cd4d78b3dd4e2348fdd5702edb9ba (patch) | |
tree | 769033ab47421b56ed6710cff6c5be095b654404 /cortex-m-rt/src | |
parent | 7865725aacf3c9718902361b9d9919b7bebce7be (diff) | |
download | cortex-m-335856a05a9cd4d78b3dd4e2348fdd5702edb9ba.tar.gz cortex-m-335856a05a9cd4d78b3dd4e2348fdd5702edb9ba.tar.zst cortex-m-335856a05a9cd4d78b3dd4e2348fdd5702edb9ba.zip |
[WIP] provide defaults for DefaultHandler and HardFault
`exception!(HardFault, ..)` and `exception!(*, ..)` can now be omitted from
programs to pick up the default behavior of an infinite loop. Existing programs
that define these exception handlers will continue to work w/o any functional
change.
closes #72
Diffstat (limited to 'cortex-m-rt/src')
-rw-r--r-- | cortex-m-rt/src/lib.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/cortex-m-rt/src/lib.rs b/cortex-m-rt/src/lib.rs index e55171a..60c8034 100644 --- a/cortex-m-rt/src/lib.rs +++ b/cortex-m-rt/src/lib.rs @@ -390,7 +390,7 @@ extern crate r0; -use core::fmt; +use core::{fmt, ptr}; /// Registers stacked (pushed into the stack) during an exception #[derive(Clone, Copy)] @@ -511,6 +511,26 @@ pub unsafe extern "C" fn Reset() -> ! { } } +#[doc(hidden)] +#[no_mangle] +pub unsafe extern "C" fn DefaultDefaultHandler() { + loop { + // add some side effect to prevent this from turning into a UDF instruction + // see rust-lang/rust#28728 + ptr::read_volatile(&0u8); + } +} + +#[doc(hidden)] +#[no_mangle] +pub unsafe extern "C" fn DefaultUserHardFault() { + loop { + // add some side effect to prevent this from turning into a UDF instruction + // see rust-lang/rust#28728 + ptr::read_volatile(&0u8); + } +} + /// Macro to define the entry point of the program /// /// **NOTE** This macro must be invoked once and must be invoked from an accessible module, ideally |