use crate::scb;
#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
#[inline(always)]
pub fn nop() {
use core::arch::asm;
unsafe {
asm!("nop", options(nomem, nostack, preserves_flags));
}
}
#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
#[inline(always)]
pub unsafe fn wfi() {
use core::arch::asm;
asm!("wfi", options(nomem, preserves_flags));
}
#[cfg(any(doc, all(target_arch = "arm", target_os = "none")))]
pub unsafe fn atomic<F, R>(f: F) -> R
where
F: FnOnce() -> R,
{
use core::arch::asm;
asm!("cpsid i", options(nomem, nostack));
let res = f();
asm!("cpsie i", options(nomem, nostack));
res
}
#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
pub fn nop() {
unimplemented!()
}
#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
pub unsafe fn wfi() {
unimplemented!()
}
#[cfg(not(any(doc, all(target_arch = "arm", target_os = "none"))))]
pub unsafe fn atomic<F, R>(_f: F) -> R
where
F: FnOnce() -> R,
{
unimplemented!()
}
pub fn reset() -> ! {
unsafe {
scb::reset();
}
loop {
nop();
}
}