Skip to content

Commit 6c09acb

Browse files
authored
Merge pull request #550 from Dirbaio/gpio-no-toggleable
gpio: remove `ToggleableOutputPin`, move `toggle()` to `StatefulOutputPin`.
2 parents b327f43 + c5c076a commit 6c09acb

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

embedded-hal/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10-
No unreleased changes yet
10+
- gpio: remove `ToggleableOutputPin`, move `toggle()` to `StatefulOutputPin`.
1111

1212
## [v1.0.0-rc.3] - 2023-12-14
1313

embedded-hal/src/digital.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,12 @@ pub trait StatefulOutputPin: OutputPin {
175175
///
176176
/// *NOTE* this does *not* read the electrical state of the pin.
177177
fn is_set_low(&mut self) -> Result<bool, Self::Error>;
178+
179+
/// Toggle pin output.
180+
fn toggle(&mut self) -> Result<(), Self::Error> {
181+
let was_low: bool = self.is_set_low()?;
182+
self.set_state(PinState::from(was_low))
183+
}
178184
}
179185

180186
impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
@@ -187,15 +193,7 @@ impl<T: StatefulOutputPin + ?Sized> StatefulOutputPin for &mut T {
187193
fn is_set_low(&mut self) -> Result<bool, Self::Error> {
188194
T::is_set_low(self)
189195
}
190-
}
191-
192-
/// Output pin that can be toggled.
193-
pub trait ToggleableOutputPin: ErrorType {
194-
/// Toggle pin output.
195-
fn toggle(&mut self) -> Result<(), Self::Error>;
196-
}
197196

198-
impl<T: ToggleableOutputPin + ?Sized> ToggleableOutputPin for &mut T {
199197
#[inline]
200198
fn toggle(&mut self) -> Result<(), Self::Error> {
201199
T::toggle(self)

0 commit comments

Comments
 (0)