diff options
| author | Rogan Morrow <[email protected]> | 2025-08-29 16:08:50 +1000 |
|---|---|---|
| committer | Rogan Morrow <[email protected]> | 2025-08-29 16:08:50 +1000 |
| commit | 13fc222ef45e16980aca221044ae41d106065ce1 (patch) | |
| tree | 6e7b77c89fe0a3e5c667be126909cfc56dbd76c9 | |
| parent | 73717f9ae8ea1f13f029c4c2722610a7e54436cb (diff) | |
set XSPI clock source to HSI and reset after clock init; dont reset SYSCFG
| -rw-r--r-- | embassy-stm32/CHANGELOG.md | 1 | ||||
| -rw-r--r-- | embassy-stm32/src/lib.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/h.rs | 19 |
3 files changed, 20 insertions, 2 deletions
diff --git a/embassy-stm32/CHANGELOG.md b/embassy-stm32/CHANGELOG.md index dd82613d9..bf451da79 100644 --- a/embassy-stm32/CHANGELOG.md +++ b/embassy-stm32/CHANGELOG.md | |||
| @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 15 | - chore: Updated stm32-metapac and stm32-data dependencies | 15 | - chore: Updated stm32-metapac and stm32-data dependencies |
| 16 | - feat: stm32/adc/v3: allow DMA reads to loop through enable channels | 16 | - feat: stm32/adc/v3: allow DMA reads to loop through enable channels |
| 17 | - fix: Fix XSPI not disabling alternate bytes when they were previously enabled | 17 | - fix: Fix XSPI not disabling alternate bytes when they were previously enabled |
| 18 | - fix: Fix stm32h7rs init when using external flash via XSPI | ||
| 18 | 19 | ||
| 19 | ## 0.3.0 - 2025-08-12 | 20 | ## 0.3.0 - 2025-08-12 |
| 20 | 21 | ||
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs index e4a8ff0ab..3be98c462 100644 --- a/embassy-stm32/src/lib.rs +++ b/embassy-stm32/src/lib.rs | |||
| @@ -526,7 +526,7 @@ fn init_hw(config: Config) -> Peripherals { | |||
| 526 | } | 526 | } |
| 527 | }); | 527 | }); |
| 528 | 528 | ||
| 529 | #[cfg(not(any(stm32f1, stm32wb, stm32wl)))] | 529 | #[cfg(not(any(stm32f1, stm32wb, stm32wl, stm32h7rs)))] |
| 530 | rcc::enable_and_reset_with_cs::<peripherals::SYSCFG>(cs); | 530 | rcc::enable_and_reset_with_cs::<peripherals::SYSCFG>(cs); |
| 531 | #[cfg(not(any(stm32h5, stm32h7, stm32h7rs, stm32wb, stm32wl)))] | 531 | #[cfg(not(any(stm32h5, stm32h7, stm32h7rs, stm32wb, stm32wl)))] |
| 532 | rcc::enable_and_reset_with_cs::<peripherals::PWR>(cs); | 532 | rcc::enable_and_reset_with_cs::<peripherals::PWR>(cs); |
diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 837210b6a..331db1968 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | use core::ops::RangeInclusive; | 1 | use core::ops::RangeInclusive; |
| 2 | 2 | ||
| 3 | #[cfg(stm32h7rs)] | 3 | #[cfg(stm32h7rs)] |
| 4 | use stm32_metapac::rcc::vals::Plldivst; | 4 | use stm32_metapac::rcc::vals::{Plldivst, Xspisel}; |
| 5 | 5 | ||
| 6 | use crate::pac; | 6 | use crate::pac; |
| 7 | pub use crate::pac::rcc::vals::{ | 7 | pub use crate::pac::rcc::vals::{ |
| @@ -430,6 +430,16 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 430 | } | 430 | } |
| 431 | while !RCC.cr().read().hsirdy() {} | 431 | while !RCC.cr().read().hsirdy() {} |
| 432 | 432 | ||
| 433 | #[cfg(stm32h7rs)] | ||
| 434 | let (xspi1sel, xspi2sel) = { | ||
| 435 | // Save XSPI clock source settings and switch the clock source so it will use HSI | ||
| 436 | let xspi1sel = RCC.ahbperckselr().read().xspi1sel(); | ||
| 437 | let xspi2sel = RCC.ahbperckselr().read().xspi2sel(); | ||
| 438 | RCC.ahbperckselr().modify(|w| w.set_xspi1sel(Xspisel::HCLK5)); | ||
| 439 | RCC.ahbperckselr().modify(|w| w.set_xspi2sel(Xspisel::HCLK5)); | ||
| 440 | (xspi1sel, xspi2sel) | ||
| 441 | }; | ||
| 442 | |||
| 433 | // Use the HSI clock as system clock during the actual clock setup | 443 | // Use the HSI clock as system clock during the actual clock setup |
| 434 | RCC.cfgr().modify(|w| w.set_sw(Sysclk::HSI)); | 444 | RCC.cfgr().modify(|w| w.set_sw(Sysclk::HSI)); |
| 435 | while RCC.cfgr().read().sws() != Sysclk::HSI {} | 445 | while RCC.cfgr().read().sws() != Sysclk::HSI {} |
| @@ -678,6 +688,13 @@ pub(crate) unsafe fn init(config: Config) { | |||
| 678 | 688 | ||
| 679 | config.mux.init(); | 689 | config.mux.init(); |
| 680 | 690 | ||
| 691 | #[cfg(stm32h7rs)] | ||
| 692 | { | ||
| 693 | // Set the XSPI clock source back to what it was originally | ||
| 694 | RCC.ahbperckselr().modify(|w| w.set_xspi1sel(xspi1sel)); | ||
| 695 | RCC.ahbperckselr().modify(|w| w.set_xspi2sel(xspi2sel)); | ||
| 696 | } | ||
| 697 | |||
| 681 | set_clocks!( | 698 | set_clocks!( |
| 682 | sys: Some(sys), | 699 | sys: Some(sys), |
| 683 | hclk1: Some(hclk), | 700 | hclk1: Some(hclk), |
