aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-20 09:52:03 -0400
committerBob McWhirter <[email protected]>2021-07-23 13:22:39 -0400
commitd5ed5c3ef3d3bc2ad6f22a1f67dfd8021c259621 (patch)
treeda8fa716d76794e1c16f69ee37d204c3023ae821
parent22901938ce4199c6545906226abecbe174a2e553 (diff)
Split up the nRF impls for SPI traits.
-rw-r--r--embassy-nrf/src/spim.rs23
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;
9use embassy::util::{AtomicWaker, Unborrow}; 9use embassy::util::{AtomicWaker, Unborrow};
10use embassy_extras::unborrow; 10use embassy_extras::unborrow;
11use futures::future::poll_fn; 11use futures::future::poll_fn;
12use traits::spi::FullDuplex; 12use traits::spi::{ Spi, Read, Write, FullDuplex};
13 13
14use crate::gpio; 14use crate::gpio;
15use crate::gpio::sealed::Pin as _; 15use crate::gpio::sealed::Pin as _;
@@ -177,22 +177,31 @@ impl<'d, T: Instance> Drop for Spim<'d, T> {
177 } 177 }
178} 178}
179 179
180impl<'d, T: Instance> FullDuplex<u8> for Spim<'d, T> { 180impl<'d, T: Instance> Spi<u8> for Spim<'d, T> {
181 type Error = Error; 181 type Error = Error;
182}
182 183
184impl<'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
193impl<'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
202impl<'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 {