STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches

Peripheral clock gating, oscillators, PLL, SYSCLK switch and reset cause. More...

Collaboration diagram for RCC:

Macros

#define RCC_CLOCK_READY_TIMEOUT_ITERATIONS   (100000U)
 Polls allowed for each oscillator, PLL or SWS wait (see Poll-count timeouts).

Functions

static DriverStatus_e rccGpioClockBit (const GpioRegisters_t *port, uint32_t *bit)
 Map a GPIO port to its AHB1ENR bit.
static uint32_t rccActiveSysclkSource (const RccRegisters_t *rcc)
 The SYSCLK source in use, from CFGR.SWS (not the requested CFGR.SW).
static DriverStatus_e rccOscillatorDisableGuard (const RccRegisters_t *rcc, uint32_t sysclk_value, uint32_t pllsrc_value)
 Report whether an oscillator feeds SYSCLK, directly or through the PLL.
static DriverStatus_e rccWaitCrFlag (const RccRegisters_t *rcc, uint32_t ready_bit, uint32_t expected)
 Poll a CR ready flag until it reaches expected or the budget runs out.
static DriverStatus_e rccValidateHpre (uint32_t hpre)
 Check that hpre is one of the nine RCC_CFGR_HPRE_DIV* values.
static DriverStatus_e rccValidatePpre (uint32_t ppre)
 Check that ppre is one of the five RCC_CFGR_PPRE_DIV* values.

Peripheral clock gating

DRIVER_MUST_CHECK DriverStatus_e rccGpioClockEnable (RccRegisters_t *rcc, const GpioRegisters_t *port)
 Enable a GPIO port's clock.
DRIVER_MUST_CHECK DriverStatus_e rccGpioClockDisable (RccRegisters_t *rcc, const GpioRegisters_t *port)
 Disable a GPIO port's clock.
void rccUsart2ClockEnable (RccRegisters_t *rcc)
 Enable USART2's clock.
void rccUsart2ClockDisable (RccRegisters_t *rcc)
 Disable USART2's clock.
void rccWwdgClockEnable (RccRegisters_t *rcc)
 Enable the WWDG's clock; needed before any WWDG access.
void rccWwdgClockDisable (RccRegisters_t *rcc)
 Disable the WWDG's clock.
void rccSyscfgClockEnable (RccRegisters_t *rcc)
 Enable SYSCFG's clock; needed before any SYSCFG access (e.g.
void rccSyscfgClockDisable (RccRegisters_t *rcc)
 Disable SYSCFG's clock.
void rccPwrClockEnable (RccRegisters_t *rcc)
 Enable PWR's clock; needed before any PWR access.
void rccPwrClockDisable (RccRegisters_t *rcc)
 Disable PWR's clock.

Reset cause

uint32_t rccResetFlags (const RccRegisters_t *rcc)
 The reset-cause flags set since they were last cleared.
void rccClearResetFlags (RccRegisters_t *rcc)
 Clear every reset-cause flag (CSR.RMVF).
#define RCC_RESET_FLAGS_Msk
 Every CSR reset-cause flag; rccResetFlags() returns a subset of these.

Oscillators

DRIVER_MUST_CHECK DriverStatus_e rccHsiEnable (RccRegisters_t *rcc)
 Turn on the 16 MHz internal oscillator (HSI) and wait until ready.
DRIVER_MUST_CHECK DriverStatus_e rccHsiDisable (RccRegisters_t *rcc)
 Turn off HSI and wait until HSIRDY clears.
DRIVER_MUST_CHECK DriverStatus_e rccHseEnable (RccRegisters_t *rcc, uint32_t bypass)
 Turn on the external oscillator (HSE) and wait until ready.
DRIVER_MUST_CHECK DriverStatus_e rccHseDisable (RccRegisters_t *rcc)
 Turn off HSE and wait until HSERDY clears.

Main PLL

DRIVER_MUST_CHECK DriverStatus_e rccPllConfig (RccRegisters_t *rcc, uint32_t source, uint32_t m, uint32_t n, uint32_t p)
 Set the PLL's input source and M, N and P.
