diff options
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"); - } -} |