Use builder
This commit is contained in:
parent
a41a812345
commit
3669eba561
@ -46,8 +46,9 @@ pub struct Config {
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new(rcc: rcc::Config) -> Self {
|
||||
Self { rcc }
|
||||
pub fn rcc(mut self, rcc: rcc::Config) -> Self {
|
||||
self.rcc = rcc;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -224,49 +224,6 @@ impl Config {
|
||||
self.apb2_pre = pre;
|
||||
self
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hsi16() -> Config {
|
||||
Config {
|
||||
mux: ClockSrc::HSI16,
|
||||
ahb_pre: AHBPrescaler::NotDivided,
|
||||
apb1_pre: APBPrescaler::NotDivided,
|
||||
apb2_pre: APBPrescaler::NotDivided,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn msi(range: MSIRange) -> Config {
|
||||
Config {
|
||||
mux: ClockSrc::MSI(range),
|
||||
ahb_pre: AHBPrescaler::NotDivided,
|
||||
apb1_pre: APBPrescaler::NotDivided,
|
||||
apb2_pre: APBPrescaler::NotDivided,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pll(pll_src: PLLSource, pll_mul: PLLMul, pll_div: PLLDiv) -> Config {
|
||||
Config {
|
||||
mux: ClockSrc::PLL(pll_src, pll_mul, pll_div),
|
||||
ahb_pre: AHBPrescaler::NotDivided,
|
||||
apb1_pre: APBPrescaler::NotDivided,
|
||||
apb2_pre: APBPrescaler::NotDivided,
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn hse<T>(freq: T) -> Config
|
||||
where
|
||||
T: Into<Hertz>,
|
||||
{
|
||||
Config {
|
||||
mux: ClockSrc::HSE(freq.into()),
|
||||
ahb_pre: AHBPrescaler::NotDivided,
|
||||
apb1_pre: APBPrescaler::NotDivided,
|
||||
apb2_pre: APBPrescaler::NotDivided,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// RCC peripheral
|
||||
|
Loading…
Reference in New Issue
Block a user