Special handling for timers instead

This commit is contained in:
Ulf Lilleengen 2021-06-10 09:52:57 +02:00
parent 0a9022d59f
commit 8dd3ddd228

View File

@ -268,42 +268,42 @@ pub fn gen(options: Options) {
} }
if let Some(rcc) = &rcc { if let Some(rcc) = &rcc {
// Workaround for clock registers being split on some chip families. Assume fields are let mut generate_rcc_peripheral = |clock_prefix| {
// named after peripheral and look for first field matching and use that register. // 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.
// Not all peripherals have the clock hint due to insufficient information from
// chip definition. If clock is not specified, the first matching register with the
// expected field will be used.
let en = find_reg_for_field(
&rcc,
p.clock.as_ref().unwrap_or(&String::new()),
&format!("{}EN", name),
);
let rst = find_reg_for_field(
&rcc,
p.clock.as_ref().unwrap_or(&String::new()),
&format!("{}RST", name),
);
match (en, rst) { let en = find_reg_for_field(&rcc, clock_prefix, &format!("{}EN", name));
(Some((enable_reg, enable_field)), Some((reset_reg, reset_field))) => { let rst = find_reg_for_field(&rcc, clock_prefix, &format!("{}RST", name));
peripheral_rcc_table.push(vec![
name.clone(), match (en, rst) {
enable_reg.to_ascii_lowercase(), (Some((enable_reg, enable_field)), Some((reset_reg, reset_field))) => {
reset_reg.to_ascii_lowercase(), peripheral_rcc_table.push(vec![
format!("set_{}", enable_field.to_ascii_lowercase()), name.clone(),
format!("set_{}", reset_field.to_ascii_lowercase()), enable_reg.to_ascii_lowercase(),
]); reset_reg.to_ascii_lowercase(),
} format!("set_{}", enable_field.to_ascii_lowercase()),
(None, Some(_)) => { format!("set_{}", reset_field.to_ascii_lowercase()),
println!("Unable to find enable register for {}", name) ]);
} }
(Some(_), None) => { (None, Some(_)) => {
println!("Unable to find reset register for {}", name) println!("Unable to find enable register for {}", name)
} }
(None, None) => { (Some(_), None) => {
println!("Unable to find enable and reset register for {}", name) println!("Unable to find reset register for {}", name)
}
(None, None) => {
println!("Unable to find enable and reset register for {}", name)
}
} }
};
if let Some(clock) = &p.clock {
generate_rcc_peripheral(clock);
} else if name.starts_with("TIM") {
// Not all peripherals like timers the clock hint due to insufficient information from
// chip definition. If clock is not specified, the first matching register with the
// expected field will be used.
generate_rcc_peripheral("");
} }
} }
} }