#[macro_export]
macro_rules! iprint {
($channel:expr, $s:expr) => {
$crate::itm::write_str($channel, $s);
};
($channel:expr, $($arg:tt)*) => {
$crate::itm::write_fmt($channel, format_args!($($arg)*));
};
}
#[macro_export]
macro_rules! iprintln {
($channel:expr) => {
$crate::itm::write_str($channel, "\n");
};
($channel:expr, $fmt:expr) => {
$crate::itm::write_str($channel, concat!($fmt, "\n"));
};
($channel:expr, $fmt:expr, $($arg:tt)*) => {
$crate::itm::write_fmt($channel, format_args!(concat!($fmt, "\n"), $($arg)*));
};
}
#[macro_export]
macro_rules! singleton {
(: $ty:ty = $expr:expr) => {
$crate::interrupt::free(|_| {
static mut VAR: Option<$ty> = None;
#[allow(unsafe_code)]
let used = unsafe { VAR.is_some() };
if used {
None
} else {
let expr = $expr;
#[allow(unsafe_code)]
unsafe {
VAR = Some(expr)
}
#[allow(unsafe_code)]
unsafe {
VAR.as_mut()
}
}
})
};
}
#[allow(dead_code)]
const CFAIL: () = ();
#[allow(dead_code)]
const CPASS: () = ();