Skip to content

Commit

Permalink
Merge pull request #6 from niclashoyer/1.0.0-alpha.6
Browse files Browse the repository at this point in the history
Eliminated undefined behaviour on pin toggle
  • Loading branch information
niclashoyer authored Dec 23, 2021
2 parents d324f8a + 768fe91 commit ccd79b7
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.5.2] - 2021-12-23
### Changed
- Eliminated undefined behaviour on pin toggle

## [0.5.1] - 2021-12-23
### Fixed
- Fix panic on pin toggle
Expand Down
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "embedded-hal-sync-pins"
version = "0.5.1"
version = "0.5.2"
authors = ["Niclas Hoyer <info@niclashoyer.de>"]
edition = "2018"
description = "embedded-hal pin implementations that can be shared between threads"
Expand Down
6 changes: 3 additions & 3 deletions src/pins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl hal::ToggleableOutputPin for PushPullPin {
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| match x {
PinState::Low => Some(PinState::High),
PinState::High => Some(PinState::Low),
_ => None,
PinState::Floating => Some(PinState::Low),
});
Ok(())
}
Expand Down Expand Up @@ -290,9 +290,9 @@ impl hal::ToggleableOutputPin for OpenDrainPin {
fn toggle(&mut self) -> Result<(), Self::Error> {
self.state
.fetch_update(Ordering::SeqCst, Ordering::SeqCst, |x| match x {
PinState::Low => Some(PinState::Floating),
PinState::Floating => Some(PinState::Low),
_ => None,
PinState::Low => Some(PinState::Floating),
PinState::High => Some(PinState::Floating),
});
Ok(())
}
Expand Down
6 changes: 3 additions & 3 deletions src/wire.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ impl ToggleableOutputPin for PushPullPin {

fn toggle(&mut self) -> Result<(), Self::Error> {
self.wire.update_pin_state(self.id, |x| match x {
WireState::High => WireState::Low,
WireState::Low => WireState::High,
WireState::Floating => unreachable!(),
WireState::High => WireState::Low,
WireState::Floating => WireState::Low,
});
Ok(())
}
Expand Down Expand Up @@ -251,7 +251,7 @@ impl ToggleableOutputPin for OpenDrainPin {
self.wire.update_pin_state(self.id, |x| match x {
WireState::Floating => WireState::Low,
WireState::Low => WireState::Floating,
WireState::High => unreachable!(),
WireState::High => WireState::Floating,
});
Ok(())
}
Expand Down

0 comments on commit ccd79b7

Please sign in to comment.