diff --git a/embassy-traits/src/spi.rs b/embassy-traits/src/spi.rs index 227b8bfe..d19a1e58 100644 --- a/embassy-traits/src/spi.rs +++ b/embassy-traits/src/spi.rs @@ -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 /// `Word` types to allow operation in both modes. -pub trait FullDuplex { + +pub trait Spi { /// An enumeration of SPI errors type Error; +} + +pub trait FullDuplex : Spi + Write + Read { - type WriteFuture<'a>: Future> + 'a - where - Self: 'a; - type ReadFuture<'a>: Future> + 'a - where - Self: 'a; type WriteReadFuture<'a>: Future> + 'a where 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>( &'a mut self, read: &'a mut [Word], write: &'a [Word], ) -> Self::WriteReadFuture<'a>; } + +pub trait Write : Spi{ + + type WriteFuture<'a>: Future> + 'a + where + Self: 'a; + + fn write<'a>(&'a mut self, data: &'a [Word]) -> Self::WriteFuture<'a>; +} + +pub trait Read : Spi{ + + type ReadFuture<'a>: Future> + 'a + where + Self: 'a; + + fn read<'a>(&'a mut self, data: &'a mut [Word]) -> Self::ReadFuture<'a>; +} \ No newline at end of file