aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Adam Greig <adam@adamgreig.com> 2020-03-15 19:40:37 +0000
committerGravatar Adam Greig <adam@adamgreig.com> 2020-03-15 19:40:47 +0000
commit539c6d00fffabaf7c3f61f2f8c1aaefa661fa500 (patch)
treea54c12251a7e7cbdafe6b2ee8909ab5acf63b492 /src
parent1cb6baf8bd46b602c01d51e7a3c5c6e77af9c8f2 (diff)
downloadcortex-m-539c6d00fffabaf7c3f61f2f8c1aaefa661fa500.tar.gz
cortex-m-539c6d00fffabaf7c3f61f2f8c1aaefa661fa500.tar.zst
cortex-m-539c6d00fffabaf7c3f61f2f8c1aaefa661fa500.zip
Add UDF instruction. Closes #199.
Diffstat (limited to 'src')
-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() {