diff options
Diffstat (limited to 'embassy-stm32/src/exti.rs')
| -rw-r--r-- | embassy-stm32/src/exti.rs | 89 |
1 files changed, 36 insertions, 53 deletions
diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 07c63a2ef..dbd24804f 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs | |||
| @@ -1,3 +1,4 @@ | |||
| 1 | use core::convert::Infallible; | ||
| 1 | use core::future::Future; | 2 | use core::future::Future; |
| 2 | use core::marker::PhantomData; | 3 | use core::marker::PhantomData; |
| 3 | use core::pin::Pin; | 4 | use core::pin::Pin; |
| @@ -137,74 +138,56 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { | |||
| 137 | } | 138 | } |
| 138 | } | 139 | } |
| 139 | 140 | ||
| 140 | mod eh02 { | 141 | impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { |
| 141 | use core::convert::Infallible; | 142 | type Error = Infallible; |
| 142 | 143 | ||
| 143 | use super::*; | 144 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 144 | 145 | Ok(self.is_high()) | |
| 145 | impl<'d, T: GpioPin> embedded_hal_02::digital::v2::InputPin for ExtiInput<'d, T> { | 146 | } |
| 146 | type Error = Infallible; | ||
| 147 | |||
| 148 | fn is_high(&self) -> Result<bool, Self::Error> { | ||
| 149 | Ok(self.is_high()) | ||
| 150 | } | ||
| 151 | 147 | ||
| 152 | fn is_low(&self) -> Result<bool, Self::Error> { | 148 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 153 | Ok(self.is_low()) | 149 | Ok(self.is_low()) |
| 154 | } | ||
| 155 | } | 150 | } |
| 156 | } | 151 | } |
| 157 | 152 | ||
| 158 | #[cfg(feature = "unstable-traits")] | 153 | impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { |
| 159 | mod eh1 { | 154 | type Error = Infallible; |
| 160 | use core::convert::Infallible; | 155 | } |
| 161 | |||
| 162 | use super::*; | ||
| 163 | 156 | ||
| 164 | impl<'d, T: GpioPin> embedded_hal_1::digital::ErrorType for ExtiInput<'d, T> { | 157 | impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { |
| 165 | type Error = Infallible; | 158 | fn is_high(&self) -> Result<bool, Self::Error> { |
| 159 | Ok(self.is_high()) | ||
| 166 | } | 160 | } |
| 167 | 161 | ||
| 168 | impl<'d, T: GpioPin> embedded_hal_1::digital::InputPin for ExtiInput<'d, T> { | 162 | fn is_low(&self) -> Result<bool, Self::Error> { |
| 169 | fn is_high(&self) -> Result<bool, Self::Error> { | 163 | Ok(self.is_low()) |
| 170 | Ok(self.is_high()) | ||
| 171 | } | ||
| 172 | |||
| 173 | fn is_low(&self) -> Result<bool, Self::Error> { | ||
| 174 | Ok(self.is_low()) | ||
| 175 | } | ||
| 176 | } | 164 | } |
| 177 | } | 165 | } |
| 178 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | ||
| 179 | mod eha { | ||
| 180 | 166 | ||
| 181 | use super::*; | 167 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { |
| 182 | 168 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | |
| 183 | impl<'d, T: GpioPin> embedded_hal_async::digital::Wait for ExtiInput<'d, T> { | 169 | self.wait_for_high().await; |
| 184 | async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | 170 | Ok(()) |
| 185 | self.wait_for_high().await; | 171 | } |
| 186 | Ok(()) | ||
| 187 | } | ||
| 188 | 172 | ||
| 189 | async fn wait_for_low(&mut self) -> Result<(), Self::Error> { | 173 | async fn wait_for_low(&mut self) -> Result<(), Self::Error> { |
| 190 | self.wait_for_low().await; | 174 | self.wait_for_low().await; |
| 191 | Ok(()) | 175 | Ok(()) |
| 192 | } | 176 | } |
| 193 | 177 | ||
| 194 | async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { | 178 | async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { |
| 195 | self.wait_for_rising_edge().await; | 179 | self.wait_for_rising_edge().await; |
| 196 | Ok(()) | 180 | Ok(()) |
| 197 | } | 181 | } |
| 198 | 182 | ||
| 199 | async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { | 183 | async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { |
| 200 | self.wait_for_falling_edge().await; | 184 | self.wait_for_falling_edge().await; |
| 201 | Ok(()) | 185 | Ok(()) |
| 202 | } | 186 | } |
| 203 | 187 | ||
| 204 | async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { | 188 | async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { |
| 205 | self.wait_for_any_edge().await; | 189 | self.wait_for_any_edge().await; |
| 206 | Ok(()) | 190 | Ok(()) |
| 207 | } | ||
| 208 | } | 191 | } |
| 209 | } | 192 | } |
| 210 | 193 | ||
