|
9 | 9 |
|
10 | 10 | /// Blocking delay traits
|
11 | 11 | pub mod blocking {
|
12 |
| - /// Millisecond delay |
| 12 | + /// Microsecond delay |
13 | 13 | ///
|
14 |
| - /// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can |
15 |
| - /// implement this trait for different types of `UXX`. |
16 |
| - pub trait DelayMs<UXX> { |
17 |
| - /// Enumeration of `DelayMs` errors |
| 14 | + pub trait DelayUs { |
| 15 | + /// Enumeration of `DelayUs` errors |
18 | 16 | type Error: core::fmt::Debug;
|
19 | 17 |
|
20 |
| - /// Pauses execution for `ms` milliseconds |
21 |
| - fn delay_ms(&mut self, ms: UXX) -> Result<(), Self::Error>; |
22 |
| - } |
| 18 | + /// Pauses execution for at minimum `us` microseconds. Pause can be longer |
| 19 | + /// if the implementation requires it due to precision/timing issues. |
| 20 | + fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>; |
23 | 21 |
|
24 |
| - /// Microsecond delay |
25 |
| - /// |
26 |
| - /// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can |
27 |
| - /// implement this trait for different types of `UXX`. |
28 |
| - pub trait DelayUs<UXX> { |
29 |
| - /// Enumeration of `DelayMs` errors |
30 |
| - type Error: core::fmt::Debug; |
| 22 | + /// Pauses execution for at minimum `ms` milliseconds. Pause can be longer |
| 23 | + /// if the implementation requires it due to precision/timing issues. |
| 24 | + fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> { |
| 25 | + for _ in 0..ms { |
| 26 | + self.delay_us(1000)?; |
| 27 | + } |
31 | 28 |
|
32 |
| - /// Pauses execution for `us` microseconds |
33 |
| - fn delay_us(&mut self, us: UXX) -> Result<(), Self::Error>; |
| 29 | + Ok(()) |
| 30 | + } |
34 | 31 | }
|
35 | 32 | }
|
0 commit comments