aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-rp/src/gpio.rs59
1 files changed, 59 insertions, 0 deletions
diff --git a/embassy-rp/src/gpio.rs b/embassy-rp/src/gpio.rs
index fb45ef7cf..98e182868 100644
--- a/embassy-rp/src/gpio.rs
+++ b/embassy-rp/src/gpio.rs
@@ -437,6 +437,37 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> {
437 pub fn is_low(&self) -> bool { 437 pub fn is_low(&self) -> bool {
438 self.pin.is_low() 438 self.pin.is_low()
439 } 439 }
440
441 /// Returns current pin level
442 #[inline]
443 pub fn get_level(&self) -> Level {
444 self.is_high().into()
445 }
446
447 #[inline]
448 pub async fn wait_for_high(&mut self) {
449 self.pin.wait_for_high().await;
450 }
451
452 #[inline]
453 pub async fn wait_for_low(&mut self) {
454 self.pin.wait_for_low().await;
455 }
456
457 #[inline]
458 pub async fn wait_for_rising_edge(&mut self) {
459 self.pin.wait_for_rising_edge().await;
460 }
461
462 #[inline]
463 pub async fn wait_for_falling_edge(&mut self) {
464 self.pin.wait_for_falling_edge().await;
465 }
466
467 #[inline]
468 pub async fn wait_for_any_edge(&mut self) {
469 self.pin.wait_for_any_edge().await;
470 }
440} 471}
441 472
442/// GPIO flexible pin. 473/// GPIO flexible pin.
@@ -1117,4 +1148,32 @@ mod eh1 {
1117 Ok(()) 1148 Ok(())
1118 } 1149 }
1119 } 1150 }
1151
1152 #[cfg(feature = "nightly")]
1153 impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> {
1154 async fn wait_for_high(&mut self) -> Result<(), Self::Error> {
1155 self.wait_for_high().await;
1156 Ok(())
1157 }
1158
1159 async fn wait_for_low(&mut self) -> Result<(), Self::Error> {
1160 self.wait_for_low().await;
1161 Ok(())
1162 }
1163
1164 async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> {
1165 self.wait_for_rising_edge().await;
1166 Ok(())
1167 }
1168
1169 async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> {
1170 self.wait_for_falling_edge().await;
1171 Ok(())
1172 }
1173
1174 async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> {
1175 self.wait_for_any_edge().await;
1176 Ok(())
1177 }
1178 }
1120} 1179}