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.
This commit is contained in:
Thomas Giesel 2025-06-09 21:15:25 +02:00
parent 206a324cf4
commit cbf61765f1
2 changed files with 15 additions and 22 deletions

View File

@ -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"]

View File

@ -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();
if let Some(ch_str) = pin.signal.strip_prefix("VINP") {
// Impl NonInvertingPin for VINP0, VINP1 etc.
if let Ok(ch) = ch_str.parse::<u8>() {
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<u8, _> = pin.signal.strip_prefix("VINM").unwrap().parse();
if let Ok(ch) = ch {
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::<u8>() {
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 );
})