From 13b259d7cdcfb23f76497b5d9db8aa2b1e1d558d Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Mon, 4 Jul 2022 22:19:02 +0200 Subject: Have added Flex to eh01 and eh2 --- embassy-stm32/src/gpio.rs | 116 ++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 111 insertions(+), 5 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index a2405c232..6c989b52e 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -657,7 +657,7 @@ mod eh02 { use super::*; - impl<'d, T: Pin> InputPin for Flex<'d, T> { + impl<'d, T: Pin> InputPin for Input<'d, T> { type Error = Infallible; #[inline] @@ -671,7 +671,7 @@ mod eh02 { } } - impl<'d, T: Pin> OutputPin for Flex<'d, T> { + impl<'d, T: Pin> OutputPin for Output<'d, T> { type Error = Infallible; #[inline] @@ -685,7 +685,7 @@ mod eh02 { } } - impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { + impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { #[inline] fn is_set_high(&self) -> Result { Ok(self.is_set_high()) @@ -698,7 +698,7 @@ mod eh02 { } } - impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { + impl<'d, T: Pin> ToggleableOutputPin for Output<'d, T> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { @@ -740,6 +740,55 @@ mod eh02 { Ok(self.toggle()) } } + + impl<'d, T: Pin> InputPin for Flex<'d, T> { + type Error = Infallible; + + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) + } + + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } + } + + impl<'d, T: Pin> OutputPin for Flex<'d, T> { + type Error = Infallible; + + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } + } + + impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } + } + + impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } + } } #[cfg(feature = "unstable-traits")] @@ -836,9 +885,66 @@ mod eh1 { Ok(self.toggle()) } } + + impl<'d, T: Pin> ErrorType for Flex<'d, T> { + type Error = Infallible; + } + + impl<'d, T: Pin> InputPin for Flex<'d, T> { + #[inline] + fn is_high(&self) -> Result { + Ok(self.is_high()) + } + + #[inline] + fn is_low(&self) -> Result { + Ok(self.is_low()) + } + } + + impl<'d, T: Pin> ErrorType for Flex<'d, T> { + type Error = Infallible; + } + + impl<'d, T: Pin> OutputPin for Flex<'d, T> { + #[inline] + fn set_high(&mut self) -> Result<(), Self::Error> { + Ok(self.set_high()) + } + + #[inline] + fn set_low(&mut self) -> Result<(), Self::Error> { + Ok(self.set_low()) + } + } + + impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } + } + + impl<'d, T: Pin> ErrorType for Flex<'d, T> { + type Error = Infallible; + } + + impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { + #[inline] + fn is_set_high(&self) -> Result { + Ok(self.is_set_high()) + } + + /// Is the output pin set as low? + #[inline] + fn is_set_low(&self) -> Result { + Ok(self.is_set_low()) + } + } + } #[cfg(feature = "unstable-pac")] pub mod low_level { pub use super::sealed::*; -} +} \ No newline at end of file -- cgit