Skip to content

Commit fa26e97

Browse files
TheZoq2TeXitoi
authored andcommitted
Add InputPin impl for generic open drain outputs (#160)
1 parent bd54507 commit fa26e97

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Add `InputPin` impl for generic open drain outputs
11+
1012
## [v0.5.2] - 2019-12-15
1113

1214
- Fix USB module docs

src/gpio.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,6 +731,21 @@ macro_rules! impl_pxx {
731731
}
732732
}
733733

734+
impl InputPin for Pxx<Output<OpenDrain>> {
735+
type Error = Infallible;
736+
fn is_high(&self) -> Result<bool, Infallible> {
737+
match self {
738+
$(Pxx::$pin(pin) => pin.is_high()),*
739+
}
740+
}
741+
742+
fn is_low(&self) -> Result<bool, Infallible> {
743+
match self {
744+
$(Pxx::$pin(pin) => pin.is_low()),*
745+
}
746+
}
747+
}
748+
734749
impl<MODE> ExtiPin for Pxx<Input<MODE>> {
735750
fn make_interrupt_source(&mut self, afio: &mut afio::Parts) {
736751
match self {

0 commit comments

Comments
 (0)