File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change 1+ //! Delays
2+
3+ use core:: future:: Future ;
4+
5+ /// Microsecond delay
6+ pub trait DelayUs {
7+ /// Enumeration of errors
8+ type Error : core:: fmt:: Debug ;
9+
10+ /// The future returned by the `delay_us` function.
11+ type DelayUsFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
12+ where
13+ Self : ' a ;
14+
15+ /// Pauses execution for at minimum `us` microseconds. Pause can be longer
16+ /// if the implementation requires it due to precision/timing issues.
17+ fn delay_us ( & mut self , us : u32 ) -> Self :: DelayUsFuture < ' _ > ;
18+
19+ /// The future returned by the `delay_ms` function.
20+ type DelayMsFuture < ' a > : Future < Output = Result < ( ) , Self :: Error > > + ' a
21+ where
22+ Self : ' a ;
23+
24+ /// Pauses execution for at minimum `ms` milliseconds. Pause can be longer
25+ /// if the implementation requires it due to precision/timing issues.
26+ fn delay_ms ( & mut self , ms : u32 ) -> Self :: DelayMsFuture < ' _ > ;
27+ }
28+
29+ impl < T > DelayUs for & mut T
30+ where
31+ T : DelayUs ,
32+ {
33+ type Error = T :: Error ;
34+
35+ type DelayUsFuture < ' a >
36+ where
37+ Self : ' a ,
38+ = T :: DelayUsFuture < ' a > ;
39+
40+ fn delay_us ( & mut self , us : u32 ) -> Self :: DelayUsFuture < ' _ > {
41+ T :: delay_us ( self , us)
42+ }
43+
44+ type DelayMsFuture < ' a >
45+ where
46+ Self : ' a ,
47+ = T :: DelayMsFuture < ' a > ;
48+
49+ fn delay_ms ( & mut self , ms : u32 ) -> Self :: DelayMsFuture < ' _ > {
50+ T :: delay_ms ( self , ms)
51+ }
52+ }
Original file line number Diff line number Diff line change 1010#![ deny( missing_docs) ]
1111#![ no_std]
1212#![ feature( generic_associated_types) ]
13+
14+ pub mod delay;
You can’t perform that action at this time.
0 commit comments