From e0600ae4f855d7cc575a22dc5d7edc813ba72e05 Mon Sep 17 00:00:00 2001 From: liebman Date: Wed, 18 Sep 2024 15:35:50 -0700 Subject: [PATCH] default 4092 for esp32 & fmt --- esp-hal/src/dma/mod.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index e9769c5aeb..0e5d37034d 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -585,16 +585,12 @@ macro_rules! dma_circular_descriptors_chunk_size { #[macro_export] macro_rules! dma_tx_buffer { ($tx_size:expr, $tx_align:expr) => {{ - const TX_DESCRIPTOR_LEN: usize = $crate::dma::DmaTxBuf::compute_descriptor_count($tx_size, $tx_align); + const TX_DESCRIPTOR_LEN: usize = + $crate::dma::DmaTxBuf::compute_descriptor_count($tx_size, $tx_align); static mut TX_BUFFER: [u8; $tx_size] = [0u8; $tx_size]; static mut TX_DESCRIPTORS: [$crate::dma::DmaDescriptor; TX_DESCRIPTOR_LEN] = [$crate::dma::DmaDescriptor::EMPTY; TX_DESCRIPTOR_LEN]; - let (tx_buffer, tx_descriptors) = unsafe { - ( - &mut TX_BUFFER, - &mut TX_DESCRIPTORS, - ) - }; + let (tx_buffer, tx_descriptors) = unsafe { (&mut TX_BUFFER, &mut TX_DESCRIPTORS) }; $crate::dma::DmaTxBuf::new_with_block_size(tx_descriptors, tx_buffer, $tx_align) }}; @@ -2128,7 +2124,10 @@ impl DmaTxBuf { pub const fn compute_chunk_size(block_size: Option) -> usize { match block_size { Some(size) => 4096 - size as usize, - None => 4095, // TODO: does this need to be chip specific? + #[cfg(esp32)] + None => 4092, // esp32 requires 4 byte alignment + #[cfg(not(esp32))] + None => 4095, } }