Move to a single Mux Struct.
This commit is contained in:
parent
e99ef49611
commit
2ee9b37373
3 changed files with 18 additions and 22 deletions
|
@ -430,7 +430,7 @@ fn main() {
|
||||||
|
|
||||||
let mut clock_names = BTreeSet::new();
|
let mut clock_names = BTreeSet::new();
|
||||||
|
|
||||||
let mut rcc_cfgr_regs = BTreeMap::new();
|
let mut rcc_cfgr_regs = BTreeSet::new();
|
||||||
|
|
||||||
for p in METADATA.peripherals {
|
for p in METADATA.peripherals {
|
||||||
if !singletons.contains(&p.name.to_string()) {
|
if !singletons.contains(&p.name.to_string()) {
|
||||||
|
@ -510,11 +510,7 @@ fn main() {
|
||||||
let field_name = format_ident!("{}", field_name);
|
let field_name = format_ident!("{}", field_name);
|
||||||
let enum_name = format_ident!("{}", enum_name);
|
let enum_name = format_ident!("{}", enum_name);
|
||||||
|
|
||||||
if !rcc_cfgr_regs.contains_key(mux.register) {
|
rcc_cfgr_regs.insert((
|
||||||
rcc_cfgr_regs.insert(mux.register, Vec::new());
|
|
||||||
}
|
|
||||||
|
|
||||||
rcc_cfgr_regs.get_mut(mux.register).unwrap().push((
|
|
||||||
fieldset_name.clone(),
|
fieldset_name.clone(),
|
||||||
field_name.clone(),
|
field_name.clone(),
|
||||||
enum_name.clone(),
|
enum_name.clone(),
|
||||||
|
@ -602,10 +598,10 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (rcc_cfgr_reg, fields) in rcc_cfgr_regs {
|
if !rcc_cfgr_regs.is_empty() {
|
||||||
println!("cargo:rustc-cfg={}", rcc_cfgr_reg.to_ascii_lowercase());
|
println!("cargo:rustc-cfg=clock_mux");
|
||||||
|
|
||||||
let struct_fields: Vec<_> = fields
|
let struct_fields: Vec<_> = rcc_cfgr_regs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_fieldset, fieldname, enum_name)| {
|
.map(|(_fieldset, fieldname, enum_name)| {
|
||||||
quote! {
|
quote! {
|
||||||
|
@ -614,12 +610,12 @@ fn main() {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let field_names: Vec<_> = fields
|
let field_names: Vec<_> = rcc_cfgr_regs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(_fieldset, fieldname, _enum_name)| fieldname)
|
.map(|(_fieldset, fieldname, _enum_name)| fieldname)
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let inits: Vec<_> = fields
|
let inits: Vec<_> = rcc_cfgr_regs
|
||||||
.iter()
|
.iter()
|
||||||
.map(|(fieldset, fieldname, _enum_name)| {
|
.map(|(fieldset, fieldname, _enum_name)| {
|
||||||
let setter = format_ident!("set_{}", fieldname);
|
let setter = format_ident!("set_{}", fieldname);
|
||||||
|
@ -635,15 +631,13 @@ fn main() {
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
let cfgr_reg = format_ident!("{}", rcc_cfgr_reg);
|
|
||||||
|
|
||||||
g.extend(quote! {
|
g.extend(quote! {
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct #cfgr_reg {
|
pub struct ClockMux {
|
||||||
#( #struct_fields, )*
|
#( #struct_fields, )*
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for #cfgr_reg {
|
impl Default for ClockMux {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
#( #field_names: None, )*
|
#( #field_names: None, )*
|
||||||
|
@ -651,7 +645,7 @@ fn main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl #cfgr_reg {
|
impl ClockMux {
|
||||||
pub fn init(self) {
|
pub fn init(self) {
|
||||||
#( #inits )*
|
#( #inits )*
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,8 +99,8 @@ pub struct Config {
|
||||||
pub adc34: AdcClockSource,
|
pub adc34: AdcClockSource,
|
||||||
#[cfg(stm32f334)]
|
#[cfg(stm32f334)]
|
||||||
pub hrtim: HrtimClockSource,
|
pub hrtim: HrtimClockSource,
|
||||||
#[cfg(cfgr3)]
|
#[cfg(clock_mux)]
|
||||||
pub cfgr3: crate::_generated::CFGR3,
|
pub mux: crate::rcc::ClockMux,
|
||||||
|
|
||||||
pub ls: super::LsConfig,
|
pub ls: super::LsConfig,
|
||||||
}
|
}
|
||||||
|
@ -130,8 +130,8 @@ impl Default for Config {
|
||||||
adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
||||||
#[cfg(stm32f334)]
|
#[cfg(stm32f334)]
|
||||||
hrtim: HrtimClockSource::BusClk,
|
hrtim: HrtimClockSource::BusClk,
|
||||||
#[cfg(cfgr3)]
|
#[cfg(clock_mux)]
|
||||||
cfgr3: Default::default(),
|
mux: Default::default(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -367,8 +367,8 @@ pub(crate) unsafe fn init(config: Config) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(cfgr3)]
|
#[cfg(clock_mux)]
|
||||||
config.cfgr3.init();
|
config.mux.init();
|
||||||
|
|
||||||
set_clocks!(
|
set_clocks!(
|
||||||
hsi: hsi,
|
hsi: hsi,
|
||||||
|
|
|
@ -32,6 +32,8 @@ mod _version;
|
||||||
pub use _version::*;
|
pub use _version::*;
|
||||||
|
|
||||||
pub use crate::_generated::Clocks;
|
pub use crate::_generated::Clocks;
|
||||||
|
#[cfg(clock_mux)]
|
||||||
|
pub use crate::_generated::ClockMux;
|
||||||
|
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
/// Must be written within a critical section
|
/// Must be written within a critical section
|
||||||
|
|
Loading…
Reference in a new issue