aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32/src/lib.rs
diff options
context:
space:
mode:
authorMichael Medin <[email protected]>2025-04-28 09:14:56 +0200
committerMichael Medin <[email protected]>2025-04-28 09:14:56 +0200
commit74cb84eb4e4be75859deb6fa4896efae5345eacb (patch)
tree7697d7f250050d577af60f1b871fb461cb23e9e5 /embassy-stm32/src/lib.rs
parent584066e209141ce92d882ceb6e7525c980833689 (diff)
Moved functions to rcc module (this is a bit awkward as we now have two init functions in rcc: `rcc::init`and `rcc::init_rcc`)
Diffstat (limited to 'embassy-stm32/src/lib.rs')
-rw-r--r--embassy-stm32/src/lib.rs32
1 files changed, 1 insertions, 31 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 444d14f28..3e84d3386 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -213,7 +213,6 @@ macro_rules! bind_interrupts {
213 213
214// Reexports 214// Reexports
215pub use _generated::{peripherals, Peripherals}; 215pub use _generated::{peripherals, Peripherals};
216use critical_section::CriticalSection;
217pub use embassy_hal_internal::{Peri, PeripheralType}; 216pub use embassy_hal_internal::{Peri, PeripheralType};
218#[cfg(feature = "unstable-pac")] 217#[cfg(feature = "unstable-pac")]
219pub use stm32_metapac as pac; 218pub use stm32_metapac as pac;
@@ -601,38 +600,9 @@ fn init_hw(config: Config) -> Peripherals {
601 #[cfg(feature = "exti")] 600 #[cfg(feature = "exti")]
602 exti::init(cs); 601 exti::init(cs);
603 602
604 init_rcc(cs, config.rcc); 603 rcc::init_rcc(cs, config.rcc);
605 } 604 }
606 605
607 p 606 p
608 }) 607 })
609} 608}
610
611/// Re-initialize the `embassy-stm32` clock configuration with the provided configuration.
612///
613/// This is useful when you need to alter the CPU clock after configuring peripherals.
614/// For instance, configure an external clock via spi or i2c.
615///
616/// Please not this only re-configures the rcc and the time driver (not GPIO, EXTI, etc).
617///
618/// This should only be called after `init`.
619#[cfg(not(feature = "_dual-core"))]
620pub fn reinit(config: rcc::Config) {
621 critical_section::with(|cs| init_rcc(cs, config))
622}
623
624fn init_rcc(_cs: CriticalSection, config: rcc::Config) {
625 unsafe {
626 rcc::init(config);
627
628 // must be after rcc init
629 #[cfg(feature = "_time-driver")]
630 time_driver::init(_cs);
631
632 #[cfg(feature = "low-power")]
633 {
634 crate::rcc::REFCOUNT_STOP2 = 0;
635 crate::rcc::REFCOUNT_STOP1 = 0;
636 }
637 }
638}