1
use embedded_hal::digital;
2
use embedded_hal_async::digital::Wait;
3

            
4
#[cfg(feature = "unstable")]
5
use super::Flex;
6
use super::{Input, Output};
7

            
8
impl digital::ErrorType for Input<'_> {
9
    type Error = core::convert::Infallible;
10
}
11

            
12
impl digital::InputPin for Input<'_> {
13
    fn is_high(&mut self) -> Result<bool, Self::Error> {
14
        Ok(Self::is_high(self))
15
    }
16

            
17
    fn is_low(&mut self) -> Result<bool, Self::Error> {
18
        Ok(Self::is_low(self))
19
    }
20
}
21

            
22
impl digital::ErrorType for Output<'_> {
23
    type Error = core::convert::Infallible;
24
}
25

            
26
impl digital::OutputPin for Output<'_> {
27
2
    fn set_low(&mut self) -> Result<(), Self::Error> {
28
        Self::set_low(self);
29
        Ok(())
30
2
    }
31

            
32
4
    fn set_high(&mut self) -> Result<(), Self::Error> {
33
        Self::set_high(self);
34
        Ok(())
35
4
    }
36
}
37

            
38
impl digital::StatefulOutputPin for Output<'_> {
39
    fn is_set_high(&mut self) -> Result<bool, Self::Error> {
40
        Ok(Self::is_set_high(self))
41
    }
42

            
43
4
    fn is_set_low(&mut self) -> Result<bool, Self::Error> {
44
        Ok(Self::is_set_low(self))
45
4
    }
46
}
47

            
48
#[instability::unstable]
49
impl digital::InputPin for Flex<'_> {
50
    fn is_high(&mut self) -> Result<bool, Self::Error> {
51
        Ok(Self::is_high(self))
52
    }
53

            
54
    fn is_low(&mut self) -> Result<bool, Self::Error> {
55
        Ok(Self::is_low(self))
56
    }
57
}
58

            
59
#[instability::unstable]
60
impl digital::ErrorType for Flex<'_> {
61
    type Error = core::convert::Infallible;
62
}
63

            
64
#[instability::unstable]
65
impl digital::OutputPin for Flex<'_> {
66
    fn set_low(&mut self) -> Result<(), Self::Error> {
67
        Self::set_low(self);
68
        Ok(())
69
    }
70

            
71
    fn set_high(&mut self) -> Result<(), Self::Error> {
72
        Self::set_high(self);
73
        Ok(())
74
    }
75
}
76

            
77
#[instability::unstable]
78
impl digital::StatefulOutputPin for super::Flex<'_> {
79
    fn is_set_high(&mut self) -> Result<bool, Self::Error> {
80
        Ok(Self::is_set_high(self))
81
    }
82

            
83
    fn is_set_low(&mut self) -> Result<bool, Self::Error> {
84
        Ok(Self::is_set_low(self))
85
    }
86
}
87

            
88
#[instability::unstable]
89
impl Wait for Flex<'_> {
90
    async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
91
        Self::wait_for_high(self).await;
92
        Ok(())
93
    }
94

            
95
    async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
96
        Self::wait_for_low(self).await;
97
        Ok(())
98
    }
99

            
100
    async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
101
        Self::wait_for_rising_edge(self).await;
102
        Ok(())
103
    }
104

            
105
    async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
106
        Self::wait_for_falling_edge(self).await;
107
        Ok(())
108
    }
109

            
110
    async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
111
        Self::wait_for_any_edge(self).await;
112
        Ok(())
113
    }
114
}
115

            
116
impl Wait for Input<'_> {
117
    async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
118
        Self::wait_for_high(self).await;
119
        Ok(())
120
    }
121

            
122
    async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
123
        Self::wait_for_low(self).await;
124
        Ok(())
125
    }
126

            
127
    async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
128
        Self::wait_for_rising_edge(self).await;
129
        Ok(())
130
    }
131

            
132
    async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
133
        Self::wait_for_falling_edge(self).await;
134
        Ok(())
135
    }
136

            
137
    async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
138
        Self::wait_for_any_edge(self).await;
139
        Ok(())
140
    }
141
}