Cortex-M4 (STM32F4) Clock HAL Implementation. More...
#include "core/cortex-m4/clock.h"
#include "core/cortex-m4/flash_reg.h"
#include "core/cortex-m4/rcc_reg.h"
#include <stdint.h>
Functions | |
void | _toggle_hse_clock (uint8_t state) |
Initialize system clocks based on the provided configuration. | |
void | _toggle_hsi_clock (uint8_t state) |
void | _toggle_pll_clock (uint8_t state) |
void | hal_clock_init (hal_clock_config_t *cfg, hal_pll_config_t *pll_cfg) |
Initialize the system clock. | |
uint32_t | hal_clock_get_sysclk (void) |
Get the current system clock frequency in Hz. | |
uint32_t | hal_clock_get_ahbclk (void) |
Get the current AHB clock frequency. | |
uint32_t | hal_clock_get_apb1clk (void) |
Get the current APB1 clock frequency. | |
uint32_t | hal_clock_get_apb2clk (void) |
Get the current APB2 clock frequency. |
Cortex-M4 (STM32F4) Clock HAL Implementation.
Provides functions to initialize and retrieve clock frequencies including SYSCLK, AHB, APB1, and APB2 clocks.
This implementation supports HSI, HSE, and PLL clock sources.
void _toggle_hse_clock | ( | uint8_t | state | ) |
Initialize system clocks based on the provided configuration.
Enables and waits for the selected clock source (HSI, HSE, or PLL). If PLL is selected, configures PLL parameters and switches system clock source to PLL output.
cfg | Pointer to clock configuration structure specifying source. |
pll_cfg | Pointer to PLL configuration structure (used if source is PLL). |
void _toggle_hsi_clock | ( | uint8_t | state | ) |
void _toggle_pll_clock | ( | uint8_t | state | ) |
uint32_t hal_clock_get_ahbclk | ( | void | ) |
Get the current AHB clock frequency.
Get the AHB bus clock frequency.
Calculated as SYSCLK divided by AHB prescaler.
uint32_t hal_clock_get_apb1clk | ( | void | ) |
Get the current APB1 clock frequency.
Get the APB1 bus clock frequency.
Calculated as SYSCLK divided by APB1 prescaler.
uint32_t hal_clock_get_apb2clk | ( | void | ) |
Get the current APB2 clock frequency.
Get the APB2 bus clock frequency.
Calculated as SYSCLK divided by APB2 prescaler.
uint32_t hal_clock_get_sysclk | ( | void | ) |
Get the current system clock frequency in Hz.
Get the system clock frequency (SYSCLK).
Detects the current SYSCLK source and calculates frequency based on configured clock source and PLL parameters.
void hal_clock_init | ( | hal_clock_config_t * | cfg, |
hal_pll_config_t * | pll_cfg ) |
Initialize the system clock.
cfg | Pointer to the main clock configuration structure. |
pll_cfg | Pointer to the PLL configuration structure. |