Use correct frequencies for timers
This commit is contained in:
@ -167,23 +167,23 @@ impl RccExt for RCC {
|
||||
}
|
||||
};
|
||||
|
||||
let apb1_freq = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb1_freq, apb1_tim_freq) = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / pre as u32;
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
let apb2_freq = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb2_freq, apb2_tim_freq) = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / (1 << (pre as u8 - 3));
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
@ -194,6 +194,8 @@ impl RccExt for RCC {
|
||||
ahb3: ahb_freq.hz(),
|
||||
apb1: apb1_freq.hz(),
|
||||
apb2: apb2_freq.hz(),
|
||||
apb1_tim: apb1_tim_freq.hz(),
|
||||
apb2_tim: apb2_tim_freq.hz(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -535,5 +535,7 @@ pub unsafe fn init(config: Config) {
|
||||
apb1: core_clocks.pclk1,
|
||||
apb2: core_clocks.pclk2,
|
||||
apb4: core_clocks.pclk4,
|
||||
apb1_tim: core_clocks.timx_ker_ck.unwrap_or(core_clocks.pclk1),
|
||||
apb2_tim: core_clocks.timy_ker_ck.unwrap_or(core_clocks.pclk2),
|
||||
});
|
||||
}
|
||||
|
@ -353,23 +353,23 @@ impl RccExt for RCC {
|
||||
}
|
||||
};
|
||||
|
||||
let apb1_freq = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb1_freq, apb1_tim_freq) = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / pre as u32;
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
let apb2_freq = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb2_freq, apb2_tim_freq) = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / (1 << (pre as u8 - 3));
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
@ -378,6 +378,8 @@ impl RccExt for RCC {
|
||||
ahb: ahb_freq.hz(),
|
||||
apb1: apb1_freq.hz(),
|
||||
apb2: apb2_freq.hz(),
|
||||
apb1_tim: apb1_tim_freq.hz(),
|
||||
apb2_tim: apb2_tim_freq.hz(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -166,23 +166,23 @@ impl RccExt for RCC {
|
||||
}
|
||||
};
|
||||
|
||||
let apb1_freq = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb1_freq, apb1_tim_freq) = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: u8 = pre.into();
|
||||
let pre: u8 = 1 << (pre - 3);
|
||||
let freq = ahb_freq / pre as u32;
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
let apb2_freq = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb2_freq, apb2_tim_freq) = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: u8 = pre.into();
|
||||
let pre: u8 = 1 << (pre - 3);
|
||||
let freq = ahb_freq / (1 << (pre as u8 - 3));
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
@ -193,6 +193,8 @@ impl RccExt for RCC {
|
||||
ahb3: ahb_freq.hz(),
|
||||
apb1: apb1_freq.hz(),
|
||||
apb2: apb2_freq.hz(),
|
||||
apb1_tim: apb1_tim_freq.hz(),
|
||||
apb2_tim: apb2_tim_freq.hz(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ pub struct Clocks {
|
||||
pub sys: Hertz,
|
||||
pub apb1: Hertz,
|
||||
pub apb2: Hertz,
|
||||
pub apb1_tim: Hertz,
|
||||
pub apb2_tim: Hertz,
|
||||
|
||||
#[cfg(any(rcc_l0))]
|
||||
pub ahb: Hertz,
|
||||
|
@ -166,23 +166,23 @@ impl RccExt for RCC {
|
||||
}
|
||||
};
|
||||
|
||||
let apb1_freq = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb1_freq, apb1_tim_freq) = match cfgr.apb1_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: u8 = pre.into();
|
||||
let pre: u8 = 1 << (pre - 3);
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / pre as u32;
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
let apb2_freq = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => ahb_freq,
|
||||
let (apb2_freq, apb2_tim_freq) = match cfgr.apb2_pre {
|
||||
APBPrescaler::NotDivided => (ahb_freq, ahb_freq),
|
||||
pre => {
|
||||
let pre: u8 = pre.into();
|
||||
let pre: u8 = 1 << (pre - 3);
|
||||
let pre: Ppre = pre.into();
|
||||
let pre: u8 = 1 << (pre.0 - 3);
|
||||
let freq = ahb_freq / (1 << (pre as u8 - 3));
|
||||
freq
|
||||
(freq, freq * 2)
|
||||
}
|
||||
};
|
||||
|
||||
@ -193,6 +193,8 @@ impl RccExt for RCC {
|
||||
ahb3: ahb_freq.hz(),
|
||||
apb1: apb1_freq.hz(),
|
||||
apb2: apb2_freq.hz(),
|
||||
apb1_tim: apb1_tim_freq.hz(),
|
||||
apb2_tim: apb2_tim_freq.hz(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user