@@ -14,14 +14,18 @@ use crate::blocking::digital::InputPin;
14
14
/// where
15
15
/// P: AsyncInputPin,
16
16
/// {
17
- /// ready_pin.until_high().await
17
+ /// ready_pin
18
+ /// .until_high()
19
+ /// .await
20
+ /// .expect("failed to await input pin")
18
21
/// }
19
22
/// ```
20
23
///
21
24
/// ```rust,ignore
22
25
/// # use embedded_hal::futures::digital::AsyncInputPin;
23
26
/// # use embedded_hal::futures::delay::Delay;
24
- /// # use core::time::Duration;
27
+ /// use core::time::Duration;
28
+ ///
25
29
/// /// Wait until the `ready_pin` is high or timeout after 1 millisecond.
26
30
/// /// Returns true is the pin became high or false if it timed-out.
27
31
/// 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;
30
34
/// D: Delay,
31
35
/// {
32
36
/// 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
35
42
/// }
36
43
/// }
37
44
/// ```
38
45
pub trait AsyncInputPin : InputPin {
39
46
/// 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 ;
41
48
42
49
/// 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 ;
44
51
45
52
/// Returns a future that resolves when this pin becomes high.
46
53
fn until_high < ' a > ( & self ) -> Self :: UntilHighFuture < ' a > ;
0 commit comments