aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src
diff options
context:
space:
mode:
authorRogan Morrow <[email protected]>2025-08-29 16:08:50 +1000
committerRogan Morrow <[email protected]>2025-08-29 16:08:50 +1000
commit13fc222ef45e16980aca221044ae41d106065ce1 (patch)
tree6e7b77c89fe0a3e5c667be126909cfc56dbd76c9 /embassy-stm32/src
parent73717f9ae8ea1f13f029c4c2722610a7e54436cb (diff)
set XSPI clock source to HSI and reset after clock init; dont reset SYSCFG
Diffstat (limited to 'embassy-stm32/src')
-rw-r--r--embassy-stm32/src/lib.rs2
-rw-r--r--embassy-stm32/src/rcc/h.rs19
2 files changed, 19 insertions, 2 deletions
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 @@
1use core::ops::RangeInclusive; 1use core::ops::RangeInclusive;
2 2
3#[cfg(stm32h7rs)] 3#[cfg(stm32h7rs)]
4use stm32_metapac::rcc::vals::Plldivst; 4use stm32_metapac::rcc::vals::{Plldivst, Xspisel};
5 5
6use crate::pac; 6use crate::pac;
7pub use crate::pac::rcc::vals::{ 7pub 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),