Move to internal mod and re-export the enums
This commit is contained in:
parent
88e29608ed
commit
e79d2dd756
@ -601,7 +601,7 @@ fn main() {
|
|||||||
.iter()
|
.iter()
|
||||||
.map(|(_fieldset, fieldname, enum_name)| {
|
.map(|(_fieldset, fieldname, enum_name)| {
|
||||||
quote! {
|
quote! {
|
||||||
pub #fieldname: Option<crate::pac::rcc::vals::#enum_name>
|
pub #fieldname: Option<#enum_name>
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
@ -627,7 +627,15 @@ fn main() {
|
|||||||
})
|
})
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
|
let enum_names: BTreeSet<_> = rcc_cfgr_regs
|
||||||
|
.iter()
|
||||||
|
.map(|(_fieldset, _fieldname, enum_name)| enum_name)
|
||||||
|
.collect();
|
||||||
|
|
||||||
g.extend(quote! {
|
g.extend(quote! {
|
||||||
|
pub mod mux {
|
||||||
|
#(pub use crate::pac::rcc::vals::#enum_names as #enum_names; )*
|
||||||
|
|
||||||
#[derive(Clone, Copy)]
|
#[derive(Clone, Copy)]
|
||||||
pub struct ClockMux {
|
pub struct ClockMux {
|
||||||
#( #struct_fields, )*
|
#( #struct_fields, )*
|
||||||
@ -646,6 +654,7 @@ fn main() {
|
|||||||
#( #inits )*
|
#( #inits )*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -97,10 +97,9 @@ pub struct Config {
|
|||||||
pub adc: AdcClockSource,
|
pub adc: AdcClockSource,
|
||||||
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
||||||
pub adc34: AdcClockSource,
|
pub adc34: AdcClockSource,
|
||||||
#[cfg(stm32f334)]
|
|
||||||
pub hrtim: HrtimClockSource,
|
|
||||||
#[cfg(clock_mux)]
|
#[cfg(clock_mux)]
|
||||||
pub mux: crate::rcc::ClockMux,
|
pub mux: crate::rcc::mux::ClockMux,
|
||||||
|
|
||||||
pub ls: super::LsConfig,
|
pub ls: super::LsConfig,
|
||||||
}
|
}
|
||||||
@ -128,8 +127,7 @@ impl Default for Config {
|
|||||||
adc: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
adc: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
||||||
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
||||||
adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
adc34: AdcClockSource::Hclk(AdcHclkPrescaler::Div1),
|
||||||
#[cfg(stm32f334)]
|
|
||||||
hrtim: HrtimClockSource::BusClk,
|
|
||||||
#[cfg(clock_mux)]
|
#[cfg(clock_mux)]
|
||||||
mux: Default::default(),
|
mux: Default::default(),
|
||||||
}
|
}
|
||||||
@ -350,7 +348,8 @@ pub(crate) unsafe fn init(config: Config) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(stm32f334)]
|
/*
|
||||||
|
TODO: Maybe add something like this to clock_mux? How can we autogenerate the data for this?
|
||||||
let hrtim = match config.hrtim {
|
let hrtim = match config.hrtim {
|
||||||
// Must be configured after the bus is ready, otherwise it won't work
|
// Must be configured after the bus is ready, otherwise it won't work
|
||||||
HrtimClockSource::BusClk => None,
|
HrtimClockSource::BusClk => None,
|
||||||
@ -366,6 +365,7 @@ pub(crate) unsafe fn init(config: Config) {
|
|||||||
Some(pll * 2u32)
|
Some(pll * 2u32)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
*/
|
||||||
|
|
||||||
#[cfg(clock_mux)]
|
#[cfg(clock_mux)]
|
||||||
config.mux.init();
|
config.mux.init();
|
||||||
@ -384,8 +384,6 @@ pub(crate) unsafe fn init(config: Config) {
|
|||||||
adc: Some(adc),
|
adc: Some(adc),
|
||||||
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
#[cfg(all(stm32f3, not(rcc_f37), adc3_common))]
|
||||||
adc34: Some(adc34),
|
adc34: Some(adc34),
|
||||||
#[cfg(stm32f334)]
|
|
||||||
hrtim: hrtim,
|
|
||||||
rtc: rtc,
|
rtc: rtc,
|
||||||
hsi48: hsi48,
|
hsi48: hsi48,
|
||||||
#[cfg(any(rcc_f1, rcc_f1cl, stm32f3))]
|
#[cfg(any(rcc_f1, rcc_f1cl, stm32f3))]
|
||||||
|
|||||||
@ -32,7 +32,7 @@ mod _version;
|
|||||||
pub use _version::*;
|
pub use _version::*;
|
||||||
|
|
||||||
#[cfg(clock_mux)]
|
#[cfg(clock_mux)]
|
||||||
pub use crate::_generated::ClockMux;
|
pub use crate::_generated::mux as mux;
|
||||||
pub use crate::_generated::Clocks;
|
pub use crate::_generated::Clocks;
|
||||||
|
|
||||||
#[cfg(feature = "low-power")]
|
#[cfg(feature = "low-power")]
|
||||||
|
|||||||
@ -28,9 +28,7 @@ async fn main(_spawner: Spawner) {
|
|||||||
config.rcc.apb1_pre = APBPrescaler::DIV2;
|
config.rcc.apb1_pre = APBPrescaler::DIV2;
|
||||||
config.rcc.apb2_pre = APBPrescaler::DIV1;
|
config.rcc.apb2_pre = APBPrescaler::DIV1;
|
||||||
|
|
||||||
// TODO: The two lines here do the same thing
|
config.rcc.mux.hrtim1sw = Some(embassy_stm32::rcc::mux::Timsw::PLL1_P);
|
||||||
config.rcc.hrtim = HrtimClockSource::PllClk;
|
|
||||||
config.rcc.mux.hrtim1sw = Some(embassy_stm32::pac::rcc::vals::Timsw::PLL1_P);
|
|
||||||
}
|
}
|
||||||
let p = embassy_stm32::init(config);
|
let p = embassy_stm32::init(config);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user