diff options
| author | xoviat <[email protected]> | 2023-10-23 23:42:38 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-10-23 23:42:38 +0000 |
| commit | 1aaa19748ac907d5f169170a8afc8218ec021e23 (patch) | |
| tree | 5e26729cce14922220e5bf3864cffec1b3958461 | |
| parent | 17b4cf8ce75c985445754eea8c437b934c14c68c (diff) | |
| parent | 9e230b64a409379b3e24ed4ad7195c06ea212e1f (diff) | |
Merge pull request #2107 from embassy-rs/hil-test
stm32/build: deterministically generate data
| -rw-r--r-- | embassy-stm32/build.rs | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index f8908756d..938e44b14 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | use std::collections::{HashMap, HashSet}; | 1 | use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet}; |
| 2 | use std::fmt::Write as _; | 2 | use std::fmt::Write as _; |
| 3 | use std::path::PathBuf; | 3 | use std::path::PathBuf; |
| 4 | use std::{env, fs}; | 4 | use std::{env, fs}; |
| @@ -352,7 +352,7 @@ fn main() { | |||
| 352 | // ======== | 352 | // ======== |
| 353 | // Generate DMA IRQs. | 353 | // Generate DMA IRQs. |
| 354 | 354 | ||
| 355 | let mut dma_irqs: HashMap<&str, Vec<(&str, &str, &str)>> = HashMap::new(); | 355 | let mut dma_irqs: BTreeMap<&str, Vec<(&str, &str, &str)>> = BTreeMap::new(); |
| 356 | 356 | ||
| 357 | for p in METADATA.peripherals { | 357 | for p in METADATA.peripherals { |
| 358 | if let Some(r) = &p.registers { | 358 | if let Some(r) = &p.registers { |
| @@ -371,22 +371,27 @@ fn main() { | |||
| 371 | } | 371 | } |
| 372 | } | 372 | } |
| 373 | 373 | ||
| 374 | for (irq, channels) in dma_irqs { | 374 | let dma_irqs: TokenStream = dma_irqs |
| 375 | let irq = format_ident!("{}", irq); | 375 | .iter() |
| 376 | .map(|(irq, channels)| { | ||
| 377 | let irq = format_ident!("{}", irq); | ||
| 376 | 378 | ||
| 377 | let xdma = format_ident!("{}", channels[0].0); | 379 | let xdma = format_ident!("{}", channels[0].0); |
| 378 | let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); | 380 | let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); |
| 379 | 381 | ||
| 380 | g.extend(quote! { | 382 | quote! { |
| 381 | #[cfg(feature = "rt")] | 383 | #[cfg(feature = "rt")] |
| 382 | #[crate::interrupt] | 384 | #[crate::interrupt] |
| 383 | unsafe fn #irq () { | 385 | unsafe fn #irq () { |
| 384 | #( | 386 | #( |
| 385 | <crate::peripherals::#channels as crate::dma::#xdma::sealed::Channel>::on_irq(); | 387 | <crate::peripherals::#channels as crate::dma::#xdma::sealed::Channel>::on_irq(); |
| 386 | )* | 388 | )* |
| 389 | } | ||
| 387 | } | 390 | } |
| 388 | }); | 391 | }) |
| 389 | } | 392 | .collect(); |
| 393 | |||
| 394 | g.extend(dma_irqs); | ||
| 390 | 395 | ||
| 391 | // ======== | 396 | // ======== |
| 392 | // Extract the rcc registers | 397 | // Extract the rcc registers |
| @@ -433,7 +438,7 @@ fn main() { | |||
| 433 | // Generate RccPeripheral impls | 438 | // Generate RccPeripheral impls |
| 434 | 439 | ||
| 435 | let refcounted_peripherals = HashSet::from(["usart", "adc"]); | 440 | let refcounted_peripherals = HashSet::from(["usart", "adc"]); |
| 436 | let mut refcount_statics = HashSet::new(); | 441 | let mut refcount_statics = BTreeSet::new(); |
| 437 | 442 | ||
| 438 | for p in METADATA.peripherals { | 443 | for p in METADATA.peripherals { |
| 439 | if !singletons.contains(&p.name.to_string()) { | 444 | if !singletons.contains(&p.name.to_string()) { |
