From 4a893c37daa663077586efcc6dc6926e3aa2e1ae Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 1 Oct 2023 13:28:31 -0500 Subject: [PATCH 1/2] add man impl. pin signals --- data/extra/family/STM32F3.yaml | 12 ++++++++++++ stm32-data-gen/src/chips.rs | 16 ++++++++++++---- stm32-data-serde/src/lib.rs | 1 + 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/data/extra/family/STM32F3.yaml b/data/extra/family/STM32F3.yaml index 84da393..4eafa82 100644 --- a/data/extra/family/STM32F3.yaml +++ b/data/extra/family/STM32F3.yaml @@ -6,3 +6,15 @@ peripherals: kind: vrefintcal version: v1 block: VREFINTCAL + - name: OPAMP2 + pins: + - pin: PA5 + signal: VM1 + - pin: PC5 + signal: VM0 + - pin: PA7 + signal: VP0 + - pin: PD14 + signal: VP1 + - pin: PB0 + signal: VP2 \ No newline at end of file diff --git a/stm32-data-gen/src/chips.rs b/stm32-data-gen/src/chips.rs index 01f38bc..b756036 100644 --- a/stm32-data-gen/src/chips.rs +++ b/stm32-data-gen/src/chips.rs @@ -927,7 +927,7 @@ fn process_core( pins.sort(); pins.dedup(); } - let mut peripherals = Vec::new(); + let mut peripherals = HashMap::new(); for (pname, pkind) in peri_kinds { // We cannot add this to FAKE peripherals because we need the pins if pname.starts_with("I2S") { @@ -1045,7 +1045,7 @@ fn process_core( p.interrupts = Some(irqs); } - peripherals.push(p); + peripherals.insert(p.name.clone(), p); } if let Ok(extra_f) = std::fs::read(format!("data/extra/family/{}.yaml", group.family.as_ref().unwrap())) { #[derive(serde::Deserialize)] @@ -1054,10 +1054,18 @@ fn process_core( } let extra: Extra = serde_yaml::from_slice(&extra_f).unwrap(); - for p in extra.peripherals { - peripherals.push(p); + for mut p in extra.peripherals { + if let Some(peripheral) = peripherals.get_mut(&p.name) { + // Modify the generated peripheral + peripheral.pins.append(&mut p.pins); + } else if p.address != 0 { + // Only insert the peripheral if the address is not the default + peripherals.insert(p.name.clone(), p); + } } } + + let mut peripherals: Vec<_> = peripherals.into_values().collect(); peripherals.sort_by_key(|x| x.name.clone()); let have_peris: HashSet<_> = peripherals.iter_mut().map(|p| p.name.clone()).collect(); // Collect DMA versions in the chip diff --git a/stm32-data-serde/src/lib.rs b/stm32-data-serde/src/lib.rs index b95a3b1..0372c21 100644 --- a/stm32-data-serde/src/lib.rs +++ b/stm32-data-serde/src/lib.rs @@ -84,6 +84,7 @@ pub mod chip { #[derive(Clone, Debug, Eq, PartialEq, Hash, PartialOrd, Ord, Serialize, Deserialize)] pub struct Peripheral { pub name: String, + #[serde(default)] pub address: u32, #[serde(skip_serializing_if = "Option::is_none")] pub registers: Option, From 92ae3d587054b65a974dd3c60bdee82cecea4b43 Mon Sep 17 00:00:00 2001 From: xoviat Date: Sun, 1 Oct 2023 13:44:30 -0500 Subject: [PATCH 2/2] optimize hashset gen. --- stm32-data-gen/src/chips.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/stm32-data-gen/src/chips.rs b/stm32-data-gen/src/chips.rs index b756036..82f1ec8 100644 --- a/stm32-data-gen/src/chips.rs +++ b/stm32-data-gen/src/chips.rs @@ -1065,9 +1065,9 @@ fn process_core( } } + let have_peris: HashSet<_> = peripherals.keys().cloned().collect(); let mut peripherals: Vec<_> = peripherals.into_values().collect(); peripherals.sort_by_key(|x| x.name.clone()); - let have_peris: HashSet<_> = peripherals.iter_mut().map(|p| p.name.clone()).collect(); // Collect DMA versions in the chip let mut chip_dmas: Vec<_> = group .ips