diff options
| author | xoviat <[email protected]> | 2023-07-04 16:29:46 -0500 |
|---|---|---|
| committer | xoviat <[email protected]> | 2023-07-04 16:29:46 -0500 |
| commit | 953c745ed86341dba1ce96a15cc03348e1120766 (patch) | |
| tree | 7d1f8c87f4cafa092925df147c810396d85715fc | |
| parent | 99b4ea7c1dd5d2d10020ae569b878231c6c00524 (diff) | |
stm32/rcc: allow const-propagation
| -rw-r--r-- | embassy-stm32/build.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/rcc/mod.rs | 4 |
2 files changed, 3 insertions, 5 deletions
diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index fa66da1f6..995ad1443 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs | |||
| @@ -348,9 +348,7 @@ fn main() { | |||
| 348 | g.extend(quote! { | 348 | g.extend(quote! { |
| 349 | impl crate::rcc::sealed::RccPeripheral for peripherals::#pname { | 349 | impl crate::rcc::sealed::RccPeripheral for peripherals::#pname { |
| 350 | fn frequency() -> crate::time::Hertz { | 350 | fn frequency() -> crate::time::Hertz { |
| 351 | critical_section::with(|_| unsafe { | 351 | unsafe { crate::rcc::get_freqs().#clk } |
| 352 | crate::rcc::get_freqs().#clk | ||
| 353 | }) | ||
| 354 | } | 352 | } |
| 355 | fn enable() { | 353 | fn enable() { |
| 356 | critical_section::with(|_| { | 354 | critical_section::with(|_| { |
diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index d6816d6a8..886fc0b93 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs | |||
| @@ -83,12 +83,12 @@ static mut CLOCK_FREQS: MaybeUninit<Clocks> = MaybeUninit::uninit(); | |||
| 83 | /// Safety: Sets a mutable global. | 83 | /// Safety: Sets a mutable global. |
| 84 | pub(crate) unsafe fn set_freqs(freqs: Clocks) { | 84 | pub(crate) unsafe fn set_freqs(freqs: Clocks) { |
| 85 | debug!("rcc: {:?}", freqs); | 85 | debug!("rcc: {:?}", freqs); |
| 86 | CLOCK_FREQS.as_mut_ptr().write(freqs); | 86 | CLOCK_FREQS = MaybeUninit::new(freqs); |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | /// Safety: Reads a mutable global. | 89 | /// Safety: Reads a mutable global. |
| 90 | pub(crate) unsafe fn get_freqs() -> &'static Clocks { | 90 | pub(crate) unsafe fn get_freqs() -> &'static Clocks { |
| 91 | &*CLOCK_FREQS.as_ptr() | 91 | CLOCK_FREQS.assume_init_ref() |
| 92 | } | 92 | } |
| 93 | 93 | ||
| 94 | #[cfg(feature = "unstable-pac")] | 94 | #[cfg(feature = "unstable-pac")] |
