Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "gpio: require &mut self in InputPin and StatefulOutputPin" #553

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions embedded-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions embedded-hal/src/digital.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bool, Self::Error>;
fn is_set_high(&self) -> Result<bool, Self::Error>;

/// 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<bool, Self::Error>;
fn is_set_low(&self) -> Result<bool, Self::Error>;

/// Toggle pin output.
fn toggle(&mut self) -> Result<(), Self::Error> {
Expand All @@ -185,12 +185,12 @@ pub trait StatefulOutputPin: OutputPin {

impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
#[inline]
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
fn is_set_high(&self) -> Result<bool, Self::Error> {
T::is_set_high(self)
}

#[inline]
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
fn is_set_low(&self) -> Result<bool, Self::Error> {
T::is_set_low(self)
}

Expand All @@ -203,20 +203,20 @@ impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
/// Single digital input pin.
pub trait InputPin: ErrorType {
/// Is the input pin high?
fn is_high(&mut self) -> Result<bool, Self::Error>;
fn is_high(&self) -> Result<bool, Self::Error>;

/// Is the input pin low?
fn is_low(&mut self) -> Result<bool, Self::Error>;
fn is_low(&self) -> Result<bool, Self::Error>;
}

impl<T: InputPin + ?Sized> InputPin for &mut T {
impl<T: InputPin + ?Sized> InputPin for &T {
#[inline]
fn is_high(&mut self) -> Result<bool, Self::Error> {
fn is_high(&self) -> Result<bool, Self::Error> {
T::is_high(self)
}

#[inline]
fn is_low(&mut self) -> Result<bool, Self::Error> {
fn is_low(&self) -> Result<bool, Self::Error> {
T::is_low(self)
}
}