DRIVER_MUST_CHECK DriverStatus_e rccPllEnable (RccRegisters_t *rcc)
 Turn on the PLL and wait for lock.
DRIVER_MUST_CHECK DriverStatus_e rccPllDisable (RccRegisters_t *rcc)
 Turn off the PLL and wait until PLLRDY clears.

Bus prescalers and SYSCLK

DRIVER_MUST_CHECK DriverStatus_e rccBusPrescalerConfig (RccRegisters_t *rcc, uint32_t hpre, uint32_t ppre1, uint32_t ppre2)
 Set the AHB, APB1 and APB2 prescalers.
DRIVER_MUST_CHECK DriverStatus_e rccSysclkSwitch (RccRegisters_t *rcc, FlashRegisters_t *flash, uint32_t source, uint32_t latency)
 Switch SYSCLK to a ready source and set the flash latency it needs.

Detailed Description

Peripheral clock gating, oscillators, PLL, SYSCLK switch and reset cause.

Macro Definition Documentation

◆ RCC_RESET_FLAGS_Msk

#define RCC_RESET_FLAGS_Msk
Value:
#define RCC_CSR_SFTRSTF
<span class="regaccess">ro</span> Software reset occurred.
Definition rcc_reg.h:288
#define RCC_CSR_IWDGRSTF
<span class="regaccess">ro</span> Independent watchdog reset occurred.
Definition rcc_reg.h:291
#define RCC_CSR_PINRSTF
<span class="regaccess">ro</span> NRST pin reset occurred.
Definition rcc_reg.h:282
#define RCC_CSR_BORRSTF
<span class="regaccess">ro</span> Brown-out reset occurred.
Definition rcc_reg.h:279
#define RCC_CSR_LPWRRSTF
<span class="regaccess">ro</span> Low-power reset occurred.
Definition rcc_reg.h:297
#define RCC_CSR_PORRSTF
<span class="regaccess">ro</span> Power-on reset occurred.
Definition rcc_reg.h:285
#define RCC_CSR_WWDGRSTF
<span class="regaccess">ro</span> Window watchdog reset occurred.
Definition rcc_reg.h:294

Every CSR reset-cause flag; rccResetFlags() returns a subset of these.

Definition at line 108 of file rcc.h.

Referenced by rccResetFlags().

◆ RCC_CLOCK_READY_TIMEOUT_ITERATIONS

#define RCC_CLOCK_READY_TIMEOUT_ITERATIONS   (100000U)

Polls allowed for each oscillator, PLL or SWS wait (see Poll-count timeouts).

Definition at line 16 of file rcc.c.

Referenced by rccSysclkSwitch(), and rccWaitCrFlag().

Function Documentation

◆ rccGpioClockEnable()

DriverStatus_e rccGpioClockEnable ( RccRegisters_t * rcc,
const GpioRegisters_t * port )

Enable a GPIO port's clock.

Parameters
rccRCC block (e.g. RCC).
portPort to enable, GPIOA to GPIOH; compared by address, never dereferenced.
Return values
DRIVER_STATUS_OKEnabled.
DRIVER_STATUS_ERR_INVALID_PARAMport is not GPIOA to GPIOH.

Definition at line 69 of file rcc.c.

References RccRegisters_t::AHB1ENR, DRIVER_STATUS_OK, rccGpioClockBit(), and rccGpioClockEnable().

Referenced by rccGpioClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccGpioClockDisable()

DriverStatus_e rccGpioClockDisable ( RccRegisters_t * rcc,
const GpioRegisters_t * port )

Disable a GPIO port's clock.

Parameters
rccRCC block (e.g. RCC).
portPort to disable, GPIOA to GPIOH.
Return values
DRIVER_STATUS_OKDisabled.
DRIVER_STATUS_ERR_INVALID_PARAMport is not GPIOA to GPIOH.

Definition at line 83 of file rcc.c.

References RccRegisters_t::AHB1ENR, DRIVER_STATUS_OK, rccGpioClockBit(), and rccGpioClockDisable().

Referenced by rccGpioClockDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccUsart2ClockEnable()

void rccUsart2ClockEnable ( RccRegisters_t * rcc)

