diff --git a/embedded-hal/CHANGELOG.md b/embedded-hal/CHANGELOG.md index 9d3ac625b..00c663582 100644 --- a/embedded-hal/CHANGELOG.md +++ b/embedded-hal/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] - gpio: remove `ToggleableOutputPin`, move `toggle()` to `StatefulOutputPin`. +- gpio: *don't* require `&mut self` in `InputPin` and `StatefulOutputPin`. ## [v1.0.0-rc.3] - 2023-12-14 diff --git a/embedded-hal/src/digital.rs b/embedded-hal/src/digital.rs index afcf03963..ef2fe1784 100644 --- a/embedded-hal/src/digital.rs +++ b/embedded-hal/src/digital.rs @@ -169,12 +169,12 @@ pub trait StatefulOutputPin: OutputPin { /// Is the pin in drive high mode? /// /// *NOTE* this does *not* read the electrical state of the pin. - fn is_set_high(&mut self) -> Result; + fn is_set_high(&self) -> Result; /// Is the pin in drive low mode? /// /// *NOTE* this does *not* read the electrical state of the pin. - fn is_set_low(&mut self) -> Result; + fn is_set_low(&self) -> Result; /// Toggle pin output. fn toggle(&mut self) -> Result<(), Self::Error> { @@ -185,12 +185,12 @@ pub trait StatefulOutputPin: OutputPin { impl StatefulOutputPin for &mut T { #[inline] - fn is_set_high(&mut self) -> Result { + fn is_set_high(&self) -> Result { T::is_set_high(self) } #[inline] - fn is_set_low(&mut self) -> Result { + fn is_set_low(&self) -> Result { T::is_set_low(self) } @@ -203,20 +203,20 @@ impl StatefulOutputPin for &mut T { /// Single digital input pin. pub trait InputPin: ErrorType { /// Is the input pin high? - fn is_high(&mut self) -> Result; + fn is_high(&self) -> Result; /// Is the input pin low? - fn is_low(&mut self) -> Result; + fn is_low(&self) -> Result; } -impl InputPin for &mut T { +impl InputPin for &T { #[inline] - fn is_high(&mut self) -> Result { + fn is_high(&self) -> Result { T::is_high(self) } #[inline] - fn is_low(&mut self) -> Result { + fn is_low(&self) -> Result { T::is_low(self) } }