STM32F479xx HAL User Manual
stm32f4xx_hal_rcc.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32f4xx_hal_rcc.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of RCC HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.</center></h2>
00011   *
00012   * This software component is licensed by ST under BSD 3-Clause license,
00013   * the "License"; You may not use this file except in compliance with the
00014   * License. You may obtain a copy of the License at:
00015   *                        opensource.org/licenses/BSD-3-Clause
00016   *
00017   ******************************************************************************
00018   */
00019 
00020 /* Define to prevent recursive inclusion -------------------------------------*/
00021 #ifndef __STM32F4xx_HAL_RCC_H
00022 #define __STM32F4xx_HAL_RCC_H
00023 
00024 #ifdef __cplusplus
00025  extern "C" {
00026 #endif
00027 
00028 /* Includes ------------------------------------------------------------------*/
00029 #include "stm32f4xx_hal_def.h"
00030 
00031 /* Include RCC HAL Extended module */
00032 /* (include on top of file since RCC structures are defined in extended file) */
00033 #include "stm32f4xx_hal_rcc_ex.h"
00034 
00035 /** @addtogroup STM32F4xx_HAL_Driver
00036   * @{
00037   */
00038 
00039 /** @addtogroup RCC
00040   * @{
00041   */
00042 
00043 /* Exported types ------------------------------------------------------------*/
00044 /** @defgroup RCC_Exported_Types RCC Exported Types
00045   * @{
00046   */
00047 
00048 /**
00049   * @brief  RCC Internal/External Oscillator (HSE, HSI, LSE and LSI) configuration structure definition
00050   */
00051 typedef struct
00052 {
00053   uint32_t OscillatorType;       /*!< The oscillators to be configured.
00054                                       This parameter can be a value of @ref RCC_Oscillator_Type                   */
00055 
00056   uint32_t HSEState;             /*!< The new state of the HSE.
00057                                       This parameter can be a value of @ref RCC_HSE_Config                        */
00058 
00059   uint32_t LSEState;             /*!< The new state of the LSE.
00060                                       This parameter can be a value of @ref RCC_LSE_Config                        */
00061 
00062   uint32_t HSIState;             /*!< The new state of the HSI.
00063                                       This parameter can be a value of @ref RCC_HSI_Config                        */
00064 
00065   uint32_t HSICalibrationValue;  /*!< The HSI calibration trimming value (default is RCC_HSICALIBRATION_DEFAULT).
00066                                        This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
00067 
00068   uint32_t LSIState;             /*!< The new state of the LSI.
00069                                       This parameter can be a value of @ref RCC_LSI_Config                        */
00070 
00071   RCC_PLLInitTypeDef PLL;        /*!< PLL structure parameters                                                    */
00072 }RCC_OscInitTypeDef;
00073 
00074 /**
00075   * @brief  RCC System, AHB and APB busses clock configuration structure definition
00076   */
00077 typedef struct
00078 {
00079   uint32_t ClockType;             /*!< The clock to be configured.
00080                                        This parameter can be a value of @ref RCC_System_Clock_Type      */
00081 
00082   uint32_t SYSCLKSource;          /*!< The clock source (SYSCLKS) used as system clock.
00083                                        This parameter can be a value of @ref RCC_System_Clock_Source    */
00084 
00085   uint32_t AHBCLKDivider;         /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
00086                                        This parameter can be a value of @ref RCC_AHB_Clock_Source       */
00087 
00088   uint32_t APB1CLKDivider;        /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
00089                                        This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
00090 
00091   uint32_t APB2CLKDivider;        /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
00092                                        This parameter can be a value of @ref RCC_APB1_APB2_Clock_Source */
00093 
00094 }RCC_ClkInitTypeDef;
00095 
00096 /**
00097   * @}
00098   */
00099 
00100 /* Exported constants --------------------------------------------------------*/
00101 /** @defgroup RCC_Exported_Constants RCC Exported Constants
00102   * @{
00103   */
00104 
00105 /** @defgroup RCC_Oscillator_Type Oscillator Type
00106   * @{
00107   */
00108 #define RCC_OSCILLATORTYPE_NONE            0x00000000U
00109 #define RCC_OSCILLATORTYPE_HSE             0x00000001U
00110 #define RCC_OSCILLATORTYPE_HSI             0x00000002U
00111 #define RCC_OSCILLATORTYPE_LSE             0x00000004U
00112 #define RCC_OSCILLATORTYPE_LSI             0x00000008U
00113 /**
00114   * @}
00115   */
00116 
00117 /** @defgroup RCC_HSE_Config HSE Config
00118   * @{
00119   */
00120 #define RCC_HSE_OFF                      0x00000000U
00121 #define RCC_HSE_ON                       RCC_CR_HSEON
00122 #define RCC_HSE_BYPASS                   ((uint32_t)(RCC_CR_HSEBYP | RCC_CR_HSEON))
00123 /**
00124   * @}
00125   */
00126 
00127 /** @defgroup RCC_LSE_Config LSE Config
00128   * @{
00129   */
00130 #define RCC_LSE_OFF                    0x00000000U
00131 #define RCC_LSE_ON                     RCC_BDCR_LSEON
00132 #define RCC_LSE_BYPASS                 ((uint32_t)(RCC_BDCR_LSEBYP | RCC_BDCR_LSEON))
00133 /**
00134   * @}
00135   */
00136 
00137 /** @defgroup RCC_HSI_Config HSI Config
00138   * @{
00139   */
00140 #define RCC_HSI_OFF                      ((uint8_t)0x00)
00141 #define RCC_HSI_ON                       ((uint8_t)0x01)
00142 
00143 #define RCC_HSICALIBRATION_DEFAULT       0x10U         /* Default HSI calibration trimming value */
00144 /**
00145   * @}
00146   */
00147 
00148 /** @defgroup RCC_LSI_Config LSI Config
00149   * @{
00150   */
00151 #define RCC_LSI_OFF                      ((uint8_t)0x00)
00152 #define RCC_LSI_ON                       ((uint8_t)0x01)
00153 /**
00154   * @}
00155   */
00156 
00157 /** @defgroup RCC_PLL_Config PLL Config
00158   * @{
00159   */
00160 #define RCC_PLL_NONE                      ((uint8_t)0x00)
00161 #define RCC_PLL_OFF                       ((uint8_t)0x01)
00162 #define RCC_PLL_ON                        ((uint8_t)0x02)
00163 /**
00164   * @}
00165   */
00166 
00167 /** @defgroup RCC_PLLP_Clock_Divider PLLP Clock Divider
00168   * @{
00169   */
00170 #define RCC_PLLP_DIV2                  0x00000002U
00171 #define RCC_PLLP_DIV4                  0x00000004U
00172 #define RCC_PLLP_DIV6                  0x00000006U
00173 #define RCC_PLLP_DIV8                  0x00000008U
00174 /**
00175   * @}
00176   */
00177 
00178 /** @defgroup RCC_PLL_Clock_Source PLL Clock Source
00179   * @{
00180   */
00181 #define RCC_PLLSOURCE_HSI                RCC_PLLCFGR_PLLSRC_HSI
00182 #define RCC_PLLSOURCE_HSE                RCC_PLLCFGR_PLLSRC_HSE
00183 /**
00184   * @}
00185   */
00186 
00187 /** @defgroup RCC_System_Clock_Type System Clock Type
00188   * @{
00189   */
00190 #define RCC_CLOCKTYPE_SYSCLK             0x00000001U
00191 #define RCC_CLOCKTYPE_HCLK               0x00000002U
00192 #define RCC_CLOCKTYPE_PCLK1              0x00000004U
00193 #define RCC_CLOCKTYPE_PCLK2              0x00000008U
00194 /**
00195   * @}
00196   */
00197 
00198 /** @defgroup RCC_System_Clock_Source System Clock Source
00199   * @note     The RCC_SYSCLKSOURCE_PLLRCLK parameter is available only for
00200   *           STM32F446xx devices.
00201   * @{
00202   */
00203 #define RCC_SYSCLKSOURCE_HSI             RCC_CFGR_SW_HSI
00204 #define RCC_SYSCLKSOURCE_HSE             RCC_CFGR_SW_HSE
00205 #define RCC_SYSCLKSOURCE_PLLCLK          RCC_CFGR_SW_PLL
00206 #define RCC_SYSCLKSOURCE_PLLRCLK         ((uint32_t)(RCC_CFGR_SW_0 | RCC_CFGR_SW_1))
00207 /**
00208   * @}
00209   */
00210 
00211 /** @defgroup RCC_System_Clock_Source_Status System Clock Source Status
00212   * @note     The RCC_SYSCLKSOURCE_STATUS_PLLRCLK parameter is available only for
00213   *           STM32F446xx devices.
00214   * @{
00215   */
00216 #define RCC_SYSCLKSOURCE_STATUS_HSI     RCC_CFGR_SWS_HSI   /*!< HSI used as system clock */
00217 #define RCC_SYSCLKSOURCE_STATUS_HSE     RCC_CFGR_SWS_HSE   /*!< HSE used as system clock */
00218 #define RCC_SYSCLKSOURCE_STATUS_PLLCLK  RCC_CFGR_SWS_PLL   /*!< PLL used as system clock */
00219 #define RCC_SYSCLKSOURCE_STATUS_PLLRCLK ((uint32_t)(RCC_CFGR_SWS_0 | RCC_CFGR_SWS_1))   /*!< PLLR used as system clock */
00220 /**
00221   * @}
00222   */
00223 
00224 /** @defgroup RCC_AHB_Clock_Source AHB Clock Source
00225   * @{
00226   */
00227 #define RCC_SYSCLK_DIV1                  RCC_CFGR_HPRE_DIV1
00228 #define RCC_SYSCLK_DIV2                  RCC_CFGR_HPRE_DIV2
00229 #define RCC_SYSCLK_DIV4                  RCC_CFGR_HPRE_DIV4
00230 #define RCC_SYSCLK_DIV8                  RCC_CFGR_HPRE_DIV8
00231 #define RCC_SYSCLK_DIV16                 RCC_CFGR_HPRE_DIV16
00232 #define RCC_SYSCLK_DIV64                 RCC_CFGR_HPRE_DIV64
00233 #define RCC_SYSCLK_DIV128                RCC_CFGR_HPRE_DIV128
00234 #define RCC_SYSCLK_DIV256                RCC_CFGR_HPRE_DIV256
00235 #define RCC_SYSCLK_DIV512                RCC_CFGR_HPRE_DIV512
00236 /**
00237   * @}
00238   */
00239 
00240 /** @defgroup RCC_APB1_APB2_Clock_Source APB1/APB2 Clock Source
00241   * @{
00242   */
00243 #define RCC_HCLK_DIV1                    RCC_CFGR_PPRE1_DIV1
00244 #define RCC_HCLK_DIV2                    RCC_CFGR_PPRE1_DIV2
00245 #define RCC_HCLK_DIV4                    RCC_CFGR_PPRE1_DIV4
00246 #define RCC_HCLK_DIV8                    RCC_CFGR_PPRE1_DIV8
00247 #define RCC_HCLK_DIV16                   RCC_CFGR_PPRE1_DIV16
00248 /**
00249   * @}
00250   */
00251 
00252 /** @defgroup RCC_RTC_Clock_Source RTC Clock Source
00253   * @{
00254   */
00255 #define RCC_RTCCLKSOURCE_NO_CLK          0x00000000U
00256 #define RCC_RTCCLKSOURCE_LSE             0x00000100U
00257 #define RCC_RTCCLKSOURCE_LSI             0x00000200U
00258 #define RCC_RTCCLKSOURCE_HSE_DIVX        0x00000300U
00259 #define RCC_RTCCLKSOURCE_HSE_DIV2        0x00020300U
00260 #define RCC_RTCCLKSOURCE_HSE_DIV3        0x00030300U
00261 #define RCC_RTCCLKSOURCE_HSE_DIV4        0x00040300U
00262 #define RCC_RTCCLKSOURCE_HSE_DIV5        0x00050300U
00263 #define RCC_RTCCLKSOURCE_HSE_DIV6        0x00060300U
00264 #define RCC_RTCCLKSOURCE_HSE_DIV7        0x00070300U
00265 #define RCC_RTCCLKSOURCE_HSE_DIV8        0x00080300U
00266 #define RCC_RTCCLKSOURCE_HSE_DIV9        0x00090300U
00267 #define RCC_RTCCLKSOURCE_HSE_DIV10       0x000A0300U
00268 #define RCC_RTCCLKSOURCE_HSE_DIV11       0x000B0300U
00269 #define RCC_RTCCLKSOURCE_HSE_DIV12       0x000C0300U
00270 #define RCC_RTCCLKSOURCE_HSE_DIV13       0x000D0300U
00271 #define RCC_RTCCLKSOURCE_HSE_DIV14       0x000E0300U
00272 #define RCC_RTCCLKSOURCE_HSE_DIV15       0x000F0300U
00273 #define RCC_RTCCLKSOURCE_HSE_DIV16       0x00100300U
00274 #define RCC_RTCCLKSOURCE_HSE_DIV17       0x00110300U
00275 #define RCC_RTCCLKSOURCE_HSE_DIV18       0x00120300U
00276 #define RCC_RTCCLKSOURCE_HSE_DIV19       0x00130300U
00277 #define RCC_RTCCLKSOURCE_HSE_DIV20       0x00140300U
00278 #define RCC_RTCCLKSOURCE_HSE_DIV21       0x00150300U
00279 #define RCC_RTCCLKSOURCE_HSE_DIV22       0x00160300U
00280 #define RCC_RTCCLKSOURCE_HSE_DIV23       0x00170300U
00281 #define RCC_RTCCLKSOURCE_HSE_DIV24       0x00180300U
00282 #define RCC_RTCCLKSOURCE_HSE_DIV25       0x00190300U
00283 #define RCC_RTCCLKSOURCE_HSE_DIV26       0x001A0300U
00284 #define RCC_RTCCLKSOURCE_HSE_DIV27       0x001B0300U
00285 #define RCC_RTCCLKSOURCE_HSE_DIV28       0x001C0300U
00286 #define RCC_RTCCLKSOURCE_HSE_DIV29       0x001D0300U
00287 #define RCC_RTCCLKSOURCE_HSE_DIV30       0x001E0300U
00288 #define RCC_RTCCLKSOURCE_HSE_DIV31       0x001F0300U
00289 /**
00290   * @}
00291   */
00292 
00293 /** @defgroup RCC_MCO_Index MCO Index
00294   * @{
00295   */
00296 #define RCC_MCO1                         0x00000000U
00297 #define RCC_MCO2                         0x00000001U
00298 /**
00299   * @}
00300   */
00301 
00302 /** @defgroup RCC_MCO1_Clock_Source MCO1 Clock Source
00303   * @{
00304   */
00305 #define RCC_MCO1SOURCE_HSI               0x00000000U
00306 #define RCC_MCO1SOURCE_LSE               RCC_CFGR_MCO1_0
00307 #define RCC_MCO1SOURCE_HSE               RCC_CFGR_MCO1_1
00308 #define RCC_MCO1SOURCE_PLLCLK            RCC_CFGR_MCO1
00309 /**
00310   * @}
00311   */
00312 
00313 /** @defgroup RCC_MCOx_Clock_Prescaler MCOx Clock Prescaler
00314   * @{
00315   */
00316 #define RCC_MCODIV_1                    0x00000000U
00317 #define RCC_MCODIV_2                    RCC_CFGR_MCO1PRE_2
00318 #define RCC_MCODIV_3                    ((uint32_t)RCC_CFGR_MCO1PRE_0 | RCC_CFGR_MCO1PRE_2)
00319 #define RCC_MCODIV_4                    ((uint32_t)RCC_CFGR_MCO1PRE_1 | RCC_CFGR_MCO1PRE_2)
00320 #define RCC_MCODIV_5                    RCC_CFGR_MCO1PRE
00321 /**
00322   * @}
00323   */
00324 
00325 /** @defgroup RCC_Interrupt Interrupts
00326   * @{
00327   */
00328 #define RCC_IT_LSIRDY                    ((uint8_t)0x01)
00329 #define RCC_IT_LSERDY                    ((uint8_t)0x02)
00330 #define RCC_IT_HSIRDY                    ((uint8_t)0x04)
00331 #define RCC_IT_HSERDY                    ((uint8_t)0x08)
00332 #define RCC_IT_PLLRDY                    ((uint8_t)0x10)
00333 #define RCC_IT_PLLI2SRDY                 ((uint8_t)0x20)
00334 #define RCC_IT_CSS                       ((uint8_t)0x80)
00335 /**
00336   * @}
00337   */
00338 
00339 /** @defgroup RCC_Flag Flags
00340   *        Elements values convention: 0XXYYYYYb
00341   *           - YYYYY  : Flag position in the register
00342   *           - 0XX  : Register index
00343   *                 - 01: CR register
00344   *                 - 10: BDCR register
00345   *                 - 11: CSR register
00346   * @{
00347   */
00348 /* Flags in the CR register */
00349 #define RCC_FLAG_HSIRDY                  ((uint8_t)0x21)
00350 #define RCC_FLAG_HSERDY                  ((uint8_t)0x31)
00351 #define RCC_FLAG_PLLRDY                  ((uint8_t)0x39)
00352 #define RCC_FLAG_PLLI2SRDY               ((uint8_t)0x3B)
00353 
00354 /* Flags in the BDCR register */
00355 #define RCC_FLAG_LSERDY                  ((uint8_t)0x41)
00356 
00357 /* Flags in the CSR register */
00358 #define RCC_FLAG_LSIRDY                  ((uint8_t)0x61)
00359 #define RCC_FLAG_BORRST                  ((uint8_t)0x79)
00360 #define RCC_FLAG_PINRST                  ((uint8_t)0x7A)
00361 #define RCC_FLAG_PORRST                  ((uint8_t)0x7B)
00362 #define RCC_FLAG_SFTRST                  ((uint8_t)0x7C)
00363 #define RCC_FLAG_IWDGRST                 ((uint8_t)0x7D)
00364 #define RCC_FLAG_WWDGRST                 ((uint8_t)0x7E)
00365 #define RCC_FLAG_LPWRRST                 ((uint8_t)0x7F)
00366 /**
00367   * @}
00368   */
00369 
00370 /**
00371   * @}
00372   */
00373 
00374 /* Exported macro ------------------------------------------------------------*/
00375 /** @defgroup RCC_Exported_Macros RCC Exported Macros
00376   * @{
00377   */
00378 
00379 /** @defgroup RCC_AHB1_Clock_Enable_Disable AHB1 Peripheral Clock Enable Disable
00380   * @brief  Enable or disable the AHB1 peripheral clock.
00381   * @note   After reset, the peripheral clock (used for registers read/write access)
00382   *         is disabled and the application software has to enable this clock before
00383   *         using it.
00384   * @{
00385   */
00386 #define __HAL_RCC_GPIOA_CLK_ENABLE()   do { \
00387                                         __IO uint32_t tmpreg = 0x00U; \
00388                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
00389                                         /* Delay after an RCC peripheral clock enabling */ \
00390                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOAEN);\
00391                                         UNUSED(tmpreg); \
00392                                           } while(0U)
00393 #define __HAL_RCC_GPIOB_CLK_ENABLE()   do { \
00394                                         __IO uint32_t tmpreg = 0x00U; \
00395                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
00396                                         /* Delay after an RCC peripheral clock enabling */ \
00397                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOBEN);\
00398                                         UNUSED(tmpreg); \
00399                                           } while(0U)
00400 #define __HAL_RCC_GPIOC_CLK_ENABLE()  do { \
00401                                         __IO uint32_t tmpreg = 0x00U; \
00402                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
00403                                         /* Delay after an RCC peripheral clock enabling */ \
00404                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOCEN);\
00405                                         UNUSED(tmpreg); \
00406                                           } while(0U)
00407 #define __HAL_RCC_GPIOH_CLK_ENABLE()  do { \
00408                                         __IO uint32_t tmpreg = 0x00U; \
00409                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
00410                                         /* Delay after an RCC peripheral clock enabling */ \
00411                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_GPIOHEN);\
00412                                         UNUSED(tmpreg); \
00413                                          } while(0U)
00414 #define __HAL_RCC_DMA1_CLK_ENABLE()  do { \
00415                                         __IO uint32_t tmpreg = 0x00U; \
00416                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
00417                                         /* Delay after an RCC peripheral clock enabling */ \
00418                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA1EN);\
00419                                         UNUSED(tmpreg); \
00420                                          } while(0U)
00421 #define __HAL_RCC_DMA2_CLK_ENABLE()     do { \
00422                                         __IO uint32_t tmpreg = 0x00U; \
00423                                         SET_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
00424                                         /* Delay after an RCC peripheral clock enabling */ \
00425                                         tmpreg = READ_BIT(RCC->AHB1ENR, RCC_AHB1ENR_DMA2EN);\
00426                                         UNUSED(tmpreg); \
00427                                           } while(0U)
00428 
00429 #define __HAL_RCC_GPIOA_CLK_DISABLE()        (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOAEN))
00430 #define __HAL_RCC_GPIOB_CLK_DISABLE()        (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOBEN))
00431 #define __HAL_RCC_GPIOC_CLK_DISABLE()        (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOCEN))
00432 #define __HAL_RCC_GPIOH_CLK_DISABLE()        (RCC->AHB1ENR &= ~(RCC_AHB1ENR_GPIOHEN))
00433 #define __HAL_RCC_DMA1_CLK_DISABLE()         (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA1EN))
00434 #define __HAL_RCC_DMA2_CLK_DISABLE()         (RCC->AHB1ENR &= ~(RCC_AHB1ENR_DMA2EN))
00435 /**
00436   * @}
00437   */
00438 
00439 /** @defgroup RCC_AHB1_Peripheral_Clock_Enable_Disable_Status AHB1 Peripheral Clock Enable Disable Status
00440   * @brief  Get the enable or disable status of the AHB1 peripheral clock.
00441   * @note   After reset, the peripheral clock (used for registers read/write access)
00442   *         is disabled and the application software has to enable this clock before
00443   *         using it.
00444   * @{
00445   */
00446 #define __HAL_RCC_GPIOA_IS_CLK_ENABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOAEN)) != RESET)
00447 #define __HAL_RCC_GPIOB_IS_CLK_ENABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOBEN)) != RESET)
00448 #define __HAL_RCC_GPIOC_IS_CLK_ENABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOCEN)) != RESET)
00449 #define __HAL_RCC_GPIOH_IS_CLK_ENABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOHEN)) != RESET)
00450 #define __HAL_RCC_DMA1_IS_CLK_ENABLED()         ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA1EN)) != RESET)
00451 #define __HAL_RCC_DMA2_IS_CLK_ENABLED()         ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA2EN)) != RESET)
00452 
00453 #define __HAL_RCC_GPIOA_IS_CLK_DISABLED()       ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOAEN)) == RESET)
00454 #define __HAL_RCC_GPIOB_IS_CLK_DISABLED()       ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOBEN)) == RESET)
00455 #define __HAL_RCC_GPIOC_IS_CLK_DISABLED()       ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOCEN)) == RESET)
00456 #define __HAL_RCC_GPIOH_IS_CLK_DISABLED()       ((RCC->AHB1ENR &(RCC_AHB1ENR_GPIOHEN)) == RESET)
00457 #define __HAL_RCC_DMA1_IS_CLK_DISABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA1EN)) == RESET)
00458 #define __HAL_RCC_DMA2_IS_CLK_DISABLED()        ((RCC->AHB1ENR &(RCC_AHB1ENR_DMA2EN)) == RESET)
00459 /**
00460   * @}
00461   */
00462 
00463 /** @defgroup RCC_APB1_Clock_Enable_Disable APB1 Peripheral Clock Enable Disable
00464   * @brief  Enable or disable the Low Speed APB (APB1) peripheral clock.
00465   * @note   After reset, the peripheral clock (used for registers read/write access)
00466   *         is disabled and the application software has to enable this clock before
00467   *         using it.
00468   * @{
00469   */
00470 #define __HAL_RCC_TIM5_CLK_ENABLE()     do { \
00471                                         __IO uint32_t tmpreg = 0x00U; \
00472                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
00473                                         /* Delay after an RCC peripheral clock enabling */ \
00474                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_TIM5EN);\
00475                                         UNUSED(tmpreg); \
00476                                           } while(0U)
00477 #define __HAL_RCC_WWDG_CLK_ENABLE()     do { \
00478                                         __IO uint32_t tmpreg = 0x00U; \
00479                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
00480                                         /* Delay after an RCC peripheral clock enabling */ \
00481                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_WWDGEN);\
00482                                         UNUSED(tmpreg); \
00483                                           } while(0U)
00484 #define __HAL_RCC_SPI2_CLK_ENABLE()     do { \
00485                                         __IO uint32_t tmpreg = 0x00U; \
00486                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
00487                                         /* Delay after an RCC peripheral clock enabling */ \
00488                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_SPI2EN);\
00489                                         UNUSED(tmpreg); \
00490                                           } while(0U)
00491 #define __HAL_RCC_USART2_CLK_ENABLE()     do { \
00492                                         __IO uint32_t tmpreg = 0x00U; \
00493                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
00494                                         /* Delay after an RCC peripheral clock enabling */ \
00495                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_USART2EN);\
00496                                         UNUSED(tmpreg); \
00497                                           } while(0U)
00498 #define __HAL_RCC_I2C1_CLK_ENABLE()     do { \
00499                                         __IO uint32_t tmpreg = 0x00U; \
00500                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
00501                                         /* Delay after an RCC peripheral clock enabling */ \
00502                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C1EN);\
00503                                         UNUSED(tmpreg); \
00504                                           } while(0U)
00505 #define __HAL_RCC_I2C2_CLK_ENABLE()     do { \
00506                                         __IO uint32_t tmpreg = 0x00U; \
00507                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
00508                                         /* Delay after an RCC peripheral clock enabling */ \
00509                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_I2C2EN);\
00510                                         UNUSED(tmpreg); \
00511                                           } while(0U)
00512 #define __HAL_RCC_PWR_CLK_ENABLE()     do { \
00513                                         __IO uint32_t tmpreg = 0x00U; \
00514                                         SET_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
00515                                         /* Delay after an RCC peripheral clock enabling */ \
00516                                         tmpreg = READ_BIT(RCC->APB1ENR, RCC_APB1ENR_PWREN);\
00517                                         UNUSED(tmpreg); \
00518                                           } while(0U)
00519 
00520 #define __HAL_RCC_TIM5_CLK_DISABLE()   (RCC->APB1ENR &= ~(RCC_APB1ENR_TIM5EN))
00521 #define __HAL_RCC_WWDG_CLK_DISABLE()   (RCC->APB1ENR &= ~(RCC_APB1ENR_WWDGEN))
00522 #define __HAL_RCC_SPI2_CLK_DISABLE()   (RCC->APB1ENR &= ~(RCC_APB1ENR_SPI2EN))
00523 #define __HAL_RCC_USART2_CLK_DISABLE() (RCC->APB1ENR &= ~(RCC_APB1ENR_USART2EN))
00524 #define __HAL_RCC_I2C1_CLK_DISABLE()   (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C1EN))
00525 #define __HAL_RCC_I2C2_CLK_DISABLE()   (RCC->APB1ENR &= ~(RCC_APB1ENR_I2C2EN))
00526 #define __HAL_RCC_PWR_CLK_DISABLE()    (RCC->APB1ENR &= ~(RCC_APB1ENR_PWREN))
00527 /**
00528   * @}
00529   */
00530 
00531 /** @defgroup RCC_APB1_Peripheral_Clock_Enable_Disable_Status APB1 Peripheral Clock Enable Disable Status
00532   * @brief  Get the enable or disable status of the APB1 peripheral clock.
00533   * @note   After reset, the peripheral clock (used for registers read/write access)
00534   *         is disabled and the application software has to enable this clock before
00535   *         using it.
00536   * @{
00537   */
00538 #define __HAL_RCC_TIM5_IS_CLK_ENABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) != RESET)
00539 #define __HAL_RCC_WWDG_IS_CLK_ENABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) != RESET)
00540 #define __HAL_RCC_SPI2_IS_CLK_ENABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) != RESET)
00541 #define __HAL_RCC_USART2_IS_CLK_ENABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) != RESET)
00542 #define __HAL_RCC_I2C1_IS_CLK_ENABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) != RESET)
00543 #define __HAL_RCC_I2C2_IS_CLK_ENABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) != RESET)
00544 #define __HAL_RCC_PWR_IS_CLK_ENABLED()    ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) != RESET)
00545 
00546 #define __HAL_RCC_TIM5_IS_CLK_DISABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_TIM5EN)) == RESET)
00547 #define __HAL_RCC_WWDG_IS_CLK_DISABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_WWDGEN)) == RESET)
00548 #define __HAL_RCC_SPI2_IS_CLK_DISABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_SPI2EN)) == RESET)
00549 #define __HAL_RCC_USART2_IS_CLK_DISABLED() ((RCC->APB1ENR & (RCC_APB1ENR_USART2EN)) == RESET)
00550 #define __HAL_RCC_I2C1_IS_CLK_DISABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_I2C1EN)) == RESET)
00551 #define __HAL_RCC_I2C2_IS_CLK_DISABLED()   ((RCC->APB1ENR & (RCC_APB1ENR_I2C2EN)) == RESET)
00552 #define __HAL_RCC_PWR_IS_CLK_DISABLED()    ((RCC->APB1ENR & (RCC_APB1ENR_PWREN)) == RESET)
00553 /**
00554   * @}
00555   */
00556 
00557 /** @defgroup RCC_APB2_Clock_Enable_Disable APB2 Peripheral Clock Enable Disable
00558   * @brief  Enable or disable the High Speed APB (APB2) peripheral clock.
00559   * @note   After reset, the peripheral clock (used for registers read/write access)
00560   *         is disabled and the application software has to enable this clock before
00561   *         using it.
00562   * @{
00563   */
00564 #define __HAL_RCC_TIM1_CLK_ENABLE()     do { \
00565                                         __IO uint32_t tmpreg = 0x00U; \
00566                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
00567                                         /* Delay after an RCC peripheral clock enabling */ \
00568                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM1EN);\
00569                                         UNUSED(tmpreg); \
00570                                           } while(0U)
00571 #define __HAL_RCC_USART1_CLK_ENABLE()   do { \
00572                                         __IO uint32_t tmpreg = 0x00U; \
00573                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
00574                                         /* Delay after an RCC peripheral clock enabling */ \
00575                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART1EN);\
00576                                         UNUSED(tmpreg); \
00577                                           } while(0U)
00578 #define __HAL_RCC_USART6_CLK_ENABLE()   do { \
00579                                         __IO uint32_t tmpreg = 0x00U; \
00580                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
00581                                         /* Delay after an RCC peripheral clock enabling */ \
00582                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_USART6EN);\
00583                                         UNUSED(tmpreg); \
00584                                           } while(0U)
00585 #define __HAL_RCC_ADC1_CLK_ENABLE()     do { \
00586                                         __IO uint32_t tmpreg = 0x00U; \
00587                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
00588                                         /* Delay after an RCC peripheral clock enabling */ \
00589                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_ADC1EN);\
00590                                         UNUSED(tmpreg); \
00591                                           } while(0U)
00592 #define __HAL_RCC_SPI1_CLK_ENABLE()     do { \
00593                                         __IO uint32_t tmpreg = 0x00U; \
00594                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
00595                                         /* Delay after an RCC peripheral clock enabling */ \
00596                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SPI1EN);\
00597                                         UNUSED(tmpreg); \
00598                                           } while(0U)
00599 #define __HAL_RCC_SYSCFG_CLK_ENABLE()   do { \
00600                                         __IO uint32_t tmpreg = 0x00U; \
00601                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
00602                                         /* Delay after an RCC peripheral clock enabling */ \
00603                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_SYSCFGEN);\
00604                                         UNUSED(tmpreg); \
00605                                           } while(0U)
00606 #define __HAL_RCC_TIM9_CLK_ENABLE()     do { \
00607                                         __IO uint32_t tmpreg = 0x00U; \
00608                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
00609                                         /* Delay after an RCC peripheral clock enabling */ \
00610                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM9EN);\
00611                                         UNUSED(tmpreg); \
00612                                           } while(0U)
00613 #define __HAL_RCC_TIM11_CLK_ENABLE()    do { \
00614                                         __IO uint32_t tmpreg = 0x00U; \
00615                                         SET_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
00616                                         /* Delay after an RCC peripheral clock enabling */ \
00617                                         tmpreg = READ_BIT(RCC->APB2ENR, RCC_APB2ENR_TIM11EN);\
00618                                         UNUSED(tmpreg); \
00619                                           } while(0U)
00620 
00621 #define __HAL_RCC_TIM1_CLK_DISABLE()   (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM1EN))
00622 #define __HAL_RCC_USART1_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART1EN))
00623 #define __HAL_RCC_USART6_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_USART6EN))
00624 #define __HAL_RCC_ADC1_CLK_DISABLE()   (RCC->APB2ENR &= ~(RCC_APB2ENR_ADC1EN))
00625 #define __HAL_RCC_SPI1_CLK_DISABLE()   (RCC->APB2ENR &= ~(RCC_APB2ENR_SPI1EN))
00626 #define __HAL_RCC_SYSCFG_CLK_DISABLE() (RCC->APB2ENR &= ~(RCC_APB2ENR_SYSCFGEN))
00627 #define __HAL_RCC_TIM9_CLK_DISABLE()   (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM9EN))
00628 #define __HAL_RCC_TIM11_CLK_DISABLE()  (RCC->APB2ENR &= ~(RCC_APB2ENR_TIM11EN))
00629 /**
00630   * @}
00631   */
00632 
00633 /** @defgroup RCC_APB2_Peripheral_Clock_Enable_Disable_Status APB2 Peripheral Clock Enable Disable Status
00634   * @brief  Get the enable or disable status of the APB2 peripheral clock.
00635   * @note   After reset, the peripheral clock (used for registers read/write access)
00636   *         is disabled and the application software has to enable this clock before
00637   *         using it.
00638   * @{
00639   */
00640 #define __HAL_RCC_TIM1_IS_CLK_ENABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_TIM1EN)) != RESET)
00641 #define __HAL_RCC_USART1_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) != RESET)
00642 #define __HAL_RCC_USART6_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART6EN)) != RESET)
00643 #define __HAL_RCC_ADC1_IS_CLK_ENABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) != RESET)
00644 #define __HAL_RCC_SPI1_IS_CLK_ENABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) != RESET)
00645 #define __HAL_RCC_SYSCFG_IS_CLK_ENABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) != RESET)
00646 #define __HAL_RCC_TIM9_IS_CLK_ENABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) != RESET)
00647 #define __HAL_RCC_TIM11_IS_CLK_ENABLED()  ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) != RESET)
00648 
00649 #define __HAL_RCC_TIM1_IS_CLK_DISABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_TIM1EN)) == RESET)
00650 #define __HAL_RCC_USART1_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART1EN)) == RESET)
00651 #define __HAL_RCC_USART6_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_USART6EN)) == RESET)
00652 #define __HAL_RCC_ADC1_IS_CLK_DISABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_ADC1EN)) == RESET)
00653 #define __HAL_RCC_SPI1_IS_CLK_DISABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_SPI1EN)) == RESET)
00654 #define __HAL_RCC_SYSCFG_IS_CLK_DISABLED() ((RCC->APB2ENR & (RCC_APB2ENR_SYSCFGEN)) == RESET)
00655 #define __HAL_RCC_TIM9_IS_CLK_DISABLED()   ((RCC->APB2ENR & (RCC_APB2ENR_TIM9EN)) == RESET)
00656 #define __HAL_RCC_TIM11_IS_CLK_DISABLED()  ((RCC->APB2ENR & (RCC_APB2ENR_TIM11EN)) == RESET)
00657 /**
00658   * @}
00659   */
00660 
00661 /** @defgroup RCC_AHB1_Force_Release_Reset AHB1 Force Release Reset
00662   * @brief  Force or release AHB1 peripheral reset.
00663   * @{
00664   */
00665 #define __HAL_RCC_AHB1_FORCE_RESET()    (RCC->AHB1RSTR = 0xFFFFFFFFU)
00666 #define __HAL_RCC_GPIOA_FORCE_RESET()   (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOARST))
00667 #define __HAL_RCC_GPIOB_FORCE_RESET()   (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOBRST))
00668 #define __HAL_RCC_GPIOC_FORCE_RESET()   (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOCRST))
00669 #define __HAL_RCC_GPIOH_FORCE_RESET()   (RCC->AHB1RSTR |= (RCC_AHB1RSTR_GPIOHRST))
00670 #define __HAL_RCC_DMA1_FORCE_RESET()    (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA1RST))
00671 #define __HAL_RCC_DMA2_FORCE_RESET()    (RCC->AHB1RSTR |= (RCC_AHB1RSTR_DMA2RST))
00672 
00673 #define __HAL_RCC_AHB1_RELEASE_RESET()  (RCC->AHB1RSTR = 0x00U)
00674 #define __HAL_RCC_GPIOA_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOARST))
00675 #define __HAL_RCC_GPIOB_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOBRST))
00676 #define __HAL_RCC_GPIOC_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOCRST))
00677 #define __HAL_RCC_GPIOH_RELEASE_RESET() (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_GPIOHRST))
00678 #define __HAL_RCC_DMA1_RELEASE_RESET()  (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA1RST))
00679 #define __HAL_RCC_DMA2_RELEASE_RESET()  (RCC->AHB1RSTR &= ~(RCC_AHB1RSTR_DMA2RST))
00680 /**
00681   * @}
00682   */
00683 
00684 /** @defgroup RCC_APB1_Force_Release_Reset APB1 Force Release Reset
00685   * @brief  Force or release APB1 peripheral reset.
00686   * @{
00687   */
00688 #define __HAL_RCC_APB1_FORCE_RESET()     (RCC->APB1RSTR = 0xFFFFFFFFU)
00689 #define __HAL_RCC_TIM5_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_TIM5RST))
00690 #define __HAL_RCC_WWDG_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_WWDGRST))
00691 #define __HAL_RCC_SPI2_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_SPI2RST))
00692 #define __HAL_RCC_USART2_FORCE_RESET()   (RCC->APB1RSTR |= (RCC_APB1RSTR_USART2RST))
00693 #define __HAL_RCC_I2C1_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C1RST))
00694 #define __HAL_RCC_I2C2_FORCE_RESET()     (RCC->APB1RSTR |= (RCC_APB1RSTR_I2C2RST))
00695 #define __HAL_RCC_PWR_FORCE_RESET()      (RCC->APB1RSTR |= (RCC_APB1RSTR_PWRRST))
00696 
00697 #define __HAL_RCC_APB1_RELEASE_RESET()   (RCC->APB1RSTR = 0x00U)
00698 #define __HAL_RCC_TIM5_RELEASE_RESET()   (RCC->APB1RSTR &= ~(RCC_APB1RSTR_TIM5RST))
00699 #define __HAL_RCC_WWDG_RELEASE_RESET()   (RCC->APB1RSTR &= ~(RCC_APB1RSTR_WWDGRST))
00700 #define __HAL_RCC_SPI2_RELEASE_RESET()   (RCC->APB1RSTR &= ~(RCC_APB1RSTR_SPI2RST))
00701 #define __HAL_RCC_USART2_RELEASE_RESET() (RCC->APB1RSTR &= ~(RCC_APB1RSTR_USART2RST))
00702 #define __HAL_RCC_I2C1_RELEASE_RESET()   (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C1RST))
00703 #define __HAL_RCC_I2C2_RELEASE_RESET()   (RCC->APB1RSTR &= ~(RCC_APB1RSTR_I2C2RST))
00704 #define __HAL_RCC_PWR_RELEASE_RESET()    (RCC->APB1RSTR &= ~(RCC_APB1RSTR_PWRRST))
00705 /**
00706   * @}
00707   */
00708 
00709 /** @defgroup RCC_APB2_Force_Release_Reset APB2 Force Release Reset
00710   * @brief  Force or release APB2 peripheral reset.
00711   * @{
00712   */
00713 #define __HAL_RCC_APB2_FORCE_RESET()     (RCC->APB2RSTR = 0xFFFFFFFFU)
00714 #define __HAL_RCC_TIM1_FORCE_RESET()     (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM1RST))
00715 #define __HAL_RCC_USART1_FORCE_RESET()   (RCC->APB2RSTR |= (RCC_APB2RSTR_USART1RST))
00716 #define __HAL_RCC_USART6_FORCE_RESET()   (RCC->APB2RSTR |= (RCC_APB2RSTR_USART6RST))
00717 #define __HAL_RCC_ADC_FORCE_RESET()      (RCC->APB2RSTR |= (RCC_APB2RSTR_ADCRST))
00718 #define __HAL_RCC_SPI1_FORCE_RESET()     (RCC->APB2RSTR |= (RCC_APB2RSTR_SPI1RST))
00719 #define __HAL_RCC_SYSCFG_FORCE_RESET()   (RCC->APB2RSTR |= (RCC_APB2RSTR_SYSCFGRST))
00720 #define __HAL_RCC_TIM9_FORCE_RESET()     (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM9RST))
00721 #define __HAL_RCC_TIM11_FORCE_RESET()    (RCC->APB2RSTR |= (RCC_APB2RSTR_TIM11RST))
00722 
00723 #define __HAL_RCC_APB2_RELEASE_RESET()   (RCC->APB2RSTR = 0x00U)
00724 #define __HAL_RCC_TIM1_RELEASE_RESET()   (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM1RST))
00725 #define __HAL_RCC_USART1_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART1RST))
00726 #define __HAL_RCC_USART6_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_USART6RST))
00727 #define __HAL_RCC_ADC_RELEASE_RESET()    (RCC->APB2RSTR &= ~(RCC_APB2RSTR_ADCRST))
00728 #define __HAL_RCC_SPI1_RELEASE_RESET()   (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SPI1RST))
00729 #define __HAL_RCC_SYSCFG_RELEASE_RESET() (RCC->APB2RSTR &= ~(RCC_APB2RSTR_SYSCFGRST))
00730 #define __HAL_RCC_TIM9_RELEASE_RESET()   (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM9RST))
00731 #define __HAL_RCC_TIM11_RELEASE_RESET()  (RCC->APB2RSTR &= ~(RCC_APB2RSTR_TIM11RST))
00732 /**
00733   * @}
00734   */
00735 
00736 /** @defgroup RCC_AHB1_LowPower_Enable_Disable AHB1 Peripheral Low Power Enable Disable
00737   * @brief  Enable or disable the AHB1 peripheral clock during Low Power (Sleep) mode.
00738   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce
00739   *         power consumption.
00740   * @note   After wake-up from SLEEP mode, the peripheral clock is enabled again.
00741   * @note   By default, all peripheral clocks are enabled during SLEEP mode.
00742   * @{
00743   */
00744 #define __HAL_RCC_GPIOA_CLK_SLEEP_ENABLE()    (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOALPEN))
00745 #define __HAL_RCC_GPIOB_CLK_SLEEP_ENABLE()    (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOBLPEN))
00746 #define __HAL_RCC_GPIOC_CLK_SLEEP_ENABLE()    (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOCLPEN))
00747 #define __HAL_RCC_GPIOH_CLK_SLEEP_ENABLE()    (RCC->AHB1LPENR |= (RCC_AHB1LPENR_GPIOHLPEN))
00748 #define __HAL_RCC_DMA1_CLK_SLEEP_ENABLE()     (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA1LPEN))
00749 #define __HAL_RCC_DMA2_CLK_SLEEP_ENABLE()     (RCC->AHB1LPENR |= (RCC_AHB1LPENR_DMA2LPEN))
00750 
00751 #define __HAL_RCC_GPIOA_CLK_SLEEP_DISABLE()   (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOALPEN))
00752 #define __HAL_RCC_GPIOB_CLK_SLEEP_DISABLE()   (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOBLPEN))
00753 #define __HAL_RCC_GPIOC_CLK_SLEEP_DISABLE()   (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOCLPEN))
00754 #define __HAL_RCC_GPIOH_CLK_SLEEP_DISABLE()   (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_GPIOHLPEN))
00755 #define __HAL_RCC_DMA1_CLK_SLEEP_DISABLE()    (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA1LPEN))
00756 #define __HAL_RCC_DMA2_CLK_SLEEP_DISABLE()    (RCC->AHB1LPENR &= ~(RCC_AHB1LPENR_DMA2LPEN))
00757 /**
00758   * @}
00759   */
00760 
00761 /** @defgroup RCC_APB1_LowPower_Enable_Disable APB1 Peripheral Low Power Enable Disable
00762   * @brief  Enable or disable the APB1 peripheral clock during Low Power (Sleep) mode.
00763   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce
00764   *         power consumption.
00765   * @note   After wake-up from SLEEP mode, the peripheral clock is enabled again.
00766   * @note   By default, all peripheral clocks are enabled during SLEEP mode.
00767   * @{
00768   */
00769 #define __HAL_RCC_TIM5_CLK_SLEEP_ENABLE()    (RCC->APB1LPENR |= (RCC_APB1LPENR_TIM5LPEN))
00770 #define __HAL_RCC_WWDG_CLK_SLEEP_ENABLE()    (RCC->APB1LPENR |= (RCC_APB1LPENR_WWDGLPEN))
00771 #define __HAL_RCC_SPI2_CLK_SLEEP_ENABLE()    (RCC->APB1LPENR |= (RCC_APB1LPENR_SPI2LPEN))
00772 #define __HAL_RCC_USART2_CLK_SLEEP_ENABLE()  (RCC->APB1LPENR |= (RCC_APB1LPENR_USART2LPEN))
00773 #define __HAL_RCC_I2C1_CLK_SLEEP_ENABLE()    (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C1LPEN))
00774 #define __HAL_RCC_I2C2_CLK_SLEEP_ENABLE()    (RCC->APB1LPENR |= (RCC_APB1LPENR_I2C2LPEN))
00775 #define __HAL_RCC_PWR_CLK_SLEEP_ENABLE()     (RCC->APB1LPENR |= (RCC_APB1LPENR_PWRLPEN))
00776 
00777 #define __HAL_RCC_TIM5_CLK_SLEEP_DISABLE()   (RCC->APB1LPENR &= ~(RCC_APB1LPENR_TIM5LPEN))
00778 #define __HAL_RCC_WWDG_CLK_SLEEP_DISABLE()   (RCC->APB1LPENR &= ~(RCC_APB1LPENR_WWDGLPEN))
00779 #define __HAL_RCC_SPI2_CLK_SLEEP_DISABLE()   (RCC->APB1LPENR &= ~(RCC_APB1LPENR_SPI2LPEN))
00780 #define __HAL_RCC_USART2_CLK_SLEEP_DISABLE() (RCC->APB1LPENR &= ~(RCC_APB1LPENR_USART2LPEN))
00781 #define __HAL_RCC_I2C1_CLK_SLEEP_DISABLE()   (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C1LPEN))
00782 #define __HAL_RCC_I2C2_CLK_SLEEP_DISABLE()   (RCC->APB1LPENR &= ~(RCC_APB1LPENR_I2C2LPEN))
00783 #define __HAL_RCC_PWR_CLK_SLEEP_DISABLE()    (RCC->APB1LPENR &= ~(RCC_APB1LPENR_PWRLPEN))
00784 /**
00785   * @}
00786   */
00787 
00788 /** @defgroup RCC_APB2_LowPower_Enable_Disable APB2 Peripheral Low Power Enable Disable
00789   * @brief  Enable or disable the APB2 peripheral clock during Low Power (Sleep) mode.
00790   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce
00791   *         power consumption.
00792   * @note   After wake-up from SLEEP mode, the peripheral clock is enabled again.
00793   * @note   By default, all peripheral clocks are enabled during SLEEP mode.
00794   * @{
00795   */
00796 #define __HAL_RCC_TIM1_CLK_SLEEP_ENABLE()    (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM1LPEN))
00797 #define __HAL_RCC_USART1_CLK_SLEEP_ENABLE()  (RCC->APB2LPENR |= (RCC_APB2LPENR_USART1LPEN))
00798 #define __HAL_RCC_USART6_CLK_SLEEP_ENABLE()  (RCC->APB2LPENR |= (RCC_APB2LPENR_USART6LPEN))
00799 #define __HAL_RCC_ADC1_CLK_SLEEP_ENABLE()    (RCC->APB2LPENR |= (RCC_APB2LPENR_ADC1LPEN))
00800 #define __HAL_RCC_SPI1_CLK_SLEEP_ENABLE()    (RCC->APB2LPENR |= (RCC_APB2LPENR_SPI1LPEN))
00801 #define __HAL_RCC_SYSCFG_CLK_SLEEP_ENABLE()  (RCC->APB2LPENR |= (RCC_APB2LPENR_SYSCFGLPEN))
00802 #define __HAL_RCC_TIM9_CLK_SLEEP_ENABLE()    (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM9LPEN))
00803 #define __HAL_RCC_TIM11_CLK_SLEEP_ENABLE()   (RCC->APB2LPENR |= (RCC_APB2LPENR_TIM11LPEN))
00804 
00805 #define __HAL_RCC_TIM1_CLK_SLEEP_DISABLE()   (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM1LPEN))
00806 #define __HAL_RCC_USART1_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART1LPEN))
00807 #define __HAL_RCC_USART6_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_USART6LPEN))
00808 #define __HAL_RCC_ADC1_CLK_SLEEP_DISABLE()   (RCC->APB2LPENR &= ~(RCC_APB2LPENR_ADC1LPEN))
00809 #define __HAL_RCC_SPI1_CLK_SLEEP_DISABLE()   (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SPI1LPEN))
00810 #define __HAL_RCC_SYSCFG_CLK_SLEEP_DISABLE() (RCC->APB2LPENR &= ~(RCC_APB2LPENR_SYSCFGLPEN))
00811 #define __HAL_RCC_TIM9_CLK_SLEEP_DISABLE()   (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM9LPEN))
00812 #define __HAL_RCC_TIM11_CLK_SLEEP_DISABLE()  (RCC->APB2LPENR &= ~(RCC_APB2LPENR_TIM11LPEN))
00813 /**
00814   * @}
00815   */
00816 
00817 /** @defgroup RCC_HSI_Configuration HSI Configuration
00818   * @{
00819   */
00820 
00821 /** @brief  Macros to enable or disable the Internal High Speed oscillator (HSI).
00822   * @note   The HSI is stopped by hardware when entering STOP and STANDBY modes.
00823   *         It is used (enabled by hardware) as system clock source after startup
00824   *         from Reset, wake-up from STOP and STANDBY mode, or in case of failure
00825   *         of the HSE used directly or indirectly as system clock (if the Clock
00826   *         Security System CSS is enabled).
00827   * @note   HSI can not be stopped if it is used as system clock source. In this case,
00828   *         you have to select another source of the system clock then stop the HSI.
00829   * @note   After enabling the HSI, the application software should wait on HSIRDY
00830   *         flag to be set indicating that HSI clock is stable and can be used as
00831   *         system clock source.
00832   *         This parameter can be: ENABLE or DISABLE.
00833   * @note   When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
00834   *         clock cycles.
00835   */
00836 #define __HAL_RCC_HSI_ENABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = ENABLE)
00837 #define __HAL_RCC_HSI_DISABLE() (*(__IO uint32_t *) RCC_CR_HSION_BB = DISABLE)
00838 
00839 /** @brief  Macro to adjust the Internal High Speed oscillator (HSI) calibration value.
00840   * @note   The calibration is used to compensate for the variations in voltage
00841   *         and temperature that influence the frequency of the internal HSI RC.
00842   * @param  __HSICalibrationValue__ specifies the calibration trimming value.
00843   *         (default is RCC_HSICALIBRATION_DEFAULT).
00844   *         This parameter must be a number between 0 and 0x1F.
00845   */
00846 #define __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(__HSICalibrationValue__) (MODIFY_REG(RCC->CR,\
00847         RCC_CR_HSITRIM, (uint32_t)(__HSICalibrationValue__) << RCC_CR_HSITRIM_Pos))
00848 /**
00849   * @}
00850   */
00851 
00852 /** @defgroup RCC_LSI_Configuration LSI Configuration
00853   * @{
00854   */
00855 
00856 /** @brief  Macros to enable or disable the Internal Low Speed oscillator (LSI).
00857   * @note   After enabling the LSI, the application software should wait on
00858   *         LSIRDY flag to be set indicating that LSI clock is stable and can
00859   *         be used to clock the IWDG and/or the RTC.
00860   * @note   LSI can not be disabled if the IWDG is running.
00861   * @note   When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
00862   *         clock cycles.
00863   */
00864 #define __HAL_RCC_LSI_ENABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = ENABLE)
00865 #define __HAL_RCC_LSI_DISABLE() (*(__IO uint32_t *) RCC_CSR_LSION_BB = DISABLE)
00866 /**
00867   * @}
00868   */
00869 
00870 /** @defgroup RCC_HSE_Configuration HSE Configuration
00871   * @{
00872   */
00873 
00874 /**
00875   * @brief  Macro to configure the External High Speed oscillator (HSE).
00876   * @note   Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not supported by this macro.
00877   *         User should request a transition to HSE Off first and then HSE On or HSE Bypass.
00878   * @note   After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
00879   *         software should wait on HSERDY flag to be set indicating that HSE clock
00880   *         is stable and can be used to clock the PLL and/or system clock.
00881   * @note   HSE state can not be changed if it is used directly or through the
00882   *         PLL as system clock. In this case, you have to select another source
00883   *         of the system clock then change the HSE state (ex. disable it).
00884   * @note   The HSE is stopped by hardware when entering STOP and STANDBY modes.
00885   * @note   This function reset the CSSON bit, so if the clock security system(CSS)
00886   *         was previously enabled you have to enable it again after calling this
00887   *         function.
00888   * @param  __STATE__ specifies the new state of the HSE.
00889   *         This parameter can be one of the following values:
00890   *            @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
00891   *                              6 HSE oscillator clock cycles.
00892   *            @arg RCC_HSE_ON: turn ON the HSE oscillator.
00893   *            @arg RCC_HSE_BYPASS: HSE oscillator bypassed with external clock.
00894   */
00895 #define __HAL_RCC_HSE_CONFIG(__STATE__)                         \
00896                     do {                                        \
00897                       if ((__STATE__) == RCC_HSE_ON)            \
00898                       {                                         \
00899                         SET_BIT(RCC->CR, RCC_CR_HSEON);         \
00900                       }                                         \
00901                       else if ((__STATE__) == RCC_HSE_BYPASS)   \
00902                       {                                         \
00903                         SET_BIT(RCC->CR, RCC_CR_HSEBYP);        \
00904                         SET_BIT(RCC->CR, RCC_CR_HSEON);         \
00905                       }                                         \
00906                       else                                      \
00907                       {                                         \
00908                         CLEAR_BIT(RCC->CR, RCC_CR_HSEON);       \
00909                         CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);      \
00910                       }                                         \
00911                     } while(0U)
00912 /**
00913   * @}
00914   */
00915 
00916 /** @defgroup RCC_LSE_Configuration LSE Configuration
00917   * @{
00918   */
00919 
00920 /**
00921   * @brief  Macro to configure the External Low Speed oscillator (LSE).
00922   * @note   Transition LSE Bypass to LSE On and LSE On to LSE Bypass are not supported by this macro.
00923   *         User should request a transition to LSE Off first and then LSE On or LSE Bypass.
00924   * @note   As the LSE is in the Backup domain and write access is denied to
00925   *         this domain after reset, you have to enable write access using
00926   *         HAL_PWR_EnableBkUpAccess() function before to configure the LSE
00927   *         (to be done once after reset).
00928   * @note   After enabling the LSE (RCC_LSE_ON or RCC_LSE_BYPASS), the application
00929   *         software should wait on LSERDY flag to be set indicating that LSE clock
00930   *         is stable and can be used to clock the RTC.
00931   * @param  __STATE__ specifies the new state of the LSE.
00932   *         This parameter can be one of the following values:
00933   *            @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
00934   *                              6 LSE oscillator clock cycles.
00935   *            @arg RCC_LSE_ON: turn ON the LSE oscillator.
00936   *            @arg RCC_LSE_BYPASS: LSE oscillator bypassed with external clock.
00937   */
00938 #define __HAL_RCC_LSE_CONFIG(__STATE__) \
00939                     do {                                       \
00940                       if((__STATE__) == RCC_LSE_ON)            \
00941                       {                                        \
00942                         SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);    \
00943                       }                                        \
00944                       else if((__STATE__) == RCC_LSE_BYPASS)   \
00945                       {                                        \
00946                         SET_BIT(RCC->BDCR, RCC_BDCR_LSEBYP);   \
00947                         SET_BIT(RCC->BDCR, RCC_BDCR_LSEON);    \
00948                       }                                        \
00949                       else                                     \
00950                       {                                        \
00951                         CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEON);  \
00952                         CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEBYP); \
00953                       }                                        \
00954                     } while(0U)
00955 /**
00956   * @}
00957   */
00958 
00959 /** @defgroup RCC_Internal_RTC_Clock_Configuration RTC Clock Configuration
00960   * @{
00961   */
00962 
00963 /** @brief  Macros to enable or disable the RTC clock.
00964   * @note   These macros must be used only after the RTC clock source was selected.
00965   */
00966 #define __HAL_RCC_RTC_ENABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = ENABLE)
00967 #define __HAL_RCC_RTC_DISABLE() (*(__IO uint32_t *) RCC_BDCR_RTCEN_BB = DISABLE)
00968 
00969 /** @brief  Macros to configure the RTC clock (RTCCLK).
00970   * @note   As the RTC clock configuration bits are in the Backup domain and write
00971   *         access is denied to this domain after reset, you have to enable write
00972   *         access using the Power Backup Access macro before to configure
00973   *         the RTC clock source (to be done once after reset).
00974   * @note   Once the RTC clock is configured it can't be changed unless the
00975   *         Backup domain is reset using __HAL_RCC_BackupReset_RELEASE() macro, or by
00976   *         a Power On Reset (POR).
00977   * @param  __RTCCLKSource__ specifies the RTC clock source.
00978   *         This parameter can be one of the following values:
00979   *            @arg @ref RCC_RTCCLKSOURCE_NO_CLK : No clock selected as RTC clock.
00980   *            @arg @ref RCC_RTCCLKSOURCE_LSE : LSE selected as RTC clock.
00981   *            @arg @ref RCC_RTCCLKSOURCE_LSI : LSI selected as RTC clock.
00982   *            @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX HSE divided by X selected as RTC clock (X can be retrieved thanks to @ref __HAL_RCC_GET_RTC_HSE_PRESCALER()
00983   * @note   If the LSE or LSI is used as RTC clock source, the RTC continues to
00984   *         work in STOP and STANDBY modes, and can be used as wake-up source.
00985   *         However, when the HSE clock is used as RTC clock source, the RTC
00986   *         cannot be used in STOP and STANDBY modes.
00987   * @note   The maximum input clock frequency for RTC is 1MHz (when using HSE as
00988   *         RTC clock source).
00989   */
00990 #define __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__) (((__RTCCLKSource__) & RCC_BDCR_RTCSEL) == RCC_BDCR_RTCSEL) ?    \
00991                                                  MODIFY_REG(RCC->CFGR, RCC_CFGR_RTCPRE, ((__RTCCLKSource__) & 0xFFFFCFFU)) : CLEAR_BIT(RCC->CFGR, RCC_CFGR_RTCPRE)
00992 
00993 #define __HAL_RCC_RTC_CONFIG(__RTCCLKSource__) do { __HAL_RCC_RTC_CLKPRESCALER(__RTCCLKSource__);    \
00994                                                     RCC->BDCR |= ((__RTCCLKSource__) & 0x00000FFFU);  \
00995                                                    } while(0U)
00996 
00997 /** @brief Macro to get the RTC clock source.
00998   * @retval The clock source can be one of the following values:
00999   *            @arg @ref RCC_RTCCLKSOURCE_NO_CLK No clock selected as RTC clock
01000   *            @arg @ref RCC_RTCCLKSOURCE_LSE LSE selected as RTC clock
01001   *            @arg @ref RCC_RTCCLKSOURCE_LSI LSI selected as RTC clock
01002   *            @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX HSE divided by X selected as RTC clock (X can be retrieved thanks to @ref __HAL_RCC_GET_RTC_HSE_PRESCALER()
01003   */
01004 #define __HAL_RCC_GET_RTC_SOURCE() (READ_BIT(RCC->BDCR, RCC_BDCR_RTCSEL))
01005 
01006 /**
01007   * @brief   Get the RTC and HSE clock divider (RTCPRE).
01008   * @retval Returned value can be one of the following values:
01009  *            @arg @ref RCC_RTCCLKSOURCE_HSE_DIVX HSE divided by X selected as RTC clock (X can be retrieved thanks to @ref __HAL_RCC_GET_RTC_HSE_PRESCALER()
01010   */
01011 #define  __HAL_RCC_GET_RTC_HSE_PRESCALER() (READ_BIT(RCC->CFGR, RCC_CFGR_RTCPRE) | RCC_BDCR_RTCSEL)
01012 
01013 /** @brief  Macros to force or release the Backup domain reset.
01014   * @note   This function resets the RTC peripheral (including the backup registers)
01015   *         and the RTC clock source selection in RCC_CSR register.
01016   * @note   The BKPSRAM is not affected by this reset.
01017   */
01018 #define __HAL_RCC_BACKUPRESET_FORCE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = ENABLE)
01019 #define __HAL_RCC_BACKUPRESET_RELEASE() (*(__IO uint32_t *) RCC_BDCR_BDRST_BB = DISABLE)
01020 /**
01021   * @}
01022   */
01023 
01024 /** @defgroup RCC_PLL_Configuration PLL Configuration
01025   * @{
01026   */
01027 
01028 /** @brief  Macros to enable or disable the main PLL.
01029   * @note   After enabling the main PLL, the application software should wait on
01030   *         PLLRDY flag to be set indicating that PLL clock is stable and can
01031   *         be used as system clock source.
01032   * @note   The main PLL can not be disabled if it is used as system clock source
01033   * @note   The main PLL is disabled by hardware when entering STOP and STANDBY modes.
01034   */
01035 #define __HAL_RCC_PLL_ENABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = ENABLE)
01036 #define __HAL_RCC_PLL_DISABLE() (*(__IO uint32_t *) RCC_CR_PLLON_BB = DISABLE)
01037 
01038 /** @brief  Macro to configure the PLL clock source.
01039   * @note   This function must be used only when the main PLL is disabled.
01040   * @param  __PLLSOURCE__ specifies the PLL entry clock source.
01041   *         This parameter can be one of the following values:
01042   *            @arg RCC_PLLSOURCE_HSI: HSI oscillator clock selected as PLL clock entry
01043   *            @arg RCC_PLLSOURCE_HSE: HSE oscillator clock selected as PLL clock entry
01044   *
01045   */
01046 #define __HAL_RCC_PLL_PLLSOURCE_CONFIG(__PLLSOURCE__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLSRC, (__PLLSOURCE__))
01047 
01048 /** @brief  Macro to configure the PLL multiplication factor.
01049   * @note   This function must be used only when the main PLL is disabled.
01050   * @param  __PLLM__ specifies the division factor for PLL VCO input clock
01051   *         This parameter must be a number between Min_Data = 2 and Max_Data = 63.
01052   * @note   You have to set the PLLM parameter correctly to ensure that the VCO input
01053   *         frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
01054   *         of 2 MHz to limit PLL jitter.
01055   *
01056   */
01057 #define __HAL_RCC_PLL_PLLM_CONFIG(__PLLM__) MODIFY_REG(RCC->PLLCFGR, RCC_PLLCFGR_PLLM, (__PLLM__))
01058 /**
01059   * @}
01060   */
01061 
01062 /** @defgroup RCC_Get_Clock_source Get Clock source
01063   * @{
01064   */
01065 /**
01066   * @brief Macro to configure the system clock source.
01067   * @param __RCC_SYSCLKSOURCE__ specifies the system clock source.
01068   * This parameter can be one of the following values:
01069   *              - RCC_SYSCLKSOURCE_HSI: HSI oscillator is used as system clock source.
01070   *              - RCC_SYSCLKSOURCE_HSE: HSE oscillator is used as system clock source.
01071   *              - RCC_SYSCLKSOURCE_PLLCLK: PLL output is used as system clock source.
01072   *              - RCC_SYSCLKSOURCE_PLLRCLK: PLLR output is used as system clock source. This
01073   *                parameter is available only for STM32F446xx devices.
01074   */
01075 #define __HAL_RCC_SYSCLK_CONFIG(__RCC_SYSCLKSOURCE__) MODIFY_REG(RCC->CFGR, RCC_CFGR_SW, (__RCC_SYSCLKSOURCE__))
01076 
01077 /** @brief  Macro to get the clock source used as system clock.
01078   * @retval The clock source used as system clock. The returned value can be one
01079   *         of the following:
01080   *              - RCC_SYSCLKSOURCE_STATUS_HSI: HSI used as system clock.
01081   *              - RCC_SYSCLKSOURCE_STATUS_HSE: HSE used as system clock.
01082   *              - RCC_SYSCLKSOURCE_STATUS_PLLCLK: PLL used as system clock.
01083   *              - RCC_SYSCLKSOURCE_STATUS_PLLRCLK: PLLR used as system clock. This parameter
01084   *                is available only for STM32F446xx devices.
01085   */
01086 #define __HAL_RCC_GET_SYSCLK_SOURCE() (RCC->CFGR & RCC_CFGR_SWS)
01087 
01088 /** @brief  Macro to get the oscillator used as PLL clock source.
01089   * @retval The oscillator used as PLL clock source. The returned value can be one
01090   *         of the following:
01091   *              - RCC_PLLSOURCE_HSI: HSI oscillator is used as PLL clock source.
01092   *              - RCC_PLLSOURCE_HSE: HSE oscillator is used as PLL clock source.
01093   */
01094 #define __HAL_RCC_GET_PLL_OSCSOURCE() ((uint32_t)(RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC))
01095 /**
01096   * @}
01097   */
01098 
01099 /** @defgroup RCCEx_MCOx_Clock_Config RCC Extended MCOx Clock Config
01100   * @{
01101   */
01102 
01103 /** @brief  Macro to configure the MCO1 clock.
01104   * @param  __MCOCLKSOURCE__ specifies the MCO clock source.
01105   *          This parameter can be one of the following values:
01106   *            @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
01107   *            @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
01108   *            @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
01109   *            @arg RCC_MCO1SOURCE_PLLCLK: main PLL clock selected as MCO1 source
01110   * @param  __MCODIV__ specifies the MCO clock prescaler.
01111   *          This parameter can be one of the following values:
01112   *            @arg RCC_MCODIV_1: no division applied to MCOx clock
01113   *            @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
01114   *            @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
01115   *            @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
01116   *            @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
01117   */
01118 #define __HAL_RCC_MCO1_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
01119                  MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO1 | RCC_CFGR_MCO1PRE), ((__MCOCLKSOURCE__) | (__MCODIV__)))
01120 
01121 /** @brief  Macro to configure the MCO2 clock.
01122   * @param  __MCOCLKSOURCE__ specifies the MCO clock source.
01123   *          This parameter can be one of the following values:
01124   *            @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
01125   *            @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source, available for all STM32F4 devices except STM32F410xx
01126   *            @arg RCC_MCO2SOURCE_I2SCLK: I2SCLK clock selected as MCO2 source, available only for STM32F410Rx devices
01127   *            @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
01128   *            @arg RCC_MCO2SOURCE_PLLCLK: main PLL clock selected as MCO2 source
01129   * @param  __MCODIV__ specifies the MCO clock prescaler.
01130   *          This parameter can be one of the following values:
01131   *            @arg RCC_MCODIV_1: no division applied to MCOx clock
01132   *            @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
01133   *            @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
01134   *            @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
01135   *            @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
01136   * @note  For STM32F410Rx devices, to output I2SCLK clock on MCO2, you should have
01137   *        at least one of the SPI clocks enabled (SPI1, SPI2 or SPI5).
01138   */
01139 #define __HAL_RCC_MCO2_CONFIG(__MCOCLKSOURCE__, __MCODIV__) \
01140     MODIFY_REG(RCC->CFGR, (RCC_CFGR_MCO2 | RCC_CFGR_MCO2PRE), ((__MCOCLKSOURCE__) | ((__MCODIV__) << 3U)));
01141 /**
01142   * @}
01143   */
01144 
01145 /** @defgroup RCC_Flags_Interrupts_Management Flags Interrupts Management
01146   * @brief macros to manage the specified RCC Flags and interrupts.
01147   * @{
01148   */
01149 
01150 /** @brief  Enable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to enable
01151   *         the selected interrupts).
01152   * @param  __INTERRUPT__ specifies the RCC interrupt sources to be enabled.
01153   *         This parameter can be any combination of the following values:
01154   *            @arg RCC_IT_LSIRDY: LSI ready interrupt.
01155   *            @arg RCC_IT_LSERDY: LSE ready interrupt.
01156   *            @arg RCC_IT_HSIRDY: HSI ready interrupt.
01157   *            @arg RCC_IT_HSERDY: HSE ready interrupt.
01158   *            @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
01159   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
01160   */
01161 #define __HAL_RCC_ENABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS |= (__INTERRUPT__))
01162 
01163 /** @brief Disable RCC interrupt (Perform Byte access to RCC_CIR[14:8] bits to disable
01164   *        the selected interrupts).
01165   * @param  __INTERRUPT__ specifies the RCC interrupt sources to be disabled.
01166   *         This parameter can be any combination of the following values:
01167   *            @arg RCC_IT_LSIRDY: LSI ready interrupt.
01168   *            @arg RCC_IT_LSERDY: LSE ready interrupt.
01169   *            @arg RCC_IT_HSIRDY: HSI ready interrupt.
01170   *            @arg RCC_IT_HSERDY: HSE ready interrupt.
01171   *            @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
01172   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
01173   */
01174 #define __HAL_RCC_DISABLE_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE1_ADDRESS &= (uint8_t)(~(__INTERRUPT__)))
01175 
01176 /** @brief  Clear the RCC's interrupt pending bits (Perform Byte access to RCC_CIR[23:16]
01177   *         bits to clear the selected interrupt pending bits.
01178   * @param  __INTERRUPT__ specifies the interrupt pending bit to clear.
01179   *         This parameter can be any combination of the following values:
01180   *            @arg RCC_IT_LSIRDY: LSI ready interrupt.
01181   *            @arg RCC_IT_LSERDY: LSE ready interrupt.
01182   *            @arg RCC_IT_HSIRDY: HSI ready interrupt.
01183   *            @arg RCC_IT_HSERDY: HSE ready interrupt.
01184   *            @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
01185   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
01186   *            @arg RCC_IT_CSS: Clock Security System interrupt
01187   */
01188 #define __HAL_RCC_CLEAR_IT(__INTERRUPT__) (*(__IO uint8_t *) RCC_CIR_BYTE2_ADDRESS = (__INTERRUPT__))
01189 
01190 /** @brief  Check the RCC's interrupt has occurred or not.
01191   * @param  __INTERRUPT__ specifies the RCC interrupt source to check.
01192   *         This parameter can be one of the following values:
01193   *            @arg RCC_IT_LSIRDY: LSI ready interrupt.
01194   *            @arg RCC_IT_LSERDY: LSE ready interrupt.
01195   *            @arg RCC_IT_HSIRDY: HSI ready interrupt.
01196   *            @arg RCC_IT_HSERDY: HSE ready interrupt.
01197   *            @arg RCC_IT_PLLRDY: Main PLL ready interrupt.
01198   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt.
01199   *            @arg RCC_IT_CSS: Clock Security System interrupt
01200   * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
01201   */
01202 #define __HAL_RCC_GET_IT(__INTERRUPT__) ((RCC->CIR & (__INTERRUPT__)) == (__INTERRUPT__))
01203 
01204 /** @brief Set RMVF bit to clear the reset flags: RCC_FLAG_PINRST, RCC_FLAG_PORRST,
01205   *        RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST and RCC_FLAG_LPWRRST.
01206   */
01207 #define __HAL_RCC_CLEAR_RESET_FLAGS() (RCC->CSR |= RCC_CSR_RMVF)
01208 
01209 /** @brief  Check RCC flag is set or not.
01210   * @param  __FLAG__ specifies the flag to check.
01211   *         This parameter can be one of the following values:
01212   *            @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready.
01213   *            @arg RCC_FLAG_HSERDY: HSE oscillator clock ready.
01214   *            @arg RCC_FLAG_PLLRDY: Main PLL clock ready.
01215   *            @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready.
01216   *            @arg RCC_FLAG_LSERDY: LSE oscillator clock ready.
01217   *            @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready.
01218   *            @arg RCC_FLAG_BORRST: POR/PDR or BOR reset.
01219   *            @arg RCC_FLAG_PINRST: Pin reset.
01220   *            @arg RCC_FLAG_PORRST: POR/PDR reset.
01221   *            @arg RCC_FLAG_SFTRST: Software reset.
01222   *            @arg RCC_FLAG_IWDGRST: Independent Watchdog reset.
01223   *            @arg RCC_FLAG_WWDGRST: Window Watchdog reset.
01224   *            @arg RCC_FLAG_LPWRRST: Low Power reset.
01225   * @retval The new state of __FLAG__ (TRUE or FALSE).
01226   */
01227 #define RCC_FLAG_MASK  ((uint8_t)0x1FU)
01228 #define __HAL_RCC_GET_FLAG(__FLAG__) (((((((__FLAG__) >> 5U) == 1U)? RCC->CR :((((__FLAG__) >> 5U) == 2U) ? RCC->BDCR :((((__FLAG__) >> 5U) == 3U)? RCC->CSR :RCC->CIR))) & (1U << ((__FLAG__) & RCC_FLAG_MASK)))!= 0U)? 1U : 0U)
01229 
01230 /**
01231   * @}
01232   */
01233 
01234 /**
01235   * @}
01236   */
01237 
01238 /* Exported functions --------------------------------------------------------*/
01239  /** @addtogroup RCC_Exported_Functions
01240   * @{
01241   */
01242 
01243 /** @addtogroup RCC_Exported_Functions_Group1
01244   * @{
01245   */
01246 /* Initialization and de-initialization functions  ******************************/
01247 HAL_StatusTypeDef HAL_RCC_DeInit(void);
01248 HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
01249 HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency);
01250 /**
01251   * @}
01252   */
01253 
01254 /** @addtogroup RCC_Exported_Functions_Group2
01255   * @{
01256   */
01257 /* Peripheral Control functions  ************************************************/
01258 void     HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv);
01259 void     HAL_RCC_EnableCSS(void);
01260 void     HAL_RCC_DisableCSS(void);
01261 uint32_t HAL_RCC_GetSysClockFreq(void);
01262 uint32_t HAL_RCC_GetHCLKFreq(void);
01263 uint32_t HAL_RCC_GetPCLK1Freq(void);
01264 uint32_t HAL_RCC_GetPCLK2Freq(void);
01265 void     HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct);
01266 void     HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency);
01267 
01268 /* CSS NMI IRQ handler */
01269 void HAL_RCC_NMI_IRQHandler(void);
01270 
01271 /* User Callbacks in non blocking mode (IT mode) */
01272 void HAL_RCC_CSSCallback(void);
01273 
01274 /**
01275   * @}
01276   */
01277 
01278 /**
01279   * @}
01280   */
01281 
01282 /* Private types -------------------------------------------------------------*/
01283 /* Private variables ---------------------------------------------------------*/
01284 /* Private constants ---------------------------------------------------------*/
01285 /** @defgroup RCC_Private_Constants RCC Private Constants
01286   * @{
01287   */
01288 
01289 /** @defgroup RCC_BitAddress_AliasRegion RCC BitAddress AliasRegion
01290   * @brief RCC registers bit address in the alias region
01291   * @{
01292   */
01293 #define RCC_OFFSET                 (RCC_BASE - PERIPH_BASE)
01294 /* --- CR Register --- */
01295 /* Alias word address of HSION bit */
01296 #define RCC_CR_OFFSET              (RCC_OFFSET + 0x00U)
01297 #define RCC_HSION_BIT_NUMBER       0x00U
01298 #define RCC_CR_HSION_BB            (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_HSION_BIT_NUMBER * 4U))
01299 /* Alias word address of CSSON bit */
01300 #define RCC_CSSON_BIT_NUMBER       0x13U
01301 #define RCC_CR_CSSON_BB            (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_CSSON_BIT_NUMBER * 4U))
01302 /* Alias word address of PLLON bit */
01303 #define RCC_PLLON_BIT_NUMBER       0x18U
01304 #define RCC_CR_PLLON_BB            (PERIPH_BB_BASE + (RCC_CR_OFFSET * 32U) + (RCC_PLLON_BIT_NUMBER * 4U))
01305 
01306 /* --- BDCR Register --- */
01307 /* Alias word address of RTCEN bit */
01308 #define RCC_BDCR_OFFSET            (RCC_OFFSET + 0x70U)
01309 #define RCC_RTCEN_BIT_NUMBER       0x0FU
01310 #define RCC_BDCR_RTCEN_BB          (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32U) + (RCC_RTCEN_BIT_NUMBER * 4U))
01311 /* Alias word address of BDRST bit */
01312 #define RCC_BDRST_BIT_NUMBER       0x10U
01313 #define RCC_BDCR_BDRST_BB          (PERIPH_BB_BASE + (RCC_BDCR_OFFSET * 32U) + (RCC_BDRST_BIT_NUMBER * 4U))
01314 
01315 /* --- CSR Register --- */
01316 /* Alias word address of LSION bit */
01317 #define RCC_CSR_OFFSET             (RCC_OFFSET + 0x74U)
01318 #define RCC_LSION_BIT_NUMBER        0x00U
01319 #define RCC_CSR_LSION_BB           (PERIPH_BB_BASE + (RCC_CSR_OFFSET * 32U) + (RCC_LSION_BIT_NUMBER * 4U))
01320 
01321 /* CR register byte 3 (Bits[23:16]) base address */
01322 #define RCC_CR_BYTE2_ADDRESS       0x40023802U
01323 
01324 /* CIR register byte 2 (Bits[15:8]) base address */
01325 #define RCC_CIR_BYTE1_ADDRESS      ((uint32_t)(RCC_BASE + 0x0CU + 0x01U))
01326 
01327 /* CIR register byte 3 (Bits[23:16]) base address */
01328 #define RCC_CIR_BYTE2_ADDRESS      ((uint32_t)(RCC_BASE + 0x0CU + 0x02U))
01329 
01330 /* BDCR register base address */
01331 #define RCC_BDCR_BYTE0_ADDRESS     (PERIPH_BASE + RCC_BDCR_OFFSET)
01332 
01333 #define RCC_DBP_TIMEOUT_VALUE      2U
01334 #define RCC_LSE_TIMEOUT_VALUE      LSE_STARTUP_TIMEOUT
01335 
01336 #define HSE_TIMEOUT_VALUE          HSE_STARTUP_TIMEOUT
01337 #define HSI_TIMEOUT_VALUE          2U  /* 2 ms */
01338 #define LSI_TIMEOUT_VALUE          2U  /* 2 ms */
01339 #define CLOCKSWITCH_TIMEOUT_VALUE  5000U /* 5 s */
01340 
01341 /**
01342   * @}
01343   */
01344 
01345 /**
01346   * @}
01347   */
01348 
01349 /* Private macros ------------------------------------------------------------*/
01350 /** @defgroup RCC_Private_Macros RCC Private Macros
01351   * @{
01352   */
01353 
01354 /** @defgroup RCC_IS_RCC_Definitions RCC Private macros to check input parameters
01355   * @{
01356   */
01357 #define IS_RCC_OSCILLATORTYPE(OSCILLATOR) ((OSCILLATOR) <= 15U)
01358 
01359 #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
01360                          ((HSE) == RCC_HSE_BYPASS))
01361 
01362 #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
01363                          ((LSE) == RCC_LSE_BYPASS))
01364 
01365 #define IS_RCC_HSI(HSI) (((HSI) == RCC_HSI_OFF) || ((HSI) == RCC_HSI_ON))
01366 
01367 #define IS_RCC_LSI(LSI) (((LSI) == RCC_LSI_OFF) || ((LSI) == RCC_LSI_ON))
01368 
01369 #define IS_RCC_PLL(PLL) (((PLL) == RCC_PLL_NONE) ||((PLL) == RCC_PLL_OFF) || ((PLL) == RCC_PLL_ON))
01370 
01371 #define IS_RCC_PLLSOURCE(SOURCE) (((SOURCE) == RCC_PLLSOURCE_HSI) || \
01372                                   ((SOURCE) == RCC_PLLSOURCE_HSE))
01373 
01374 #define IS_RCC_SYSCLKSOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSOURCE_HSI) || \
01375                                      ((SOURCE) == RCC_SYSCLKSOURCE_HSE) || \
01376                                      ((SOURCE) == RCC_SYSCLKSOURCE_PLLCLK) || \
01377                                      ((SOURCE) == RCC_SYSCLKSOURCE_PLLRCLK))
01378 
01379 #define IS_RCC_RTCCLKSOURCE(__SOURCE__) (((__SOURCE__) == RCC_RTCCLKSOURCE_LSE) || \
01380                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_LSI) || \
01381                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV2) || \
01382                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV3) || \
01383                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV4) || \
01384                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV5) || \
01385                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV6) || \
01386                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV7) || \
01387                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV8) || \
01388                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV9) || \
01389                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV10) || \
01390                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV11) || \
01391                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV12) || \
01392                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV13) || \
01393                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV14) || \
01394                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV15) || \
01395                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV16) || \
01396                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV17) || \
01397                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV18) || \
01398                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV19) || \
01399                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV20) || \
01400                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV21) || \
01401                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV22) || \
01402                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV23) || \
01403                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV24) || \
01404                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV25) || \
01405                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV26) || \
01406                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV27) || \
01407                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV28) || \
01408                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV29) || \
01409                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV30) || \
01410                                          ((__SOURCE__) == RCC_RTCCLKSOURCE_HSE_DIV31))
01411 
01412 #define IS_RCC_PLLM_VALUE(VALUE) ((VALUE) <= 63U)
01413 
01414 #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == 2U) || ((VALUE) == 4U) || ((VALUE) == 6U) || ((VALUE) == 8U))
01415 
01416 #define IS_RCC_PLLQ_VALUE(VALUE) ((2U <= (VALUE)) && ((VALUE) <= 15U))
01417 
01418 #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_DIV1)   || ((HCLK) == RCC_SYSCLK_DIV2)   || \
01419                            ((HCLK) == RCC_SYSCLK_DIV4)   || ((HCLK) == RCC_SYSCLK_DIV8)   || \
01420                            ((HCLK) == RCC_SYSCLK_DIV16)  || ((HCLK) == RCC_SYSCLK_DIV64)  || \
01421                            ((HCLK) == RCC_SYSCLK_DIV128) || ((HCLK) == RCC_SYSCLK_DIV256) || \
01422                            ((HCLK) == RCC_SYSCLK_DIV512))
01423 
01424 #define IS_RCC_CLOCKTYPE(CLK) ((1U <= (CLK)) && ((CLK) <= 15U))
01425 
01426 #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_DIV1) || ((PCLK) == RCC_HCLK_DIV2) || \
01427                            ((PCLK) == RCC_HCLK_DIV4) || ((PCLK) == RCC_HCLK_DIV8) || \
01428                            ((PCLK) == RCC_HCLK_DIV16))
01429 
01430 #define IS_RCC_MCO(MCOx) (((MCOx) == RCC_MCO1) || ((MCOx) == RCC_MCO2))
01431 
01432 #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1SOURCE_HSI) || ((SOURCE) == RCC_MCO1SOURCE_LSE) || \
01433                                    ((SOURCE) == RCC_MCO1SOURCE_HSE) || ((SOURCE) == RCC_MCO1SOURCE_PLLCLK))
01434 
01435 #define IS_RCC_MCODIV(DIV) (((DIV) == RCC_MCODIV_1)  || ((DIV) == RCC_MCODIV_2) || \
01436                              ((DIV) == RCC_MCODIV_3) || ((DIV) == RCC_MCODIV_4) || \
01437                              ((DIV) == RCC_MCODIV_5))
01438 #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1FU)
01439 
01440 /**
01441   * @}
01442   */
01443 
01444 /**
01445   * @}
01446   */
01447 
01448 /**
01449   * @}
01450   */
01451 
01452 /**
01453   * @}
01454   */
01455 
01456 #ifdef __cplusplus
01457 }
01458 #endif
01459 
01460 #endif /* __STM32F4xx_HAL_RCC_H */
01461 
01462 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/