diff --git a/ci.sh b/ci.sh index ba250fa67..4dc76cb69 100755 --- a/ci.sh +++ b/ci.sh @@ -85,6 +85,7 @@ cargo batch \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt,exti \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv8m.main-none-eabihf --features stm32l552ze,defmt \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f072c8,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f401ve,defmt,exti,time-driver-any \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f405zg,defmt,exti,time-driver-any \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32f407zg,defmt,exti,time-driver-any \ @@ -111,6 +112,7 @@ cargo batch \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h755zi-cm7,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h725re,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32h7b3ai,defmt,exti,time-driver-any,time \ + --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l431cb,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l476vg,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32l422cb,defmt,exti,time-driver-any,time \ --- build --release --manifest-path embassy-stm32/Cargo.toml --target thumbv7em-none-eabi --features stm32wb15cc,defmt,exti,time-driver-any,time \ diff --git a/embassy-stm32/src/rcc/f0.rs b/embassy-stm32/src/rcc/f0.rs index a6b627887..d99fd0476 100644 --- a/embassy-stm32/src/rcc/f0.rs +++ b/embassy-stm32/src/rcc/f0.rs @@ -11,14 +11,13 @@ pub const HSI_FREQ: Hertz = Hertz(8_000_000); /// /// hse takes precedence over hsi48 if both are enabled #[non_exhaustive] -#[derive(Default)] pub struct Config { pub hse: Option, pub bypass_hse: bool, pub usb_pll: bool, - #[cfg(not(stm32f0x0))] - pub hsi48: bool, + #[cfg(crs)] + pub hsi48: Option, pub sys_ck: Option, pub hclk: Option, @@ -27,12 +26,31 @@ pub struct Config { pub ls: super::LsConfig, } +impl Default for Config { + fn default() -> Self { + Self { + hse: Default::default(), + bypass_hse: Default::default(), + usb_pll: Default::default(), + hsi48: Some(Default::default()), + sys_ck: Default::default(), + hclk: Default::default(), + pclk: Default::default(), + ls: Default::default(), + } + } +} + pub(crate) unsafe fn init(config: Config) { let sysclk = config.sys_ck.map(|v| v.0).unwrap_or(HSI_FREQ.0); + #[cfg(crs)] + let hsi48 = config.hsi48.map(|config| super::init_hsi48(config)); + #[cfg(not(crs))] + let hsi48: Option = None; + let (src_clk, use_hsi48) = config.hse.map(|v| (v.0, false)).unwrap_or_else(|| { - #[cfg(not(stm32f0x0))] - if config.hsi48 { + if hsi48.is_some() { return (48_000_000, true); } (HSI_FREQ.0, false) @@ -169,5 +187,9 @@ pub(crate) unsafe fn init(config: Config) { pclk2_tim: Some(Hertz(pclk * timer_mul)), hclk1: Some(Hertz(hclk)), rtc: rtc, + hsi48: hsi48, + + // TODO: + pll1_p: None, ); } diff --git a/embassy-stm32/src/rcc/l.rs b/embassy-stm32/src/rcc/l.rs index ab1681dd4..04ea81ec4 100644 --- a/embassy-stm32/src/rcc/l.rs +++ b/embassy-stm32/src/rcc/l.rs @@ -215,12 +215,9 @@ pub(crate) unsafe fn init(config: Config) { }); #[cfg(crs)] - let _hsi48 = config.hsi48.map(|config| { - // - super::init_hsi48(config) - }); + let hsi48 = config.hsi48.map(|config| super::init_hsi48(config)); #[cfg(not(crs))] - let _hsi48: Option = None; + let hsi48: Option = None; let _plls = [ &config.pll, @@ -274,12 +271,12 @@ pub(crate) unsafe fn init(config: Config) { RCC.ccipr().modify(|w| w.set_clk48sel(config.clk48_src)); #[cfg(any(rcc_l0_v2))] let clk48 = match config.clk48_src { - Clk48Src::HSI48 => _hsi48, + Clk48Src::HSI48 => hsi48, Clk48Src::PLL1_VCO_DIV_2 => pll.clk48, }; #[cfg(any(stm32l4, stm32l5, stm32wb))] let clk48 = match config.clk48_src { - Clk48Src::HSI48 => _hsi48, + Clk48Src::HSI48 => hsi48, Clk48Src::MSI => msi, Clk48Src::PLLSAI1_Q => pllsai1.q, Clk48Src::PLL1_Q => pll.q, @@ -393,6 +390,7 @@ pub(crate) unsafe fn init(config: Config) { msi: msi, #[cfg(any(rcc_l0_v2, stm32l4, stm32l5, stm32wb))] clk48: clk48, + hsi48: hsi48, #[cfg(not(any(stm32l0, stm32l1)))] pll1_p: pll.p, @@ -407,6 +405,13 @@ pub(crate) unsafe fn init(config: Config) { #[cfg(any(stm32l4, stm32l5, stm32wb))] pllsai1_r: pllsai1.r, + #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))] + pllsai2_p: None, + #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))] + pllsai2_q: None, + #[cfg(not(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5)))] + pllsai2_r: None, + #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))] pllsai2_p: pllsai2.p, #[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]