This commit is contained in:
xoviat 2023-10-08 18:26:27 -05:00
parent 2ae9d28d47
commit a4b6bc31f8

View File

@ -382,11 +382,7 @@ fn main() {
) )
}) })
.collect(); .collect();
let rcc_enum_map: HashMap<String, &Enum> = rcc_registers let rcc_enum_map: HashMap<&str, &Enum> = rcc_registers.enums.iter().map(|e| (e.name, e)).collect();
.enums
.iter()
.map(|e| (e.name.to_ascii_uppercase(), e))
.collect();
// ======== // ========
// Generate RccPeripheral impls // Generate RccPeripheral impls
@ -465,7 +461,7 @@ fn main() {
let fieldset = rcc_fieldset_map.get(mux.register)?; let fieldset = rcc_fieldset_map.get(mux.register)?;
let field = fieldset.get(mux.field)?; let field = fieldset.get(mux.field)?;
let enum_name = field.enumm?; let enum_name = field.enumm?;
let enumm = rcc_enum_map.get(enum_name.to_ascii_uppercase().as_str())?; let enumm = rcc_enum_map.get(enum_name)?;
Some((mux, enumm)) Some((mux, enumm))
}; };
@ -539,12 +535,14 @@ fn main() {
} }
} }
let mut refcount_mod = TokenStream::new(); let refcount_mod: TokenStream = refcount_statics
for refcount_static in refcount_statics { .iter()
refcount_mod.extend(quote! { .map(|refcount_static| {
quote! {
pub(crate) static mut #refcount_static: u8 = 0; pub(crate) static mut #refcount_static: u8 = 0;
});
} }
})
.collect();
g.extend(quote! { g.extend(quote! {
mod refcount_statics { mod refcount_statics {