Merge pull request #2107 from embassy-rs/hil-test

stm32/build: deterministically generate data
This commit is contained in:
xoviat 2023-10-23 23:42:38 +00:00 committed by GitHub
commit 1aaa19748a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,4 +1,4 @@
use std::collections::{HashMap, HashSet}; use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet};
use std::fmt::Write as _; use std::fmt::Write as _;
use std::path::PathBuf; use std::path::PathBuf;
use std::{env, fs}; use std::{env, fs};
@ -352,7 +352,7 @@ fn main() {
// ======== // ========
// Generate DMA IRQs. // Generate DMA IRQs.
let mut dma_irqs: HashMap<&str, Vec<(&str, &str, &str)>> = HashMap::new(); let mut dma_irqs: BTreeMap<&str, Vec<(&str, &str, &str)>> = BTreeMap::new();
for p in METADATA.peripherals { for p in METADATA.peripherals {
if let Some(r) = &p.registers { if let Some(r) = &p.registers {
@ -371,13 +371,15 @@ fn main() {
} }
} }
for (irq, channels) in dma_irqs { let dma_irqs: TokenStream = dma_irqs
.iter()
.map(|(irq, channels)| {
let irq = format_ident!("{}", irq); let irq = format_ident!("{}", irq);
let xdma = format_ident!("{}", channels[0].0); let xdma = format_ident!("{}", channels[0].0);
let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch)); let channels = channels.iter().map(|(_, dma, ch)| format_ident!("{}_{}", dma, ch));
g.extend(quote! { quote! {
#[cfg(feature = "rt")] #[cfg(feature = "rt")]
#[crate::interrupt] #[crate::interrupt]
unsafe fn #irq () { unsafe fn #irq () {
@ -385,8 +387,11 @@ fn main() {
<crate::peripherals::#channels as crate::dma::#xdma::sealed::Channel>::on_irq(); <crate::peripherals::#channels as crate::dma::#xdma::sealed::Channel>::on_irq();
)* )*
} }
});
} }
})
.collect();
g.extend(dma_irqs);
// ======== // ========
// Extract the rcc registers // Extract the rcc registers
@ -433,7 +438,7 @@ fn main() {
// Generate RccPeripheral impls // Generate RccPeripheral impls
let refcounted_peripherals = HashSet::from(["usart", "adc"]); let refcounted_peripherals = HashSet::from(["usart", "adc"]);
let mut refcount_statics = HashSet::new(); let mut refcount_statics = BTreeSet::new();
for p in METADATA.peripherals { for p in METADATA.peripherals {
if !singletons.contains(&p.name.to_string()) { if !singletons.contains(&p.name.to_string()) {