Skip to content

Commit 5fe9c7a

Browse files
committed
Also implement delay_us and delay_ms.
1 parent 78527ac commit 5fe9c7a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/delay.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,27 @@ impl DelayNs for Delay {
1414
fn delay_ns(&mut self, n: u32) {
1515
thread::sleep(Duration::from_nanos(n.into()));
1616
}
17+
18+
fn delay_us(&mut self, n: u32) {
19+
thread::sleep(Duration::from_micros(n.into()));
20+
}
21+
22+
fn delay_ms(&mut self, n: u32) {
23+
thread::sleep(Duration::from_millis(n.into()));
24+
}
1725
}
1826

1927
#[cfg(feature = "async-tokio")]
2028
impl embedded_hal_async::delay::DelayNs for Delay {
2129
async fn delay_ns(&mut self, n: u32) {
2230
tokio::time::sleep(Duration::from_nanos(n.into())).await;
2331
}
32+
33+
async fn delay_us(&mut self, n: u32) {
34+
tokio::time::sleep(Duration::from_micros(n.into())).await;
35+
}
36+
37+
async fn delay_ms(&mut self, n: u32) {
38+
tokio::time::sleep(Duration::from_millis(n.into())).await;
39+
}
2440
}

0 commit comments

Comments
 (0)