Split up the SPI trait into several with shared Error associated type.
This commit is contained in:
parent
372884422a
commit
22901938ce
@ -18,25 +18,39 @@ use core::future::Future;
|
|||||||
///
|
///
|
||||||
/// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different
|
/// - Some SPIs can work with 8-bit *and* 16-bit words. You can overload this trait with different
|
||||||
/// `Word` types to allow operation in both modes.
|
/// `Word` types to allow operation in both modes.
|
||||||
pub trait FullDuplex<Word> {
|
|
||||||
|
pub trait Spi<Word> {
|
||||||
/// An enumeration of SPI errors
|
/// An enumeration of SPI errors
|
||||||
type Error;
|
type Error;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FullDuplex<Word> : Spi<Word> + Write<Word> + Read<Word> {
|
||||||
|
|
||||||
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
|
type WriteReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||||
where
|
where
|
||||||
Self: 'a;
|
Self: 'a;
|
||||||
|
|
||||||
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
|
|
||||||
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
|
|
||||||
fn read_write<'a>(
|
fn read_write<'a>(
|
||||||
&'a mut self,
|
&'a mut self,
|
||||||
read: &'a mut [Word],
|
read: &'a mut [Word],
|
||||||
write: &'a [Word],
|
write: &'a [Word],
|
||||||
) -> Self::WriteReadFuture<'a>;
|
) -> Self::WriteReadFuture<'a>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub trait Write<Word> : Spi<Word>{
|
||||||
|
|
||||||
|
type WriteFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||||
|
where
|
||||||
|
Self: 'a;
|
||||||
|
|
||||||
|
fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait Read<Word> : Spi<Word>{
|
||||||
|
|
||||||
|
type ReadFuture<'a>: Future<Output = Result<(), Self::Error>> + 'a
|
||||||
|
where
|
||||||
|
Self: 'a;
|
||||||
|
|
||||||
|
fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user