2 releases
0.1.1 | Jan 12, 2023 |
---|---|
0.1.0 | Dec 30, 2022 |
#1920 in Embedded development
1,316 downloads per month
Used in 8 crates
(2 directly)
71KB
953 lines
imxrt-dma
DMA driver for i.MX RT microcontrollers.
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
Channel
s. - 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
- the location of the DMA controller registers.
- the location of the DMAMUX registers.
- 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 Channel
s.
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