Correct DMA descriptor docs, math (#622)

This commit is contained in:
Dániel Buga 2023-06-26 17:39:37 +02:00 committed by GitHub
parent 3c4dc8df6a
commit 7f80b23c9d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 4 deletions

View File

@ -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)

View File

@ -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,

View File

@ -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};
@ -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);
}
@ -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);
}