pub struct Clocks {
Show 21 fields pub input_src: InputSrc, pub pll_src: PllSrc, pub pll1: PllCfg, pub pll2: PllCfg, pub pll3: PllCfg, pub d1_core_prescaler: HclkPrescaler, pub hclk_prescaler: HclkPrescaler, pub d1_prescaler: ApbPrescaler, pub d2_prescaler1: ApbPrescaler, pub d2_prescaler2: ApbPrescaler, pub d3_prescaler: ApbPrescaler, pub hse_bypass: bool, pub usb_src: UsbSrc, pub security_system: bool, pub hsi48_on: bool, pub stop_wuck: StopWuck, pub vos_range: VosRange, pub sai1_src: SaiSrc, pub sai4a_src: SaiSrc, pub sai4b_src: SaiSrc, pub dfsdm1_src: DfsdmSrc,
}
Expand description

Settings used to configure clocks. Create this struct by using its Default::default() implementation, then modify as required, referencing your RM’s clock tree, or Stm32Cube IDE’s interactive clock manager. Apply settings by running .setup().

Fields

input_src: InputSrc

The main input source

pll_src: PllSrc

The source driving all PLLs.

pll1: PllCfg

Enable and speed status for PLL1. Note that input_src controls if PLL1 is enabled, not pll1.enabled().

pll2: PllCfg

Enable and speed status for PLL2

pll3: PllCfg

Enable and speed status for PLL3

d1_core_prescaler: HclkPrescaler

The prescaler between sysclk and hclk

hclk_prescaler: HclkPrescaler

The value to divide SYSCLK by, to get systick and peripheral clocks. Also known as AHB divider

d1_prescaler: ApbPrescaler

APB3 peripheral clocks

d2_prescaler1: ApbPrescaler

APB1 peripheral clocks

d2_prescaler2: ApbPrescaler

APB2 peripheral clocks

d3_prescaler: ApbPrescaler

APB4 peripheral clocks

hse_bypass: bool

Bypass the HSE output, for use with oscillators that don’t need it. Saves power, and frees up the pin for use as GPIO.

usb_src: UsbSrc

USBOTG kernel clock selection. Defaults to HSI48.

security_system: boolhsi48_on: boolstop_wuck: StopWuckvos_range: VosRangesai1_src: SaiSrc

SAI1 and DFSDM1 kernel Aclk clock source selection

sai4a_src: SaiSrcsai4b_src: SaiSrcdfsdm1_src: DfsdmSrc

DFSDM1 kernel clock source selection

Implementations

Setup common and return Ok if the config is valid. Abort the setup if speeds are invalid. Use the STM32CubeIDE Clock Configuration tab to identify valid configs. Use the default() implementation as a safe baseline. This method also configures the PWR VOS setting, and can be used to enable VOS boost, if vos_range is set to VosRange::VOS0.

Re-select input source; used on Stop and Standby modes, where the system reverts to HSI after wake.

Calculate the input speed to the PLL. This must be between 1 and 16 Mhz. Called refx_ck in the RM.

Calculate VCO output frequency: = Fref1_ck x DIVN1

Check if the PLL is enabled. This is useful if checking whether to re-enable the PLL after exiting Stop or Standby modes, eg so you don’t re-enable if it was already re-enabled in a different context. eg:

if !clock_cfg.pll_is_enabled() {
    clock_cfg.reselect_input();
}

Calculate the sysclock frequency, in hz. Note that for dual core variants, this is for CPU1. CPU2 syclock is equal to the HCLK, so use the hclk() method.

Get the Domain 1 core prescaler frequency, in hz

Get the HCLK frequency, in hz

Get the systick speed. Note that for dual core variants, this is for CPU1. CPU2 systick is equal to the HCLK (possibly divided by 8), so use the hclk() method.

Get the USB clock frequency, in hz

Get the frequency used by APB1 timers, in hz

Get the frequency used by APB2 timers, in hz

Get the SAI1 audio clock frequency, in hz

Full speed of 480Mhz, with VC0 range 0. Correspondingly higher periph clock speeds as well. (520Mhz core speed on H723-35) Note that special consideration needs to be taken when using low power modes (ie anything with wfe or wfi) in this mode; may need to manually disable and re-enable it.

Trait Implementations

This default configures clocks with the HSI, and a 400Mhz sysclock speed. (280Mhz sysclock on variants that only go that high). Note that H723-745 still use this default speed due to needing VOS0 for higher. Peripheral and timer clocks are set to 100Mhz or 200Mhz, depending on their limits. HSE output is not bypassed.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.