Struct stm32_hal2::clocks::Clocks[][src]

pub struct Clocks {
    pub input_src: InputSrc,
    pub pll: PllCfg,
    pub pllsai1: PllCfg,
    pub hclk_prescaler: HclkPrescaler,
    pub apb1_prescaler: ApbPrescaler,
    pub apb2_prescaler: ApbPrescaler,
    pub clk48_src: Clk48Src,
    pub hse_bypass: bool,
    pub security_system: bool,
    pub hsi48_on: bool,
    pub stop_wuck: StopWuck,
    pub sai1_src: SaiSrc,
}
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 input source for the system and peripheral clocks. Eg HSE, HSI, PLL etc

pll: PllCfg

Enable and speed status for the main PLL

pllsai1: PllCfg

Enable and speed status for the SAI PLL

hclk_prescaler: HclkPrescaler

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

apb1_prescaler: ApbPrescaler

The divider of HCLK to get the APB1 peripheral clock

apb2_prescaler: ApbPrescaler

The divider of HCLK to get the APB2 peripheral clock

clk48_src: Clk48Src

The input source for the 48Mhz clock used by USB.

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.

security_system: boolhsi48_on: bool

Enable the HSI48. For L4, this is only applicable for some devices.

stop_wuck: StopWuck

Select the input source to use after waking up from stop mode. Eg HSI or MSI.

sai1_src: SaiSrc

SAI1 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 help identify valid configs. Use the default() implementation as a safe baseline.

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

Use this to change the MSI speed. Run this only if your clock source is MSI. Ends in a state with MSI on at the new speed, and HSI off.

Enables MSI, and configures it at 48Mhz, and trims it using the LSE. This is useful when using it as the USB clock, ie with clk48_src: Clk48Src::Msi. Don’t use this if using MSI for the input source or PLL source. You may need to re-run this after exiting stop mode. Only works for USB if you have an LSE connected. Note: MSIPLLEN must be enabled after LSE is enabled. So, run this function after RCC clock setup.

Calculate the systick, and input frequency, in Hz.

Check if the PLL is enabled. This is useful if checking wheather 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();
}

Get the SAI audio clock freq

Trait Implementations

This default configures clocks with a HSI, with system and peripheral clocks at full rated speed. All peripheral. Speeds -> L4: 80Mhz. L5: 110Mhz. G0: 64Mhz. G4: 170Mhz. WB: 64Mhz.

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

Performs the conversion.

Performs the conversion.

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.