#[derive(Debug, Clone, Copy)]
pub struct Delay {
_0: (),
}
impl Delay {
pub const fn new() -> Delay {
Delay { _0: () }
}
}
impl Default for Delay {
fn default() -> Self {
Delay::new()
}
}
impl eh1::delay::DelayNs for Delay {
fn delay_ns(&mut self, ns: u32) {
std::thread::sleep(std::time::Duration::from_nanos(ns.into()))
}
fn delay_us(&mut self, us: u32) {
std::thread::sleep(std::time::Duration::from_micros(us.into()))
}
fn delay_ms(&mut self, ms: u32) {
std::thread::sleep(std::time::Duration::from_millis(ms.into()))
}
}
macro_rules! impl_eh0_delay_for {
($UXX:ty) => {
impl eh0::blocking::delay::DelayMs<$UXX> for Delay {
fn delay_ms(&mut self, ms: $UXX) {
std::thread::sleep(std::time::Duration::from_millis(ms.into()))
}
}
impl eh0::blocking::delay::DelayUs<$UXX> for Delay {
fn delay_us(&mut self, us: $UXX) {
std::thread::sleep(std::time::Duration::from_micros(us.into()))
}
}
};
}
impl_eh0_delay_for!(u8);
impl_eh0_delay_for!(u16);
impl_eh0_delay_for!(u32);
impl_eh0_delay_for!(u64);