diff --git a/embassy-stm32/Cargo.toml b/embassy-stm32/Cargo.toml index dbf5a69d..b18cafb8 100644 --- a/embassy-stm32/Cargo.toml +++ b/embassy-stm32/Cargo.toml @@ -58,7 +58,7 @@ rand_core = "0.6.3" sdio-host = "0.5.0" embedded-sdmmc = { git = "https://github.com/embassy-rs/embedded-sdmmc-rs", rev = "a4f293d3a6f72158385f79c98634cb8a14d0d2fc", optional = true } critical-section = "1.1" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e4a769aa67aa82603448377daa579d67a789983a" } +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e6e51db6cdd7d533e52ca7a3237f7816a0486cd4" } vcell = "0.1.3" bxcan = "0.7.0" nb = "1.0.0" @@ -76,7 +76,7 @@ critical-section = { version = "1.1", features = ["std"] } [build-dependencies] proc-macro2 = "1.0.36" quote = "1.0.15" -stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e4a769aa67aa82603448377daa579d67a789983a", default-features = false, features = ["metadata"]} +stm32-metapac = { git = "https://github.com/embassy-rs/stm32-data-generated", tag = "stm32-data-e6e51db6cdd7d533e52ca7a3237f7816a0486cd4", default-features = false, features = ["metadata"]} [features] diff --git a/embassy-stm32/build.rs b/embassy-stm32/build.rs index 7ba3a6bd..3e1c76f3 100644 --- a/embassy-stm32/build.rs +++ b/embassy-stm32/build.rs @@ -520,10 +520,16 @@ fn main() { let variant_name = format_ident!("{}", v.name); // temporary hack to restrict the scope of the implementation until clock names can be stabilized - let clock_name = format_ident!("mux_{}", v.name.to_ascii_lowercase()); + let clock_name = format_ident!("{}", v.name.to_ascii_lowercase()); - quote! { - #enum_name::#variant_name => unsafe { crate::rcc::get_freqs().#clock_name.unwrap() }, + if v.name.starts_with("AHB") || v.name.starts_with("APB") { + quote! { + #enum_name::#variant_name => unsafe { crate::rcc::get_freqs().#clock_name }, + } + } else { + quote! { + #enum_name::#variant_name => unsafe { crate::rcc::get_freqs().#clock_name.unwrap() }, + } } }) .collect(); diff --git a/embassy-stm32/src/rcc/h.rs b/embassy-stm32/src/rcc/h.rs index 379d3179..a24f4d4e 100644 --- a/embassy-stm32/src/rcc/h.rs +++ b/embassy-stm32/src/rcc/h.rs @@ -541,61 +541,55 @@ pub(crate) unsafe fn init(config: Config) { apb3, #[cfg(stm32h7)] apb4, + #[cfg(stm32h5)] + apb4: Hertz(1), apb1_tim, apb2_tim, adc, rtc, #[cfg(stm32h5)] - mux_apb1: Some(apb1), + hsi: None, #[cfg(stm32h5)] - mux_apb2: Some(apb2), + hsi48: None, #[cfg(stm32h5)] - mux_apb3: Some(apb3), + lsi: None, #[cfg(stm32h5)] - mux_apb4: None, + csi: None, #[cfg(stm32h5)] - mux_rcc_hclk4: None, + lse: None, + #[cfg(stm32h5)] + hse: None, #[cfg(stm32h5)] - mux_pll2_q: None, + pll1_q: pll1.q, #[cfg(stm32h5)] - mux_pll3_q: None, + pll2_q: pll2.q, #[cfg(stm32h5)] - mux_hsi: None, + pll2_p: pll2.p, #[cfg(stm32h5)] - mux_csi: None, - #[cfg(stm32h5)] - mux_lse: None, - #[cfg(stm32h5)] - mux_pll1_q: pll1.q, - #[cfg(stm32h5)] - mux_pll2_p: pll2.p, + pll2_r: pll2.r, #[cfg(rcc_h5)] - mux_pll3_p: pll3.p, - #[cfg(stm32h5)] - mux_audioclk: None, - #[cfg(stm32h5)] - mux_per: None, - + pll3_p: pll3.p, #[cfg(rcc_h5)] - mux_pll3_r: pll3.r, - #[cfg(all(not(rcc_h5), stm32h5))] - mux_pll3_r: None, + pll3_q: pll3.q, + #[cfg(rcc_h5)] + pll3_r: pll3.r, #[cfg(stm32h5)] - mux_pll3_1: None, - #[cfg(stm32h5)] - mux_hsi48_ker: None, - #[cfg(stm32h5)] - mux_lsi: None, - #[cfg(stm32h5)] - mux_pll2_r: pll2.r, - #[cfg(stm32h5)] - mux_hse: hse, + pll3_1: None, + + #[cfg(rcc_h50)] + pll3_p: None, + #[cfg(rcc_h50)] + pll3_q: None, + #[cfg(rcc_h50)] + pll3_r: None, #[cfg(stm32h5)] - mux_hsi48: None, + audioclk: None, + #[cfg(stm32h5)] + per: None, }); } diff --git a/embassy-stm32/src/rcc/mod.rs b/embassy-stm32/src/rcc/mod.rs index f7210e18..0904ddbd 100644 --- a/embassy-stm32/src/rcc/mod.rs +++ b/embassy-stm32/src/rcc/mod.rs @@ -56,7 +56,7 @@ pub struct Clocks { pub apb2_tim: Hertz, #[cfg(any(rcc_wl5, rcc_wle, rcc_h5, rcc_h50, rcc_h7, rcc_h7rm0433, rcc_h7ab, rcc_u5))] pub apb3: Hertz, - #[cfg(any(rcc_h7, rcc_h7rm0433, rcc_h7ab))] + #[cfg(any(rcc_h7, rcc_h7rm0433, rcc_h7ab, stm32h5))] pub apb4: Hertz, #[cfg(any(rcc_wba))] pub apb7: Hertz, @@ -136,54 +136,40 @@ pub struct Clocks { pub rtc: Option, #[cfg(stm32h5)] - pub mux_apb1: Option, + pub hsi: Option, #[cfg(stm32h5)] - pub mux_apb2: Option, + pub hsi48: Option, #[cfg(stm32h5)] - pub mux_apb3: Option, + pub lsi: Option, #[cfg(stm32h5)] - pub mux_apb4: Option, + pub csi: Option, #[cfg(stm32h5)] - pub mux_rcc_hclk4: Option, + pub lse: Option, + #[cfg(stm32h5)] + pub hse: Option, #[cfg(stm32h5)] - pub mux_pll2_q: Option, + pub pll1_q: Option, #[cfg(stm32h5)] - pub mux_pll3_q: Option, + pub pll2_q: Option, #[cfg(stm32h5)] - pub mux_hsi: Option, + pub pll2_p: Option, #[cfg(stm32h5)] - pub mux_csi: Option, + pub pll2_r: Option, #[cfg(stm32h5)] - pub mux_lse: Option, + pub pll3_p: Option, + #[cfg(stm32h5)] + pub pll3_q: Option, + #[cfg(stm32h5)] + pub pll3_r: Option, + #[cfg(stm32h5)] + pub pll3_1: Option, #[cfg(stm32h5)] - pub mux_pll1_q: Option, + pub audioclk: Option, #[cfg(stm32h5)] - pub mux_pll2_p: Option, - #[cfg(rcc_h5)] - pub mux_pll3_p: Option, - #[cfg(stm32h5)] - pub mux_audioclk: Option, - #[cfg(stm32h5)] - pub mux_per: Option, - - #[cfg(stm32h5)] - pub mux_pll3_r: Option, - #[cfg(stm32h5)] - pub mux_pll3_1: Option, - #[cfg(stm32h5)] - pub mux_hsi48_ker: Option, - #[cfg(stm32h5)] - pub mux_lsi: Option, - #[cfg(stm32h5)] - pub mux_pll2_r: Option, - #[cfg(stm32h5)] - pub mux_hse: Option, - - #[cfg(stm32h5)] - pub mux_hsi48: Option, + pub per: Option, } #[cfg(feature = "low-power")]