diff --git a/esp-hal/CHANGELOG.md b/esp-hal/CHANGELOG.md index ab9f122d9..22abde76b 100644 --- a/esp-hal/CHANGELOG.md +++ b/esp-hal/CHANGELOG.md @@ -99,6 +99,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `spi::master::Spi::{into_async, into_blocking}` are now correctly available on the typed driver, to. (#2674) - It is no longer possible to safely conjure `GpioPin` instances (#2688) - UART: Public API follows `C-WORD_ORDER` Rust API standard (`VerbObject` order) (#2851) +- `DmaRxStreamBuf` now correctly resets the descriptors the next time it's used (#2890) ### Removed diff --git a/esp-hal/src/dma/buffers.rs b/esp-hal/src/dma/buffers.rs index 78a6a68bf..2bf12111d 100644 --- a/esp-hal/src/dma/buffers.rs +++ b/esp-hal/src/dma/buffers.rs @@ -1137,13 +1137,6 @@ impl DmaRxStreamBuf { return Err(DmaBufError::InsufficientDescriptors); } - // Link up all the descriptors (but not in a circle). - let mut next = null_mut(); - for desc in descriptors.iter_mut().rev() { - desc.next = next; - next = desc; - } - let mut chunks = buffer.chunks_exact_mut(chunk_size); for (desc, chunk) in descriptors.iter_mut().zip(chunks.by_ref()) { desc.buffer = chunk.as_mut_ptr(); @@ -1176,7 +1169,12 @@ unsafe impl DmaRxBuffer for DmaRxStreamBuf { type View = DmaRxStreamBufView; fn prepare(&mut self) -> Preparation { - for desc in self.descriptors.iter_mut() { + // Link up all the descriptors (but not in a circle). + let mut next = null_mut(); + for desc in self.descriptors.iter_mut().rev() { + desc.next = next; + next = desc; + desc.reset_for_rx(); } Preparation {