diff options
| -rw-r--r-- | embassy-stm32/src/gpio.rs | 10 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 1 | ||||
| -rw-r--r-- | examples/stm32h7/src/bin/usart_dma.rs | 12 | ||||
| -rw-r--r-- | stm32-metapac-gen/src/lib.rs | 47 |
4 files changed, 37 insertions, 33 deletions
diff --git a/embassy-stm32/src/gpio.rs b/embassy-stm32/src/gpio.rs index bf8400ca9..09f241faa 100644 --- a/embassy-stm32/src/gpio.rs +++ b/embassy-stm32/src/gpio.rs | |||
| @@ -449,3 +449,13 @@ crate::pac::pins!( | |||
| 449 | } | 449 | } |
| 450 | }; | 450 | }; |
| 451 | ); | 451 | ); |
| 452 | |||
| 453 | pub(crate) unsafe fn init() { | ||
| 454 | crate::pac::gpio_rcc! { | ||
| 455 | ($name:ident, $clock:ident, $en_reg:ident, $rst_reg:ident, $en_fn:ident, $rst_fn:ident) => { | ||
| 456 | crate::pac::RCC.$en_reg().modify(|reg| { | ||
| 457 | reg.$en_fn(true); | ||
| 458 | }); | ||
| 459 | }; | ||
| 460 | } | ||
| 461 | } | ||
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index 07f8b9f3b..89fd86448 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -89,6 +89,7 @@ pub fn init(config: Config) -> Peripherals { | |||
| 89 | let p = Peripherals::take(); | 89 | let p = Peripherals::take(); |
| 90 | 90 | ||
| 91 | unsafe { | 91 | unsafe { |
| 92 | gpio::init(); | ||
| 92 | dma::init(); | 93 | dma::init(); |
| 93 | #[cfg(exti)] | 94 | #[cfg(exti)] |
| 94 | exti::init(); | 95 | exti::init(); |
diff --git a/examples/stm32h7/src/bin/usart_dma.rs b/examples/stm32h7/src/bin/usart_dma.rs index 097466cea..907356500 100644 --- a/examples/stm32h7/src/bin/usart_dma.rs +++ b/examples/stm32h7/src/bin/usart_dma.rs | |||
| @@ -71,22 +71,10 @@ fn main() -> ! { | |||
| 71 | .pll1_q_ck(48.mhz()) | 71 | .pll1_q_ck(48.mhz()) |
| 72 | .freeze(pwrcfg, &pp.SYSCFG); | 72 | .freeze(pwrcfg, &pp.SYSCFG); |
| 73 | 73 | ||
| 74 | let pp = unsafe { pac::Peripherals::steal() }; | ||
| 75 | |||
| 76 | unsafe { | 74 | unsafe { |
| 77 | Dbgmcu::enable_all(); | 75 | Dbgmcu::enable_all(); |
| 78 | } | 76 | } |
| 79 | 77 | ||
| 80 | pp.RCC.ahb4enr.modify(|_, w| { | ||
| 81 | w.gpioaen().set_bit(); | ||
| 82 | w.gpioben().set_bit(); | ||
| 83 | w.gpiocen().set_bit(); | ||
| 84 | w.gpioden().set_bit(); | ||
| 85 | w.gpioeen().set_bit(); | ||
| 86 | w.gpiofen().set_bit(); | ||
| 87 | w | ||
| 88 | }); | ||
| 89 | |||
| 90 | unsafe { embassy::time::set_clock(&ZeroClock) }; | 78 | unsafe { embassy::time::set_clock(&ZeroClock) }; |
| 91 | 79 | ||
| 92 | let executor = EXECUTOR.put(Executor::new()); | 80 | let executor = EXECUTOR.put(Executor::new()); |
diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs index bfc2384cd..1c7ac38ee 100644 --- a/stm32-metapac-gen/src/lib.rs +++ b/stm32-metapac-gen/src/lib.rs | |||
| @@ -287,6 +287,7 @@ pub fn gen(options: Options) { | |||
| 287 | let mut peripheral_counts: HashMap<String, u8> = HashMap::new(); | 287 | let mut peripheral_counts: HashMap<String, u8> = HashMap::new(); |
| 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 | 291 | ||
| 291 | let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; | 292 | let gpio_base = core.peripherals.get(&"GPIOA".to_string()).unwrap().address; |
| 292 | let gpio_stride = 0x400; | 293 | let gpio_stride = 0x400; |
| @@ -465,29 +466,32 @@ pub fn gen(options: Options) { | |||
| 465 | clock.to_ascii_lowercase() | 466 | clock.to_ascii_lowercase() |
| 466 | }; | 467 | }; |
| 467 | 468 | ||
| 469 | let mut row = Vec::with_capacity(6); | ||
| 470 | row.push(name.clone()); | ||
| 471 | row.push(clock); | ||
| 472 | row.push(enable_reg.to_ascii_lowercase()); | ||
| 473 | |||
| 474 | if let Some((reset_reg, reset_field)) = reset_reg_field { | ||
| 475 | row.push(reset_reg.to_ascii_lowercase()); | ||
| 476 | row.push(format!( | ||
| 477 | "set_{}", | ||
| 478 | enable_field.to_ascii_lowercase() | ||
| 479 | )); | ||
| 480 | row.push(format!( | ||
| 481 | "set_{}", | ||
| 482 | reset_field.to_ascii_lowercase() | ||
| 483 | )); | ||
| 484 | } else { | ||
| 485 | row.push(format!( | ||
| 486 | "set_{}", | ||
| 487 | enable_field.to_ascii_lowercase() | ||
| 488 | )); | ||
| 489 | } | ||
| 490 | |||
| 468 | if !name.starts_with("GPIO") { | 491 | if !name.starts_with("GPIO") { |
| 469 | let mut row = Vec::with_capacity(6); | ||
| 470 | row.push(name.clone()); | ||
| 471 | row.push(clock); | ||
| 472 | row.push(enable_reg.to_ascii_lowercase()); | ||
| 473 | |||
| 474 | if let Some((reset_reg, reset_field)) = reset_reg_field { | ||
| 475 | row.push(reset_reg.to_ascii_lowercase()); | ||
| 476 | row.push(format!( | ||
| 477 | "set_{}", | ||
| 478 | enable_field.to_ascii_lowercase() | ||
| 479 | )); | ||
| 480 | row.push(format!( | ||
| 481 | "set_{}", | ||
| 482 | reset_field.to_ascii_lowercase() | ||
| 483 | )); | ||
| 484 | } else { | ||
| 485 | row.push(format!( | ||
| 486 | "set_{}", | ||
| 487 | enable_field.to_ascii_lowercase() | ||
| 488 | )); | ||
| 489 | } | ||
| 490 | peripheral_rcc_table.push(row); | 492 | peripheral_rcc_table.push(row); |
| 493 | } else { | ||
| 494 | gpio_rcc_table.push(row); | ||
| 491 | } | 495 | } |
| 492 | } | 496 | } |
| 493 | (None, Some(_)) => { | 497 | (None, Some(_)) => { |
| @@ -586,6 +590,7 @@ pub fn gen(options: Options) { | |||
| 586 | &peripheral_dma_channels_table, | 590 | &peripheral_dma_channels_table, |
| 587 | ); | 591 | ); |
| 588 | make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table); | 592 | make_table(&mut extra, "peripheral_rcc", &peripheral_rcc_table); |
| 593 | make_table(&mut extra, "gpio_rcc", &gpio_rcc_table); | ||
| 589 | make_table(&mut extra, "dma_channels", &dma_channels_table); | 594 | make_table(&mut extra, "dma_channels", &dma_channels_table); |
| 590 | make_table(&mut extra, "dbgmcu", &dbgmcu_table); | 595 | make_table(&mut extra, "dbgmcu", &dbgmcu_table); |
| 591 | make_peripheral_counts(&mut extra, &peripheral_counts); | 596 | make_peripheral_counts(&mut extra, &peripheral_counts); |
