1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#[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()
}
}
macro_rules! impl_delay_for {
($UXX:ty) => {
impl embedded_hal::blocking::delay::DelayMs<$UXX> for Delay {
fn delay_ms(&mut self, ms: $UXX) {
std::thread::sleep(std::time::Duration::from_millis(ms.into()))
}
}
impl embedded_hal::blocking::delay::DelayUs<$UXX> for Delay {
fn delay_us(&mut self, us: $UXX) {
std::thread::sleep(std::time::Duration::from_micros(us.into()))
}
}
};
}
impl_delay_for!(u8);
impl_delay_for!(u16);
impl_delay_for!(u32);
impl_delay_for!(u64);