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