Auto-enable all GPIOs during init().

This commit is contained in:
Bob McWhirter
2021-07-22 14:38:45 -04:00
parent e91c04a673
commit 13873df30b
4 changed files with 37 additions and 33 deletions

View File

@ -287,6 +287,7 @@ pub fn gen(options: Options) {
let mut peripheral_counts: HashMap<String, u8> = HashMap::new();
let mut dma_channel_counts: HashMap<String, u8> = HashMap::new();
let mut dbgmcu_table: Vec<Vec<String>> = Vec::new();
let mut gpio_rcc_table: Vec<Vec<String>> = Vec::new();
let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address;
let gpio_stride = 0x400;
@ -465,29 +466,32 @@ pub fn gen(options: Options) {
clock.to_ascii_lowercase()
};
if !name.starts_with("GPIO") {
let mut row = Vec::with_capacity(6);
row.push(name.clone());
row.push(clock);
row.push(enable_reg.to_ascii_lowercase());
let mut row = Vec::with_capacity(6);
row.push(name.clone());
row.push(clock);
row.push(enable_reg.to_ascii_lowercase());
if let Some((reset_reg, reset_field)) = reset_reg_field {
row.push(reset_reg.to_ascii_lowercase());
row.push(format!(
"set_{}",
enable_field.to_ascii_lowercase()
));
row.push(format!(
"set_{}",
reset_field.to_ascii_lowercase()
));
} else {
row.push(format!(
"set_{}",
enable_field.to_ascii_lowercase()
));
}
if let Some((reset_reg, reset_field)) = reset_reg_field {
row.push(reset_reg.to_ascii_lowercase());
row.push(format!(
"set_{}",
enable_field.to_ascii_lowercase()
));
row.push(format!(
"set_{}",
reset_field.to_ascii_lowercase()
));
} else {
row.push(format!(
"set_{}",
enable_field.to_ascii_lowercase()
));
}
if !name.starts_with("GPIO") {
peripheral_rcc_table.push(row);
} else {
gpio_rcc_table.push(row);
}
}
(None, Some(_)) => {
@ -586,6 +590,7 @@ pub fn gen(options: Options) {
&peripheral_dma_channels_table,
);
make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table);
make_table(&mut extra, "gpio_rcc", &gpio_rcc_table);
make_table(&mut extra, "dma_channels", &dma_channels_table);
make_table(&mut extra, "dbgmcu", &dbgmcu_table);
make_peripheral_counts(&mut extra, &peripheral_counts);