Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rcc: remove mux_prefix from clocks #2058

Merged
merged 1 commit into from
Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions embassy-stm32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]
Expand Down
14 changes: 10 additions & 4 deletions embassy-stm32/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());

quote! {
#enum_name::#variant_name => unsafe { crate::rcc::get_freqs().#clock_name.unwrap() },
let clock_name = format_ident!("{}", v.name.to_ascii_lowercase());

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();
Expand Down
62 changes: 28 additions & 34 deletions embassy-stm32/src/rcc/h.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
#[cfg(stm32h5)]
mux_apb2: Some(apb2),
hsi: None,
#[cfg(stm32h5)]
mux_apb3: Some(apb3),
hsi48: None,
#[cfg(stm32h5)]
mux_apb4: None,

lsi: None,
#[cfg(stm32h5)]
mux_rcc_hclk4: None,
csi: None,

#[cfg(stm32h5)]
mux_pll2_q: None,
#[cfg(stm32h5)]
mux_pll3_q: None,
lse: None,
#[cfg(stm32h5)]
mux_hsi: None,
hse: None,

#[cfg(stm32h5)]
mux_csi: None,
pll1_q: pll1.q,
#[cfg(stm32h5)]
mux_lse: None,
pll2_q: pll2.q,
#[cfg(stm32h5)]
mux_pll1_q: pll1.q,
pll2_p: pll2.p,
#[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,
#[cfg(stm32h5)]
mux_pll3_1: None,
#[cfg(stm32h5)]
mux_hsi48_ker: None,
#[cfg(stm32h5)]
mux_lsi: None,
#[cfg(stm32h5)]
mux_pll2_r: pll2.r,
pll3_q: pll3.q,
#[cfg(rcc_h5)]
pll3_r: pll3.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,
});
}

Expand Down
50 changes: 18 additions & 32 deletions embassy-stm32/src/rcc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -136,54 +136,40 @@ pub struct Clocks {
pub rtc: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_apb1: Option<Hertz>,
pub hsi: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_apb2: Option<Hertz>,
pub hsi48: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_apb3: Option<Hertz>,
pub lsi: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_apb4: Option<Hertz>,
pub csi: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_rcc_hclk4: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_pll2_q: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_pll3_q: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_hsi: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_csi: Option<Hertz>,
pub lse: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_lse: Option<Hertz>,
pub hse: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_pll1_q: Option<Hertz>,
pub pll1_q: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_pll2_p: Option<Hertz>,
#[cfg(rcc_h5)]
pub mux_pll3_p: Option<Hertz>,
pub pll2_q: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_audioclk: Option<Hertz>,
pub pll2_p: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_per: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_pll3_r: Option<Hertz>,
pub pll2_r: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_pll3_1: Option<Hertz>,
pub pll3_p: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_hsi48_ker: Option<Hertz>,
pub pll3_q: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_lsi: Option<Hertz>,
pub pll3_r: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_pll2_r: Option<Hertz>,
#[cfg(stm32h5)]
pub mux_hse: Option<Hertz>,
pub pll3_1: Option<Hertz>,

#[cfg(stm32h5)]
pub mux_hsi48: Option<Hertz>,
pub audioclk: Option<Hertz>,
#[cfg(stm32h5)]
pub per: Option<Hertz>,
}

#[cfg(feature = "low-power")]
Expand Down