mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 04:10:25 +00:00
50 lines
1.1 KiB
Rust
50 lines
1.1 KiB
Rust
#![macro_use]
|
|
|
|
use crate::pac;
|
|
|
|
pub(crate) struct DmamuxInfo {
|
|
pub(crate) mux: pac::dmamux::Dmamux,
|
|
pub(crate) num: usize,
|
|
}
|
|
|
|
pub(crate) fn configure_dmamux(info: &DmamuxInfo, request: u8) {
|
|
let ch_mux_regs = info.mux.ccr(info.num);
|
|
ch_mux_regs.write(|reg| {
|
|
reg.set_nbreq(0);
|
|
reg.set_dmareq_id(request);
|
|
});
|
|
|
|
ch_mux_regs.modify(|reg| {
|
|
reg.set_ege(true);
|
|
});
|
|
}
|
|
|
|
pub(crate) trait SealedMuxChannel {}
|
|
|
|
/// DMAMUX1 instance.
|
|
pub struct DMAMUX1;
|
|
/// DMAMUX2 instance.
|
|
#[cfg(stm32h7)]
|
|
pub struct DMAMUX2;
|
|
|
|
/// DMAMUX channel trait.
|
|
#[allow(private_bounds)]
|
|
pub trait MuxChannel: SealedMuxChannel {
|
|
/// DMAMUX instance this channel is on.
|
|
type Mux;
|
|
}
|
|
|
|
macro_rules! dmamux_channel_impl {
|
|
($channel_peri:ident, $dmamux:ident) => {
|
|
impl crate::dma::SealedMuxChannel for crate::peripherals::$channel_peri {}
|
|
impl crate::dma::MuxChannel for crate::peripherals::$channel_peri {
|
|
type Mux = crate::dma::$dmamux;
|
|
}
|
|
};
|
|
}
|
|
|
|
/// safety: must be called only once
|
|
pub(crate) unsafe fn init(_cs: critical_section::CriticalSection) {
|
|
crate::_generated::init_dmamux();
|
|
}
|