#![cfg_attr(feature = "std", allow(unused_variables, unreachable_code))]
#[inline]
pub fn wait_for_int() {
#[cfg(feature = "std")]
return unimplemented!();
#[cfg(not(feature = "std"))]
unsafe {
asm!("wfi", options(nomem, nostack, preserves_flags))
}
}
#[inline]
pub fn wait_for_event() {
#[cfg(feature = "std")]
return unimplemented!();
#[cfg(not(feature = "std"))]
unsafe {
asm!("wfe", options(nomem, nostack, preserves_flags));
}
}
#[inline]
pub fn send_event() {
#[cfg(feature = "std")]
return unimplemented!();
#[cfg(not(feature = "std"))]
unsafe {
asm!("sev", options(nomem, nostack, preserves_flags));
}
}
#[allow(clippy::empty_loop)]
#[inline]
pub fn self_reset() -> ! {
#[cfg(feature = "std")]
return unimplemented!();
#[cfg(not(feature = "std"))]
unsafe {
use crate::{map::reg::scb, reg::prelude::*};
use drone_core::token::Token;
asm!("dmb", "cpsid f", options(nomem, nostack, preserves_flags),);
scb::Aircr::<Urt>::take().store(|r| r.write_vectkey(0x05FA).set_sysresetreq());
loop {}
}
}
#[inline(always)]
pub fn spin(cycles: u32) {
#[cfg(feature = "std")]
return unimplemented!();
#[cfg(not(feature = "std"))]
unsafe {
asm!(
"0: subs {0}, {0}, #3",
" bhi 0b",
inlateout(reg) cycles => _,
options(nomem, nostack),
);
}
}
#[cfg(feature = "floating-point-unit")]
#[inline]
pub unsafe fn fpu_init(full_access: bool) {
const FPU_CPACR: usize = 0xE000_ED88;
unsafe {
core::ptr::write_volatile(
FPU_CPACR as *mut u32,
if full_access {
0xF } else {
0x5 } << 20,
);
}
}