cortex-m 0.7.8

Low level access to Cortex-M processors
Documentation
//! Link register

#[cfg(cortex_m)]
use core::arch::asm;
use cortex_m_macros::asm_cfg;

/// Reads the CPU register
#[inline]
#[asm_cfg(cortex_m)]
pub fn read() -> u32 {
    let r;
    unsafe { asm!("mov {}, lr", out(reg) r, options(nomem, nostack, preserves_flags)) };
    r
}

/// Writes `bits` to the CPU register
///
/// # Safety
/// This function can't be used soundly.
#[inline]
#[deprecated = "This function can't be used soundly."]
#[asm_cfg(cortex_m)]
pub unsafe fn write(bits: u32) {
    unsafe { asm!("mov lr, {}", in(reg) bits, options(nomem, nostack, preserves_flags)) };
}