STM32G474xx HAL用户手册
stm32g4xx_hal_rcc.h
转到此文件的文档。
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_hal_rcc.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RCC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file in
00013   * the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   ******************************************************************************
00016   */
00017 
00018 /* Define to prevent recursive inclusion -------------------------------------*/
00019 #ifndef STM32G4xx_HAL_RCC_H
00020 #define STM32G4xx_HAL_RCC_H
00021 
00022 #ifdef __cplusplus
00023  extern "C" {
00024 #endif
00025 
00026 /* Includes ------------------------------------------------------------------*/
00027 #include "stm32g4xx_hal_def.h"
00028 
00029 /** @addtogroup STM32G4xx_HAL_Driver
00030   * @{
00031   */
00032 
00033 /** @addtogroup RCC
00034   * @{
00035   */
00036 
00037 /* Exported types ------------------------------------------------------------*/
00038 /** @defgroup RCC_Exported_Types RCC Exported Types
00039   * @{
00040   */
00041 
00042 /**
00043   * @brief  RCC PLL configuration structure definition
00044   */
00045 typedef struct
00046 {
00047   uint32_t PLLState;   /*!< PLL的新状态。
00048                             此参数可以是@ref RCC_PLL_Config的值                      */
00049 
00050   uint32_t PLLSource;  /*!< RCC_PLLSource:PLL输入时钟源。
00051                             此参数必须是@ref RCC_PLL_Clock_Source的值               */
00052 
00053   uint32_t PLLM;       /*!< PLLM:PLL VCO输入时钟的分频系数。
00054                             此参数必须是@ref RCC_PLLM_Clock_Divider的值             */
00055 
00056   uint32_t PLLN;       /*!< PLLN:PLL VCO输出时钟的倍频系数。
00057                             此参数必须是Min_Data = 8和Max_Data = 127之间的数字    */
00058 
00059   uint32_t PLLP;       /*!< PLLP:ADC时钟的分频系数。
00060                             此参数必须是@ref RCC_PLLP_Clock_Divider的值             */
00061 
00062   uint32_t PLLQ;       /*!< PLLQ:SAI、I2S、USB、FDCAN和QUADSPI时钟的分频系数。
00063                             此参数必须是@ref RCC_PLLQ_Clock_Divider的值             */
00064 
00065   uint32_t PLLR;       /*!< PLLR:主系统时钟的分频。
00066                             用户必须正确设置PLLR参数以不超过最大频率170MHZ。
00067                             此参数必须是@ref RCC_PLLR_Clock_Divider的值             */
00068 
00069 }RCC_PLLInitTypeDef;
00070 
00071 /**
00072   * @brief  RCC内部/外部振荡器(HSE、HSI、LSE和LSI)配置结构定义
00073   */
00074 typedef struct
00075 {
00076   uint32_t OscillatorType;       /*!< 要配置的振荡器。
00077                                       此参数可以是@ref RCC_Oscillator_Type的值                   */
00078 
00079   uint32_t HSEState;             /*!< HSE的新状态。
00080                                       此参数可以是@ref RCC_HSE_Config的值                        */
00081 
00082   uint32_t LSEState;             /*!< LSE的新状态。
00083                                       此参数可以是@ref RCC_LSE_Config的值                        */
00084 
00085   uint32_t HSIState;             /*!< HSI的新状态。
00086                                       此参数可以是@ref RCC_HSI_Config的值                        */
00087 
00088   uint32_t HSICalibrationValue;  /*!< 校准微调值(默认值为RCC_HSICALIBRATION_DEFAULT)。
00089                                       此参数必须是Min_Data = 0x00和Max_Data = 0xFF之间的数字 */
00090 
00091   uint32_t LSIState;             /*!< LSI的新状态。
00092                                       此参数可以是@ref RCC_LSI_Config的值                        */
00093 
00094   uint32_t HSI48State;             /*!< HSI48的新状态。
00095                                         此参数可以是@ref RCC_HSI48_Config的值 */
00096 
00097   RCC_PLLInitTypeDef PLL;        /*!< 主PLL结构参数                                               */
00098 
00099 }RCC_OscInitTypeDef;
00100 
00101 /**
00102   * @brief  RCC系统、AHB和APB总线时钟配置结构定义
00103   */
00104 typedef struct
00105 {
00106   uint32_t ClockType;             /*!< 要配置的时钟。
00107                                        此参数可以是@ref RCC_System_Clock_Type的值      */
00108 
00109   uint32_t SYSCLKSource;          /*!< 用作系统时钟(SYSCLK)的时钟源。
00110                                        此参数可以是@ref RCC_System_Clock_Source的值    */
00111 
00112   uint32_t AHBCLKDivider;         /*!< AHB时钟(HCLK)分频器。此时钟源自系统时钟(SYSCLK)。
00113                                        此参数可以是@ref RCC_AHB_Clock_Source的值       */
00114 
00115   uint32_t APB1CLKDivider;        /*!< APB1时钟(PCLK1)分频器。此时钟源自AHB时钟(HCLK)。
00116                                        此参数可以是@ref RCC_APB1_APB2_Clock_Source的值 */
00117 
00118   uint32_t APB2CLKDivider;        /*!< APB2时钟(PCLK2)分频器。此时钟源自AHB时钟(HCLK)。
00119                                        此参数可以是@ref RCC_APB1_APB2_Clock_Source的值 */
00120 
00121 }RCC_ClkInitTypeDef;
00122 
00123 /**
00124   * @}
00125   */
00126 
00127 /* Exported constants --------------------------------------------------------*/
00128 /** @defgroup RCC_Exported_Constants RCC Exported Constants
00129   * @{
00130   */
00131 
00132 /** @defgroup RCC_Timeout_Value Timeout Values
00133   * @{
00134   */
00135 #define RCC_DBP_TIMEOUT_VALUE          2U                        /* 2 ms (minimum Tick + 1) */
00136 #define RCC_LSE_TIMEOUT_VALUE          LSE_STARTUP_TIMEOUT
00137 /**
00138   * @}
00139   */
00140 
00141 /** @defgroup RCC_Oscillator_Type Oscillator Type
00142   * @{
00143   */
00144 #define RCC_OSCILLATORTYPE_NONE        0x00000000U               /*!< 振荡器配置未更改 */
00145 #define RCC_OSCILLATORTYPE_HSE         0x00000001U               /*!< 要配置的HSE */
00146 #define RCC_OSCILLATORTYPE_HSI         0x00000002U               /*!< 要配置的HSI */
00147 #define RCC_OSCILLATORTYPE_LSE         0x00000004U               /*!< 要配置的LSE */
00148 #define RCC_OSCILLATORTYPE_LSI         0x00000008U               /*!< 要配置的LSI */
00149 #define RCC_OSCILLATORTYPE_HSI48       0x00000020U               /*!< 要配置的HSI48 */
00150 /**
00151   * @}
00152   */
00153 
00154 /** @defgroup RCC_HSE_Config HSE Config
00155   * @{
00156   */
00157 #define RCC_HSE_OFF                    0x00000000U                                /*!< HSE时钟去激活 */
00158 #define RCC_HSE_ON                     RCC_CR_HSEON                               /*!< HSE时钟激活 */
00159 #define RCC_HSE_BYPASS                 (RCC_CR_HSEBYP | RCC_CR_HSEON)             /*!< HSE时钟的外部时钟源 */
00160 /**
00161   * @}
00162   */
00163 
00164 /** @defgroup RCC_LSE_Config LSE Config
00165   * @{
00166   */
00167 #define RCC_LSE_OFF                    0x00000000U                                    /*!< LSE时钟去激活 */
00168 #define RCC_LSE_ON                     RCC_BDCR_LSEON                                 /*!< LSE时钟激活 */
00169 #define RCC_LSE_BYPASS                 (RCC_BDCR_LSEBYP | RCC_BDCR_LSEON)             /*!< LSE时钟的外部时钟源 */
00170 /**
00171   * @}
00172   */
00173 
00174 /** @defgroup RCC_HSI_Config HSI Config
00175   * @{
00176   */
00177 #define RCC_HSI_OFF                    0x00000000U            /*!< HSI时钟去激活 */
00178 #define RCC_HSI_ON                     RCC_CR_HSION           /*!< HSI时钟激活 */
00179 #define RCC_HSICALIBRATION_DEFAULT     0x40U                  /* 默认HSI校准微调值 */
00180 /**
00181   * @}
00182   */
00183 
00184 /**