Skip to content

Commit 3f3f3e8

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

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-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: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,22 @@
99
1010
/// Blocking delay traits
1111
pub mod blocking {
12-
/// Millisecond delay
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
18-
type Error: core::fmt::Debug;
19-
20-
/// Pauses execution for `ms` milliseconds
21-
fn delay_ms(&mut self, ms: UXX) -> Result<(), Self::Error>;
22-
}
23-
2412
/// Microsecond delay
2513
///
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
14+
pub trait DelayUs {
15+
/// Enumeration of `DelayUs` errors
3016
type Error: core::fmt::Debug;
3117

3218
/// Pauses execution for `us` microseconds
33-
fn delay_us(&mut self, us: UXX) -> Result<(), Self::Error>;
19+
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>;
20+
21+
/// Pauses execution for `ms` milliseconds
22+
fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
23+
for _ in 0..ms {
24+
self.delay_us(1000)?;
25+
}
26+
27+
Ok(())
28+
}
3429
}
3530
}

0 commit comments

Comments
 (0)