Wire up peripheral DMA channels for SPI.
@@ -116,3 +116,39 @@ crate::pac::peripheral_pins!(
impl_pin!($inst, $pin, MisoPin, $af);
};
);
+
+macro_rules! impl_dma {
+ ($inst:ident, {dmamux: $dmamux:ident}, $signal:ident, $request:expr) => {
+ impl<T> sealed::$signal<peripherals::$inst> for T
+ where
+ T: crate::dma::MuxChannel<Mux = crate::dma::$dmamux>,
+ {
+ fn request(&self) -> dma::Request {
+ $request
+ }
+ }
+
+ impl<T> $signal<peripherals::$inst> for T where
+ T: crate::dma::MuxChannel<Mux = crate::dma::$dmamux>
+ {
+ }
+ };
+ ($inst:ident, {channel: $channel:ident}, $signal:ident, $request:expr) => {
+ impl sealed::$signal<peripherals::$inst> for peripherals::$channel {
+ fn request(&self) -> dma::Request {
+ $request
+ }
+ }
+
+ impl $signal<peripherals::$inst> for peripherals::$channel {}
+ };
+}
+
+crate::pac::peripheral_dma_channels! {
+ ($peri:ident, spi, $kind:ident, RX, $channel:tt, $request:expr) => {
+ impl_dma!($peri, $channel, RxDmaChannel, $request);
+ };
+ ($peri:ident, spi, $kind:ident, TX, $channel:tt, $request:expr) => {
+ impl_dma!($peri, $channel, TxDmaChannel, $request);
+ };
+}
