diff --git a/embedded-hal/CHANGELOG.md b/embedded-hal/CHANGELOG.md index a177ba7f1..c64a5ddbc 100644 --- a/embedded-hal/CHANGELOG.md +++ b/embedded-hal/CHANGELOG.md @@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] -No unreleased changes +- gpio: require `&mut self` in `InputPin` and `StatefulOutputPin`. ## [v1.0.0-rc.2] - 2023-11-28 diff --git a/embedded-hal/src/digital.rs b/embedded-hal/src/digital.rs index f54c72153..f65fc0bfd 100644 --- a/embedded-hal/src/digital.rs +++ b/embedded-hal/src/digital.rs @@ -169,22 +169,22 @@ 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(&self) -> Result; + fn is_set_high(&mut self) -> Result; /// Is the pin in drive low mode? /// /// *NOTE* this does *not* read the electrical state of the pin. - fn is_set_low(&self) -> Result; + fn is_set_low(&mut self) -> Result; } impl StatefulOutputPin for &mut T { #[inline] - fn is_set_high(&self) -> Result { + fn is_set_high(&mut self) -> Result { T::is_set_high(self) } #[inline] - fn is_set_low(&self) -> Result { + fn is_set_low(&mut self) -> Result { T::is_set_low(self) } } @@ -205,20 +205,20 @@ impl ToggleableOutputPin for &mut T { /// Single digital input pin. pub trait InputPin: ErrorType { /// Is the input pin high? - fn is_high(&self) -> Result; + fn is_high(&mut self) -> Result; /// Is the input pin low? - fn is_low(&self) -> Result; + fn is_low(&mut self) -> Result; } -impl InputPin for &T { +impl InputPin for &mut T { #[inline] - fn is_high(&self) -> Result { + fn is_high(&mut self) -> Result { T::is_high(self) } #[inline] - fn is_low(&self) -> Result { + fn is_low(&mut self) -> Result { T::is_low(self) } }