mirror of
https://github.com/rust-embedded/embedded-hal.git
synced 2026-03-14 01:47:38 +00:00
delay
This commit is contained in:
parent
5415ee164b
commit
bbb96243a2
26
src/blocking/delay.rs
Normal file
26
src/blocking/delay.rs
Normal 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);
|
||||
}
|
||||
@ -1,4 +1,5 @@
|
||||
//! Blocking API
|
||||
|
||||
pub mod delay;
|
||||
pub mod i2c;
|
||||
pub mod spi;
|
||||
|
||||
@ -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;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user