diff options
| author | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
|---|---|---|
| committer | 1-rafael-1 <[email protected]> | 2025-09-15 20:07:18 +0200 |
| commit | 6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch) | |
| tree | 5a1e255cff999b00800f203b91a759c720c973e5 /embassy-time/src/delay.rs | |
| parent | eb685574601d98c44faed9a3534d056199b46e20 (diff) | |
| parent | 92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff) | |
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'embassy-time/src/delay.rs')
| -rw-r--r-- | embassy-time/src/delay.rs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/embassy-time/src/delay.rs b/embassy-time/src/delay.rs index f77859d4a..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 | ||
| @@ -13,7 +15,8 @@ pub fn block_for(duration: Duration) { | |||
| 13 | /// the amount provided, but accuracy can be affected by many factors, including interrupt usage. | 15 | /// the amount provided, but accuracy can be affected by many factors, including interrupt usage. |
| 14 | /// Make sure to use a suitable tick rate for your use case. The tick rate is defined by the currently | 16 | /// Make sure to use a suitable tick rate for your use case. The tick rate is defined by the currently |
| 15 | /// active driver. | 17 | /// active driver. |
| 16 | #[derive(Clone)] | 18 | #[derive(Clone, Debug)] |
| 19 | #[cfg_attr(feature = "defmt", derive(defmt::Format))] | ||
| 17 | pub struct Delay; | 20 | pub struct Delay; |
| 18 | 21 | ||
| 19 | impl embedded_hal_1::delay::DelayNs for Delay { | 22 | impl embedded_hal_1::delay::DelayNs for Delay { |
| @@ -31,16 +34,16 @@ impl embedded_hal_1::delay::DelayNs for Delay { | |||
| 31 | } | 34 | } |
| 32 | 35 | ||
| 33 | impl embedded_hal_async::delay::DelayNs for Delay { | 36 | impl embedded_hal_async::delay::DelayNs for Delay { |
| 34 | async fn delay_ns(&mut self, ns: u32) { | 37 | fn delay_ns(&mut self, ns: u32) -> impl Future<Output = ()> { |
| 35 | Timer::after_nanos(ns as _).await | 38 | Timer::after_nanos(ns as _) |
| 36 | } | 39 | } |
| 37 | 40 | ||
| 38 | async fn delay_us(&mut self, us: u32) { | 41 | fn delay_us(&mut self, us: u32) -> impl Future<Output = ()> { |
| 39 | Timer::after_micros(us as _).await | 42 | Timer::after_micros(us as _) |
| 40 | } | 43 | } |
| 41 | 44 | ||
| 42 | async fn delay_ms(&mut self, ms: u32) { | 45 | fn delay_ms(&mut self, ms: u32) -> impl Future<Output = ()> { |
| 43 | Timer::after_millis(ms as _).await | 46 | Timer::after_millis(ms as _) |
| 44 | } | 47 | } |
| 45 | } | 48 | } |
| 46 | 49 | ||
