Skip to content

Commit

Permalink
Merge pull request #103 from TheZoq2/master
Browse files Browse the repository at this point in the history
Remove OutputPin impl for Alternate mode pins
  • Loading branch information
therealprof authored Aug 18, 2019
2 parents 1350f81 + b8207f6 commit 9c9c6e1
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 24 deletions.
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

0 comments on commit 9c9c6e1

Please sign in to comment.