stm32f10x_rcc.c 50 KB

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