RCC Configuration Driver for STM32F4 Devices.
More...
#include "common/phal_F4_F7/phal_F4_F7.h"
Go to the source code of this file.
|
|
#define | HSE_CLOCK_RATE_HZ (16000000) |
| |
|
#define | HSE_CLOCK_RATE_HZ_INVALID (1) /* High Speed External oscilator value */ |
| |
|
#define | HSI_CLOCK_RATE_HZ (16000000) |
| |
|
#define | MCO_OUT_PIN (8) |
| |
|
| enum | PLLSrc_t { PLL_SRC_HSI16
, PLL_SRC_HSE
} |
| |
| enum | MCO1Source_t { MCO1_SRC_HSI = 0
, MCO1_SRC_LSE = 1
, MCO1_SRC_HSE = 2
, MCO1_SRC_PLL = 3
} |
| |
| enum | MCODivisor_t {
MCO_DIV_NONE = 0
, MCO_DIV_2 = 4
, MCO_DIV_3 = 5
, MCO_DIV_4 = 6
,
MCO_DIV_5 = 7
} |
| |
| enum | ClockSrc_t { CLOCK_SOURCE_HSI = 0
, CLOCK_SOURCE_HSE = 1
} |
| |
| enum | RCCErrors_t {
RCC_ERROR_AHB_INIT = 0
, RCC_ERROR_APB1_INIT = 1
, RCC_ERROR_APB2_INIT = 2
, RCC_ERROR_HSI_INIT = 3
,
RCC_ERROR_PLLSYS_INIT = 4
, RCC_ERROR_PLLVCO_INIT = 5
, RCC_ERROR_HSE_INIT = 6
} |
| |
|
| uint8_t | PHAL_configureClockRates (ClockRateConfig_t *config) |
| | Configure all AHB/APB/System clocks from the provided configuration.
|
| |
| bool | PHAL_configurePLLVCO (PLLSrc_t pll_source, uint32_t vco_output_rate_target_hz) |
| | Configure PLL VCO Clock rate The VCO clock is the input clock for the different PLL outputs. Each PLL output will divide the VCO clock to get its output.
|
| |
| bool | PHAL_configurePLLSystemClock (uint32_t system_clock_target_hz) |
| | Configure PLL CLK as the System Clock at the desired target frequency. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
|
| |
| bool | PHAL_configureHSISystemClock () |
| | Configure HSI CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
|
| |
| bool | PHAL_configureHSESystemClock () |
| | Configure HSE CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
|
| |
| bool | PHAL_configureAHBClock (uint32_t ahb_clock_target_hz) |
| | Configure AHB Clock rate by modifying the AHB prescaler value.
|
| |
| bool | PHAL_configureAPB1Clock (uint32_t apb1_clock_target_hz) |
| | Configure APB1 Clock rate by modifying the APB1 prescaler value.
|
| |
| bool | PHAL_configureAPB2Clock (uint32_t apb2_clock_target_hz) |
| | Configure APB1 Clock rate by modifying the APB2 prescaler value.
|
| |
|
void | PHAL_trimHSI (uint8_t trim_val) |
| | Trim the HSI clock 0 <= trim_val <= 31 17 = increase speed by ~0.2% 15 = decrease speed by ~0.2%.
|
| |
| bool | PHAL_enableMCO1 (GPIO_TypeDef *bank, uint8_t pin, MCO1Source_t source, MCODivisor_t division) |
| | Enable the Clock Out Pin 1 It is highly recommended to change this only after reset before enabling the external oscillators and the PLL.
|
| |
RCC Configuration Driver for STM32F4 Devices.
- Author
- Chris McGalliard (cmcga.nosp@m.lli@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u) - Port of L4 RCC by Adam Busch (busch.nosp@m.8@pu.nosp@m.rdue..nosp@m.edu)
- Version
- 0.1
- Date
- 2023-08-16
- Copyright
- Copyright (c) 2023
◆ PHAL_configureAHBClock()
| bool PHAL_configureAHBClock |
( |
uint32_t | ahb_clock_target_hz | ) |
|
Configure AHB Clock rate by modifying the AHB prescaler value.
- Parameters
-
- Returns
- true Successfully configured AHB clock rate to
- Parameters
-
- Returns
- false
◆ PHAL_configureAPB1Clock()
| bool PHAL_configureAPB1Clock |
( |
uint32_t | apb1_clock_target_hz | ) |
|
Configure APB1 Clock rate by modifying the APB1 prescaler value.
- Parameters
-
- Returns
- true Successfully configured AHB clock rate to
- Parameters
-
- Returns
- false
◆ PHAL_configureAPB2Clock()
| bool PHAL_configureAPB2Clock |
( |
uint32_t | apb2_clock_target_hz | ) |
|
Configure APB1 Clock rate by modifying the APB2 prescaler value.
- Parameters
-
- Returns
- true Successfully configured AHB clock rate to
- Parameters
-
- Returns
- false
◆ PHAL_configureClockRates()
Configure all AHB/APB/System clocks from the provided configuration.
- Parameters
-
| config | Configuration to try to match |
- Returns
- Binary encoded representation of which clocks were unsuccessfuly configured. return value of 0 means all clocks were sucessfully configured.
◆ PHAL_configureHSESystemClock()
| bool PHAL_configureHSESystemClock |
( |
| ) |
|
Configure HSE CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
- Returns
- true Successfully configured HSE clock as system clock
-
false
◆ PHAL_configureHSISystemClock()
| bool PHAL_configureHSISystemClock |
( |
| ) |
|
Configure HSI CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
- Returns
- true Successfully configured HSI clock as system clock
-
false
◆ PHAL_configurePLLSystemClock()
| bool PHAL_configurePLLSystemClock |
( |
uint32_t | system_clock_target_hz | ) |
|
Configure PLL CLK as the System Clock at the desired target frequency. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED.
- Parameters
-
- Returns
- true Successfully configured PLL clock as system clock
-
false
◆ PHAL_configurePLLVCO()
| bool PHAL_configurePLLVCO |
( |
PLLSrc_t | pll_source, |
|
|
uint32_t | vco_output_rate_target_hz ) |
Configure PLL VCO Clock rate The VCO clock is the input clock for the different PLL outputs. Each PLL output will divide the VCO clock to get its output.
- Parameters
-
| PLL | Input rate for PLL, determined by PLL source |
| vco_output_rate_target_hz | Target rate for PLL output |
- Returns
- true
-
false
◆ PHAL_enableMCO1()
| bool PHAL_enableMCO1 |
( |
GPIO_TypeDef * | bank, |
|
|
uint8_t | pin, |
|
|
MCO1Source_t | source, |
|
|
MCODivisor_t | division ) |
Enable the Clock Out Pin 1 It is highly recommended to change this only after reset before enabling the external oscillators and the PLL.
This function should be called after GPIO initialization using GPIO_INIT_MCO1_PA8
- Parameters
-
| bank | GPIO bank |
| pin | GPIO bank |
| source | Clock source to send to the pin |
| division | Division of clock source sent to the pin |
- Returns
- true Successfully enabled the clock out
-
false