Skip to content

Commit

Permalink
Add InputPin impl for generic open drain outputs (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheZoq2 authored and TeXitoi committed Dec 29, 2019
1 parent bd54507 commit fa26e97
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

- Add `InputPin` impl for generic open drain outputs

## [v0.5.2] - 2019-12-15

- Fix USB module docs
Expand Down
15 changes: 15 additions & 0 deletions src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,21 @@ macro_rules! impl_pxx {
}
}

impl InputPin for Pxx<Output<OpenDrain>> {
type Error = Infallible;
fn is_high(&self) -> Result<bool, Infallible> {
match self {
$(Pxx::$pin(pin) => pin.is_high()),*
}
}

fn is_low(&self) -> Result<bool, Infallible> {
match self {
$(Pxx::$pin(pin) => pin.is_low()),*
}
}
}

impl<MODE> ExtiPin for Pxx<Input<MODE>> {
fn make_interrupt_source(&mut self, afio: &mut afio::Parts) {
match self {
Expand Down

0 comments on commit fa26e97

Please sign in to comment.