Skip to content

Simplify blocking Delay. #313

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Removed the various `Default` marker traits.
- Removed `&[W]` returned slice in `spi::blocking::Transfer`.
- Require all associated error types to implement `core::fmt::Debug`.
- Simplified delay traits: removed `DelayMs`, changed `DelayUs` to use u32 instead of generic width integers.

### Removed
- Removed random number generation (`rng`) traits in favor of [rand_core](https://crates.io/crates/rand_core).
Expand Down
23 changes: 4 additions & 19 deletions src/delay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,12 @@

/// Blocking delay traits
pub mod blocking {
/// Millisecond delay
///
/// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can
/// implement this trait for different types of `UXX`.
pub trait DelayMs<UXX> {
/// Enumeration of `DelayMs` errors
type Error: core::fmt::Debug;

/// Pauses execution for `ms` milliseconds
fn delay_ms(&mut self, ms: UXX) -> Result<(), Self::Error>;
}

/// Microsecond delay
///
/// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can
/// implement this trait for different types of `UXX`.
pub trait DelayUs<UXX> {
/// Enumeration of `DelayMs` errors
/// Simple microsecond delay
pub trait DelayUs {
/// Enumeration of `DelayUs` errors
type Error: core::fmt::Debug;

/// Pauses execution for `us` microseconds
fn delay_us(&mut self, us: UXX) -> Result<(), Self::Error>;
fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>;
}
}