//! # Wrapping ARMv7-A Instructions //! //! This provides bindings for assembly instructions //! to be used in other rust functions without `unsafe` //! markers everywhere. /// # Wait for event #[inline(always)] pub fn wfe() { unsafe { core::arch::asm!("wfe", options(nomem, nostack)) } } /// # No Operation #[inline(always)] pub fn nop() { unsafe { core::arch::asm!("nop", options(nomem, nostack)) } } /// # Store u32 to memory address #[inline] pub fn store32(addr: u32, value: u32) { unsafe { *(addr as *mut u32) = value; } } /// # Read u32 from memory address #[inline] pub fn load32(addr: u32) -> u32 { unsafe { *(addr as *mut u32) } } /// # Spin CPU for `n` cycles #[inline] pub fn spin_for_n_cycles(n: u32) { unsafe { core::arch::asm!("1: subs r1, #1 bne 1b", in("r1") n); } } /// # Switch to user mode #[inline] pub fn usr_mode() { unsafe { core::arch::asm!("cps 0x10"); } }