]> git.piffa.net Git - arduino/blob - sheets/gyro/GY-52 Three-axis gyroscope sending data /Three-axis gyroscope sending data/GY-52 Test program/STM32-CODE/serial port output MPU-3050/serial/Libraries/STM32F10x_StdPeriph_Driver/src/stm32f10x_rcc.c
first commit
[arduino] / sheets / gyro / GY-52 Three-axis gyroscope sending data / Three-axis gyroscope sending data / GY-52 Test program / STM32-CODE / serial port output MPU-3050 / serial / Libraries / STM32F10x_StdPeriph_Driver / src / stm32f10x_rcc.c
1 /**\r
2   ******************************************************************************\r
3   * @file    stm32f10x_rcc.c\r
4   * @author  MCD Application Team\r
5   * @version V3.1.2\r
6   * @date    09/28/2009\r
7   * @brief   This file provides all the RCC firmware functions.\r
8   ******************************************************************************\r
9   * @copy\r
10   *\r
11   * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS\r
12   * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE\r
13   * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY\r
14   * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING\r
15   * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE\r
16   * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.\r
17   *\r
18   * <h2><center>&copy; COPYRIGHT 2009 STMicroelectronics</center></h2>\r
19   */ \r
20 \r
21 /* Includes ------------------------------------------------------------------*/\r
22 #include "stm32f10x_rcc.h"\r
23 \r
24 /** @addtogroup STM32F10x_StdPeriph_Driver\r
25   * @{\r
26   */\r
27 \r
28 /** @defgroup RCC \r
29   * @brief RCC driver modules\r
30   * @{\r
31   */ \r
32 \r
33 /** @defgroup RCC_Private_TypesDefinitions\r
34   * @{\r
35   */\r
36 \r
37 /**\r
38   * @}\r
39   */\r
40 \r
41 /** @defgroup RCC_Private_Defines\r
42   * @{\r
43   */\r
44 \r
45 /* ------------ RCC registers bit address in the alias region ----------- */\r
46 #define RCC_OFFSET                (RCC_BASE - PERIPH_BASE)\r
47 \r
48 /* --- CR Register ---*/\r
49 \r
50 /* Alias word address of HSION bit */\r
51 #define CR_OFFSET                 (RCC_OFFSET + 0x00)\r
52 #define HSION_BitNumber           0x00\r
53 #define CR_HSION_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4))\r
54 \r
55 /* Alias word address of PLLON bit */\r
56 #define PLLON_BitNumber           0x18\r
57 #define CR_PLLON_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLON_BitNumber * 4))\r
58 \r
59 #ifdef STM32F10X_CL\r
60  /* Alias word address of PLL2ON bit */\r
61  #define PLL2ON_BitNumber          0x1A\r
62  #define CR_PLL2ON_BB              (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL2ON_BitNumber * 4))\r
63 \r
64  /* Alias word address of PLL3ON bit */\r
65  #define PLL3ON_BitNumber          0x1C\r
66  #define CR_PLL3ON_BB              (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLL3ON_BitNumber * 4))\r
67 #endif /* STM32F10X_CL */ \r
68 \r
69 /* Alias word address of CSSON bit */\r
70 #define CSSON_BitNumber           0x13\r
71 #define CR_CSSON_BB               (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CSSON_BitNumber * 4))\r
72 \r
73 /* --- CFGR Register ---*/\r
74 \r
75 /* Alias word address of USBPRE bit */\r
76 #define CFGR_OFFSET               (RCC_OFFSET + 0x04)\r
77 \r
78 #ifndef STM32F10X_CL\r
79  #define USBPRE_BitNumber          0x16\r
80  #define CFGR_USBPRE_BB            (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (USBPRE_BitNumber * 4))\r
81 #else\r
82  #define OTGFSPRE_BitNumber        0x16\r
83  #define CFGR_OTGFSPRE_BB          (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (OTGFSPRE_BitNumber * 4))\r
84 #endif /* STM32F10X_CL */ \r
85 \r
86 /* --- BDCR Register ---*/\r
87 \r
88 /* Alias word address of RTCEN bit */\r
89 #define BDCR_OFFSET               (RCC_OFFSET + 0x20)\r
90 #define RTCEN_BitNumber           0x0F\r
91 #define BDCR_RTCEN_BB             (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (RTCEN_BitNumber * 4))\r
92 \r
93 /* Alias word address of BDRST bit */\r
94 #define BDRST_BitNumber           0x10\r
95 #define BDCR_BDRST_BB             (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (BDRST_BitNumber * 4))\r
96 \r
97 /* --- CSR Register ---*/\r
98 \r
99 /* Alias word address of LSION bit */\r
100 #define CSR_OFFSET                (RCC_OFFSET + 0x24)\r
101 #define LSION_BitNumber           0x00\r
102 #define CSR_LSION_BB              (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (LSION_BitNumber * 4))\r
103 \r
104 #ifdef STM32F10X_CL\r
105 /* --- CFGR2 Register ---*/\r
106 \r
107  /* Alias word address of I2S2SRC bit */\r
108  #define CFGR2_OFFSET              (RCC_OFFSET + 0x2C)\r
109  #define I2S2SRC_BitNumber         0x11\r
110  #define CFGR2_I2S2SRC_BB          (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S2SRC_BitNumber * 4))\r
111 \r
112  /* Alias word address of I2S3SRC bit */\r
113  #define I2S3SRC_BitNumber         0x12\r
114  #define CFGR2_I2S3SRC_BB          (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (I2S3SRC_BitNumber * 4))\r
115 #endif /* STM32F10X_CL */\r
116 \r
117 /* ---------------------- RCC registers bit mask ------------------------ */\r
118 \r
119 /* CR register bit mask */\r
120 #define CR_HSEBYP_Reset           ((uint32_t)0xFFFBFFFF)\r
121 #define CR_HSEBYP_Set             ((uint32_t)0x00040000)\r
122 #define CR_HSEON_Reset            ((uint32_t)0xFFFEFFFF)\r
123 #define CR_HSEON_Set              ((uint32_t)0x00010000)\r
124 #define CR_HSITRIM_Mask           ((uint32_t)0xFFFFFF07)\r
125 \r
126 /* CFGR register bit mask */\r
127 #ifndef STM32F10X_CL\r
128  #define CFGR_PLL_Mask            ((uint32_t)0xFFC0FFFF)\r
129 #else\r
130  #define CFGR_PLL_Mask           ((uint32_t)0xFFC2FFFF)\r
131 #endif /* STM32F10X_CL */ \r
132 \r
133 #define CFGR_PLLMull_Mask         ((uint32_t)0x003C0000)\r
134 #define CFGR_PLLSRC_Mask          ((uint32_t)0x00010000)\r
135 #define CFGR_PLLXTPRE_Mask        ((uint32_t)0x00020000)\r
136 #define CFGR_SWS_Mask             ((uint32_t)0x0000000C)\r
137 #define CFGR_SW_Mask              ((uint32_t)0xFFFFFFFC)\r
138 #define CFGR_HPRE_Reset_Mask      ((uint32_t)0xFFFFFF0F)\r
139 #define CFGR_HPRE_Set_Mask        ((uint32_t)0x000000F0)\r
140 #define CFGR_PPRE1_Reset_Mask     ((uint32_t)0xFFFFF8FF)\r
141 #define CFGR_PPRE1_Set_Mask       ((uint32_t)0x00000700)\r
142 #define CFGR_PPRE2_Reset_Mask     ((uint32_t)0xFFFFC7FF)\r
143 #define CFGR_PPRE2_Set_Mask       ((uint32_t)0x00003800)\r
144 #define CFGR_ADCPRE_Reset_Mask    ((uint32_t)0xFFFF3FFF)\r
145 #define CFGR_ADCPRE_Set_Mask      ((uint32_t)0x0000C000)\r
146 \r
147 /* CSR register bit mask */\r
148 #define CSR_RMVF_Set              ((uint32_t)0x01000000)\r
149 \r
150 #ifdef STM32F10X_CL\r
151 /* CFGR2 register bit mask */\r
152  #define CFGR2_PREDIV1SRC         ((uint32_t)0x00010000)\r
153  #define CFGR2_PREDIV1            ((uint32_t)0x0000000F)\r
154  #define CFGR2_PREDIV2            ((uint32_t)0x000000F0)\r
155  #define CFGR2_PLL2MUL            ((uint32_t)0x00000F00)\r
156  #define CFGR2_PLL3MUL            ((uint32_t)0x0000F000)\r
157 #endif /* STM32F10X_CL */ \r
158 \r
159 /* RCC Flag Mask */\r
160 #define FLAG_Mask                 ((uint8_t)0x1F)\r
161 \r
162 #ifndef HSI_Value\r
163 /* Typical Value of the HSI in Hz */\r
164  #define HSI_Value                 ((uint32_t)8000000)\r
165 #endif /* HSI_Value */\r
166 \r
167 /* CIR register byte 2 (Bits[15:8]) base address */\r
168 #define CIR_BYTE2_ADDRESS         ((uint32_t)0x40021009)\r
169 \r
170 /* CIR register byte 3 (Bits[23:16]) base address */\r
171 #define CIR_BYTE3_ADDRESS         ((uint32_t)0x4002100A)\r
172 \r
173 /* CFGR register byte 4 (Bits[31:24]) base address */\r
174 #define CFGR_BYTE4_ADDRESS        ((uint32_t)0x40021007)\r
175 \r
176 /* BDCR register base address */\r
177 #define BDCR_ADDRESS              (PERIPH_BASE + BDCR_OFFSET)\r
178 \r
179 #ifndef HSEStartUp_TimeOut\r
180 /* Time out for HSE start up */\r
181  #define HSEStartUp_TimeOut        ((uint16_t)0x0500)\r
182 #endif /* HSEStartUp_TimeOut */\r
183 \r
184 /**\r
185   * @}\r
186   */ \r
187 \r
188 /** @defgroup RCC_Private_Macros\r
189   * @{\r
190   */ \r
191 \r
192 /**\r
193   * @}\r
194   */ \r
195 \r
196 /** @defgroup RCC_Private_Variables\r
197   * @{\r
198   */ \r
199 \r
200 static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};\r
201 static __I uint8_t ADCPrescTable[4] = {2, 4, 6, 8};\r
202 \r
203 /**\r
204   * @}\r
205   */\r
206 \r
207 /** @defgroup RCC_Private_FunctionPrototypes\r
208   * @{\r
209   */\r
210 \r
211 /**\r
212   * @}\r
213   */\r
214 \r
215 /** @defgroup RCC_Private_Functions\r
216   * @{\r
217   */\r
218 \r
219 /**\r
220   * @brief  Resets the RCC clock configuration to the default reset state.\r
221   * @param  None\r
222   * @retval None\r
223   */\r
224 void RCC_DeInit(void)\r
225 {\r
226   /* Set HSION bit */\r
227   RCC->CR |= (uint32_t)0x00000001;\r
228 \r
229   /* Reset SW, HPRE, PPRE1, PPRE2, ADCPRE and MCO bits */\r
230 #ifndef STM32F10X_CL\r
231   RCC->CFGR &= (uint32_t)0xF8FF0000;\r
232 #else\r
233   RCC->CFGR &= (uint32_t)0xF0FF0000;\r
234 #endif /* STM32F10X_CL */   \r
235   \r
236   /* Reset HSEON, CSSON and PLLON bits */\r
237   RCC->CR &= (uint32_t)0xFEF6FFFF;\r
238 \r
239   /* Reset HSEBYP bit */\r
240   RCC->CR &= (uint32_t)0xFFFBFFFF;\r
241 \r
242   /* Reset PLLSRC, PLLXTPRE, PLLMUL and USBPRE/OTGFSPRE bits */\r
243   RCC->CFGR &= (uint32_t)0xFF80FFFF;\r
244 \r
245 #ifndef STM32F10X_CL\r
246   /* Disable all interrupts and clear pending bits  */\r
247   RCC->CIR = 0x009F0000;\r
248 #else\r
249   /* Reset PLL2ON and PLL3ON bits */\r
250   RCC->CR &= (uint32_t)0xEBFFFFFF;\r
251 \r
252   /* Disable all interrupts and clear pending bits  */\r
253   RCC->CIR = 0x00FF0000;\r
254 \r
255   /* Reset CFGR2 register */\r
256   RCC->CFGR2 = 0x00000000;\r
257 #endif /* STM32F10X_CL */\r
258 }\r
259 \r
260 /**\r
261   * @brief  Configures the External High Speed oscillator (HSE).\r
262   * @note   HSE can not be stopped if it is used directly or through the PLL as system clock.\r
263   * @param  RCC_HSE: specifies the new state of the HSE.\r
264   *   This parameter can be one of the following values:\r
265   *     @arg RCC_HSE_OFF: HSE oscillator OFF\r
266   *     @arg RCC_HSE_ON: HSE oscillator ON\r
267   *     @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock\r
268   * @retval None\r
269   */\r
270 void RCC_HSEConfig(uint32_t RCC_HSE)\r
271 {\r
272   /* Check the parameters */\r
273   assert_param(IS_RCC_HSE(RCC_HSE));\r
274   /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/\r
275   /* Reset HSEON bit */\r
276   RCC->CR &= CR_HSEON_Reset;\r
277   /* Reset HSEBYP bit */\r
278   RCC->CR &= CR_HSEBYP_Reset;\r
279   /* Configure HSE (RCC_HSE_OFF is already covered by the code section above) */\r
280   switch(RCC_HSE)\r
281   {\r
282     case RCC_HSE_ON:\r
283       /* Set HSEON bit */\r
284       RCC->CR |= CR_HSEON_Set;\r
285       break;\r
286       \r
287     case RCC_HSE_Bypass:\r
288       /* Set HSEBYP and HSEON bits */\r
289       RCC->CR |= CR_HSEBYP_Set | CR_HSEON_Set;\r
290       break;\r
291       \r
292     default:\r
293       break;\r
294   }\r
295 }\r
296 \r
297 /**\r
298   * @brief  Waits for HSE start-up.\r
299   * @param  None\r
300   * @retval An ErrorStatus enumuration value:\r
301   * - SUCCESS: HSE oscillator is stable and ready to use\r
302   * - ERROR: HSE oscillator not yet ready\r
303   */\r
304 ErrorStatus RCC_WaitForHSEStartUp(void)\r
305 {\r
306   __IO uint32_t StartUpCounter = 0;\r
307   ErrorStatus status = ERROR;\r
308   FlagStatus HSEStatus = RESET;\r
309   \r
310   /* Wait till HSE is ready and if Time out is reached exit */\r
311   do\r
312   {\r
313     HSEStatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);\r
314     StartUpCounter++;  \r
315   } while((StartUpCounter != HSEStartUp_TimeOut) && (HSEStatus == RESET));\r
316   \r
317   if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)\r
318   {\r
319     status = SUCCESS;\r
320   }\r
321   else\r
322   {\r
323     status = ERROR;\r
324   }  \r
325   return (status);\r
326 }\r
327 \r
328 /**\r
329   * @brief  Adjusts the Internal High Speed oscillator (HSI) calibration value.\r
330   * @param  HSICalibrationValue: specifies the calibration trimming value.\r
331   *   This parameter must be a number between 0 and 0x1F.\r
332   * @retval None\r
333   */\r
334 void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)\r
335 {\r
336   uint32_t tmpreg = 0;\r
337   /* Check the parameters */\r
338   assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue));\r
339   tmpreg = RCC->CR;\r
340   /* Clear HSITRIM[4:0] bits */\r
341   tmpreg &= CR_HSITRIM_Mask;\r
342   /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */\r
343   tmpreg |= (uint32_t)HSICalibrationValue << 3;\r
344   /* Store the new value */\r
345   RCC->CR = tmpreg;\r
346 }\r
347 \r
348 /**\r
349   * @brief  Enables or disables the Internal High Speed oscillator (HSI).\r
350   * @note   HSI can not be stopped if it is used directly or through the PLL as system clock.\r
351   * @param  NewState: new state of the HSI. This parameter can be: ENABLE or DISABLE.\r
352   * @retval None\r
353   */\r
354 void RCC_HSICmd(FunctionalState NewState)\r
355 {\r
356   /* Check the parameters */\r
357   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
358   *(__IO uint32_t *) CR_HSION_BB = (uint32_t)NewState;\r
359 }\r
360 \r
361 /**\r
362   * @brief  Configures the PLL clock source and multiplication factor.\r
363   * @note   This function must be used only when the PLL is disabled.\r
364   * @param  RCC_PLLSource: specifies the PLL entry clock source.\r
365   *   For @b STM32_Connectivity_line_devices, this parameter can be one of the\r
366   *   following values:\r
367   *     @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry\r
368   *     @arg RCC_PLLSource_PREDIV1: PREDIV1 clock selected as PLL clock entry\r
369   *   For @b other_STM32_devices, this parameter can be one of the following values:\r
370   *     @arg RCC_PLLSource_HSI_Div2: HSI oscillator clock divided by 2 selected as PLL clock entry\r
371   *     @arg RCC_PLLSource_HSE_Div1: HSE oscillator clock selected as PLL clock entry\r
372   *     @arg RCC_PLLSource_HSE_Div2: HSE oscillator clock divided by 2 selected as PLL clock entry \r
373   * @param  RCC_PLLMul: specifies the PLL multiplication factor.\r
374   *   For @b STM32_Connectivity_line_devices, this parameter can be RCC_PLLMul_x where x:{[4,9], 6_5}\r
375   *   For @b other_STM32_devices, this parameter can be RCC_PLLMul_x where x:[2,16]  \r
376   * @retval None\r
377   */\r
378 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t RCC_PLLMul)\r
379 {\r
380   uint32_t tmpreg = 0;\r
381 \r
382   /* Check the parameters */\r
383   assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));\r
384   assert_param(IS_RCC_PLL_MUL(RCC_PLLMul));\r
385 \r
386   tmpreg = RCC->CFGR;\r
387   /* Clear PLLSRC, PLLXTPRE and PLLMUL[3:0] bits */\r
388   tmpreg &= CFGR_PLL_Mask;\r
389   /* Set the PLL configuration bits */\r
390   tmpreg |= RCC_PLLSource | RCC_PLLMul;\r
391   /* Store the new value */\r
392   RCC->CFGR = tmpreg;\r
393 }\r
394 \r
395 /**\r
396   * @brief  Enables or disables the PLL.\r
397   * @note   The PLL can not be disabled if it is used as system clock.\r
398   * @param  NewState: new state of the PLL. This parameter can be: ENABLE or DISABLE.\r
399   * @retval None\r
400   */\r
401 void RCC_PLLCmd(FunctionalState NewState)\r
402 {\r
403   /* Check the parameters */\r
404   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
405 \r
406   *(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState;\r
407 }\r
408 \r
409 #ifdef STM32F10X_CL\r
410 /**\r
411   * @brief  Configures the PREDIV1 division factor.\r
412   * @note \r
413   *   - This function must be used only when the PLL is disabled.\r
414   *   - This function applies only to STM32 Connectivity line devices.\r
415   * @param  RCC_PREDIV1_Source: specifies the PREDIV1 clock source.\r
416   *   This parameter can be one of the following values:\r
417   *     @arg RCC_PREDIV1_Source_HSE: HSE selected as PREDIV1 clock\r
418   *     @arg RCC_PREDIV1_Source_PLL2: PLL2 selected as PREDIV1 clock\r
419   * @param  RCC_PREDIV1_Div: specifies the PREDIV1 clock division factor.\r
420   *   This parameter can be RCC_PREDIV1_Divx where x:[1,16]\r
421   * @retval None\r
422   */\r
423 void RCC_PREDIV1Config(uint32_t RCC_PREDIV1_Source, uint32_t RCC_PREDIV1_Div)\r
424 {\r
425   uint32_t tmpreg = 0;\r
426   \r
427   /* Check the parameters */\r
428   assert_param(IS_RCC_PREDIV1_SOURCE(RCC_PREDIV1_Source));\r
429   assert_param(IS_RCC_PREDIV1(RCC_PREDIV1_Div));\r
430 \r
431   tmpreg = RCC->CFGR2;\r
432   /* Clear PREDIV1[3:0] and PREDIV1SRC bits */\r
433   tmpreg &= ~(CFGR2_PREDIV1 | CFGR2_PREDIV1SRC);\r
434   /* Set the PREDIV1 clock source and division factor */\r
435   tmpreg |= RCC_PREDIV1_Source | RCC_PREDIV1_Div ;\r
436   /* Store the new value */\r
437   RCC->CFGR2 = tmpreg;\r
438 }\r
439 \r
440 \r
441 /**\r
442   * @brief  Configures the PREDIV2 division factor.\r
443   * @note \r
444   *   - This function must be used only when both PLL2 and PLL3 are disabled.\r
445   *   - This function applies only to STM32 Connectivity line devices.\r
446   * @param  RCC_PREDIV2_Div: specifies the PREDIV2 clock division factor.\r
447   *   This parameter can be RCC_PREDIV2_Divx where x:[1,16]\r
448   * @retval None\r
449   */\r
450 void RCC_PREDIV2Config(uint32_t RCC_PREDIV2_Div)\r
451 {\r
452   uint32_t tmpreg = 0;\r
453 \r
454   /* Check the parameters */\r
455   assert_param(IS_RCC_PREDIV2(RCC_PREDIV2_Div));\r
456 \r
457   tmpreg = RCC->CFGR2;\r
458   /* Clear PREDIV2[3:0] bits */\r
459   tmpreg &= ~CFGR2_PREDIV2;\r
460   /* Set the PREDIV2 division factor */\r
461   tmpreg |= RCC_PREDIV2_Div;\r
462   /* Store the new value */\r
463   RCC->CFGR2 = tmpreg;\r
464 }\r
465 \r
466 /**\r
467   * @brief  Configures the PLL2 multiplication factor.\r
468   * @note\r
469   *   - This function must be used only when the PLL2 is disabled.\r
470   *   - This function applies only to STM32 Connectivity line devices.\r
471   * @param  RCC_PLL2Mul: specifies the PLL2 multiplication factor.\r
472   *   This parameter can be RCC_PLL2Mul_x where x:{[8,14], 16, 20}\r
473   * @retval None\r
474   */\r
475 void RCC_PLL2Config(uint32_t RCC_PLL2Mul)\r
476 {\r
477   uint32_t tmpreg = 0;\r
478 \r
479   /* Check the parameters */\r
480   assert_param(IS_RCC_PLL2_MUL(RCC_PLL2Mul));\r
481 \r
482   tmpreg = RCC->CFGR2;\r
483   /* Clear PLL2Mul[3:0] bits */\r
484   tmpreg &= ~CFGR2_PLL2MUL;\r
485   /* Set the PLL2 configuration bits */\r
486   tmpreg |= RCC_PLL2Mul;\r
487   /* Store the new value */\r
488   RCC->CFGR2 = tmpreg;\r
489 }\r
490 \r
491 \r
492 /**\r
493   * @brief  Enables or disables the PLL2.\r
494   * @note \r
495   *   - The PLL2 can not be disabled if it is used indirectly as system clock\r
496   *     (i.e. it is used as PLL clock entry that is used as System clock).\r
497   *   - This function applies only to STM32 Connectivity line devices.\r
498   * @param  NewState: new state of the PLL2. This parameter can be: ENABLE or DISABLE.\r
499   * @retval None\r
500   */\r
501 void RCC_PLL2Cmd(FunctionalState NewState)\r
502 {\r
503   /* Check the parameters */\r
504   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
505 \r
506   *(__IO uint32_t *) CR_PLL2ON_BB = (uint32_t)NewState;\r
507 }\r
508 \r
509 \r
510 /**\r
511   * @brief  Configures the PLL3 multiplication factor.\r
512   * @note \r
513   *   - This function must be used only when the PLL3 is disabled.\r
514   *   - This function applies only to STM32 Connectivity line devices.\r
515   * @param  RCC_PLL3Mul: specifies the PLL3 multiplication factor.\r
516   *   This parameter can be RCC_PLL3Mul_x where x:{[8,14], 16, 20}\r
517   * @retval None\r
518   */\r
519 void RCC_PLL3Config(uint32_t RCC_PLL3Mul)\r
520 {\r
521   uint32_t tmpreg = 0;\r
522 \r
523   /* Check the parameters */\r
524   assert_param(IS_RCC_PLL3_MUL(RCC_PLL3Mul));\r
525 \r
526   tmpreg = RCC->CFGR2;\r
527   /* Clear PLL3Mul[3:0] bits */\r
528   tmpreg &= ~CFGR2_PLL3MUL;\r
529   /* Set the PLL3 configuration bits */\r
530   tmpreg |= RCC_PLL3Mul;\r
531   /* Store the new value */\r
532   RCC->CFGR2 = tmpreg;\r
533 }\r
534 \r
535 \r
536 /**\r
537   * @brief  Enables or disables the PLL3.\r
538   * @note   This function applies only to STM32 Connectivity line devices.\r
539   * @param  NewState: new state of the PLL3. This parameter can be: ENABLE or DISABLE.\r
540   * @retval None\r
541   */\r
542 void RCC_PLL3Cmd(FunctionalState NewState)\r
543 {\r
544   /* Check the parameters */\r
545 \r
546   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
547   *(__IO uint32_t *) CR_PLL3ON_BB = (uint32_t)NewState;\r
548 }\r
549 #endif /* STM32F10X_CL */\r
550 \r
551 /**\r
552   * @brief  Configures the system clock (SYSCLK).\r
553   * @param  RCC_SYSCLKSource: specifies the clock source used as system clock.\r
554   *   This parameter can be one of the following values:\r
555   *     @arg RCC_SYSCLKSource_HSI: HSI selected as system clock\r
556   *     @arg RCC_SYSCLKSource_HSE: HSE selected as system clock\r
557   *     @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock\r
558   * @retval None\r
559   */\r
560 void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)\r
561 {\r
562   uint32_t tmpreg = 0;\r
563   /* Check the parameters */\r
564   assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));\r
565   tmpreg = RCC->CFGR;\r
566   /* Clear SW[1:0] bits */\r
567   tmpreg &= CFGR_SW_Mask;\r
568   /* Set SW[1:0] bits according to RCC_SYSCLKSource value */\r
569   tmpreg |= RCC_SYSCLKSource;\r
570   /* Store the new value */\r
571   RCC->CFGR = tmpreg;\r
572 }\r
573 \r
574 /**\r
575   * @brief  Returns the clock source used as system clock.\r
576   * @param  None\r
577   * @retval The clock source used as system clock. The returned value can\r
578   *   be one of the following:\r
579   *     - 0x00: HSI used as system clock\r
580   *     - 0x04: HSE used as system clock\r
581   *     - 0x08: PLL used as system clock\r
582   */\r
583 uint8_t RCC_GetSYSCLKSource(void)\r
584 {\r
585   return ((uint8_t)(RCC->CFGR & CFGR_SWS_Mask));\r
586 }\r
587 \r
588 /**\r
589   * @brief  Configures the AHB clock (HCLK).\r
590   * @param  RCC_SYSCLK: defines the AHB clock divider. This clock is derived from \r
591   *   the system clock (SYSCLK).\r
592   *   This parameter can be one of the following values:\r
593   *     @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK\r
594   *     @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2\r
595   *     @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4\r
596   *     @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8\r
597   *     @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16\r
598   *     @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64\r
599   *     @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128\r
600   *     @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256\r
601   *     @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512\r
602   * @retval None\r
603   */\r
604 void RCC_HCLKConfig(uint32_t RCC_SYSCLK)\r
605 {\r
606   uint32_t tmpreg = 0;\r
607   /* Check the parameters */\r
608   assert_param(IS_RCC_HCLK(RCC_SYSCLK));\r
609   tmpreg = RCC->CFGR;\r
610   /* Clear HPRE[3:0] bits */\r
611   tmpreg &= CFGR_HPRE_Reset_Mask;\r
612   /* Set HPRE[3:0] bits according to RCC_SYSCLK value */\r
613   tmpreg |= RCC_SYSCLK;\r
614   /* Store the new value */\r
615   RCC->CFGR = tmpreg;\r
616 }\r
617 \r
618 /**\r
619   * @brief  Configures the Low Speed APB clock (PCLK1).\r
620   * @param  RCC_HCLK: defines the APB1 clock divider. This clock is derived from \r
621   *   the AHB clock (HCLK).\r
622   *   This parameter can be one of the following values:\r
623   *     @arg RCC_HCLK_Div1: APB1 clock = HCLK\r
624   *     @arg RCC_HCLK_Div2: APB1 clock = HCLK/2\r
625   *     @arg RCC_HCLK_Div4: APB1 clock = HCLK/4\r
626   *     @arg RCC_HCLK_Div8: APB1 clock = HCLK/8\r
627   *     @arg RCC_HCLK_Div16: APB1 clock = HCLK/16\r
628   * @retval None\r
629   */\r
630 void RCC_PCLK1Config(uint32_t RCC_HCLK)\r
631 {\r
632   uint32_t tmpreg = 0;\r
633   /* Check the parameters */\r
634   assert_param(IS_RCC_PCLK(RCC_HCLK));\r
635   tmpreg = RCC->CFGR;\r
636   /* Clear PPRE1[2:0] bits */\r
637   tmpreg &= CFGR_PPRE1_Reset_Mask;\r
638   /* Set PPRE1[2:0] bits according to RCC_HCLK value */\r
639   tmpreg |= RCC_HCLK;\r
640   /* Store the new value */\r
641   RCC->CFGR = tmpreg;\r
642 }\r
643 \r
644 /**\r
645   * @brief  Configures the High Speed APB clock (PCLK2).\r
646   * @param  RCC_HCLK: defines the APB2 clock divider. This clock is derived from \r
647   *   the AHB clock (HCLK).\r
648   *   This parameter can be one of the following values:\r
649   *     @arg RCC_HCLK_Div1: APB2 clock = HCLK\r
650   *     @arg RCC_HCLK_Div2: APB2 clock = HCLK/2\r
651   *     @arg RCC_HCLK_Div4: APB2 clock = HCLK/4\r
652   *     @arg RCC_HCLK_Div8: APB2 clock = HCLK/8\r
653   *     @arg RCC_HCLK_Div16: APB2 clock = HCLK/16\r
654   * @retval None\r
655   */\r
656 void RCC_PCLK2Config(uint32_t RCC_HCLK)\r
657 {\r
658   uint32_t tmpreg = 0;\r
659   /* Check the parameters */\r
660   assert_param(IS_RCC_PCLK(RCC_HCLK));\r
661   tmpreg = RCC->CFGR;\r
662   /* Clear PPRE2[2:0] bits */\r
663   tmpreg &= CFGR_PPRE2_Reset_Mask;\r
664   /* Set PPRE2[2:0] bits according to RCC_HCLK value */\r
665   tmpreg |= RCC_HCLK << 3;\r
666   /* Store the new value */\r
667   RCC->CFGR = tmpreg;\r
668 }\r
669 \r
670 /**\r
671   * @brief  Enables or disables the specified RCC interrupts.\r
672   * @param  RCC_IT: specifies the RCC interrupt sources to be enabled or disabled.\r
673   * \r
674   *   For @b STM32_Connectivity_line_devices, this parameter can be any combination\r
675   *   of the following values        \r
676   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
677   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
678   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
679   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
680   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
681   *     @arg RCC_IT_PLL2RDY: PLL2 ready interrupt\r
682   *     @arg RCC_IT_PLL3RDY: PLL3 ready interrupt\r
683   * \r
684   *   For @b other_STM32_devices, this parameter can be any combination of the \r
685   *   following values        \r
686   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
687   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
688   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
689   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
690   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
691   *       \r
692   * @param  NewState: new state of the specified RCC interrupts.\r
693   *   This parameter can be: ENABLE or DISABLE.\r
694   * @retval None\r
695   */\r
696 void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)\r
697 {\r
698   /* Check the parameters */\r
699   assert_param(IS_RCC_IT(RCC_IT));\r
700   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
701   if (NewState != DISABLE)\r
702   {\r
703     /* Perform Byte access to RCC_CIR bits to enable the selected interrupts */\r
704     *(__IO uint8_t *) CIR_BYTE2_ADDRESS |= RCC_IT;\r
705   }\r
706   else\r
707   {\r
708     /* Perform Byte access to RCC_CIR bits to disable the selected interrupts */\r
709     *(__IO uint8_t *) CIR_BYTE2_ADDRESS &= (uint8_t)~RCC_IT;\r
710   }\r
711 }\r
712 \r
713 #ifndef STM32F10X_CL\r
714 /**\r
715   * @brief  Configures the USB clock (USBCLK).\r
716   * @param  RCC_USBCLKSource: specifies the USB clock source. This clock is \r
717   *   derived from the PLL output.\r
718   *   This parameter can be one of the following values:\r
719   *     @arg RCC_USBCLKSource_PLLCLK_1Div5: PLL clock divided by 1,5 selected as USB \r
720   *                                     clock source\r
721   *     @arg RCC_USBCLKSource_PLLCLK_Div1: PLL clock selected as USB clock source\r
722   * @retval None\r
723   */\r
724 void RCC_USBCLKConfig(uint32_t RCC_USBCLKSource)\r
725 {\r
726   /* Check the parameters */\r
727   assert_param(IS_RCC_USBCLK_SOURCE(RCC_USBCLKSource));\r
728 \r
729   *(__IO uint32_t *) CFGR_USBPRE_BB = RCC_USBCLKSource;\r
730 }\r
731 #else\r
732 /**\r
733   * @brief  Configures the USB OTG FS clock (OTGFSCLK).\r
734   *   This function applies only to STM32 Connectivity line devices.\r
735   * @param  RCC_OTGFSCLKSource: specifies the USB OTG FS clock source.\r
736   *   This clock is derived from the PLL output.\r
737   *   This parameter can be one of the following values:\r
738   *     @arg  RCC_OTGFSCLKSource_PLLVCO_Div3: PLL VCO clock divided by 2 selected as USB OTG FS clock source\r
739   *     @arg  RCC_OTGFSCLKSource_PLLVCO_Div2: PLL VCO clock divided by 2 selected as USB OTG FS clock source\r
740   * @retval None\r
741   */\r
742 void RCC_OTGFSCLKConfig(uint32_t RCC_OTGFSCLKSource)\r
743 {\r
744   /* Check the parameters */\r
745   assert_param(IS_RCC_OTGFSCLK_SOURCE(RCC_OTGFSCLKSource));\r
746 \r
747   *(__IO uint32_t *) CFGR_OTGFSPRE_BB = RCC_OTGFSCLKSource;\r
748 }\r
749 #endif /* STM32F10X_CL */ \r
750 \r
751 /**\r
752   * @brief  Configures the ADC clock (ADCCLK).\r
753   * @param  RCC_PCLK2: defines the ADC clock divider. This clock is derived from \r
754   *   the APB2 clock (PCLK2).\r
755   *   This parameter can be one of the following values:\r
756   *     @arg RCC_PCLK2_Div2: ADC clock = PCLK2/2\r
757   *     @arg RCC_PCLK2_Div4: ADC clock = PCLK2/4\r
758   *     @arg RCC_PCLK2_Div6: ADC clock = PCLK2/6\r
759   *     @arg RCC_PCLK2_Div8: ADC clock = PCLK2/8\r
760   * @retval None\r
761   */\r
762 void RCC_ADCCLKConfig(uint32_t RCC_PCLK2)\r
763 {\r
764   uint32_t tmpreg = 0;\r
765   /* Check the parameters */\r
766   assert_param(IS_RCC_ADCCLK(RCC_PCLK2));\r
767   tmpreg = RCC->CFGR;\r
768   /* Clear ADCPRE[1:0] bits */\r
769   tmpreg &= CFGR_ADCPRE_Reset_Mask;\r
770   /* Set ADCPRE[1:0] bits according to RCC_PCLK2 value */\r
771   tmpreg |= RCC_PCLK2;\r
772   /* Store the new value */\r
773   RCC->CFGR = tmpreg;\r
774 }\r
775 \r
776 #ifdef STM32F10X_CL\r
777 /**\r
778   * @brief  Configures the I2S2 clock source(I2S2CLK).\r
779   * @note\r
780   *   - This function must be called before enabling I2S2 APB clock.\r
781   *   - This function applies only to STM32 Connectivity line devices.\r
782   * @param  RCC_I2S2CLKSource: specifies the I2S2 clock source.\r
783   *   This parameter can be one of the following values:\r
784   *     @arg RCC_I2S2CLKSource_SYSCLK: system clock selected as I2S2 clock entry\r
785   *     @arg RCC_I2S2CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S2 clock entry\r
786   * @retval None\r
787   */\r
788 void RCC_I2S2CLKConfig(uint32_t RCC_I2S2CLKSource)\r
789 {\r
790   /* Check the parameters */\r
791   assert_param(IS_RCC_I2S2CLK_SOURCE(RCC_I2S2CLKSource));\r
792 \r
793   *(__IO uint32_t *) CFGR2_I2S2SRC_BB = RCC_I2S2CLKSource;\r
794 }\r
795 \r
796 /**\r
797   * @brief  Configures the I2S3 clock source(I2S2CLK).\r
798   * @note\r
799   *   - This function must be called before enabling I2S3 APB clock.\r
800   *   - This function applies only to STM32 Connectivity line devices.\r
801   * @param  RCC_I2S3CLKSource: specifies the I2S3 clock source.\r
802   *   This parameter can be one of the following values:\r
803   *     @arg RCC_I2S3CLKSource_SYSCLK: system clock selected as I2S3 clock entry\r
804   *     @arg RCC_I2S3CLKSource_PLL3_VCO: PLL3 VCO clock selected as I2S3 clock entry\r
805   * @retval None\r
806   */\r
807 void RCC_I2S3CLKConfig(uint32_t RCC_I2S3CLKSource)\r
808 {\r
809   /* Check the parameters */\r
810   assert_param(IS_RCC_I2S3CLK_SOURCE(RCC_I2S3CLKSource));\r
811 \r
812   *(__IO uint32_t *) CFGR2_I2S3SRC_BB = RCC_I2S3CLKSource;\r
813 }\r
814 #endif /* STM32F10X_CL */\r
815 \r
816 /**\r
817   * @brief  Configures the External Low Speed oscillator (LSE).\r
818   * @param  RCC_LSE: specifies the new state of the LSE.\r
819   *   This parameter can be one of the following values:\r
820   *     @arg RCC_LSE_OFF: LSE oscillator OFF\r
821   *     @arg RCC_LSE_ON: LSE oscillator ON\r
822   *     @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock\r
823   * @retval None\r
824   */\r
825 void RCC_LSEConfig(uint8_t RCC_LSE)\r
826 {\r
827   /* Check the parameters */\r
828   assert_param(IS_RCC_LSE(RCC_LSE));\r
829   /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/\r
830   /* Reset LSEON bit */\r
831   *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;\r
832   /* Reset LSEBYP bit */\r
833   *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;\r
834   /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */\r
835   switch(RCC_LSE)\r
836   {\r
837     case RCC_LSE_ON:\r
838       /* Set LSEON bit */\r
839       *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_ON;\r
840       break;\r
841       \r
842     case RCC_LSE_Bypass:\r
843       /* Set LSEBYP and LSEON bits */\r
844       *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_Bypass | RCC_LSE_ON;\r
845       break;            \r
846       \r
847     default:\r
848       break;      \r
849   }\r
850 }\r
851 \r
852 /**\r
853   * @brief  Enables or disables the Internal Low Speed oscillator (LSI).\r
854   * @note   LSI can not be disabled if the IWDG is running.\r
855   * @param  NewState: new state of the LSI. This parameter can be: ENABLE or DISABLE.\r
856   * @retval None\r
857   */\r
858 void RCC_LSICmd(FunctionalState NewState)\r
859 {\r
860   /* Check the parameters */\r
861   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
862   *(__IO uint32_t *) CSR_LSION_BB = (uint32_t)NewState;\r
863 }\r
864 \r
865 /**\r
866   * @brief  Configures the RTC clock (RTCCLK).\r
867   * @note   Once the RTC clock is selected it can\92t be changed unless the Backup domain is reset.\r
868   * @param  RCC_RTCCLKSource: specifies the RTC clock source.\r
869   *   This parameter can be one of the following values:\r
870   *     @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock\r
871   *     @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock\r
872   *     @arg RCC_RTCCLKSource_HSE_Div128: HSE clock divided by 128 selected as RTC clock\r
873   * @retval None\r
874   */\r
875 void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)\r
876 {\r
877   /* Check the parameters */\r
878   assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));\r
879   /* Select the RTC clock source */\r
880   RCC->BDCR |= RCC_RTCCLKSource;\r
881 }\r
882 \r
883 /**\r
884   * @brief  Enables or disables the RTC clock.\r
885   * @note   This function must be used only after the RTC clock was selected using the RCC_RTCCLKConfig function.\r
886   * @param  NewState: new state of the RTC clock. This parameter can be: ENABLE or DISABLE.\r
887   * @retval None\r
888   */\r
889 void RCC_RTCCLKCmd(FunctionalState NewState)\r
890 {\r
891   /* Check the parameters */\r
892   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
893   *(__IO uint32_t *) BDCR_RTCEN_BB = (uint32_t)NewState;\r
894 }\r
895 \r
896 /**\r
897   * @brief  Returns the frequencies of different on chip clocks.\r
898   * @param  RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold\r
899   *   the clocks frequencies.\r
900   * @retval None\r
901   */\r
902 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)\r
903 {\r
904   uint32_t tmp = 0, pllmull = 0, pllsource = 0, presc = 0;\r
905 \r
906 #ifdef  STM32F10X_CL\r
907   uint32_t prediv1source = 0, prediv1factor = 0, prediv2factor = 0, pll2mull = 0;\r
908 #endif /* STM32F10X_CL */\r
909     \r
910   /* Get SYSCLK source -------------------------------------------------------*/\r
911   tmp = RCC->CFGR & CFGR_SWS_Mask;\r
912   \r
913   switch (tmp)\r
914   {\r
915     case 0x00:  /* HSI used as system clock */\r
916       RCC_Clocks->SYSCLK_Frequency = HSI_Value;\r
917       break;\r
918     case 0x04:  /* HSE used as system clock */\r
919       RCC_Clocks->SYSCLK_Frequency = HSE_Value;\r
920       break;\r
921     case 0x08:  /* PLL used as system clock */\r
922 \r
923       /* Get PLL clock source and multiplication factor ----------------------*/\r
924       pllmull = RCC->CFGR & CFGR_PLLMull_Mask;\r
925       pllsource = RCC->CFGR & CFGR_PLLSRC_Mask;\r
926       \r
927 #ifndef STM32F10X_CL      \r
928       pllmull = ( pllmull >> 18) + 2;\r
929       \r
930       if (pllsource == 0x00)\r
931       {/* HSI oscillator clock divided by 2 selected as PLL clock entry */\r
932         RCC_Clocks->SYSCLK_Frequency = (HSI_Value >> 1) * pllmull;\r
933       }\r
934       else\r
935       {/* HSE selected as PLL clock entry */\r
936         if ((RCC->CFGR & CFGR_PLLXTPRE_Mask) != (uint32_t)RESET)\r
937         {/* HSE oscillator clock divided by 2 */\r
938           RCC_Clocks->SYSCLK_Frequency = (HSE_Value >> 1) * pllmull;\r
939         }\r
940         else\r
941         {\r
942           RCC_Clocks->SYSCLK_Frequency = HSE_Value * pllmull;\r
943         }\r
944       }\r
945 #else\r
946       pllmull = pllmull >> 18;\r
947       \r
948       if (pllmull != 0x0D)\r
949       {\r
950          pllmull += 2;\r
951       }\r
952       else\r
953       { /* PLL multiplication factor = PLL input clock * 6.5 */\r
954         pllmull = 13 / 2; \r
955       }\r
956             \r
957       if (pllsource == 0x00)\r
958       {/* HSI oscillator clock divided by 2 selected as PLL clock entry */\r
959         RCC_Clocks->SYSCLK_Frequency = (HSI_Value >> 1) * pllmull;\r
960       }\r
961       else\r
962       {/* PREDIV1 selected as PLL clock entry */\r
963         \r
964         /* Get PREDIV1 clock source and division factor */\r
965         prediv1source = RCC->CFGR2 & CFGR2_PREDIV1SRC;\r
966         prediv1factor = (RCC->CFGR2 & CFGR2_PREDIV1) + 1;\r
967         \r
968         if (prediv1source == 0)\r
969         { /* HSE oscillator clock selected as PREDIV1 clock entry */\r
970           RCC_Clocks->SYSCLK_Frequency = (HSE_Value / prediv1factor) * pllmull;          \r
971         }\r
972         else\r
973         {/* PLL2 clock selected as PREDIV1 clock entry */\r
974           \r
975           /* Get PREDIV2 division factor and PLL2 multiplication factor */\r
976           prediv2factor = ((RCC->CFGR2 & CFGR2_PREDIV2) >> 4) + 1;\r
977           pll2mull = ((RCC->CFGR2 & CFGR2_PLL2MUL) >> 8 ) + 2; \r
978           RCC_Clocks->SYSCLK_Frequency = (((HSE_Value / prediv2factor) * pll2mull) / prediv1factor) * pllmull;                         \r
979         }\r
980       }\r
981 #endif /* STM32F10X_CL */ \r
982       break;\r
983 \r
984     default:\r
985       RCC_Clocks->SYSCLK_Frequency = HSI_Value;\r
986       break;\r
987   }\r
988 \r
989   /* Compute HCLK, PCLK1, PCLK2 and ADCCLK clocks frequencies ----------------*/\r
990   /* Get HCLK prescaler */\r
991   tmp = RCC->CFGR & CFGR_HPRE_Set_Mask;\r
992   tmp = tmp >> 4;\r
993   presc = APBAHBPrescTable[tmp];\r
994   /* HCLK clock frequency */\r
995   RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc;\r
996   /* Get PCLK1 prescaler */\r
997   tmp = RCC->CFGR & CFGR_PPRE1_Set_Mask;\r
998   tmp = tmp >> 8;\r
999   presc = APBAHBPrescTable[tmp];\r
1000   /* PCLK1 clock frequency */\r
1001   RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc;\r
1002   /* Get PCLK2 prescaler */\r
1003   tmp = RCC->CFGR & CFGR_PPRE2_Set_Mask;\r
1004   tmp = tmp >> 11;\r
1005   presc = APBAHBPrescTable[tmp];\r
1006   /* PCLK2 clock frequency */\r
1007   RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc;\r
1008   /* Get ADCCLK prescaler */\r
1009   tmp = RCC->CFGR & CFGR_ADCPRE_Set_Mask;\r
1010   tmp = tmp >> 14;\r
1011   presc = ADCPrescTable[tmp];\r
1012   /* ADCCLK clock frequency */\r
1013   RCC_Clocks->ADCCLK_Frequency = RCC_Clocks->PCLK2_Frequency / presc;\r
1014 }\r
1015 \r
1016 /**\r
1017   * @brief  Enables or disables the AHB peripheral clock.\r
1018   * @param  RCC_AHBPeriph: specifies the AHB peripheral to gates its clock.\r
1019   *   \r
1020   *   For @b STM32_Connectivity_line_devices, this parameter can be any combination\r
1021   *   of the following values:        \r
1022   *     @arg RCC_AHBPeriph_DMA1\r
1023   *     @arg RCC_AHBPeriph_DMA2\r
1024   *     @arg RCC_AHBPeriph_SRAM\r
1025   *     @arg RCC_AHBPeriph_FLITF\r
1026   *     @arg RCC_AHBPeriph_CRC\r
1027   *     @arg RCC_AHBPeriph_OTG_FS    \r
1028   *     @arg RCC_AHBPeriph_ETH_MAC   \r
1029   *     @arg RCC_AHBPeriph_ETH_MAC_Tx\r
1030   *     @arg RCC_AHBPeriph_ETH_MAC_Rx\r
1031   * \r
1032   *   For @b other_STM32_devices, this parameter can be any combination of the \r
1033   *   following values:        \r
1034   *     @arg RCC_AHBPeriph_DMA1\r
1035   *     @arg RCC_AHBPeriph_DMA2\r
1036   *     @arg RCC_AHBPeriph_SRAM\r
1037   *     @arg RCC_AHBPeriph_FLITF\r
1038   *     @arg RCC_AHBPeriph_CRC\r
1039   *     @arg RCC_AHBPeriph_FSMC\r
1040   *     @arg RCC_AHBPeriph_SDIO\r
1041   *   \r
1042   * @note SRAM and FLITF clock can be disabled only during sleep mode.\r
1043   * @param  NewState: new state of the specified peripheral clock.\r
1044   *   This parameter can be: ENABLE or DISABLE.\r
1045   * @retval None\r
1046   */\r
1047 void RCC_AHBPeriphClockCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)\r
1048 {\r
1049   /* Check the parameters */\r
1050   assert_param(IS_RCC_AHB_PERIPH(RCC_AHBPeriph));\r
1051   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1052 \r
1053   if (NewState != DISABLE)\r
1054   {\r
1055     RCC->AHBENR |= RCC_AHBPeriph;\r
1056   }\r
1057   else\r
1058   {\r
1059     RCC->AHBENR &= ~RCC_AHBPeriph;\r
1060   }\r
1061 }\r
1062 \r
1063 /**\r
1064   * @brief  Enables or disables the High Speed APB (APB2) peripheral clock.\r
1065   * @param  RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.\r
1066   *   This parameter can be any combination of the following values:\r
1067   *     @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB,\r
1068   *          RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE,\r
1069   *          RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1,\r
1070   *          RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1,\r
1071   *          RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3\r
1072   * @param  NewState: new state of the specified peripheral clock.\r
1073   *   This parameter can be: ENABLE or DISABLE.\r
1074   * @retval None\r
1075   */\r
1076 void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r
1077 {\r
1078   /* Check the parameters */\r
1079   assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));\r
1080   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1081   if (NewState != DISABLE)\r
1082   {\r
1083     RCC->APB2ENR |= RCC_APB2Periph;\r
1084   }\r
1085   else\r
1086   {\r
1087     RCC->APB2ENR &= ~RCC_APB2Periph;\r
1088   }\r
1089 }\r
1090 \r
1091 /**\r
1092   * @brief  Enables or disables the Low Speed APB (APB1) peripheral clock.\r
1093   * @param  RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.\r
1094   *   This parameter can be any combination of the following values:\r
1095   *     @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4,\r
1096   *          RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7,\r
1097   *          RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3,\r
1098   *          RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, \r
1099   *          RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2,\r
1100   *          RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP,\r
1101   *          RCC_APB1Periph_PWR, RCC_APB1Periph_DAC\r
1102   * @param  NewState: new state of the specified peripheral clock.\r
1103   *   This parameter can be: ENABLE or DISABLE.\r
1104   * @retval None\r
1105   */\r
1106 void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r
1107 {\r
1108   /* Check the parameters */\r
1109   assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));\r
1110   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1111   if (NewState != DISABLE)\r
1112   {\r
1113     RCC->APB1ENR |= RCC_APB1Periph;\r
1114   }\r
1115   else\r
1116   {\r
1117     RCC->APB1ENR &= ~RCC_APB1Periph;\r
1118   }\r
1119 }\r
1120 \r
1121 #ifdef STM32F10X_CL\r
1122 /**\r
1123   * @brief  Forces or releases AHB peripheral reset.\r
1124   * @note   This function applies only to STM32 Connectivity line devices.\r
1125   * @param  RCC_AHBPeriph: specifies the AHB peripheral to reset.\r
1126   *   This parameter can be any combination of the following values:\r
1127   *     @arg RCC_AHBPeriph_OTG_FS \r
1128   *     @arg RCC_AHBPeriph_ETH_MAC\r
1129   * @param  NewState: new state of the specified peripheral reset.\r
1130   *   This parameter can be: ENABLE or DISABLE.\r
1131   * @retval None\r
1132   */\r
1133 void RCC_AHBPeriphResetCmd(uint32_t RCC_AHBPeriph, FunctionalState NewState)\r
1134 {\r
1135   /* Check the parameters */\r
1136   assert_param(IS_RCC_AHB_PERIPH_RESET(RCC_AHBPeriph));\r
1137   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1138 \r
1139   if (NewState != DISABLE)\r
1140   {\r
1141     RCC->AHBRSTR |= RCC_AHBPeriph;\r
1142   }\r
1143   else\r
1144   {\r
1145     RCC->AHBRSTR &= ~RCC_AHBPeriph;\r
1146   }\r
1147 }\r
1148 #endif /* STM32F10X_CL */ \r
1149 \r
1150 /**\r
1151   * @brief  Forces or releases High Speed APB (APB2) peripheral reset.\r
1152   * @param  RCC_APB2Periph: specifies the APB2 peripheral to reset.\r
1153   *   This parameter can be any combination of the following values:\r
1154   *     @arg RCC_APB2Periph_AFIO, RCC_APB2Periph_GPIOA, RCC_APB2Periph_GPIOB,\r
1155   *          RCC_APB2Periph_GPIOC, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE,\r
1156   *          RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, RCC_APB2Periph_ADC1,\r
1157   *          RCC_APB2Periph_ADC2, RCC_APB2Periph_TIM1, RCC_APB2Periph_SPI1,\r
1158   *          RCC_APB2Periph_TIM8, RCC_APB2Periph_USART1, RCC_APB2Periph_ADC3\r
1159   * @param  NewState: new state of the specified peripheral reset.\r
1160   *   This parameter can be: ENABLE or DISABLE.\r
1161   * @retval None\r
1162   */\r
1163 void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)\r
1164 {\r
1165   /* Check the parameters */\r
1166   assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));\r
1167   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1168   if (NewState != DISABLE)\r
1169   {\r
1170     RCC->APB2RSTR |= RCC_APB2Periph;\r
1171   }\r
1172   else\r
1173   {\r
1174     RCC->APB2RSTR &= ~RCC_APB2Periph;\r
1175   }\r
1176 }\r
1177 \r
1178 /**\r
1179   * @brief  Forces or releases Low Speed APB (APB1) peripheral reset.\r
1180   * @param  RCC_APB1Periph: specifies the APB1 peripheral to reset.\r
1181   *   This parameter can be any combination of the following values:\r
1182   *     @arg RCC_APB1Periph_TIM2, RCC_APB1Periph_TIM3, RCC_APB1Periph_TIM4,\r
1183   *          RCC_APB1Periph_TIM5, RCC_APB1Periph_TIM6, RCC_APB1Periph_TIM7,\r
1184   *          RCC_APB1Periph_WWDG, RCC_APB1Periph_SPI2, RCC_APB1Periph_SPI3,\r
1185   *          RCC_APB1Periph_USART2, RCC_APB1Periph_USART3, RCC_APB1Periph_USART4, \r
1186   *          RCC_APB1Periph_USART5, RCC_APB1Periph_I2C1, RCC_APB1Periph_I2C2,\r
1187   *          RCC_APB1Periph_USB, RCC_APB1Periph_CAN1, RCC_APB1Periph_BKP,\r
1188   *          RCC_APB1Periph_PWR, RCC_APB1Periph_DAC\r
1189   * @param  NewState: new state of the specified peripheral clock.\r
1190   *   This parameter can be: ENABLE or DISABLE.\r
1191   * @retval None\r
1192   */\r
1193 void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)\r
1194 {\r
1195   /* Check the parameters */\r
1196   assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));\r
1197   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1198   if (NewState != DISABLE)\r
1199   {\r
1200     RCC->APB1RSTR |= RCC_APB1Periph;\r
1201   }\r
1202   else\r
1203   {\r
1204     RCC->APB1RSTR &= ~RCC_APB1Periph;\r
1205   }\r
1206 }\r
1207 \r
1208 /**\r
1209   * @brief  Forces or releases the Backup domain reset.\r
1210   * @param  NewState: new state of the Backup domain reset.\r
1211   *   This parameter can be: ENABLE or DISABLE.\r
1212   * @retval None\r
1213   */\r
1214 void RCC_BackupResetCmd(FunctionalState NewState)\r
1215 {\r
1216   /* Check the parameters */\r
1217   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1218   *(__IO uint32_t *) BDCR_BDRST_BB = (uint32_t)NewState;\r
1219 }\r
1220 \r
1221 /**\r
1222   * @brief  Enables or disables the Clock Security System.\r
1223   * @param  NewState: new state of the Clock Security System..\r
1224   *   This parameter can be: ENABLE or DISABLE.\r
1225   * @retval None\r
1226   */\r
1227 void RCC_ClockSecuritySystemCmd(FunctionalState NewState)\r
1228 {\r
1229   /* Check the parameters */\r
1230   assert_param(IS_FUNCTIONAL_STATE(NewState));\r
1231   *(__IO uint32_t *) CR_CSSON_BB = (uint32_t)NewState;\r
1232 }\r
1233 \r
1234 /**\r
1235   * @brief  Selects the clock source to output on MCO pin.\r
1236   * @param  RCC_MCO: specifies the clock source to output.\r
1237   *   \r
1238   *   For @b STM32_Connectivity_line_devices, this parameter can be one of the\r
1239   *   following values:       \r
1240   *     @arg RCC_MCO_NoClock: No clock selected\r
1241   *     @arg RCC_MCO_SYSCLK: System clock selected\r
1242   *     @arg RCC_MCO_HSI: HSI oscillator clock selected\r
1243   *     @arg RCC_MCO_HSE: HSE oscillator clock selected\r
1244   *     @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected\r
1245   *     @arg RCC_MCO_PLL2CLK: PLL2 clock selected                     \r
1246   *     @arg RCC_MCO_PLL3CLK_Div2: PLL3 clock divided by 2 selected   \r
1247   *     @arg RCC_MCO_XT1: External 3-25 MHz oscillator clock selected  \r
1248   *     @arg RCC_MCO_PLL3CLK: PLL3 clock selected \r
1249   * \r
1250   *   For  @b other_STM32_devices, this parameter can be one of the following values:        \r
1251   *     @arg RCC_MCO_NoClock: No clock selected\r
1252   *     @arg RCC_MCO_SYSCLK: System clock selected\r
1253   *     @arg RCC_MCO_HSI: HSI oscillator clock selected\r
1254   *     @arg RCC_MCO_HSE: HSE oscillator clock selected\r
1255   *     @arg RCC_MCO_PLLCLK_Div2: PLL clock divided by 2 selected\r
1256   *   \r
1257   * @retval None\r
1258   */\r
1259 void RCC_MCOConfig(uint8_t RCC_MCO)\r
1260 {\r
1261   /* Check the parameters */\r
1262   assert_param(IS_RCC_MCO(RCC_MCO));\r
1263 \r
1264   /* Perform Byte access to MCO bits to select the MCO source */\r
1265   *(__IO uint8_t *) CFGR_BYTE4_ADDRESS = RCC_MCO;\r
1266 }\r
1267 \r
1268 /**\r
1269   * @brief  Checks whether the specified RCC flag is set or not.\r
1270   * @param  RCC_FLAG: specifies the flag to check.\r
1271   *   \r
1272   *   For @b STM32_Connectivity_line_devices, this parameter can be one of the\r
1273   *   following values:\r
1274   *     @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready\r
1275   *     @arg RCC_FLAG_HSERDY: HSE oscillator clock ready\r
1276   *     @arg RCC_FLAG_PLLRDY: PLL clock ready\r
1277   *     @arg RCC_FLAG_PLL2RDY: PLL2 clock ready      \r
1278   *     @arg RCC_FLAG_PLL3RDY: PLL3 clock ready                           \r
1279   *     @arg RCC_FLAG_LSERDY: LSE oscillator clock ready\r
1280   *     @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready\r
1281   *     @arg RCC_FLAG_PINRST: Pin reset\r
1282   *     @arg RCC_FLAG_PORRST: POR/PDR reset\r
1283   *     @arg RCC_FLAG_SFTRST: Software reset\r
1284   *     @arg RCC_FLAG_IWDGRST: Independent Watchdog reset\r
1285   *     @arg RCC_FLAG_WWDGRST: Window Watchdog reset\r
1286   *     @arg RCC_FLAG_LPWRRST: Low Power reset\r
1287   * \r
1288   *   For @b other_STM32_devices, this parameter can be one of the following values:        \r
1289   *     @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready\r
1290   *     @arg RCC_FLAG_HSERDY: HSE oscillator clock ready\r
1291   *     @arg RCC_FLAG_PLLRDY: PLL clock ready\r
1292   *     @arg RCC_FLAG_LSERDY: LSE oscillator clock ready\r
1293   *     @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready\r
1294   *     @arg RCC_FLAG_PINRST: Pin reset\r
1295   *     @arg RCC_FLAG_PORRST: POR/PDR reset\r
1296   *     @arg RCC_FLAG_SFTRST: Software reset\r
1297   *     @arg RCC_FLAG_IWDGRST: Independent Watchdog reset\r
1298   *     @arg RCC_FLAG_WWDGRST: Window Watchdog reset\r
1299   *     @arg RCC_FLAG_LPWRRST: Low Power reset\r
1300   *   \r
1301   * @retval The new state of RCC_FLAG (SET or RESET).\r
1302   */\r
1303 FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)\r
1304 {\r
1305   uint32_t tmp = 0;\r
1306   uint32_t statusreg = 0;\r
1307   FlagStatus bitstatus = RESET;\r
1308   /* Check the parameters */\r
1309   assert_param(IS_RCC_FLAG(RCC_FLAG));\r
1310 \r
1311   /* Get the RCC register index */\r
1312   tmp = RCC_FLAG >> 5;\r
1313   if (tmp == 1)               /* The flag to check is in CR register */\r
1314   {\r
1315     statusreg = RCC->CR;\r
1316   }\r
1317   else if (tmp == 2)          /* The flag to check is in BDCR register */\r
1318   {\r
1319     statusreg = RCC->BDCR;\r
1320   }\r
1321   else                       /* The flag to check is in CSR register */\r
1322   {\r
1323     statusreg = RCC->CSR;\r
1324   }\r
1325 \r
1326   /* Get the flag position */\r
1327   tmp = RCC_FLAG & FLAG_Mask;\r
1328   if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)\r
1329   {\r
1330     bitstatus = SET;\r
1331   }\r
1332   else\r
1333   {\r
1334     bitstatus = RESET;\r
1335   }\r
1336 \r
1337   /* Return the flag status */\r
1338   return bitstatus;\r
1339 }\r
1340 \r
1341 /**\r
1342   * @brief  Clears the RCC reset flags.\r
1343   * @note   The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST,\r
1344   *   RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST\r
1345   * @param  None\r
1346   * @retval None\r
1347   */\r
1348 void RCC_ClearFlag(void)\r
1349 {\r
1350   /* Set RMVF bit to clear the reset flags */\r
1351   RCC->CSR |= CSR_RMVF_Set;\r
1352 }\r
1353 \r
1354 /**\r
1355   * @brief  Checks whether the specified RCC interrupt has occurred or not.\r
1356   * @param  RCC_IT: specifies the RCC interrupt source to check.\r
1357   *   \r
1358   *   For @b STM32_Connectivity_line_devices, this parameter can be one of the\r
1359   *   following values:\r
1360   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1361   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
1362   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1363   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
1364   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
1365   *     @arg RCC_IT_PLL2RDY: PLL2 ready interrupt \r
1366   *     @arg RCC_IT_PLL3RDY: PLL3 ready interrupt                      \r
1367   *     @arg RCC_IT_CSS: Clock Security System interrupt\r
1368   * \r
1369   *   For @b other_STM32_devices, this parameter can be one of the following values:        \r
1370   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1371   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
1372   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1373   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
1374   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
1375   *     @arg RCC_IT_CSS: Clock Security System interrupt\r
1376   *   \r
1377   * @retval The new state of RCC_IT (SET or RESET).\r
1378   */\r
1379 ITStatus RCC_GetITStatus(uint8_t RCC_IT)\r
1380 {\r
1381   ITStatus bitstatus = RESET;\r
1382   /* Check the parameters */\r
1383   assert_param(IS_RCC_GET_IT(RCC_IT));\r
1384 \r
1385   /* Check the status of the specified RCC interrupt */\r
1386   if ((RCC->CIR & RCC_IT) != (uint32_t)RESET)\r
1387   {\r
1388     bitstatus = SET;\r
1389   }\r
1390   else\r
1391   {\r
1392     bitstatus = RESET;\r
1393   }\r
1394 \r
1395   /* Return the RCC_IT status */\r
1396   return  bitstatus;\r
1397 }\r
1398 \r
1399 /**\r
1400   * @brief  Clears the RCC\92s interrupt pending bits.\r
1401   * @param  RCC_IT: specifies the interrupt pending bit to clear.\r
1402   *   \r
1403   *   For @b STM32_Connectivity_line_devices, this parameter can be any combination\r
1404   *   of the following values:\r
1405   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1406   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
1407   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1408   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
1409   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
1410   *     @arg RCC_IT_PLL2RDY: PLL2 ready interrupt \r
1411   *     @arg RCC_IT_PLL3RDY: PLL3 ready interrupt                      \r
1412   *     @arg RCC_IT_CSS: Clock Security System interrupt\r
1413   * \r
1414   *   For @b other_STM32_devices, this parameter can be any combination of the\r
1415   *   following values:        \r
1416   *     @arg RCC_IT_LSIRDY: LSI ready interrupt\r
1417   *     @arg RCC_IT_LSERDY: LSE ready interrupt\r
1418   *     @arg RCC_IT_HSIRDY: HSI ready interrupt\r
1419   *     @arg RCC_IT_HSERDY: HSE ready interrupt\r
1420   *     @arg RCC_IT_PLLRDY: PLL ready interrupt\r
1421   *   \r
1422   *     @arg RCC_IT_CSS: Clock Security System interrupt\r
1423   * @retval None\r
1424   */\r
1425 void RCC_ClearITPendingBit(uint8_t RCC_IT)\r
1426 {\r
1427   /* Check the parameters */\r
1428   assert_param(IS_RCC_CLEAR_IT(RCC_IT));\r
1429 \r
1430   /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt\r
1431      pending bits */\r
1432   *(__IO uint8_t *) CIR_BYTE3_ADDRESS = RCC_IT;\r
1433 }\r
1434 \r
1435 /**\r
1436   * @}\r
1437   */\r
1438 \r
1439 /**\r
1440   * @}\r
1441   */\r
1442 \r
1443 /**\r
1444   * @}\r
1445   */\r
1446 \r
1447 /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/\r