pub trait DmaChannelFor<P: DmaEligible>: DmaChannel + DmaChannelConvert<PeripheralDmaChannel<P>> { }
Available on crate feature
unstable
only.Expand description
Trait implemented for DMA channels that are compatible with a particular peripheral.
You can use this in places where a peripheral driver would expect a
DmaChannel
implementation.
§Example
The following example demonstrates how this trait can be used to only accept types compatible with a specific peripheral.
use esp_hal::{
Blocking,
dma::DmaChannelFor,
spi::master::{AnySpi, Config, Instance as SpiInstance, Spi, SpiDma},
};
fn configures_spi_dma<'d>(
spi: Spi<'d, Blocking>,
channel: impl DmaChannelFor<AnySpi<'d>>,
) -> SpiDma<'d, Blocking> {
spi.with_dma(channel)
}
let dma_channel = peripherals.DMA_CH0;
let spi = Spi::new(peripherals.SPI2, Config::default())?;
let spi_dma = configures_spi_dma(spi, dma_channel);
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.