diff --git a/esp-hal/src/dma/mod.rs b/esp-hal/src/dma/mod.rs index 99cc1ebcdc3..c9621c61b13 100644 --- a/esp-hal/src/dma/mod.rs +++ b/esp-hal/src/dma/mod.rs @@ -381,29 +381,45 @@ pub enum DmaPriority { #[cfg_attr(feature = "defmt", derive(defmt::Format))] #[doc(hidden)] pub enum DmaPeripheral { - Spi2 = 0, + Spi2 = 0, #[cfg(any(pdma, esp32s3))] - Spi3 = 1, + Spi3 = 1, + #[cfg(any(esp32c3, esp32c6, esp32h2))] + Mem2Mem1 = 1, #[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))] - Uhci0 = 2, + Uhci0 = 2, #[cfg(any(esp32, esp32s2, esp32c3, esp32c6, esp32h2, esp32s3))] - I2s0 = 3, + I2s0 = 3, #[cfg(any(esp32, esp32s3))] - I2s1 = 4, + I2s1 = 4, + #[cfg(any(esp32c3, esp32c6, esp32h2))] + Mem2Mem4 = 4, #[cfg(esp32s3)] - LcdCam = 5, + LcdCam = 5, + #[cfg(any(esp32c3, esp32c6, esp32h2))] + Mem2Mem5 = 5, #[cfg(not(esp32c2))] - Aes = 6, + Aes = 6, #[cfg(gdma)] - Sha = 7, + Sha = 7, #[cfg(any(esp32c3, esp32c6, esp32h2, esp32s3))] - Adc = 8, + Adc = 8, #[cfg(esp32s3)] - Rmt = 9, + Rmt = 9, #[cfg(parl_io)] - ParlIo = 9, - #[cfg(gdma)] - Mem2Mem = 10, // taken from esp32c6 TRM + ParlIo = 9, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem10 = 10, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem11 = 11, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem12 = 12, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem13 = 13, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem14 = 14, + #[cfg(any(esp32c6, esp32h2))] + Mem2Mem15 = 15, } #[derive(PartialEq, PartialOrd)] diff --git a/examples/src/bin/dma_mem2mem.rs b/examples/src/bin/dma_mem2mem.rs index 0f3692a64b5..d768d95c6ad 100644 --- a/examples/src/bin/dma_mem2mem.rs +++ b/examples/src/bin/dma_mem2mem.rs @@ -2,7 +2,7 @@ //! //% FEATURES: esp-hal/log -//% CHIPS: esp32s3 +//% CHIPS: esp32s3 esp32c3 esp32c6 esp32h2 #![no_std] #![no_main] @@ -19,6 +19,12 @@ use esp_hal::{ }; use log::{error, info}; +const DATA_SIZE: usize = 1024 * 100; +#[cfg(feature = "esp32s3")] +const DMA_PERIPHERAL: DmaPeripheral = DmaPeripheral::Adc; +#[cfg(not(feature = "esp32s3"))] +const DMA_PERIPHERAL: DmaPeripheral = DmaPeripheral::Mem2Mem1; + #[entry] fn main() -> ! { esp_println::logger::init_logger(log::LevelFilter::Info); @@ -28,14 +34,13 @@ fn main() -> ! { let clocks = ClockControl::boot_defaults(system.clock_control).freeze(); let delay = Delay::new(&clocks); - const DATA_SIZE: usize = 1024 * 100; let (tx_buffer, tx_descriptors, mut rx_buffer, rx_descriptors) = dma_buffers!(DATA_SIZE); let dma = Dma::new(peripherals.DMA); let channel = dma.channel0.configure(false, DmaPriority::Priority0); let mut mem2mem = - unsafe { Mem2Mem::new(channel, DmaPeripheral::Adc, tx_descriptors, rx_descriptors) }; + unsafe { Mem2Mem::new(channel, DMA_PERIPHERAL, tx_descriptors, rx_descriptors) }; for i in 0..core::mem::size_of_val(tx_buffer) { tx_buffer[i] = (i % 256) as u8;