stm32f2xx_rcc.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  1. /**
  2. ******************************************************************************
  3. * @file stm32f2xx_rcc.h
  4. * @author MCD Application Team
  5. * @version V1.1.3
  6. * @date 31-December-2021
  7. * @brief This file contains all the functions prototypes for the RCC firmware library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * Copyright (c) 2012 STMicroelectronics.
  12. * All rights reserved.
  13. *
  14. * This software is licensed under terms that can be found in the LICENSE file
  15. * in the root directory of this software component.
  16. * If no LICENSE file comes with this software, it is provided AS-IS.
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef __STM32F2xx_RCC_H
  22. #define __STM32F2xx_RCC_H
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "stm32f2xx.h"
  28. /** @addtogroup STM32F2xx_StdPeriph_Driver
  29. * @{
  30. */
  31. /** @addtogroup RCC
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. typedef struct
  36. {
  37. uint32_t SYSCLK_Frequency; /*!< SYSCLK clock frequency expressed in Hz */
  38. uint32_t HCLK_Frequency; /*!< HCLK clock frequency expressed in Hz */
  39. uint32_t PCLK1_Frequency; /*!< PCLK1 clock frequency expressed in Hz */
  40. uint32_t PCLK2_Frequency; /*!< PCLK2 clock frequency expressed in Hz */
  41. }RCC_ClocksTypeDef;
  42. /* Exported constants --------------------------------------------------------*/
  43. /** @defgroup RCC_Exported_Constants
  44. * @{
  45. */
  46. /** @defgroup RCC_HSE_configuration
  47. * @{
  48. */
  49. #define RCC_HSE_OFF ((uint8_t)0x00)
  50. #define RCC_HSE_ON ((uint8_t)0x01)
  51. #define RCC_HSE_Bypass ((uint8_t)0x05)
  52. #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
  53. ((HSE) == RCC_HSE_Bypass))
  54. /**
  55. * @}
  56. */
  57. /** @defgroup RCC_PLL_Clock_Source
  58. * @{
  59. */
  60. #define RCC_PLLSource_HSI ((uint32_t)0x00000000)
  61. #define RCC_PLLSource_HSE ((uint32_t)0x00400000)
  62. #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI) || \
  63. ((SOURCE) == RCC_PLLSource_HSE))
  64. #define IS_RCC_PLLM_VALUE(VALUE) ((VALUE) <= 63)
  65. #define IS_RCC_PLLN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  66. #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == 2) || ((VALUE) == 4) || ((VALUE) == 6) || ((VALUE) == 8))
  67. #define IS_RCC_PLLQ_VALUE(VALUE) ((4 <= (VALUE)) && ((VALUE) <= 15))
  68. #define IS_RCC_PLLI2SN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  69. #define IS_RCC_PLLI2SR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  70. /**
  71. * @}
  72. */
  73. /** @defgroup RCC_System_Clock_Source
  74. * @{
  75. */
  76. #define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000)
  77. #define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001)
  78. #define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002)
  79. #define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \
  80. ((SOURCE) == RCC_SYSCLKSource_HSE) || \
  81. ((SOURCE) == RCC_SYSCLKSource_PLLCLK))
  82. /**
  83. * @}
  84. */
  85. /** @defgroup RCC_AHB_Clock_Source
  86. * @{
  87. */
  88. #define RCC_SYSCLK_Div1 ((uint32_t)0x00000000)
  89. #define RCC_SYSCLK_Div2 ((uint32_t)0x00000080)
  90. #define RCC_SYSCLK_Div4 ((uint32_t)0x00000090)
  91. #define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0)
  92. #define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0)
  93. #define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0)
  94. #define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0)
  95. #define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0)
  96. #define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0)
  97. #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \
  98. ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \
  99. ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \
  100. ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \
  101. ((HCLK) == RCC_SYSCLK_Div512))
  102. /**
  103. * @}
  104. */
  105. /** @defgroup RCC_APB1_APB2_Clock_Source
  106. * @{
  107. */
  108. #define RCC_HCLK_Div1 ((uint32_t)0x00000000)
  109. #define RCC_HCLK_Div2 ((uint32_t)0x00001000)
  110. #define RCC_HCLK_Div4 ((uint32_t)0x00001400)
  111. #define RCC_HCLK_Div8 ((uint32_t)0x00001800)
  112. #define RCC_HCLK_Div16 ((uint32_t)0x00001C00)
  113. #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \
  114. ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \
  115. ((PCLK) == RCC_HCLK_Div16))
  116. /**
  117. * @}
  118. */
  119. /** @defgroup RCC_Interrupt_Source
  120. * @{
  121. */
  122. #define RCC_IT_LSIRDY ((uint8_t)0x01)
  123. #define RCC_IT_LSERDY ((uint8_t)0x02)
  124. #define RCC_IT_HSIRDY ((uint8_t)0x04)
  125. #define RCC_IT_HSERDY ((uint8_t)0x08)
  126. #define RCC_IT_PLLRDY ((uint8_t)0x10)
  127. #define RCC_IT_PLLI2SRDY ((uint8_t)0x20)
  128. #define RCC_IT_CSS ((uint8_t)0x80)
  129. #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0xC0) == 0x00) && ((IT) != 0x00))
  130. #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \
  131. ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \
  132. ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS) || \
  133. ((IT) == RCC_IT_PLLI2SRDY))
  134. #define IS_RCC_CLEAR_IT(IT) ((((IT) & (uint8_t)0x40) == 0x00) && ((IT) != 0x00))
  135. /**
  136. * @}
  137. */
  138. /** @defgroup RCC_LSE_Configuration
  139. * @{
  140. */
  141. #define RCC_LSE_OFF ((uint8_t)0x00)
  142. #define RCC_LSE_ON ((uint8_t)0x01)
  143. #define RCC_LSE_Bypass ((uint8_t)0x04)
  144. #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
  145. ((LSE) == RCC_LSE_Bypass))
  146. /**
  147. * @}
  148. */
  149. /** @defgroup RCC_RTC_Clock_Source
  150. * @{
  151. */
  152. #define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100)
  153. #define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200)
  154. #define RCC_RTCCLKSource_HSE_Div2 ((uint32_t)0x00020300)
  155. #define RCC_RTCCLKSource_HSE_Div3 ((uint32_t)0x00030300)
  156. #define RCC_RTCCLKSource_HSE_Div4 ((uint32_t)0x00040300)
  157. #define RCC_RTCCLKSource_HSE_Div5 ((uint32_t)0x00050300)
  158. #define RCC_RTCCLKSource_HSE_Div6 ((uint32_t)0x00060300)
  159. #define RCC_RTCCLKSource_HSE_Div7 ((uint32_t)0x00070300)
  160. #define RCC_RTCCLKSource_HSE_Div8 ((uint32_t)0x00080300)
  161. #define RCC_RTCCLKSource_HSE_Div9 ((uint32_t)0x00090300)
  162. #define RCC_RTCCLKSource_HSE_Div10 ((uint32_t)0x000A0300)
  163. #define RCC_RTCCLKSource_HSE_Div11 ((uint32_t)0x000B0300)
  164. #define RCC_RTCCLKSource_HSE_Div12 ((uint32_t)0x000C0300)
  165. #define RCC_RTCCLKSource_HSE_Div13 ((uint32_t)0x000D0300)
  166. #define RCC_RTCCLKSource_HSE_Div14 ((uint32_t)0x000E0300)
  167. #define RCC_RTCCLKSource_HSE_Div15 ((uint32_t)0x000F0300)
  168. #define RCC_RTCCLKSource_HSE_Div16 ((uint32_t)0x00100300)
  169. #define RCC_RTCCLKSource_HSE_Div17 ((uint32_t)0x00110300)
  170. #define RCC_RTCCLKSource_HSE_Div18 ((uint32_t)0x00120300)
  171. #define RCC_RTCCLKSource_HSE_Div19 ((uint32_t)0x00130300)
  172. #define RCC_RTCCLKSource_HSE_Div20 ((uint32_t)0x00140300)
  173. #define RCC_RTCCLKSource_HSE_Div21 ((uint32_t)0x00150300)
  174. #define RCC_RTCCLKSource_HSE_Div22 ((uint32_t)0x00160300)
  175. #define RCC_RTCCLKSource_HSE_Div23 ((uint32_t)0x00170300)
  176. #define RCC_RTCCLKSource_HSE_Div24 ((uint32_t)0x00180300)
  177. #define RCC_RTCCLKSource_HSE_Div25 ((uint32_t)0x00190300)
  178. #define RCC_RTCCLKSource_HSE_Div26 ((uint32_t)0x001A0300)
  179. #define RCC_RTCCLKSource_HSE_Div27 ((uint32_t)0x001B0300)
  180. #define RCC_RTCCLKSource_HSE_Div28 ((uint32_t)0x001C0300)
  181. #define RCC_RTCCLKSource_HSE_Div29 ((uint32_t)0x001D0300)
  182. #define RCC_RTCCLKSource_HSE_Div30 ((uint32_t)0x001E0300)
  183. #define RCC_RTCCLKSource_HSE_Div31 ((uint32_t)0x001F0300)
  184. #define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \
  185. ((SOURCE) == RCC_RTCCLKSource_LSI) || \
  186. ((SOURCE) == RCC_RTCCLKSource_HSE_Div2) || \
  187. ((SOURCE) == RCC_RTCCLKSource_HSE_Div3) || \
  188. ((SOURCE) == RCC_RTCCLKSource_HSE_Div4) || \
  189. ((SOURCE) == RCC_RTCCLKSource_HSE_Div5) || \
  190. ((SOURCE) == RCC_RTCCLKSource_HSE_Div6) || \
  191. ((SOURCE) == RCC_RTCCLKSource_HSE_Div7) || \
  192. ((SOURCE) == RCC_RTCCLKSource_HSE_Div8) || \
  193. ((SOURCE) == RCC_RTCCLKSource_HSE_Div9) || \
  194. ((SOURCE) == RCC_RTCCLKSource_HSE_Div10) || \
  195. ((SOURCE) == RCC_RTCCLKSource_HSE_Div11) || \
  196. ((SOURCE) == RCC_RTCCLKSource_HSE_Div12) || \
  197. ((SOURCE) == RCC_RTCCLKSource_HSE_Div13) || \
  198. ((SOURCE) == RCC_RTCCLKSource_HSE_Div14) || \
  199. ((SOURCE) == RCC_RTCCLKSource_HSE_Div15) || \
  200. ((SOURCE) == RCC_RTCCLKSource_HSE_Div16) || \
  201. ((SOURCE) == RCC_RTCCLKSource_HSE_Div17) || \
  202. ((SOURCE) == RCC_RTCCLKSource_HSE_Div18) || \
  203. ((SOURCE) == RCC_RTCCLKSource_HSE_Div19) || \
  204. ((SOURCE) == RCC_RTCCLKSource_HSE_Div20) || \
  205. ((SOURCE) == RCC_RTCCLKSource_HSE_Div21) || \
  206. ((SOURCE) == RCC_RTCCLKSource_HSE_Div22) || \
  207. ((SOURCE) == RCC_RTCCLKSource_HSE_Div23) || \
  208. ((SOURCE) == RCC_RTCCLKSource_HSE_Div24) || \
  209. ((SOURCE) == RCC_RTCCLKSource_HSE_Div25) || \
  210. ((SOURCE) == RCC_RTCCLKSource_HSE_Div26) || \
  211. ((SOURCE) == RCC_RTCCLKSource_HSE_Div27) || \
  212. ((SOURCE) == RCC_RTCCLKSource_HSE_Div28) || \
  213. ((SOURCE) == RCC_RTCCLKSource_HSE_Div29) || \
  214. ((SOURCE) == RCC_RTCCLKSource_HSE_Div30) || \
  215. ((SOURCE) == RCC_RTCCLKSource_HSE_Div31))
  216. /**
  217. * @}
  218. */
  219. /** @defgroup RCC_I2S_Clock_Source
  220. * @{
  221. */
  222. #define RCC_I2S2CLKSource_PLLI2S ((uint8_t)0x00)
  223. #define RCC_I2S2CLKSource_Ext ((uint8_t)0x01)
  224. #define IS_RCC_I2SCLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S2CLKSource_PLLI2S) || ((SOURCE) == RCC_I2S2CLKSource_Ext))
  225. /**
  226. * @}
  227. */
  228. /** @defgroup RCC_AHB1_Peripherals
  229. * @{
  230. */
  231. #define RCC_AHB1Periph_GPIOA ((uint32_t)0x00000001)
  232. #define RCC_AHB1Periph_GPIOB ((uint32_t)0x00000002)
  233. #define RCC_AHB1Periph_GPIOC ((uint32_t)0x00000004)
  234. #define RCC_AHB1Periph_GPIOD ((uint32_t)0x00000008)
  235. #define RCC_AHB1Periph_GPIOE ((uint32_t)0x00000010)
  236. #define RCC_AHB1Periph_GPIOF ((uint32_t)0x00000020)
  237. #define RCC_AHB1Periph_GPIOG ((uint32_t)0x00000040)
  238. #define RCC_AHB1Periph_GPIOH ((uint32_t)0x00000080)
  239. #define RCC_AHB1Periph_GPIOI ((uint32_t)0x00000100)
  240. #define RCC_AHB1Periph_CRC ((uint32_t)0x00001000)
  241. #define RCC_AHB1Periph_FLITF ((uint32_t)0x00008000)
  242. #define RCC_AHB1Periph_SRAM1 ((uint32_t)0x00010000)
  243. #define RCC_AHB1Periph_SRAM2 ((uint32_t)0x00020000)
  244. #define RCC_AHB1Periph_BKPSRAM ((uint32_t)0x00040000)
  245. #define RCC_AHB1Periph_DMA1 ((uint32_t)0x00200000)
  246. #define RCC_AHB1Periph_DMA2 ((uint32_t)0x00400000)
  247. #define RCC_AHB1Periph_ETH_MAC ((uint32_t)0x02000000)
  248. #define RCC_AHB1Periph_ETH_MAC_Tx ((uint32_t)0x04000000)
  249. #define RCC_AHB1Periph_ETH_MAC_Rx ((uint32_t)0x08000000)
  250. #define RCC_AHB1Periph_ETH_MAC_PTP ((uint32_t)0x10000000)
  251. #define RCC_AHB1Periph_OTG_HS ((uint32_t)0x20000000)
  252. #define RCC_AHB1Periph_OTG_HS_ULPI ((uint32_t)0x40000000)
  253. #define IS_RCC_AHB1_CLOCK_PERIPH(PERIPH) ((((PERIPH) & 0x819BEE00) == 0x00) && ((PERIPH) != 0x00))
  254. #define IS_RCC_AHB1_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xDD9FEE00) == 0x00) && ((PERIPH) != 0x00))
  255. #define IS_RCC_AHB1_LPMODE_PERIPH(PERIPH) ((((PERIPH) & 0x81986E00) == 0x00) && ((PERIPH) != 0x00))
  256. /**
  257. * @}
  258. */
  259. /** @defgroup RCC_AHB2_Peripherals
  260. * @{
  261. */
  262. #define RCC_AHB2Periph_DCMI ((uint32_t)0x00000001)
  263. #define RCC_AHB2Periph_CRYP ((uint32_t)0x00000010)
  264. #define RCC_AHB2Periph_HASH ((uint32_t)0x00000020)
  265. #define RCC_AHB2Periph_RNG ((uint32_t)0x00000040)
  266. #define RCC_AHB2Periph_OTG_FS ((uint32_t)0x00000080)
  267. #define IS_RCC_AHB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFF0E) == 0x00) && ((PERIPH) != 0x00))
  268. /**
  269. * @}
  270. */
  271. /** @defgroup RCC_AHB3_Peripherals
  272. * @{
  273. */
  274. #define RCC_AHB3Periph_FSMC ((uint32_t)0x00000001)
  275. #define IS_RCC_AHB3_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFFE) == 0x00) && ((PERIPH) != 0x00))
  276. /**
  277. * @}
  278. */
  279. /** @defgroup RCC_APB1_Peripherals
  280. * @{
  281. */
  282. #define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
  283. #define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002)
  284. #define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004)
  285. #define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008)
  286. #define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010)
  287. #define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020)
  288. #define RCC_APB1Periph_TIM12 ((uint32_t)0x00000040)
  289. #define RCC_APB1Periph_TIM13 ((uint32_t)0x00000080)
  290. #define RCC_APB1Periph_TIM14 ((uint32_t)0x00000100)
  291. #define RCC_APB1Periph_WWDG ((uint32_t)0x00000800)
  292. #define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000)
  293. #define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000)
  294. #define RCC_APB1Periph_USART2 ((uint32_t)0x00020000)
  295. #define RCC_APB1Periph_USART3 ((uint32_t)0x00040000)
  296. #define RCC_APB1Periph_UART4 ((uint32_t)0x00080000)
  297. #define RCC_APB1Periph_UART5 ((uint32_t)0x00100000)
  298. #define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000)
  299. #define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000)
  300. #define RCC_APB1Periph_I2C3 ((uint32_t)0x00800000)
  301. #define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000)
  302. #define RCC_APB1Periph_CAN2 ((uint32_t)0x04000000)
  303. #define RCC_APB1Periph_PWR ((uint32_t)0x10000000)
  304. #define RCC_APB1Periph_DAC ((uint32_t)0x20000000)
  305. #define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0xC9013600) == 0x00) && ((PERIPH) != 0x00))
  306. /**
  307. * @}
  308. */
  309. /** @defgroup RCC_APB2_Peripherals
  310. * @{
  311. */
  312. #define RCC_APB2Periph_TIM1 ((uint32_t)0x00000001)
  313. #define RCC_APB2Periph_TIM8 ((uint32_t)0x00000002)
  314. #define RCC_APB2Periph_USART1 ((uint32_t)0x00000010)
  315. #define RCC_APB2Periph_USART6 ((uint32_t)0x00000020)
  316. #define RCC_APB2Periph_ADC ((uint32_t)0x00000100)
  317. #define RCC_APB2Periph_ADC1 ((uint32_t)0x00000100)
  318. #define RCC_APB2Periph_ADC2 ((uint32_t)0x00000200)
  319. #define RCC_APB2Periph_ADC3 ((uint32_t)0x00000400)
  320. #define RCC_APB2Periph_SDIO ((uint32_t)0x00000800)
  321. #define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000)
  322. #define RCC_APB2Periph_SYSCFG ((uint32_t)0x00004000)
  323. #define RCC_APB2Periph_TIM9 ((uint32_t)0x00010000)
  324. #define RCC_APB2Periph_TIM10 ((uint32_t)0x00020000)
  325. #define RCC_APB2Periph_TIM11 ((uint32_t)0x00040000)
  326. #define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFF8A0CC) == 0x00) && ((PERIPH) != 0x00))
  327. #define IS_RCC_APB2_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xFFF8A6CC) == 0x00) && ((PERIPH) != 0x00))
  328. /**
  329. * @}
  330. */
  331. /** @defgroup RCC_MCO1_Clock_Source_Prescaler
  332. * @{
  333. */
  334. #define RCC_MCO1Source_HSI ((uint32_t)0x00000000)
  335. #define RCC_MCO1Source_LSE ((uint32_t)0x00200000)
  336. #define RCC_MCO1Source_HSE ((uint32_t)0x00400000)
  337. #define RCC_MCO1Source_PLLCLK ((uint32_t)0x00600000)
  338. #define RCC_MCO1Div_1 ((uint32_t)0x00000000)
  339. #define RCC_MCO1Div_2 ((uint32_t)0x04000000)
  340. #define RCC_MCO1Div_3 ((uint32_t)0x05000000)
  341. #define RCC_MCO1Div_4 ((uint32_t)0x06000000)
  342. #define RCC_MCO1Div_5 ((uint32_t)0x07000000)
  343. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1Source_HSI) || ((SOURCE) == RCC_MCO1Source_LSE) || \
  344. ((SOURCE) == RCC_MCO1Source_HSE) || ((SOURCE) == RCC_MCO1Source_PLLCLK))
  345. #define IS_RCC_MCO1DIV(DIV) (((DIV) == RCC_MCO1Div_1) || ((DIV) == RCC_MCO1Div_2) || \
  346. ((DIV) == RCC_MCO1Div_3) || ((DIV) == RCC_MCO1Div_4) || \
  347. ((DIV) == RCC_MCO1Div_5))
  348. /**
  349. * @}
  350. */
  351. /** @defgroup RCC_MCO2_Clock_Source_Prescaler
  352. * @{
  353. */
  354. #define RCC_MCO2Source_SYSCLK ((uint32_t)0x00000000)
  355. #define RCC_MCO2Source_PLLI2SCLK ((uint32_t)0x40000000)
  356. #define RCC_MCO2Source_HSE ((uint32_t)0x80000000)
  357. #define RCC_MCO2Source_PLLCLK ((uint32_t)0xC0000000)
  358. #define RCC_MCO2Div_1 ((uint32_t)0x00000000)
  359. #define RCC_MCO2Div_2 ((uint32_t)0x20000000)
  360. #define RCC_MCO2Div_3 ((uint32_t)0x28000000)
  361. #define RCC_MCO2Div_4 ((uint32_t)0x30000000)
  362. #define RCC_MCO2Div_5 ((uint32_t)0x38000000)
  363. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2Source_SYSCLK) || ((SOURCE) == RCC_MCO2Source_PLLI2SCLK)|| \
  364. ((SOURCE) == RCC_MCO2Source_HSE) || ((SOURCE) == RCC_MCO2Source_PLLCLK))
  365. #define IS_RCC_MCO2DIV(DIV) (((DIV) == RCC_MCO2Div_1) || ((DIV) == RCC_MCO2Div_2) || \
  366. ((DIV) == RCC_MCO2Div_3) || ((DIV) == RCC_MCO2Div_4) || \
  367. ((DIV) == RCC_MCO2Div_5))
  368. /**
  369. * @}
  370. */
  371. /** @defgroup RCC_Flag
  372. * @{
  373. */
  374. #define RCC_FLAG_HSIRDY ((uint8_t)0x21)
  375. #define RCC_FLAG_HSERDY ((uint8_t)0x31)
  376. #define RCC_FLAG_PLLRDY ((uint8_t)0x39)
  377. #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3B)
  378. #define RCC_FLAG_LSERDY ((uint8_t)0x41)
  379. #define RCC_FLAG_LSIRDY ((uint8_t)0x61)
  380. #define RCC_FLAG_BORRST ((uint8_t)0x79)
  381. #define RCC_FLAG_PINRST ((uint8_t)0x7A)
  382. #define RCC_FLAG_PORRST ((uint8_t)0x7B)
  383. #define RCC_FLAG_SFTRST ((uint8_t)0x7C)
  384. #define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
  385. #define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
  386. #define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
  387. #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \
  388. ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \
  389. ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_BORRST) || \
  390. ((FLAG) == RCC_FLAG_PINRST) || ((FLAG) == RCC_FLAG_PORRST) || \
  391. ((FLAG) == RCC_FLAG_SFTRST) || ((FLAG) == RCC_FLAG_IWDGRST)|| \
  392. ((FLAG) == RCC_FLAG_WWDGRST)|| ((FLAG) == RCC_FLAG_LPWRRST)|| \
  393. ((FLAG) == RCC_FLAG_PLLI2SRDY))
  394. #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
  395. /**
  396. * @}
  397. */
  398. /**
  399. * @}
  400. */
  401. /* Exported macro ------------------------------------------------------------*/
  402. /* Exported functions --------------------------------------------------------*/
  403. /* Function used to set the RCC clock configuration to the default reset state */
  404. void RCC_DeInit(void);
  405. /* Internal/external clocks, PLL, CSS and MCO configuration functions *********/
  406. void RCC_HSEConfig(uint8_t RCC_HSE);
  407. ErrorStatus RCC_WaitForHSEStartUp(void);
  408. void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue);
  409. void RCC_HSICmd(FunctionalState NewState);
  410. void RCC_LSEConfig(uint8_t RCC_LSE);
  411. void RCC_LSICmd(FunctionalState NewState);
  412. void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ);
  413. void RCC_PLLCmd(FunctionalState NewState);
  414. void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR);
  415. void RCC_PLLI2SCmd(FunctionalState NewState);
  416. void RCC_ClockSecuritySystemCmd(FunctionalState NewState);
  417. void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div);
  418. void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div);
  419. /* System, AHB and APB busses clocks configuration functions ******************/
  420. void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource);
  421. uint8_t RCC_GetSYSCLKSource(void);
  422. void RCC_HCLKConfig(uint32_t RCC_SYSCLK);
  423. void RCC_PCLK1Config(uint32_t RCC_HCLK);
  424. void RCC_PCLK2Config(uint32_t RCC_HCLK);
  425. void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks);
  426. /* Peripheral clocks configuration functions **********************************/
  427. void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource);
  428. void RCC_RTCCLKCmd(FunctionalState NewState);
  429. void RCC_BackupResetCmd(FunctionalState NewState);
  430. void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource);
  431. void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  432. void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  433. void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  434. void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  435. void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  436. void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  437. void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  438. void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  439. void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  440. void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  441. void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  442. void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  443. void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  444. void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  445. void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  446. /* Interrupts and flags management functions **********************************/
  447. void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState);
  448. FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG);
  449. void RCC_ClearFlag(void);
  450. ITStatus RCC_GetITStatus(uint8_t RCC_IT);
  451. void RCC_ClearITPendingBit(uint8_t RCC_IT);
  452. #ifdef __cplusplus
  453. }
  454. #endif
  455. #endif /* __STM32F2xx_RCC_H */
  456. /**
  457. * @}
  458. */
  459. /**
  460. * @}
  461. */