Enable USART2's clock.

Parameters
rccRCC block (e.g. RCC).

Definition at line 96 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_USART2EN, and rccUsart2ClockEnable().

Referenced by rccUsart2ClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccUsart2ClockDisable()

void rccUsart2ClockDisable ( RccRegisters_t * rcc)

Disable USART2's clock.

Parameters
rccRCC block (e.g. RCC).

Definition at line 102 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_USART2EN, and rccUsart2ClockDisable().

Referenced by rccUsart2ClockDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccWwdgClockEnable()

void rccWwdgClockEnable ( RccRegisters_t * rcc)

Enable the WWDG's clock; needed before any WWDG access.

Parameters
rccRCC block (e.g. RCC).

Definition at line 107 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_WWDGEN, and rccWwdgClockEnable().

Referenced by rccWwdgClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccWwdgClockDisable()

void rccWwdgClockDisable ( RccRegisters_t * rcc)

Disable the WWDG's clock.

Once the WWDG is started, only a reset stops it.

Parameters
rccRCC block (e.g. RCC).

Definition at line 113 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_WWDGEN, and rccWwdgClockDisable().

Referenced by rccWwdgClockDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccSyscfgClockEnable()

void rccSyscfgClockEnable ( RccRegisters_t * rcc)

Enable SYSCFG's clock; needed before any SYSCFG access (e.g.

EXTI routing).

Parameters
rccRCC block (e.g. RCC).

Definition at line 118 of file rcc.c.

References RccRegisters_t::APB2ENR, RCC_APB2ENR_SYSCFGEN, and rccSyscfgClockEnable().

Referenced by rccSyscfgClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccSyscfgClockDisable()

void rccSyscfgClockDisable ( RccRegisters_t * rcc)

Disable SYSCFG's clock.

Parameters
rccRCC block (e.g. RCC).

Definition at line 124 of file rcc.c.

References RccRegisters_t::APB2ENR, RCC_APB2ENR_SYSCFGEN, and rccSyscfgClockDisable().

Referenced by rccSyscfgClockDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccPwrClockEnable()

void rccPwrClockEnable ( RccRegisters_t * rcc)

Enable PWR's clock; needed before any PWR access.

Parameters
rccRCC block (e.g. RCC).

Definition at line 129 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_PWREN, and rccPwrClockEnable().

Referenced by bspClockInit(), and rccPwrClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccPwrClockDisable()

void rccPwrClockDisable ( RccRegisters_t * rcc)

Disable PWR's clock.

Parameters
rccRCC block (e.g. RCC).

Definition at line 135 of file rcc.c.

References RccRegisters_t::APB1ENR, RCC_APB1ENR_PWREN, and rccPwrClockDisable().

Referenced by rccPwrClockDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccResetFlags()

uint32_t rccResetFlags ( const RccRegisters_t * rcc)

The reset-cause flags set since they were last cleared.

Several can be set at once: a power-on reset also sets PINRSTF and BORRSTF, and every internal reset also drives the NRST pin, so PINRSTF accompanies IWDGRSTF, WWDGRSTF and SFTRSTF. Test the specific flag.

Parameters
rccRCC block (e.g. RCC).
Returns
CSR masked to RCC_RESET_FLAGS_Msk, such as RCC_CSR_IWDGRSTF.

Definition at line 140 of file rcc.c.

References RccRegisters_t::CSR, RCC_RESET_FLAGS_Msk, and rccResetFlags().

Referenced by rccResetFlags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccClearResetFlags()

void rccClearResetFlags ( RccRegisters_t * rcc)

Clear every reset-cause flag (CSR.RMVF).

Read them first with rccResetFlags(): they accumulate across resets until cleared.

Parameters
rccRCC block (e.g. RCC).

Definition at line 145 of file rcc.c.

References RccRegisters_t::CSR, RCC_CSR_RMVF, and rccClearResetFlags().

Referenced by rccClearResetFlags().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccHsiEnable()

DriverStatus_e rccHsiEnable ( RccRegisters_t * rcc)

Turn on the 16 MHz internal oscillator (HSI) and wait until ready.

