From d19e1c1dd1c8c514c375bca3ba69f636a0b19f88 Mon Sep 17 00:00:00 2001 From: xoviat Date: Mon, 4 Sep 2023 16:18:31 -0500 Subject: [PATCH] stm32: only refcount usart and use kind direclty --- embassy-stm32/build.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 7da3cdff..aef0668a 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -309,7 +309,7 @@ fn main() { // Generate RccPeripheral impls // TODO: maybe get this from peripheral kind? Not sure - let refcounted_peripherals = HashSet::from(["UART", "USART", "SPI", "I2C"]); + let refcounted_peripherals = HashSet::from(["USART"]); let mut refcount_statics = HashSet::new(); for p in METADATA.peripherals { @@ -348,13 +348,13 @@ fn main() { TokenStream::new() }; - let ptype = p.name.replace(|c| char::is_numeric(c), ""); + let ptype = (if let Some(reg) = &p.registers { reg.kind } else { "" }).to_ascii_uppercase(); let pname = format_ident!("{}", p.name); let clk = format_ident!("{}", rcc.clock.to_ascii_lowercase()); let en_reg = format_ident!("{}", en.register.to_ascii_lowercase()); let set_en_field = format_ident!("set_{}", en.field.to_ascii_lowercase()); - let (before_enable, before_disable) = if refcounted_peripherals.contains(ptype.trim_start_matches("LP")) { + let (before_enable, before_disable) = if refcounted_peripherals.contains(ptype.as_str()) { let refcount_static = format_ident!("{}_{}", en.register.to_ascii_uppercase(), en.field.to_ascii_uppercase());