aboutsummaryrefslogtreecommitdiff
path: root/embassy-stm32
diff options
context:
space:
mode:
authorMichael Medin <[email protected]>2025-04-24 07:15:11 +0200
committerMichael Medin <[email protected]>2025-04-24 07:15:11 +0200
commit8cf8fb324ce9063890d8912cccd02bc79fbffd1d (patch)
tree86c10afe63ac8691daa076a078cc561a608ca24d /embassy-stm32
parent8474e573fbde99adb3b6f0384b4f68d04cf25e9e (diff)
Add function to allow re-init rcc config for stm32
Diffstat (limited to 'embassy-stm32')
-rw-r--r--embassy-stm32/src/lib.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/embassy-stm32/src/lib.rs b/embassy-stm32/src/lib.rs
index 226293a9d..0cc6886d9 100644
--- a/embassy-stm32/src/lib.rs
+++ b/embassy-stm32/src/lib.rs
@@ -616,3 +616,31 @@ fn init_hw(config: Config) -> Peripherals {
616 p 616 p
617 }) 617 })
618} 618}
619
620
621/// Re-initialize the `embassy-stm32` clock configuration with the provided configuration.
622///
623/// This is useful when you need to alter the CPU clock after configuring peripherals.
624/// For instance, configure an external clock via spi or i2c.
625///
626/// Please not this only re-configures the rcc and the time driver (not GPIO, EXTI, etc).
627///
628/// This should only be called after `init`.
629#[cfg(not(feature = "_dual-core"))]
630pub fn reinitialize_rcc(config: Config) {
631 critical_section::with(|cs| {
632 unsafe {
633 rcc::init(config.rcc);
634
635 // must be after rcc init
636 #[cfg(feature = "_time-driver")]
637 time_driver::init(cs);
638
639 #[cfg(feature = "low-power")]
640 {
641 crate::rcc::REFCOUNT_STOP2 = 0;
642 crate::rcc::REFCOUNT_STOP1 = 0;
643 }
644 }
645 })
646}