feat(rp): add Wait impl to OutputOpenDrain
				
					
				
			A while ago `OutputOpenDrain` was made to implement `InputPin`, something that allowed drivers for various one-wire protocols to be written, but it's been lacking a `Wait` implementation — something that's needed to write async versions of these drivers. This commit also adds `get_level()` to `OutputOpenDrain`, since `is_high()` and `is_low()` were already implemented, but `get_level()` itself was missing.
This commit is contained in:
		
							parent
							
								
									047ea9066f
								
							
						
					
					
						commit
						1fbb8f0b32
					
				| @ -437,6 +437,37 @@ impl<'d, T: Pin> OutputOpenDrain<'d, T> { | |||||||
|     pub fn is_low(&self) -> bool { |     pub fn is_low(&self) -> bool { | ||||||
|         self.pin.is_low() |         self.pin.is_low() | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     /// Returns current pin level
 | ||||||
|  |     #[inline] | ||||||
|  |     pub fn get_level(&self) -> Level { | ||||||
|  |         self.is_high().into() | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     #[inline] | ||||||
|  |     pub async fn wait_for_high(&mut self) { | ||||||
|  |         self.pin.wait_for_high().await; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     #[inline] | ||||||
|  |     pub async fn wait_for_low(&mut self) { | ||||||
|  |         self.pin.wait_for_low().await; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     #[inline] | ||||||
|  |     pub async fn wait_for_rising_edge(&mut self) { | ||||||
|  |         self.pin.wait_for_rising_edge().await; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     #[inline] | ||||||
|  |     pub async fn wait_for_falling_edge(&mut self) { | ||||||
|  |         self.pin.wait_for_falling_edge().await; | ||||||
|  |     } | ||||||
|  | 
 | ||||||
|  |     #[inline] | ||||||
|  |     pub async fn wait_for_any_edge(&mut self) { | ||||||
|  |         self.pin.wait_for_any_edge().await; | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| /// GPIO flexible pin.
 | /// GPIO flexible pin.
 | ||||||
| @ -1117,4 +1148,32 @@ mod eh1 { | |||||||
|             Ok(()) |             Ok(()) | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | 
 | ||||||
|  |     #[cfg(feature = "nightly")] | ||||||
|  |     impl<'d, T: Pin> embedded_hal_async::digital::Wait for OutputOpenDrain<'d, T> { | ||||||
|  |         async fn wait_for_high(&mut self) -> Result<(), Self::Error> { | ||||||
|  |             self.wait_for_high().await; | ||||||
|  |             Ok(()) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         async fn wait_for_low(&mut self) -> Result<(), Self::Error> { | ||||||
|  |             self.wait_for_low().await; | ||||||
|  |             Ok(()) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         async fn wait_for_rising_edge(&mut self) -> Result<(), Self::Error> { | ||||||
|  |             self.wait_for_rising_edge().await; | ||||||
|  |             Ok(()) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         async fn wait_for_falling_edge(&mut self) -> Result<(), Self::Error> { | ||||||
|  |             self.wait_for_falling_edge().await; | ||||||
|  |             Ok(()) | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|  |         async fn wait_for_any_edge(&mut self) -> Result<(), Self::Error> { | ||||||
|  |             self.wait_for_any_edge().await; | ||||||
|  |             Ok(()) | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user