From eee5dcb73e1a44395c07a0b7eed2d21f576c74af Mon Sep 17 00:00:00 2001 From: Dominic Fischer Date: Thu, 1 Aug 2024 22:04:47 +0100 Subject: [PATCH] Preserve previous blocking semantics --- esp-hal/src/spi/master.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/esp-hal/src/spi/master.rs b/esp-hal/src/spi/master.rs index 7bb7347ab61..2f3c400070f 100644 --- a/esp-hal/src/spi/master.rs +++ b/esp-hal/src/spi/master.rs @@ -1099,8 +1099,8 @@ pub mod dma { true } - pub fn wait(self) -> (SpiDma<'d, T, C, M, DmaMode>, Buf) { - while !self.is_done() {} + pub fn wait(mut self) -> (SpiDma<'d, T, C, M, DmaMode>, Buf) { + self.spi_dma.spi.flush().ok(); fence(Ordering::Acquire); (self.spi_dma, self.dma_buf) } @@ -1156,13 +1156,13 @@ pub mod dma { let result = unsafe { self.spi - .start_write_bytes_dma(buffer.first(), buffer.len(), &mut self.channel.tx) + .start_write_bytes_dma(buffer.first(), bytes_to_write, &mut self.channel.tx) }; if let Err(e) = result { return Err((e, self, buffer)); } - Ok(SpiDmaTransfer::new(self, buffer, true, false)) + Ok(SpiDmaTransfer::new(self, buffer, false, true)) } /// Perform a DMA read. @@ -1190,7 +1190,7 @@ pub mod dma { return Err((e, self, buffer)); } - Ok(SpiDmaTransfer::new(self, buffer, false, true)) + Ok(SpiDmaTransfer::new(self, buffer, true, false)) } /// Perform a DMA transfer