STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
Loading...
Searching...
No Matches
rcc.c File Reference

RCC driver implementation (API in rcc.h). More...

#include "rcc.h"
#include "flash.h"
Include dependency graph for rcc.c:

Go to the source code of this file.

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).
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

RCC driver implementation (API in rcc.h).

Definition in file rcc.c.