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

Remove OutputPin impl for Alternate mode pins #103

Merged
merged 1 commit into from
Aug 18, 2019
Merged
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 CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
### Breaking changes

- Change timer/pwm init API
- Remove `set_low` and `set_high` for pins in Alternate output mode

### Changed

Expand Down
24 changes: 0 additions & 24 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,30 +479,6 @@ macro_rules! gpio {

impl<MODE> toggleable::Default for $PXi<Output<MODE>> {}

impl<MODE> OutputPin for $PXi<Alternate<MODE>> {
type Error = Void;
fn set_high(&mut self) -> Result<(), Self::Error> {
// NOTE(unsafe) atomic write to a stateless register
Ok(unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << $i)) })
}

fn set_low(&mut self) -> Result<(), Self::Error> {
// NOTE(unsafe) atomic write to a stateless register
Ok(unsafe { (*$GPIOX::ptr()).bsrr.write(|w| w.bits(1 << (16 + $i))) })
}
}

impl<MODE> StatefulOutputPin for $PXi<Alternate<MODE>> {
fn is_set_high(&self) -> Result<bool, Self::Error> {
self.is_set_low().map(|b| !b)
}

fn is_set_low(&self) -> Result<bool, Self::Error> {
// NOTE(unsafe) atomic read with no side effects
Ok(unsafe { (*$GPIOX::ptr()).odr.read().bits() & (1 << $i) == 0 })
}
}

impl<MODE> InputPin for $PXi<Input<MODE>> {
type Error = Void;
fn is_high(&self) -> Result<bool, Self::Error> {
Expand Down