pub struct CFGR { /* private fields */ }
Expand description
Clock configuration
An instance of this struct is acquired from the RCC
struct.
let dp = pac::Peripherals::take().unwrap();
let rcc = dp.RCC.constrain();
use_cfgr(&mut rcc.cfgr)
Implementations§
Source§impl CFGR
impl CFGR
Sourcepub fn use_pll(self) -> Self
pub fn use_pll(self) -> Self
Set this to disallow bypass the PLLCLK for the systemclock generation.
Sourcepub fn bypass_hse(self) -> Self
pub fn bypass_hse(self) -> Self
Enable HSE
bypass.
Uses user provided clock signal instead of an external oscillator.
OSC_OUT
pin is free and can be used as GPIO.
No effect if HSE
is not enabled.
Sourcepub fn enable_css(self) -> Self
pub fn enable_css(self) -> Self
Enable CSS
(Clock Security System).
System clock is automatically switched to HSI
and an interrupt (CSSI
) is generated
when HSE
clock failure is detected.
No effect if HSE
is not enabled.
Sourcepub fn hclk(self, freq: Megahertz) -> Self
pub fn hclk(self, freq: Megahertz) -> Self
Sets a frequency for the AHB bus.
§Panics
Panics if conversion from Megahertz
to Hertz
produces a value greater then u32::MAX
.
Sourcepub fn pclk1(self, freq: Megahertz) -> Self
pub fn pclk1(self, freq: Megahertz) -> Self
Sets a frequency for the APB1
bus
- Maximal supported frequency: 36 Mhz
If not manually set, it will be set to CFGR::sysclk
frequency
or CFGR::sysclk
frequency / 2, if CFGR::sysclk
> 36 Mhz
§Panics
Panics if conversion from Megahertz
to Hertz
produces a value greater then u32::MAX
.
Sourcepub fn pclk2(self, freq: Megahertz) -> Self
pub fn pclk2(self, freq: Megahertz) -> Self
Sets a frequency for the APB2
bus
§Resolution and Limits
- Maximal supported frequency with HSE: 72 Mhz
- Maximal supported frequency without HSE: 64 Mhz
This is true for devices except the following devices, as these allow finer resolutions even when using the internal oscillator:
[stm32f302xd,stm32f302xe,stm32f303xd,stm32f303xe,stm32f398]
§Panics
Panics if conversion from Megahertz
to Hertz
produces a value greater then u32::MAX
.
Sourcepub fn sysclk(self, freq: Megahertz) -> Self
pub fn sysclk(self, freq: Megahertz) -> Self
Sets the system (core) frequency
§Resolution and Limits
- Maximal supported frequency with
HSE
: 72 Mhz - Maximal supported frequency without
HSE
: 64 Mhz
If CFGR::use_hse
is not set, HSI / 2
will be used.
Only multiples of (HSI / 2) (4 Mhz) are allowed.
This is true for devices except the following devices, as these allow finer resolutions even when using the internal oscillator:
[stm32f302xd,stm32f302xe,stm32f303xd,stm32f303xe,stm32f398]
§Panics
Panics if conversion from Megahertz
to Hertz
produces a value greater then u32::MAX
.
Sourcepub fn freeze(self, acr: &mut ACR) -> Clocks
pub fn freeze(self, acr: &mut ACR) -> Clocks
Freezes the clock configuration, making it effective
This function internally calculates the specific. divisors for the different clock peripheries.
§Panics
If any of the set frequencies via sysclk
, hclk
, pclk1
or pclk2
are invalid or can not be reached because of e.g. to low frequencies
of the former, as sysclk
depends on the configuration of hclk
this function will panic.