From cbf61765f166edd7377e148291c102c61903efe8 Mon Sep 17 00:00:00 2001 From: Thomas Giesel Date: Mon, 9 Jun 2025 21:15:25 +0200 Subject: Generate pins for new opamp pin naming scheme The new code implements the corresponding traits for the common opamp pin naming scheme of all families, which is VINPx/VINMx. The same pin must not be used for multiple channels for the same opamp. For example, if VINM0 and VINM1 of the same opamp were assigned to the same pin, the channel would not be unique, meaning that the traits would be implemented in a conflicting manner. --- embassy-stm32/Cargo.toml | 4 ++-- embassy-stm32/build.rs | 33 +++++++++++++-------------------- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index 034f51df9..4ee43e600 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -81,7 +81,7 @@ futures-util = { version = "0.3.30", default-features = false } sdio-host = "0.9.0" critical-section = "1.1" #stm32-metapac = { version = "16" } -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-27ef8fba3483187e852eaf3796d827259f61e8ec" } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8a502cec14512a6b833beb8f6e15f4a7b5ee7c06" } vcell = "0.1.3" nb = "1.0.0" @@ -110,7 +110,7 @@ proc-macro2 = "1.0.36" quote = "1.0.15" #stm32-metapac = { version = "16", default-features = false, features = ["metadata"]} -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-27ef8fba3483187e852eaf3796d827259f61e8ec", default-features = false, features = ["metadata"] } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8a502cec14512a6b833beb8f6e15f4a7b5ee7c06", default-features = false, features = ["metadata"] } [features] default = ["rt"] diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index bb5ef53d7..8143c9a23 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -1402,31 +1402,24 @@ fn main() { } if regs.kind == "opamp" { - if pin.signal.starts_with("VP") { - // Impl NonInvertingPin for the VP* signals (VP0, VP1, VP2, etc) - let peri = format_ident!("{}", p.name); - let pin_name = format_ident!("{}", pin.pin); - let ch: u8 = pin.signal.strip_prefix("VP").unwrap().parse().unwrap(); - - g.extend(quote! { - impl_opamp_vp_pin!( #peri, #pin_name, #ch); - }) - } else if pin.signal.starts_with("VINM") { - // Impl NonInvertingPin for the VINM* signals ( VINM0, VINM1, etc) - // STM32G4 - let peri = format_ident!("{}", p.name); - let pin_name = format_ident!("{}", pin.pin); - let ch: Result = pin.signal.strip_prefix("VINM").unwrap().parse(); - - if let Ok(ch) = ch { + let peri = format_ident!("{}", p.name); + let pin_name = format_ident!("{}", pin.pin); + if let Some(ch_str) = pin.signal.strip_prefix("VINP") { + // Impl NonInvertingPin for VINP0, VINP1 etc. + if let Ok(ch) = ch_str.parse::() { + g.extend(quote! { + impl_opamp_vp_pin!( #peri, #pin_name, #ch ); + }); + } + } else if let Some(ch_str) = pin.signal.strip_prefix("VINM") { + // Impl InvertingPin for VINM0, VINM1 etc. + if let Ok(ch) = ch_str.parse::() { g.extend(quote! { impl_opamp_vn_pin!( #peri, #pin_name, #ch); - }) + }); } } else if pin.signal == "VOUT" { // Impl OutputPin for the VOUT pin - let peri = format_ident!("{}", p.name); - let pin_name = format_ident!("{}", pin.pin); g.extend(quote! { impl_opamp_vout_pin!( #peri, #pin_name ); }) -- cgit