Core clock library.
More...
#include "stm32g4xx_hal.h"
#include <stdbool.h>
#include <stdint.h>
Go to the source code of this file.
|
|
void | core_clock_ADC12_init () |
| | Set the clocks for ADC1 and ADC2 to SYSCLK and enable them.
|
| |
|
void | core_clock_ADC345_init () |
| | Set the clocks for ADC3, ADC4, and ADC5 to SYSCLK and enable them.
|
| |
| void | core_clock_FDCAN_init (FDCAN_GlobalTypeDef *can) |
| | Set FDCAN clock to PCLK1 and enable it.
|
| |
| bool | core_clock_USART_init (USART_TypeDef *usart) |
| | Set a USART clock to PCLK1 and enable it.
|
| |
| bool | core_clock_timer_init (TIM_TypeDef *timer) |
| | Enable a timer clock.
|
| |
| bool | core_clock_I2C_init (I2C_TypeDef *i2c) |
| | Set an I2C clock to PCLK1 and enable it.
|
| |
| bool | core_clock_RTC_init () |
| | Enable the external 32.768kHz oscillator and set the RTC clock to it.
|
| |
| void | core_clock_port_init (GPIO_TypeDef *port) |
| | Initializes port clock for selected port.
|
| |
| uint8_t | core_clock_generate_params (uint32_t src_freq, uint32_t target_freq, uint8_t *n, uint8_t *m, uint8_t *r) |
| | Generate the settings for the N, M, and R dividers from the clock source frequency and the desired output frequency.
|
| |
| bool | core_clock_init () |
| | Initialize the STM32G4's core clocks.
|
| |
Core clock library.
This core library component is used to initialize peripheral clocks. Generally, it is only necessary to call core_clock_init() from user code. Other clock initialization functions are called by the respective core module init function.
◆ core_clock_FDCAN_init()
| void core_clock_FDCAN_init |
( |
FDCAN_GlobalTypeDef * | can | ) |
|
Set FDCAN clock to PCLK1 and enable it.
Initialize GPIO port clocks corresponding to CAN bus selected
- Parameters
-
| can | FDCAN module to initialize |
◆ core_clock_generate_params()
| uint8_t core_clock_generate_params |
( |
uint32_t | src_freq, |
|
|
uint32_t | target_freq, |
|
|
uint8_t * | n, |
|
|
uint8_t * | m, |
|
|
uint8_t * | r ) |
Generate the settings for the N, M, and R dividers from the clock source frequency and the desired output frequency.
- Parameters
-
| src_freq | Frequency of the clock source of the PLL, in kilohertz |
| target_freq | Desired frequency of the R output of the PLL, in kilohertz |
| n | Location where the setting of the N divider is stored |
| m | Location where the setting of the M divider is stored |
| r | Location where the setting of the R divider is stored |
- Note
- The algorithm used here will try to maximize the frequency of the VCO output. Thus, in certain cases, the algorithm will not find an exact setting, even if one exists.
- Return values
-
| 0 | if the desired setting is outside of the frequency range of the VCO |
| 1 | otherwise |
◆ core_clock_I2C_init()
| bool core_clock_I2C_init |
( |
I2C_TypeDef * | i2c | ) |
|
Set an I2C clock to PCLK1 and enable it.
- Parameters
-
| i2c | I2C module to initialize |
- Return values
-
| 1 | if i2c_num is a valid I2C module |
| 0 | otherwise |
◆ core_clock_init()
Initialize the STM32G4's core clocks.
The SYSCLK frequency will be set to CORE_CLOCK_SYSCLK_FREQ, which is given in kilohertz and defined in core_config.h. This function is generally called immediately after HAL_Init() in the user code.
- Return values
-
◆ core_clock_port_init()
| void core_clock_port_init |
( |
GPIO_TypeDef * | port | ) |
|
Initializes port clock for selected port.
- Parameters
-
| port | Port to initialize clock for |
◆ core_clock_RTC_init()
| bool core_clock_RTC_init |
( |
| ) |
|
Enable the external 32.768kHz oscillator and set the RTC clock to it.
- Return values
-
◆ core_clock_timer_init()
| bool core_clock_timer_init |
( |
TIM_TypeDef * | timer | ) |
|
Enable a timer clock.
- Parameters
-
| timer | Timer to initialize (TIM2 through TIM7) |
- Return values
-
| 1 | if timer is a supported timer module |
| 0 | otherwise |
◆ core_clock_USART_init()
| bool core_clock_USART_init |
( |
USART_TypeDef * | usart | ) |
|
Set a USART clock to PCLK1 and enable it.
- Parameters
-
| usart | USART module to initialize |
- Return values
-
| 1 | if usart_num is a valid USART module |
| 0 | otherwise |