Skip to content

Commit 1280509

Browse files
committed
spi: fix bindings to futures
1 parent d1b0e4d commit 1280509

File tree

1 file changed

+10
-17
lines changed

1 file changed

+10
-17
lines changed

src/spi/dma.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use core::{
2-
future::Future,
2+
future::{Future, IntoFuture},
33
ops::{Deref, DerefMut},
44
pin::Pin,
55
task::{Context, Poll},
@@ -208,8 +208,7 @@ where
208208
pub fn start_dma_read<'a>(
209209
&'a mut self,
210210
words: &'a mut [W],
211-
) -> Result<DmaTransfer<'a, impl DmaChannel + use<'a, SPI, W, MODE>>, Error>
212-
{
211+
) -> Result<DmaTransfer<'a, <MODE as Rx<W>>::CH>, Error> {
213212
let config = DmaConfig::new().with_request(SPI::rx_dma_request());
214213

215214
self.spi.inner.set_transfer_word_count(words.len() as u16);
@@ -229,7 +228,7 @@ where
229228
}
230229

231230
async fn read_dma(&mut self, words: &mut [W]) -> Result<(), Error> {
232-
let result = self.start_dma_read(words)?.to_async().await;
231+
let result = self.start_dma_read(words)?.await;
233232
self.finish_transfer_async(result).await
234233
}
235234
}
@@ -243,8 +242,7 @@ where
243242
pub fn start_dma_write<'a>(
244243
&'a mut self,
245244
words: &'a [W],
246-
) -> Result<DmaTransfer<'a, impl DmaChannel + use<'a, SPI, W, MODE>>, Error>
247-
{
245+
) -> Result<DmaTransfer<'a, <MODE as Tx<W>>::CH>, Error> {
248246
let config = DmaConfig::new().with_request(SPI::tx_dma_request());
249247

250248
self.inner.set_transfer_word_count(words.len() as u16);
@@ -263,28 +261,23 @@ where
263261
}
264262

265263
async fn write_dma(&mut self, words: &[W]) -> Result<(), Error> {
266-
let result = self.start_dma_write(words)?.to_async().await;
264+
let result = self.start_dma_write(words)?.await;
267265
self.finish_transfer_async(result).await
268266
}
269267
}
270268

271-
impl<SPI, MODE, W> SpiDma<SPI, MODE, W>
269+
impl<SPI, TX, RX, W> SpiDma<SPI, DmaDuplex<SPI, W, TX, RX>, W>
272270
where
273271
SPI: Instance,
274272
W: Word + DmaWord,
275-
MODE: Tx<W> + Rx<W>,
273+
TX: DmaChannel,
274+
RX: DmaChannel,
276275
{
277276
pub fn start_dma_duplex_transfer<'a>(
278277
&'a mut self,
279278
read: &'a mut [W],
280279
write: &'a [W],
281-
) -> Result<
282-
(
283-
DmaTransfer<'a, impl DmaChannel + use<'a, SPI, W, MODE>>,
284-
DmaTransfer<'a, impl DmaChannel + use<'a, SPI, W, MODE>>,
285-
),
286-
Error,
287-
> {
280+
) -> Result<(DmaTransfer<'a, TX>, DmaTransfer<'a, RX>), Error> {
288281
let tx_config = DmaConfig::new().with_request(SPI::tx_dma_request());
289282
let rx_config = DmaConfig::new().with_request(SPI::rx_dma_request());
290283

@@ -311,7 +304,7 @@ where
311304
write: &[W],
312305
) -> Result<(), Error> {
313306
let (tx, rx) = self.start_dma_duplex_transfer(read, write)?;
314-
let (tx, rx) = (tx.to_async(), rx.to_async());
307+
let (tx, rx) = (tx.into_future(), rx.into_future());
315308
let results = join!(tx, rx);
316309
let result = results.0.and(results.1);
317310

0 commit comments

Comments
 (0)