unstable
only.Expand description
§Direct Memory Access (DMA)
§Overview
The DMA driver provides an interface to efficiently transfer data between different memory regions and peripherals within the ESP microcontroller without involving the CPU. The DMA controller is responsible for managing these data transfers.
Notice, that this module is a common version of the DMA driver, ESP32
and
ESP32-S2
are using older PDMA
controller, whenever other chips are using
newer GDMA
controller.
§Examples
§Initialize and utilize DMA controller in SPI
let dma_channel = peripherals.DMA_CH0;
let sclk = peripherals.GPIO0;
let miso = peripherals.GPIO2;
let mosi = peripherals.GPIO4;
let cs = peripherals.GPIO5;
let mut spi = Spi::new(
peripherals.SPI2,
Config::default().with_frequency(Rate::from_khz(100)).
with_mode(Mode::_0) )?
.with_sck(sclk)
.with_mosi(mosi)
.with_miso(miso)
.with_cs(cs)
.with_dma(dma_channel);
⚠️ Note: Descriptors should be sized as (max_transfer_size + CHUNK_SIZE - 1) / CHUNK_SIZE
.
I.e., to transfer buffers of size 1..=CHUNK_SIZE
, you need 1 descriptor.
⚠️ Note: For chips that support DMA to/from PSRAM (ESP32-S3) DMA transfers to/from PSRAM have extra alignment requirements. The address and size of the buffer pointed to by each descriptor must be a multiple of the cache line (block) size. This is 32 bytes on ESP32-S3.
For convenience you can use the crate::dma_buffers macro.
Structs§
- AnyGdma
Channel - An arbitrary GDMA channel
- AnyGdma
RxChannel - An arbitrary GDMA RX channel
- AnyGdma
TxChannel - An arbitrary GDMA TX channel
- BufView
- An in-progress view into DmaRxBuf/DmaTxBuf.
- Burst
Config - Burst transfer configuration.
- Channel
- DMA Channel
- DmaDescriptor
- A DMA transfer descriptor.
- DmaDescriptor
Flags - DMA descriptor flags.
- DmaLoop
Buf - DMA Loop Buffer
- DmaRx
Buf - DMA receive buffer
- DmaRx
Stream Buf - DMA Streaming Receive Buffer.
- DmaRx
Stream BufView - A view into a DmaRxStreamBuf
- DmaRx
TxBuf - DMA transmit and receive buffer.
- DmaTransfer
Rx - DMA transaction for RX only transfers
- DmaTransfer
RxCircular - DMA transaction for RX only circular transfers
- DmaTransfer
RxTx - DMA transaction for TX+RX transfers
- DmaTransfer
Tx - DMA transaction for TX only transfers
- DmaTransfer
TxCircular - DMA transaction for TX only circular transfers
- DmaTx
Buf - DMA transmit buffer
- Empty
Buf - An empty buffer that can be used when you don’t need to transfer any data.
- Mem2Mem
- DMA Memory to Memory pseudo-Peripheral
- Mem2
MemRx - The RX half of Mem2Mem.
- Mem2
MemRx Transfer - Represents an ongoing (or potentially finished) DMA Memory-to-Memory RX transfer.
- Mem2
MemTx - The TX half of Mem2Mem.
- Mem2
MemTx Transfer - Represents an ongoing (or potentially finished) DMA Memory-to-Memory TX transfer.
- Preparation
- Holds all the information needed to configure a DMA channel for a transfer.
- Simple
Mem2 Mem - A simple and easy to use wrapper around SimpleMem2Mem. More complex memory to memory transfers should use Mem2Mem directly.
- Simple
Mem2 MemTransfer - Represents an ongoing (or potentially finished) DMA Memory-to-Memory transfer.
Enums§
- DmaAlignment
Error - DMA buffer alignment errors.
- DmaBuf
Error - Error returned from Dma[Rx|Tx|RxTx]Buf operations.
- DmaError
- DMA Errors
- DmaExt
MemBK Size - Block size for transfers to/from PSRAM
- DmaInterrupt
- Kinds of interrupt to listen to.
- DmaPriority
- DMA Priorities
- DmaRx
Interrupt - Types of interrupts emitted by the RX channel.
- DmaTx
Interrupt - Types of interrupts emitted by the TX channel.
- External
Burst Config - Burst size used when transferring to and from external memory.
- Internal
Burst Config - Internal memory access burst mode.
- Owner
- The owner bit of a DMA descriptor.
- Transfer
Direction - The direction of the DMA transfer.
Constants§
- CHUNK_
SIZE - The default chunk size used for DMA transfers.
Traits§
- DmaChannel
- A description of a DMA Channel.
- DmaChannel
For - Trait implemented for DMA channels that are compatible with a particular peripheral.
- DmaRx
Buffer - DmaRxBuffer is a DMA descriptor + memory combo that can be used for receiving data from a peripheral’s FIFO to a DMA channel.
- DmaRx
Channel - Stability
- DmaTx
Buffer - DmaTxBuffer is a DMA descriptor + memory combo that can be used for transmitting data from a DMA channel to a peripheral’s FIFO.
- DmaTx
Channel - Stability
- Read
Buffer - Trait for buffers that can be given to DMA for reading.
- RxChannel
For - Trait implemented for the RX half of split DMA channels that are compatible with a particular peripheral. Accepts complete DMA channels or split halves.
- TxChannel
For - Trait implemented for the TX half of split DMA channels that are compatible with a particular peripheral. Accepts complete DMA channels or split halves.
- Write
Buffer - Trait for buffers that can be given to DMA for writing.
Functions§
- descriptor_
count - Computes the number of descriptors required for a given buffer size with a given chunk size.
Type Aliases§
- Peripheral
DmaChannel - Helper type to get the DMA (Rx and Tx) channel for a peripheral.
- Peripheral
RxChannel - Helper type to get the DMA Rx channel for a peripheral.
- Peripheral
TxChannel - Helper type to get the DMA Tx channel for a peripheral.