diff options
| author | Bob McWhirter <[email protected]> | 2021-07-20 09:52:03 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-07-23 13:22:39 -0400 |
| commit | d5ed5c3ef3d3bc2ad6f22a1f67dfd8021c259621 (patch) | |
| tree | da8fa716d76794e1c16f69ee37d204c3023ae821 | |
| parent | 22901938ce4199c6545906226abecbe174a2e553 (diff) | |
Split up the nRF impls for SPI traits.
| -rw-r--r-- | embassy-nrf/src/spim.rs | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/embassy-nrf/src/spim.rs b/embassy-nrf/src/spim.rs index 47d7c5f90..c3d4c5b30 100644 --- a/embassy-nrf/src/spim.rs +++ b/embassy-nrf/src/spim.rs | |||
| @@ -9,7 +9,7 @@ use embassy::traits; | |||
| 9 | use embassy::util::{AtomicWaker, Unborrow}; | 9 | use embassy::util::{AtomicWaker, Unborrow}; |
| 10 | use embassy_extras::unborrow; | 10 | use embassy_extras::unborrow; |
| 11 | use futures::future::poll_fn; | 11 | use futures::future::poll_fn; |
| 12 | use traits::spi::FullDuplex; | 12 | use traits::spi::{ Spi, Read, Write, FullDuplex}; |
| 13 | 13 | ||
| 14 | use crate::gpio; | 14 | use crate::gpio; |
| 15 | use crate::gpio::sealed::Pin as _; | 15 | use crate::gpio::sealed::Pin as _; |
| @@ -177,22 +177,31 @@ impl<'d, T: Instance> Drop for Spim<'d, T> { | |||
| 177 | } | 177 | } |
| 178 | } | 178 | } |
| 179 | 179 | ||
| 180 | impl<'d, T: Instance> FullDuplex<u8> for Spim<'d, T> { | 180 | impl<'d, T: Instance> Spi<u8> for Spim<'d, T> { |
| 181 | type Error = Error; | 181 | type Error = Error; |
| 182 | } | ||
| 182 | 183 | ||
| 184 | impl<'d, T: Instance> Read<u8> for Spim<'d, T> { | ||
| 183 | #[rustfmt::skip] | 185 | #[rustfmt::skip] |
| 184 | type WriteFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>> + 'a; | 186 | type ReadFuture<'a> where Self: 'a = impl Future<Output=Result<(), Self::Error>> + 'a; |
| 185 | #[rustfmt::skip] | ||
| 186 | type ReadFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>> + 'a; | ||
| 187 | #[rustfmt::skip] | ||
| 188 | type WriteReadFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>> + 'a; | ||
| 189 | 187 | ||
| 190 | fn read<'a>(&'a mut self, data: &'a mut [u8]) -> Self::ReadFuture<'a> { | 188 | fn read<'a>(&'a mut self, data: &'a mut [u8]) -> Self::ReadFuture<'a> { |
| 191 | self.read_write(data, &[]) | 189 | self.read_write(data, &[]) |
| 192 | } | 190 | } |
| 191 | } | ||
| 192 | |||
| 193 | impl<'d, T: Instance> Write<u8> for Spim<'d, T> { | ||
| 194 | #[rustfmt::skip] | ||
| 195 | type WriteFuture<'a> where Self: 'a = impl Future<Output=Result<(), Self::Error>> + 'a; | ||
| 196 | |||
| 193 | fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> { | 197 | fn write<'a>(&'a mut self, data: &'a [u8]) -> Self::WriteFuture<'a> { |
| 194 | self.read_write(&mut [], data) | 198 | self.read_write(&mut [], data) |
| 195 | } | 199 | } |
| 200 | } | ||
| 201 | |||
| 202 | impl<'d, T: Instance> FullDuplex<u8> for Spim<'d, T> { | ||
| 203 | #[rustfmt::skip] | ||
| 204 | type WriteReadFuture<'a> where Self: 'a = impl Future<Output = Result<(), Self::Error>> + 'a; | ||
| 196 | 205 | ||
| 197 | fn read_write<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::WriteReadFuture<'a> { | 206 | fn read_write<'a>(&'a mut self, rx: &'a mut [u8], tx: &'a [u8]) -> Self::WriteReadFuture<'a> { |
| 198 | async move { | 207 | async move { |
