diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-04 22:31:55 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-04 22:31:55 +0000 |
| commit | eb57bb298fc2ac3a7bdc10a6a1cf1d44efee31d6 (patch) | |
| tree | 8903eb01f99a30b9e1c7451e7d62a5a8e8f24040 | |
| parent | ce73c29246d59b913efaafdb38414806541e0511 (diff) | |
| parent | 953c745ed86341dba1ce96a15cc03348e1120766 (diff) | |
Merge pull request #1617 from xoviat/const-rcc
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")] |
