PER Firmware
Loading...
Searching...
No Matches
rcc.c File Reference

G4 RCC public API implementation. More...

Include dependency graph for rcc.c:

Functions

static void rcc_initFromOscillator (bool use_hse, bool use_pll)
 
void PHAL_RCC_init (PHAL_RCC_Mode_t mode)
 Configure the system, AHB, APB1, and APB2 clocks for a supported clock tree.
 
uint32_t PHAL_RCC_getSystemClockHz (void)
 
uint32_t PHAL_RCC_getAHBClockHz (void)
 
uint32_t PHAL_RCC_getAPB1ClockHz (void)
 
uint32_t PHAL_RCC_getAPB2ClockHz (void)
 

Variables

static uint32_t g_system_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
 
static uint32_t g_ahb_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
 
static uint32_t g_apb1_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
 
static uint32_t g_apb2_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
 

Detailed Description

G4 RCC public API implementation.

Author
Millan Kumar (kumar.nosp@m.798@.nosp@m.purdu.nosp@m.e.ed.nosp@m.u)

Function Documentation

◆ PHAL_RCC_getAHBClockHz()

uint32_t PHAL_RCC_getAHBClockHz ( void )
Returns
the current AHB (HCLK) rate in Hz

◆ PHAL_RCC_getAPB1ClockHz()

uint32_t PHAL_RCC_getAPB1ClockHz ( void )
Returns
the current APB1 (PCLK1) rate in Hz
Here is the caller graph for this function:

◆ PHAL_RCC_getAPB2ClockHz()

uint32_t PHAL_RCC_getAPB2ClockHz ( void )
Returns
the current APB2 (PCLK2) rate in Hz
Here is the caller graph for this function:

◆ PHAL_RCC_getSystemClockHz()

uint32_t PHAL_RCC_getSystemClockHz ( void )
Returns
the current system clock (SYSCLK) rate in Hz

◆ PHAL_RCC_init()

void PHAL_RCC_init ( PHAL_RCC_Mode_t mode)

Configure the system, AHB, APB1, and APB2 clocks for a supported clock tree.

  • The *_16MHZ modes run directly from the input oscillator (HSI16, or the board's 16 MHz HSE input in bypass mode) with no PLL
    • 0 Flash wait states
    • AHB = APB1 = APB2 = 16 MHz
  • The *_170MHZ modes feed the input oscillator through the PLL (PLLM=4, PLLN=85, PLLR=2) for a clock speed of exactly 170 MHz
    • Enable Range 1 boost mode
    • Set 4 Flash wait states
    • AHB = APB1 = APB2 = 170 MHz

The unselected input oscillator will be disabled once this function ends:

  • HSI is on by default out of reset
  • If HSI is selected, we don't turn it off
  • For an HSE mode, HSI is switched off once it's no longer needed
Parameters
modeone of the four supported clock configurations
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rcc_initFromOscillator()

static void rcc_initFromOscillator ( bool use_hse,
bool use_pll )
static
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ g_ahb_clock_hz

uint32_t g_ahb_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
static

◆ g_apb1_clock_hz

uint32_t g_apb1_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
static

◆ g_apb2_clock_hz

uint32_t g_apb2_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
static

◆ g_system_clock_hz

uint32_t g_system_clock_hz = RCC_PRIV_HSI_CLOCK_RATE_HZ
static