aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Bevenius <[email protected]>2022-05-19 05:43:18 +0200
committerDaniel Bevenius <[email protected]>2022-05-21 10:11:12 +0200
commit027ab3371ea85d68c7fc02da69e29924b53aa087 (patch)
tree226f78c069e45a7f54f7cf204c1d2fdba6db1e04
parentc8461709e39621a04edcb9c12a5652aa6181d6da (diff)
Impl OutputPin/StatefulOutputPin/ToggleableOutputPin
This commit implements embedded_hal_02::digital::v2 OutputPin, StatefulOutputPin, and ToggleableOutputPin for embassy-rp.
-rw-r--r--embassy-rp/src/gpio.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index 79f3a600e..12b9f6aca 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -404,6 +404,38 @@ mod eh02 {
404 Ok(self.toggle()) 404 Ok(self.toggle())
405 } 405 }
406 } 406 }
407
408 impl<'d, T: Pin> embedded_hal_02::digital::v2::OutputPin for OutputOpenDrain<'d, T> {
409 type Error = Infallible;
410
411 #[inline]
412 fn set_high(&mut self) -> Result<(), Self::Error> {
413 Ok(self.set_high())
414 }
415
416 #[inline]
417 fn set_low(&mut self) -> Result<(), Self::Error> {
418 Ok(self.set_low())
419 }
420 }
421
422 impl<'d, T: Pin> embedded_hal_02::digital::v2::StatefulOutputPin for OutputOpenDrain<'d, T> {
423 fn is_set_high(&self) -> Result<bool, Self::Error> {
424 Ok(self.is_set_high())
425 }
426
427 fn is_set_low(&self) -> Result<bool, Self::Error> {
428 Ok(self.is_set_low())
429 }
430 }
431
432 impl<'d, T: Pin> embedded_hal_02::digital::v2::ToggleableOutputPin for OutputOpenDrain<'d, T> {
433 type Error = Infallible;
434 #[inline]
435 fn toggle(&mut self) -> Result<(), Self::Error> {
436 Ok(self.toggle())
437 }
438 }
407} 439}
408 440
409#[cfg(feature = "unstable-traits")] 441#[cfg(feature = "unstable-traits")]