Clocks

Struct Clocks 

Source
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

Source

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.

Source

pub fn calc_speeds(&self) -> Speeds

Calculate clock speeds from a given config. Everything is in Mhz. todo: Handle fractions of mhz. Do floats.

Source

pub fn validate(&self) -> Validation

Check if valid.

Source

pub fn validate_usb(&self) -> Validation

Source

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.

Source

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§

Source§

impl Default for Clocks

Source§

fn default() -> Self

This default configures clocks with a HSE, a 48Mhz sysclck. All peripheral clocks are at 48 Mhz, except for APB1, which is at and 24Mhz. USB is set to 48Mhz. HSE output is not bypassed.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.