11#ifndef __PHAL_G4_RCC_H__
12#define __PHAL_G4_RCC_H__
14#include "common/phal_G4/phal_G4.h"
16#define HSE_CLOCK_RATE_HZ (16'000'000)
18#define HSE_CLOCK_RATE_HZ_INVALID (1)
19#ifndef HSE_CLOCK_RATE_HZ
20#define HSE_CLOCK_RATE_HZ HSE_CLOCK_RATE_HZ_INVALID
23#define HSI_CLOCK_RATE_HZ (16'000'000)
24#define MCO_OUT_PIN (8)
27#if defined(STM32G474xx)
30#define RCC_MAX_VCO_RATE_HZ ((uint32_t)344e6)
31#define RCC_MIN_VCO_RATE_HZ ((uint32_t)64e6)
34#define RCC_MIN_PLL_INPUT_DIVISOR (1U)
35#define RCC_MAX_PLL_INPUT_DIVISOR (16U)
36#define RCC_MIN_PLL_OUTPUT_MULTIPLIER (8U)
37#define RCC_MAX_PLL_OUTPUT_MULTIPLIER (127U)
38#define RCC_MAX_SYSCLK_TARGET_HZ (170'000'000)
41#error "Please define a MCU arch"
72 RCC_ERROR_AHB_INIT = 0,
73 RCC_ERROR_APB1_INIT = 1,
74 RCC_ERROR_APB2_INIT = 2,
75 RCC_ERROR_HSI_INIT = 3,
76 RCC_ERROR_PLLSYS_INIT = 4,
77 RCC_ERROR_PLLVCO_INIT = 5,
78 RCC_ERROR_HSE_INIT = 6,
82 ClockSrc_t clock_source;
84 uint32_t system_clock_target_hz;
85 uint32_t ahb_clock_target_hz;
86 uint32_t apb1_clock_target_hz;
87 uint32_t apb2_clock_target_hz;
91 uint32_t vco_output_rate_target_hz;
92 uint32_t msi_output_rate_target_hz;
bool PHAL_configureAPB1Clock(uint32_t apb1_clock_target_hz)
Configure APB1 Clock rate by modifying the APB1 prescaler value.
Definition rcc.c:318
bool PHAL_configureAHBClock(uint32_t ahb_clock_target_hz)
Configure AHB Clock rate by modifying the AHB prescaler value.
Definition rcc.c:267
bool PHAL_configureHSISystemClock()
Configure HSI CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED...
Definition rcc.c:215
uint8_t PHAL_configureClockRates(ClockRateConfig_t *config)
Configure all AHB/APB/System clocks from the provided configuration.
Definition rcc.c:20
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 T...
Definition rcc.c:121
bool PHAL_configureHSESystemClock()
Configure HSE CLK as the System Clock. SHOULD BE DONE BEFORE ANY OF THE AHB OR APB CLOCKS ARE CHANGED...
Definition rcc.c:237
bool PHAL_configureAPB2Clock(uint32_t apb2_clock_target_hz)
Configure APB1 Clock rate by modifying the APB2 prescaler value.
Definition rcc.c:356
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....
Definition rcc.c:52