Function imxrt_hal::dma::peripheral::write
source · pub fn write<D, E, 'a>(
channel: &'a mut Channel,
buffer: &'a [E],
destination: &'a mut D
) -> Write<'a, D, E> ⓘwhere
D: Destination<E>,
E: Element,
Expand description
Use a DMA channel to send a buffer
of data to the destination peripheral.
Consider using a DMA interrupt handler that calls on_interrupt()
to wake the executor when the transfer completes. Otherwise, poll the future.
Example
Send five bytes to a LPUART device. Wake the executor when the transfer completes.
use imxrt_dma::{peripheral, channel::Channel};
// #[cortex_m_rt::interrupt]
fn DMA7() {
// Safety: DMA channel 7 valid and used by a future.
unsafe { DMA.on_interrupt(7) };
}
let mut lpuart = // A LPUART peripheral
let mut channel_7: Channel = // DMA channel 7
channel_7.set_interrupt_on_completion(true);
// TODO unmask interrupts in NVIC!
let buffer = [4u8, 5, 6, 7, 8];
peripheral::write(
&mut channel_7,
&buffer,
&mut lpuart,
).await?;