Implement FullDuplex for nrf spim

This commit is contained in:
Dario Nieuwenhuis
2021-03-18 01:27:30 +01:00
parent c403a47b7f
commit 3de2d5c5bd
3 changed files with 43 additions and 15 deletions

View File

@ -1,6 +1,7 @@
//! Async SPI API
use core::future::Future;
use core::pin::Pin;
/// Full duplex (master mode)
///
@ -22,15 +23,21 @@ pub trait FullDuplex<Word> {
/// An enumeration of SPI errors
type Error;
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a;
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a;
type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a;
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where
Self: 'a;
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where
Self: 'a;
type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
where
Self: 'a;
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'_>;
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'_>;
fn read<'a>(self: Pin<&'a mut Self>, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
fn write<'a>(self: Pin<&'a mut Self>, data: &'a [Word]) -> Self::WriteFuture<'a>;
fn read_write<'a>(
&mut self,
self: Pin<&'a mut Self>,
read: &'a mut [Word],
write: &'a [Word],
) -> Self::WriteReadFuture<'_>;
) -> Self::WriteReadFuture<'a>;
}