2 releases

0.1.1 Jan 12, 2023
0.1.0 Dec 30, 2022

#1920 in Embedded development

Download history 361/week @ 2024-06-15 503/week @ 2024-06-22 250/week @ 2024-06-29 47/week @ 2024-07-06 529/week @ 2024-07-13 118/week @ 2024-07-20 85/week @ 2024-07-27 347/week @ 2024-08-03 115/week @ 2024-08-10 1060/week @ 2024-08-17 85/week @ 2024-08-24 181/week @ 2024-08-31 217/week @ 2024-09-07 239/week @ 2024-09-14 407/week @ 2024-09-21 432/week @ 2024-09-28

1,316 downloads per month
Used in 8 crates (2 directly)

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

~630KB