diff options
| author | Dario Nieuwenhuis <[email protected]> | 2021-03-18 01:27:30 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2021-03-18 01:27:30 +0100 |
| commit | 3de2d5c5bde44f1aec0e1727cfb2af3052c1bda4 (patch) | |
| tree | a337a563ce519ff73123f5b219587e3570adf0c1 /embassy-traits/src | |
| parent | c403a47b7f77252c26356d69173169b5fe393d52 (diff) | |
Implement FullDuplex for nrf spim
Diffstat (limited to 'embassy-traits/src')
| -rw-r--r-- | embassy-traits/src/spi.rs | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/embassy-traits/src/spi.rs b/embassy-traits/src/spi.rs index d0cf29e6d..9f08e7402 100644 --- a/embassy-traits/src/spi.rs +++ b/embassy-traits/src/spi.rs | |||
| @@ -1,6 +1,7 @@ | |||
| 1 | //! Async SPI API | 1 | //! Async SPI API |
| 2 | 2 | ||
| 3 | use core::future::Future; | 3 | use core::future::Future; |
| 4 | use core::pin::Pin; | ||
| 4 | 5 | ||
| 5 | /// Full duplex (master mode) | 6 | /// Full duplex (master mode) |
| 6 | /// | 7 | /// |
| @@ -22,15 +23,21 @@ pub trait FullDuplex<Word> { | |||
| 22 | /// An enumeration of SPI errors | 23 | /// An enumeration of SPI errors |
| 23 | type Error; | 24 | type Error; |
| 24 | 25 | ||
| 25 | type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a; | 26 | type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a |
| 26 | type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a; | 27 | where |
| 27 | type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a; | 28 | Self: 'a; |
| 29 | type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a | ||
| 30 | where | ||
| 31 | Self: 'a; | ||
| 32 | type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a | ||
| 33 | where | ||
| 34 | Self: 'a; | ||
| 28 | 35 | ||
| 29 | fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'_>; | 36 | fn read<'a>(self: Pin<&'a mut Self>, data: &'a mut [Word]) -> Self::ReadFuture<'a>; |
| 30 | fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'_>; | 37 | fn write<'a>(self: Pin<&'a mut Self>, data: &'a [Word]) -> Self::WriteFuture<'a>; |
| 31 | fn read_write<'a>( | 38 | fn read_write<'a>( |
| 32 | &mut self, | 39 | self: Pin<&'a mut Self>, |
| 33 | read: &'a mut [Word], | 40 | read: &'a mut [Word], |
| 34 | write: &'a [Word], | 41 | write: &'a [Word], |
| 35 | ) -> Self::WriteReadFuture<'_>; | 42 | ) -> Self::WriteReadFuture<'a>; |
| 36 | } | 43 | } |
