stm32/f3: add high res for hrtim and misc.
This commit is contained in:
@ -8,6 +8,8 @@ pub use traits::Instance;
|
||||
#[allow(unused_imports)]
|
||||
use crate::gpio::sealed::{AFType, Pin};
|
||||
use crate::gpio::AnyPin;
|
||||
#[cfg(stm32f334)]
|
||||
use crate::rcc::get_freqs;
|
||||
use crate::time::Hertz;
|
||||
use crate::Peripheral;
|
||||
|
||||
@ -158,17 +160,29 @@ impl<'d, T: Instance> AdvancedPwm<'d, T> {
|
||||
T::enable();
|
||||
<T as crate::rcc::sealed::RccPeripheral>::reset();
|
||||
|
||||
// // Enable and and stabilize the DLL
|
||||
// T::regs().dllcr().modify(|w| {
|
||||
// // w.set_calen(true);
|
||||
// // w.set_calrte(11);
|
||||
// w.set_cal(true);
|
||||
// });
|
||||
//
|
||||
// debug!("wait for dll calibration");
|
||||
// while !T::regs().isr().read().dllrdy() {}
|
||||
//
|
||||
// debug!("dll calibration complete");
|
||||
#[cfg(stm32f334)]
|
||||
if unsafe { get_freqs() }.hrtim.is_some() {
|
||||
// Enable and and stabilize the DLL
|
||||
T::regs().dllcr().modify(|w| {
|
||||
w.set_cal(true);
|
||||
});
|
||||
|
||||
trace!("hrtim: wait for dll calibration");
|
||||
while !T::regs().isr().read().dllrdy() {}
|
||||
|
||||
trace!("hrtim: dll calibration complete");
|
||||
|
||||
// Enable periodic calibration
|
||||
// Cal must be disabled before we can enable it
|
||||
T::regs().dllcr().modify(|w| {
|
||||
w.set_cal(false);
|
||||
});
|
||||
|
||||
T::regs().dllcr().modify(|w| {
|
||||
w.set_calen(true);
|
||||
w.set_calrte(11);
|
||||
});
|
||||
}
|
||||
|
||||
Self {
|
||||
_inner: tim,
|
||||
|
@ -104,7 +104,13 @@ foreach_interrupt! {
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
|
||||
let f = frequency.0;
|
||||
#[cfg(not(stm32f334))]
|
||||
let timer_f = Self::frequency().0;
|
||||
#[cfg(stm32f334)]
|
||||
let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(
|
||||
Self::frequency()
|
||||
).0;
|
||||
|
||||
let psc_min = (timer_f / f) / (u16::MAX as u32 / 32);
|
||||
let psc = if Self::regs().isr().read().dllrdy() {
|
||||
Prescaler::compute_min_high_res(psc_min)
|
||||
@ -125,7 +131,13 @@ foreach_interrupt! {
|
||||
use crate::rcc::sealed::RccPeripheral;
|
||||
|
||||
let f = frequency.0;
|
||||
#[cfg(not(stm32f334))]
|
||||
let timer_f = Self::frequency().0;
|
||||
#[cfg(stm32f334)]
|
||||
let timer_f = unsafe { crate::rcc::get_freqs() }.hrtim.unwrap_or(
|
||||
Self::frequency()
|
||||
).0;
|
||||
|
||||
let psc_min = (timer_f / f) / (u16::MAX as u32 / 32);
|
||||
let psc = if Self::regs().isr().read().dllrdy() {
|
||||
Prescaler::compute_min_high_res(psc_min)
|
||||
|
Reference in New Issue
Block a user