From 5cb58754d49642fb0789625efe48ab3c37ae9fee Mon Sep 17 00:00:00 2001 From: JuliDi <20155974+JuliDi@users.noreply.github.com> Date: Sat, 30 Sep 2023 10:10:06 +0200 Subject: [PATCH] skip _C pins for pin impls if split_feature not enabled. --- embassy-stm32/build.rs | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 005ec5280..2c349e55e 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -732,17 +732,14 @@ fn main() { let key = (regs.kind, pin.signal); if let Some(tr) = signals.get(&key) { let mut peri = format_ident!("{}", p.name); + let pin_name = { - // If we encounter a "_C" pin, we remove the suffix - let mut pin_name = pin.pin.strip_suffix("_C").unwrap_or(pin.pin).to_string(); - // However, if the corresponding split_feature is enabled, we actually do want the pin name including "_C" - for split_feature in &split_features { - if pin.pin == split_feature.pin_name_with_c { - pin_name = split_feature.pin_name_with_c.clone(); - } + // If we encounter a _C pin but the split_feature for this pin is not enabled, skip it + if pin.pin.ends_with("_C") && !split_features.iter().any(|x| x.pin_name_with_c == pin.pin) { + continue; } - format_ident!("{}", pin_name) + format_ident!("{}", pin.pin) }; let af = pin.af.unwrap_or(0); @@ -782,16 +779,11 @@ fn main() { let peri = format_ident!("{}", p.name); let pin_name = { - // If we encounter a "_C" pin, we remove the suffix - let mut pin_name = pin.pin.strip_suffix("_C").unwrap_or(pin.pin).to_string(); - // However, if the corresponding split_feature is enabled, we actually do want the pin name including "_C" - for split_feature in &split_features { - if pin.pin == split_feature.pin_name_with_c { - pin_name = split_feature.pin_name_with_c.clone(); - } + // If we encounter a _C pin but the split_feature for this pin is not enabled, skip it + if pin.pin.ends_with("_C") && !split_features.iter().any(|x| x.pin_name_with_c == pin.pin) { + continue; } - - format_ident!("{}", pin_name) + format_ident!("{}", pin.pin) }; // H7 has differential voltage measurements