This commit is contained in:
Jorge Aparicio 2018-01-09 22:22:07 +01:00
parent 5415ee164b
commit bbb96243a2
3 changed files with 29 additions and 0 deletions

26
src/blocking/delay.rs Normal file
View File

@ -0,0 +1,26 @@
//! Delays
//!
//! # What's the difference between these traits and the `Timer` trait?
//!
//! The `Timer` trait provides a *non-blocking* timer abstraction and it's meant to be used to build
//! higher level abstractions like I/O operations with timeouts. OTOH, these delays traits only
//! provide blocking functionality. Note that you can also use the `Timer` trait to implement
//! blocking delays.
/// 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 DelayMs<UXX> {
/// Pauses execution for `ms` milliseconds
fn delay_ms(&mut self, ms: UXX);
}
/// 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 DelayUs<UXX> {
/// Pauses execution for `us` microseconds
fn delay_us(&mut self, us: UXX);
}

View File

@ -1,4 +1,5 @@
//! Blocking API
pub mod delay;
pub mod i2c;
pub mod spi;

View File

@ -8,6 +8,8 @@ pub use ::Pwm as _embedded_hal_Pwm;
pub use ::PwmPin as _embedded_hal_PwmPin;
pub use ::Qei as _embedded_hal_Qei;
pub use ::Timer as _embedded_hal_Timer;
pub use ::blocking::delay::DelayMs as _embedded_hal_blocking_delay_DelayMs;
pub use ::blocking::delay::DelayUs as _embedded_hal_blocking_delay_DelayUs;
pub use ::digital::OutputPin as _embedded_hal_digital_OutputPin;
pub use ::serial::Read as _embedded_hal_serial_Read;
pub use ::serial::Write as _embedded_hal_serial_Write;