aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-stm32/src/rcc/mod.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs
index 3733fed56..c41f81816 100644
--- a/embassy-stm32/src/rcc/mod.rs
+++ b/embassy-stm32/src/rcc/mod.rs
@@ -95,6 +95,15 @@ pub(crate) unsafe fn get_freqs() -> &'static Clocks {
95 unwrap!(CLOCK_FREQS_PTR.load(core::sync::atomic::Ordering::SeqCst).as_ref()).assume_init_ref() 95 unwrap!(CLOCK_FREQS_PTR.load(core::sync::atomic::Ordering::SeqCst).as_ref()).assume_init_ref()
96} 96}
97 97
98/// Get the current clock configuration of the chip.
99pub fn clocks<'a>(_rcc: &'a crate::Peri<'a, crate::peripherals::RCC>) -> &'a Clocks {
100 // Safety: the existence of a `Peri<RCC>` means that `rcc::init()`
101 // has already been called, so `CLOCK_FREQS` must be initialized.
102 // The clocks could be modified again by `reinit()`, but reinit
103 // (for this reason) requires an exclusive reference to `Peri<RCC>`.
104 unsafe { get_freqs() }
105}
106
98pub(crate) trait SealedRccPeripheral { 107pub(crate) trait SealedRccPeripheral {
99 fn frequency() -> Hertz; 108 fn frequency() -> Hertz;
100 #[allow(dead_code)] 109 #[allow(dead_code)]
@@ -381,7 +390,7 @@ pub fn disable<T: RccPeripheral>() {
381/// 390///
382/// This should only be called after `init`. 391/// This should only be called after `init`.
383#[cfg(not(feature = "_dual-core"))] 392#[cfg(not(feature = "_dual-core"))]
384pub fn reinit(config: Config) { 393pub fn reinit<'a>(config: Config, _rcc: &'a mut crate::Peri<'a, crate::peripherals::RCC>) {
385 critical_section::with(|cs| init_rcc(cs, config)) 394 critical_section::with(|cs| init_rcc(cs, config))
386} 395}
387 396