-
Notifications
You must be signed in to change notification settings - Fork 269
Expand file tree
/
Copy pathdelay.rs
More file actions
30 lines (24 loc) · 877 Bytes
/
delay.rs
File metadata and controls
30 lines (24 loc) · 877 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
//! Delays
/// Microsecond delay
pub trait DelayUs {
/// Enumeration of errors
type Error: core::fmt::Debug;
/// Pauses execution for at minimum `us` microseconds. Pause can be longer
/// if the implementation requires it due to precision/timing issues.
async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error>;
/// Pauses execution for at minimum `ms` milliseconds. Pause can be longer
/// if the implementation requires it due to precision/timing issues.
async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error>;
}
impl<T> DelayUs for &mut T
where
T: DelayUs,
{
type Error = T::Error;
async fn delay_us(&mut self, us: u32) -> Result<(), Self::Error> {
T::delay_us(self, us).await
}
async fn delay_ms(&mut self, ms: u32) -> Result<(), Self::Error> {
T::delay_ms(self, ms).await
}
}