pub struct Dma<const CHANNELS: usize> { /* private fields */ }Expand description
A DMA driver.
This DMA driver manages the DMA controller and the multiplexer. It’s configured with pointers to both peripherals.
Dma allocates Channels. Channel provides
the interface for scheduling transfers.
Implementations§
Source§impl<const CHANNELS: usize> Dma<CHANNELS>
impl<const CHANNELS: usize> Dma<CHANNELS>
Sourcepub unsafe fn channel(&'static self, index: usize) -> Channel
pub unsafe fn channel(&'static self, index: usize) -> Channel
Creates the DMA channel described by index.
§Safety
This will create a handle that may alias global, mutable state. You should only create one channel per index. If there are multiple channels for the same index, you’re responsible for ensuring synchronized access.
§Panics
Panics if index is greater than or equal to the maximum number of channels.
Source§impl<const CHANNELS: usize> Dma<CHANNELS>
impl<const CHANNELS: usize> Dma<CHANNELS>
Sourcepub unsafe fn on_interrupt(&'static self, channel: usize)
pub unsafe fn on_interrupt(&'static self, channel: usize)
Handle a DMA interrupt
Checks the interrupt status for the channel identified by channel.
If the channel completed its transfer, on_interrupt wakes the channel’s
waker.
Consider calling on_interrupt in a DMA channel’s interrupt handler:
use imxrt_dma::Dma;
static DMA: Dma<32> = // Handle to DMA driver.
// #[cortex_m_rt::interrupt]
fn DMA7_DMA23() {
// Safety: only checking channels 7 and 23, which
// are both valid on an i.MX RT 1060 chip.
unsafe {
DMA.on_interrupt(7);
DMA.on_interrupt(23);
}
}§Safety
This should only be used when the associated DMA channel is exclusively referenced
by a DMA transfer future. Caller must ensure that on_interrupt is called in
the correct interrupt handler.
§Panics
Panics if channel is greater than or equal to the maximum number of channels.
Source§impl<const CHANNELS: usize> Dma<CHANNELS>
impl<const CHANNELS: usize> Dma<CHANNELS>
Sourcepub const unsafe fn new(controller: *const (), multiplexer: *const ()) -> Self
pub const unsafe fn new(controller: *const (), multiplexer: *const ()) -> Self
Create the DMA driver.
Note that this can evaluate at compile time. Consider using this to
expose a Dma through your higher-level API that you can use to
allocate DMA channels.
CHANNELS specifies the total number of channels supported by the DMA
controller. It’s referenced when allocating channels.
§Safety
Caller must make sure that controller is a pointer to the start of the
DMA controller register block. Caller must also make sure that
multiplexer is a pointer to the start of the DMA multiplexer. Both
pointers must be valid for your MCU.
An incorrect CHANNELS value prevents proper bounds checking when
allocating channels. This may result in DMA channels that point to
invalid memory.