|
STM32 RTOS 0.2.3
Bare-metal preemptive RTOS for STM32F446RE
|
RCC driver: peripheral clock gating, HSI/HSE-to-PLL SYSCLK bring-up and the reset cause. More...
#include "driver_status.h"#include "flash_reg.h"#include "gpio_reg.h"#include "rcc_reg.h"#include <stdint.h>Go to the source code of this file.
Functions | |
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. | |
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. | |
Reset cause | |
| #define | RCC_RESET_FLAGS_Msk |
| Every CSR reset-cause flag; rccResetFlags() returns a subset of these. | |
| 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). | |
RCC driver: peripheral clock gating, HSI/HSE-to-PLL SYSCLK bring-up and the reset cause.
Bring-up to a PLL clock must follow this order, which RM0390 imposes (see Clock bring-up order); bspClockInit() is the worked example:
Steps 2 and 3 can swap. Running directly from HSI or HSE needs only steps 3 and 9, plus 8 if the buses must be divided:
Every wait is a bounded poll count, not a time (see Poll-count timeouts). Each enable reads the enable register back, so the clock is running before the caller's first access to the peripheral.
Definition in file rcc.h.