Prescaler 1 means divide by 3 on WL55

This commit is contained in:
Ulf Lilleengen 2021-06-16 16:21:16 +02:00
parent 383beb37b3
commit 56c5218292
2 changed files with 6 additions and 2 deletions

View File

@ -63,7 +63,7 @@ pub enum PLLMul {
}
/// AHB prescaler
#[derive(Clone, Copy)]
#[derive(Clone, Copy, PartialEq)]
pub enum AHBPrescaler {
NotDivided,
Div2,

View File

@ -164,7 +164,11 @@ impl RccExt for RCC {
unsafe {
rcc.cfgr().modify(|w| {
w.set_sw(sw.into());
w.set_hpre(cfgr.ahb_pre.into());
if cfgr.ahb_pre == AHBPrescaler::NotDivided {
w.set_hpre(0);
} else {
w.set_hpre(cfgr.ahb_pre.into());
}
w.set_ppre1(cfgr.apb1_pre.into());
w.set_ppre2(cfgr.apb2_pre.into());
});