microHAL
An abstraction layer for your future F4xx projects
Loading...
Searching...
No Matches
rcc.c File Reference

Function defines for the RCC driver. More...

#include "defines.h"
#include "rcc.h"

Functions

void rcc_configure_ahb_prescaler (const rcc_ahb_prescaler_t value)
 Set AHB prescaler to the desired value.
 
void rcc_configure_apb_prescaler (const uint8_t apb, const rcc_apb_prescaler_t value)
 Set APBx prescaler to the desired value.
 
void rcc_configure_pll_clk (const struct RCCPLLConfig config, const rcc_pll_target_t target)
 Sets the PLL clocks according to config.
 
void rcc_enable_osc (const rcc_osc_t osc)
 Enable the specified oscillator.
 
void rcc_disable_osc (const rcc_osc_t osc)
 Disable the specified oscillator.
 
void rcc_set_systemclock_src (const rcc_systemclock_src_t source)
 Sets the system clock to the specified source.
 
void rcc_enable_peripheral_clk (const rcc_clk_periph_t peripheral)
 Enables the specified peripheral clock.
 
void rcc_disable_peripheral_clk (const rcc_clk_periph_t peripheral)
 Disables the specified peripheral clock.
 
void rcc_enable_lp_peripheral_clk (const rcc_clk_periph_t peripheral)
 Enables the peripheral in low power mode.
 
void rcc_set_mco1_src (const rcc_mco1_src_t source)
 Set MCO1 to the specified clock source.
 
void rcc_set_mco2_src (const rcc_mco2_src_t source)
 Set MCO2 to the specified clock source.
 
void rcc_configure_mco_prescaler (const uint8_t mco, const rcc_mco_prescaler_t value)
 Set MCOx prescaler to the desired value.
 
void rcc_enable_rtc (const rcc_rtc_src_t source)
 Enables the RTC with specified source.
 
void rcc_disable_rtc (void)
 Disables the RTC.
 
void rcc_configure_rtc_prescaler (const uint8_t value)
 Set RTC HSE prescaler to the desired value.
 

Detailed Description

Function defines for the RCC driver.

This file contains all of the function definitions declared in rcc.h.

Author
Vasileios Ch. (BillisC)
Bug
None, yet.W

Function Documentation

◆ rcc_configure_ahb_prescaler()

void rcc_configure_ahb_prescaler ( const rcc_ahb_prescaler_t value)

Set AHB prescaler to the desired value.

The available prescale dividers are available in the rcc_ahb_prescaler_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
valueThe prescaler divide value
Returns
None

◆ rcc_configure_apb_prescaler()

void rcc_configure_apb_prescaler ( const uint8_t apb,
const rcc_apb_prescaler_t value )

Set APBx prescaler to the desired value.

The available prescale dividers are available in the rcc_apb_prescaler_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
apbThe selected APB (1..2)
valueThe prescaler divide value
Returns
None

◆ rcc_configure_mco_prescaler()

void rcc_configure_mco_prescaler ( const uint8_t mco,
const rcc_mco_prescaler_t value )

Set MCOx prescaler to the desired value.

The available prescale dividers are available in the rcc_mco_prescaler_t enum. Any other value will be ignored.

Parameters
mcoThe selected MCO (1..2)
valueThe prescaler divide value
Returns
None

◆ rcc_configure_pll_clk()

void rcc_configure_pll_clk ( const struct RCCPLLConfig config,
const rcc_pll_target_t target )

Sets the PLL clocks according to config.

The configuration values can be found in the RCCPLLConfig struct. Extra care must be taken with PLL values as their bits are not the same and wrapping may happen. Also a target (PLL, I2S, SAI) must be specified. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
peripheralThe peripheral clock
targetThe target PLL
Returns
None

◆ rcc_configure_rtc_prescaler()

void rcc_configure_rtc_prescaler ( const uint8_t value)

Set RTC HSE prescaler to the desired value.

Parameters
valueThe prescaler divide value (0..31)
Returns
None

◆ rcc_disable_osc()

void rcc_disable_osc ( const rcc_osc_t osc)

Disable the specified oscillator.

The available oscilattors are available in the rcc_osc_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
oscThe selected oscillator
Returns
None

◆ rcc_disable_peripheral_clk()

void rcc_disable_peripheral_clk ( const rcc_clk_periph_t peripheral)

Disables the specified peripheral clock.

The available peripherals can be found in the rcc_clk_periph_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
peripheralThe peripheral clock
Returns
None

◆ rcc_enable_lp_peripheral_clk()

void rcc_enable_lp_peripheral_clk ( const rcc_clk_periph_t peripheral)

Enables the peripheral in low power mode.

The available peripherals can be found in the rcc_clk_periph_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

DISCLAIMER: Only enable peripherals that actually exist on hardware!

Parameters
peripheralThe peripheral clock
Returns
None

◆ rcc_enable_osc()

void rcc_enable_osc ( const rcc_osc_t osc)

Enable the specified oscillator.

The available oscilattors are available in the rcc_osc_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
oscThe selected oscillator
Returns
None

◆ rcc_enable_peripheral_clk()

void rcc_enable_peripheral_clk ( const rcc_clk_periph_t peripheral)

Enables the specified peripheral clock.

The available peripherals can be found in the rcc_clk_periph_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

DISCLAIMER: Only enable peripherals that actually exist on hardware!

Parameters
peripheralThe peripheral clock
Returns
None

◆ rcc_enable_rtc()

void rcc_enable_rtc ( const rcc_rtc_src_t source)

Enables the RTC with specified source.

The available RTC sources can be found in the rcc_rtc_src_t enum. Any other value will be ignored.

Parameters
sourceThe RTC clock source
Returns
None

◆ rcc_set_mco1_src()

void rcc_set_mco1_src ( const rcc_mco1_src_t source)

Set MCO1 to the specified clock source.

The available source clocks are available in the rcc_mco1_src_t enum. Any other value will be ignored.

Parameters
sourceThe specified clock source
Returns
None

◆ rcc_set_mco2_src()

void rcc_set_mco2_src ( const rcc_mco2_src_t source)

Set MCO2 to the specified clock source.

The available source clocks are available in the rcc_mco2_src_t enum. Any other value will be ignored.

Parameters
sourceThe specified clock source
Returns
None

◆ rcc_set_systemclock_src()

void rcc_set_systemclock_src ( const rcc_systemclock_src_t source)

Sets the system clock to the specified source.

The available systemclock sources are located in the rcc_systemclock_src_t enum. Any other value will be ignored. A DSB instruction is inserted after each RCC register write as per errata.

Parameters
sourceThe selected clock source
Returns
None