diff options
Diffstat (limited to 'src/asm.rs')
-rw-r--r-- | src/asm.rs | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -81,6 +81,35 @@ pub fn nop() { } } + +/// Generate an Undefined Instruction exception. +/// +/// Can be used as a stable alternative to `core::intrinsics::abort`. +#[inline] +pub fn udf() -> ! { + match () { + #[cfg(all(cortex_m, feature = "inline-asm"))] + () => unsafe { + asm!("udf" :::: "volatile"); + core::hint::unreachable_unchecked(); + }, + + #[cfg(all(cortex_m, not(feature = "inline-asm")))] + () => unsafe { + extern "C" { + fn __udf(); + } + + __udf(); + + core::hint::unreachable_unchecked(); + }, + + #[cfg(not(cortex_m))] + () => unimplemented!(), + } +} + /// Wait For Event #[inline] pub fn wfe() { |