pub struct CFGR { /* private fields */ }Expand description
Clock configuration register.
Implementations§
Source§impl CFGR
impl CFGR
Sourcepub fn hclk(self, freq: Hertz) -> Self
pub fn hclk(self, freq: Hertz) -> Self
Sets HCLK frequency.
The HCLK is used for the AHB bus, core, memory and DMA.
§Panics
Panics if the frequency is larger than 216 MHz.
Sourcepub fn sysclk(self, sysclk: Hertz) -> Self
pub fn sysclk(self, sysclk: Hertz) -> Self
Sets the SYSCLK frequency.
This sets the SYSCLK frequency and sets up the USB clock if defined. The provided frequency must be between 12.5 Mhz and 216 Mhz. 12.5 Mhz is the VCO minimum frequency and SYSCLK PLLP divider limitation. If the ethernet peripheral is on, the user should set a frequency higher than 25 Mhz.
§Panics
Panics if the frequency is not between 12.5 MHz and 216 MHz.
Sourcepub fn pclk1(self, freq: Hertz) -> Self
pub fn pclk1(self, freq: Hertz) -> Self
Sets the PCLK1 clock (APB1 clock).
If this method isn’t called the maximum allowed frequency is used for PCLK1.
§Panics
Panics if the frequency is not between 12.5 MHz and 54 MHz.
Sourcepub fn pclk2(self, freq: Hertz) -> Self
pub fn pclk2(self, freq: Hertz) -> Self
Sets PCLK2 clock (APB2 clock).
If this method isn’t called the maximum allowed frequency is used for PCLK2.
§Panics
Panics if the frequency is not between 12.5 MHz and 108 MHz.
Sourcepub fn lsi(self) -> Self
pub fn lsi(self) -> Self
Sets the LSI clock source to 32 kHz.
Be aware that the tolerance is up to ±47% (Min 17 kHz, Typ 32 kHz, Max 47 kHz).
Sourcepub fn use_pll(self) -> Self
pub fn use_pll(self) -> Self
Sets the SYSCLK clock source to the main PLL.
Note: sysclk must be specified or use_pll48clk must be set to true, otherwise use_pll is reset to false.
Sourcepub fn use_pll48clk(self, pll48clk: PLL48CLK) -> Self
pub fn use_pll48clk(self, pll48clk: PLL48CLK) -> Self
Sets the 48 MHz clock source.
Sourcepub fn plln(self, plln: u16) -> Self
pub fn plln(self, plln: u16) -> Self
Sets the PLL multiplication factor for the main PLL.
§Panics
Panics if the multiplication factor isn’t between 50 and 432 (inclusive).
Sourcepub fn pllq(self, pllq: u8) -> Self
pub fn pllq(self, pllq: u8) -> Self
Sets the PLL division factor for the 48 MHz clock.
§Panics
Panics if the division factor isn’t between 2 and 15 (inclusive).
Sourcepub fn use_pllsai(self) -> Self
pub fn use_pllsai(self) -> Self
Enables the PLLSAI clock source.
Sourcepub fn pllsain(self, pllsain: u16) -> Self
pub fn pllsain(self, pllsain: u16) -> Self
Sets the PLLSAIN multiplication factor for PLLSAI.
§Panics
Panics if the multiplication factor isn’t between 50 and 432.
Sourcepub fn pllsaiq(self, pllsaiq: u8) -> Self
pub fn pllsaiq(self, pllsaiq: u8) -> Self
Sets the PLLSAIQ division factor for PLLSAIS.
§Panics
Panics if the division factor isn’t between 2 and 15.
Sourcepub fn use_plli2s(self) -> Self
pub fn use_plli2s(self) -> Self
Enables the PLLI2S clock source.
Sourcepub fn plli2sn(self, plli2sn: u16) -> Self
pub fn plli2sn(self, plli2sn: u16) -> Self
Sets the PLLI2SN multiplication factor for PLLI2S.
§Panics
Panics if the multiplication factor isn’t between 50 and 432.
Sourcepub fn plli2sq(self, plli2sq: u8) -> Self
pub fn plli2sq(self, plli2sq: u8) -> Self
Sets the PLLI2SQ division factor for PLLI2S.
§Panics
Panics if the division factor isn’t between 2 and 15.
Sourcepub fn plli2sr(self, plli2sr: u8) -> Self
pub fn plli2sr(self, plli2sr: u8) -> Self
Sets the PLLI2SR division factor for PLLI2S.
§Panics
Panics if the division factor isn’t between 2 and 7.
Sourcepub fn set_defaults(self) -> Self
pub fn set_defaults(self) -> Self
Configures the default clock settings.
Set SYSCLK as 216 Mhz and setup USB clock if defined.
Sourcepub fn freeze(self) -> Clocks
pub fn freeze(self) -> Clocks
Configure the “mandatory” clocks (sysclk, hclk, pclk1 and pclk2') and return them via the Clocks` struct.
The user shouldn’t call freeze more than once as the clocks parameters cannot be changed after the clocks have started.
The implementation makes the following choice: HSI is always chosen over HSE except when HSE is provided. When HSE is provided, HSE is used wherever it is possible.