@@ -12,10 +12,10 @@ use crate::blocking::digital::InputPin;
12
12
/// /// Asynchronously wait until the `ready_pin` becomes high.
13
13
/// async fn wait_until_ready<P>(ready_pin: &P)
14
14
/// where
15
- /// P: AsyncInputPin ,
15
+ /// P: WaitFor ,
16
16
/// {
17
17
/// ready_pin
18
- /// .until_high ()
18
+ /// .wait_for_high ()
19
19
/// .await
20
20
/// .expect("failed to await input pin")
21
21
/// }
@@ -30,28 +30,37 @@ use crate::blocking::digital::InputPin;
30
30
/// /// Returns true is the pin became high or false if it timed-out.
31
31
/// async fn wait_until_ready_or_timeout<P, D>(ready_pin: &P, delay: &mut D) -> bool
32
32
/// where
33
- /// P: AsyncInputPin ,
33
+ /// P: WaitFor ,
34
34
/// D: Delay,
35
35
/// {
36
36
/// futures::select_biased! {
37
- /// x => ready_pin.until_high () => {
37
+ /// x => ready_pin.wait_for_high () => {
38
38
/// x.expect("failed to await input pin");
39
39
/// true
40
40
/// },
41
41
/// _ => delay.delay(Duration::from_millis(1)) => false, // ignore the error
42
42
/// }
43
43
/// }
44
44
/// ```
45
- pub trait AsyncInputPin : InputPin {
45
+ pub trait WaitFor : InputPin {
46
46
/// The future returned by the `until_high` function.
47
47
type UntilHighFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
48
48
49
49
/// The future returned by the `until_low` function.
50
50
type UntilLowFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
51
51
52
- /// Returns a future that resolves when this pin becomes high.
53
- fn until_high < ' a > ( & self ) -> Self :: UntilHighFuture < ' a > ;
52
+ /// Returns a future that resolves when this pin _is_ high. If the pin
53
+ /// is already high, the future resolves immediately.
54
+ ///
55
+ /// # Note for implementers
56
+ /// The pin may have switched back to low before the task was run after
57
+ /// being woken. The future should still resolve in that case.
58
+ fn wait_for_high < ' a > ( & ' a mut self ) -> Self :: UntilHighFuture < ' a > ;
54
59
55
- /// Returns a future that resolves when this pin becomes high.
56
- fn until_low < ' a > ( & self ) -> Self :: UntilLowFuture < ' a > ;
60
+ /// Returns a future that resolves when this pin becomes low.
61
+ ///
62
+ /// # Note for implementers
63
+ /// The pin may have switched back to high before the task was run after
64
+ /// being woken. The future should still resolve in that case.
65
+ fn wait_for_low < ' a > ( & ' a mut self ) -> Self :: UntilLowFuture < ' a > ;
57
66
}
0 commit comments