Skip to content

Commit a8107cc

Browse files
committed
unify DelayUs and DelayMs to DelayUs for v1.0
1 parent bd7f607 commit a8107cc

File tree

2 files changed

+16
-17
lines changed

2 files changed

+16
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Removed
11+
- Removed `DelayMs` in favor of `DelayUs` with `u32` as type for clarity.
1012

1113
## [v1.0.0-alpha.5] - 2021-09-11
1214

src/delay.rs

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,24 @@
99
1010
/// Blocking delay traits
1111
pub mod blocking {
12-
/// Millisecond delay
12+
/// Microsecond delay
1313
///
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
1816
type Error: core::fmt::Debug;
1917

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>;
2321

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+
}
3128

32-
/// Pauses execution for `us` microseconds
33-
fn delay_us(&mut self, us: UXX) -> Result<(), Self::Error>;
29+
Ok(())
30+
}
3431
}
3532
}

0 commit comments

Comments
 (0)