Module imxrt_hal::dma

source ·
Expand description

Direct memory access.

Use the dma APIs to perform memory operations without processor intervention. The API supports the following transfers:

  • peripheral to memory
  • memory to peripheral
  • memory to memory

Peripheral support depends on the peripheral. See your peripheral’s API for details. Methods that use DMA are typically prefixed with dma.

DMA transfers are modeled as futures. The examples below demonstrate a simple way to start a transfer. Since these are futures, you may use these futures in async code.

DMA channels

The API provides access to at least 16 DMA channels. If you’ve enabled an optional chip family feature, this number may change. See CHANNEL_COUNT for more information.

Visibility

Select items become visible when a chip family feature is enabled.

Example

Use channels() to access all DMA channels for your processor.

use imxrt_hal as hal;
use imxrt_ral as ral;

let mut ccm = unsafe { ral::ccm::CCM::instance() };
hal::ccm::clock_gate::dma().set(&mut ccm, hal::ccm::clock_gate::ON);

let mut channels = hal::dma::channels(
    unsafe { ral::dma::DMA::instance() },
    unsafe { ral::dmamux::DMAMUX::instance() },
);

// Selecting the 13th DMA channel for our examples...
let mut channel = channels[13].take()?;

Construct and poll a Memcpy to perform a memory-to-memory transfer.

let source = [4u32, 5, 6, 7];
let mut destination = [0u32; 4];

let memcpy = hal::dma::memcpy::memcpy(&source, &mut destination, &mut channel);
memcpy.await.ok()?;

For examples of using DMA with a peripheral, see the peripheral’s documentation.

Modules

Structs

  • A DMA driver.
  • A wrapper around a DMA error status value
  • The core DMA transfer future

Enums

Constants

Statics

  • The DMA driver.

Traits

  • Describes a transferrable DMA element; basically, an unsigned integer of any size.

Functions

Type Aliases