diff --git a/embassy-stm32/src/rcc/types.rs b/embassy-stm32/src/rcc/types.rs index df7917ab..1fcaa27e 100644 --- a/embassy-stm32/src/rcc/types.rs +++ b/embassy-stm32/src/rcc/types.rs @@ -63,7 +63,7 @@ pub enum PLLMul { } /// AHB prescaler -#[derive(Clone, Copy)] +#[derive(Clone, Copy, PartialEq)] pub enum AHBPrescaler { NotDivided, Div2, diff --git a/embassy-stm32/src/rcc/wl5x/mod.rs b/embassy-stm32/src/rcc/wl5x/mod.rs index 6fa31ce2..554a27ca 100644 --- a/embassy-stm32/src/rcc/wl5x/mod.rs +++ b/embassy-stm32/src/rcc/wl5x/mod.rs @@ -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()); });