rp: implement input for OutputOpenDrain

This commit is contained in:
Dario Nieuwenhuis 2022-12-06 19:54:39 +01:00
parent 5e94b8060b
commit 7cbc3aefe6

View File

@ -411,6 +411,16 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
pub fn toggle(&mut self) { pub fn toggle(&mut self) {
self.pin.toggle_set_as_output() self.pin.toggle_set_as_output()
} }
#[inline]
pub fn is_high(&self) -> bool {
self.pin.is_high()
}
#[inline]
pub fn is_low(&self) -> bool {
self.pin.is_low()
}
} }
/// GPIO flexible pin. /// GPIO flexible pin.
@ -791,6 +801,18 @@ mod eh02 {
} }
} }
impl<'d, T: Pin> embedded_hal_02::digital::v2::InputPin for OutputOpenDrain<'d, T> {
type Error = Infallible;
fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high())
}
fn is_low(&self) -> Result<bool, Self::Error> {
Ok(self.is_low())
}
}
impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> { impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> {
type Error = Infallible; type Error = Infallible;
@ -946,6 +968,16 @@ mod eh1 {
} }
} }
impl<'d, T: Pin> embedded_hal_1::digital::InputPin for OutputOpenDrain<'d, T> {
fn is_high(&self) -> Result<bool, Self::Error> {
Ok(self.is_high())
}
fn is_low(&self) -> Result<bool, Self::Error> {
Ok(self.is_low())
}
}
impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> { impl<'d, T: Pin> embedded_hal_1::digital::ErrorType for Flex<'d, T> {
type Error = Infallible; type Error = Infallible;
} }