24 switch(rcc_cfgr_sws) {
39 uint16_t ahb_division_factor;
41 if(rcc_cfgr_hpre <= 7) {
42 ahb_division_factor = 1;
44 else if(rcc_cfgr_hpre <= 11) {
45 ahb_division_factor = 0x1 << (rcc_cfgr_hpre - 7);
48 ahb_division_factor = 0x1 << (rcc_cfgr_hpre - 6);
51 return system_clock / ahb_division_factor;
58 uint8_t apb1_division_factor;
60 if(rcc_cfgr_ppre1 < 4) {
61 apb1_division_factor = 1;
64 apb1_division_factor = 0x1 << (rcc_cfgr_ppre1 - 3);
67 return ahb_clock / apb1_division_factor;
74 uint8_t apb2_division_factor;
76 if(rcc_cfgr_ppre2 < 4) {
77 apb2_division_factor = 1;
80 apb2_division_factor = 0x1 << (rcc_cfgr_ppre2 - 3);
83 return ahb_clock / apb2_division_factor;
89 RCC->RCC_AHB1ENR |= (0x1 << periph_position);
92 RCC->RCC_AHB1ENR &= ~(0x1 << periph_position);
99 RCC->RCC_APB1ENR |= (0x1 << periph_position);
101 else if(en_status ==
DISABLE) {
102 RCC->RCC_APB1ENR &= ~(0x1 << periph_position);
109 RCC->RCC_APB2ENR |= (0x1 << periph_position);
111 else if(en_status ==
DISABLE) {
112 RCC->RCC_APB2ENR &= ~(0x1 << periph_position);
118 RCC->RCC_AHB1RSTR |= (0x1 << periph_position);
119 RCC->RCC_AHB1RSTR &= ~(0x1 << periph_position);
124 RCC->RCC_APB1RSTR |= (0x1 << periph_position);
125 RCC->RCC_APB1RSTR &= ~(0x1 << periph_position);
130 RCC->RCC_APB2RSTR |= (0x1 << periph_position);
131 RCC->RCC_APB2RSTR &= ~(0x1 << periph_position);
EN_STATUS_te
Represents an enabled or disabled state.
void rcc_set_pclk_apb2(RCC_APB2ENR_te periph_position, EN_STATUS_te en_status)
Enables or disables the peripheral clock for an APB2 peripheral.
void rcc_reset_periph_apb2(RCC_APB2RSTR_te periph_position)
Resets an APB2 peripheral via RCC_APB2RSTR.
uint32_t rcc_get_apb2_clk(void)
Returns the current APB2 peripheral bus clock frequency in Hz.
void rcc_set_pclk_ahb1(RCC_AHB1ENR_te periph_position, EN_STATUS_te en_status)
Enables or disables the peripheral clock for an AHB1 peripheral.
void rcc_set_pclk_apb1(RCC_APB1ENR_te periph_position, EN_STATUS_te en_status)
Enables or disables the peripheral clock for an APB1 peripheral.
void rcc_reset_periph_apb1(RCC_APB1RSTR_te periph_position)
Resets an APB1 peripheral via RCC_APB1RSTR.
uint32_t rcc_get_sysclk(void)
Returns the current system clock frequency in Hz.
uint32_t rcc_get_apb1_clk(void)
Returns the current APB1 peripheral bus clock frequency in Hz.
uint32_t rcc_get_ahb_clk(void)
Returns the current AHB bus clock frequency in Hz.
void rcc_reset_bkpd(void)
Resets the backup domain.
void rcc_reset_periph_ahb1(RCC_AHB1RSTR_te periph_position)
Resets an AHB1 peripheral via RCC_AHB1RSTR.
RCC_AHB1RSTR_te
RCC_AHB1RSTR register bit positions.
RCC_AHB1ENR_te
RCC_AHB1ENR register bit positions.
RCC_APB2ENR_te
RCC_APB2ENR register bit positions.
RCC_APB2RSTR_te
RCC_APB2RSTR register bit positions.
RCC_APB1ENR_te
RCC_APB1ENR register bit positions.
RCC_APB1RSTR_te
RCC_APB1RSTR register bit positions.
STM32F401RE MCU-specific peripheral register definitions and bit position enumerations.
STM32F401RE RCC driver public API.