Skip to content

Commit 3a5709e

Browse files
committed
spi: use futures-rs AtomicWaker, and use join! macro to combine tx, rx futures.
1 parent 10db576 commit 3a5709e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/spi/dma.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,10 @@ use core::{
55
task::{Context, Poll},
66
};
77

8-
use atomic_waker::AtomicWaker;
98
use embedded_hal::spi::ErrorType;
109
use embedded_hal_async::spi::SpiBus;
10+
use futures_util::join;
11+
use futures_util::task::AtomicWaker;
1112

1213
use crate::gpdma::{
1314
config::DmaConfig,
@@ -104,9 +105,7 @@ where
104105
result: Result<(), DmaError>,
105106
) -> Result<(), Error> {
106107
let result = match result {
107-
Ok(_) => {
108-
SpiDmaFuture::new(self).await
109-
}
108+
Ok(_) => SpiDmaFuture::new(self).await,
110109
Err(error) => {
111110
self.abort_transaction();
112111
Err(Error::DmaError(error))
@@ -319,7 +318,8 @@ where
319318
) -> Result<(), Error> {
320319
let (tx, rx) = self.start_dma_duplex_transfer(read, write)?;
321320
let (tx, rx) = (tx.to_async(), rx.to_async());
322-
let result = tx.await.and(rx.await);
321+
let results = join!(tx, rx);
322+
let result = results.0.and(results.1);
323323

324324
self.finish_transfer_async(result).await
325325
}

0 commit comments

Comments
 (0)