From 9b3c5af92ad55bc05a72b8957784f12c1a1ddcbd Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Thu, 30 Jun 2022 21:41:45 +0200 Subject: [PATCH 01/18] Flex GPIO implementation : Input --- embassy-stm32/src/gpio.rs | 167 ++++++++++++++++++++++++-------------- 1 file changed, 105 insertions(+), 62 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 6e445f8c..58eed688 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -7,6 +7,102 @@ use embassy_hal_common::{unborrow, unsafe_impl_unborrow}; use crate::pac::gpio::{self, vals}; use crate::{pac, peripherals, Unborrow}; +/// GPIO flexible pin. +/// +/// This pin can either be a disconnected, input, or output pin, or both. The level register bit will remain +/// set while not in output mode, so the pin's level will be 'remembered' when it is not in output +/// mode. +pub struct Flex<'d, T: Pin> { + pub(crate) pin: T, + phantom: PhantomData<&'d mut T>, +} + +impl<'d, T: Pin> Flex<'d, T> { + /// Wrap the pin in a `Flex`. + /// + /// The pin remains disconnected. The initial output level is unspecified, but can be changed + /// before the pin is put into output mode. + /// + #[inline] + pub fn new(pin: impl Unborrow + 'd) -> Self { + unborrow!(pin); + // Pin will be in disconnected state. + Self { + pin, + phantom: PhantomData, + } + } + + /// Put the pin into input mode. + #[inline] + pub fn set_as_input(&mut self, pull: Pull) { + critical_section::with(|_| unsafe { + let r = self.pin.block(); + let n = self.pin.pin() as usize; + #[cfg(gpio_v1)] + { + let cnf = match pull { + Pull::Up => { + r.bsrr().write(|w| w.set_bs(n, true)); + vals::CnfIn::PULL + } + Pull::Down => { + r.bsrr().write(|w| w.set_br(n, true)); + vals::CnfIn::PULL + } + Pull::None => vals::CnfIn::FLOATING, + }; + + let crlh = if n < 8 { 0 } else { 1 }; + r.cr(crlh).modify(|w| { + w.set_mode(n % 8, vals::Mode::INPUT); + w.set_cnf_in(n % 8, cnf); + }); + } + #[cfg(gpio_v2)] + { + r.pupdr().modify(|w| w.set_pupdr(n, pull.into())); + r.otyper().modify(|w| w.set_ot(n, vals::Ot::PUSHPULL)); + r.moder().modify(|w| w.set_moder(n, vals::Moder::INPUT)); + } + }); + } + + #[inline] + pub fn is_high(&self) -> bool { + !self.is_low() + } + + #[inline] + pub fn is_low(&self) -> bool { + let state = unsafe { self.pin.block().idr().read().idr(self.pin.pin() as _) }; + state == vals::Idr::LOW + } +} + +impl<'d, T: Pin> Drop for Flex<'d, T> { + #[inline] + fn drop(&mut self) { + critical_section::with(|_| unsafe { + let r = self.pin.block(); + let n = self.pin.pin() as usize; + #[cfg(gpio_v1)] + { + let crlh = if n < 8 { 0 } else { 1 }; + r.cr(crlh).modify(|w| { + w.set_mode(n % 8, vals::Mode::INPUT); + w.set_cnf_in(n % 8, vals::CnfIn::FLOATING); + }); + } + #[cfg(gpio_v2)] + { + r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); + r.moder().modify(|w| w.set_moder(n, vals::Moder::INPUT)); + } + }); + } +} + /// Pull setting for an input. #[derive(Debug, Eq, PartialEq)] #[cfg_attr(feature = "defmt", derive(defmt::Format))] @@ -70,78 +166,25 @@ impl From for vals::Ospeedr { /// GPIO input driver. pub struct Input<'d, T: Pin> { - pub(crate) pin: T, - phantom: PhantomData<&'d mut T>, + pub(crate) pin: Flex<'d, T> } impl<'d, T: Pin> Input<'d, T> { #[inline] pub fn new(pin: impl Unborrow + 'd, pull: Pull) -> Self { - unborrow!(pin); - - critical_section::with(|_| unsafe { - let r = pin.block(); - let n = pin.pin() as usize; - #[cfg(gpio_v1)] - { - let cnf = match pull { - Pull::Up => { - r.bsrr().write(|w| w.set_bs(n, true)); - vals::CnfIn::PULL - } - Pull::Down => { - r.bsrr().write(|w| w.set_br(n, true)); - vals::CnfIn::PULL - } - Pull::None => vals::CnfIn::FLOATING, - }; - - let crlh = if n < 8 { 0 } else { 1 }; - r.cr(crlh).modify(|w| { - w.set_mode(n % 8, vals::Mode::INPUT); - w.set_cnf_in(n % 8, cnf); - }); - } - #[cfg(gpio_v2)] - { - r.pupdr().modify(|w| w.set_pupdr(n, pull.into())); - r.otyper().modify(|w| w.set_ot(n, vals::Ot::PUSHPULL)); - r.moder().modify(|w| w.set_moder(n, vals::Moder::INPUT)); - } - }); - - Self { - pin, - phantom: PhantomData, - } + let mut pin = Flex::new(pin); + pin.set_as_input(pull); + Self { pin } } #[inline] pub fn is_high(&self) -> bool { - !self.is_low() + self.pin.is_high() } #[inline] pub fn is_low(&self) -> bool { - let state = unsafe { self.pin.block().idr().read().idr(self.pin.pin() as _) }; - state == vals::Idr::LOW - } -} - -impl<'d, T: Pin> Drop for Input<'d, T> { - #[inline] - fn drop(&mut self) { - critical_section::with(|_| unsafe { - let r = self.pin.block(); - let n = self.pin.pin() as usize; - #[cfg(gpio_v1)] - { - let crlh = if n < 8 { 0 } else { 1 }; - r.cr(crlh).modify(|w| w.set_cnf_in(n % 8, vals::CnfIn::FLOATING)); - } - #[cfg(gpio_v2)] - r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); - }); + self.pin.is_low() } } @@ -609,7 +652,7 @@ mod eh02 { use super::*; - impl<'d, T: Pin> InputPin for Input<'d, T> { + impl<'d, T: Pin> InputPin for Flex<'d, T> { type Error = Infallible; #[inline] @@ -701,11 +744,11 @@ mod eh1 { use super::*; - impl<'d, T: Pin> ErrorType for Input<'d, T> { + impl<'d, T: Pin> ErrorType for Flex<'d, T> { type Error = Infallible; } - impl<'d, T: Pin> InputPin for Input<'d, T> { + impl<'d, T: Pin> InputPin for Flex<'d, T> { #[inline] fn is_high(&self) -> Result { Ok(self.is_high()) From f05082b9a3378e05d93fdfe4489b28ec1798f6d5 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Thu, 30 Jun 2022 22:55:57 +0200 Subject: [PATCH 02/18] have reverted changed in mod eh1 from previous commit --- embassy-stm32/src/gpio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 58eed688..3284b0cb 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -744,11 +744,11 @@ mod eh1 { use super::*; - impl<'d, T: Pin> ErrorType for Flex<'d, T> { + impl<'d, T: Pin> ErrorType for Input<'d, T> { type Error = Infallible; } - impl<'d, T: Pin> InputPin for Flex<'d, T> { + impl<'d, T: Pin> InputPin for Input<'d, T> { #[inline] fn is_high(&self) -> Result { Ok(self.is_high()) From 359fc4d124989d9f8f6676b5090964c5ad202705 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Thu, 30 Jun 2022 23:03:15 +0200 Subject: [PATCH 03/18] Flex GPIO implementation : Output --- embassy-stm32/src/gpio.rs | 129 ++++++++++++++++++++------------------ 1 file changed, 67 insertions(+), 62 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 3284b0cb..a2405c23 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -68,6 +68,30 @@ impl<'d, T: Pin> Flex<'d, T> { }); } + #[inline] + fn set_as_output(&mut self, speed: Speed) { + + critical_section::with(|_| unsafe { + let r = self.pin.block(); + let n = self.pin.pin() as usize; + #[cfg(gpio_v1)] + { + let crlh = if n < 8 { 0 } else { 1 }; + r.cr(crlh).modify(|w| { + w.set_mode(n % 8, speed.into()); + w.set_cnf_out(n % 8, vals::CnfOut::PUSHPULL); + }); + } + #[cfg(gpio_v2)] + { + r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); + r.otyper().modify(|w| w.set_ot(n, vals::Ot::PUSHPULL)); + pin.set_speed(speed); + r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); + } + }); + } + #[inline] pub fn is_high(&self) -> bool { !self.is_low() @@ -78,6 +102,39 @@ impl<'d, T: Pin> Flex<'d, T> { let state = unsafe { self.pin.block().idr().read().idr(self.pin.pin() as _) }; state == vals::Idr::LOW } + + #[inline] + pub fn is_set_high(&self) -> bool { + !self.is_set_low() + } + + /// Is the output pin set as low? + #[inline] + pub fn is_set_low(&self) -> bool { + let state = unsafe { self.pin.block().odr().read().odr(self.pin.pin() as _) }; + state == vals::Odr::LOW + } + + #[inline] + pub fn set_high(&mut self) { + self.pin.set_high(); + } + + /// Set the output as low. + #[inline] + pub fn set_low(&mut self) { + self.pin.set_low(); + } + + /// Toggle pin output + #[inline] + pub fn toggle(&mut self) { + if self.is_set_low() { + self.set_high() + } else { + self.set_low() + } + } } impl<'d, T: Pin> Drop for Flex<'d, T> { @@ -198,44 +255,19 @@ pub enum Level { /// GPIO output driver. pub struct Output<'d, T: Pin> { - pub(crate) pin: T, - phantom: PhantomData<&'d mut T>, + pub(crate) pin: Flex<'d, T>, } impl<'d, T: Pin> Output<'d, T> { #[inline] pub fn new(pin: impl Unborrow + 'd, initial_output: Level, speed: Speed) -> Self { - unborrow!(pin); - + let mut pin = Flex::new(pin); match initial_output { Level::High => pin.set_high(), Level::Low => pin.set_low(), } - - critical_section::with(|_| unsafe { - let r = pin.block(); - let n = pin.pin() as usize; - #[cfg(gpio_v1)] - { - let crlh = if n < 8 { 0 } else { 1 }; - r.cr(crlh).modify(|w| { - w.set_mode(n % 8, speed.into()); - w.set_cnf_out(n % 8, vals::CnfOut::PUSHPULL); - }); - } - #[cfg(gpio_v2)] - { - r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); - r.otyper().modify(|w| w.set_ot(n, vals::Ot::PUSHPULL)); - pin.set_speed(speed); - r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); - } - }); - - Self { - pin, - phantom: PhantomData, - } + pin.set_as_output(speed); + Self { pin } } /// Set the output as high. @@ -253,49 +285,22 @@ impl<'d, T: Pin> Output<'d, T> { /// Is the output pin set as high? #[inline] pub fn is_set_high(&self) -> bool { - !self.is_set_low() + self.pin.is_set_high() } /// Is the output pin set as low? #[inline] pub fn is_set_low(&self) -> bool { - let state = unsafe { self.pin.block().odr().read().odr(self.pin.pin() as _) }; - state == vals::Odr::LOW + self.pin.is_set_low() } /// Toggle pin output #[inline] pub fn toggle(&mut self) { - if self.is_set_low() { - self.set_high() - } else { - self.set_low() - } + self.pin.toggle(); } } -impl<'d, T: Pin> Drop for Output<'d, T> { - #[inline] - fn drop(&mut self) { - critical_section::with(|_| unsafe { - let r = self.pin.block(); - let n = self.pin.pin() as usize; - #[cfg(gpio_v1)] - { - let crlh = if n < 8 { 0 } else { 1 }; - r.cr(crlh).modify(|w| { - w.set_mode(n % 8, vals::Mode::INPUT); - w.set_cnf_in(n % 8, vals::CnfIn::FLOATING); - }); - } - #[cfg(gpio_v2)] - { - r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); - r.moder().modify(|w| w.set_moder(n, vals::Moder::INPUT)); - } - }); - } -} /// GPIO output open-drain driver. pub struct OutputOpenDrain<'d, T: Pin> { @@ -666,7 +671,7 @@ mod eh02 { } } - impl<'d, T: Pin> OutputPin for Output<'d, T> { + impl<'d, T: Pin> OutputPin for Flex<'d, T> { type Error = Infallible; #[inline] @@ -680,7 +685,7 @@ mod eh02 { } } - impl<'d, T: Pin> StatefulOutputPin for Output<'d, T> { + impl<'d, T: Pin> StatefulOutputPin for Flex<'d, T> { #[inline] fn is_set_high(&self) -> Result { Ok(self.is_set_high()) @@ -693,7 +698,7 @@ mod eh02 { } } - impl<'d, T: Pin> ToggleableOutputPin for Output<'d, T> { + impl<'d, T: Pin> ToggleableOutputPin for Flex<'d, T> { type Error = Infallible; #[inline] fn toggle(&mut self) -> Result<(), Self::Error> { From 13b259d7cdcfb23f76497b5d9db8aa2b1e1d558d Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Mon, 4 Jul 2022 22:19:02 +0200 Subject: [PATCH 04/18] Have added Flex to eh01 and eh2 --- embassy-stm32/src/gpio.rs | 178 ++++++++++++++++++++++++++++++-------- 1 file changed, 142 insertions(+), 36 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index a2405c23..6c989b52 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -657,6 +657,90 @@ mod eh02 { use super::*; + impl<'d, T: Pin> InputPin for Input<'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 Output<'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 Output<'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 Output<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } + } + + impl<'d, T: Pin> OutputPin for OutputOpenDrain<'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 OutputOpenDrain<'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 OutputOpenDrain<'d, T> { + type Error = Infallible; + #[inline] + fn toggle(&mut self) -> Result<(), Self::Error> { + Ok(self.toggle()) + } + } + impl<'d, T: Pin> InputPin for Flex<'d, T> { type Error = Infallible; @@ -705,41 +789,6 @@ mod eh02 { Ok(self.toggle()) } } - - impl<'d, T: Pin> OutputPin for OutputOpenDrain<'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 OutputOpenDrain<'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 OutputOpenDrain<'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 From 4e54d09ab1802705bc8d3c52b4c81616303899cb Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Mon, 4 Jul 2022 22:38:05 +0200 Subject: [PATCH 05/18] Have added OutputOpenDrain with Flex --- embassy-stm32/src/gpio.rs | 97 ++++++++++++++------------------------- 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 6c989b52..81969c4c 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -92,6 +92,32 @@ impl<'d, T: Pin> Flex<'d, T> { }); } + #[inline] + fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { + critical_section::with(|_| unsafe { + let r = self.pin.block(); + let n = self.pin.pin() as usize; + #[cfg(gpio_v1)] + { + let crlh = if n < 8 { 0 } else { 1 }; + match pull { + Pull::Up => r.bsrr().write(|w| w.set_bs(n, true)), + Pull::Down => r.bsrr().write(|w| w.set_br(n, true)), + Pull::None => {} + } + r.cr(crlh).modify(|w| w.set_mode(n % 8, speed.into())); + r.cr(crlh).modify(|w| w.set_cnf_out(n % 8, vals::CnfOut::OPENDRAIN)); + } + #[cfg(gpio_v2)] + { + r.pupdr().modify(|w| w.set_pupdr(n, pull.into())); + r.otyper().modify(|w| w.set_ot(n, vals::Ot::OPENDRAIN)); + pin.set_speed(speed); + r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); + } + }); + } + #[inline] pub fn is_high(&self) -> bool { !self.is_low() @@ -304,58 +330,31 @@ impl<'d, T: Pin> Output<'d, T> { /// GPIO output open-drain driver. pub struct OutputOpenDrain<'d, T: Pin> { - pub(crate) pin: T, - phantom: PhantomData<&'d mut T>, + pub(crate) pin: Flex<'d, T> } impl<'d, T: Pin> OutputOpenDrain<'d, T> { #[inline] pub fn new(pin: impl Unborrow + 'd, initial_output: Level, speed: Speed, pull: Pull) -> Self { - unborrow!(pin); + let mut pin = Flex::new(pin); match initial_output { Level::High => pin.set_high(), Level::Low => pin.set_low(), } - critical_section::with(|_| unsafe { - let r = pin.block(); - let n = pin.pin() as usize; - #[cfg(gpio_v1)] - { - let crlh = if n < 8 { 0 } else { 1 }; - match pull { - Pull::Up => r.bsrr().write(|w| w.set_bs(n, true)), - Pull::Down => r.bsrr().write(|w| w.set_br(n, true)), - Pull::None => {} - } - r.cr(crlh).modify(|w| w.set_mode(n % 8, speed.into())); - r.cr(crlh).modify(|w| w.set_cnf_out(n % 8, vals::CnfOut::OPENDRAIN)); - } - #[cfg(gpio_v2)] - { - r.pupdr().modify(|w| w.set_pupdr(n, pull.into())); - r.otyper().modify(|w| w.set_ot(n, vals::Ot::OPENDRAIN)); - pin.set_speed(speed); - r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); - } - }); - - Self { - pin, - phantom: PhantomData, - } + pin.set_as_input_output(speed, pull); + Self { pin } } #[inline] pub fn is_high(&self) -> bool { - !self.is_low() + !self.pin.is_low() } #[inline] pub fn is_low(&self) -> bool { - let state = unsafe { self.pin.block().idr().read().idr(self.pin.pin() as _) }; - state == vals::Idr::LOW + self.pin.is_low() } /// Set the output as high. @@ -379,41 +378,13 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { /// Is the output pin set as low? #[inline] pub fn is_set_low(&self) -> bool { - let state = unsafe { self.pin.block().odr().read().odr(self.pin.pin() as _) }; - state == vals::Odr::LOW + self.pin.is_set_low() } /// Toggle pin output #[inline] pub fn toggle(&mut self) { - if self.is_set_low() { - self.set_high() - } else { - self.set_low() - } - } -} - -impl<'d, T: Pin> Drop for OutputOpenDrain<'d, T> { - #[inline] - fn drop(&mut self) { - critical_section::with(|_| unsafe { - let r = self.pin.block(); - let n = self.pin.pin() as usize; - #[cfg(gpio_v1)] - { - let crlh = if n < 8 { 0 } else { 1 }; - r.cr(crlh).modify(|w| { - w.set_mode(n % 8, vals::Mode::INPUT); - w.set_cnf_in(n % 8, vals::CnfIn::FLOATING); - }); - } - #[cfg(gpio_v2)] - { - r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); - r.moder().modify(|w| w.set_moder(n, vals::Moder::INPUT)); - } - }); + self.pin.toggle() } } From 39702d76242797106f77b3af56f3aed946e237b0 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 21:46:16 +0200 Subject: [PATCH 06/18] set_as_input_output() and set_as_output() : Have added comments and made functions public --- embassy-stm32/src/gpio.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 81969c4c..4f1ce3cf 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -68,8 +68,12 @@ impl<'d, T: Pin> Flex<'d, T> { }); } + /// Put the pin into output mode. + /// + /// The pin level will be whatever was set before (or low by default). If you want it to begin + /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] - fn set_as_output(&mut self, speed: Speed) { + pub fn set_as_output(&mut self, speed: Speed) { critical_section::with(|_| unsafe { let r = self.pin.block(); @@ -91,9 +95,18 @@ impl<'d, T: Pin> Flex<'d, T> { } }); } - + + /// Put the pin into input + output mode. + /// + /// This is commonly used for "open drain" mode. + /// the hardware will drive the line low if you set it to low, and will leave it floating if you set + /// it to high, in which case you can read the input to figure out whether another device + /// is driving the line low. + /// + /// The pin level will be whatever was set before (or low by default). If you want it to begin + /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] - fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { + pub fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; From f911ad25c3cb1155dc47cf9bd7de31628562c6a9 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 21:59:09 +0200 Subject: [PATCH 07/18] Flex/ Test initial output test done --- tests/stm32/src/bin/gpio.rs | 92 ++++++++++++++++++++++++++++++++++++- 1 file changed, 91 insertions(+), 1 deletion(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index c7991953..2692f25f 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -6,7 +6,7 @@ mod example_common; use defmt::assert; use embassy::executor::Spawner; -use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed}; +use embassy_stm32::gpio::{Input, Level, Output, OutputOpenDrain, Flex, Pull, Speed}; use embassy_stm32::Peripherals; use example_common::*; @@ -88,6 +88,96 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert!(b.is_high()); } + // Test output open drain + { + let b = Input::new(&mut b, Pull::Down); + // no pull, the status is undefined + + let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); + delay(); + assert!(b.is_low()); + a.set_high(); // High-Z output + delay(); + assert!(b.is_low()); + } + + // FLEX + // Test initial output + { + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::None); + + { + let mut a = Flex::new(&mut a); + a.set_low(); + a.set_as_output(Speed::Low); + delay(); + assert!(b.is_low()); + } + { + let mut a = Flex::new(&mut a); + a.set_as_output(Speed::Low); + a.set_high(); + delay(); + assert!(b.is_high()); + } + } + /* + // Test input no pull + { + let b = Input::new(&mut b, Pull::None); + // no pull, the status is undefined + + let mut a = Output::new(&mut a, Level::Low, Speed::Low); + delay(); + assert!(b.is_low()); + a.set_high(); + delay(); + assert!(b.is_high()); + } + + // Test input pulldown + { + let b = Input::new(&mut b, Pull::Down); + delay(); + assert!(b.is_low()); + + let mut a = Output::new(&mut a, Level::Low, Speed::Low); + delay(); + assert!(b.is_low()); + a.set_high(); + delay(); + assert!(b.is_high()); + } + + // Test input pullup + { + let b = Input::new(&mut b, Pull::Up); + delay(); + assert!(b.is_high()); + + let mut a = Output::new(&mut a, Level::Low, Speed::Low); + delay(); + assert!(b.is_low()); + a.set_high(); + delay(); + assert!(b.is_high()); + } + + // Test output open drain + { + let b = Input::new(&mut b, Pull::Down); + // no pull, the status is undefined + + let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); + delay(); + assert!(b.is_low()); + a.set_high(); // High-Z output + delay(); + assert!(b.is_low()); + } +*/ + info!("Test OK"); cortex_m::asm::bkpt(); } From 555f18aa95651f39ea62d965e348ba62eab71414 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:02:49 +0200 Subject: [PATCH 08/18] Flex/ input no pull test done --- tests/stm32/src/bin/gpio.rs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 2692f25f..b82ad81a 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -122,13 +122,15 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert!(b.is_high()); } } - /* + // Test input no pull { - let b = Input::new(&mut b, Pull::None); - // no pull, the status is undefined + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::None); // no pull, the status is undefined - let mut a = Output::new(&mut a, Level::Low, Speed::Low); + let mut a = Flex::new(&mut a); + a.set_low(); + a.set_as_output(Speed::Low); delay(); assert!(b.is_low()); a.set_high(); @@ -136,6 +138,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert!(b.is_high()); } + /* // Test input pulldown { let b = Input::new(&mut b, Pull::Down); From 1d91405d4d5ceee64fa0331e63f6ed565906a77a Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:08:14 +0200 Subject: [PATCH 09/18] Flex/ input pull down test done --- tests/stm32/src/bin/gpio.rs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index b82ad81a..f9b9e8f7 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -138,26 +138,29 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert!(b.is_high()); } - /* + // Test input pulldown { - let b = Input::new(&mut b, Pull::Down); + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::Down); // no pull, the status is undefined delay(); assert!(b.is_low()); - - let mut a = Output::new(&mut a, Level::Low, Speed::Low); + + let mut a = Flex::new(&mut a); + a.set_low(); + a.set_as_output(Speed::Low); delay(); assert!(b.is_low()); a.set_high(); delay(); assert!(b.is_high()); } - + /* // Test input pullup { - let b = Input::new(&mut b, Pull::Up); + let b = Input::new(&mut b, Pull::Down); delay(); - assert!(b.is_high()); + assert!(b.is_low()); let mut a = Output::new(&mut a, Level::Low, Speed::Low); delay(); From 00df9b507c66526dee1e395fc82a0f71b17c557e Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:10:52 +0200 Subject: [PATCH 10/18] Flex/ input pull up test done --- tests/stm32/src/bin/gpio.rs | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index f9b9e8f7..edcb1eca 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -142,10 +142,10 @@ async fn main(_spawner: Spawner, p: Peripherals) { // Test input pulldown { let mut b = Flex::new(&mut b); - b.set_as_input(Pull::Down); // no pull, the status is undefined + b.set_as_input(Pull::Down); delay(); assert!(b.is_low()); - + let mut a = Flex::new(&mut a); a.set_low(); a.set_as_output(Speed::Low); @@ -155,21 +155,24 @@ async fn main(_spawner: Spawner, p: Peripherals) { delay(); assert!(b.is_high()); } - /* + // Test input pullup { - let b = Input::new(&mut b, Pull::Down); - delay(); - assert!(b.is_low()); - - let mut a = Output::new(&mut a, Level::Low, Speed::Low); - delay(); - assert!(b.is_low()); - a.set_high(); + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::Up); delay(); assert!(b.is_high()); - } + let mut a = Flex::new(&mut a); + a.set_high(); + a.set_as_output(Speed::Low); + delay(); + assert!(b.is_high()); + a.set_low(); + delay(); + assert!(b.is_low()); + } + /* // Test output open drain { let b = Input::new(&mut b, Pull::Down); From dda528808a87af23feafb709dbcd665da91d5547 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:16:01 +0200 Subject: [PATCH 11/18] Flex/ output open drain test done --- tests/stm32/src/bin/gpio.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index edcb1eca..2cdf52c0 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -172,20 +172,21 @@ async fn main(_spawner: Spawner, p: Peripherals) { delay(); assert!(b.is_low()); } - /* + // Test output open drain { - let b = Input::new(&mut b, Pull::Down); - // no pull, the status is undefined + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::Down); - let mut a = OutputOpenDrain::new(&mut a, Level::Low, Speed::Low, Pull::None); + let mut a = Flex::new(&mut a); + a.set_low(); + a.set_as_input_output(Speed::Low, Pull::None); delay(); assert!(b.is_low()); a.set_high(); // High-Z output delay(); assert!(b.is_low()); } -*/ info!("Test OK"); cortex_m::asm::bkpt(); From abba86d1bac38ab0e776fe376c78017299c8f699 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:24:29 +0200 Subject: [PATCH 12/18] Have added doc + minor correction --- tests/stm32/src/bin/gpio.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 2cdf52c0..952d4cd6 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -104,20 +104,24 @@ async fn main(_spawner: Spawner, p: Peripherals) { // FLEX // Test initial output { - let mut b = Flex::new(&mut b); + //Flex pin configured as input + let mut b = Flex::new(&mut b); b.set_as_input(Pull::None); { - let mut a = Flex::new(&mut a); - a.set_low(); + //Flex pin configured as output + let mut a = Flex::new(&mut a); //Flex pin configured as output + a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state a.set_as_output(Speed::Low); delay(); assert!(b.is_low()); } { - let mut a = Flex::new(&mut a); - a.set_as_output(Speed::Low); + //Flex pin configured as output + let mut a = Flex::new(&mut a); a.set_high(); + a.set_as_output(Speed::Low); + delay(); assert!(b.is_high()); } @@ -125,12 +129,13 @@ async fn main(_spawner: Spawner, p: Peripherals) { // Test input no pull { - let mut b = Flex::new(&mut b); + let mut b = Flex::new(&mut b); b.set_as_input(Pull::None); // no pull, the status is undefined let mut a = Flex::new(&mut a); a.set_low(); - a.set_as_output(Speed::Low); + a.set_as_output(Speed::Low); + delay(); assert!(b.is_low()); a.set_high(); From 94c13eb2afb14ba3358eb9f2b4c1baf3471a8a6a Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Fri, 8 Jul 2022 22:34:17 +0200 Subject: [PATCH 13/18] forgotten file --- tests/stm32/src/bin/gpio.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index 952d4cd6..a26daab4 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -135,7 +135,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut a = Flex::new(&mut a); a.set_low(); a.set_as_output(Speed::Low); - + delay(); assert!(b.is_low()); a.set_high(); From fa3e1ab68a11deb4b9ddad069bbf1e94d4375a0b Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Sat, 9 Jul 2022 14:06:47 +0200 Subject: [PATCH 14/18] correction of the access to flex pin attribute in gpio_v2 --- embassy-stm32/src/gpio.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 4f1ce3cf..c3ae96f3 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -90,7 +90,7 @@ impl<'d, T: Pin> Flex<'d, T> { { r.pupdr().modify(|w| w.set_pupdr(n, vals::Pupdr::FLOATING)); r.otyper().modify(|w| w.set_ot(n, vals::Ot::PUSHPULL)); - pin.set_speed(speed); + self.pin.set_speed(speed); r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); } }); @@ -125,7 +125,7 @@ impl<'d, T: Pin> Flex<'d, T> { { r.pupdr().modify(|w| w.set_pupdr(n, pull.into())); r.otyper().modify(|w| w.set_ot(n, vals::Ot::OPENDRAIN)); - pin.set_speed(speed); + self.pin.set_speed(speed); r.moder().modify(|w| w.set_moder(n, vals::Moder::OUTPUT)); } }); From 53388d4576617e621b5e63fd8599311a7f6066c3 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Sun, 10 Jul 2022 20:55:04 +0200 Subject: [PATCH 15/18] have adapted access to pin() and port() methods of Sealed::Pin in exti.rs according to previous changes on Input struct --- embassy-stm32/src/exti.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/embassy-stm32/src/exti.rs b/embassy-stm32/src/exti.rs index 378665b7..94e0e941 100644 --- a/embassy-stm32/src/exti.rs +++ b/embassy-stm32/src/exti.rs @@ -99,7 +99,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { } pub async fn wait_for_high<'a>(&'a mut self) { - let fut = ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false); + let fut = ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, false); if self.is_high() { return; } @@ -107,7 +107,7 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { } pub async fn wait_for_low<'a>(&'a mut self) { - let fut = ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true); + let fut = ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), false, true); if self.is_low() { return; } @@ -115,15 +115,15 @@ impl<'d, T: GpioPin> ExtiInput<'d, T> { } pub async fn wait_for_rising_edge<'a>(&'a mut self) { - ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, false).await + ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, false).await } pub async fn wait_for_falling_edge<'a>(&'a mut self) { - ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), false, true).await + ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), false, true).await } pub async fn wait_for_any_edge<'a>(&'a mut self) { - ExtiInputFuture::new(self.pin.pin.pin(), self.pin.pin.port(), true, true).await + ExtiInputFuture::new(self.pin.pin.pin.pin(), self.pin.pin.pin.port(), true, true).await } } From e4a36e1d98ac62482285dfb2b22f2683c3840572 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Sun, 10 Jul 2022 21:08:12 +0200 Subject: [PATCH 16/18] rustfmt on previously edited files --- embassy-stm32/src/gpio.rs | 21 +++++++++------------ tests/stm32/src/bin/gpio.rs | 27 +++++++++++++-------------- 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index c3ae96f3..fd0bdb7b 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -23,7 +23,7 @@ impl<'d, T: Pin> Flex<'d, T> { /// The pin remains disconnected. The initial output level is unspecified, but can be changed /// before the pin is put into output mode. /// - #[inline] + #[inline] pub fn new(pin: impl Unborrow + 'd) -> Self { unborrow!(pin); // Pin will be in disconnected state. @@ -32,9 +32,9 @@ impl<'d, T: Pin> Flex<'d, T> { phantom: PhantomData, } } - + /// Put the pin into input mode. - #[inline] + #[inline] pub fn set_as_input(&mut self, pull: Pull) { critical_section::with(|_| unsafe { let r = self.pin.block(); @@ -74,7 +74,6 @@ impl<'d, T: Pin> Flex<'d, T> { /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] pub fn set_as_output(&mut self, speed: Speed) { - critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; @@ -95,7 +94,7 @@ impl<'d, T: Pin> Flex<'d, T> { } }); } - + /// Put the pin into input + output mode. /// /// This is commonly used for "open drain" mode. @@ -106,7 +105,7 @@ impl<'d, T: Pin> Flex<'d, T> { /// The pin level will be whatever was set before (or low by default). If you want it to begin /// at a specific level, call `set_high`/`set_low` on the pin first. #[inline] - pub fn set_as_input_output(&mut self,speed: Speed, pull : Pull) { + pub fn set_as_input_output(&mut self, speed: Speed, pull: Pull) { critical_section::with(|_| unsafe { let r = self.pin.block(); let n = self.pin.pin() as usize; @@ -164,7 +163,7 @@ impl<'d, T: Pin> Flex<'d, T> { pub fn set_low(&mut self) { self.pin.set_low(); } - + /// Toggle pin output #[inline] pub fn toggle(&mut self) { @@ -262,7 +261,7 @@ impl From for vals::Ospeedr { /// GPIO input driver. pub struct Input<'d, T: Pin> { - pub(crate) pin: Flex<'d, T> + pub(crate) pin: Flex<'d, T>, } impl<'d, T: Pin> Input<'d, T> { @@ -340,10 +339,9 @@ impl<'d, T: Pin> Output<'d, T> { } } - /// GPIO output open-drain driver. pub struct OutputOpenDrain<'d, T: Pin> { - pub(crate) pin: Flex<'d, T> + pub(crate) pin: Flex<'d, T>, } impl<'d, T: Pin> OutputOpenDrain<'d, T> { @@ -925,10 +923,9 @@ mod eh1 { Ok(self.is_set_low()) } } - } #[cfg(feature = "unstable-pac")] pub mod low_level { pub use super::sealed::*; -} \ No newline at end of file +} diff --git a/tests/stm32/src/bin/gpio.rs b/tests/stm32/src/bin/gpio.rs index a26daab4..37cfe7cf 100644 --- a/tests/stm32/src/bin/gpio.rs +++ b/tests/stm32/src/bin/gpio.rs @@ -6,7 +6,7 @@ mod example_common; use defmt::assert; use embassy::executor::Spawner; -use embassy_stm32::gpio::{Input, Level, Output, OutputOpenDrain, Flex, Pull, Speed}; +use embassy_stm32::gpio::{Flex, Input, Level, Output, OutputOpenDrain, Pull, Speed}; use embassy_stm32::Peripherals; use example_common::*; @@ -104,21 +104,21 @@ async fn main(_spawner: Spawner, p: Peripherals) { // FLEX // Test initial output { - //Flex pin configured as input - let mut b = Flex::new(&mut b); + //Flex pin configured as input + let mut b = Flex::new(&mut b); b.set_as_input(Pull::None); { - //Flex pin configured as output - let mut a = Flex::new(&mut a); //Flex pin configured as output + //Flex pin configured as output + let mut a = Flex::new(&mut a); //Flex pin configured as output a.set_low(); // Pin state must be set before configuring the pin, thus we avoid unknown state a.set_as_output(Speed::Low); delay(); assert!(b.is_low()); } { - //Flex pin configured as output - let mut a = Flex::new(&mut a); + //Flex pin configured as output + let mut a = Flex::new(&mut a); a.set_high(); a.set_as_output(Speed::Low); @@ -129,12 +129,12 @@ async fn main(_spawner: Spawner, p: Peripherals) { // Test input no pull { - let mut b = Flex::new(&mut b); - b.set_as_input(Pull::None); // no pull, the status is undefined + let mut b = Flex::new(&mut b); + b.set_as_input(Pull::None); // no pull, the status is undefined let mut a = Flex::new(&mut a); a.set_low(); - a.set_as_output(Speed::Low); + a.set_as_output(Speed::Low); delay(); assert!(b.is_low()); @@ -143,11 +143,10 @@ async fn main(_spawner: Spawner, p: Peripherals) { assert!(b.is_high()); } - // Test input pulldown { let mut b = Flex::new(&mut b); - b.set_as_input(Pull::Down); + b.set_as_input(Pull::Down); delay(); assert!(b.is_low()); @@ -164,7 +163,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { // Test input pullup { let mut b = Flex::new(&mut b); - b.set_as_input(Pull::Up); + b.set_as_input(Pull::Up); delay(); assert!(b.is_high()); @@ -185,7 +184,7 @@ async fn main(_spawner: Spawner, p: Peripherals) { let mut a = Flex::new(&mut a); a.set_low(); - a.set_as_input_output(Speed::Low, Pull::None); + a.set_as_input_output(Speed::Low, Pull::None); delay(); assert!(b.is_low()); a.set_high(); // High-Z output From 1eca026ebdbbb85056ad27058a750d726013c5e3 Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Sun, 10 Jul 2022 21:36:04 +0200 Subject: [PATCH 17/18] Have removed redondant ErrorType trait impl --- embassy-stm32/src/gpio.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index fd0bdb7b..4926e1d8 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -868,10 +868,6 @@ mod eh1 { } } - 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 { From 323b0d1a5c430bfcec3288e229179a5b7c86038a Mon Sep 17 00:00:00 2001 From: "amugniere@gmail.com" Date: Sun, 10 Jul 2022 22:01:48 +0200 Subject: [PATCH 18/18] Have removed ANOTHER redondant ErrorType trait impl --- embassy-stm32/src/gpio.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index 4926e1d8..806b5eb6 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs @@ -880,10 +880,6 @@ mod eh1 { } } - 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> {