stm32f4xx_rcc.h 24 KB

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