mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-29 21:31:08 +00:00
feat(stm32-l): provide a const
constructor on rcc::Config
This commit is contained in:
parent
156bf00009
commit
65a22439d5
@ -92,6 +92,16 @@ pub struct LsConfig {
|
||||
}
|
||||
|
||||
impl LsConfig {
|
||||
pub const fn new() -> Self {
|
||||
// on L5, just the fact that LSI is enabled makes things crash.
|
||||
// TODO: investigate.
|
||||
|
||||
#[cfg(not(stm32l5))]
|
||||
return Self::default_lsi();
|
||||
#[cfg(stm32l5)]
|
||||
return Self::off();
|
||||
}
|
||||
|
||||
pub const fn default_lse() -> Self {
|
||||
Self {
|
||||
rtc: RtcClockSource::LSE,
|
||||
@ -124,13 +134,7 @@ impl LsConfig {
|
||||
|
||||
impl Default for LsConfig {
|
||||
fn default() -> Self {
|
||||
// on L5, just the fact that LSI is enabled makes things crash.
|
||||
// TODO: investigate.
|
||||
|
||||
#[cfg(not(stm32l5))]
|
||||
return Self::default_lsi();
|
||||
#[cfg(stm32l5)]
|
||||
return Self::off();
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18,9 +18,15 @@ pub struct Hsi48Config {
|
||||
pub sync_from_usb: bool,
|
||||
}
|
||||
|
||||
impl Hsi48Config {
|
||||
pub const fn new() -> Self {
|
||||
Self { sync_from_usb: false }
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Hsi48Config {
|
||||
fn default() -> Self {
|
||||
Self { sync_from_usb: false }
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -68,9 +68,9 @@ pub struct Config {
|
||||
pub mux: super::mux::ClockMux,
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
impl Config {
|
||||
#[inline]
|
||||
fn default() -> Config {
|
||||
pub const fn new() -> Self {
|
||||
Config {
|
||||
hse: None,
|
||||
hsi: false,
|
||||
@ -90,15 +90,22 @@ impl Default for Config {
|
||||
#[cfg(any(stm32l47x, stm32l48x, stm32l49x, stm32l4ax, rcc_l4plus, stm32l5))]
|
||||
pllsai2: None,
|
||||
#[cfg(crs)]
|
||||
hsi48: Some(Default::default()),
|
||||
ls: Default::default(),
|
||||
hsi48: Some(crate::rcc::Hsi48Config::new()),
|
||||
ls: crate::rcc::LsConfig::new(),
|
||||
#[cfg(any(stm32l0, stm32l1))]
|
||||
voltage_scale: VoltageScale::RANGE1,
|
||||
mux: Default::default(),
|
||||
mux: super::mux::ClockMux::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
#[inline]
|
||||
fn default() -> Config {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(stm32wb)]
|
||||
pub const WPAN_DEFAULT: Config = Config {
|
||||
hse: Some(Hse {
|
||||
|
Loading…
x
Reference in New Issue
Block a user