Auto generate SPI v2 clock enable

Adds RccPeripheral trait for peripherals implementing clock enable and reset for a given peripheral.

Add macro table generting implementations of RccPeripheral for peripherals with clock set, currently restricted to SPI.
This commit is contained in:
Ulf Lilleengen
2021-06-02 16:34:37 +02:00
parent af0f8082f0
commit ee3b82b743
4 changed files with 65 additions and 7 deletions

View File

@ -136,6 +136,7 @@ fn main() {
let mut interrupt_table: Vec<Vec<String>> = Vec::new();
let mut peripherals_table: Vec<Vec<String>> = Vec::new();
let mut peripheral_pins_table: Vec<Vec<String>> = Vec::new();
let mut peripheral_rcc_table: Vec<Vec<String>> = Vec::new();
let dma_base = chip
.peripherals
@ -216,6 +217,19 @@ fn main() {
};
assert_eq!(p.address, dma_base + dma_stride * dma_num);
}
"spi" => {
if let Some(clock) = &p.clock {
let reg = clock.to_ascii_lowercase();
let field = name.to_ascii_lowercase();
peripheral_rcc_table.push(vec![
name.clone(),
format!("{}enr", reg),
format!("{}rstr", reg),
format!("set_{}en", field),
format!("set_{}rst", field),
]);
}
}
_ => {}
}
}
@ -255,6 +269,7 @@ fn main() {
make_table(&mut extra, "peripherals", &peripherals_table);
make_table(&mut extra, "peripheral_versions", &peripheral_version_table);
make_table(&mut extra, "peripheral_pins", &peripheral_pins_table);
make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table);
for (module, version) in peripheral_versions {
println!("loading {} {}", module, version);