Skip to content

Commit 119240d

Browse files
committed
data-gen: verify pin names with dot do not exist
1 parent 9b8408c commit 119240d

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

mspm0-data-gen/src/generate.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ pub fn generate(
6565
dma_channels,
6666
};
6767

68-
verify::verify(&chip, &name)?;
68+
if let Err(err) = verify::verify(&chip, &name) {
69+
eprintln!("{err}");
70+
};
6971

7072
let _ = fs::write(
7173
format!("./build/data/{name}.json"),
@@ -258,6 +260,10 @@ fn generate_peripherals2(
258260
.unwrap_or_else(|| &device_pin_name)
259261
.to_string();
260262

263+
if skip_peripheral_pin(device_pin_name, chip_name) {
264+
continue;
265+
}
266+
261267
peri.pins.push(PeripheralPin {
262268
pin,
263269
signal: String::from(signal),
@@ -684,3 +690,15 @@ fn generate_dma_channels(
684690

685691
Ok(channels)
686692
}
693+
694+
fn skip_peripheral_pin(pin_name: &String, chip_name: &str) -> bool {
695+
// L130X and L134X defines some device pins that only contain `OPAx.IN0-`, which is one of the symbols. Not the pin
696+
// itself.
697+
if (chip_name == "MSPM0L130X" || chip_name == "MSPM0L134X")
698+
&& (pin_name == "OPA0.IN0-" || pin_name == "OPA1.IN0-")
699+
{
700+
return true;
701+
}
702+
703+
false
704+
}

mspm0-data-gen/src/verify.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,22 @@ fn core_peripherals(chip: &Chip, name: &str) -> anyhow::Result<()> {
7070
fn pin_names(chip: &Chip, name: &str) -> anyhow::Result<()> {
7171
for peripheral in chip.peripherals.values() {
7272
for pin in peripheral.pins.iter() {
73+
// `+` and `-` are allowed
74+
//
75+
// `/` and `.` are not allowed, as these are likely bugs in generation.
7376
if pin.pin.contains('/') {
7477
let peripheral_name = &peripheral.name;
7578
let pin = &pin.pin;
7679

7780
bail!("{name}, {peripheral_name}: pin {pin} contains a '/'");
7881
}
82+
83+
if pin.pin.contains('.') {
84+
let peripheral_name = &peripheral.name;
85+
let pin = &pin.pin;
86+
87+
bail!("{name}, {peripheral_name}: pin {pin} contains invalid characters");
88+
}
7989
}
8090
}
8191

0 commit comments

Comments
 (0)