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

Add InputPin impl for generic open drain outputs #160

Merged
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
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