stm32f4xx_rcc.h 24 KB

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