]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M4F_STM32F407ZG-SK/Libraries/STM32F4xx_StdPeriph_Driver/src/stm32f4xx_rcc.c
commit 9f316c246baafa15c542a5aea81a94f26e3d6507
[freertos] / FreeRTOS / Demo / CORTEX_M4F_STM32F407ZG-SK / Libraries / STM32F4xx_StdPeriph_Driver / src / stm32f4xx_rcc.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f4xx_rcc.c\r
4   * @author  MCD Application Team\r
5   * @version V1.0.0\r
6   * @date    30-September-2011\r
7   * @brief   This file provides firmware functions to manage the following \r
8   *          functionalities of the Reset and clock control (RCC) peripheral:\r
9   *           - Internal/external clocks, PLL, CSS and MCO configuration\r
10   *           - System, AHB and APB busses clocks configuration\r
11   *           - Peripheral clocks configuration\r
12   *           - Interrupts and flags management\r
13   *\r
14   *  @verbatim\r
15   *               \r
16   *          ===================================================================\r
17   *                               RCC specific features\r
18   *          ===================================================================\r
19   *    \r
20   *          After reset the device is running from Internal High Speed oscillator \r
21   *          (HSI 16MHz) with Flash 0 wait state, Flash prefetch buffer, D-Cache \r
22   *          and I-Cache are disabled, and all peripherals are off except internal\r
23   *          SRAM, Flash and JTAG.\r
24   *           - There is no prescaler on High speed (AHB) and Low speed (APB) busses;\r
25   *             all peripherals mapped on these busses are running at HSI speed.\r
26   *               - The clock for all peripherals is switched off, except the SRAM and FLASH.\r
27   *           - All GPIOs are in input floating state, except the JTAG pins which\r
28   *             are assigned to be used for debug purpose.\r
29   *        \r
30   *          Once the device started from reset, the user application has to:        \r
31   *           - Configure the clock source to be used to drive the System clock\r
32   *             (if the application needs higher frequency/performance)\r
33   *           - Configure the System clock frequency and Flash settings  \r
34   *           - Configure the AHB and APB busses prescalers\r
35   *           - Enable the clock for the peripheral(s) to be used\r
36   *           - Configure the clock source(s) for peripherals which clocks are not\r
37   *             derived from the System clock (I2S, RTC, ADC, USB OTG FS/SDIO/RNG)      \r
38   *                        \r
39   *  @endverbatim\r
40   *    \r
41   ******************************************************************************\r
42   * @attention\r
43   *\r
44   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
45   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
46   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
47   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
48   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
49   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
50   *\r
51   * <h2><center>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>\r
52   ******************************************************************************\r
53   */\r
54 \r
55 /* Includes ------------------------------------------------------------------*/\r
56 #include "stm32f4xx_rcc.h"\r
57 \r
58 /** @addtogroup STM32F4xx_StdPeriph_Driver\r
59   * @{\r
60   */\r
61 \r
62 /** @defgroup RCC \r
63   * @brief RCC driver modules\r
64   * @{\r
65   */ \r
66 \r
67 /* Private typedef -----------------------------------------------------------*/\r
68 /* Private define ------------------------------------------------------------*/\r
69 /* ------------ RCC registers bit address in the alias region ----------- */\r
70 #define RCC_OFFSET                (RCC_BASE - PERIPH_BASE)\r
71 /* --- CR Register ---*/\r
72 /* Alias word address of HSION bit */\r
73 #define CR_OFFSET                 (RCC_OFFSET + 0x00)\r
74 #define HSION_BitNumber           0x00\r
75 #define CR_HSION_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4))\r
76 /* Alias word address of CSSON bit */\r
77 #define CSSON_BitNumber           0x13\r
78 #define CR_CSSON_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CSSON_BitNumber * 4))\r
79 /* Alias word address of PLLON bit */\r
80 #define PLLON_BitNumber           0x18\r
81 #define CR_PLLON_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLON_BitNumber * 4))\r
82 /* Alias word address of PLLI2SON bit */\r
83 #define PLLI2SON_BitNumber        0x1A\r
84 #define CR_PLLI2SON_BB            (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLI2SON_BitNumber * 4))\r
85 \r
86 /* --- CFGR Register ---*/\r
87 /* Alias word address of I2SSRC bit */\r
88 #define CFGR_OFFSET               (RCC_OFFSET + 0x08)\r
89 #define I2SSRC_BitNumber          0x17\r
90 #define CFGR_I2SSRC_BB            (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (I2SSRC_BitNumber * 4))\r
91 \r
92 /* --- BDCR Register ---*/\r
93 /* Alias word address of RTCEN bit */\r
94 #define BDCR_OFFSET               (RCC_OFFSET + 0x70)\r
95 #define RTCEN_BitNumber           0x0F\r
96 #define BDCR_RTCEN_BB             (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (RTCEN_BitNumber * 4))\r
97 /* Alias word address of BDRST bit */\r
98 #define BDRST_BitNumber           0x10\r
99 #define BDCR_BDRST_BB             (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (BDRST_BitNumber * 4))\r
100 /* --- CSR Register ---*/\r
101 /* Alias word address of LSION bit */\r
102 #define CSR_OFFSET                (RCC_OFFSET + 0x74)\r
103 #define LSION_BitNumber           0x00\r
104 #define CSR_LSION_BB              (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (LSION_BitNumber * 4))\r
105 /* ---------------------- RCC registers bit mask ------------------------ */\r
106 /* CFGR register bit mask */\r
107 #define CFGR_MCO2_RESET_MASK      ((uint32_t)0x07FFFFFF)\r
108 #define CFGR_MCO1_RESET_MASK      ((uint32_t)0xF89FFFFF)\r
109 \r
110 /* RCC Flag Mask */\r
111 #define FLAG_MASK                 ((uint8_t)0x1F)\r
112 \r
113 /* CR register byte 3 (Bits[23:16]) base address */\r
114 #define CR_BYTE3_ADDRESS          ((uint32_t)0x40023802)\r
115 \r
116 /* CIR register byte 2 (Bits[15:8]) base address */\r
117 #define CIR_BYTE2_ADDRESS         ((uint32_t)(RCC_BASE + 0x0C + 0x01))\r
118 \r
119 /* CIR register byte 3 (Bits[23:16]) base address */\r
120 #define CIR_BYTE3_ADDRESS         ((uint32_t)(RCC_BASE + 0x0C + 0x02))\r
121 \r
122 /* BDCR register base address */\r
123 #define BDCR_ADDRESS              (PERIPH_BASE + BDCR_OFFSET)\r
124 \r
125 /* Private macro -------------------------------------------------------------*/\r
126 /* Private variables ---------------------------------------------------------*/\r
127 static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};\r
128 \r
129 /* Private function prototypes -----------------------------------------------*/\r
130 /* Private functions ---------------------------------------------------------*/\r
131 \r
132 /** @defgroup RCC_Private_Functions\r
133   * @{\r
134   */ \r
135 \r
136 /** @defgroup RCC_Group1 Internal and external clocks, PLL, CSS and MCO configuration functions\r
137  *  @brief   Internal and external clocks, PLL, CSS and MCO configuration functions \r
138  *\r
139 @verbatim   \r
140  ===============================================================================\r
141       Internal/external clocks, PLL, CSS and MCO configuration functions\r
142  ===============================================================================  \r
143 \r
144   This section provide functions allowing to configure the internal/external clocks,\r
145   PLLs, CSS and MCO pins.\r
146   \r
147   1. HSI (high-speed internal), 16 MHz factory-trimmed RC used directly or through\r
148      the PLL as System clock source.\r
149 \r
150   2. LSI (low-speed internal), 32 KHz low consumption RC used as IWDG and/or RTC\r
151      clock source.\r
152 \r
153   3. HSE (high-speed external), 4 to 26 MHz crystal oscillator used directly or\r
154      through the PLL as System clock source. Can be used also as RTC clock source.\r
155 \r
156   4. LSE (low-speed external), 32 KHz oscillator used as RTC clock source.   \r
157 \r
158   5. PLL (clocked by HSI or HSE), featuring two different output clocks:\r
159       - The first output is used to generate the high speed system clock (up to 168 MHz)\r
160       - The second output is used to generate the clock for the USB OTG FS (48 MHz),\r
161         the random analog generator (<=48 MHz) and the SDIO (<= 48 MHz).\r
162 \r
163   6. PLLI2S (clocked by HSI or HSE), used to generate an accurate clock to achieve \r
164      high-quality audio performance on the I2S interface.\r
165   \r
166   7. CSS (Clock security system), once enable and if a HSE clock failure occurs \r
167      (HSE used directly or through PLL as System clock source), the System clock\r
168      is automatically switched to HSI and an interrupt is generated if enabled. \r
169      The interrupt is linked to the Cortex-M4 NMI (Non-Maskable Interrupt) \r
170      exception vector.   \r
171 \r
172   8. MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL\r
173      clock (through a configurable prescaler) on PA8 pin.\r
174 \r
175   9. MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or PLLI2S\r
176      clock (through a configurable prescaler) on PC9 pin.\r
177 \r
178 @endverbatim\r
179   * @{\r
180   */\r
181 \r
182 /**\r
183   * @brief  Resets the RCC clock configuration to the default reset state.\r
184   * @note   The default reset state of the clock configuration is given below:\r
185   *            - HSI ON and used as system clock source\r
186   *            - HSE, PLL and PLLI2S OFF\r
187   *            - AHB, APB1 and APB2 prescaler set to 1.\r
188   *            - CSS, MCO1 and MCO2 OFF\r
189   *            - All interrupts disabled\r
190   * @note   This function doesn't modify the configuration of the\r
191   *            - Peripheral clocks\r
192   *            - LSI, LSE and RTC clocks \r
193   * @param  None\r
194   * @retval None\r
195   */\r
196 void RCC_DeInit(void)\r
197 {\r
198   /* Set HSION bit */\r
199   RCC->CR |= (uint32_t)0x00000001;\r
200 \r
201   /* Reset CFGR register */\r
202   RCC->CFGR = 0x00000000;\r
203 \r
204   /* Reset HSEON, CSSON and PLLON bits */\r
205   RCC->CR &= (uint32_t)0xFEF6FFFF;\r
206 \r
207   /* Reset PLLCFGR register */\r
208   RCC->PLLCFGR = 0x24003010;\r
209 \r
210   /* Reset HSEBYP bit */\r
211   RCC->CR &= (uint32_t)0xFFFBFFFF;\r
212 \r
213   /* Disable all interrupts */\r
214   RCC->CIR = 0x00000000;\r
215 }\r
216 \r
217 /**\r
218   * @brief  Configures the External High Speed oscillator (HSE).\r
219   * @note   After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application\r
220   *         software should wait on HSERDY flag to be set indicating that HSE clock\r
221   *         is stable and can be used to clock the PLL and/or system clock.\r
222   * @note   HSE state can not be changed if it is used directly or through the\r
223   *         PLL as system clock. In this case, you have to select another source\r
224   *         of the system clock then change the HSE state (ex. disable it).\r
225   * @note   The HSE is stopped by hardware when entering STOP and STANDBY modes.  \r
226   * @note   This function reset the CSSON bit, so if the Clock security system(CSS)\r
227   *         was previously enabled you have to enable it again after calling this\r
228   *         function.    \r
229   * @param  RCC_HSE: specifies the new state of the HSE.\r
230   *          This parameter can be one of the following values:\r
231   *            @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after\r
232   *                              6 HSE oscillator clock cycles.\r
233   *            @arg RCC_HSE_ON: turn ON the HSE oscillator\r
234   *            @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock\r
235   * @retval None\r
236   */\r
237 void RCC_HSEConfig(uint8_t RCC_HSE)\r
238 {\r
239   /* Check the parameters */\r
240   assert_param(IS_RCC_HSE(RCC_HSE));\r
241 \r
242   /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/\r
243   *(__IO uint8_t *) CR_BYTE3_ADDRESS = RCC_HSE_OFF;\r
244 \r
245   /* Set the new HSE configuration -------------------------------------------*/\r
246   *(__IO uint8_t *) CR_BYTE3_ADDRESS = RCC_HSE;\r
247 }\r
248 \r
249 /**\r
250   * @brief  Waits for HSE start-up.\r
251   * @note   This functions waits on HSERDY flag to be set and return SUCCESS if \r
252   *         this flag is set, otherwise returns ERROR if the timeout is reached \r
253   *         and this flag is not set. The timeout value is defined by the constant\r
254   *         HSE_STARTUP_TIMEOUT in stm32f4xx.h file. You can tailor it depending\r
255   *         on the HSE crystal used in your application. \r
256   * @param  None\r
257   * @retval An ErrorStatus enumeration value:\r
258   *          - SUCCESS: HSE oscillator is stable and ready to use\r
259   *          - ERROR: HSE oscillator not yet ready\r
260   */\r
261 ErrorStatus RCC_WaitForHSEStartUp(void)\r
262 {\r
263   __IO uint32_t startupcounter = 0;\r
264   ErrorStatus status = ERROR;\r
265   FlagStatus hsestatus = RESET;\r
266   /* Wait till HSE is ready and if Time out is reached exit */\r
267   do\r
268   {\r
269     hsestatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);\r
270     startupcounter++;\r
271   } while((startupcounter != HSE_STARTUP_TIMEOUT) && (hsestatus == RESET));\r
272 \r
273   if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)\r
274   {\r
275     status = SUCCESS;\r
276   }\r
277   else\r
278   {\r
279     status = ERROR;\r
280   }\r
281   return (status);\r
282 }\r
283 \r
284 /**\r
285   * @brief  Adjusts the Internal High Speed oscillator (HSI) calibration value.\r
286   * @note   The calibration is used to compensate for the variations in voltage\r
287   *         and temperature that influence the frequency of the internal HSI RC.\r
288   * @param  HSICalibrationValue: specifies the calibration trimming value.\r
289   *         This parameter must be a number between 0 and 0x1F.\r
290   * @retval None\r
291   */\r
292 void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)\r
293 {\r
294   uint32_t tmpreg = 0;\r
295   /* Check the parameters */\r
296   assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue));\r
297 \r
298   tmpreg = RCC->CR;\r
299 \r
300   /* Clear HSITRIM[4:0] bits */\r
301   tmpreg &= ~RCC_CR_HSITRIM;\r
302 \r
303   /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */\r
304   tmpreg |= (uint32_t)HSICalibrationValue << 3;\r
305 \r
306   /* Store the new value */\r
307   RCC->CR = tmpreg;\r
308 }\r
309 \r
310 /**\r
311   * @brief  Enables or disables the Internal High Speed oscillator (HSI).\r
312   * @note   The HSI is stopped by hardware when entering STOP and STANDBY modes.\r
313   *         It is used (enabled by hardware) as system clock source after startup\r
314   *         from Reset, wakeup from STOP and STANDBY mode, or in case of failure\r
315   *         of the HSE used directly or indirectly as system clock (if the Clock\r
316   *         Security System CSS is enabled).             \r
317   * @note   HSI can not be stopped if it is used as system clock source. In this case,\r
318   *         you have to select another source of the system clock then stop the HSI.  \r
319   * @note   After enabling the HSI, the application software should wait on HSIRDY\r
320   *         flag to be set indicating that HSI clock is stable and can be used as\r
321   *         system clock source.  \r
322   * @param  NewState: new state of the HSI.\r
323   *          This parameter can be: ENABLE or DISABLE.\r
324   * @note   When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator\r
325   *         clock cycles.  \r
326   * @retval None\r
327   */\r
328 void RCC_HSICmd(FunctionalState NewState)\r
329 {\r
330   /* Check the parameters */\r
331   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
332 \r
333   *(__IO uint32_t *) CR_HSION_BB = (uint32_t)NewState;\r
334 }\r
335 \r
336 /**\r
337   * @brief  Configures the External Low Speed oscillator (LSE).\r
338   * @note   As the LSE is in the Backup domain and write access is denied to\r
339   *         this domain after reset, you have to enable write access using \r
340   *         PWR_BackupAccessCmd(ENABLE) function before to configure the LSE\r
341   *         (to be done once after reset).  \r
342   * @note   After enabling the LSE (RCC_LSE_ON or RCC_LSE_Bypass), the application\r
343   *         software should wait on LSERDY flag to be set indicating that LSE clock\r
344   *         is stable and can be used to clock the RTC.\r
345   * @param  RCC_LSE: specifies the new state of the LSE.\r
346   *          This parameter can be one of the following values:\r
347   *            @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after\r
348   *                              6 LSE oscillator clock cycles.\r
349   *            @arg RCC_LSE_ON: turn ON the LSE oscillator\r
350   *            @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock\r
351   * @retval None\r
352   */\r
353 void RCC_LSEConfig(uint8_t RCC_LSE)\r
354 {\r
355   /* Check the parameters */\r
356   assert_param(IS_RCC_LSE(RCC_LSE));\r
357 \r
358   /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/\r
359   /* Reset LSEON bit */\r
360   *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;\r
361 \r
362   /* Reset LSEBYP bit */\r
363   *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;\r
364 \r
365   /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */\r
366   switch (RCC_LSE)\r
367   {\r
368     case RCC_LSE_ON:\r
369       /* Set LSEON bit */\r
370       *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_ON;\r
371       break;\r
372     case RCC_LSE_Bypass:\r
373       /* Set LSEBYP and LSEON bits */\r
374       *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_Bypass | RCC_LSE_ON;\r
375       break;\r
376     default:\r
377       break;\r
378   }\r
379 }\r
380 \r
381 /**\r
382   * @brief  Enables or disables the Internal Low Speed oscillator (LSI).\r
383   * @note   After enabling the LSI, the application software should wait on \r
384   *         LSIRDY flag to be set indicating that LSI clock is stable and can\r
385   *         be used to clock the IWDG and/or the RTC.\r
386   * @note   LSI can not be disabled if the IWDG is running.  \r
387   * @param  NewState: new state of the LSI.\r
388   *          This parameter can be: ENABLE or DISABLE.\r
389   * @note   When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator\r
390   *         clock cycles. \r
391   * @retval None\r
392   */\r
393 void RCC_LSICmd(FunctionalState NewState)\r
394 {\r
395   /* Check the parameters */\r
396   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
397 \r
398   *(__IO uint32_t *) CSR_LSION_BB = (uint32_t)NewState;\r
399 }\r
400 \r
401 /**\r
402   * @brief  Configures the main PLL clock source, multiplication and division factors.\r
403   * @note   This function must be used only when the main PLL is disabled.\r
404   *  \r
405   * @param  RCC_PLLSource: specifies the PLL entry clock source.\r
406   *          This parameter can be one of the following values:\r
407   *            @arg RCC_PLLSource_HSI: HSI oscillator clock selected as PLL clock entry\r
408   *            @arg RCC_PLLSource_HSE: HSE oscillator clock selected as PLL clock entry\r
409   * @note   This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.  \r
410   *  \r
411   * @param  PLLM: specifies the division factor for PLL VCO input clock\r
412   *          This parameter must be a number between 0 and 63.\r
413   * @note   You have to set the PLLM parameter correctly to ensure that the VCO input\r
414   *         frequency ranges from 1 to 2 MHz. It is recommended to select a frequency\r
415   *         of 2 MHz to limit PLL jitter.\r
416   *  \r
417   * @param  PLLN: specifies the multiplication factor for PLL VCO output clock\r
418   *          This parameter must be a number between 192 and 432.\r
419   * @note   You have to set the PLLN parameter correctly to ensure that the VCO\r
420   *         output frequency is between 192 and 432 MHz.\r
421   *   \r
422   * @param  PLLP: specifies the division factor for main system clock (SYSCLK)\r
423   *          This parameter must be a number in the range {2, 4, 6, or 8}.\r
424   * @note   You have to set the PLLP parameter correctly to not exceed 168 MHz on\r
425   *         the System clock frequency.\r
426   *  \r
427   * @param  PLLQ: specifies the division factor for OTG FS, SDIO and RNG clocks\r
428   *          This parameter must be a number between 4 and 15.\r
429   * @note   If the USB OTG FS is used in your application, you have to set the\r
430   *         PLLQ parameter correctly to have 48 MHz clock for the USB. However,\r
431   *         the SDIO and RNG need a frequency lower than or equal to 48 MHz to work\r
432   *         correctly.\r
433   *   \r
434   * @retval None\r
435   */\r
436 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ)\r
437 {\r
438   /* Check the parameters */\r
439   assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));\r
440   assert_param(IS_RCC_PLLM_VALUE(PLLM));\r
441   assert_param(IS_RCC_PLLN_VALUE(PLLN));\r
442   assert_param(IS_RCC_PLLP_VALUE(PLLP));\r
443   assert_param(IS_RCC_PLLQ_VALUE(PLLQ));\r
444 \r
445   RCC->PLLCFGR = PLLM | (PLLN << 6) | (((PLLP >> 1) -1) << 16) | (RCC_PLLSource) |\r
446                  (PLLQ << 24);\r
447 }\r
448 \r
449 /**\r
450   * @brief  Enables or disables the main PLL.\r
451   * @note   After enabling the main PLL, the application software should wait on \r
452   *         PLLRDY flag to be set indicating that PLL clock is stable and can\r
453   *         be used as system clock source.\r
454   * @note   The main PLL can not be disabled if it is used as system clock source\r
455   * @note   The main PLL is disabled by hardware when entering STOP and STANDBY modes.\r
456   * @param  NewState: new state of the main PLL. This parameter can be: ENABLE or DISABLE.\r
457   * @retval None\r
458   */\r
459 void RCC_PLLCmd(FunctionalState NewState)\r
460 {\r
461   /* Check the parameters */\r
462   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
463   *(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState;\r
464 }\r
465 \r
466 /**\r
467   * @brief  Configures the PLLI2S clock multiplication and division factors.\r
468   *  \r
469   * @note   This function must be used only when the PLLI2S is disabled.\r
470   * @note   PLLI2S clock source is common with the main PLL (configured in \r
471   *         RCC_PLLConfig function )  \r
472   *             \r
473   * @param  PLLI2SN: specifies the multiplication factor for PLLI2S VCO output clock\r
474   *          This parameter must be a number between 192 and 432.\r
475   * @note   You have to set the PLLI2SN parameter correctly to ensure that the VCO \r
476   *         output frequency is between 192 and 432 MHz.\r
477   *    \r
478   * @param  PLLI2SR: specifies the division factor for I2S clock\r
479   *          This parameter must be a number between 2 and 7.\r
480   * @note   You have to set the PLLI2SR parameter correctly to not exceed 192 MHz\r
481   *         on the I2S clock frequency.\r
482   *   \r
483   * @retval None\r
484   */\r
485 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR)\r
486 {\r
487   /* Check the parameters */\r
488   assert_param(IS_RCC_PLLI2SN_VALUE(PLLI2SN));\r
489   assert_param(IS_RCC_PLLI2SR_VALUE(PLLI2SR));\r
490 \r
491   RCC->PLLI2SCFGR = (PLLI2SN << 6) | (PLLI2SR << 28);\r
492 }\r
493 \r
494 /**\r
495   * @brief  Enables or disables the PLLI2S. \r
496   * @note   The PLLI2S is disabled by hardware when entering STOP and STANDBY modes.  \r
497   * @param  NewState: new state of the PLLI2S. This parameter can be: ENABLE or DISABLE.\r
498   * @retval None\r
499   */\r
500 void RCC_PLLI2SCmd(FunctionalState NewState)\r
501 {\r
502   /* Check the parameters */\r
503   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
504   *(__IO uint32_t *) CR_PLLI2SON_BB = (uint32_t)NewState;\r
505 }\r
506 \r
507 /**\r
508   * @brief  Enables or disables the Clock Security System.\r
509   * @note   If a failure is detected on the HSE oscillator clock, this oscillator\r
510   *         is automatically disabled and an interrupt is generated to inform the\r
511   *         software about the failure (Clock Security System Interrupt, CSSI),\r
512   *         allowing the MCU to perform rescue operations. The CSSI is linked to \r
513   *         the Cortex-M4 NMI (Non-Maskable Interrupt) exception vector.  \r
514   * @param  NewState: new state of the Clock Security System.\r
515   *         This parameter can be: ENABLE or DISABLE.\r
516   * @retval None\r
517   */\r
518 void RCC_ClockSecuritySystemCmd(FunctionalState NewState)\r
519 {\r
520   /* Check the parameters */\r
521   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
522   *(__IO uint32_t *) CR_CSSON_BB = (uint32_t)NewState;\r
523 }\r
524 \r
525 /**\r
526   * @brief  Selects the clock source to output on MCO1 pin(PA8).\r
527   * @note   PA8 should be configured in alternate function mode.\r
528   * @param  RCC_MCO1Source: specifies the clock source to output.\r
529   *          This parameter can be one of the following values:\r
530   *            @arg RCC_MCO1Source_HSI: HSI clock selected as MCO1 source\r
531   *            @arg RCC_MCO1Source_LSE: LSE clock selected as MCO1 source\r
532   *            @arg RCC_MCO1Source_HSE: HSE clock selected as MCO1 source\r
533   *            @arg RCC_MCO1Source_PLLCLK: main PLL clock selected as MCO1 source\r
534   * @param  RCC_MCO1Div: specifies the MCO1 prescaler.\r
535   *          This parameter can be one of the following values:\r
536   *            @arg RCC_MCO1Div_1: no division applied to MCO1 clock\r
537   *            @arg RCC_MCO1Div_2: division by 2 applied to MCO1 clock\r
538   *            @arg RCC_MCO1Div_3: division by 3 applied to MCO1 clock\r
539   *            @arg RCC_MCO1Div_4: division by 4 applied to MCO1 clock\r
540   *            @arg RCC_MCO1Div_5: division by 5 applied to MCO1 clock\r
541   * @retval None\r
542   */\r
543 void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div)\r
544 {\r
545   uint32_t tmpreg = 0;\r
546   \r
547   /* Check the parameters */\r
548   assert_param(IS_RCC_MCO1SOURCE(RCC_MCO1Source));\r
549   assert_param(IS_RCC_MCO1DIV(RCC_MCO1Div));  \r
550 \r
551   tmpreg = RCC->CFGR;\r
552 \r
553   /* Clear MCO1[1:0] and MCO1PRE[2:0] bits */\r
554   tmpreg &= CFGR_MCO1_RESET_MASK;\r
555 \r
556   /* Select MCO1 clock source and prescaler */\r
557   tmpreg |= RCC_MCO1Source | RCC_MCO1Div;\r
558 \r
559   /* Store the new value */\r
560   RCC->CFGR = tmpreg;  \r
561 }\r
562 \r
563 /**\r
564   * @brief  Selects the clock source to output on MCO2 pin(PC9).\r
565   * @note   PC9 should be configured in alternate function mode.\r
566   * @param  RCC_MCO2Source: specifies the clock source to output.\r
567   *          This parameter can be one of the following values:\r
568   *            @arg RCC_MCO2Source_SYSCLK: System clock (SYSCLK) selected as MCO2 source\r
569   *            @arg RCC_MCO2Source_PLLI2SCLK: PLLI2S clock selected as MCO2 source\r
570   *            @arg RCC_MCO2Source_HSE: HSE clock selected as MCO2 source\r
571   *            @arg RCC_MCO2Source_PLLCLK: main PLL clock selected as MCO2 source\r
572   * @param  RCC_MCO2Div: specifies the MCO2 prescaler.\r
573   *          This parameter can be one of the following values:\r
574   *            @arg RCC_MCO2Div_1: no division applied to MCO2 clock\r
575   *            @arg RCC_MCO2Div_2: division by 2 applied to MCO2 clock\r
576   *            @arg RCC_MCO2Div_3: division by 3 applied to MCO2 clock\r
577   *            @arg RCC_MCO2Div_4: division by 4 applied to MCO2 clock\r
578   *            @arg RCC_MCO2Div_5: division by 5 applied to MCO2 clock\r
579   * @retval None\r
580   */\r
581 void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div)\r
582 {\r
583   uint32_t tmpreg = 0;\r
584   \r
585   /* Check the parameters */\r
586   assert_param(IS_RCC_MCO2SOURCE(RCC_MCO2Source));\r
587   assert_param(IS_RCC_MCO2DIV(RCC_MCO2Div));\r
588   \r
589   tmpreg = RCC->CFGR;\r
590   \r
591   /* Clear MCO2 and MCO2PRE[2:0] bits */\r
592   tmpreg &= CFGR_MCO2_RESET_MASK;\r
593 \r
594   /* Select MCO2 clock source and prescaler */\r
595   tmpreg |= RCC_MCO2Source | RCC_MCO2Div;\r
596 \r
597   /* Store the new value */\r
598   RCC->CFGR = tmpreg;  \r
599 }\r
600 \r
601 /**\r
602   * @}\r
603   */\r
604 \r
605 /** @defgroup RCC_Group2 System AHB and APB busses clocks configuration functions\r
606  *  @brief   System, AHB and APB busses clocks configuration functions\r
607  *\r
608 @verbatim   \r
609  ===============================================================================\r
610              System, AHB and APB busses clocks configuration functions\r
611  ===============================================================================  \r
612 \r
613   This section provide functions allowing to configure the System, AHB, APB1 and \r
614   APB2 busses clocks.\r
615   \r
616   1. Several clock sources can be used to drive the System clock (SYSCLK): HSI,\r
617      HSE and PLL.\r
618      The AHB clock (HCLK) is derived from System clock through configurable prescaler\r
619      and used to clock the CPU, memory and peripherals mapped on AHB bus (DMA, GPIO...).\r
620      APB1 (PCLK1) and APB2 (PCLK2) clocks are derived from AHB clock through \r
621      configurable prescalers and used to clock the peripherals mapped on these busses.\r
622      You can use "RCC_GetClocksFreq()" function to retrieve the frequencies of these clocks.  \r
623 \r
624 @note All the peripheral clocks are derived from the System clock (SYSCLK) except:\r
625        - I2S: the I2S clock can be derived either from a specific PLL (PLLI2S) or\r
626           from an external clock mapped on the I2S_CKIN pin. \r
627           You have to use RCC_I2SCLKConfig() function to configure this clock. \r
628        - RTC: the RTC clock can be derived either from the LSI, LSE or HSE clock\r
629           divided by 2 to 31. You have to use RCC_RTCCLKConfig() and RCC_RTCCLKCmd()\r
630           functions to configure this clock. \r
631        - USB OTG FS, SDIO and RTC: USB OTG FS require a frequency equal to 48 MHz\r
632           to work correctly, while the SDIO require a frequency equal or lower than\r
633           to 48. This clock is derived of the main PLL through PLLQ divider.\r
634        - IWDG clock which is always the LSI clock.\r
635        \r
636   2. The maximum frequency of the SYSCLK and HCLK is 168 MHz, PCLK2 82 MHz and PCLK1 42 MHz.\r
637      Depending on the device voltage range, the maximum frequency should be \r
638      adapted accordingly:\r
639  +-------------------------------------------------------------------------------------+     \r
640  | Latency       |                HCLK clock frequency (MHz)                           |\r
641  |               |---------------------------------------------------------------------|     \r
642  |               | voltage range  | voltage range  | voltage range   | voltage range   |\r
643  |               | 2.7 V - 3.6 V  | 2.4 V - 2.7 V  | 2.1 V - 2.4 V   | 1.8 V - 2.1 V   |\r
644  |---------------|----------------|----------------|-----------------|-----------------|              \r
645  |0WS(1CPU cycle)|0 < HCLK <= 30  |0 < HCLK <= 24  |0 < HCLK <= 18   |0 < HCLK <= 16   |\r
646  |---------------|----------------|----------------|-----------------|-----------------|   \r
647  |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |18 < HCLK <= 36  |16 < HCLK <= 32  | \r
648  |---------------|----------------|----------------|-----------------|-----------------|   \r
649  |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |36 < HCLK <= 54  |32 < HCLK <= 48  |\r
650  |---------------|----------------|----------------|-----------------|-----------------| \r
651  |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |54 < HCLK <= 72  |48 < HCLK <= 64  |\r
652  |---------------|----------------|----------------|-----------------|-----------------| \r
653  |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|72 < HCLK <= 90  |64 < HCLK <= 80  |\r
654  |---------------|----------------|----------------|-----------------|-----------------| \r
655  |5WS(6CPU cycle)|120< HCLK <= 168|120< HCLK <= 144|90 < HCLK <= 108 |80 < HCLK <= 96  | \r
656  |---------------|----------------|----------------|-----------------|-----------------| \r
657  |6WS(7CPU cycle)|      NA        |144< HCLK <= 168|108 < HCLK <= 120|96 < HCLK <= 112 | \r
658  |---------------|----------------|----------------|-----------------|-----------------| \r
659  |7WS(8CPU cycle)|      NA        |      NA        |120 < HCLK <= 138|112 < HCLK <= 120| \r
660  +-------------------------------------------------------------------------------------+    \r
661    @note When VOS bit (in PWR_CR register) is reset to '0\92, the maximum value of HCLK is 144 MHz.\r
662          You can use PWR_MainRegulatorModeConfig() function to set or reset this bit.\r
663 \r
664 @endverbatim\r
665   * @{\r
666   */\r
667 \r
668 /**\r
669   * @brief  Configures the system clock (SYSCLK).\r
670   * @note   The HSI is used (enabled by hardware) as system clock source after\r
671   *         startup from Reset, wake-up from STOP and STANDBY mode, or in case\r
672   *         of failure of the HSE used directly or indirectly as system clock\r
673   *         (if the Clock Security System CSS is enabled).\r
674   * @note   A switch from one clock source to another occurs only if the target\r
675   *         clock source is ready (clock stable after startup delay or PLL locked). \r
676   *         If a clock source which is not yet ready is selected, the switch will\r
677   *         occur when the clock source will be ready. \r
678   *         You can use RCC_GetSYSCLKSource() function to know which clock is\r
679   *         currently used as system clock source. \r
680   * @param  RCC_SYSCLKSource: specifies the clock source used as system clock.\r
681   *          This parameter can be one of the following values:\r
682   *            @arg RCC_SYSCLKSource_HSI:    HSI selected as system clock source\r
683   *            @arg RCC_SYSCLKSource_HSE:    HSE selected as system clock source\r
684   *            @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock source\r
685   * @retval None\r
686   */\r
687 void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)\r
688 {\r
689   uint32_t tmpreg = 0;\r
690 \r
691   /* Check the parameters */\r
692   assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));\r
693 \r
694   tmpreg = RCC->CFGR;\r
695 \r
696   /* Clear SW[1:0] bits */\r
697   tmpreg &= ~RCC_CFGR_SW;\r
698 \r
699   /* Set SW[1:0] bits according to RCC_SYSCLKSource value */\r
700   tmpreg |= RCC_SYSCLKSource;\r
701 \r
702   /* Store the new value */\r
703   RCC->CFGR = tmpreg;\r
704 }\r
705 \r
706 /**\r
707   * @brief  Returns the clock source used as system clock.\r
708   * @param  None\r
709   * @retval The clock source used as system clock. The returned value can be one\r
710   *         of the following:\r
711   *              - 0x00: HSI used as system clock\r
712   *              - 0x04: HSE used as system clock\r
713   *              - 0x08: PLL used as system clock\r
714   */\r
715 uint8_t RCC_GetSYSCLKSource(void)\r
716 {\r
717   return ((uint8_t)(RCC->CFGR & RCC_CFGR_SWS));\r
718 }\r
719 \r
720 /**\r
721   * @brief  Configures the AHB clock (HCLK).\r
722   * @note   Depending on the device voltage range, the software has to set correctly\r
723   *         these bits to ensure that HCLK not exceed the maximum allowed frequency\r
724   *         (for more details refer to section above\r
725   *           "CPU, AHB and APB busses clocks configuration functions")\r
726   * @param  RCC_SYSCLK: defines the AHB clock divider. This clock is derived from \r
727   *         the system clock (SYSCLK).\r
728   *          This parameter can be one of the following values:\r
729   *            @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK\r
730   *            @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2\r
731   *            @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4\r
732   *            @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8\r
733   *            @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16\r
734   *            @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64\r
735   *            @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128\r
736   *            @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256\r
737   *            @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512\r
738   * @retval None\r
739   */\r
740 void RCC_HCLKConfig(uint32_t RCC_SYSCLK)\r
741 {\r
742   uint32_t tmpreg = 0;\r
743   \r
744   /* Check the parameters */\r
745   assert_param(IS_RCC_HCLK(RCC_SYSCLK));\r
746 \r
747   tmpreg = RCC->CFGR;\r
748 \r
749   /* Clear HPRE[3:0] bits */\r
750   tmpreg &= ~RCC_CFGR_HPRE;\r
751 \r
752   /* Set HPRE[3:0] bits according to RCC_SYSCLK value */\r
753   tmpreg |= RCC_SYSCLK;\r
754 \r
755   /* Store the new value */\r
756   RCC->CFGR = tmpreg;\r
757 }\r
758 \r
759 \r
760 /**\r
761   * @brief  Configures the Low Speed APB clock (PCLK1).\r
762   * @param  RCC_HCLK: defines the APB1 clock divider. This clock is derived from \r
763   *         the AHB clock (HCLK).\r
764   *          This parameter can be one of the following values:\r
765   *            @arg RCC_HCLK_Div1:  APB1 clock = HCLK\r
766   *            @arg RCC_HCLK_Div2:  APB1 clock = HCLK/2\r
767   *            @arg RCC_HCLK_Div4:  APB1 clock = HCLK/4\r
768   *            @arg RCC_HCLK_Div8:  APB1 clock = HCLK/8\r
769   *            @arg RCC_HCLK_Div16: APB1 clock = HCLK/16\r
770   * @retval None\r
771   */\r
772 void RCC_PCLK1Config(uint32_t RCC_HCLK)\r
773 {\r
774   uint32_t tmpreg = 0;\r
775 \r
776   /* Check the parameters */\r
777   assert_param(IS_RCC_PCLK(RCC_HCLK));\r
778 \r
779   tmpreg = RCC->CFGR;\r
780 \r
781   /* Clear PPRE1[2:0] bits */\r
782   tmpreg &= ~RCC_CFGR_PPRE1;\r
783 \r
784   /* Set PPRE1[2:0] bits according to RCC_HCLK value */\r
785   tmpreg |= RCC_HCLK;\r
786 \r
787   /* Store the new value */\r
788   RCC->CFGR = tmpreg;\r
789 }\r
790 \r
791 /**\r
792   * @brief  Configures the High Speed APB clock (PCLK2).\r
793   * @param  RCC_HCLK: defines the APB2 clock divider. This clock is derived from \r
794   *         the AHB clock (HCLK).\r
795   *          This parameter can be one of the following values:\r
796   *            @arg RCC_HCLK_Div1:  APB2 clock = HCLK\r
797   *            @arg RCC_HCLK_Div2:  APB2 clock = HCLK/2\r
798   *            @arg RCC_HCLK_Div4:  APB2 clock = HCLK/4\r
799   *            @arg RCC_HCLK_Div8:  APB2 clock = HCLK/8\r
800   *            @arg RCC_HCLK_Div16: APB2 clock = HCLK/16\r
801   * @retval None\r
802   */\r
803 void RCC_PCLK2Config(uint32_t RCC_HCLK)\r
804 {\r
805   uint32_t tmpreg = 0;\r
806 \r
807   /* Check the parameters */\r
808   assert_param(IS_RCC_PCLK(RCC_HCLK));\r
809 \r
810   tmpreg = RCC->CFGR;\r
811 \r
812   /* Clear PPRE2[2:0] bits */\r
813   tmpreg &= ~RCC_CFGR_PPRE2;\r
814 \r
815   /* Set PPRE2[2:0] bits according to RCC_HCLK value */\r
816   tmpreg |= RCC_HCLK << 3;\r
817 \r
818   /* Store the new value */\r
819   RCC->CFGR = tmpreg;\r
820 }\r
821 \r
822 /**\r
823   * @brief  Returns the frequencies of different on chip clocks; SYSCLK, HCLK, \r
824   *         PCLK1 and PCLK2.       \r
825   * \r
826   * @note   The system frequency computed by this function is not the real \r
827   *         frequency in the chip. It is calculated based on the predefined \r
828   *         constant and the selected clock source:\r
829   * @note     If SYSCLK source is HSI, function returns values based on HSI_VALUE(*)\r
830   * @note     If SYSCLK source is HSE, function returns values based on HSE_VALUE(**)\r
831   * @note     If SYSCLK source is PLL, function returns values based on HSE_VALUE(**) \r
832   *           or HSI_VALUE(*) multiplied/divided by the PLL factors.         \r
833   * @note     (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value\r
834   *               16 MHz) but the real value may vary depending on the variations\r
835   *               in voltage and temperature.\r
836   * @note     (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value\r
837   *                25 MHz), user has to ensure that HSE_VALUE is same as the real\r
838   *                frequency of the crystal used. Otherwise, this function may\r
839   *                have wrong result.\r
840   *                \r
841   * @note   The result of this function could be not correct when using fractional\r
842   *         value for HSE crystal.\r
843   *   \r
844   * @param  RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold\r
845   *          the clocks frequencies.\r
846   *     \r
847   * @note   This function can be used by the user application to compute the \r
848   *         baudrate for the communication peripherals or configure other parameters.\r
849   * @note   Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function\r
850   *         must be called to update the structure's field. Otherwise, any\r
851   *         configuration based on this function will be incorrect.\r
852   *    \r
853   * @retval None\r
854   */\r
855 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)\r
856 {\r
857   uint32_t tmp = 0, presc = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;\r
858 \r
859   /* Get SYSCLK source -------------------------------------------------------*/\r
860   tmp = RCC->CFGR & RCC_CFGR_SWS;\r
861 \r
862   switch (tmp)\r
863   {\r
864     case 0x00:  /* HSI used as system clock source */\r
865       RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;\r
866       break;\r
867     case 0x04:  /* HSE used as system clock  source */\r
868       RCC_Clocks->SYSCLK_Frequency = HSE_VALUE;\r
869       break;\r
870     case 0x08:  /* PLL used as system clock  source */\r
871 \r
872       /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN\r
873          SYSCLK = PLL_VCO / PLLP\r
874          */    \r
875       pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;\r
876       pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;\r
877       \r
878       if (pllsource != 0)\r
879       {\r
880         /* HSE used as PLL clock source */\r
881         pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);\r
882       }\r
883       else\r
884       {\r
885         /* HSI used as PLL clock source */\r
886         pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);      \r
887       }\r
888 \r
889       pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;\r
890       RCC_Clocks->SYSCLK_Frequency = pllvco/pllp;\r
891       break;\r
892     default:\r
893       RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;\r
894       break;\r
895   }\r
896   /* Compute HCLK, PCLK1 and PCLK2 clocks frequencies ------------------------*/\r
897 \r
898   /* Get HCLK prescaler */\r
899   tmp = RCC->CFGR & RCC_CFGR_HPRE;\r
900   tmp = tmp >> 4;\r
901   presc = APBAHBPrescTable[tmp];\r
902   /* HCLK clock frequency */\r
903   RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc;\r
904 \r
905   /* Get PCLK1 prescaler */\r
906   tmp = RCC->CFGR & RCC_CFGR_PPRE1;\r
907   tmp = tmp >> 10;\r
908   presc = APBAHBPrescTable[tmp];\r
909   /* PCLK1 clock frequency */\r
910   RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc;\r
911 \r
912   /* Get PCLK2 prescaler */\r
913   tmp = RCC->CFGR & RCC_CFGR_PPRE2;\r
914   tmp = tmp >> 13;\r
915   presc = APBAHBPrescTable[tmp];\r
916   /* PCLK2 clock frequency */\r
917   RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc;\r
918 }\r
919 \r
920 /**\r
921   * @}\r
922   */\r
923 \r
924 /** @defgroup RCC_Group3 Peripheral clocks configuration functions\r
925  *  @brief   Peripheral clocks configuration functions \r
926  *\r
927 @verbatim   \r
928  ===============================================================================\r
929                    Peripheral clocks configuration functions\r
930  ===============================================================================  \r
931 \r
932   This section provide functions allowing to configure the Peripheral clocks. \r
933   \r
934   1. The RTC clock which is derived from the LSI, LSE or HSE clock divided by 2 to 31.\r
935      \r
936   2. After restart from Reset or wakeup from STANDBY, all peripherals are off\r
937      except internal SRAM, Flash and JTAG. Before to start using a peripheral you\r
938      have to enable its interface clock. You can do this using RCC_AHBPeriphClockCmd()\r
939      , RCC_APB2PeriphClockCmd() and RCC_APB1PeriphClockCmd() functions.\r
940 \r
941   3. To reset the peripherals configuration (to the default state after device reset)\r
942      you can use RCC_AHBPeriphResetCmd(), RCC_APB2PeriphResetCmd() and \r
943      RCC_APB1PeriphResetCmd() functions.\r
944      \r
945   4. To further reduce power consumption in SLEEP mode the peripheral clocks can\r
946      be disabled prior to executing the WFI or WFE instructions. You can do this\r
947      using RCC_AHBPeriphClockLPModeCmd(), RCC_APB2PeriphClockLPModeCmd() and\r
948      RCC_APB1PeriphClockLPModeCmd() functions.  \r
949 \r
950 @endverbatim\r
951   * @{\r
952   */\r
953 \r
954 /**\r
955   * @brief  Configures the RTC clock (RTCCLK).\r
956   * @note   As the RTC clock configuration bits are in the Backup domain and write\r
957   *         access is denied to this domain after reset, you have to enable write\r
958   *         access using PWR_BackupAccessCmd(ENABLE) function before to configure\r
959   *         the RTC clock source (to be done once after reset).    \r
960   * @note   Once the RTC clock is configured it can't be changed unless the  \r
961   *         Backup domain is reset using RCC_BackupResetCmd() function, or by\r
962   *         a Power On Reset (POR).\r
963   *    \r
964   * @param  RCC_RTCCLKSource: specifies the RTC clock source.\r
965   *          This parameter can be one of the following values:\r
966   *            @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock\r
967   *            @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock\r
968   *            @arg RCC_RTCCLKSource_HSE_Divx: HSE clock divided by x selected\r
969   *                                            as RTC clock, where x:[2,31]\r
970   *  \r
971   * @note   If the LSE or LSI is used as RTC clock source, the RTC continues to\r
972   *         work in STOP and STANDBY modes, and can be used as wakeup source.\r
973   *         However, when the HSE clock is used as RTC clock source, the RTC\r
974   *         cannot be used in STOP and STANDBY modes.    \r
975   * @note   The maximum input clock frequency for RTC is 1MHz (when using HSE as\r
976   *         RTC clock source).\r
977   *  \r
978   * @retval None\r
979   */\r
980 void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)\r
981 {\r
982   uint32_t tmpreg = 0;\r
983 \r
984   /* Check the parameters */\r
985   assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));\r
986 \r
987   if ((RCC_RTCCLKSource & 0x00000300) == 0x00000300)\r
988   { /* If HSE is selected as RTC clock source, configure HSE division factor for RTC clock */\r
989     tmpreg = RCC->CFGR;\r
990 \r
991     /* Clear RTCPRE[4:0] bits */\r
992     tmpreg &= ~RCC_CFGR_RTCPRE;\r
993 \r
994     /* Configure HSE division factor for RTC clock */\r
995     tmpreg |= (RCC_RTCCLKSource & 0xFFFFCFF);\r
996 \r
997     /* Store the new value */\r
998     RCC->CFGR = tmpreg;\r
999   }\r
1000     \r
1001   /* Select the RTC clock source */\r
1002   RCC->BDCR |= (RCC_RTCCLKSource & 0x00000FFF);\r
1003 }\r
1004 \r
1005 /**\r
1006   * @brief  Enables or disables the RTC clock.\r
1007   * @note   This function must be used only after the RTC clock source was selected\r
1008   *         using the RCC_RTCCLKConfig function.\r
1009   * @param  NewState: new state of the RTC clock. This parameter can be: ENABLE or DISABLE.\r
1010   * @retval None\r
1011   */\r
1012 void RCC_RTCCLKCmd(FunctionalState NewState)\r
1013 {\r
1014   /* Check the parameters */\r
1015   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1016 \r
1017   *(__IO uint32_t *) BDCR_RTCEN_BB = (uint32_t)NewState;\r
1018 }\r
1019 \r
1020 /**\r
1021   * @brief  Forces or releases the Backup domain reset.\r
1022   * @note   This function resets the RTC peripheral (including the backup registers)\r
1023   *         and the RTC clock source selection in RCC_CSR register.\r
1024   * @note   The BKPSRAM is not affected by this reset.    \r
1025   * @param  NewState: new state of the Backup domain reset.\r
1026   *          This parameter can be: ENABLE or DISABLE.\r
1027   * @retval None\r
1028   */\r
1029 void RCC_BackupResetCmd(FunctionalState NewState)\r
1030 {\r
1031   /* Check the parameters */\r
1032   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1033   *(__IO uint32_t *) BDCR_BDRST_BB = (uint32_t)NewState;\r
1034 }\r
1035 \r
1036 /**\r
1037   * @brief  Configures the I2S clock source (I2SCLK).\r
1038   * @note   This function must be called before enabling the I2S APB clock.\r
1039   * @param  RCC_I2SCLKSource: specifies the I2S clock source.\r
1040   *          This parameter can be one of the following values:\r
1041   *            @arg RCC_I2S2CLKSource_PLLI2S: PLLI2S clock used as I2S clock source\r
1042   *            @arg RCC_I2S2CLKSource_Ext: External clock mapped on the I2S_CKIN pin\r
1043   *                                        used as I2S clock source\r
1044   * @retval None\r
1045   */\r
1046 void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource)\r
1047 {\r
1048   /* Check the parameters */\r
1049   assert_param(IS_RCC_I2SCLK_SOURCE(RCC_I2SCLKSource));\r
1050 \r
1051   *(__IO uint32_t *) CFGR_I2SSRC_BB = RCC_I2SCLKSource;\r
1052 }\r
1053 \r
1054 /**\r
1055   * @brief  Enables or disables the AHB1 peripheral clock.\r
1056   * @note   After reset, the peripheral clock (used for registers read/write access)\r
1057   *         is disabled and the application software has to enable this clock before \r
1058   *         using it.   \r
1059   * @param  RCC_AHBPeriph: specifies the AHB1 peripheral to gates its clock.\r
1060   *          This parameter can be any combination of the following values:\r
1061   *            @arg RCC_AHB1Periph_GPIOA:       GPIOA clock\r
1062   *            @arg RCC_AHB1Periph_GPIOB:       GPIOB clock \r
1063   *            @arg RCC_AHB1Periph_GPIOC:       GPIOC clock\r
1064   *            @arg RCC_AHB1Periph_GPIOD:       GPIOD clock\r
1065   *            @arg RCC_AHB1Periph_GPIOE:       GPIOE clock\r
1066   *            @arg RCC_AHB1Periph_GPIOF:       GPIOF clock\r
1067   *            @arg RCC_AHB1Periph_GPIOG:       GPIOG clock\r
1068   *            @arg RCC_AHB1Periph_GPIOH:       GPIOH clock\r
1069   *            @arg RCC_AHB1Periph_GPIOI:       GPIOI clock\r
1070   *            @arg RCC_AHB1Periph_CRC:         CRC clock\r
1071   *            @arg RCC_AHB1Periph_BKPSRAM:     BKPSRAM interface clock\r
1072   *            @arg RCC_AHB1Periph_CCMDATARAMEN CCM data RAM interface clock\r
1073   *            @arg RCC_AHB1Periph_DMA1:        DMA1 clock\r
1074   *            @arg RCC_AHB1Periph_DMA2:        DMA2 clock\r
1075   *            @arg RCC_AHB1Periph_ETH_MAC:     Ethernet MAC clock\r
1076   *            @arg RCC_AHB1Periph_ETH_MAC_Tx:  Ethernet Transmission clock\r
1077   *            @arg RCC_AHB1Periph_ETH_MAC_Rx:  Ethernet Reception clock\r
1078   *            @arg RCC_AHB1Periph_ETH_MAC_PTP: Ethernet PTP clock\r
1079   *            @arg RCC_AHB1Periph_OTG_HS:      USB OTG HS clock\r
1080   *            @arg RCC_AHB1Periph_OTG_HS_ULPI: USB OTG HS ULPI clock\r
1081   * @param  NewState: new state of the specified peripheral clock.\r
1082   *          This parameter can be: ENABLE or DISABLE.\r
1083   * @retval None\r
1084   */\r
1085 void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)\r
1086 {\r
1087   /* Check the parameters */\r
1088   assert_param(IS_RCC_AHB1_CLOCK_PERIPH(RCC_AHB1Periph));\r
1089 \r
1090   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1091   if (NewState != DISABLE)\r
1092   {\r
1093     RCC->AHB1ENR |= RCC_AHB1Periph;\r
1094   }\r
1095   else\r
1096   {\r
1097     RCC->AHB1ENR &= ~RCC_AHB1Periph;\r
1098   }\r
1099 }\r
1100 \r
1101 /**\r
1102   * @brief  Enables or disables the AHB2 peripheral clock.\r
1103   * @note   After reset, the peripheral clock (used for registers read/write access)\r
1104   *         is disabled and the application software has to enable this clock before \r
1105   *         using it. \r
1106   * @param  RCC_AHBPeriph: specifies the AHB2 peripheral to gates its clock.\r
1107   *          This parameter can be any combination of the following values:\r
1108   *            @arg RCC_AHB2Periph_DCMI:   DCMI clock\r
1109   *            @arg RCC_AHB2Periph_CRYP:   CRYP clock\r
1110   *            @arg RCC_AHB2Periph_HASH:   HASH clock\r
1111   *            @arg RCC_AHB2Periph_RNG:    RNG clock\r
1112   *            @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock\r
1113   * @param  NewState: new state of the specified peripheral clock.\r
1114   *          This parameter can be: ENABLE or DISABLE.\r
1115   * @retval None\r
1116   */\r
1117 void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)\r
1118 {\r
1119   /* Check the parameters */\r
1120   assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));\r
1121   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1122 \r
1123   if (NewState != DISABLE)\r
1124   {\r
1125     RCC->AHB2ENR |= RCC_AHB2Periph;\r
1126   }\r
1127   else\r
1128   {\r
1129     RCC->AHB2ENR &= ~RCC_AHB2Periph;\r
1130   }\r
1131 }\r
1132 \r
1133 /**\r
1134   * @brief  Enables or disables the AHB3 peripheral clock.\r
1135   * @note   After reset, the peripheral clock (used for registers read/write access)\r
1136   *         is disabled and the application software has to enable this clock before \r
1137   *         using it. \r
1138   * @param  RCC_AHBPeriph: specifies the AHB3 peripheral to gates its clock.\r
1139   *          This parameter must be: RCC_AHB3Periph_FSMC\r
1140   * @param  NewState: new state of the specified peripheral clock.\r
1141   *          This parameter can be: ENABLE or DISABLE.\r
1142   * @retval None\r
1143   */\r
1144 void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)\r
1145 {\r
1146   /* Check the parameters */\r
1147   assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));  \r
1148   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1149 \r
1150   if (NewState != DISABLE)\r
1151   {\r
1152     RCC->AHB3ENR |= RCC_AHB3Periph;\r
1153   }\r
1154   else\r
1155   {\r
1156     RCC->AHB3ENR &= ~RCC_AHB3Periph;\r
1157   }\r
1158 }\r
1159 \r
1160 /**\r
1161   * @brief  Enables or disables the Low Speed APB (APB1) peripheral clock.\r
1162   * @note   After reset, the peripheral clock (used for registers read/write access)\r
1163   *         is disabled and the application software has to enable this clock before \r
1164   *         using it. \r
1165   * @param  RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.\r
1166   *          This parameter can be any combination of the following values:\r
1167   *            @arg RCC_APB1Periph_TIM2:   TIM2 clock\r
1168   *            @arg RCC_APB1Periph_TIM3:   TIM3 clock\r
1169   *            @arg RCC_APB1Periph_TIM4:   TIM4 clock\r
1170   *            @arg RCC_APB1Periph_TIM5:   TIM5 clock\r
1171   *            @arg RCC_APB1Periph_TIM6:   TIM6 clock\r
1172   *            @arg RCC_APB1Periph_TIM7:   TIM7 clock\r
1173   *            @arg RCC_APB1Periph_TIM12:  TIM12 clock\r
1174   *            @arg RCC_APB1Periph_TIM13:  TIM13 clock\r
1175   *            @arg RCC_APB1Periph_TIM14:  TIM14 clock\r
1176   *            @arg RCC_APB1Periph_WWDG:   WWDG clock\r
1177   *            @arg RCC_APB1Periph_SPI2:   SPI2 clock\r
1178   *            @arg RCC_APB1Periph_SPI3:   SPI3 clock\r
1179   *            @arg RCC_APB1Periph_USART2: USART2 clock\r
1180   *            @arg RCC_APB1Periph_USART3: USART3 clock\r
1181   *            @arg RCC_APB1Periph_UART4:  UART4 clock\r
1182   *            @arg RCC_APB1Periph_UART5:  UART5 clock\r
1183   *            @arg RCC_APB1Periph_I2C1:   I2C1 clock\r
1184   *            @arg RCC_APB1Periph_I2C2:   I2C2 clock\r
1185   *            @arg RCC_APB1Periph_I2C3:   I2C3 clock\r
1186   *            @arg RCC_APB1Periph_CAN1:   CAN1 clock\r
1187   *            @arg RCC_APB1Periph_CAN2:   CAN2 clock\r
1188   *            @arg RCC_APB1Periph_PWR:    PWR clock\r
1189   *            @arg RCC_APB1Periph_DAC:    DAC clock\r
1190   * @param  NewState: new state of the specified peripheral clock.\r
1191   *          This parameter can be: ENABLE or DISABLE.\r
1192   * @retval None\r
1193   */\r
1194 void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r
1195 {\r
1196   /* Check the parameters */\r
1197   assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));  \r
1198   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1199 \r
1200   if (NewState != DISABLE)\r
1201   {\r
1202     RCC->APB1ENR |= RCC_APB1Periph;\r
1203   }\r
1204   else\r
1205   {\r
1206     RCC->APB1ENR &= ~RCC_APB1Periph;\r
1207   }\r
1208 }\r
1209 \r
1210 /**\r
1211   * @brief  Enables or disables the High Speed APB (APB2) peripheral clock.\r
1212   * @note   After reset, the peripheral clock (used for registers read/write access)\r
1213   *         is disabled and the application software has to enable this clock before \r
1214   *         using it.\r
1215   * @param  RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.\r
1216   *          This parameter can be any combination of the following values:\r
1217   *            @arg RCC_APB2Periph_TIM1:   TIM1 clock\r
1218   *            @arg RCC_APB2Periph_TIM8:   TIM8 clock\r
1219   *            @arg RCC_APB2Periph_USART1: USART1 clock\r
1220   *            @arg RCC_APB2Periph_USART6: USART6 clock\r
1221   *            @arg RCC_APB2Periph_ADC1:   ADC1 clock\r
1222   *            @arg RCC_APB2Periph_ADC2:   ADC2 clock\r
1223   *            @arg RCC_APB2Periph_ADC3:   ADC3 clock\r
1224   *            @arg RCC_APB2Periph_SDIO:   SDIO clock\r
1225   *            @arg RCC_APB2Periph_SPI1:   SPI1 clock\r
1226   *            @arg RCC_APB2Periph_SYSCFG: SYSCFG clock\r
1227   *            @arg RCC_APB2Periph_TIM9:   TIM9 clock\r
1228   *            @arg RCC_APB2Periph_TIM10:  TIM10 clock\r
1229   *            @arg RCC_APB2Periph_TIM11:  TIM11 clock\r
1230   * @param  NewState: new state of the specified peripheral clock.\r
1231   *          This parameter can be: ENABLE or DISABLE.\r
1232   * @retval None\r
1233   */\r
1234 void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r
1235 {\r
1236   /* Check the parameters */\r
1237   assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));\r
1238   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1239 \r
1240   if (NewState != DISABLE)\r
1241   {\r
1242     RCC->APB2ENR |= RCC_APB2Periph;\r
1243   }\r
1244   else\r
1245   {\r
1246     RCC->APB2ENR &= ~RCC_APB2Periph;\r
1247   }\r
1248 }\r
1249 \r
1250 /**\r
1251   * @brief  Forces or releases AHB1 peripheral reset.\r
1252   * @param  RCC_AHB1Periph: specifies the AHB1 peripheral to reset.\r
1253   *          This parameter can be any combination of the following values:\r
1254   *            @arg RCC_AHB1Periph_GPIOA:   GPIOA clock\r
1255   *            @arg RCC_AHB1Periph_GPIOB:   GPIOB clock \r
1256   *            @arg RCC_AHB1Periph_GPIOC:   GPIOC clock\r
1257   *            @arg RCC_AHB1Periph_GPIOD:   GPIOD clock\r
1258   *            @arg RCC_AHB1Periph_GPIOE:   GPIOE clock\r
1259   *            @arg RCC_AHB1Periph_GPIOF:   GPIOF clock\r
1260   *            @arg RCC_AHB1Periph_GPIOG:   GPIOG clock\r
1261   *            @arg RCC_AHB1Periph_GPIOH:   GPIOH clock\r
1262   *            @arg RCC_AHB1Periph_GPIOI:   GPIOI clock\r
1263   *            @arg RCC_AHB1Periph_CRC:     CRC clock\r
1264   *            @arg RCC_AHB1Periph_DMA1:    DMA1 clock\r
1265   *            @arg RCC_AHB1Periph_DMA2:    DMA2 clock\r
1266   *            @arg RCC_AHB1Periph_ETH_MAC: Ethernet MAC clock\r
1267   *            @arg RCC_AHB1Periph_OTG_HS:  USB OTG HS clock\r
1268   *                  \r
1269   * @param  NewState: new state of the specified peripheral reset.\r
1270   *          This parameter can be: ENABLE or DISABLE.\r
1271   * @retval None\r
1272   */\r
1273 void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)\r
1274 {\r
1275   /* Check the parameters */\r
1276   assert_param(IS_RCC_AHB1_RESET_PERIPH(RCC_AHB1Periph));\r
1277   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1278 \r
1279   if (NewState != DISABLE)\r
1280   {\r
1281     RCC->AHB1RSTR |= RCC_AHB1Periph;\r
1282   }\r
1283   else\r
1284   {\r
1285     RCC->AHB1RSTR &= ~RCC_AHB1Periph;\r
1286   }\r
1287 }\r
1288 \r
1289 /**\r
1290   * @brief  Forces or releases AHB2 peripheral reset.\r
1291   * @param  RCC_AHB2Periph: specifies the AHB2 peripheral to reset.\r
1292   *          This parameter can be any combination of the following values:\r
1293   *            @arg RCC_AHB2Periph_DCMI:   DCMI clock\r
1294   *            @arg RCC_AHB2Periph_CRYP:   CRYP clock\r
1295   *            @arg RCC_AHB2Periph_HASH:   HASH clock\r
1296   *            @arg RCC_AHB2Periph_RNG:    RNG clock\r
1297   *            @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock\r
1298   * @param  NewState: new state of the specified peripheral reset.\r
1299   *          This parameter can be: ENABLE or DISABLE.\r
1300   * @retval None\r
1301   */\r
1302 void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)\r
1303 {\r
1304   /* Check the parameters */\r
1305   assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));\r
1306   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1307 \r
1308   if (NewState != DISABLE)\r
1309   {\r
1310     RCC->AHB2RSTR |= RCC_AHB2Periph;\r
1311   }\r
1312   else\r
1313   {\r
1314     RCC->AHB2RSTR &= ~RCC_AHB2Periph;\r
1315   }\r
1316 }\r
1317 \r
1318 /**\r
1319   * @brief  Forces or releases AHB3 peripheral reset.\r
1320   * @param  RCC_AHB3Periph: specifies the AHB3 peripheral to reset.\r
1321   *          This parameter must be: RCC_AHB3Periph_FSMC\r
1322   * @param  NewState: new state of the specified peripheral reset.\r
1323   *          This parameter can be: ENABLE or DISABLE.\r
1324   * @retval None\r
1325   */\r
1326 void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)\r
1327 {\r
1328   /* Check the parameters */\r
1329   assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));\r
1330   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1331 \r
1332   if (NewState != DISABLE)\r
1333   {\r
1334     RCC->AHB3RSTR |= RCC_AHB3Periph;\r
1335   }\r
1336   else\r
1337   {\r
1338     RCC->AHB3RSTR &= ~RCC_AHB3Periph;\r
1339   }\r
1340 }\r
1341 \r
1342 /**\r
1343   * @brief  Forces or releases Low Speed APB (APB1) peripheral reset.\r
1344   * @param  RCC_APB1Periph: specifies the APB1 peripheral to reset.\r
1345   *          This parameter can be any combination of the following values:\r
1346   *            @arg RCC_APB1Periph_TIM2:   TIM2 clock\r
1347   *            @arg RCC_APB1Periph_TIM3:   TIM3 clock\r
1348   *            @arg RCC_APB1Periph_TIM4:   TIM4 clock\r
1349   *            @arg RCC_APB1Periph_TIM5:   TIM5 clock\r
1350   *            @arg RCC_APB1Periph_TIM6:   TIM6 clock\r
1351   *            @arg RCC_APB1Periph_TIM7:   TIM7 clock\r
1352   *            @arg RCC_APB1Periph_TIM12:  TIM12 clock\r
1353   *            @arg RCC_APB1Periph_TIM13:  TIM13 clock\r
1354   *            @arg RCC_APB1Periph_TIM14:  TIM14 clock\r
1355   *            @arg RCC_APB1Periph_WWDG:   WWDG clock\r
1356   *            @arg RCC_APB1Periph_SPI2:   SPI2 clock\r
1357   *            @arg RCC_APB1Periph_SPI3:   SPI3 clock\r
1358   *            @arg RCC_APB1Periph_USART2: USART2 clock\r
1359   *            @arg RCC_APB1Periph_USART3: USART3 clock\r
1360   *            @arg RCC_APB1Periph_UART4:  UART4 clock\r
1361   *            @arg RCC_APB1Periph_UART5:  UART5 clock\r
1362   *            @arg RCC_APB1Periph_I2C1:   I2C1 clock\r
1363   *            @arg RCC_APB1Periph_I2C2:   I2C2 clock\r
1364   *            @arg RCC_APB1Periph_I2C3:   I2C3 clock\r
1365   *            @arg RCC_APB1Periph_CAN1:   CAN1 clock\r
1366   *            @arg RCC_APB1Periph_CAN2:   CAN2 clock\r
1367   *            @arg RCC_APB1Periph_PWR:    PWR clock\r
1368   *            @arg RCC_APB1Periph_DAC:    DAC clock\r
1369   * @param  NewState: new state of the specified peripheral reset.\r
1370   *          This parameter can be: ENABLE or DISABLE.\r
1371   * @retval None\r
1372   */\r
1373 void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r
1374 {\r
1375   /* Check the parameters */\r
1376   assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));\r
1377   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1378   if (NewState != DISABLE)\r
1379   {\r
1380     RCC->APB1RSTR |= RCC_APB1Periph;\r
1381   }\r
1382   else\r
1383   {\r
1384     RCC->APB1RSTR &= ~RCC_APB1Periph;\r
1385   }\r
1386 }\r
1387 \r
1388 /**\r
1389   * @brief  Forces or releases High Speed APB (APB2) peripheral reset.\r
1390   * @param  RCC_APB2Periph: specifies the APB2 peripheral to reset.\r
1391   *          This parameter can be any combination of the following values:\r
1392   *            @arg RCC_APB2Periph_TIM1:   TIM1 clock\r
1393   *            @arg RCC_APB2Periph_TIM8:   TIM8 clock\r
1394   *            @arg RCC_APB2Periph_USART1: USART1 clock\r
1395   *            @arg RCC_APB2Periph_USART6: USART6 clock\r
1396   *            @arg RCC_APB2Periph_ADC1:   ADC1 clock\r
1397   *            @arg RCC_APB2Periph_ADC2:   ADC2 clock\r
1398   *            @arg RCC_APB2Periph_ADC3:   ADC3 clock\r
1399   *            @arg RCC_APB2Periph_SDIO:   SDIO clock\r
1400   *            @arg RCC_APB2Periph_SPI1:   SPI1 clock\r
1401   *            @arg RCC_APB2Periph_SYSCFG: SYSCFG clock\r
1402   *            @arg RCC_APB2Periph_TIM9:   TIM9 clock\r
1403   *            @arg RCC_APB2Periph_TIM10:  TIM10 clock\r
1404   *            @arg RCC_APB2Periph_TIM11:  TIM11 clock\r
1405   * @param  NewState: new state of the specified peripheral reset.\r
1406   *          This parameter can be: ENABLE or DISABLE.\r
1407   * @retval None\r
1408   */\r
1409 void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r
1410 {\r
1411   /* Check the parameters */\r
1412   assert_param(IS_RCC_APB2_RESET_PERIPH(RCC_APB2Periph));\r
1413   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1414   if (NewState != DISABLE)\r
1415   {\r
1416     RCC->APB2RSTR |= RCC_APB2Periph;\r
1417   }\r
1418   else\r
1419   {\r
1420     RCC->APB2RSTR &= ~RCC_APB2Periph;\r
1421   }\r
1422 }\r
1423 \r
1424 /**\r
1425   * @brief  Enables or disables the AHB1 peripheral clock during Low Power (Sleep) mode.\r
1426   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce\r
1427   *         power consumption.\r
1428   * @note   After wakeup from SLEEP mode, the peripheral clock is enabled again.\r
1429   * @note   By default, all peripheral clocks are enabled during SLEEP mode.\r
1430   * @param  RCC_AHBPeriph: specifies the AHB1 peripheral to gates its clock.\r
1431   *          This parameter can be any combination of the following values:\r
1432   *            @arg RCC_AHB1Periph_GPIOA:       GPIOA clock\r
1433   *            @arg RCC_AHB1Periph_GPIOB:       GPIOB clock \r
1434   *            @arg RCC_AHB1Periph_GPIOC:       GPIOC clock\r
1435   *            @arg RCC_AHB1Periph_GPIOD:       GPIOD clock\r
1436   *            @arg RCC_AHB1Periph_GPIOE:       GPIOE clock\r
1437   *            @arg RCC_AHB1Periph_GPIOF:       GPIOF clock\r
1438   *            @arg RCC_AHB1Periph_GPIOG:       GPIOG clock\r
1439   *            @arg RCC_AHB1Periph_GPIOH:       GPIOH clock\r
1440   *            @arg RCC_AHB1Periph_GPIOI:       GPIOI clock\r
1441   *            @arg RCC_AHB1Periph_CRC:         CRC clock\r
1442   *            @arg RCC_AHB1Periph_BKPSRAM:     BKPSRAM interface clock\r
1443   *            @arg RCC_AHB1Periph_DMA1:        DMA1 clock\r
1444   *            @arg RCC_AHB1Periph_DMA2:        DMA2 clock\r
1445   *            @arg RCC_AHB1Periph_ETH_MAC:     Ethernet MAC clock\r
1446   *            @arg RCC_AHB1Periph_ETH_MAC_Tx:  Ethernet Transmission clock\r
1447   *            @arg RCC_AHB1Periph_ETH_MAC_Rx:  Ethernet Reception clock\r
1448   *            @arg RCC_AHB1Periph_ETH_MAC_PTP: Ethernet PTP clock\r
1449   *            @arg RCC_AHB1Periph_OTG_HS:      USB OTG HS clock\r
1450   *            @arg RCC_AHB1Periph_OTG_HS_ULPI: USB OTG HS ULPI clock\r
1451   * @param  NewState: new state of the specified peripheral clock.\r
1452   *          This parameter can be: ENABLE or DISABLE.\r
1453   * @retval None\r
1454   */\r
1455 void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)\r
1456 {\r
1457   /* Check the parameters */\r
1458   assert_param(IS_RCC_AHB1_LPMODE_PERIPH(RCC_AHB1Periph));\r
1459   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1460   if (NewState != DISABLE)\r
1461   {\r
1462     RCC->AHB1LPENR |= RCC_AHB1Periph;\r
1463   }\r
1464   else\r
1465   {\r
1466     RCC->AHB1LPENR &= ~RCC_AHB1Periph;\r
1467   }\r
1468 }\r
1469 \r
1470 /**\r
1471   * @brief  Enables or disables the AHB2 peripheral clock during Low Power (Sleep) mode.\r
1472   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce\r
1473   *           power consumption.\r
1474   * @note   After wakeup from SLEEP mode, the peripheral clock is enabled again.\r
1475   * @note   By default, all peripheral clocks are enabled during SLEEP mode.\r
1476   * @param  RCC_AHBPeriph: specifies the AHB2 peripheral to gates its clock.\r
1477   *          This parameter can be any combination of the following values:\r
1478   *            @arg RCC_AHB2Periph_DCMI:   DCMI clock\r
1479   *            @arg RCC_AHB2Periph_CRYP:   CRYP clock\r
1480   *            @arg RCC_AHB2Periph_HASH:   HASH clock\r
1481   *            @arg RCC_AHB2Periph_RNG:    RNG clock\r
1482   *            @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock  \r
1483   * @param  NewState: new state of the specified peripheral clock.\r
1484   *          This parameter can be: ENABLE or DISABLE.\r
1485   * @retval None\r
1486   */\r
1487 void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)\r
1488 {\r
1489   /* Check the parameters */\r
1490   assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));\r
1491   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1492   if (NewState != DISABLE)\r
1493   {\r
1494     RCC->AHB2LPENR |= RCC_AHB2Periph;\r
1495   }\r
1496   else\r
1497   {\r
1498     RCC->AHB2LPENR &= ~RCC_AHB2Periph;\r
1499   }\r
1500 }\r
1501 \r
1502 /**\r
1503   * @brief  Enables or disables the AHB3 peripheral clock during Low Power (Sleep) mode.\r
1504   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce\r
1505   *         power consumption.\r
1506   * @note   After wakeup from SLEEP mode, the peripheral clock is enabled again.\r
1507   * @note   By default, all peripheral clocks are enabled during SLEEP mode.\r
1508   * @param  RCC_AHBPeriph: specifies the AHB3 peripheral to gates its clock.\r
1509   *          This parameter must be: RCC_AHB3Periph_FSMC\r
1510   * @param  NewState: new state of the specified peripheral clock.\r
1511   *          This parameter can be: ENABLE or DISABLE.\r
1512   * @retval None\r
1513   */\r
1514 void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)\r
1515 {\r
1516   /* Check the parameters */\r
1517   assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));\r
1518   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1519   if (NewState != DISABLE)\r
1520   {\r
1521     RCC->AHB3LPENR |= RCC_AHB3Periph;\r
1522   }\r
1523   else\r
1524   {\r
1525     RCC->AHB3LPENR &= ~RCC_AHB3Periph;\r
1526   }\r
1527 }\r
1528 \r
1529 /**\r
1530   * @brief  Enables or disables the APB1 peripheral clock during Low Power (Sleep) mode.\r
1531   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce\r
1532   *         power consumption.\r
1533   * @note   After wakeup from SLEEP mode, the peripheral clock is enabled again.\r
1534   * @note   By default, all peripheral clocks are enabled during SLEEP mode.\r
1535   * @param  RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.\r
1536   *          This parameter can be any combination of the following values:\r
1537   *            @arg RCC_APB1Periph_TIM2:   TIM2 clock\r
1538   *            @arg RCC_APB1Periph_TIM3:   TIM3 clock\r
1539   *            @arg RCC_APB1Periph_TIM4:   TIM4 clock\r
1540   *            @arg RCC_APB1Periph_TIM5:   TIM5 clock\r
1541   *            @arg RCC_APB1Periph_TIM6:   TIM6 clock\r
1542   *            @arg RCC_APB1Periph_TIM7:   TIM7 clock\r
1543   *            @arg RCC_APB1Periph_TIM12:  TIM12 clock\r
1544   *            @arg RCC_APB1Periph_TIM13:  TIM13 clock\r
1545   *            @arg RCC_APB1Periph_TIM14:  TIM14 clock\r
1546   *            @arg RCC_APB1Periph_WWDG:   WWDG clock\r
1547   *            @arg RCC_APB1Periph_SPI2:   SPI2 clock\r
1548   *            @arg RCC_APB1Periph_SPI3:   SPI3 clock\r
1549   *            @arg RCC_APB1Periph_USART2: USART2 clock\r
1550   *            @arg RCC_APB1Periph_USART3: USART3 clock\r
1551   *            @arg RCC_APB1Periph_UART4:  UART4 clock\r
1552   *            @arg RCC_APB1Periph_UART5:  UART5 clock\r
1553   *            @arg RCC_APB1Periph_I2C1:   I2C1 clock\r
1554   *            @arg RCC_APB1Periph_I2C2:   I2C2 clock\r
1555   *            @arg RCC_APB1Periph_I2C3:   I2C3 clock\r
1556   *            @arg RCC_APB1Periph_CAN1:   CAN1 clock\r
1557   *            @arg RCC_APB1Periph_CAN2:   CAN2 clock\r
1558   *            @arg RCC_APB1Periph_PWR:    PWR clock\r
1559   *            @arg RCC_APB1Periph_DAC:    DAC clock\r
1560   * @param  NewState: new state of the specified peripheral clock.\r
1561   *          This parameter can be: ENABLE or DISABLE.\r
1562   * @retval None\r
1563   */\r
1564 void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r
1565 {\r
1566   /* Check the parameters */\r
1567   assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));\r
1568   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1569   if (NewState != DISABLE)\r
1570   {\r
1571     RCC->APB1LPENR |= RCC_APB1Periph;\r
1572   }\r
1573   else\r
1574   {\r
1575     RCC->APB1LPENR &= ~RCC_APB1Periph;\r
1576   }\r
1577 }\r
1578 \r
1579 /**\r
1580   * @brief  Enables or disables the APB2 peripheral clock during Low Power (Sleep) mode.\r
1581   * @note   Peripheral clock gating in SLEEP mode can be used to further reduce\r
1582   *         power consumption.\r
1583   * @note   After wakeup from SLEEP mode, the peripheral clock is enabled again.\r
1584   * @note   By default, all peripheral clocks are enabled during SLEEP mode.\r
1585   * @param  RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.\r
1586   *          This parameter can be any combination of the following values:\r
1587   *            @arg RCC_APB2Periph_TIM1:   TIM1 clock\r
1588   *            @arg RCC_APB2Periph_TIM8:   TIM8 clock\r
1589   *            @arg RCC_APB2Periph_USART1: USART1 clock\r
1590   *            @arg RCC_APB2Periph_USART6: USART6 clock\r
1591   *            @arg RCC_APB2Periph_ADC1:   ADC1 clock\r
1592   *            @arg RCC_APB2Periph_ADC2:   ADC2 clock\r
1593   *            @arg RCC_APB2Periph_ADC3:   ADC3 clock\r
1594   *            @arg RCC_APB2Periph_SDIO:   SDIO clock\r
1595   *            @arg RCC_APB2Periph_SPI1:   SPI1 clock\r
1596   *            @arg RCC_APB2Periph_SYSCFG: SYSCFG clock\r
1597   *            @arg RCC_APB2Periph_TIM9:   TIM9 clock\r
1598   *            @arg RCC_APB2Periph_TIM10:  TIM10 clock\r
1599   *            @arg RCC_APB2Periph_TIM11:  TIM11 clock\r
1600   * @param  NewState: new state of the specified peripheral clock.\r
1601   *          This parameter can be: ENABLE or DISABLE.\r
1602   * @retval None\r
1603   */\r
1604 void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r
1605 {\r
1606   /* Check the parameters */\r
1607   assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));\r
1608   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1609   if (NewState != DISABLE)\r
1610   {\r
1611     RCC->APB2LPENR |= RCC_APB2Periph;\r
1612   }\r
1613   else\r
1614   {\r
1615     RCC->APB2LPENR &= ~RCC_APB2Periph;\r
1616   }\r
1617 }\r
1618 \r
1619 /**\r
1620   * @}\r
1621   */\r
1622 \r
1623 /** @defgroup RCC_Group4 Interrupts and flags management functions\r
1624  *  @brief   Interrupts and flags management functions \r
1625  *\r
1626 @verbatim   \r
1627  ===============================================================================\r
1628                    Interrupts and flags management functions\r
1629  ===============================================================================  \r
1630 \r
1631 @endverbatim\r
1632   * @{\r
1633   */\r
1634 \r
1635 /**\r
1636   * @brief  Enables or disables the specified RCC interrupts.\r
1637   * @param  RCC_IT: specifies the RCC interrupt sources to be enabled or disabled.\r
1638   *          This parameter can be any combination of the following values:\r
1639   *            @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1640   *            @arg RCC_IT_LSERDY: LSE ready interrupt\r
1641   *            @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1642   *            @arg RCC_IT_HSERDY: HSE ready interrupt\r
1643   *            @arg RCC_IT_PLLRDY: main PLL ready interrupt\r
1644   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt  \r
1645   * @param  NewState: new state of the specified RCC interrupts.\r
1646   *          This parameter can be: ENABLE or DISABLE.\r
1647   * @retval None\r
1648   */\r
1649 void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)\r
1650 {\r
1651   /* Check the parameters */\r
1652   assert_param(IS_RCC_IT(RCC_IT));\r
1653   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1654   if (NewState != DISABLE)\r
1655   {\r
1656     /* Perform Byte access to RCC_CIR[14:8] bits to enable the selected interrupts */\r
1657     *(__IO uint8_t *) CIR_BYTE2_ADDRESS |= RCC_IT;\r
1658   }\r
1659   else\r
1660   {\r
1661     /* Perform Byte access to RCC_CIR[14:8] bits to disable the selected interrupts */\r
1662     *(__IO uint8_t *) CIR_BYTE2_ADDRESS &= (uint8_t)~RCC_IT;\r
1663   }\r
1664 }\r
1665 \r
1666 /**\r
1667   * @brief  Checks whether the specified RCC flag is set or not.\r
1668   * @param  RCC_FLAG: specifies the flag to check.\r
1669   *          This parameter can be one of the following values:\r
1670   *            @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready\r
1671   *            @arg RCC_FLAG_HSERDY: HSE oscillator clock ready\r
1672   *            @arg RCC_FLAG_PLLRDY: main PLL clock ready\r
1673   *            @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready\r
1674   *            @arg RCC_FLAG_LSERDY: LSE oscillator clock ready\r
1675   *            @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready\r
1676   *            @arg RCC_FLAG_BORRST: POR/PDR or BOR reset\r
1677   *            @arg RCC_FLAG_PINRST: Pin reset\r
1678   *            @arg RCC_FLAG_PORRST: POR/PDR reset\r
1679   *            @arg RCC_FLAG_SFTRST: Software reset\r
1680   *            @arg RCC_FLAG_IWDGRST: Independent Watchdog reset\r
1681   *            @arg RCC_FLAG_WWDGRST: Window Watchdog reset\r
1682   *            @arg RCC_FLAG_LPWRRST: Low Power reset\r
1683   * @retval The new state of RCC_FLAG (SET or RESET).\r
1684   */\r
1685 FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)\r
1686 {\r
1687   uint32_t tmp = 0;\r
1688   uint32_t statusreg = 0;\r
1689   FlagStatus bitstatus = RESET;\r
1690 \r
1691   /* Check the parameters */\r
1692   assert_param(IS_RCC_FLAG(RCC_FLAG));\r
1693 \r
1694   /* Get the RCC register index */\r
1695   tmp = RCC_FLAG >> 5;\r
1696   if (tmp == 1)               /* The flag to check is in CR register */\r
1697   {\r
1698     statusreg = RCC->CR;\r
1699   }\r
1700   else if (tmp == 2)          /* The flag to check is in BDCR register */\r
1701   {\r
1702     statusreg = RCC->BDCR;\r
1703   }\r
1704   else                       /* The flag to check is in CSR register */\r
1705   {\r
1706     statusreg = RCC->CSR;\r
1707   }\r
1708 \r
1709   /* Get the flag position */\r
1710   tmp = RCC_FLAG & FLAG_MASK;\r
1711   if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)\r
1712   {\r
1713     bitstatus = SET;\r
1714   }\r
1715   else\r
1716   {\r
1717     bitstatus = RESET;\r
1718   }\r
1719   /* Return the flag status */\r
1720   return bitstatus;\r
1721 }\r
1722 \r
1723 /**\r
1724   * @brief  Clears the RCC reset flags.\r
1725   *         The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST,  RCC_FLAG_SFTRST,\r
1726   *         RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST\r
1727   * @param  None\r
1728   * @retval None\r
1729   */\r
1730 void RCC_ClearFlag(void)\r
1731 {\r
1732   /* Set RMVF bit to clear the reset flags */\r
1733   RCC->CSR |= RCC_CSR_RMVF;\r
1734 }\r
1735 \r
1736 /**\r
1737   * @brief  Checks whether the specified RCC interrupt has occurred or not.\r
1738   * @param  RCC_IT: specifies the RCC interrupt source to check.\r
1739   *          This parameter can be one of the following values:\r
1740   *            @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1741   *            @arg RCC_IT_LSERDY: LSE ready interrupt\r
1742   *            @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1743   *            @arg RCC_IT_HSERDY: HSE ready interrupt\r
1744   *            @arg RCC_IT_PLLRDY: main PLL ready interrupt\r
1745   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt  \r
1746   *            @arg RCC_IT_CSS: Clock Security System interrupt\r
1747   * @retval The new state of RCC_IT (SET or RESET).\r
1748   */\r
1749 ITStatus RCC_GetITStatus(uint8_t RCC_IT)\r
1750 {\r
1751   ITStatus bitstatus = RESET;\r
1752 \r
1753   /* Check the parameters */\r
1754   assert_param(IS_RCC_GET_IT(RCC_IT));\r
1755 \r
1756   /* Check the status of the specified RCC interrupt */\r
1757   if ((RCC->CIR & RCC_IT) != (uint32_t)RESET)\r
1758   {\r
1759     bitstatus = SET;\r
1760   }\r
1761   else\r
1762   {\r
1763     bitstatus = RESET;\r
1764   }\r
1765   /* Return the RCC_IT status */\r
1766   return  bitstatus;\r
1767 }\r
1768 \r
1769 /**\r
1770   * @brief  Clears the RCC's interrupt pending bits.\r
1771   * @param  RCC_IT: specifies the interrupt pending bit to clear.\r
1772   *          This parameter can be any combination of the following values:\r
1773   *            @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1774   *            @arg RCC_IT_LSERDY: LSE ready interrupt\r
1775   *            @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1776   *            @arg RCC_IT_HSERDY: HSE ready interrupt\r
1777   *            @arg RCC_IT_PLLRDY: main PLL ready interrupt\r
1778   *            @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt  \r
1779   *            @arg RCC_IT_CSS: Clock Security System interrupt\r
1780   * @retval None\r
1781   */\r
1782 void RCC_ClearITPendingBit(uint8_t RCC_IT)\r
1783 {\r
1784   /* Check the parameters */\r
1785   assert_param(IS_RCC_CLEAR_IT(RCC_IT));\r
1786 \r
1787   /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt\r
1788      pending bits */\r
1789   *(__IO uint8_t *) CIR_BYTE3_ADDRESS = RCC_IT;\r
1790 }\r
1791 \r
1792 /**\r
1793   * @}\r
1794   */ \r
1795 \r
1796 /**\r
1797   * @}\r
1798   */ \r
1799 \r
1800 /**\r
1801   * @}\r
1802   */ \r
1803 \r
1804 /**\r
1805   * @}\r
1806   */ \r
1807 \r
1808 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/\r