Struct stm32f412g::clocks::Clocks

source ·
pub struct Clocks<'a, ChipSpecs> {
    pub hsi: Hsi<'a>,
    pub hse: Hse<'a>,
    pub pll: Pll<'a, ChipSpecs>,
    /* private fields */
}
Expand description

Main struct for configuring on-board clocks.

Fields§

§hsi: Hsi<'a>

High speed internal clock

§hse: Hse<'a>

High speed external clock

§pll: Pll<'a, ChipSpecs>

Main phase loop-lock clock

Implementations§

source§

impl<'a, ChipSpecs> Clocks<'a, ChipSpecs>
where ChipSpecs: ChipSpecs,

source

pub fn new(rcc: &'a Rcc) -> Clocks<'a, ChipSpecs>

source

pub fn set_ahb_prescaler( &self, prescaler: AHBPrescaler, ) -> Result<(), ErrorCode>

Set the AHB prescaler

AHB bus, core, memory, DMA, Cortex System timer and FCLK Cortex free-running clock frequencies are equal to the system clock frequency divided by the AHB prescaler.

§Errors:
source

pub fn get_ahb_prescaler(&self) -> AHBPrescaler

Get the current configured AHB prescaler

source

pub fn get_ahb_frequency_mhz(&self) -> usize

Get the frequency of the AHB

source

pub fn set_apb1_prescaler( &self, prescaler: APBPrescaler, ) -> Result<(), ErrorCode>

Set the APB1 prescaler.

The APB1 peripheral clock frequency is equal to the AHB frequency divided by the APB1 prescaler.

§Errors:
source

pub fn get_apb1_prescaler(&self) -> APBPrescaler

Get the current configured APB1 prescaler

source

pub fn get_apb1_frequency_mhz(&self) -> usize

Get the current APB1 frequency

source

pub fn set_apb2_prescaler( &self, prescaler: APBPrescaler, ) -> Result<(), ErrorCode>

Set the APB2 prescaler.

The APB2 peripheral clock frequency is equal to the AHB frequency divided by the APB2 prescaler.

§Errors:
source

pub fn get_apb2_prescaler(&self) -> APBPrescaler

Get the current configured APB2 prescaler

source

pub fn get_apb2_frequency_mhz(&self) -> usize

Get the current APB2 frequency

source

pub fn set_sys_clock_source( &self, source: SysClockSource, ) -> Result<(), ErrorCode>

Set the system clock source

§Errors:
source

pub fn get_sys_clock_source(&self) -> SysClockSource

Get the current system clock source

source

pub fn get_sys_clock_frequency_mhz(&self) -> usize

Get the current system clock frequency in MHz

source

pub fn _get_sys_clock_frequency_mhz_no_cache(&self) -> usize

Get the current system clock frequency in MHz from RCC registers instead of the cached value. Used for debug only.

source

pub fn set_pll_frequency_mhz( &self, pll_source: PllSource, desired_frequency_mhz: usize, ) -> Result<(), ErrorCode>

Set the frequency of the PLL clock.

§Parameters
  • pll_source: PLL source clock (HSI or HSE)

  • desired_frequency_mhz: the desired frequency in MHz. Supported values: 24-216MHz for STM32F401 and 13-216MHz for all the other chips

§Errors
source

pub fn set_mco1_clock_source(&self, source: MCO1Source) -> Result<(), ErrorCode>

Set the clock source for the microcontroller clock output 1 (MCO1)

§Errors:
source

pub fn get_mco1_clock_source(&self) -> MCO1Source

Get the clock source of the MCO1

source

pub fn set_mco1_clock_divider( &self, divider: MCO1Divider, ) -> Result<(), ErrorCode>

Set MCO1 divider

§Errors:
source

pub fn get_mco1_clock_divider(&self) -> MCO1Divider

Get MCO1 divider

Trait Implementations§

source§

impl<'a, ChipSpecs> Stm32f4Clocks for Clocks<'a, ChipSpecs>
where ChipSpecs: ChipSpecs,

source§

fn get_rcc(&self) -> &'a Rcc

Get RCC instance
source§

fn get_ahb_frequency(&self) -> usize

Get current AHB clock (HCLK) frequency in Hz

Auto Trait Implementations§

§

impl<'a, ChipSpecs> !Freeze for Clocks<'a, ChipSpecs>

§

impl<'a, ChipSpecs> !RefUnwindSafe for Clocks<'a, ChipSpecs>

§

impl<'a, ChipSpecs> !Send for Clocks<'a, ChipSpecs>

§

impl<'a, ChipSpecs> !Sync for Clocks<'a, ChipSpecs>

§

impl<'a, ChipSpecs> Unpin for Clocks<'a, ChipSpecs>
where ChipSpecs: Unpin,

§

impl<'a, ChipSpecs> !UnwindSafe for Clocks<'a, ChipSpecs>

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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.