From db2bc8783e756d0e10838869603c844d8c276feb Mon Sep 17 00:00:00 2001 From: Marco Pastrello Date: Fri, 5 May 2023 19:04:58 +0200 Subject: [PATCH] Improve readability --- embassy-stm32/src/rcc/f1.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/embassy-stm32/src/rcc/f1.rs b/embassy-stm32/src/rcc/f1.rs index 3c374adf..4769b705 100644 --- a/embassy-stm32/src/rcc/f1.rs +++ b/embassy-stm32/src/rcc/f1.rs @@ -28,10 +28,8 @@ pub struct Config { } pub(crate) unsafe fn init(config: Config) { - let pllsrcclk = config - .hse - .map(|hse| if config.pllxtpre { hse.0 / 2 } else { hse.0 }) - .unwrap_or(HSI_FREQ.0 / 2); + let pllxtpre_div = if config.pllxtpre { 2 } else { 1 }; + let pllsrcclk = config.hse.map(|hse| hse.0 / pllxtpre_div).unwrap_or(HSI_FREQ.0 / 2); let sysclk = config.sys_ck.map(|sys| sys.0).unwrap_or(pllsrcclk); let pllmul = sysclk / pllsrcclk;