Remove parse_signal_name duplicate.
This commit is contained in:
parent
823168933f
commit
ce5c57db68
@ -4,6 +4,7 @@ use std::collections::{HashMap, HashSet};
|
|||||||
use stm32_data_serde::chip::core::peripheral::Pin;
|
use stm32_data_serde::chip::core::peripheral::Pin;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::gpio_af::parse_signal_name;
|
||||||
|
|
||||||
mod xml {
|
mod xml {
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
@ -1140,27 +1141,21 @@ fn process_core(
|
|||||||
let mut periph_pins = HashMap::<_, Vec<_>>::new();
|
let mut periph_pins = HashMap::<_, Vec<_>>::new();
|
||||||
for (pin_name, pin) in &group.pins {
|
for (pin_name, pin) in &group.pins {
|
||||||
for signal in &pin.signals {
|
for signal in &pin.signals {
|
||||||
let mut signal = signal.name.clone();
|
let signal = &signal.name;
|
||||||
if signal.starts_with("DEBUG_SUBGHZSPI-") {
|
|
||||||
signal = format!("SUBGHZSPI_{}", &signal[16..(signal.len() - 3)]);
|
|
||||||
}
|
|
||||||
// TODO: What are those signals (well, GPIO is clear) Which peripheral do they belong to?
|
// TODO: What are those signals (well, GPIO is clear) Which peripheral do they belong to?
|
||||||
if !["GPIO", "CEC", "AUDIOCLK", "VDDTCXO"].contains(&signal.as_str()) && !signal.contains("EXTI") {
|
if ["GPIO", "CEC", "AUDIOCLK", "VDDTCXO"].contains(&signal.as_str()) || signal.contains("EXTI") {
|
||||||
// both peripherals and signals can have underscores in their names so there is no easy way to split
|
continue;
|
||||||
// check if signal name starts with one of the peripheral names
|
}
|
||||||
for periph in peri_kinds.keys() {
|
let Some((signal_peri, signal_name)) = parse_signal_name(signal) else {
|
||||||
if let Some(signal) = signal.strip_prefix(&format!("{periph}_")) {
|
continue;
|
||||||
periph_pins.entry(periph.to_string()).or_default().push(
|
};
|
||||||
|
periph_pins.entry(signal_peri.to_string()).or_default().push(
|
||||||
stm32_data_serde::chip::core::peripheral::Pin {
|
stm32_data_serde::chip::core::peripheral::Pin {
|
||||||
pin: pin_name.clone(),
|
pin: pin_name.clone(),
|
||||||
signal: signal.to_string(),
|
signal: signal_name.to_string(),
|
||||||
af: None,
|
af: None,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for pins in periph_pins.values_mut() {
|
for pins in periph_pins.values_mut() {
|
||||||
|
@ -102,7 +102,7 @@ impl Af {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_signal_name(signal_name: &str) -> Option<(&str, &str)> {
|
pub fn parse_signal_name(signal_name: &str) -> Option<(&str, &str)> {
|
||||||
let (peri_name, signal_name) = {
|
let (peri_name, signal_name) = {
|
||||||
if let Some(signal_name) = signal_name.strip_prefix("USB_OTG_FS_") {
|
if let Some(signal_name) = signal_name.strip_prefix("USB_OTG_FS_") {
|
||||||
("USB_OTG_FS", signal_name)
|
("USB_OTG_FS", signal_name)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user