pub struct Clocks {
pub input_freq: u8,
pub input_src: InputSrc,
pub prediv: Prediv,
pub pll_mul: PllMul,
pub usb_pre: UsbPrescaler,
pub hclk_prescaler: HclkPrescaler,
pub apb1_prescaler: ApbPrescaler,
pub apb2_prescaler: ApbPrescaler,
pub hse_bypass: bool,
pub security_system: bool,
}
Expand description
Settings used to configure clocks
Fields§
§input_freq: u8
§input_src: InputSrc
§prediv: Prediv
§pll_mul: PllMul
§usb_pre: UsbPrescaler
§hclk_prescaler: HclkPrescaler
§apb1_prescaler: ApbPrescaler
§apb2_prescaler: ApbPrescaler
§hse_bypass: bool
§security_system: bool
Implementations§
Source§impl Clocks
impl Clocks
Sourcepub fn setup(&self, rcc: &mut RCC, flash: &mut FLASH) -> Result<(), SpeedError>
pub fn setup(&self, rcc: &mut RCC, flash: &mut FLASH) -> Result<(), SpeedError>
Setup clocks and return a Valid
status if the config is valid. Return
Invalid
, and don’t setup if not.
https://docs.rs/stm32f3xx-hal/0.5.0/stm32f3xx_hal/rcc/struct.CFGR.html
Use the STM32CubeIDE Clock Configuration tab to help.
Sourcepub fn calc_speeds(&self) -> Speeds
pub fn calc_speeds(&self) -> Speeds
Calculate clock speeds from a given config. Everything is in Mhz. todo: Handle fractions of mhz. Do floats.
Sourcepub fn validate(&self) -> Validation
pub fn validate(&self) -> Validation
Check if valid.
pub fn validate_usb(&self) -> Validation
Sourcepub fn make_rcc_clocks(&self) -> Clocks
pub fn make_rcc_clocks(&self) -> Clocks
Make a clocks struct from the rcc
module, that we can pass into existing modules
that use its speeds, like i2c
, serial
, timer
etc.
Sourcepub fn full_speed() -> Self
pub fn full_speed() -> Self
This preset configures clocks with a HSE, a 72Mhz sysclck. All peripheral clocks are at 72Mhz, except for APB1, which is at and 36Mhz. USB is set to 48Mhz. HSE output is not bypassed.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Clocks
impl RefUnwindSafe for Clocks
impl Send for Clocks
impl Sync for Clocks
impl Unpin for Clocks
impl UnwindSafe for Clocks
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more