diff options
| -rw-r--r-- | embassy-stm32/build.rs | 51 |
1 files changed, 43 insertions, 8 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 2795f2597..00f52294c 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -81,15 +81,36 @@ fn main() { | |||
| 81 | singletons.push(c.name.to_string()); | 81 | singletons.push(c.name.to_string()); |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | let mut pin_set = std::collections::HashSet::new(); | ||
| 85 | for p in METADATA.peripherals { | ||
| 86 | for pin in p.pins { | ||
| 87 | pin_set.insert(pin.pin); | ||
| 88 | } | ||
| 89 | } | ||
| 90 | |||
| 84 | // Extra analog switch pins available on most H7 chips | 91 | // Extra analog switch pins available on most H7 chips |
| 85 | #[cfg(feature = "split-pa0")] | 92 | let split_features = [ |
| 86 | singletons.push("PA0_C".into()); | 93 | #[cfg(feature = "split-pa0")] |
| 87 | #[cfg(feature = "split-pa1")] | 94 | ("split-pa0", "PA0_C"), |
| 88 | singletons.push("PA1_C".into()); | 95 | #[cfg(feature = "split-pa1")] |
| 89 | #[cfg(feature = "split-pc2")] | 96 | ("split-pa1", "PA1_C"), |
| 90 | singletons.push("PC2_C".into()); | 97 | #[cfg(feature = "split-pc2")] |
| 91 | #[cfg(feature = "split-pc3")] | 98 | ("split-pc2", "PC2_C"), |
| 92 | singletons.push("PC3_C".into()); | 99 | #[cfg(feature = "split-pc3")] |
| 100 | ("split-pc3", "PC3_C"), | ||
| 101 | ]; | ||
| 102 | |||
| 103 | for (feature_name, pin_name) in split_features { | ||
| 104 | if pin_set.contains(pin_name) { | ||
| 105 | singletons.push(pin_name.into()); | ||
| 106 | } else { | ||
| 107 | panic!( | ||
| 108 | "'{}' feature invalid for this chip! No pin '{}' found.\n | ||
| 109 | Found pins: {:#?}", | ||
| 110 | feature_name, pin_name, pin_set | ||
| 111 | ) | ||
| 112 | } | ||
| 113 | } | ||
| 93 | 114 | ||
| 94 | // ======== | 115 | // ======== |
| 95 | // Handle time-driver-XXXX features. | 116 | // Handle time-driver-XXXX features. |
| @@ -923,6 +944,20 @@ fn main() { | |||
| 923 | 944 | ||
| 924 | for pin_num in 0u32..16 { | 945 | for pin_num in 0u32..16 { |
| 925 | let pin_name = format!("P{}{}", port_letter, pin_num); | 946 | let pin_name = format!("P{}{}", port_letter, pin_num); |
| 947 | |||
| 948 | // TODO: Here we need to take care of the _C pins properly. | ||
| 949 | // Maybe it would be better to not iterate over 0..16 but the | ||
| 950 | // Pin names directly. However, this might have side-effects... :( | ||
| 951 | if pin_name == "PC2" { | ||
| 952 | pins_table.push(vec![ | ||
| 953 | "PC2_C".to_string(), | ||
| 954 | p.name.to_string(), | ||
| 955 | port_num.to_string(), | ||
| 956 | "2".to_string(), | ||
| 957 | format!("EXTI{}", 2), | ||
| 958 | ]); | ||
| 959 | } | ||
| 960 | |||
| 926 | pins_table.push(vec