aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/delay.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2025-08-19 13:16:22 +0000
committerGitHub <[email protected]>2025-08-19 13:16:22 +0000
commit61dbd89bd4648cc6b16017bbbf4db8f5fdcb109a (patch)
tree1467f0dd3a400212a1b0b8a33b54d66b2e769cda /embassy-time/src/delay.rs
parent271611c4b16055eabc367770c6341944c9d5ae9c (diff)
parent011c382b7785485b632d567d941ff670797a0d74 (diff)
Merge pull request #4560 from 823984418/optimize_async_delay
Optimize embedded_hal_async::delay::DelayNs impl
Diffstat (limited to 'embassy-time/src/delay.rs')
-rw-r--r--embassy-time/src/delay.rs14
1 files changed, 8 insertions, 6 deletions
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs
index 67345f726..11b54b098 100644
--- a/embassy-time/src/delay.rs
+++ b/embassy-time/src/delay.rs
@@ -1,3 +1,5 @@
1use core::future::Future;
2
1use super::{Duration, Instant}; 3use super::{Duration, Instant};
2use crate::Timer; 4use crate::Timer;
3 5
@@ -32,16 +34,16 @@ impl embedded_hal_1::delay::DelayNs for Delay {
32} 34}
33 35
34impl embedded_hal_async::delay::DelayNs for Delay { 36impl embedded_hal_async::delay::DelayNs for Delay {
35 async fn delay_ns(&mut self, ns: u32) { 37 fn delay_ns(&mut self, ns: u32) -> impl Future<Output = ()> {
36 Timer::after_nanos(ns as _).await 38 Timer::after_nanos(ns as _)
37 } 39 }
38 40
39 async fn delay_us(&mut self, us: u32) { 41 fn delay_us(&mut self, us: u32) -> impl Future<Output = ()> {
40 Timer::after_micros(us as _).await 42 Timer::after_micros(us as _)
41 } 43 }
42 44
43 async fn delay_ms(&mut self, ms: u32) { 45 fn delay_ms(&mut self, ms: u32) -> impl Future<Output = ()> {
44 Timer::after_millis(ms as _).await 46 Timer::after_millis(ms as _)
45 } 47 }
46} 48}
47 49