diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-02-02 22:42:32 +0100 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-02-02 23:24:34 +0100 |
| commit | 98668473756b144cb5e5d7bb2be4b54b947412ff (patch) | |
| tree | 34a61f2ba8c3fa13eacb9cab6fc9928e839da61a /embassy-stm32/src/hrtim | |
| parent | a099084bffe621f45fc798cec26164b96a8984aa (diff) | |
stm32: autogenerate clocks struct, enable mux for all chips.
Diffstat (limited to 'embassy-stm32/src/hrtim')
| -rw-r--r-- | embassy-stm32/src/hrtim/mod.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/hrtim/traits.rs | 16 |
2 files changed, 11 insertions, 9 deletions
diff --git a/embassy-stm32/src/hrtim/mod.rs b/embassy-stm32/src/hrtim/mod.rs index faefaabbc..3ec646fc3 100644 --- a/embassy-stm32/src/hrtim/mod.rs +++ b/embassy-stm32/src/hrtim/mod.rs | |||
| @@ -10,8 +10,6 @@ pub use traits::Instance; | |||
| 10 | #[allow(unused_imports)] | 10 | #[allow(unused_imports)] |
| 11 | use crate::gpio::sealed::{AFType, Pin}; | 11 | use crate::gpio::sealed::{AFType, Pin}; |
| 12 | use crate::gpio::AnyPin; | 12 | use crate::gpio::AnyPin; |
| 13 | #[cfg(stm32f334)] | ||
| 14 | use crate::rcc::get_freqs; | ||
| 15 | use crate::time::Hertz; | 13 | use crate::time::Hertz; |
| 16 | use crate::Peripheral; | 14 | use crate::Peripheral; |
| 17 | 15 | ||
| @@ -182,7 +180,7 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> { | |||
| 182 | T::enable_and_reset(); | 180 | T::enable_and_reset(); |
| 183 | 181 | ||
| 184 | #[cfg(stm32f334)] | 182 | #[cfg(stm32f334)] |
| 185 | if unsafe { get_freqs() }.hrtim.is_some() { | 183 | if crate::pac::RCC.cfgr3().read().hrtim1sw() == crate::pac::rcc::vals::Timsw::PLL1_P { |
| 186 | // Enable and and stabilize the DLL | 184 | // Enable and and stabilize the DLL |
| 187 | T::regs().dllcr().modify(|w| { | 185 | T::regs().dllcr().modify(|w| { |
| 188 | w.set_cal(true); | 186 | w.set_cal(true); |
diff --git a/embassy-stm32/src/hrtim/traits.rs b/embassy-stm32/src/hrtim/traits.rs index cfd31c47c..dcc2b9ef4 100644 --- a/embassy-stm32/src/hrtim/traits.rs +++ b/embassy-stm32/src/hrtim/traits.rs | |||
| @@ -80,10 +80,12 @@ pub(crate) mod sealed { | |||
| 80 | 80 | ||
| 81 | fn set_master_frequency(frequency: Hertz) { | 81 | fn set_master_frequency(frequency: Hertz) { |
| 82 | let f = frequency.0; | 82 | let f = frequency.0; |
| 83 | #[cfg(not(stm32f334))] | 83 | |
| 84 | // TODO: wire up HRTIM to the RCC mux infra. | ||
| 85 | //#[cfg(stm32f334)] | ||
| 86 | //let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(Self::frequency()).0; | ||
| 87 | //#[cfg(not(stm32f334))] | ||
| 84 | let timer_f = Self::frequency().0; | 88 | let timer_f = Self::frequency().0; |
| 85 | #[cfg(stm32f334)] | ||
| 86 | let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(Self::frequency()).0; | ||
| 87 | 89 | ||
| 88 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); | 90 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); |
| 89 | let psc = if Self::regs().isr().read().dllrdy() { | 91 | let psc = if Self::regs().isr().read().dllrdy() { |
| @@ -103,10 +105,12 @@ pub(crate) mod sealed { | |||
| 103 | 105 | ||
| 104 | fn set_channel_frequency(channel: usize, frequency: Hertz) { | 106 | fn set_channel_frequency(channel: usize, frequency: Hertz) { |
| 105 | let f = frequency.0; | 107 | let f = frequency.0; |
| 106 | #[cfg(not(stm32f334))] | 108 | |
| 109 | // TODO: wire up HRTIM to the RCC mux infra. | ||
| 110 | //#[cfg(stm32f334)] | ||
| 111 | //let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(Self::frequency()).0; | ||
| 112 | //#[cfg(not(stm32f334))] | ||
| 107 | let timer_f = Self::frequency().0; | 113 | let timer_f = Self::frequency().0; |
| 108 | #[cfg(stm32f334)] | ||
| 109 | let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(Self::frequency()).0; | ||
| 110 | 114 | ||
| 111 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); | 115 | let psc_min = (timer_f / f) / (u16::MAX as u32 / 32); |
| 112 | let psc = if Self::regs().isr().read().dllrdy() { | 116 | let psc = if Self::regs().isr().read().dllrdy() { |
