Skip to content

Commit

Permalink
Add missing docs
Browse files Browse the repository at this point in the history
  • Loading branch information
bugadani committed Dec 3, 2024
1 parent 0f5a9f4 commit 01c70c2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions esp-hal/src/dma/buffers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum DmaBufError {
InvalidChunkSize,
}

/// DMA buffer alignment errors.
#[derive(Debug, PartialEq, Eq, Hash, Clone, Copy)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum DmaAlignmentError {
Expand Down
14 changes: 10 additions & 4 deletions esp-hal/src/dma/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1966,8 +1966,11 @@ where
if crate::soc::addr_in_range(des.buffer as usize, psram_range.clone()) {
uses_psram = true;
// both the size and address of the buffer must be aligned
if des.buffer as usize % alignment != 0 && des.size() % alignment != 0 {
return Err(DmaError::InvalidAlignment);
if des.buffer as usize % alignment != 0 {
return Err(DmaError::InvalidAlignment(DmaAlignmentError::Address));
}
if des.size() % alignment != 0 {
return Err(DmaError::InvalidAlignment(DmaAlignmentError::Size));
}
crate::soc::cache_invalidate_addr(des.buffer as u32, des.size() as u32);
}
Expand Down Expand Up @@ -2255,8 +2258,11 @@ where
if crate::soc::addr_in_range(des.buffer as usize, psram_range.clone()) {
uses_psram = true;
// both the size and address of the buffer must be aligned
if des.buffer as usize % alignment != 0 && des.size() % alignment != 0 {
return Err(DmaError::InvalidAlignment);
if des.buffer as usize % alignment != 0 {
return Err(DmaError::InvalidAlignment(DmaAlignmentError::Address));
}
if des.size() % alignment != 0 {
return Err(DmaError::InvalidAlignment(DmaAlignmentError::Size));
}
crate::soc::cache_writeback_addr(des.buffer as u32, des.size() as u32);
}
Expand Down

0 comments on commit 01c70c2

Please sign in to comment.