Special handling for timers instead
This commit is contained in:
parent
0a9022d59f
commit
8dd3ddd228
@ -268,22 +268,12 @@ pub fn gen(options: Options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if let Some(rcc) = &rcc {
|
if let Some(rcc) = &rcc {
|
||||||
|
let mut generate_rcc_peripheral = |clock_prefix| {
|
||||||
// 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.
|
||||||
//
|
|
||||||
// Not all peripherals have the clock hint due to insufficient information from
|
let en = find_reg_for_field(&rcc, clock_prefix, &format!("{}EN", name));
|
||||||
// chip definition. If clock is not specified, the first matching register with the
|
let rst = find_reg_for_field(&rcc, clock_prefix, &format!("{}RST", name));
|
||||||
// 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) {
|
match (en, rst) {
|
||||||
(Some((enable_reg, enable_field)), Some((reset_reg, reset_field))) => {
|
(Some((enable_reg, enable_field)), Some((reset_reg, reset_field))) => {
|
||||||
@ -305,6 +295,16 @@ pub fn gen(options: Options) {
|
|||||||
println!("Unable to find enable and reset register for {}", name)
|
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("");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user