stm32/dma: add MuxChannel trait to distinguish DMAMUX1 and DMAMUX2 channels.

This commit is contained in:
Dario Nieuwenhuis
2021-07-17 07:49:49 +02:00
parent 54b5012c56
commit 3655048e0f
5 changed files with 37 additions and 14 deletions

View File

@ -19,17 +19,31 @@ pub(crate) unsafe fn configure_dmamux(
});
}
pub(crate) trait MuxChannel {
const DMAMUX_CH_NUM: u8;
const DMAMUX_REGS: pac::dmamux::Dmamux;
pub(crate) mod sealed {
use super::*;
pub trait MuxChannel {
const DMAMUX_CH_NUM: u8;
const DMAMUX_REGS: pac::dmamux::Dmamux;
}
}
pub struct DMAMUX1;
#[cfg(rcc_h7)]
pub struct DMAMUX2;
pub trait MuxChannel: sealed::MuxChannel + super::Channel {
type Mux;
}
pac::dma_channels! {
($channel_peri:ident, $dma_peri:ident, $version:ident, $channel_num:expr, {dmamux: $dmamux:ident, dmamux_channel: $dmamux_channel:expr}) => {
impl MuxChannel for peripherals::$channel_peri {
impl sealed::MuxChannel for peripherals::$channel_peri {
const DMAMUX_CH_NUM: u8 = $dmamux_channel;
const DMAMUX_REGS: pac::dmamux::Dmamux = pac::$dmamux;
}
impl MuxChannel for peripherals::$channel_peri {
type Mux = $dmamux;
}
};
}