aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorThomas Giesel <[email protected]>2025-06-09 21:15:25 +0200
committerThomas Giesel <[email protected]>2025-06-25 08:27:44 +0200
commitcbf61765f166edd7377e148291c102c61903efe8 (patch)
tree3b53048fec9015a3b4ff0eb9fa11c1dbba9a7e40 /embassy-stm32
parent206a324cf4d612122356fb350b4a3b56391d6f20 (diff)
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.
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/Cargo.toml4
-rw-r--r--embassy-stm32/build.rs33
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 }
81sdio-host = "0.9.0" 81sdio-host = "0.9.0"
82critical-section = "1.1" 82critical-section = "1.1"
83#stm32-metapac = { version = "16" } 83#stm32-metapac = { version = "16" }
84stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-27ef8fba3483187e852eaf3796d827259f61e8ec" } 84stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8a502cec14512a6b833beb8f6e15f4a7b5ee7c06" }
85 85
86vcell = "0.1.3" 86vcell = "0.1.3"
87nb = "1.0.0" 87nb = "1.0.0"
@@ -110,7 +110,7 @@ proc-macro2 = "1.0.36"
110quote = "1.0.15" 110quote = "1.0.15"
111 111
112#stm32-metapac = { version = "16", default-features = false, features = ["metadata"]} 112#stm32-metapac = { version = "16", default-features = false, features = ["metadata"]}
113stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-27ef8fba3483187e852eaf3796d827259f61e8ec", default-features = false, features = ["metadata"] } 113stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-8a502cec14512a6b833beb8f6e15f4a7b5ee7c06", default-features = false, features = ["metadata"] }
114 114
115[features] 115[features]
116default = ["rt"] 116default = ["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() {
1402 } 1402 }
1403 1403
1404 if regs.kind == "opamp" { 1404 if regs.kind == "opamp" {
1405 if pin.signal.starts_with("VP") { 1405 let peri = format_ident!("{}", p.name);
1406 // Impl NonInvertingPin for the VP* signals (VP0, VP1, VP2, etc) 1406 let pin_name = format_ident!("{}", pin.pin);
1407 let peri = format_ident!("{}", p.name); 1407 if let Some(ch_str) = pin.signal.strip_prefix("VINP") {
1408 let pin_name = format_ident!("{}", pin.pin); 1408 // Impl NonInvertingPin for VINP0, VINP1 etc.
1409 let ch: u8 = pin.signal.strip_prefix("VP").unwrap().parse().unwrap(); 1409 if let Ok(ch) = ch_str.parse::<u8>() {
1410 1410 g.extend(quote! {
1411 g.extend(quote! { 1411 impl_opamp_vp_pin!( #peri, #pin_name, #ch );
1412 impl_opamp_vp_pin!( #peri, #pin_name, #ch); 1412 });
1413 }) 1413 }
1414 } else if pin.signal.starts_with("VINM") { 1414 } else if let Some(ch_str) = pin.signal.strip_prefix("VINM") {
1415 // Impl NonInvertingPin for the VINM* signals ( VINM0, VINM1, etc) 1415 // Impl InvertingPin for VINM0, VINM1 etc.
1416 // STM32G4 1416 if let Ok(ch) = ch_str.parse::<u8>() {
1417 let peri = format_ident!("{}", p.name);
1418 let pin_name = format_ident!("{}", pin.pin);
1419 let ch: Result<u8, _> = pin.signal.strip_prefix("VINM").unwrap().parse();
1420
1421 if let Ok(ch) = ch {
1422 g.extend(quote! { 1417 g.extend(quote! {
1423 impl_opamp_vn_pin!( #peri, #pin_name, #ch); 1418 impl_opamp_vn_pin!( #peri, #pin_name, #ch);
1424 }) 1419 });
1425 } 1420 }
1426 } else if pin.signal == "VOUT" { 1421 } else if pin.signal == "VOUT" {
1427 // Impl OutputPin for the VOUT pin 1422 // Impl OutputPin for the VOUT pin
1428 let peri = format_ident!("{}", p.name);
1429 let pin_name = format_ident!("{}", pin.pin);
1430 g.extend(quote! { 1423 g.extend(quote! {
1431 impl_opamp_vout_pin!( #peri, #pin_name ); 1424 impl_opamp_vout_pin!( #peri, #pin_name );
1432 }) 1425 })