diff --git a/embassy-stm32/src/bdma/v1.rs b/embassy-stm32/src/bdma/v1.rs index 9a7cfae19..597cb0137 100644 --- a/embassy-stm32/src/bdma/v1.rs +++ b/embassy-stm32/src/bdma/v1.rs @@ -236,7 +236,6 @@ macro_rules! impl_dma_channel { #[cfg(not(dmamux))] impl WriteDma for crate::peripherals::$channel_peri where - Self: crate::dmamux::sealed::PeripheralChannel, T: 'static, { type WriteDmaFuture<'a> = impl Future; @@ -358,7 +357,7 @@ macro_rules! impl_dma_channel { pac::peripherals! { (bdma, DMA1) => { impl_dma!(DMA1, 0); - pac::dma_channels! { + pac::bdma_channels! { ($channel_peri:ident, DMA1, $channel_num:expr) => { impl_dma_channel!($channel_peri, DMA1, 0, $channel_num); }; @@ -366,7 +365,7 @@ pac::peripherals! { }; (bdma, DMA2) => { impl_dma!(DMA2, 1); - pac::dma_channels! { + pac::bdma_channels! { ($channel_peri:ident, DMA2, $channel_num:expr) => { impl_dma_channel!($channel_peri, DMA2, 1, $channel_num); }; @@ -375,8 +374,8 @@ pac::peripherals! { // Because H7cm changes the naming (bdma, BDMA) => { impl_dma!(BDMA, 0); - pac::dma_channels! { - ($channel_peri:ident, DMA1, $channel_num:expr) => { + pac::bdma_channels! { + ($channel_peri:ident, BDMA, $channel_num:expr) => { impl_dma_channel!($channel_peri, BDMA, 0, $channel_num); }; } @@ -421,7 +420,7 @@ pac::peripheral_dma_channels! { #[cfg(dmamux)] pac::peripherals! { (usart, $peri:ident) => { - pac::dma_channels! { + pac::bdma_channels! { ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { impl usart::TxDma for crate::peripherals::$channel_peri { } impl usart::sealed::TxDma for crate::peripherals::$channel_peri { } @@ -429,7 +428,7 @@ pac::peripherals! { } }; (uart, $peri:ident) => { - pac::dma_channels! { + pac::bdma_channels! { ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { impl usart::TxDma for crate::peripherals::$channel_peri { } impl usart::sealed::TxDma for crate::peripherals::$channel_peri { } diff --git a/embassy-stm32/src/dmamux/mod.rs b/embassy-stm32/src/dmamux/mod.rs index 93653b513..4ef04081f 100644 --- a/embassy-stm32/src/dmamux/mod.rs +++ b/embassy-stm32/src/dmamux/mod.rs @@ -11,7 +11,7 @@ use crate::interrupt; use crate::pac::bdma::{regs, vals}; use crate::pac; -use crate::pac::dma_channels; +use crate::pac::bdma_channels; use crate::pac::dma_requests; use crate::pac::interrupts; use crate::pac::peripheral_count; @@ -170,19 +170,26 @@ macro_rules! impl_dmamux { peripherals! { (bdma, DMA1) => { - dma_channels! { + bdma_channels! { ($channel_peri:ident, DMA1, $channel_num:expr) => { impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA1, 0); }; } }; (bdma, DMA2) => { - dma_channels! { + bdma_channels! { ($channel_peri:ident, DMA2, $channel_num:expr) => { impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1); }; } }; + (bdma, BDMA) => { + bdma_channels! { + ($channel_peri:ident, BDMA, $channel_num:expr) => { + impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1); + }; + } + }; (dmamux, DMAMUX1) => { impl_dmamux!(DMAMUX1); }; @@ -243,7 +250,7 @@ macro_rules! impl_usart_dma_requests { #[cfg(usart)] use crate::usart; -dma_channels! { +bdma_channels! { ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { impl_usart_dma_requests!($channel_peri, $dma_peri, $channel_num); }; diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs index 3f6a03fcc..640d746e1 100644 --- a/stm32-metapac-gen/src/lib.rs +++ b/stm32-metapac-gen/src/lib.rs @@ -252,6 +252,7 @@ pub fn gen(options: Options) { let mut peripheral_pins_table: Vec> = Vec::new(); let mut peripheral_rcc_table: Vec> = Vec::new(); let mut dma_channels_table: Vec> = Vec::new(); + let mut bdma_channels_table: Vec> = Vec::new(); let mut dma_requests_table: Vec> = Vec::new(); let mut peripheral_dma_channels_table: Vec> = Vec::new(); let mut peripheral_counts: HashMap = HashMap::new(); @@ -266,13 +267,7 @@ pub fn gen(options: Options) { let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; let gpio_stride = 0x400; - for (id, channel_info) in &core.dma_channels { - let mut row = Vec::new(); - row.push(id.clone()); - row.push(channel_info.dma.clone()); - row.push(channel_info.channel.to_string()); - dma_channels_table.push(row); - } + let number_suffix_re = Regex::new("^(.*?)[0-9]*$").unwrap(); @@ -449,6 +444,24 @@ pub fn gen(options: Options) { dev.peripherals.push(ir_peri); } + for (id, channel_info) in &core.dma_channels { + let mut row = Vec::new(); + let dma_peri = core.peripherals.get(&channel_info.dma); + row.push(id.clone()); + row.push(channel_info.dma.clone()); + row.push(channel_info.channel.to_string()); + if let Some(dma_peri) = dma_peri { + if let Some(ref block) = dma_peri.block { + let bi = BlockInfo::parse(block); + if bi.module == "bdma" { + bdma_channels_table.push(row); + } else { + dma_channels_table.push(row); + } + } + } + } + for (name, &num) in &core.interrupts { dev.interrupts.push(ir::Interrupt { name: name.clone(), @@ -495,6 +508,7 @@ pub fn gen(options: Options) { ); make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table); make_table(&mut extra, "dma_channels", &dma_channels_table); + make_table(&mut extra, "bdma_channels", &bdma_channels_table); make_table(&mut extra, "dma_requests", &dma_requests_table); make_peripheral_counts(&mut extra, &peripheral_counts);