diff options
author | 2017-03-08 10:02:51 -0500 | |
---|---|---|
committer | 2017-03-08 10:02:51 -0500 | |
commit | 0e628b32ac27d47aa897dfd7930ddad85903bd37 (patch) | |
tree | cb3966272822615e5d2973af0cbbd314a5873b82 /src/asm.rs | |
parent | c3a35c1b6cea81aa71e8832bca79ccafa492be02 (diff) | |
download | cortex-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.rs | 54 |
1 files changed, 14 insertions, 40 deletions
@@ -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"); - } -} |