aboutsummaryrefslogtreecommitdiff
path: root/src/asm.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/asm.rs')
-rw-r--r--src/asm.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/asm.rs b/src/asm.rs
index 7b1a9ce..593aeac 100644
--- a/src/asm.rs
+++ b/src/asm.rs
@@ -81,6 +81,30 @@ 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") },
+
+ #[cfg(all(cortex_m, not(feature = "inline-asm")))]
+ () => unsafe {
+ extern "C" {
+ fn __udf();
+ }
+
+ __udf()
+ },
+
+ #[cfg(not(cortex_m))]
+ () => unimplemented!(),
+ }
+}
+
/// Wait For Event
#[inline]
pub fn wfe() {