aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-23 11:16:17 -0400
committerBob McWhirter <[email protected]>2021-07-23 11:32:20 -0400
commit650f867b1cb364a514d9e5145b0244bb7223c387 (patch)
tree8886c16519ef3eb164bb16f5125e97b566fb4ed4
parent13873df30b6fc2cdb0520ecd706a4f00e6afc528 (diff)
Add a single-column variant to gpio_rcc! macro table
which includes just the set of registers that need to be considered. Then match against those registers with a single `modify(...)`
-rw-r--r--embassy-stm32/src/gpio.rs8
-rw-r--r--stm32-metapac-gen/src/lib.rs6
2 files changed, 12 insertions, 2 deletions
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs
index 09f241faa..5145bd689 100644
--- a/embassy-stm32/src/gpio.rs
+++ b/embassy-stm32/src/gpio.rs
@@ -452,9 +452,13 @@ crate::pac::pins!(
452 452
453pub(crate) unsafe fn init() { 453pub(crate) unsafe fn init() {
454 crate::pac::gpio_rcc! { 454 crate::pac::gpio_rcc! {
455 ($name:ident, $clock:ident, $en_reg:ident, $rst_reg:ident, $en_fn:ident, $rst_fn:ident) => { 455 ($en_reg:ident) => {
456 crate::pac::RCC.$en_reg().modify(|reg| { 456 crate::pac::RCC.$en_reg().modify(|reg| {
457 reg.$en_fn(true); 457 crate::pac::gpio_rcc! {
458 ($name:ident, $clock:ident, $en_reg, $rst_reg:ident, $en_fn:ident, $rst_fn:ident) => {
459 reg.$en_fn(true);
460 };
461 }
458 }); 462 });
459 }; 463 };
460 } 464 }
diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs
index 1c7ac38ee..203d943de 100644
--- a/stm32-metapac-gen/src/lib.rs
+++ b/stm32-metapac-gen/src/lib.rs
@@ -288,6 +288,7 @@ pub fn gen(options: Options) {
288 let mut dma_channel_counts: HashMap<String, u8> = HashMap::new(); 288 let mut dma_channel_counts: HashMap<String, u8> = HashMap::new();
289 let mut dbgmcu_table: Vec<Vec<String>> = Vec::new(); 289 let mut dbgmcu_table: Vec<Vec<String>> = Vec::new();
290 let mut gpio_rcc_table: Vec<Vec<String>> = Vec::new(); 290 let mut gpio_rcc_table: Vec<Vec<String>> = Vec::new();
291 let mut gpio_regs: HashSet<String> = HashSet::new();
291 292
292 let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; 293 let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address;
293 let gpio_stride = 0x400; 294 let gpio_stride = 0x400;
@@ -492,6 +493,7 @@ pub fn gen(options: Options) {
492 peripheral_rcc_table.push(row); 493 peripheral_rcc_table.push(row);
493 } else { 494 } else {
494 gpio_rcc_table.push(row); 495 gpio_rcc_table.push(row);
496 gpio_regs.insert( enable_reg.to_ascii_lowercase() );
495 } 497 }
496 } 498 }
497 (None, Some(_)) => { 499 (None, Some(_)) => {
@@ -508,6 +510,10 @@ pub fn gen(options: Options) {
508 dev.peripherals.push(ir_peri); 510 dev.peripherals.push(ir_peri);
509 } 511 }
510 512
513 for reg in gpio_regs {
514 gpio_rcc_table.push( vec!( reg ) );
515 }
516
511 for (id, channel_info) in &core.dma_channels { 517 for (id, channel_info) in &core.dma_channels {
512 let mut row = Vec::new(); 518 let mut row = Vec::new();
513 let dma_peri = core.peripherals.get(&channel_info.dma).unwrap(); 519 let dma_peri = core.peripherals.get(&channel_info.dma).unwrap();