@@ -14,14 +14,18 @@ use crate::blocking::digital::InputPin;
1414/// where
1515/// P: AsyncInputPin,
1616/// {
17- /// ready_pin.until_high().await
17+ /// ready_pin
18+ /// .until_high()
19+ /// .await
20+ /// .expect("failed to await input pin")
1821/// }
1922/// ```
2023///
2124/// ```rust,ignore
2225/// # use embedded_hal::futures::digital::AsyncInputPin;
2326/// # use embedded_hal::futures::delay::Delay;
24- /// # use core::time::Duration;
27+ /// use core::time::Duration;
28+ ///
2529/// /// Wait until the `ready_pin` is high or timeout after 1 millisecond.
2630/// /// Returns true is the pin became high or false if it timed-out.
2731/// async fn wait_until_ready_or_timeout<P, D>(ready_pin: &P, delay: &mut D) -> bool
@@ -30,17 +34,20 @@ use crate::blocking::digital::InputPin;
3034/// D: Delay,
3135/// {
3236/// futures::select_biased! {
33- /// _ => ready_pin.until_high() => true,
34- /// _ => delay.delay(Duration::from_millis(1)) => false,
37+ /// x => ready_pin.until_high() => {
38+ /// x.expect("failed to await input pin");
39+ /// true
40+ /// },
41+ /// _ => delay.delay(Duration::from_millis(1)) => false, // ignore the error
3542/// }
3643/// }
3744/// ```
3845pub trait AsyncInputPin : InputPin {
3946 /// The future returned by the `until_high` function.
40- type UntilHighFuture < ' a > : Future < Output =( ) > + ' a ;
47+ type UntilHighFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
4148
4249 /// The future returned by the `until_low` function.
43- type UntilLowFuture < ' a > : Future < Output =( ) > + ' a ;
50+ type UntilLowFuture < ' a > : Future < Output =Result < ( ) , Self :: Error > > + ' a ;
4451
4552 /// Returns a future that resolves when this pin becomes high.
4653 fn until_high < ' a > ( & self ) -> Self :: UntilHighFuture < ' a > ;
0 commit comments