Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Fixed

- Corrected the expected DMA descriptor counts (#622)
- DMA is supported for SPI3 on ESP32-S3 (#507)
- `change_bus_frequency` is now available on `SpiDma` (#529)
- Fixed a bug where a GPIO interrupt could erroneously fire again causing the next `await` on that pin to instantly return `Poll::Ok` (#537)
Expand Down
3 changes: 2 additions & 1 deletion esp-hal-common/src/dma/gdma.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ macro_rules! impl_channel {
impl [<ChannelCreator $num>] {
/// Configure the channel for use
///
/// Descriptors should be sized as (BUFFERSIZE / 4092) * 3
/// Descriptors should be sized as `((BUFFERSIZE + 4091) / 4092) * 3`. I.e., to
/// transfer buffers of size `1..=4092`, you need 3 descriptors.
pub fn configure<'a>(
self,
burst_mode: bool,
Expand Down
7 changes: 4 additions & 3 deletions esp-hal-common/src/dma/mod.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Direct Memory Access Commons
//!
//! Descriptors should be sized as (BUFFERSIZE / 4092) * 3
//! Descriptors should be sized as `((BUFFERSIZE + 4091) / 4092) * 3`. I.e., to
//! transfer buffers of size `1..=4092`, you need 3 descriptors.

use core::{marker::PhantomData, sync::atomic::compiler_fence};

Expand Down Expand Up @@ -347,7 +348,7 @@ where
return Err(DmaError::InvalidDescriptorSize);
}

if self.descriptors.len() / 3 < len / CHUNK_SIZE {
if self.descriptors.len() / 3 < (len + CHUNK_SIZE - 1) / CHUNK_SIZE {
return Err(DmaError::OutOfDescriptors);
}

Expand Down Expand Up @@ -647,7 +648,7 @@ where
return Err(DmaError::InvalidDescriptorSize);
}

if self.descriptors.len() / 3 < len / CHUNK_SIZE {
if self.descriptors.len() / 3 < (len + CHUNK_SIZE - 1) / CHUNK_SIZE {
return Err(DmaError::OutOfDescriptors);
}

Expand Down