stm32f4xx_rcc.h 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. /**
  2. ******************************************************************************
  3. * @file stm32f4xx_rcc.h
  4. * @author MCD Application Team
  5. * @version V1.4.0
  6. * @date 04-August-2014
  7. * @brief This file contains all the functions prototypes for the RCC firmware library.
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT 2014 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_LSE_Dual_Mode_Selection
  65. * @{
  66. */
  67. #define RCC_LSE_LOWPOWER_MODE ((uint8_t)0x00)
  68. #define RCC_LSE_HIGHDRIVE_MODE ((uint8_t)0x01)
  69. #define IS_RCC_LSE_MODE(MODE) (((MODE) == RCC_LSE_LOWPOWER_MODE) || \
  70. ((MODE) == RCC_LSE_HIGHDRIVE_MODE))
  71. /**
  72. * @}
  73. */
  74. /** @defgroup RCC_PLL_Clock_Source
  75. * @{
  76. */
  77. #define RCC_PLLSource_HSI ((uint32_t)0x00000000)
  78. #define RCC_PLLSource_HSE ((uint32_t)0x00400000)
  79. #define IS_RCC_PLL_SOURCE(SOURCE) (((SOURCE) == RCC_PLLSource_HSI) || \
  80. ((SOURCE) == RCC_PLLSource_HSE))
  81. #define IS_RCC_PLLM_VALUE(VALUE) ((VALUE) <= 63)
  82. #define IS_RCC_PLLN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  83. #define IS_RCC_PLLP_VALUE(VALUE) (((VALUE) == 2) || ((VALUE) == 4) || ((VALUE) == 6) || ((VALUE) == 8))
  84. #define IS_RCC_PLLQ_VALUE(VALUE) ((4 <= (VALUE)) && ((VALUE) <= 15))
  85. #define IS_RCC_PLLI2SN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  86. #define IS_RCC_PLLI2SR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  87. #define IS_RCC_PLLI2SM_VALUE(VALUE) ((VALUE) <= 63)
  88. #define IS_RCC_PLLI2SQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
  89. #define IS_RCC_PLLSAIN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
  90. #define IS_RCC_PLLSAIQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
  91. #define IS_RCC_PLLSAIR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
  92. #define IS_RCC_PLLSAI_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
  93. #define IS_RCC_PLLI2S_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
  94. #define RCC_PLLSAIDivR_Div2 ((uint32_t)0x00000000)
  95. #define RCC_PLLSAIDivR_Div4 ((uint32_t)0x00010000)
  96. #define RCC_PLLSAIDivR_Div8 ((uint32_t)0x00020000)
  97. #define RCC_PLLSAIDivR_Div16 ((uint32_t)0x00030000)
  98. #define IS_RCC_PLLSAI_DIVR_VALUE(VALUE) (((VALUE) == RCC_PLLSAIDivR_Div2) ||\
  99. ((VALUE) == RCC_PLLSAIDivR_Div4) ||\
  100. ((VALUE) == RCC_PLLSAIDivR_Div8) ||\
  101. ((VALUE) == RCC_PLLSAIDivR_Div16))
  102. /**
  103. * @}
  104. */
  105. /** @defgroup RCC_System_Clock_Source
  106. * @{
  107. */
  108. #define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000)
  109. #define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001)
  110. #define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002)
  111. #define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \
  112. ((SOURCE) == RCC_SYSCLKSource_HSE) || \
  113. ((SOURCE) == RCC_SYSCLKSource_PLLCLK))
  114. /**
  115. * @}
  116. */
  117. /** @defgroup RCC_AHB_Clock_Source
  118. * @{
  119. */
  120. #define RCC_SYSCLK_Div1 ((uint32_t)0x00000000)
  121. #define RCC_SYSCLK_Div2 ((uint32_t)0x00000080)
  122. #define RCC_SYSCLK_Div4 ((uint32_t)0x00000090)
  123. #define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0)
  124. #define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0)
  125. #define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0)
  126. #define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0)
  127. #define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0)
  128. #define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0)
  129. #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \
  130. ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \
  131. ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \
  132. ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \
  133. ((HCLK) == RCC_SYSCLK_Div512))
  134. /**
  135. * @}
  136. */
  137. /** @defgroup RCC_APB1_APB2_Clock_Source
  138. * @{
  139. */
  140. #define RCC_HCLK_Div1 ((uint32_t)0x00000000)
  141. #define RCC_HCLK_Div2 ((uint32_t)0x00001000)
  142. #define RCC_HCLK_Div4 ((uint32_t)0x00001400)
  143. #define RCC_HCLK_Div8 ((uint32_t)0x00001800)
  144. #define RCC_HCLK_Div16 ((uint32_t)0x00001C00)
  145. #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \
  146. ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \
  147. ((PCLK) == RCC_HCLK_Div16))
  148. /**
  149. * @}
  150. */
  151. /** @defgroup RCC_Interrupt_Source
  152. * @{
  153. */
  154. #define RCC_IT_LSIRDY ((uint8_t)0x01)
  155. #define RCC_IT_LSERDY ((uint8_t)0x02)
  156. #define RCC_IT_HSIRDY ((uint8_t)0x04)
  157. #define RCC_IT_HSERDY ((uint8_t)0x08)
  158. #define RCC_IT_PLLRDY ((uint8_t)0x10)
  159. #define RCC_IT_PLLI2SRDY ((uint8_t)0x20)
  160. #define RCC_IT_PLLSAIRDY ((uint8_t)0x40)
  161. #define RCC_IT_CSS ((uint8_t)0x80)
  162. #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0x80) == 0x00) && ((IT) != 0x00))
  163. #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \
  164. ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \
  165. ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS) || \
  166. ((IT) == RCC_IT_PLLSAIRDY) || ((IT) == RCC_IT_PLLI2SRDY))
  167. #define IS_RCC_CLEAR_IT(IT)((IT) != 0x00)
  168. /**
  169. * @}
  170. */
  171. /** @defgroup RCC_LSE_Configuration
  172. * @{
  173. */
  174. #define RCC_LSE_OFF ((uint8_t)0x00)
  175. #define RCC_LSE_ON ((uint8_t)0x01)
  176. #define RCC_LSE_Bypass ((uint8_t)0x04)
  177. #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
  178. ((LSE) == RCC_LSE_Bypass))
  179. /**
  180. * @}
  181. */
  182. /** @defgroup RCC_RTC_Clock_Source
  183. * @{
  184. */
  185. #define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100)
  186. #define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200)
  187. #define RCC_RTCCLKSource_HSE_Div2 ((uint32_t)0x00020300)
  188. #define RCC_RTCCLKSource_HSE_Div3 ((uint32_t)0x00030300)
  189. #define RCC_RTCCLKSource_HSE_Div4 ((uint32_t)0x00040300)
  190. #define RCC_RTCCLKSource_HSE_Div5 ((uint32_t)0x00050300)
  191. #define RCC_RTCCLKSource_HSE_Div6 ((uint32_t)0x00060300)
  192. #define RCC_RTCCLKSource_HSE_Div7 ((uint32_t)0x00070300)
  193. #define RCC_RTCCLKSource_HSE_Div8 ((uint32_t)0x00080300)
  194. #define RCC_RTCCLKSource_HSE_Div9 ((uint32_t)0x00090300)
  195. #define RCC_RTCCLKSource_HSE_Div10 ((uint32_t)0x000A0300)
  196. #define RCC_RTCCLKSource_HSE_Div11 ((uint32_t)0x000B0300)
  197. #define RCC_RTCCLKSource_HSE_Div12 ((uint32_t)0x000C0300)
  198. #define RCC_RTCCLKSource_HSE_Div13 ((uint32_t)0x000D0300)
  199. #define RCC_RTCCLKSource_HSE_Div14 ((uint32_t)0x000E0300)
  200. #define RCC_RTCCLKSource_HSE_Div15 ((uint32_t)0x000F0300)
  201. #define RCC_RTCCLKSource_HSE_Div16 ((uint32_t)0x00100300)
  202. #define RCC_RTCCLKSource_HSE_Div17 ((uint32_t)0x00110300)
  203. #define RCC_RTCCLKSource_HSE_Div18 ((uint32_t)0x00120300)
  204. #define RCC_RTCCLKSource_HSE_Div19 ((uint32_t)0x00130300)
  205. #define RCC_RTCCLKSource_HSE_Div20 ((uint32_t)0x00140300)
  206. #define RCC_RTCCLKSource_HSE_Div21 ((uint32_t)0x00150300)
  207. #define RCC_RTCCLKSource_HSE_Div22 ((uint32_t)0x00160300)
  208. #define RCC_RTCCLKSource_HSE_Div23 ((uint32_t)0x00170300)
  209. #define RCC_RTCCLKSource_HSE_Div24 ((uint32_t)0x00180300)
  210. #define RCC_RTCCLKSource_HSE_Div25 ((uint32_t)0x00190300)
  211. #define RCC_RTCCLKSource_HSE_Div26 ((uint32_t)0x001A0300)
  212. #define RCC_RTCCLKSource_HSE_Div27 ((uint32_t)0x001B0300)
  213. #define RCC_RTCCLKSource_HSE_Div28 ((uint32_t)0x001C0300)
  214. #define RCC_RTCCLKSource_HSE_Div29 ((uint32_t)0x001D0300)
  215. #define RCC_RTCCLKSource_HSE_Div30 ((uint32_t)0x001E0300)
  216. #define RCC_RTCCLKSource_HSE_Div31 ((uint32_t)0x001F0300)
  217. #define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \
  218. ((SOURCE) == RCC_RTCCLKSource_LSI) || \
  219. ((SOURCE) == RCC_RTCCLKSource_HSE_Div2) || \
  220. ((SOURCE) == RCC_RTCCLKSource_HSE_Div3) || \
  221. ((SOURCE) == RCC_RTCCLKSource_HSE_Div4) || \
  222. ((SOURCE) == RCC_RTCCLKSource_HSE_Div5) || \
  223. ((SOURCE) == RCC_RTCCLKSource_HSE_Div6) || \
  224. ((SOURCE) == RCC_RTCCLKSource_HSE_Div7) || \
  225. ((SOURCE) == RCC_RTCCLKSource_HSE_Div8) || \
  226. ((SOURCE) == RCC_RTCCLKSource_HSE_Div9) || \
  227. ((SOURCE) == RCC_RTCCLKSource_HSE_Div10) || \
  228. ((SOURCE) == RCC_RTCCLKSource_HSE_Div11) || \
  229. ((SOURCE) == RCC_RTCCLKSource_HSE_Div12) || \
  230. ((SOURCE) == RCC_RTCCLKSource_HSE_Div13) || \
  231. ((SOURCE) == RCC_RTCCLKSource_HSE_Div14) || \
  232. ((SOURCE) == RCC_RTCCLKSource_HSE_Div15) || \
  233. ((SOURCE) == RCC_RTCCLKSource_HSE_Div16) || \
  234. ((SOURCE) == RCC_RTCCLKSource_HSE_Div17) || \
  235. ((SOURCE) == RCC_RTCCLKSource_HSE_Div18) || \
  236. ((SOURCE) == RCC_RTCCLKSource_HSE_Div19) || \
  237. ((SOURCE) == RCC_RTCCLKSource_HSE_Div20) || \
  238. ((SOURCE) == RCC_RTCCLKSource_HSE_Div21) || \
  239. ((SOURCE) == RCC_RTCCLKSource_HSE_Div22) || \
  240. ((SOURCE) == RCC_RTCCLKSource_HSE_Div23) || \
  241. ((SOURCE) == RCC_RTCCLKSource_HSE_Div24) || \
  242. ((SOURCE) == RCC_RTCCLKSource_HSE_Div25) || \
  243. ((SOURCE) == RCC_RTCCLKSource_HSE_Div26) || \
  244. ((SOURCE) == RCC_RTCCLKSource_HSE_Div27) || \
  245. ((SOURCE) == RCC_RTCCLKSource_HSE_Div28) || \
  246. ((SOURCE) == RCC_RTCCLKSource_HSE_Div29) || \
  247. ((SOURCE) == RCC_RTCCLKSource_HSE_Div30) || \
  248. ((SOURCE) == RCC_RTCCLKSource_HSE_Div31))
  249. /**
  250. * @}
  251. */
  252. /** @defgroup RCC_I2S_Clock_Source
  253. * @{
  254. */
  255. #define RCC_I2S2CLKSource_PLLI2S ((uint8_t)0x00)
  256. #define RCC_I2S2CLKSource_Ext ((uint8_t)0x01)
  257. #define IS_RCC_I2SCLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S2CLKSource_PLLI2S) || ((SOURCE) == RCC_I2S2CLKSource_Ext))
  258. /**
  259. * @}
  260. */
  261. /** @defgroup RCC_SAI_BlockA_Clock_Source
  262. * @{
  263. */
  264. #define RCC_SAIACLKSource_PLLSAI ((uint32_t)0x00000000)
  265. #define RCC_SAIACLKSource_PLLI2S ((uint32_t)0x00100000)
  266. #define RCC_SAIACLKSource_Ext ((uint32_t)0x00200000)
  267. #define IS_RCC_SAIACLK_SOURCE(SOURCE) (((SOURCE) == RCC_SAIACLKSource_PLLI2S) ||\
  268. ((SOURCE) == RCC_SAIACLKSource_PLLSAI) ||\
  269. ((SOURCE) == RCC_SAIACLKSource_Ext))
  270. /**
  271. * @}
  272. */
  273. /** @defgroup RCC_SAI_BlockB_Clock_Source
  274. * @{
  275. */
  276. #define RCC_SAIBCLKSource_PLLSAI ((uint32_t)0x00000000)
  277. #define RCC_SAIBCLKSource_PLLI2S ((uint32_t)0x00400000)
  278. #define RCC_SAIBCLKSource_Ext ((uint32_t)0x00800000)
  279. #define IS_RCC_SAIBCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SAIBCLKSource_PLLI2S) ||\
  280. ((SOURCE) == RCC_SAIBCLKSource_PLLSAI) ||\
  281. ((SOURCE) == RCC_SAIBCLKSource_Ext))
  282. /**
  283. * @}
  284. */
  285. /** @defgroup RCC_TIM_PRescaler_Selection
  286. * @{
  287. */
  288. #define RCC_TIMPrescDesactivated ((uint8_t)0x00)
  289. #define RCC_TIMPrescActivated ((uint8_t)0x01)
  290. #define IS_RCC_TIMCLK_PRESCALER(VALUE) (((VALUE) == RCC_TIMPrescDesactivated) || ((VALUE) == RCC_TIMPrescActivated))
  291. /**
  292. * @}
  293. */
  294. /** @defgroup RCC_AHB1_Peripherals
  295. * @{
  296. */
  297. #define RCC_AHB1Periph_GPIOA ((uint32_t)0x00000001)
  298. #define RCC_AHB1Periph_GPIOB ((uint32_t)0x00000002)
  299. #define RCC_AHB1Periph_GPIOC ((uint32_t)0x00000004)
  300. #define RCC_AHB1Periph_GPIOD ((uint32_t)0x00000008)
  301. #define RCC_AHB1Periph_GPIOE ((uint32_t)0x00000010)
  302. #define RCC_AHB1Periph_GPIOF ((uint32_t)0x00000020)
  303. #define RCC_AHB1Periph_GPIOG ((uint32_t)0x00000040)
  304. #define RCC_AHB1Periph_GPIOH ((uint32_t)0x00000080)
  305. #define RCC_AHB1Periph_GPIOI ((uint32_t)0x00000100)
  306. #define RCC_AHB1Periph_GPIOJ ((uint32_t)0x00000200)
  307. #define RCC_AHB1Periph_GPIOK ((uint32_t)0x00000400)
  308. #define RCC_AHB1Periph_CRC ((uint32_t)0x00001000)
  309. #define RCC_AHB1Periph_FLITF ((uint32_t)0x00008000)
  310. #define RCC_AHB1Periph_SRAM1 ((uint32_t)0x00010000)
  311. #define RCC_AHB1Periph_SRAM2 ((uint32_t)0x00020000)
  312. #define RCC_AHB1Periph_BKPSRAM ((uint32_t)0x00040000)
  313. #define RCC_AHB1Periph_SRAM3 ((uint32_t)0x00080000)
  314. #define RCC_AHB1Periph_CCMDATARAMEN ((uint32_t)0x00100000)
  315. #define RCC_AHB1Periph_DMA1 ((uint32_t)0x00200000)
  316. #define RCC_AHB1Periph_DMA2 ((uint32_t)0x00400000)
  317. #define RCC_AHB1Periph_DMA2D ((uint32_t)0x00800000)
  318. #define RCC_AHB1Periph_ETH_MAC ((uint32_t)0x02000000)
  319. #define RCC_AHB1Periph_ETH_MAC_Tx ((uint32_t)0x04000000)
  320. #define RCC_AHB1Periph_ETH_MAC_Rx ((uint32_t)0x08000000)
  321. #define RCC_AHB1Periph_ETH_MAC_PTP ((uint32_t)0x10000000)
  322. #define RCC_AHB1Periph_OTG_HS ((uint32_t)0x20000000)
  323. #define RCC_AHB1Periph_OTG_HS_ULPI ((uint32_t)0x40000000)
  324. #define IS_RCC_AHB1_CLOCK_PERIPH(PERIPH) ((((PERIPH) & 0x810BE800) == 0x00) && ((PERIPH) != 0x00))
  325. #define IS_RCC_AHB1_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xDD1FE800) == 0x00) && ((PERIPH) != 0x00))
  326. #define IS_RCC_AHB1_LPMODE_PERIPH(PERIPH) ((((PERIPH) & 0x81106800) == 0x00) && ((PERIPH) != 0x00))
  327. /**
  328. * @}
  329. */
  330. /** @defgroup RCC_AHB2_Peripherals
  331. * @{
  332. */
  333. #define RCC_AHB2Periph_DCMI ((uint32_t)0x00000001)
  334. #define RCC_AHB2Periph_CRYP ((uint32_t)0x00000010)
  335. #define RCC_AHB2Periph_HASH ((uint32_t)0x00000020)
  336. #define RCC_AHB2Periph_RNG ((uint32_t)0x00000040)
  337. #define RCC_AHB2Periph_OTG_FS ((uint32_t)0x00000080)
  338. #define IS_RCC_AHB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFF0E) == 0x00) && ((PERIPH) != 0x00))
  339. /**
  340. * @}
  341. */
  342. /** @defgroup RCC_AHB3_Peripherals
  343. * @{
  344. */
  345. #if defined (STM32F40_41xxx)
  346. #define RCC_AHB3Periph_FSMC ((uint32_t)0x00000001)
  347. #endif /* STM32F40_41xxx */
  348. #if defined (STM32F427_437xx) || defined (STM32F429_439xx)
  349. #define RCC_AHB3Periph_FMC ((uint32_t)0x00000001)
  350. #endif /* STM32F427_437xx || STM32F429_439xx */
  351. #define IS_RCC_AHB3_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFFE) == 0x00) && ((PERIPH) != 0x00))
  352. /**
  353. * @}
  354. */
  355. /** @defgroup RCC_APB1_Peripherals
  356. * @{
  357. */
  358. #define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
  359. #define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002)
  360. #define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004)
  361. #define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008)
  362. #define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010)
  363. #define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020)
  364. #define RCC_APB1Periph_TIM12 ((uint32_t)0x00000040)
  365. #define RCC_APB1Periph_TIM13 ((uint32_t)0x00000080)
  366. #define RCC_APB1Periph_TIM14 ((uint32_t)0x00000100)
  367. #define RCC_APB1Periph_WWDG ((uint32_t)0x00000800)
  368. #define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000)
  369. #define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000)
  370. #define RCC_APB1Periph_USART2 ((uint32_t)0x00020000)
  371. #define RCC_APB1Periph_USART3 ((uint32_t)0x00040000)
  372. #define RCC_APB1Periph_UART4 ((uint32_t)0x00080000)
  373. #define RCC_APB1Periph_UART5 ((uint32_t)0x00100000)
  374. #define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000)
  375. #define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000)
  376. #define RCC_APB1Periph_I2C3 ((uint32_t)0x00800000)
  377. #define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000)
  378. #define RCC_APB1Periph_CAN2 ((uint32_t)0x04000000)
  379. #define RCC_APB1Periph_PWR ((uint32_t)0x10000000)
  380. #define RCC_APB1Periph_DAC ((uint32_t)0x20000000)
  381. #define RCC_APB1Periph_UART7 ((uint32_t)0x40000000)
  382. #define RCC_APB1Periph_UART8 ((uint32_t)0x80000000)
  383. #define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0x09013600) == 0x00) && ((PERIPH) != 0x00))
  384. /**
  385. * @}
  386. */
  387. /** @defgroup RCC_APB2_Peripherals
  388. * @{
  389. */
  390. #define RCC_APB2Periph_TIM1 ((uint32_t)0x00000001)
  391. #define RCC_APB2Periph_TIM8 ((uint32_t)0x00000002)
  392. #define RCC_APB2Periph_USART1 ((uint32_t)0x00000010)
  393. #define RCC_APB2Periph_USART6 ((uint32_t)0x00000020)
  394. #define RCC_APB2Periph_ADC ((uint32_t)0x00000100)
  395. #define RCC_APB2Periph_ADC1 ((uint32_t)0x00000100)
  396. #define RCC_APB2Periph_ADC2 ((uint32_t)0x00000200)
  397. #define RCC_APB2Periph_ADC3 ((uint32_t)0x00000400)
  398. #define RCC_APB2Periph_SDIO ((uint32_t)0x00000800)
  399. #define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000)
  400. #define RCC_APB2Periph_SPI4 ((uint32_t)0x00002000)
  401. #define RCC_APB2Periph_SYSCFG ((uint32_t)0x00004000)
  402. #define RCC_APB2Periph_TIM9 ((uint32_t)0x00010000)
  403. #define RCC_APB2Periph_TIM10 ((uint32_t)0x00020000)
  404. #define RCC_APB2Periph_TIM11 ((uint32_t)0x00040000)
  405. #define RCC_APB2Periph_SPI5 ((uint32_t)0x00100000)
  406. #define RCC_APB2Periph_SPI6 ((uint32_t)0x00200000)
  407. #define RCC_APB2Periph_SAI1 ((uint32_t)0x00400000)
  408. #define RCC_APB2Periph_LTDC ((uint32_t)0x04000000)
  409. #define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFB8880CC) == 0x00) && ((PERIPH) != 0x00))
  410. #define IS_RCC_APB2_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xFB8886CC) == 0x00) && ((PERIPH) != 0x00))
  411. /**
  412. * @}
  413. */
  414. /** @defgroup RCC_MCO1_Clock_Source_Prescaler
  415. * @{
  416. */
  417. #define RCC_MCO1Source_HSI ((uint32_t)0x00000000)
  418. #define RCC_MCO1Source_LSE ((uint32_t)0x00200000)
  419. #define RCC_MCO1Source_HSE ((uint32_t)0x00400000)
  420. #define RCC_MCO1Source_PLLCLK ((uint32_t)0x00600000)
  421. #define RCC_MCO1Div_1 ((uint32_t)0x00000000)
  422. #define RCC_MCO1Div_2 ((uint32_t)0x04000000)
  423. #define RCC_MCO1Div_3 ((uint32_t)0x05000000)
  424. #define RCC_MCO1Div_4 ((uint32_t)0x06000000)
  425. #define RCC_MCO1Div_5 ((uint32_t)0x07000000)
  426. #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1Source_HSI) || ((SOURCE) == RCC_MCO1Source_LSE) || \
  427. ((SOURCE) == RCC_MCO1Source_HSE) || ((SOURCE) == RCC_MCO1Source_PLLCLK))
  428. #define IS_RCC_MCO1DIV(DIV) (((DIV) == RCC_MCO1Div_1) || ((DIV) == RCC_MCO1Div_2) || \
  429. ((DIV) == RCC_MCO1Div_3) || ((DIV) == RCC_MCO1Div_4) || \
  430. ((DIV) == RCC_MCO1Div_5))
  431. /**
  432. * @}
  433. */
  434. /** @defgroup RCC_MCO2_Clock_Source_Prescaler
  435. * @{
  436. */
  437. #define RCC_MCO2Source_SYSCLK ((uint32_t)0x00000000)
  438. #define RCC_MCO2Source_PLLI2SCLK ((uint32_t)0x40000000)
  439. #define RCC_MCO2Source_HSE ((uint32_t)0x80000000)
  440. #define RCC_MCO2Source_PLLCLK ((uint32_t)0xC0000000)
  441. #define RCC_MCO2Div_1 ((uint32_t)0x00000000)
  442. #define RCC_MCO2Div_2 ((uint32_t)0x20000000)
  443. #define RCC_MCO2Div_3 ((uint32_t)0x28000000)
  444. #define RCC_MCO2Div_4 ((uint32_t)0x30000000)
  445. #define RCC_MCO2Div_5 ((uint32_t)0x38000000)
  446. #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2Source_SYSCLK) || ((SOURCE) == RCC_MCO2Source_PLLI2SCLK)|| \
  447. ((SOURCE) == RCC_MCO2Source_HSE) || ((SOURCE) == RCC_MCO2Source_PLLCLK))
  448. #define IS_RCC_MCO2DIV(DIV) (((DIV) == RCC_MCO2Div_1) || ((DIV) == RCC_MCO2Div_2) || \
  449. ((DIV) == RCC_MCO2Div_3) || ((DIV) == RCC_MCO2Div_4) || \
  450. ((DIV) == RCC_MCO2Div_5))
  451. /**
  452. * @}
  453. */
  454. /** @defgroup RCC_Flag
  455. * @{
  456. */
  457. #define RCC_FLAG_HSIRDY ((uint8_t)0x21)
  458. #define RCC_FLAG_HSERDY ((uint8_t)0x31)
  459. #define RCC_FLAG_PLLRDY ((uint8_t)0x39)
  460. #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3B)
  461. #define RCC_FLAG_PLLSAIRDY ((uint8_t)0x3D)
  462. #define RCC_FLAG_LSERDY ((uint8_t)0x41)
  463. #define RCC_FLAG_LSIRDY ((uint8_t)0x61)
  464. #define RCC_FLAG_BORRST ((uint8_t)0x79)
  465. #define RCC_FLAG_PINRST ((uint8_t)0x7A)
  466. #define RCC_FLAG_PORRST ((uint8_t)0x7B)
  467. #define RCC_FLAG_SFTRST ((uint8_t)0x7C)
  468. #define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
  469. #define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
  470. #define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
  471. #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \
  472. ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \
  473. ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_BORRST) || \
  474. ((FLAG) == RCC_FLAG_PINRST) || ((FLAG) == RCC_FLAG_PORRST) || \
  475. ((FLAG) == RCC_FLAG_SFTRST) || ((FLAG) == RCC_FLAG_IWDGRST)|| \
  476. ((FLAG) == RCC_FLAG_WWDGRST) || ((FLAG) == RCC_FLAG_LPWRRST)|| \
  477. ((FLAG) == RCC_FLAG_PLLI2SRDY)|| ((FLAG) == RCC_FLAG_PLLSAIRDY))
  478. #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
  479. /**
  480. * @}
  481. */
  482. /**
  483. * @}
  484. */
  485. /* Exported macro ------------------------------------------------------------*/
  486. /* Exported functions --------------------------------------------------------*/
  487. /* Function used to set the RCC clock configuration to the default reset state */
  488. void RCC_DeInit(void);
  489. /* Internal/external clocks, PLL, CSS and MCO configuration functions *********/
  490. void RCC_HSEConfig(uint8_t RCC_HSE);
  491. ErrorStatus RCC_WaitForHSEStartUp(void);
  492. void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue);
  493. void RCC_HSICmd(FunctionalState NewState);
  494. void RCC_LSEConfig(uint8_t RCC_LSE);
  495. void RCC_LSICmd(FunctionalState NewState);
  496. void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ);
  497. void RCC_PLLCmd(FunctionalState NewState);
  498. #if defined (STM32F40_41xxx) || defined (STM32F401xx)
  499. void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR);
  500. #elif defined (STM32F411xE)
  501. void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR, uint32_t PLLI2SM);
  502. #elif defined (STM32F427_437xx) || defined (STM32F429_439xx)
  503. void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SQ, uint32_t PLLI2SR);
  504. #else
  505. #endif /* STM32F40_41xxx || STM32F401xx */
  506. void RCC_PLLI2SCmd(FunctionalState NewState);
  507. void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR);
  508. void RCC_PLLSAICmd(FunctionalState NewState);
  509. void RCC_ClockSecuritySystemCmd(FunctionalState NewState);
  510. void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div);
  511. void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div);
  512. /* System, AHB and APB busses clocks configuration functions ******************/
  513. void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource);
  514. uint8_t RCC_GetSYSCLKSource(void);
  515. void RCC_HCLKConfig(uint32_t RCC_SYSCLK);
  516. void RCC_PCLK1Config(uint32_t RCC_HCLK);
  517. void RCC_PCLK2Config(uint32_t RCC_HCLK);
  518. void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks);
  519. /* Peripheral clocks configuration functions **********************************/
  520. void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource);
  521. void RCC_RTCCLKCmd(FunctionalState NewState);
  522. void RCC_BackupResetCmd(FunctionalState NewState);
  523. void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource);
  524. void RCC_SAIPLLI2SClkDivConfig(uint32_t RCC_PLLI2SDivQ);
  525. void RCC_SAIPLLSAIClkDivConfig(uint32_t RCC_PLLSAIDivQ);
  526. void RCC_SAIBlockACLKConfig(uint32_t RCC_SAIBlockACLKSource);
  527. void RCC_SAIBlockBCLKConfig(uint32_t RCC_SAIBlockBCLKSource);
  528. void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR);
  529. void RCC_TIMCLKPresConfig(uint32_t RCC_TIMCLKPrescaler);
  530. void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  531. void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  532. void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  533. void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  534. void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  535. void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  536. void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  537. void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  538. void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  539. void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  540. void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
  541. void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
  542. void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
  543. void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
  544. void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
  545. void RCC_LSEModeConfig(uint8_t Mode);
  546. /* Interrupts and flags management functions **********************************/
  547. void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState);
  548. FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG);
  549. void RCC_ClearFlag(void);
  550. ITStatus RCC_GetITStatus(uint8_t RCC_IT);
  551. void RCC_ClearITPendingBit(uint8_t RCC_IT);
  552. #ifdef __cplusplus
  553. }
  554. #endif
  555. #endif /* __STM32F4xx_RCC_H */
  556. /**
  557. * @}
  558. */
  559. /**
  560. * @}
  561. */
  562. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/