1use crate::scb;
6
7#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
8#[inline(always)]
9pub fn nop() {
11 use core::arch::asm;
12 unsafe {
13 asm!("nop", options(nomem, nostack, preserves_flags));
14 }
15}
16
17#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
18#[inline(always)]
19pub unsafe fn wfi() {
21 use core::arch::asm;
22 asm!("wfi", options(nomem, preserves_flags));
23}
24
25#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
26pub unsafe fn atomic<F, R>(f: F) -> R
27where
28 F: FnOnce() -> R,
29{
30 use core::arch::asm;
31 asm!("cpsid i", options(nomem, nostack));
33
34 let res = f();
35
36 asm!("cpsie i", options(nomem, nostack));
38 res
39}
40
41#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
43pub fn nop() {
45 unimplemented!()
46}
47
48#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
49pub unsafe fn wfi() {
51 unimplemented!()
52}
53
54#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
55pub unsafe fn atomic<F, R>(_f: F) -> R
56where
57 F: FnOnce() -> R,
58{
59 unimplemented!()
60}
61
62pub fn reset() -> ! {
63 unsafe {
64 scb::reset();
65 }
66 loop {
67 nop();
70 }
71}