@@ -12,10 +12,10 @@ use crate::blocking::digital::InputPin;
1212/// /// Asynchronously wait until the `ready_pin` becomes high.
1313/// async fn wait_until_ready<P>(ready_pin: &P)
1414/// where
15- /// P: AsyncInputPin ,
15+ /// P: WaitFor ,
1616/// {
1717/// ready_pin
18- /// .until_high ()
18+ /// .wait_for_high ()
1919/// .await
2020/// .expect("failed to await input pin")
2121/// }
@@ -30,28 +30,37 @@ use crate::blocking::digital::InputPin;
3030/// /// Returns true is the pin became high or false if it timed-out.
3131/// async fn wait_until_ready_or_timeout<P, D>(ready_pin: &P, delay: &mut D) -> bool
3232/// where
33- /// P: AsyncInputPin ,
33+ /// P: WaitFor ,
3434/// D: Delay,
3535/// {
3636/// futures::select_biased! {
37- /// x => ready_pin.until_high () => {
37+ /// x => ready_pin.wait_for_high () => {
3838/// x.expect("failed to await input pin");
3939/// true
4040/// },
4141/// _ => delay.delay(Duration::from_millis(1)) => false, // ignore the error
4242/// }
4343/// }
4444/// ```
45- pub trait AsyncInputPin : InputPin {
45+ pub trait WaitFor : InputPin {
4646 /// The future returned by the `until_high` function.
4747 type UntilHighFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
4848
4949 /// The future returned by the `until_low` function.
5050 type UntilLowFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
5151
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 > ;
5459
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 > ;
5766}
0 commit comments