diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-11-21 23:31:31 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-11-25 21:02:06 +0100 |
| commit | 1e2fb0459d8546ba658bb9fe150be5f1f537b48e (patch) | |
| tree | eb40a5027581896c7b78db58f509431ed6b11892 /embassy-rp/src/spi.rs | |
| parent | 758f5d7ea29f1df14d5ef59c82e4b7f22545d775 (diff) | |
Switch to async-fn-in-trait
Diffstat (limited to 'embassy-rp/src/spi.rs')
| -rw-r--r-- | embassy-rp/src/spi.rs | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/embassy-rp/src/spi.rs b/embassy-rp/src/spi.rs index 754e2dd30..2b7a818d9 100644 --- a/embassy-rp/src/spi.rs +++ b/embassy-rp/src/spi.rs | |||
| @@ -554,45 +554,33 @@ mod eh1 { | |||
| 554 | 554 | ||
| 555 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] | 555 | #[cfg(all(feature = "unstable-traits", feature = "nightly"))] |
| 556 | mod eha { | 556 | mod eha { |
| 557 | use core::future::Future; | ||
| 558 | |||
| 559 | use super::*; | 557 | use super::*; |
| 560 | 558 | ||
| 561 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Async> { | 559 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusFlush for Spi<'d, T, Async> { |
| 562 | type FlushFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 560 | async fn flush(&mut self) -> Result<(), Self::Error> { |
| 563 | 561 | Ok(()) | |
| 564 | fn flush<'a>(&'a mut self) -> Self::FlushFuture<'a> { | ||
| 565 | async { Ok(()) } | ||
| 566 | } | 562 | } |
| 567 | } | 563 | } |
| 568 | 564 | ||
| 569 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spi<'d, T, Async> { | 565 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusWrite<u8> for Spi<'d, T, Async> { |
| 570 | type WriteFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 566 | async fn write(&mut self, words: &[u8]) -> Result<(), Self::Error> { |
| 571 | 567 | self.write(words).await | |
| 572 | fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> { | ||
| 573 | self.write(data) | ||
| 574 | } | 568 | } |
| 575 | } | 569 | } |
| 576 | 570 | ||
| 577 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spi<'d, T, Async> { | 571 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBusRead<u8> for Spi<'d, T, Async> { |
| 578 | type ReadFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 572 | async fn read(&mut self, words: &mut [u8]) -> Result<(), Self::Error> { |
| 579 | 573 | self.read(words).await | |
| 580 | fn read<'a>(&'a mut self, data: &'a mut [u8]) -> Self::ReadFuture<'a> { | ||
| 581 | self.read(data) | ||
| 582 | } | 574 | } |
| 583 | } | 575 | } |
| 584 | 576 | ||
| 585 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spi<'d, T, Async> { | 577 | impl<'d, T: Instance> embedded_hal_async::spi::SpiBus<u8> for Spi<'d, T, Async> { |
| 586 | type TransferFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 578 | async fn transfer<'a>(&'a mut self, read: &'a mut [u8], write: &'a [u8]) -> Result<(), Self::Error> { |
| 587 | 579 | self.transfer(read, write).await | |
| 588 | fn transfer<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::TransferFuture<'a> { | ||
| 589 | self.transfer(rx, tx) | ||
| 590 | } | 580 | } |
| 591 | 581 | ||
| 592 | type TransferInPlaceFuture<'a> = impl Future<Output = Result<(), Self::Error>> + 'a where Self: 'a; | 582 | async fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Result<(), Self::Error> { |
| 593 | 583 | self.transfer_in_place(words).await | |
| 594 | fn transfer_in_place<'a>(&'a mut self, words: &'a mut [u8]) -> Self::TransferInPlaceFuture<'a> { | ||
| 595 | self.transfer_in_place(words) | ||
| 596 | } | 584 | } |
| 597 | } | 585 | } |
| 598 | } | 586 | } |
