1#[cfg(cortex_m)]
4use core::arch::asm;
5use cortex_m_macros::asm_cfg;
6
7#[inline]
9#[asm_cfg(cortex_m)]
10pub fn read() -> u32 {
11 let r;
12 unsafe { asm!("mrs {}, MSP", out(reg) r, options(nomem, nostack, preserves_flags)) };
13 r
14}
15
16#[inline]
18#[deprecated = "calling this function invokes Undefined Behavior, consider asm::bootstrap as an alternative"]
19#[asm_cfg(cortex_m)]
20pub unsafe fn write(bits: u32) {
21 unsafe { asm!("msr MSP, {}", in(reg) bits, options(nomem, nostack, preserves_flags)) };
26}
27
28#[inline]
32#[asm_cfg(armv8m)]
33pub fn read_ns() -> u32 {
34 let r;
35 unsafe { asm!("mrs {}, MSP_NS", out(reg) r, options(nomem, nostack, preserves_flags)) };
36 r
37}
38
39#[inline]
43#[asm_cfg(armv8m)]
44pub unsafe fn write_ns(bits: u32) {
45 unsafe { asm!("msr MSP_NS, {}", in(reg) bits, options(nomem, nostack, preserves_flags)) };
46}