From 01c70c2e5884c92945007db71b7c9fb77305f762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1niel=20Buga?= Date: Mon, 2 Dec 2024 14:52:55 +0100 Subject: [PATCH] Add missing docs --- esp-hal/src/dma/buffers.rs | 1 + esp-hal/src/dma/mod.rs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/esp-hal/src/dma/buffers.rs b/esp-hal/src/dma/buffers.rs index dec9a4e4ff3..a42eaaf2baf 100644 --- a/esp-hal/src/dma/buffers.rs +++ b/esp-hal/src/dma/buffers.rs @@ -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 { diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index d454fa8f87b..2862bf53b4a 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -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); } @@ -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); }