NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
clock.h File Reference

Cortex-M4 specific clock control HAL interface. More...

Include dependency graph for clock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  hal_pll_config_t
 PLL (Phase Locked Loop) configuration structure. More...

Functions

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 system clock frequency (SYSCLK).
uint32_t hal_clock_get_ahbclk (void)
 Get the AHB bus clock frequency.
uint32_t hal_clock_get_apb1clk (void)
 Get the APB1 bus clock frequency.
uint32_t hal_clock_get_apb2clk (void)
 Get the APB2 bus clock frequency.

Detailed Description

Cortex-M4 specific clock control HAL interface.

This header defines the structures and functions to configure and query the system and peripheral clocks for Cortex-M4 microcontrollers. It includes PLL configuration, system clock initialization, and AHB/APB clock retrieval functions.

The HAL provides a platform-independent abstraction while leveraging the Cortex-M4 specific hardware.

Function Documentation

◆ hal_clock_get_ahbclk()

uint32_t hal_clock_get_ahbclk ( void )

Get the AHB bus clock frequency.

Returns
AHB clock frequency in Hz.

Get the AHB bus clock frequency.

Calculated as SYSCLK divided by AHB prescaler.

Returns
AHB bus clock frequency in Hertz.

◆ hal_clock_get_apb1clk()

uint32_t hal_clock_get_apb1clk ( void )

Get the APB1 bus clock frequency.

Returns
APB1 clock frequency in Hz.

Get the APB1 bus clock frequency.

Calculated as SYSCLK divided by APB1 prescaler.

Returns
APB1 bus clock frequency in Hertz.

◆ hal_clock_get_apb2clk()

uint32_t hal_clock_get_apb2clk ( void )

Get the APB2 bus clock frequency.

Returns
APB2 clock frequency in Hz.

Get the APB2 bus clock frequency.

Calculated as SYSCLK divided by APB2 prescaler.

Returns
APB2 bus clock frequency in Hertz.

◆ hal_clock_get_sysclk()

uint32_t hal_clock_get_sysclk ( void )

Get the system clock frequency (SYSCLK).

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

Returns
SYSCLK frequency in Hertz.

◆ hal_clock_init()

void hal_clock_init ( hal_clock_config_t * cfg,
hal_pll_config_t * pll_cfg )

Initialize the system clock.

Parameters
cfgPointer to the main clock configuration structure.
pll_cfgPointer to the PLL configuration structure.
Note
This function must be called before using other peripheral clocks.