From 4ed1d6e96804482ee2cfc4414ea3b0cf51916e3b Mon Sep 17 00:00:00 2001 From: liebman Date: Sun, 25 Aug 2024 09:12:09 -0700 Subject: [PATCH 1/2] parl_io: use ReadBuffer/WriteBuffer for async DMA --- esp-hal/src/parl_io.rs | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/esp-hal/src/parl_io.rs b/esp-hal/src/parl_io.rs index 72cfdd3ddc8..2d99381066a 100644 --- a/esp-hal/src/parl_io.rs +++ b/esp-hal/src/parl_io.rs @@ -1669,7 +1669,7 @@ pub mod asynch { use super::{private::Instance, Error, ParlIoRx, ParlIoTx, MAX_DMA_SIZE}; use crate::{ - dma::{asynch::DmaRxFuture, DmaChannel, ParlIoPeripheral}, + dma::{asynch::DmaRxFuture, DmaChannel, ParlIoPeripheral, ReadBuffer, WriteBuffer}, peripherals::Interrupt, }; @@ -1731,8 +1731,11 @@ pub mod asynch { /// Perform a DMA write. /// /// The maximum amount of data to be sent is 32736 bytes. - pub async fn write_dma_async(&mut self, words: &mut [u8]) -> Result<(), Error> { - let (ptr, len) = (words.as_ptr(), words.len()); + pub async fn write_dma_async<'t, TXBUF>(&mut self, words: &'t TXBUF) -> Result<(), Error> + where + TXBUF: ReadBuffer, + { + let (ptr, len) = unsafe { words.read_buffer() }; if len > MAX_DMA_SIZE { return Err(Error::MaxDmaTransferSizeExceeded); @@ -1754,8 +1757,14 @@ pub mod asynch { /// Perform a DMA write. /// /// The maximum amount of data to be sent is 32736 bytes. - pub async fn read_dma_async(&mut self, words: &mut [u8]) -> Result<(), Error> { - let (ptr, len) = (words.as_mut_ptr(), words.len()); + pub async fn read_dma_async<'t, RXBUF>( + &'t mut self, + words: &'t mut RXBUF, + ) -> Result<(), Error> + where + RXBUF: WriteBuffer, + { + let (ptr, len) = unsafe { words.write_buffer() }; if !Instance::is_suc_eof_generated_externally() && len > MAX_DMA_SIZE { return Err(Error::MaxDmaTransferSizeExceeded); From 258b56b7175b26c3a3f4139ff1f03941ba7fca82 Mon Sep 17 00:00:00 2001 From: liebman Date: Sun, 25 Aug 2024 09:23:50 -0700 Subject: [PATCH 2/2] CHANGELOG --- esp-hal/CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index 61c074ebf64..319fdca4011 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -29,6 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - DMA buffers now don't require a static lifetime. Make sure to never `mem::forget` an in-progress DMA transfer (consider using `#[deny(clippy::mem_forget)]`) (#1837) - SHA driver now use specific structs for the hashing algorithm instead of a parameter. (#1908) - Remove `fn free(self)` in HMAC which goes against esp-hal API guidelines (#1972) +- PARL_IO use ReadBuffer and WriteBuffer for Async DMA (#1996) ### Fixed