Make RCC lookup optional
This commit is contained in:
parent
f3d1ac6623
commit
9a2adec584
@ -156,12 +156,19 @@ fn main() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Load RCC register for chip
|
// Load RCC register for chip
|
||||||
let chip_family = chip.family.to_ascii_lowercase();
|
let rcc = chip.peripherals.iter().find_map(|(name, p)| {
|
||||||
let rcc_family = chip_family.strip_prefix("stm32").unwrap();
|
if name == "RCC" {
|
||||||
|
p.block.as_ref().map(|block| {
|
||||||
|
let bi = BlockInfo::parse(block);
|
||||||
let rcc_reg_path = Path::new(&dir)
|
let rcc_reg_path = Path::new(&dir)
|
||||||
.join("registers")
|
.join("registers")
|
||||||
.join(&format!("rcc_{}.yaml", &rcc_family[0..2]));
|
.join(&format!("{}_{}.yaml", bi.module, bi.version));
|
||||||
let rcc: ir::IR = serde_yaml::from_reader(File::open(rcc_reg_path).unwrap()).unwrap();
|
serde_yaml::from_reader(File::open(rcc_reg_path).unwrap()).unwrap()
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
let mut peripheral_versions: HashMap<String, String> = HashMap::new();
|
let mut peripheral_versions: HashMap<String, String> = HashMap::new();
|
||||||
let mut pin_table: Vec<Vec<String>> = Vec::new();
|
let mut pin_table: Vec<Vec<String>> = Vec::new();
|
||||||
@ -254,6 +261,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(clock) = &p.clock {
|
if let Some(clock) = &p.clock {
|
||||||
|
if let Some(rcc) = &rcc {
|
||||||
// Workaround for clock registers being split on some chip families. Assume fields are
|
// Workaround for clock registers being split on some chip families. Assume fields are
|
||||||
// named after peripheral and look for first field matching and use that register.
|
// named after peripheral and look for first field matching and use that register.
|
||||||
let en = find_reg_for_field(&rcc, clock, &format!("{}EN", name));
|
let en = find_reg_for_field(&rcc, clock, &format!("{}EN", name));
|
||||||
@ -281,6 +289,7 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
dev.peripherals.push(ir_peri);
|
dev.peripherals.push(ir_peri);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user