diff options
| author | Dario Nieuwenhuis <[email protected]> | 2025-08-19 13:16:22 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-08-19 13:16:22 +0000 |
| commit | 61dbd89bd4648cc6b16017bbbf4db8f5fdcb109a (patch) | |
| tree | 1467f0dd3a400212a1b0b8a33b54d66b2e769cda /embassy-time | |
| parent | 271611c4b16055eabc367770c6341944c9d5ae9c (diff) | |
| parent | 011c382b7785485b632d567d941ff670797a0d74 (diff) | |
Merge pull request #4560 from 823984418/optimize_async_delay
Optimize embedded_hal_async::delay::DelayNs impl
Diffstat (limited to 'embassy-time')
| -rw-r--r-- | embassy-time/src/delay.rs | 14 |
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 @@ | |||
| 1 | use core::future::Future; | ||
| 2 | |||
| 1 | use super::{Duration, Instant}; | 3 | use super::{Duration, Instant}; |
| 2 | use crate::Timer; | 4 | use crate::Timer; |
| 3 | 5 | ||
| @@ -32,16 +34,16 @@ impl embedded_hal_1::delay::DelayNs for Delay { | |||
| 32 | } | 34 | } |
| 33 | 35 | ||
| 34 | impl embedded_hal_async::delay::DelayNs for Delay { | 36 | impl 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 | ||
