From 8bb41a3281ab66fdaef1c460b5674fd23d7257a3 Mon Sep 17 00:00:00 2001 From: Greg V Date: Wed, 2 Feb 2022 22:51:47 +0300 Subject: [PATCH] stm32f3: fix nonexistent cfg tests The rcc code was taken from stm32-rs which uses 'x' features, but embassy uses features with full chip names. Add these 'x' wildcards as cfgs and use them in rcc. They will be useful for USB too. --- embassy-stm32/build.rs | 4 ++++ embassy-stm32/src/rcc/f3.rs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 248941efe..cefd7434a 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -125,6 +125,10 @@ fn main() { println!("cargo:rustc-cfg={}", &chip_name[..chip_name.len() - 2]); } + if chip_name.starts_with("stm32f3") { + println!("cargo:rustc-cfg={}x{}", &chip_name[..9], &chip_name[10..11]); + } + // ======== // Handle time-driver-XXXX features. diff --git a/embassy-stm32/src/rcc/f3.rs b/embassy-stm32/src/rcc/f3.rs index e16e1e499..2727a5b1c 100644 --- a/embassy-stm32/src/rcc/f3.rs +++ b/embassy-stm32/src/rcc/f3.rs @@ -217,8 +217,8 @@ fn calc_pll(config: &Config, Hertz(sysclk): Hertz) -> (Hertz, PllConfig) { cfg_if::cfg_if! { // For some chips PREDIV is always two, and cannot be changed if #[cfg(any( - feature="stm32f302xd", feature="stm32f302xe", feature="stm32f303xd", - feature="stm32f303xe", feature="stm32f398xe" + stm32f302xd, stm32f302xe, stm32f303xd, + stm32f303xe, stm32f398xe ))] { let (multiplier, divisor) = get_mul_div(sysclk, HSI); (