diff options
| author | Bob McWhirter <[email protected]> | 2021-07-12 10:32:57 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-07-13 10:09:35 -0400 |
| commit | 97ad434d387b1f893aa3091a76d3b350d0dddf2e (patch) | |
| tree | 64fdcb36997e668c6b620ec884efa4453164cfcb | |
| parent | a24a7e9fece1768e359621780c0dfdf56ee46805 (diff) | |
Twizzle our DMA vs BDMA channels.
| -rw-r--r-- | embassy-stm32/src/bdma/v1.rs | 13 | ||||
| -rw-r--r-- | embassy-stm32/src/dmamux/mod.rs | 15 | ||||
| -rw-r--r-- | stm32-metapac-gen/src/lib.rs | 28 |
3 files changed, 38 insertions, 18 deletions
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 { | |||
| 236 | #[cfg(not(dmamux))] | 236 | #[cfg(not(dmamux))] |
| 237 | impl<T> WriteDma<T> for crate::peripherals::$channel_peri | 237 | impl<T> WriteDma<T> for crate::peripherals::$channel_peri |
| 238 | where | 238 | where |
| 239 | Self: crate::dmamux::sealed::PeripheralChannel<T, crate::dmamux::M2P>, | ||
| 240 | T: 'static, | 239 | T: 'static, |
| 241 | { | 240 | { |
| 242 | type WriteDmaFuture<'a> = impl Future<Output = ()>; | 241 | type WriteDmaFuture<'a> = impl Future<Output = ()>; |
| @@ -358,7 +357,7 @@ macro_rules! impl_dma_channel { | |||
| 358 | pac::peripherals! { | 357 | pac::peripherals! { |
| 359 | (bdma, DMA1) => { | 358 | (bdma, DMA1) => { |
| 360 | impl_dma!(DMA1, 0); | 359 | impl_dma!(DMA1, 0); |
| 361 | pac::dma_channels! { | 360 | pac::bdma_channels! { |
| 362 | ($channel_peri:ident, DMA1, $channel_num:expr) => { | 361 | ($channel_peri:ident, DMA1, $channel_num:expr) => { |
| 363 | impl_dma_channel!($channel_peri, DMA1, 0, $channel_num); | 362 | impl_dma_channel!($channel_peri, DMA1, 0, $channel_num); |
| 364 | }; | 363 | }; |
| @@ -366,7 +365,7 @@ pac::peripherals! { | |||
| 366 | }; | 365 | }; |
| 367 | (bdma, DMA2) => { | 366 | (bdma, DMA2) => { |
| 368 | impl_dma!(DMA2, 1); | 367 | impl_dma!(DMA2, 1); |
| 369 | pac::dma_channels! { | 368 | pac::bdma_channels! { |
| 370 | ($channel_peri:ident, DMA2, $channel_num:expr) => { | 369 | ($channel_peri:ident, DMA2, $channel_num:expr) => { |
| 371 | impl_dma_channel!($channel_peri, DMA2, 1, $channel_num); | 370 | impl_dma_channel!($channel_peri, DMA2, 1, $channel_num); |
| 372 | }; | 371 | }; |
| @@ -375,8 +374,8 @@ pac::peripherals! { | |||
| 375 | // Because H7cm changes the naming | 374 | // Because H7cm changes the naming |
| 376 | (bdma, BDMA) => { | 375 | (bdma, BDMA) => { |
| 377 | impl_dma!(BDMA, 0); | 376 | impl_dma!(BDMA, 0); |
| 378 | pac::dma_channels! { | 377 | pac::bdma_channels! { |
| 379 | ($channel_peri:ident, DMA1, $channel_num:expr) => { | 378 | ($channel_peri:ident, BDMA, $channel_num:expr) => { |
| 380 | impl_dma_channel!($channel_peri, BDMA, 0, $channel_num); | 379 | impl_dma_channel!($channel_peri, BDMA, 0, $channel_num); |
| 381 | }; | 380 | }; |
| 382 | } | 381 | } |
| @@ -421,7 +420,7 @@ pac::peripheral_dma_channels! { | |||
| 421 | #[cfg(dmamux)] | 420 | #[cfg(dmamux)] |
| 422 | pac::peripherals! { | 421 | pac::peripherals! { |
| 423 | (usart, $peri:ident) => { | 422 | (usart, $peri:ident) => { |
| 424 | pac::dma_channels! { | 423 | pac::bdma_channels! { |
| 425 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { | 424 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { |
| 426 | impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } | 425 | impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } |
| 427 | impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } | 426 | impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } |
| @@ -429,7 +428,7 @@ pac::peripherals! { | |||
| 429 | } | 428 | } |
| 430 | }; | 429 | }; |
| 431 | (uart, $peri:ident) => { | 430 | (uart, $peri:ident) => { |
| 432 | pac::dma_channels! { | 431 | pac::bdma_channels! { |
| 433 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { | 432 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { |
| 434 | impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } | 433 | impl usart::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } |
| 435 | impl usart::sealed::TxDma<crate::peripherals::$peri> for crate::peripherals::$channel_peri { } | 434 | impl usart::sealed::TxDma<crate::peripherals::$peri> 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; | |||
| 11 | use crate::pac::bdma::{regs, vals}; | 11 | use crate::pac::bdma::{regs, vals}; |
| 12 | 12 | ||
| 13 | use crate::pac; | 13 | use crate::pac; |
| 14 | use crate::pac::dma_channels; | 14 | use crate::pac::bdma_channels; |
| 15 | use crate::pac::dma_requests; | 15 | use crate::pac::dma_requests; |
| 16 | use crate::pac::interrupts; | 16 | use crate::pac::interrupts; |
| 17 | use crate::pac::peripheral_count; | 17 | use crate::pac::peripheral_count; |
| @@ -170,19 +170,26 @@ macro_rules! impl_dmamux { | |||
| 170 | 170 | ||
| 171 | peripherals! { | 171 | peripherals! { |
| 172 | (bdma, DMA1) => { | 172 | (bdma, DMA1) => { |
| 173 | dma_channels! { | 173 | bdma_channels! { |
| 174 | ($channel_peri:ident, DMA1, $channel_num:expr) => { | 174 | ($channel_peri:ident, DMA1, $channel_num:expr) => { |
| 175 | impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA1, 0); | 175 | impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA1, 0); |
| 176 | }; | 176 | }; |
| 177 | } | 177 | } |
| 178 | }; | 178 | }; |
| 179 | (bdma, DMA2) => { | 179 | (bdma, DMA2) => { |
| 180 | dma_channels! { | 180 | bdma_channels! { |
| 181 | ($channel_peri:ident, DMA2, $channel_num:expr) => { | 181 | ($channel_peri:ident, DMA2, $channel_num:expr) => { |
| 182 | impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1); | 182 | impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1); |
| 183 | }; | 183 | }; |
| 184 | } | 184 | } |
| 185 | }; | 185 | }; |
| 186 | (bdma, BDMA) => { | ||
| 187 | bdma_channels! { | ||
| 188 | ($channel_peri:ident, BDMA, $channel_num:expr) => { | ||
| 189 | impl_dma_channel!($channel_peri, DMAMUX1, $channel_num, DMA2, 1); | ||
| 190 | }; | ||
| 191 | } | ||
| 192 | }; | ||
| 186 | (dmamux, DMAMUX1) => { | 193 | (dmamux, DMAMUX1) => { |
| 187 | impl_dmamux!(DMAMUX1); | 194 | impl_dmamux!(DMAMUX1); |
| 188 | }; | 195 | }; |
| @@ -243,7 +250,7 @@ macro_rules! impl_usart_dma_requests { | |||
| 243 | #[cfg(usart)] | 250 | #[cfg(usart)] |
| 244 | use crate::usart; | 251 | use crate::usart; |
| 245 | 252 | ||
| 246 | dma_channels! { | 253 | bdma_channels! { |
| 247 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { | 254 | ($channel_peri:ident, $dma_peri:ident, $channel_num:expr) => { |
| 248 | impl_usart_dma_requests!($channel_peri, $dma_peri, $channel_num); | 255 | impl_usart_dma_requests!($channel_peri, $dma_peri, $channel_num); |
| 249 | }; | 256 | }; |
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) { | |||
| 252 | let mut peripheral_pins_table: Vec<Vec<String>> = Vec::new(); | 252 | let mut peripheral_pins_table: Vec<Vec<String>> = Vec::new(); |
| 253 | let mut peripheral_rcc_table: Vec<Vec<String>> = Vec::new(); | 253 | let mut peripheral_rcc_table: Vec<Vec<String>> = Vec::new(); |
| 254 | let mut dma_channels_table: Vec<Vec<String>> = Vec::new(); | 254 | let mut dma_channels_table: Vec<Vec<String>> = Vec::new(); |
| 255 | let mut bdma_channels_table: Vec<Vec<String>> = Vec::new(); | ||
| 255 | let mut dma_requests_table: Vec<Vec<String>> = Vec::new(); | 256 | let mut dma_requests_table: Vec<Vec<String>> = Vec::new(); |
| 256 | let mut peripheral_dma_channels_table: Vec<Vec<String>> = Vec::new(); | 257 | let mut peripheral_dma_channels_table: Vec<Vec<String>> = Vec::new(); |
| 257 | let mut peripheral_counts: HashMap<String, u8> = HashMap::new(); | 258 | let mut peripheral_counts: HashMap<String, u8> = HashMap::new(); |
| @@ -266,13 +267,7 @@ pub fn gen(options: Options) { | |||
| 266 | let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; | 267 | let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; |
| 267 | let gpio_stride = 0x400; | 268 | let gpio_stride = 0x400; |
| 268 | 269 | ||
| 269 | for (id, channel_info) in &core.dma_channels { | 270 | |
| 270 | let mut row = Vec::new(); | ||
| 271 | row.push(id.clone()); | ||
| 272 | row.push(channel_info.dma.clone()); | ||
| 273 | row.push(channel_info.channel.to_string()); | ||
| 274 | dma_channels_table.push(row); | ||
| 275 | } | ||
| 276 | 271 | ||
| 277 | let number_suffix_re = Regex::new("^(.*?)[0-9]*$").unwrap(); | 272 | let number_suffix_re = Regex::new("^(.*?)[0-9]*$").unwrap(); |
| 278 | 273 | ||
| @@ -449,6 +444,24 @@ pub fn gen(options: Options) { | |||
| 449 | dev.peripherals.push(ir_peri); | 444 | dev.peripherals.push(ir_peri); |
| 450 | } | 445 | } |
| 451 | 446 | ||
| 447 | for (id, channel_info) in &core.dma_channels { | ||
| 448 | let mut row = Vec::new(); | ||
| 449 | let dma_peri = core.peripherals.get(&channel_info.dma); | ||
| 450 | row.push(id.clone()); | ||
| 451 | row.push(channel_info.dma.clone()); | ||
| 452 | row.push(channel_info.channel.to_string()); | ||
| 453 | if let Some(dma_peri) = dma_peri { | ||
| 454 | if let Some(ref block) = dma_peri.block { | ||
| 455 | let bi = BlockInfo::parse(block); | ||
| 456 | if bi.module == "bdma" { | ||
| 457 | bdma_channels_table.push(row); | ||
| 458 | } else { | ||
| 459 | dma_channels_table.push(row); | ||
| 460 | } | ||
| 461 | } | ||
| 462 | } | ||
| 463 | } | ||
| 464 | |||
| 452 | for (name, &num) in &core.interrupts { | 465 | for (name, &num) in &core.interrupts { |
| 453 | dev.interrupts.push(ir::Interrupt { | 466 | dev.interrupts.push(ir::Interrupt { |
| 454 | name: name.clone(), | 467 | name: name.clone(), |
| @@ -495,6 +508,7 @@ pub fn gen(options: Options) { | |||
| 495 | ); | 508 | ); |
| 496 | make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table); | 509 | make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table); |
| 497 | make_table(&mut extra, "dma_channels", &dma_channels_table); | 510 | make_table(&mut extra, "dma_channels", &dma_channels_table); |
| 511 | make_table(&mut extra, "bdma_channels", &bdma_channels_table); | ||
| 498 | make_table(&mut extra, "dma_requests", &dma_requests_table); | 512 | make_table(&mut extra, "dma_requests", &dma_requests_table); |
| 499 | make_peripheral_counts(&mut extra, &peripheral_counts); | 513 | make_peripheral_counts(&mut extra, &peripheral_counts); |
| 500 | 514 | ||
