aboutsummaryrefslogtreecommitdiff
path: root/embassy-time/src/delay.rs
diff options
context:
space:
mode:
author1-rafael-1 <[email protected]>2025-09-15 20:07:18 +0200
committer1-rafael-1 <[email protected]>2025-09-15 20:07:18 +0200
commit6bb3d2c0720fa082f27d3cdb70f516058497ec87 (patch)
tree5a1e255cff999b00800f203b91a759c720c973e5 /embassy-time/src/delay.rs
parenteb685574601d98c44faed9a3534d056199b46e20 (diff)
parent92a6fd2946f2cbb15359290f68aa360953da2ff7 (diff)
Merge branch 'main' into rp2040-rtc-alarm
Diffstat (limited to 'embassy-time/src/delay.rs')
-rw-r--r--embassy-time/src/delay.rs17
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 @@
1use core::future::Future;
2
1use super::{Duration, Instant}; 3use super::{Duration, Instant};
2use crate::Timer; 4use 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))]
17pub struct Delay; 20pub struct Delay;
18 21
19impl embedded_hal_1::delay::DelayNs for Delay { 22impl embedded_hal_1::delay::DelayNs for Delay {
@@ -31,16 +34,16 @@ impl embedded_hal_1::delay::DelayNs for Delay {
31} 34}
32 35
33impl embedded_hal_async::delay::DelayNs for Delay { 36impl 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