Skip to content

Commit f5c9371

Browse files
committed
shrink chip-specific handling
1 parent ac2dbde commit f5c9371

File tree

1 file changed

+30
-17
lines changed

1 file changed

+30
-17
lines changed

stm32-data-gen/src/interrupts.rs

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -497,6 +497,36 @@ fn match_peris(peris: &[String], name: &str) -> Vec<String> {
497497
}
498498

499499
fn valid_signals(peri: &str, chip_name: &str) -> Vec<String> {
500+
// Special chip-specific signal mappings
501+
// Format: (peripheral_prefix, chip_pattern, signals)
502+
const CHIP_SPECIFIC_SIGNALS: &[(&str, &str, &[&str])] = &[
503+
// LTDC signals: STM32N6 supports all signals, others only basic ones
504+
("LTDC", "STM32N6", &["GLOBAL", "ER", "LO", "ERR"]),
505+
("LTDC", "*", &["GLOBAL", "ER"]), // Default for all other LTDC devices
506+
// DCMIPP signals: STM32N6 supports CSI, others only basic signals
507+
("DCMIPP", "STM32N6", &["GLOBAL", "CSI"]),
508+
("DCMIPP", "*", &["GLOBAL"]), // Default for all other DCMIPP devices
509+
];
510+
511+
// Check for chip-specific overrides first
512+
for &(peri_prefix, chip_pattern, signals) in CHIP_SPECIFIC_SIGNALS {
513+
if peri.starts_with(peri_prefix) {
514+
let matches = if chip_pattern == "*" {
515+
// This is a default case - check if no specific pattern matched
516+
!CHIP_SPECIFIC_SIGNALS
517+
.iter()
518+
.any(|&(p, c, _)| p == peri_prefix && c != "*" && chip_name.starts_with(c))
519+
} else {
520+
chip_name.starts_with(chip_pattern)
521+
};
522+
523+
if matches {
524+
return signals.iter().map(ToString::to_string).collect();
525+
}
526+
}
527+
}
528+
529+
// Fallback to the general signal map
500530
const IRQ_SIGNALS_MAP: &[(&str, &[&str])] = &[
501531
("CAN", &["TX", "RX0", "RX1", "SCE"]),
502532
("FDCAN", &["IT0", "IT1", "CAL"]),
@@ -534,25 +564,8 @@ fn valid_signals(peri: &str, chip_name: &str) -> Vec<String> {
534564
("ADF", &["FLT0"]),
535565
("RAMECC", &["ECC"]),
536566
("RAMCFG", &["BKP", "ECC"]),
537-
("DCMIPP", &["CSI"]),
538567
];
539568

540-
// Special handling for LTDC based on chip family
541-
if peri.starts_with("LTDC") {
542-
if chip_name.starts_with("STM32N6") {
543-
// STM32N6 variants support all LTDC signals
544-
return vec![
545-
"GLOBAL".to_string(),
546-
"ER".to_string(),
547-
"LO".to_string(),
548-
"ERR".to_string(),
549-
];
550-
} else {
551-
// Other devices only support basic LTDC signals
552-
return vec!["GLOBAL".to_string(), "ER".to_string()];
553-
}
554-
}
555-
556569
for (prefix, signals) in IRQ_SIGNALS_MAP {
557570
if peri.starts_with(prefix) {
558571
return signals.iter().map(ToString::to_string).collect();

0 commit comments

Comments
 (0)