#nxp #imxrt

no-std imxrt-dma

DMA driver for i.MX RT processors

2 releases

0.1.1 Jan 12, 2023
0.1.0 Dec 30, 2022

#2097 in Embedded development

Download history 393/week @ 2023-12-15 272/week @ 2023-12-22 35/week @ 2023-12-29 208/week @ 2024-01-05 127/week @ 2024-01-12 157/week @ 2024-01-19 78/week @ 2024-01-26 115/week @ 2024-02-02 50/week @ 2024-02-09 76/week @ 2024-02-16 191/week @ 2024-02-23 110/week @ 2024-03-01 170/week @ 2024-03-08 118/week @ 2024-03-15 74/week @ 2024-03-22 86/week @ 2024-03-29

459 downloads per month
Used in 8 crates (via imxrt-hal)

MIT/Apache

71KB
953 lines

imxrt-dma

DMA driver for i.MX RT microcontrollers.

API Docs (main branch)

See the API docs for more information. To try examples on hardware, see the examples directory.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

Direct Memory Access (DMA) driver for i.MX RT processors.

imxrt-dma provides

  • an unsafe API for defining and scheduling transfers with DMA Channels.
  • safe DMA futures for memcpy, peripheral-to-memory, and memory-to-peripheral transfers.

This DMA driver may be re-exported from a hardware abstraction layer (HAL). If it is, you should use the safer APIs provided by your HAL.

Getting started

To allocate a Dma driver, you'll need to know

  1. the location of the DMA controller registers.
  2. the location of the DMAMUX registers.
  3. the number of DMA channels supported by your chip.

These parameters depend on the i.MX RT chip you're targeting. If you're already using imxrt-ral, consider using the DMA and DMAMUX constants for the addresses. You're always responsible for configuring the number of DMA channels.

With those three parameters, assign a Dma to a static. Then, use that object to create DMA Channels.

use imxrt_dma::Dma;

// Safety: addresses and channel count are valid for this target.
static DMA: Dma<32> = unsafe { Dma::new(DMA_PTR, DMAMUX_PTR) };

// Safety: we only allocate one DMA channel 7 object.
let mut channel = unsafe { DMA.channel(7) };

Once you have a channel, you can use the higher-level DMA APIs, like

  • memcpy for memory copies.
  • write to transmit data from memory to a peripheral.
  • read to receive data from a peripheral.
  • full_duplex to read / write with a peripheral using a single buffer.

Peripheral transfers depends on a peripheral's DMA support. These are signaled through various peripheral traits.

For a lower-level API, use the channel objects and helper functions.

License

Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~615KB