libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
|
libopencm3 STM32F1xx Reset and Clock Control More...
Macros | |
#define | _RCC_REG(i) MMIO32(RCC_BASE + ((i) >> 5)) |
#define | _RCC_BIT(i) (1 << ((i) & 0x1f)) |
Functions | |
void | rcc_peripheral_enable_clock (volatile uint32_t *reg, uint32_t en) |
RCC Enable Peripheral Clocks. More... | |
void | rcc_peripheral_disable_clock (volatile uint32_t *reg, uint32_t en) |
RCC Disable Peripheral Clocks. More... | |
void | rcc_peripheral_reset (volatile uint32_t *reg, uint32_t reset) |
RCC Reset Peripherals. More... | |
void | rcc_peripheral_clear_reset (volatile uint32_t *reg, uint32_t clear_reset) |
RCC Remove Reset on Peripherals. More... | |
void | rcc_periph_clock_enable (enum rcc_periph_clken clken) |
Enable Peripheral Clock in running mode. More... | |
void | rcc_periph_clock_disable (enum rcc_periph_clken clken) |
Disable Peripheral Clock in running mode. More... | |
void | rcc_periph_reset_pulse (enum rcc_periph_rst rst) |
Reset Peripheral, pulsed. More... | |
void | rcc_periph_reset_hold (enum rcc_periph_rst rst) |
Reset Peripheral, hold. More... | |
void | rcc_periph_reset_release (enum rcc_periph_rst rst) |
Reset Peripheral, release. More... | |
void | rcc_set_mco (uint32_t mcosrc) |
Select the source of Microcontroller Clock Output. More... | |
void | rcc_osc_bypass_enable (enum rcc_osc osc) |
RCC Enable Bypass. More... | |
void | rcc_osc_bypass_disable (enum rcc_osc osc) |
RCC Disable Bypass. More... | |
uint16_t | rcc_get_div_from_hpre (uint8_t div_val) |
This will return the divisor 1/2/4/8/16/64/128/256/512 which is set as a 4-bit value, typically used for hpre and other prescalers. More... | |
void | rcc_osc_ready_int_clear (enum rcc_osc osc) |
RCC Clear the Oscillator Ready Interrupt Flag. More... | |
void | rcc_osc_ready_int_enable (enum rcc_osc osc) |
RCC Enable the Oscillator Ready Interrupt. More... | |
void | rcc_osc_ready_int_disable (enum rcc_osc osc) |
RCC Disable the Oscillator Ready Interrupt. More... | |
int | rcc_osc_ready_int_flag (enum rcc_osc osc) |
RCC Read the Oscillator Ready Interrupt Flag. More... | |
void | rcc_css_int_clear (void) |
RCC Clear the Clock Security System Interrupt Flag. More... | |
int | rcc_css_int_flag (void) |
RCC Read the Clock Security System Interrupt Flag. More... | |
bool | rcc_is_osc_ready (enum rcc_osc osc) |
Is the given oscillator ready? More... | |
void | rcc_wait_for_osc_ready (enum rcc_osc osc) |
Wait for Oscillator Ready. More... | |
void | rcc_osc_on (enum rcc_osc osc) |
RCC Turn on an Oscillator. More... | |
void | rcc_osc_off (enum rcc_osc osc) |
RCC Turn off an Oscillator. More... | |
void | rcc_css_enable (void) |
RCC Enable the Clock Security System. More... | |
void | rcc_css_disable (void) |
RCC Disable the Clock Security System. More... | |
void | rcc_set_sysclk_source (uint32_t clk) |
RCC Set the Source for the System Clock. More... | |
void | rcc_set_pll_multiplication_factor (uint32_t mul) |
RCC Set the PLL Multiplication Factor. More... | |
void | rcc_set_pll2_multiplication_factor (uint32_t mul) |
RCC Set the PLL2 Multiplication Factor. More... | |
void | rcc_set_pll3_multiplication_factor (uint32_t mul) |
RCC Set the PLL3 Multiplication Factor. More... | |
void | rcc_set_pll_source (uint32_t pllsrc) |
RCC Set the PLL Clock Source. More... | |
void | rcc_set_pllxtpre (uint32_t pllxtpre) |
RCC Set the HSE Frequency Divider used as PLL Clock Source. More... | |
uint32_t | rcc_rtc_clock_enabled_flag (void) |
RCC RTC Clock Enabled Flag. More... | |
void | rcc_enable_rtc_clock (void) |
RCC Enable the RTC clock. More... | |
void | rcc_set_rtc_clock_source (enum rcc_osc clock_source) |
RCC Set the Source for the RTC clock. More... | |
void | rcc_set_adcpre (uint32_t adcpre) |
ADC Setup the A/D Clock. More... | |
void | rcc_set_ppre2 (uint32_t ppre2) |
RCC Set the APB2 Prescale Factor. More... | |
void | rcc_set_ppre1 (uint32_t ppre1) |
RCC Set the APB1 Prescale Factor. More... | |
void | rcc_set_hpre (uint32_t hpre) |
RCC Set the AHB Prescale Factor. More... | |
void | rcc_set_usbpre (uint32_t usbpre) |
RCC Set the USB Prescale Factor. More... | |
void | rcc_set_prediv1 (uint32_t prediv) |
void | rcc_set_prediv2 (uint32_t prediv) |
void | rcc_set_prediv1_source (uint32_t rccsrc) |
uint32_t | rcc_system_clock_source (void) |
RCC Get the System Clock Source. More... | |
void | rcc_clock_setup_in_hsi_out_64mhz (void) |
RCC Set System Clock PLL at 64MHz from HSI. More... | |
void | rcc_clock_setup_in_hsi_out_48mhz (void) |
RCC Set System Clock PLL at 48MHz from HSI. More... | |
void | rcc_clock_setup_in_hsi_out_24mhz (void) |
RCC Set System Clock PLL at 24MHz from HSI. More... | |
void | rcc_clock_setup_in_hse_8mhz_out_24mhz (void) |
RCC Set System Clock PLL at 24MHz from HSE at 8MHz. More... | |
void | rcc_clock_setup_in_hse_8mhz_out_72mhz (void) |
RCC Set System Clock PLL at 72MHz from HSE at 8MHz. More... | |
void | rcc_clock_setup_in_hse_12mhz_out_72mhz (void) |
RCC Set System Clock PLL at 72MHz from HSE at 12MHz. More... | |
void | rcc_clock_setup_in_hse_16mhz_out_72mhz (void) |
RCC Set System Clock PLL at 72MHz from HSE at 16MHz. More... | |
void | rcc_clock_setup_in_hse_25mhz_out_72mhz (void) |
RCC Set System Clock PLL at 72MHz from HSE at 25MHz. More... | |
void | rcc_clock_setup_pll (const struct rcc_clock_scale *clock) |
Switch sysclock to PLL with the given parameters. More... | |
void | rcc_backupdomain_reset (void) |
RCC Reset the Backup Domain. More... | |
uint32_t | rcc_get_usart_clk_freq (uint32_t usart) |
Get the peripheral clock speed for the USART at base specified. More... | |
uint32_t | rcc_get_timer_clk_freq (uint32_t timer) |
Get the peripheral clock speed for the Timer at base specified. More... | |
uint32_t | rcc_get_i2c_clk_freq (uint32_t i2c) |
Get the peripheral clock speed for the I2C device at base specified. More... | |
Variables | |
uint32_t | rcc_apb1_frequency = 8000000 |
Set the default clock frequencies. More... | |
uint32_t | rcc_apb2_frequency = 8000000 |
uint32_t | rcc_ahb_frequency = 8000000 |
const struct rcc_clock_scale | rcc_hse_configs [RCC_CLOCK_HSE_END] |
const struct rcc_clock_scale | rcc_hsi_configs [RCC_CLOCK_HSI_END] |
libopencm3 STM32F1xx Reset and Clock Control
This library supports the Reset and Clock Control System in the STM32F1xx series of ARM Cortex Microcontrollers by ST Microelectronics.
Clock settings and resets for many peripherals are given here rather than in the corresponding peripheral library.
The library also provides a number of common configurations for the processor system clock. Not all possible configurations are included.
LGPL License Terms libopencm3 License
#define _RCC_BIT | ( | i | ) | (1 << ((i) & 0x1f)) |
Definition at line 117 of file rcc_common_all.c.
Definition at line 116 of file rcc_common_all.c.
void rcc_backupdomain_reset | ( | void | ) |
RCC Reset the Backup Domain.
The backup domain registers are reset to disable RTC controls and clear user data.
Definition at line 1283 of file rcc.c.
References RCC_BDCR, and RCC_BDCR_BDRST.
void rcc_clock_setup_in_hse_12mhz_out_72mhz | ( | void | ) |
RCC Set System Clock PLL at 72MHz from HSE at 12MHz.
Definition at line 1032 of file rcc.c.
References FLASH_ACR_LATENCY_2WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV6, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL6, RCC_CFGR_PLLSRC_HSE_CLK, RCC_CFGR_PLLXTPRE_HSE_CLK, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSECLK, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSE, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hse_16mhz_out_72mhz | ( | void | ) |
RCC Set System Clock PLL at 72MHz from HSE at 16MHz.
Definition at line 1096 of file rcc.c.
References FLASH_ACR_LATENCY_2WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV6, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL9, RCC_CFGR_PLLSRC_HSE_CLK, RCC_CFGR_PLLXTPRE_HSE_CLK_DIV2, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSECLK, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSE, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hse_25mhz_out_72mhz | ( | void | ) |
RCC Set System Clock PLL at 72MHz from HSE at 25MHz.
Definition at line 1160 of file rcc.c.
References FLASH_ACR_LATENCY_2WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL8, RCC_CFGR2_PREDIV1SRC_PLL2_CLK, RCC_CFGR2_PREDIV2_DIV5, RCC_CFGR2_PREDIV_DIV5, RCC_CFGR_ADCPRE_DIV6, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL9, RCC_CFGR_PLLSRC_PREDIV1_CLK, RCC_CFGR_PLLXTPRE_HSE_CLK, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSECLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_CFGR_USBPRE_PLL_VCO_CLK_DIV3, RCC_HSE, rcc_osc_on(), RCC_PLL, RCC_PLL2, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll2_multiplication_factor(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_prediv1(), rcc_set_prediv1_source(), rcc_set_prediv2(), rcc_set_sysclk_source(), rcc_set_usbpre(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hse_8mhz_out_24mhz | ( | void | ) |
RCC Set System Clock PLL at 24MHz from HSE at 8MHz.
Definition at line 904 of file rcc.c.
References FLASH_ACR_LATENCY_0WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV2, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL3, RCC_CFGR_PLLSRC_HSE_CLK, RCC_CFGR_PLLXTPRE_HSE_CLK, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSECLK, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSE, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hse_8mhz_out_72mhz | ( | void | ) |
RCC Set System Clock PLL at 72MHz from HSE at 8MHz.
Definition at line 968 of file rcc.c.
References FLASH_ACR_LATENCY_2WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV8, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL9, RCC_CFGR_PLLSRC_HSE_CLK, RCC_CFGR_PLLXTPRE_HSE_CLK, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSECLK, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSE, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hsi_out_24mhz | ( | void | ) |
RCC Set System Clock PLL at 24MHz from HSI.
Definition at line 851 of file rcc.c.
References FLASH_ACR_LATENCY_0WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV2, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL6, RCC_CFGR_PLLSRC_HSI_CLK_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hsi_out_48mhz | ( | void | ) |
RCC Set System Clock PLL at 48MHz from HSI.
Definition at line 797 of file rcc.c.
References FLASH_ACR_LATENCY_1WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV8, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL12, RCC_CFGR_PLLSRC_HSI_CLK_DIV2, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_CFGR_USBPRE_PLL_CLK_NODIV, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), rcc_set_usbpre(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_in_hsi_out_64mhz | ( | void | ) |
RCC Set System Clock PLL at 64MHz from HSI.
Definition at line 744 of file rcc.c.
References FLASH_ACR_LATENCY_2WS, flash_set_ws(), rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR_ADCPRE_DIV8, RCC_CFGR_HPRE_NODIV, RCC_CFGR_PLLMUL_PLL_CLK_MUL16, RCC_CFGR_PLLSRC_HSI_CLK_DIV2, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_NODIV, RCC_CFGR_SW_SYSCLKSEL_HSICLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSI, rcc_osc_on(), RCC_PLL, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_sysclk_source(), and rcc_wait_for_osc_ready().
void rcc_clock_setup_pll | ( | const struct rcc_clock_scale * | clock | ) |
Switch sysclock to PLL with the given parameters.
This should be usable from any point in time, but only if you have used library functions to manage clocks.
clock | full struct with desired parameters |
Definition at line 1213 of file rcc.c.
References rcc_clock_scale::adcpre, rcc_clock_scale::ahb_frequency, rcc_clock_scale::apb1_frequency, rcc_clock_scale::apb2_frequency, flash_set_ws(), rcc_clock_scale::flash_waitstates, rcc_clock_scale::hpre, rcc_clock_scale::pll2_mul, rcc_clock_scale::pll3_mul, rcc_clock_scale::pll_mul, rcc_clock_scale::pll_source, rcc_clock_scale::ppre1, rcc_clock_scale::ppre2, rcc_clock_scale::prediv1, rcc_clock_scale::prediv1_source, rcc_clock_scale::prediv2, rcc_ahb_frequency, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR2_PREDIV_DIV2, RCC_CFGR_PLLSRC_HSE_CLK, RCC_CFGR_SW_SYSCLKSEL_PLLCLK, RCC_HSE, RCC_HSI, rcc_osc_on(), RCC_PLL, RCC_PLL2, RCC_PLL3, rcc_set_adcpre(), rcc_set_hpre(), rcc_set_pll2_multiplication_factor(), rcc_set_pll3_multiplication_factor(), rcc_set_pll_multiplication_factor(), rcc_set_pll_source(), rcc_set_pllxtpre(), rcc_set_ppre1(), rcc_set_ppre2(), rcc_set_prediv1(), rcc_set_prediv1_source(), rcc_set_prediv2(), rcc_set_sysclk_source(), rcc_set_usbpre(), rcc_wait_for_osc_ready(), and rcc_clock_scale::usbpre.
void rcc_css_disable | ( | void | ) |
void rcc_css_enable | ( | void | ) |
RCC Enable the Clock Security System.
Definition at line 457 of file rcc.c.
References RCC_CR, and RCC_CR_CSSON.
void rcc_css_int_clear | ( | void | ) |
RCC Clear the Clock Security System Interrupt Flag.
Definition at line 327 of file rcc.c.
References RCC_CIR, and RCC_CIR_CSSC.
int rcc_css_int_flag | ( | void | ) |
RCC Read the Clock Security System Interrupt Flag.
Definition at line 338 of file rcc.c.
References RCC_CIR, and RCC_CIR_CSSF.
void rcc_enable_rtc_clock | ( | void | ) |
RCC Enable the RTC clock.
Definition at line 570 of file rcc.c.
References RCC_BDCR, and RCC_BDCR_RTCEN.
Referenced by rtc_awake_from_off().
uint16_t rcc_get_div_from_hpre | ( | uint8_t | div_val | ) |
This will return the divisor 1/2/4/8/16/64/128/256/512 which is set as a 4-bit value, typically used for hpre and other prescalers.
div_val | Masked and shifted divider value from register (e.g. RCC_CFGR) |
Definition at line 260 of file rcc_common_all.c.
uint32_t rcc_get_i2c_clk_freq | ( | uint32_t | i2c | ) |
Get the peripheral clock speed for the I2C device at base specified.
i2c | Base address of I2C to get clock frequency for. |
Definition at line 1328 of file rcc.c.
References rcc_apb1_frequency.
uint32_t rcc_get_timer_clk_freq | ( | uint32_t | timer | ) |
Get the peripheral clock speed for the Timer at base specified.
timer | Base address of TIM to get clock frequency for. |
Definition at line 1309 of file rcc.c.
References cm3_assert_not_reached, rcc_clock_scale::ppre1, rcc_clock_scale::ppre2, rcc_apb1_frequency, rcc_apb2_frequency, RCC_CFGR, RCC_CFGR_PPRE1_HCLK_NODIV, RCC_CFGR_PPRE1_MASK, RCC_CFGR_PPRE1_SHIFT, RCC_CFGR_PPRE2_HCLK_NODIV, RCC_CFGR_PPRE2_MASK, RCC_CFGR_PPRE2_SHIFT, TIM14_BASE, and TIM2_BASE.
uint32_t rcc_get_usart_clk_freq | ( | uint32_t | usart | ) |
Get the peripheral clock speed for the USART at base specified.
usart | Base address of USART to get clock frequency for. |
Definition at line 1296 of file rcc.c.
References rcc_apb1_frequency, rcc_apb2_frequency, and USART1_BASE.
Referenced by usart_set_baudrate().
bool rcc_is_osc_ready | ( | enum rcc_osc | osc | ) |
Is the given oscillator ready?
osc | Oscillator ID |
Definition at line 343 of file rcc.c.
References RCC_BDCR, RCC_BDCR_LSERDY, RCC_CR, RCC_CR_HSERDY, RCC_CR_HSIRDY, RCC_CR_PLL2RDY, RCC_CR_PLL3RDY, RCC_CR_PLLRDY, RCC_CSR, RCC_CSR_LSIRDY, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
Referenced by rcc_wait_for_osc_ready().
void rcc_osc_bypass_disable | ( | enum rcc_osc | osc | ) |
RCC Disable Bypass.
Re-enable the internal clock (high speed and low speed clocks only). The internal clock must be disabled (see rcc_osc_off) for this to have effect.
[in] | osc | Oscillator ID. Only HSE and LSE have effect. |
Definition at line 238 of file rcc_common_all.c.
void rcc_osc_bypass_enable | ( | enum rcc_osc | osc | ) |
RCC Enable Bypass.
Enable an external clock to bypass the internal clock (high speed and low speed clocks only). The external clock must be enabled (see rcc_osc_on) and the internal clock must be disabled (see rcc_osc_off) for this to have effect.
[in] | osc | Oscillator ID. Only HSE and LSE have effect. |
Definition at line 208 of file rcc_common_all.c.
References RCC_BDCR, RCC_BDCR_LSEBYP, RCC_CR, RCC_CR_HSEBYP, RCC_CSR, RCC_HSE, and RCC_LSE.
void rcc_osc_off | ( | enum rcc_osc | osc | ) |
RCC Turn off an Oscillator.
Disable an oscillator and power off.
[in] | osc | Oscillator ID |
Definition at line 425 of file rcc.c.
References RCC_BDCR, RCC_CR, RCC_CSR, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
void rcc_osc_on | ( | enum rcc_osc | osc | ) |
RCC Turn on an Oscillator.
Enable an oscillator and power on. Each oscillator requires an amount of time to settle to a usable state. Refer to datasheets for time delay information. A status flag is available to indicate when the oscillator becomes ready (see rcc_osc_ready_int_flag and rcc_wait_for_osc_ready).
[in] | osc | Oscillator ID |
Definition at line 384 of file rcc.c.
References RCC_BDCR, RCC_BDCR_LSEON, RCC_CR, RCC_CR_HSEON, RCC_CR_HSION, RCC_CR_PLL2ON, RCC_CR_PLL3ON, RCC_CR_PLLON, RCC_CSR, RCC_CSR_LSION, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_osc_ready_int_clear | ( | enum rcc_osc | osc | ) |
RCC Clear the Oscillator Ready Interrupt Flag.
Clear the interrupt flag that was set when a clock oscillator became ready to use.
[in] | osc | Oscillator ID |
Definition at line 193 of file rcc.c.
References RCC_CIR, RCC_CIR_HSERDYC, RCC_CIR_HSIRDYC, RCC_CIR_LSERDYC, RCC_CIR_LSIRDYC, RCC_CIR_PLL2RDYC, RCC_CIR_PLL3RDYC, RCC_CIR_PLLRDYC, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
void rcc_osc_ready_int_disable | ( | enum rcc_osc | osc | ) |
void rcc_osc_ready_int_enable | ( | enum rcc_osc | osc | ) |
RCC Enable the Oscillator Ready Interrupt.
osc | Oscillator ID |
Definition at line 226 of file rcc.c.
References RCC_CIR, RCC_CIR_HSERDYIE, RCC_CIR_HSIRDYIE, RCC_CIR_LSERDYIE, RCC_CIR_LSIRDYIE, RCC_CIR_PLL2RDYIE, RCC_CIR_PLL3RDYIE, RCC_CIR_PLLRDYIE, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
int rcc_osc_ready_int_flag | ( | enum rcc_osc | osc | ) |
RCC Read the Oscillator Ready Interrupt Flag.
[in] | osc | Oscillator ID |
Definition at line 293 of file rcc.c.
References cm3_assert_not_reached, RCC_CIR, RCC_CIR_HSERDYF, RCC_CIR_HSIRDYF, RCC_CIR_LSERDYF, RCC_CIR_LSIRDYF, RCC_CIR_PLL2RDYF, RCC_CIR_PLL3RDYF, RCC_CIR_PLLRDYF, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
void rcc_periph_clock_disable | ( | enum rcc_periph_clken | clken | ) |
Disable Peripheral Clock in running mode.
Disable the clock on particular peripheral.
[in] | clken | rcc_periph_clken Peripheral RCC |
For available constants, see rcc_periph_clken (RCC_UART1 for example)
Definition at line 139 of file rcc_common_all.c.
References _RCC_REG.
void rcc_periph_clock_enable | ( | enum rcc_periph_clken | clken | ) |
Enable Peripheral Clock in running mode.
Enable the clock on particular peripheral.
[in] | clken | rcc_periph_clken Peripheral RCC |
For available constants, see rcc_periph_clken (RCC_UART1 for example)
Definition at line 127 of file rcc_common_all.c.
References _RCC_BIT, and _RCC_REG.
Referenced by rtc_auto_awake(), rtc_awake_from_off(), rtc_awake_from_standby(), st_usbfs_v1_usbd_init(), and stm32f107_usbd_init().
void rcc_periph_reset_hold | ( | enum rcc_periph_rst | rst | ) |
Reset Peripheral, hold.
Reset particular peripheral, and hold in reset state.
[in] | rst | rcc_periph_rst Peripheral reset |
For available constants, see rcc_periph_rst (RST_UART1 for example)
Definition at line 166 of file rcc_common_all.c.
void rcc_periph_reset_pulse | ( | enum rcc_periph_rst | rst | ) |
Reset Peripheral, pulsed.
Reset particular peripheral, and restore to working state.
[in] | rst | rcc_periph_rst Peripheral reset |
For available constants, see rcc_periph_rst (RST_UART1 for example)
Definition at line 152 of file rcc_common_all.c.
References _RCC_BIT, and _RCC_REG.
Referenced by can_reset().
void rcc_periph_reset_release | ( | enum rcc_periph_rst | rst | ) |
Reset Peripheral, release.
Restore peripheral from reset state to working state.
[in] | rst | rcc_periph_rst Peripheral reset |
For available constants, see rcc_periph_rst (RST_UART1 for example)
Definition at line 179 of file rcc_common_all.c.
References _RCC_REG.
void rcc_peripheral_clear_reset | ( | volatile uint32_t * | reg, |
uint32_t | clear_reset | ||
) |
RCC Remove Reset on Peripherals.
Remove the reset on particular peripherals. There are three registers involved, each one controlling reset of peripherals associated with the AHB, APB1 and APB2 respectively. Several peripherals could have the reset removed simultaneously only if they are controlled by the same register.
[in] | *reg | Unsigned int32. Pointer to a Reset Register (either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR) |
[in] | clear_reset | Unsigned int32. Logical OR of all resets to be removed:
|
Definition at line 111 of file rcc_common_all.c.
void rcc_peripheral_disable_clock | ( | volatile uint32_t * | reg, |
uint32_t | en | ||
) |
RCC Disable Peripheral Clocks.
Disable the clock on particular peripherals. There are three registers involved, each one controlling the enabling of clocks associated with the AHB, APB1 and APB2 respectively. Several peripherals could be disabled simultaneously only if they are controlled by the same register.
[in] | *reg | Unsigned int32. Pointer to a Clock Enable Register (either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR) |
[in] | en | Unsigned int32. Logical OR of all enables to be used for disabling.
|
Definition at line 66 of file rcc_common_all.c.
void rcc_peripheral_enable_clock | ( | volatile uint32_t * | reg, |
uint32_t | en | ||
) |
RCC Enable Peripheral Clocks.
Enable the clock on particular peripherals. There are three registers involved, each one controlling the enabling of clocks associated with the AHB, APB1 and APB2 respectively. Several peripherals could be enabled simultaneously only if they are controlled by the same register.
[in] | *reg | Unsigned int32. Pointer to a Clock Enable Register (either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR) |
[in] | en | Unsigned int32. Logical OR of all enables to be set
|
Definition at line 44 of file rcc_common_all.c.
void rcc_peripheral_reset | ( | volatile uint32_t * | reg, |
uint32_t | reset | ||
) |
RCC Reset Peripherals.
Reset particular peripherals. There are three registers involved, each one controlling reset of peripherals associated with the AHB, APB1 and APB2 respectively. Several peripherals could be reset simultaneously only if they are controlled by the same register.
[in] | *reg | Unsigned int32. Pointer to a Reset Register (either RCC_AHBENR, RCC_APB1ENR or RCC_APB2ENR) |
[in] | reset | Unsigned int32. Logical OR of all resets.
|
Definition at line 88 of file rcc_common_all.c.
uint32_t rcc_rtc_clock_enabled_flag | ( | void | ) |
RCC RTC Clock Enabled Flag.
Definition at line 560 of file rcc.c.
References RCC_BDCR, and RCC_BDCR_RTCEN.
Referenced by rtc_auto_awake().
void rcc_set_adcpre | ( | uint32_t | adcpre | ) |
ADC Setup the A/D Clock.
The ADC's have a common clock prescale setting.
[in] | adcpre | uint32_t. Prescale divider taken from RCC ADC clock prescaler enable values |
Definition at line 632 of file rcc.c.
References rcc_clock_scale::adcpre, RCC_CFGR, and RCC_CFGR_ADCPRE_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_hpre | ( | uint32_t | hpre | ) |
RCC Set the AHB Prescale Factor.
[in] | hpre | Unsigned int32. AHB prescale factor RCC_CFGR AHB prescale Factors |
Definition at line 671 of file rcc.c.
References rcc_clock_scale::hpre, RCC_CFGR, and RCC_CFGR_HPRE_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_mco | ( | uint32_t | mcosrc | ) |
Select the source of Microcontroller Clock Output.
Exact sources available depend on your target. On devices with multiple MCO pins, this function controls MCO1
[in] | mcosrc | the unshifted source bits |
Definition at line 191 of file rcc_common_all.c.
References RCC_CFGR, RCC_CFGR_MCO_MASK, and RCC_CFGR_MCO_SHIFT.
void rcc_set_pll2_multiplication_factor | ( | uint32_t | mul | ) |
RCC Set the PLL2 Multiplication Factor.
[in] | mul | Unsigned int32. PLL multiplication factor RCC_CFGR PLL Multiplication Factor |
Definition at line 506 of file rcc.c.
References RCC_CFGR2, and RCC_CFGR2_PLL2MUL_SHIFT.
Referenced by rcc_clock_setup_in_hse_25mhz_out_72mhz(), and rcc_clock_setup_pll().
void rcc_set_pll3_multiplication_factor | ( | uint32_t | mul | ) |
RCC Set the PLL3 Multiplication Factor.
[in] | mul | Unsigned int32. PLL multiplication factor RCC_CFGR PLL Multiplication Factor |
Definition at line 520 of file rcc.c.
References RCC_CFGR2, and RCC_CFGR2_PLL3MUL_SHIFT.
Referenced by rcc_clock_setup_pll().
void rcc_set_pll_multiplication_factor | ( | uint32_t | mul | ) |
RCC Set the PLL Multiplication Factor.
[in] | mul | Unsigned int32. PLL multiplication factor RCC_CFGR PLL Multiplication Factor |
Definition at line 492 of file rcc.c.
References RCC_CFGR, and RCC_CFGR_PLLMUL_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_pll_source | ( | uint32_t | pllsrc | ) |
RCC Set the PLL Clock Source.
[in] | pllsrc | Unsigned int32. PLL clock source RCC_CFGR PLL Clock Source |
Definition at line 534 of file rcc.c.
References RCC_CFGR.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_pllxtpre | ( | uint32_t | pllxtpre | ) |
RCC Set the HSE Frequency Divider used as PLL Clock Source.
[in] | pllxtpre | Unsigned int32. HSE division factor RCC_CFGR HSE Divider for PLL |
Definition at line 548 of file rcc.c.
References RCC_CFGR.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), and rcc_clock_setup_pll().
void rcc_set_ppre1 | ( | uint32_t | ppre1 | ) |
RCC Set the APB1 Prescale Factor.
[in] | ppre1 | Unsigned int32. APB1 prescale factor rcc_cfgr_apb1pre |
Definition at line 658 of file rcc.c.
References rcc_clock_scale::ppre1, RCC_CFGR, and RCC_CFGR_PPRE1_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_ppre2 | ( | uint32_t | ppre2 | ) |
RCC Set the APB2 Prescale Factor.
[in] | ppre2 | Unsigned int32. APB2 prescale factor rcc_cfgr_apb2pre |
Definition at line 644 of file rcc.c.
References rcc_clock_scale::ppre2, RCC_CFGR, and RCC_CFGR_PPRE2_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_prediv1 | ( | uint32_t | prediv | ) |
Definition at line 698 of file rcc.c.
References RCC_CFGR2, and RCC_CFGR2_PREDIV1_SHIFT.
Referenced by rcc_clock_setup_in_hse_25mhz_out_72mhz(), and rcc_clock_setup_pll().
void rcc_set_prediv1_source | ( | uint32_t | rccsrc | ) |
Definition at line 710 of file rcc.c.
References RCC_CFGR2, and RCC_CFGR2_PREDIV1SRC.
Referenced by rcc_clock_setup_in_hse_25mhz_out_72mhz(), and rcc_clock_setup_pll().
void rcc_set_prediv2 | ( | uint32_t | prediv | ) |
Definition at line 704 of file rcc.c.
References RCC_CFGR2, and RCC_CFGR2_PREDIV2_SHIFT.
Referenced by rcc_clock_setup_in_hse_25mhz_out_72mhz(), and rcc_clock_setup_pll().
void rcc_set_rtc_clock_source | ( | enum rcc_osc | clock_source | ) |
RCC Set the Source for the RTC clock.
[in] | clock_source | RTC clock source. Only HSE/128, LSE and LSI. |
Definition at line 581 of file rcc.c.
References RCC_BDCR, RCC_BDCR_LSEON, RCC_BDCR_LSERDY, RCC_CR, RCC_CR_HSEON, RCC_CR_HSERDY, RCC_CSR, RCC_CSR_LSION, RCC_CSR_LSIRDY, RCC_HSE, RCC_HSI, RCC_LSE, RCC_LSI, RCC_PLL, RCC_PLL2, and RCC_PLL3.
Referenced by rtc_awake_from_off().
void rcc_set_sysclk_source | ( | uint32_t | clk | ) |
RCC Set the Source for the System Clock.
[in] | clk | Unsigned int32. System Clock Selection RCC_CFGR System Clock Selection |
Definition at line 478 of file rcc.c.
References RCC_CFGR, and RCC_CFGR_SW_SHIFT.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
void rcc_set_usbpre | ( | uint32_t | usbpre | ) |
RCC Set the USB Prescale Factor.
The prescale factor can be set to 1 (no prescale) for use when the PLL clock is 48MHz, or 1.5 to generate the 48MHz USB clock from a 72MHz PLL clock.
[in] | usbpre | Unsigned int32. USB prescale factor RCC_CFGR USB prescale Factors |
Definition at line 689 of file rcc.c.
References RCC_CFGR, RCC_CFGR_USBPRE, and rcc_clock_scale::usbpre.
Referenced by rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_48mhz(), and rcc_clock_setup_pll().
uint32_t rcc_system_clock_source | ( | void | ) |
RCC Get the System Clock Source.
Definition at line 728 of file rcc.c.
References RCC_CFGR, RCC_CFGR_SWS, and RCC_CFGR_SWS_SHIFT.
void rcc_wait_for_osc_ready | ( | enum rcc_osc | osc | ) |
Wait for Oscillator Ready.
Block until the hardware indicates that the Oscillator is ready.
osc | Oscillator ID |
Definition at line 364 of file rcc.c.
References rcc_is_osc_ready().
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
uint32_t rcc_ahb_frequency = 8000000 |
Definition at line 59 of file rcc.c.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), and rcc_clock_setup_pll().
uint32_t rcc_apb1_frequency = 8000000 |
Set the default clock frequencies.
Definition at line 57 of file rcc.c.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), rcc_clock_setup_pll(), rcc_get_i2c_clk_freq(), rcc_get_timer_clk_freq(), and rcc_get_usart_clk_freq().
uint32_t rcc_apb2_frequency = 8000000 |
Definition at line 58 of file rcc.c.
Referenced by rcc_clock_setup_in_hse_12mhz_out_72mhz(), rcc_clock_setup_in_hse_16mhz_out_72mhz(), rcc_clock_setup_in_hse_25mhz_out_72mhz(), rcc_clock_setup_in_hse_8mhz_out_24mhz(), rcc_clock_setup_in_hse_8mhz_out_72mhz(), rcc_clock_setup_in_hsi_out_24mhz(), rcc_clock_setup_in_hsi_out_48mhz(), rcc_clock_setup_in_hsi_out_64mhz(), rcc_clock_setup_pll(), rcc_get_timer_clk_freq(), and rcc_get_usart_clk_freq().
const struct rcc_clock_scale rcc_hse_configs[RCC_CLOCK_HSE_END] |
const struct rcc_clock_scale rcc_hsi_configs[RCC_CLOCK_HSI_END] |