aboutsummaryrefslogtreecommitdiff
path: root/src/asm.rs
diff options
context:
space:
mode:
authorGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-08 10:02:51 -0500
committerGravatar Jorge Aparicio <japaricious@gmail.com> 2017-03-08 10:02:51 -0500
commit0e628b32ac27d47aa897dfd7930ddad85903bd37 (patch)
treecb3966272822615e5d2973af0cbbd314a5873b82 /src/asm.rs
parentc3a35c1b6cea81aa71e8832bca79ccafa492be02 (diff)
downloadcortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.tar.gz
cortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.tar.zst
cortex-m-0e628b32ac27d47aa897dfd7930ddad85903bd37.zip
turn bkpt! into a function
Diffstat (limited to 'src/asm.rs')
-rw-r--r--src/asm.rs54
1 files changed, 14 insertions, 40 deletions
diff --git a/src/asm.rs b/src/asm.rs
index b94d4ef..c82d45d 100644
--- a/src/asm.rs
+++ b/src/asm.rs
@@ -3,45 +3,30 @@
/// Puts the processor in Debug state. Debuggers can pick this up as a
/// "breakpoint".
///
-/// Optionally, an "immediate" value (in the 0-255 range) can be passed to
-/// `bkpt!`. The debugger can then read this value using the Program Counter
-/// (PC).
-#[cfg(target_arch = "arm")]
-#[macro_export]
-macro_rules! bkpt {
- () => {
+/// NOTE calling `bkpt` when the processor is not connected to a debugger will
+/// cause an exception
+#[inline(always)]
+pub fn bkpt() {
+ #[cfg(target_arch = "arm")]
+ unsafe {
asm!("bkpt"
:
:
:
: "volatile");
- };
- ($imm:expr) => {
- asm!(concat!("bkpt #", stringify!($imm))
+ }
+}
+
+/// A no-operation. Useful to prevent delay loops from being optimized away.
+pub fn nop() {
+ unsafe {
+ asm!("nop"
:
:
:
: "volatile");
- };
-}
-
-/// Puts the processor in Debug state. Debuggers can pick this up as a
-/// "breakpoint".
-///
-/// Optionally, an "immediate" value (in the 0-255 range) can be passed to
-/// `bkpt!`. The debugger can then read this value using the Program Counter
-/// (PC).
-#[cfg(not(target_arch = "arm"))]
-#[macro_export]
-macro_rules! bkpt {
- () => {
- asm!("");
- };
- ($e:expr) => {
- asm!("");
- };
+ }
}
-
/// Wait For Event
pub fn wfe() {
match () {
@@ -73,14 +58,3 @@ pub fn wfi() {
() => {}
}
}
-
-/// A no-operation. Useful to prevent delay loops from being optimized away.
-pub fn nop() {
- unsafe {
- asm!("nop"
- :
- :
- :
- : "volatile");
- }
-}