HSI is the reset clock, so this normally returns at once.

Parameters
rccRCC block (e.g. RCC).
Return values
DRIVER_STATUS_OKHSIRDY is set.
DRIVER_STATUS_ERR_TIMEOUTHSIRDY did not set; HSION stays set.

Definition at line 226 of file rcc.c.

References RccRegisters_t::CR, RCC_CR_HSION, RCC_CR_HSIRDY, rccHsiEnable(), and rccWaitCrFlag().

Referenced by rccHsiEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccHsiDisable()

DriverStatus_e rccHsiDisable ( RccRegisters_t * rcc)

Turn off HSI and wait until HSIRDY clears.

Parameters
rccRCC block (e.g. RCC).
Return values
DRIVER_STATUS_OKHSI is off.
DRIVER_STATUS_ERR_BUSYHSI feeds SYSCLK, directly or through the PLL; nothing written.
DRIVER_STATUS_ERR_TIMEOUTHSIRDY stayed set; HSION is cleared.

Definition at line 233 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_OK, RCC_CFGR_SYSCLK_HSI, RCC_CR_HSION, RCC_CR_HSIRDY, RCC_PLLCFGR_PLLSRC_HSI, rccHsiDisable(), rccOscillatorDisableGuard(), and rccWaitCrFlag().

Referenced by rccHsiDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccHseEnable()

DriverStatus_e rccHseEnable ( RccRegisters_t * rcc,
uint32_t bypass )

Turn on the external oscillator (HSE) and wait until ready.

