| 1 | //! Delays |
| 2 | //! |
| 3 | //! # What's the difference between these traits and the `timer::CountDown` trait? |
| 4 | //! |
| 5 | //! The `Timer` trait provides a *non-blocking* timer abstraction and it's meant to be used to build |
| 6 | //! higher level abstractions like I/O operations with timeouts. OTOH, these delays traits only |
| 7 | //! provide *blocking* functionality. Note that you can also use the `timer::CountDown` trait to |
| 8 | //! implement blocking delays. |
| 9 | |
| 10 | /// Millisecond delay |
| 11 | /// |
| 12 | /// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can |
| 13 | /// implement this trait for different types of `UXX`. |
| 14 | pub trait DelayMs<UXX> { |
| 15 | /// Pauses execution for `ms` milliseconds |
| 16 | fn delay_ms(&mut self, ms: UXX); |
| 17 | } |
| 18 | |
| 19 | /// Microsecond delay |
| 20 | /// |
| 21 | /// `UXX` denotes the range type of the delay time. `UXX` can be `u8`, `u16`, etc. A single type can |
| 22 | /// implement this trait for different types of `UXX`. |
| 23 | pub trait DelayUs<UXX> { |
| 24 | /// Pauses execution for `us` microseconds |
| 25 | fn delay_us(&mut self, us: UXX); |
| 26 | } |
| 27 | |