| 1 | //! Main Stack Pointer |
| 2 | |
| 3 | /// Reads the CPU register |
| 4 | #[inline ] |
| 5 | pub fn read() -> u32 { |
| 6 | call_asm!(__msp_r() -> u32) |
| 7 | } |
| 8 | |
| 9 | /// Writes `bits` to the CPU register |
| 10 | #[inline ] |
| 11 | #[deprecated = "calling this function invokes Undefined Behavior, consider asm::bootstrap as an alternative" ] |
| 12 | pub unsafe fn write(bits: u32) { |
| 13 | call_asm!(__msp_w(bits: u32)); |
| 14 | } |
| 15 | |
| 16 | /// Reads the Non-Secure CPU register from Secure state. |
| 17 | /// |
| 18 | /// Executing this function in Non-Secure state will return zeroes. |
| 19 | #[cfg (armv8m)] |
| 20 | #[inline ] |
| 21 | pub fn read_ns() -> u32 { |
| 22 | call_asm!(__msp_ns_r() -> u32) |
| 23 | } |
| 24 | |
| 25 | /// Writes `bits` to the Non-Secure CPU register from Secure state. |
| 26 | /// |
| 27 | /// Executing this function in Non-Secure state will be ignored. |
| 28 | #[cfg (armv8m)] |
| 29 | #[inline ] |
| 30 | pub unsafe fn write_ns(bits: u32) { |
| 31 | call_asm!(__msp_ns_w(bits: u32)); |
| 32 | } |
| 33 | |