Parameters
rccRCC block (e.g. RCC).
bypassRCC_CR_HSEBYP for an external clock on OSC_IN (the NUCLEO's ST-LINK MCO), or 0 for a crystal.
Return values
DRIVER_STATUS_OKHSERDY is set.
DRIVER_STATUS_ERR_INVALID_PARAMbypass is neither value.
DRIVER_STATUS_ERR_BUSYHSE is already on; call rccHseDisable() first.
DRIVER_STATUS_ERR_TIMEOUTHSERDY did not set; HSEON stays set.

Definition at line 247 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_ERR_BUSY, DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, RCC_CR_HSEBYP, RCC_CR_HSEON, RCC_CR_HSERDY, rccHseEnable(), and rccWaitCrFlag().

Referenced by bspClockInit(), and rccHseEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccHseDisable()

DriverStatus_e rccHseDisable ( RccRegisters_t * rcc)

Turn off HSE and wait until HSERDY clears.

Parameters
rccRCC block (e.g. RCC).
Return values
DRIVER_STATUS_OKHSE is off.
DRIVER_STATUS_ERR_BUSYHSE feeds SYSCLK, directly or through the PLL; nothing written.
DRIVER_STATUS_ERR_TIMEOUTHSERDY stayed set; HSEON is cleared.
Warning
A PLL that is on but not feeding SYSCLK loses its input. Disable it first.

Definition at line 271 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_OK, RCC_CFGR_SYSCLK_HSE, RCC_CR_HSEON, RCC_CR_HSERDY, RCC_PLLCFGR_PLLSRC_HSE, rccHseDisable(), rccOscillatorDisableGuard(), and rccWaitCrFlag().

Referenced by rccHseDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccPllConfig()

DriverStatus_e rccPllConfig ( RccRegisters_t * rcc,
uint32_t source,
uint32_t m,
uint32_t n,
uint32_t p )

Set the PLL's input source and M, N and P.

Checks the register ranges, not the VCO frequency limits. PLLQ is left unchanged.

Parameters
rccRCC block (e.g. RCC).
sourceRCC_PLLCFGR_PLLSRC_HSI or RCC_PLLCFGR_PLLSRC_HSE.
mInput divider, 2-63. VCO input = source / m, must be 1-2 MHz.
nMultiplier, 50-432. VCO output = VCO input x n, must be 100-432 MHz.
pA RCC_PLLCFGR_PLLP_DIV* value. SYSCLK = VCO output / p.
Return values
DRIVER_STATUS_OKPLLCFGR written.
DRIVER_STATUS_ERR_INVALID_PARAMA parameter is out of range.
DRIVER_STATUS_ERR_BUSYThe PLL is on; PLLCFGR is writable only while it is off.

Definition at line 285 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_ERR_BUSY, DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, RccRegisters_t::PLLCFGR, RCC_CR_PLLON, RCC_PLLCFGR_PLLM_Msk, RCC_PLLCFGR_PLLM_Pos, RCC_PLLCFGR_PLLN_Msk, RCC_PLLCFGR_PLLN_Pos, RCC_PLLCFGR_PLLP_Msk, RCC_PLLCFGR_PLLP_Pos, RCC_PLLCFGR_PLLSRC, RCC_PLLCFGR_PLLSRC_HSE, RCC_PLLCFGR_PLLSRC_HSI, and rccPllConfig().

Referenced by bspClockInit(), and rccPllConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccPllEnable()

DriverStatus_e rccPllEnable ( RccRegisters_t * rcc)

Turn on the PLL and wait for lock.

Parameters
rccRCC block (e.g. RCC).
Precondition
rccPllConfig() has run and its source oscillator is ready.
Return values
DRIVER_STATUS_OKPLLRDY is set.
DRIVER_STATUS_ERR_TIMEOUTPLLRDY did not set, usually because the source is not ready. PLLON stays set; call rccPllDisable() to retry.

Definition at line 323 of file rcc.c.

References RccRegisters_t::CR, RCC_CR_PLLON, RCC_CR_PLLRDY, rccPllEnable(), and rccWaitCrFlag().

Referenced by bspClockInit(), and rccPllEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccPllDisable()

DriverStatus_e rccPllDisable ( RccRegisters_t * rcc)

Turn off the PLL and wait until PLLRDY clears.

Parameters
rccRCC block (e.g. RCC).
Return values
DRIVER_STATUS_OKThe PLL is off.
DRIVER_STATUS_ERR_BUSYThe PLL is the SYSCLK source; nothing written.
DRIVER_STATUS_ERR_TIMEOUTPLLRDY stayed set; PLLON is cleared.

Definition at line 330 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_ERR_BUSY, DRIVER_STATUS_OK, RCC_CFGR_SYSCLK_PLL, RCC_CR_PLLON, RCC_CR_PLLRDY, rccActiveSysclkSource(), rccPllDisable(), and rccWaitCrFlag().

Referenced by rccPllDisable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccBusPrescalerConfig()

DriverStatus_e rccBusPrescalerConfig ( RccRegisters_t * rcc,
uint32_t hpre,
uint32_t ppre1,
uint32_t ppre2 )

Set the AHB, APB1 and APB2 prescalers.

The new division takes effect 1 to 16 AHB cycles after the write. Does not check the bus maximums: APB1 at most 45 MHz, APB2 at most 90 MHz.

Parameters
rccRCC block (e.g. RCC).
hpreA RCC_CFGR_HPRE_DIV* value.
ppre1A RCC_CFGR_PPRE_DIV* value for APB1.
ppre2A RCC_CFGR_PPRE_DIV* value for APB2.
Return values
DRIVER_STATUS_OKCFGR written.
DRIVER_STATUS_ERR_INVALID_PARAMA value is not one of its macros.

Definition at line 387 of file rcc.c.

References RccRegisters_t::CFGR, DRIVER_STATUS_OK, RCC_CFGR_HPRE_Msk, RCC_CFGR_HPRE_Pos, RCC_CFGR_PPRE1_Msk, RCC_CFGR_PPRE1_Pos, RCC_CFGR_PPRE2_Msk, RCC_CFGR_PPRE2_Pos, rccBusPrescalerConfig(), rccValidateHpre(), and rccValidatePpre().

Referenced by bspClockInit(), and rccBusPrescalerConfig().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccSysclkSwitch()

DriverStatus_e rccSysclkSwitch ( RccRegisters_t * rcc,
FlashRegisters_t * flash,
uint32_t source,
uint32_t latency )

Switch SYSCLK to a ready source and set the flash latency it needs.

A higher latency is written before the switch; a lower one only after CFGR.SWS confirms the switch, so flash is never read with too few wait states.

Parameters
rccRCC block (e.g. RCC).
flashFlash interface block (e.g. FLASH).
sourceRCC_CFGR_SYSCLK_HSI, RCC_CFGR_SYSCLK_HSE or RCC_CFGR_SYSCLK_PLL.
latencyWait states for the new SYSCLK (RM0390 Table 5); see flashSetLatency().
Precondition
For the PLL, steps 1 to 8 of the bring-up order above have run.
Return values
DRIVER_STATUS_OKSwitched, and the latency is set.
DRIVER_STATUS_ERR_INVALID_PARAMsource or latency is invalid.
DRIVER_STATUS_ERR_NOT_INITIALIZEDsource is not ready.
DRIVER_STATUS_ERR_TIMEOUTSWS never reported source.
DRIVER_STATUS_ERR_HW_FAULTACR.LATENCY did not read back as written.
Note
On NOT_INITIALIZED or TIMEOUT a raised latency stays written. That is safe: extra wait states only slow flash down. A lowered latency is never written unless the switch completed.

Definition at line 413 of file rcc.c.

References FlashRegisters_t::ACR, RccRegisters_t::CFGR, RccRegisters_t::CR, DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_ERR_NOT_INITIALIZED, DRIVER_STATUS_ERR_TIMEOUT, DRIVER_STATUS_OK, FLASH_ACR_LATENCY_Msk, FLASH_ACR_LATENCY_Pos, flashSetLatency(), RCC_CFGR_SW_Msk, RCC_CFGR_SW_Pos, RCC_CFGR_SYSCLK_HSE, RCC_CFGR_SYSCLK_HSI, RCC_CFGR_SYSCLK_PLL, RCC_CLOCK_READY_TIMEOUT_ITERATIONS, RCC_CR_HSERDY, RCC_CR_HSIRDY, RCC_CR_PLLRDY, rccActiveSysclkSource(), and rccSysclkSwitch().

Referenced by bspClockInit(), and rccSysclkSwitch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccGpioClockBit()

DriverStatus_e rccGpioClockBit ( const GpioRegisters_t * port,
uint32_t * bit )
static

Map a GPIO port to its AHB1ENR bit.

Parameters
portPort to identify, compared by address.
bitReceives the GPIOxEN bit; untouched on failure.
Return values
DRIVER_STATUS_OKport is GPIOA to GPIOH.
DRIVER_STATUS_ERR_INVALID_PARAMOtherwise.

Definition at line 25 of file rcc.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, GPIOA, GPIOB, GPIOC, GPIOD, GPIOE, GPIOF, GPIOG, GPIOH, RCC_AHB1ENR_GPIOAEN, RCC_AHB1ENR_GPIOBEN, RCC_AHB1ENR_GPIOCEN, RCC_AHB1ENR_GPIODEN, RCC_AHB1ENR_GPIOEEN, RCC_AHB1ENR_GPIOFEN, RCC_AHB1ENR_GPIOGEN, RCC_AHB1ENR_GPIOHEN, and rccGpioClockBit().

Referenced by rccGpioClockBit(), rccGpioClockDisable(), and rccGpioClockEnable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccActiveSysclkSource()

uint32_t rccActiveSysclkSource ( const RccRegisters_t * rcc)
static

The SYSCLK source in use, from CFGR.SWS (not the requested CFGR.SW).

Parameters
rccRCC block.
Returns
RCC_CFGR_SYSCLK_HSI, RCC_CFGR_SYSCLK_HSE or RCC_CFGR_SYSCLK_PLL.

Definition at line 155 of file rcc.c.

References RccRegisters_t::CFGR, RCC_CFGR_SWS_Msk, RCC_CFGR_SWS_Pos, and rccActiveSysclkSource().

Referenced by rccActiveSysclkSource(), rccOscillatorDisableGuard(), rccPllDisable(), and rccSysclkSwitch().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccOscillatorDisableGuard()

DriverStatus_e rccOscillatorDisableGuard ( const RccRegisters_t * rcc,
uint32_t sysclk_value,
uint32_t pllsrc_value )
static

Report whether an oscillator feeds SYSCLK, directly or through the PLL.

RM0390 ignores clearing HSION/HSEON in either case, so checking SWS alone would report success for a write the hardware dropped.

Parameters
rccRCC block.
sysclk_valueThe oscillator's SW/SWS value (RCC_CFGR_SYSCLK_HSI or _HSE).
pllsrc_valueThe oscillator's PLLSRC value (RCC_PLLCFGR_PLLSRC_HSI or _HSE).
Return values
DRIVER_STATUS_OKNot feeding SYSCLK.
DRIVER_STATUS_ERR_BUSYFeeding SYSCLK.

Definition at line 172 of file rcc.c.

References DRIVER_STATUS_ERR_BUSY, DRIVER_STATUS_OK, RccRegisters_t::PLLCFGR, RCC_CFGR_SYSCLK_PLL, RCC_PLLCFGR_PLLSRC, rccActiveSysclkSource(), and rccOscillatorDisableGuard().

Referenced by rccHseDisable(), rccHsiDisable(), and rccOscillatorDisableGuard().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccWaitCrFlag()

DriverStatus_e rccWaitCrFlag ( const RccRegisters_t * rcc,
uint32_t ready_bit,
uint32_t expected )
static

Poll a CR ready flag until it reaches expected or the budget runs out.

The flag is re-read after the loop, so a flag that settles on the last poll counts as success.

Parameters
rccRCC block.
ready_bitRCC_CR_HSIRDY, RCC_CR_HSERDY or RCC_CR_PLLRDY.
expectedready_bit to wait for set, 0 to wait for clear.
Return values
DRIVER_STATUS_OKThe flag is in the expected state.
DRIVER_STATUS_ERR_TIMEOUTIt is not, after RCC_CLOCK_READY_TIMEOUT_ITERATIONS polls.

Definition at line 207 of file rcc.c.

References RccRegisters_t::CR, DRIVER_STATUS_ERR_TIMEOUT, DRIVER_STATUS_OK, RCC_CLOCK_READY_TIMEOUT_ITERATIONS, and rccWaitCrFlag().

Referenced by rccHseDisable(), rccHseEnable(), rccHsiDisable(), rccHsiEnable(), rccPllDisable(), rccPllEnable(), and rccWaitCrFlag().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccValidateHpre()

DriverStatus_e rccValidateHpre ( uint32_t hpre)
static

Check that hpre is one of the nine RCC_CFGR_HPRE_DIV* values.

Parameters
hpreCandidate HPRE value.
Return values
DRIVER_STATUS_OKValid.
DRIVER_STATUS_ERR_INVALID_PARAMNot a defined divisor.

Definition at line 353 of file rcc.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, RCC_CFGR_HPRE_DIV1, RCC_CFGR_HPRE_DIV128, RCC_CFGR_HPRE_DIV16, RCC_CFGR_HPRE_DIV2, RCC_CFGR_HPRE_DIV256, RCC_CFGR_HPRE_DIV4, RCC_CFGR_HPRE_DIV512, RCC_CFGR_HPRE_DIV64, RCC_CFGR_HPRE_DIV8, and rccValidateHpre().

Referenced by rccBusPrescalerConfig(), and rccValidateHpre().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rccValidatePpre()

DriverStatus_e rccValidatePpre ( uint32_t ppre)
static

Check that ppre is one of the five RCC_CFGR_PPRE_DIV* values.

Parameters
ppreCandidate PPRE1 or PPRE2 value.
Return values
DRIVER_STATUS_OKValid.
DRIVER_STATUS_ERR_INVALID_PARAMNot a defined divisor.

Definition at line 374 of file rcc.c.

References DRIVER_STATUS_ERR_INVALID_PARAM, DRIVER_STATUS_OK, RCC_CFGR_PPRE_DIV1, RCC_CFGR_PPRE_DIV16, RCC_CFGR_PPRE_DIV2, RCC_CFGR_PPRE_DIV4, RCC_CFGR_PPRE_DIV8, and rccValidatePpre().

Referenced by rccBusPrescalerConfig(), and rccValidatePpre().

Here is the call graph for this function:
Here is the caller graph for this function: