CARME-M4 BSP  V1.5
stm32f4xx_rcc.h
Go to the documentation of this file.
1 
28 /* Define to prevent recursive inclusion -------------------------------------*/
29 #ifndef __STM32F4xx_RCC_H
30 #define __STM32F4xx_RCC_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------*/
37 #include "stm32f4xx.h"
38 
47 /* Exported types ------------------------------------------------------------*/
48 typedef struct
49 {
50  uint32_t SYSCLK_Frequency;
51  uint32_t HCLK_Frequency;
52  uint32_t PCLK1_Frequency;
53  uint32_t PCLK2_Frequency;
55 
56 /* Exported constants --------------------------------------------------------*/
57 
65 #define RCC_HSE_OFF ((uint8_t)0x00)
66 #define RCC_HSE_ON ((uint8_t)0x01)
67 #define RCC_HSE_Bypass ((uint8_t)0x05)
68 #define IS_RCC_HSE(HSE) (((HSE) == RCC_HSE_OFF) || ((HSE) == RCC_HSE_ON) || \
69  ((HSE) == RCC_HSE_Bypass))
70 
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 
86 #define IS_RCC_PLLI2SN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
87 #define IS_RCC_PLLI2SR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
88 
89 #define IS_RCC_PLLI2SQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
90 #define IS_RCC_PLLSAIN_VALUE(VALUE) ((192 <= (VALUE)) && ((VALUE) <= 432))
91 #define IS_RCC_PLLSAIQ_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 15))
92 #define IS_RCC_PLLSAIR_VALUE(VALUE) ((2 <= (VALUE)) && ((VALUE) <= 7))
93 
94 #define IS_RCC_PLLSAI_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
95 #define IS_RCC_PLLI2S_DIVQ_VALUE(VALUE) ((1 <= (VALUE)) && ((VALUE) <= 32))
96 
97 #define RCC_PLLSAIDivR_Div2 ((uint32_t)0x00000000)
98 #define RCC_PLLSAIDivR_Div4 ((uint32_t)0x00010000)
99 #define RCC_PLLSAIDivR_Div8 ((uint32_t)0x00020000)
100 #define RCC_PLLSAIDivR_Div16 ((uint32_t)0x00030000)
101 #define IS_RCC_PLLSAI_DIVR_VALUE(VALUE) (((VALUE) == RCC_PLLSAIDivR_Div2) ||\
102  ((VALUE) == RCC_PLLSAIDivR_Div4) ||\
103  ((VALUE) == RCC_PLLSAIDivR_Div8) ||\
104  ((VALUE) == RCC_PLLSAIDivR_Div16))
105 
113 #define RCC_SYSCLKSource_HSI ((uint32_t)0x00000000)
114 #define RCC_SYSCLKSource_HSE ((uint32_t)0x00000001)
115 #define RCC_SYSCLKSource_PLLCLK ((uint32_t)0x00000002)
116 #define IS_RCC_SYSCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SYSCLKSource_HSI) || \
117  ((SOURCE) == RCC_SYSCLKSource_HSE) || \
118  ((SOURCE) == RCC_SYSCLKSource_PLLCLK))
119 
126 #define RCC_SYSCLK_Div1 ((uint32_t)0x00000000)
127 #define RCC_SYSCLK_Div2 ((uint32_t)0x00000080)
128 #define RCC_SYSCLK_Div4 ((uint32_t)0x00000090)
129 #define RCC_SYSCLK_Div8 ((uint32_t)0x000000A0)
130 #define RCC_SYSCLK_Div16 ((uint32_t)0x000000B0)
131 #define RCC_SYSCLK_Div64 ((uint32_t)0x000000C0)
132 #define RCC_SYSCLK_Div128 ((uint32_t)0x000000D0)
133 #define RCC_SYSCLK_Div256 ((uint32_t)0x000000E0)
134 #define RCC_SYSCLK_Div512 ((uint32_t)0x000000F0)
135 #define IS_RCC_HCLK(HCLK) (((HCLK) == RCC_SYSCLK_Div1) || ((HCLK) == RCC_SYSCLK_Div2) || \
136  ((HCLK) == RCC_SYSCLK_Div4) || ((HCLK) == RCC_SYSCLK_Div8) || \
137  ((HCLK) == RCC_SYSCLK_Div16) || ((HCLK) == RCC_SYSCLK_Div64) || \
138  ((HCLK) == RCC_SYSCLK_Div128) || ((HCLK) == RCC_SYSCLK_Div256) || \
139  ((HCLK) == RCC_SYSCLK_Div512))
140 
147 #define RCC_HCLK_Div1 ((uint32_t)0x00000000)
148 #define RCC_HCLK_Div2 ((uint32_t)0x00001000)
149 #define RCC_HCLK_Div4 ((uint32_t)0x00001400)
150 #define RCC_HCLK_Div8 ((uint32_t)0x00001800)
151 #define RCC_HCLK_Div16 ((uint32_t)0x00001C00)
152 #define IS_RCC_PCLK(PCLK) (((PCLK) == RCC_HCLK_Div1) || ((PCLK) == RCC_HCLK_Div2) || \
153  ((PCLK) == RCC_HCLK_Div4) || ((PCLK) == RCC_HCLK_Div8) || \
154  ((PCLK) == RCC_HCLK_Div16))
155 
162 #define RCC_IT_LSIRDY ((uint8_t)0x01)
163 #define RCC_IT_LSERDY ((uint8_t)0x02)
164 #define RCC_IT_HSIRDY ((uint8_t)0x04)
165 #define RCC_IT_HSERDY ((uint8_t)0x08)
166 #define RCC_IT_PLLRDY ((uint8_t)0x10)
167 #define RCC_IT_PLLI2SRDY ((uint8_t)0x20)
168 #define RCC_IT_PLLSAIRDY ((uint8_t)0x40)
169 #define RCC_IT_CSS ((uint8_t)0x80)
170 
171 #define IS_RCC_IT(IT) ((((IT) & (uint8_t)0x80) == 0x00) && ((IT) != 0x00))
172 #define IS_RCC_GET_IT(IT) (((IT) == RCC_IT_LSIRDY) || ((IT) == RCC_IT_LSERDY) || \
173  ((IT) == RCC_IT_HSIRDY) || ((IT) == RCC_IT_HSERDY) || \
174  ((IT) == RCC_IT_PLLRDY) || ((IT) == RCC_IT_CSS) || \
175  ((IT) == RCC_IT_PLLSAIRDY) || ((IT) == RCC_IT_PLLI2SRDY))
176 #define IS_RCC_CLEAR_IT(IT)((IT) != 0x00)
177 
185 #define RCC_LSE_OFF ((uint8_t)0x00)
186 #define RCC_LSE_ON ((uint8_t)0x01)
187 #define RCC_LSE_Bypass ((uint8_t)0x04)
188 #define IS_RCC_LSE(LSE) (((LSE) == RCC_LSE_OFF) || ((LSE) == RCC_LSE_ON) || \
189  ((LSE) == RCC_LSE_Bypass))
190 
197 #define RCC_RTCCLKSource_LSE ((uint32_t)0x00000100)
198 #define RCC_RTCCLKSource_LSI ((uint32_t)0x00000200)
199 #define RCC_RTCCLKSource_HSE_Div2 ((uint32_t)0x00020300)
200 #define RCC_RTCCLKSource_HSE_Div3 ((uint32_t)0x00030300)
201 #define RCC_RTCCLKSource_HSE_Div4 ((uint32_t)0x00040300)
202 #define RCC_RTCCLKSource_HSE_Div5 ((uint32_t)0x00050300)
203 #define RCC_RTCCLKSource_HSE_Div6 ((uint32_t)0x00060300)
204 #define RCC_RTCCLKSource_HSE_Div7 ((uint32_t)0x00070300)
205 #define RCC_RTCCLKSource_HSE_Div8 ((uint32_t)0x00080300)
206 #define RCC_RTCCLKSource_HSE_Div9 ((uint32_t)0x00090300)
207 #define RCC_RTCCLKSource_HSE_Div10 ((uint32_t)0x000A0300)
208 #define RCC_RTCCLKSource_HSE_Div11 ((uint32_t)0x000B0300)
209 #define RCC_RTCCLKSource_HSE_Div12 ((uint32_t)0x000C0300)
210 #define RCC_RTCCLKSource_HSE_Div13 ((uint32_t)0x000D0300)
211 #define RCC_RTCCLKSource_HSE_Div14 ((uint32_t)0x000E0300)
212 #define RCC_RTCCLKSource_HSE_Div15 ((uint32_t)0x000F0300)
213 #define RCC_RTCCLKSource_HSE_Div16 ((uint32_t)0x00100300)
214 #define RCC_RTCCLKSource_HSE_Div17 ((uint32_t)0x00110300)
215 #define RCC_RTCCLKSource_HSE_Div18 ((uint32_t)0x00120300)
216 #define RCC_RTCCLKSource_HSE_Div19 ((uint32_t)0x00130300)
217 #define RCC_RTCCLKSource_HSE_Div20 ((uint32_t)0x00140300)
218 #define RCC_RTCCLKSource_HSE_Div21 ((uint32_t)0x00150300)
219 #define RCC_RTCCLKSource_HSE_Div22 ((uint32_t)0x00160300)
220 #define RCC_RTCCLKSource_HSE_Div23 ((uint32_t)0x00170300)
221 #define RCC_RTCCLKSource_HSE_Div24 ((uint32_t)0x00180300)
222 #define RCC_RTCCLKSource_HSE_Div25 ((uint32_t)0x00190300)
223 #define RCC_RTCCLKSource_HSE_Div26 ((uint32_t)0x001A0300)
224 #define RCC_RTCCLKSource_HSE_Div27 ((uint32_t)0x001B0300)
225 #define RCC_RTCCLKSource_HSE_Div28 ((uint32_t)0x001C0300)
226 #define RCC_RTCCLKSource_HSE_Div29 ((uint32_t)0x001D0300)
227 #define RCC_RTCCLKSource_HSE_Div30 ((uint32_t)0x001E0300)
228 #define RCC_RTCCLKSource_HSE_Div31 ((uint32_t)0x001F0300)
229 #define IS_RCC_RTCCLK_SOURCE(SOURCE) (((SOURCE) == RCC_RTCCLKSource_LSE) || \
230  ((SOURCE) == RCC_RTCCLKSource_LSI) || \
231  ((SOURCE) == RCC_RTCCLKSource_HSE_Div2) || \
232  ((SOURCE) == RCC_RTCCLKSource_HSE_Div3) || \
233  ((SOURCE) == RCC_RTCCLKSource_HSE_Div4) || \
234  ((SOURCE) == RCC_RTCCLKSource_HSE_Div5) || \
235  ((SOURCE) == RCC_RTCCLKSource_HSE_Div6) || \
236  ((SOURCE) == RCC_RTCCLKSource_HSE_Div7) || \
237  ((SOURCE) == RCC_RTCCLKSource_HSE_Div8) || \
238  ((SOURCE) == RCC_RTCCLKSource_HSE_Div9) || \
239  ((SOURCE) == RCC_RTCCLKSource_HSE_Div10) || \
240  ((SOURCE) == RCC_RTCCLKSource_HSE_Div11) || \
241  ((SOURCE) == RCC_RTCCLKSource_HSE_Div12) || \
242  ((SOURCE) == RCC_RTCCLKSource_HSE_Div13) || \
243  ((SOURCE) == RCC_RTCCLKSource_HSE_Div14) || \
244  ((SOURCE) == RCC_RTCCLKSource_HSE_Div15) || \
245  ((SOURCE) == RCC_RTCCLKSource_HSE_Div16) || \
246  ((SOURCE) == RCC_RTCCLKSource_HSE_Div17) || \
247  ((SOURCE) == RCC_RTCCLKSource_HSE_Div18) || \
248  ((SOURCE) == RCC_RTCCLKSource_HSE_Div19) || \
249  ((SOURCE) == RCC_RTCCLKSource_HSE_Div20) || \
250  ((SOURCE) == RCC_RTCCLKSource_HSE_Div21) || \
251  ((SOURCE) == RCC_RTCCLKSource_HSE_Div22) || \
252  ((SOURCE) == RCC_RTCCLKSource_HSE_Div23) || \
253  ((SOURCE) == RCC_RTCCLKSource_HSE_Div24) || \
254  ((SOURCE) == RCC_RTCCLKSource_HSE_Div25) || \
255  ((SOURCE) == RCC_RTCCLKSource_HSE_Div26) || \
256  ((SOURCE) == RCC_RTCCLKSource_HSE_Div27) || \
257  ((SOURCE) == RCC_RTCCLKSource_HSE_Div28) || \
258  ((SOURCE) == RCC_RTCCLKSource_HSE_Div29) || \
259  ((SOURCE) == RCC_RTCCLKSource_HSE_Div30) || \
260  ((SOURCE) == RCC_RTCCLKSource_HSE_Div31))
261 
268 #define RCC_I2S2CLKSource_PLLI2S ((uint8_t)0x00)
269 #define RCC_I2S2CLKSource_Ext ((uint8_t)0x01)
270 
271 #define IS_RCC_I2SCLK_SOURCE(SOURCE) (((SOURCE) == RCC_I2S2CLKSource_PLLI2S) || ((SOURCE) == RCC_I2S2CLKSource_Ext))
272 
279 #define RCC_SAIACLKSource_PLLSAI ((uint32_t)0x00000000)
280 #define RCC_SAIACLKSource_PLLI2S ((uint32_t)0x00100000)
281 #define RCC_SAIACLKSource_Ext ((uint32_t)0x00200000)
282 
283 #define IS_RCC_SAIACLK_SOURCE(SOURCE) (((SOURCE) == RCC_SAIACLKSource_PLLI2S) ||\
284  ((SOURCE) == RCC_SAIACLKSource_PLLSAI) ||\
285  ((SOURCE) == RCC_SAIACLKSource_Ext))
286 
293 #define RCC_SAIBCLKSource_PLLSAI ((uint32_t)0x00000000)
294 #define RCC_SAIBCLKSource_PLLI2S ((uint32_t)0x00400000)
295 #define RCC_SAIBCLKSource_Ext ((uint32_t)0x00800000)
296 
297 #define IS_RCC_SAIBCLK_SOURCE(SOURCE) (((SOURCE) == RCC_SAIBCLKSource_PLLI2S) ||\
298  ((SOURCE) == RCC_SAIBCLKSource_PLLSAI) ||\
299  ((SOURCE) == RCC_SAIBCLKSource_Ext))
300 
307 #define RCC_TIMPrescDesactivated ((uint8_t)0x00)
308 #define RCC_TIMPrescActivated ((uint8_t)0x01)
309 
310 #define IS_RCC_TIMCLK_PRESCALER(VALUE) (((VALUE) == RCC_TIMPrescDesactivated) || ((VALUE) == RCC_TIMPrescActivated))
311 
318 #define RCC_AHB1Periph_GPIOA ((uint32_t)0x00000001)
319 #define RCC_AHB1Periph_GPIOB ((uint32_t)0x00000002)
320 #define RCC_AHB1Periph_GPIOC ((uint32_t)0x00000004)
321 #define RCC_AHB1Periph_GPIOD ((uint32_t)0x00000008)
322 #define RCC_AHB1Periph_GPIOE ((uint32_t)0x00000010)
323 #define RCC_AHB1Periph_GPIOF ((uint32_t)0x00000020)
324 #define RCC_AHB1Periph_GPIOG ((uint32_t)0x00000040)
325 #define RCC_AHB1Periph_GPIOH ((uint32_t)0x00000080)
326 #define RCC_AHB1Periph_GPIOI ((uint32_t)0x00000100)
327 #define RCC_AHB1Periph_GPIOJ ((uint32_t)0x00000200)
328 #define RCC_AHB1Periph_GPIOK ((uint32_t)0x00000400)
329 #define RCC_AHB1Periph_CRC ((uint32_t)0x00001000)
330 #define RCC_AHB1Periph_FLITF ((uint32_t)0x00008000)
331 #define RCC_AHB1Periph_SRAM1 ((uint32_t)0x00010000)
332 #define RCC_AHB1Periph_SRAM2 ((uint32_t)0x00020000)
333 #define RCC_AHB1Periph_BKPSRAM ((uint32_t)0x00040000)
334 #define RCC_AHB1Periph_SRAM3 ((uint32_t)0x00080000)
335 #define RCC_AHB1Periph_CCMDATARAMEN ((uint32_t)0x00100000)
336 #define RCC_AHB1Periph_DMA1 ((uint32_t)0x00200000)
337 #define RCC_AHB1Periph_DMA2 ((uint32_t)0x00400000)
338 #define RCC_AHB1Periph_DMA2D ((uint32_t)0x00800000)
339 #define RCC_AHB1Periph_ETH_MAC ((uint32_t)0x02000000)
340 #define RCC_AHB1Periph_ETH_MAC_Tx ((uint32_t)0x04000000)
341 #define RCC_AHB1Periph_ETH_MAC_Rx ((uint32_t)0x08000000)
342 #define RCC_AHB1Periph_ETH_MAC_PTP ((uint32_t)0x10000000)
343 #define RCC_AHB1Periph_OTG_HS ((uint32_t)0x20000000)
344 #define RCC_AHB1Periph_OTG_HS_ULPI ((uint32_t)0x40000000)
345 
346 #define IS_RCC_AHB1_CLOCK_PERIPH(PERIPH) ((((PERIPH) & 0x810BE800) == 0x00) && ((PERIPH) != 0x00))
347 #define IS_RCC_AHB1_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xDD1FE800) == 0x00) && ((PERIPH) != 0x00))
348 #define IS_RCC_AHB1_LPMODE_PERIPH(PERIPH) ((((PERIPH) & 0x81106800) == 0x00) && ((PERIPH) != 0x00))
349 
357 #define RCC_AHB2Periph_DCMI ((uint32_t)0x00000001)
358 #define RCC_AHB2Periph_CRYP ((uint32_t)0x00000010)
359 #define RCC_AHB2Periph_HASH ((uint32_t)0x00000020)
360 #define RCC_AHB2Periph_RNG ((uint32_t)0x00000040)
361 #define RCC_AHB2Periph_OTG_FS ((uint32_t)0x00000080)
362 #define IS_RCC_AHB2_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFF0E) == 0x00) && ((PERIPH) != 0x00))
363 
370 #if defined (STM32F40_41xxx)
371 #define RCC_AHB3Periph_FSMC ((uint32_t)0x00000001)
372 #endif /* STM32F40_41xxx */
373 
374 #if defined (STM32F427_437xx) || defined (STM32F429_439xx)
375 #define RCC_AHB3Periph_FMC ((uint32_t)0x00000001)
376 #endif /* STM32F427_437xx || STM32F429_439xx */
377 
378 #define IS_RCC_AHB3_PERIPH(PERIPH) ((((PERIPH) & 0xFFFFFFFE) == 0x00) && ((PERIPH) != 0x00))
379 
386 #define RCC_APB1Periph_TIM2 ((uint32_t)0x00000001)
387 #define RCC_APB1Periph_TIM3 ((uint32_t)0x00000002)
388 #define RCC_APB1Periph_TIM4 ((uint32_t)0x00000004)
389 #define RCC_APB1Periph_TIM5 ((uint32_t)0x00000008)
390 #define RCC_APB1Periph_TIM6 ((uint32_t)0x00000010)
391 #define RCC_APB1Periph_TIM7 ((uint32_t)0x00000020)
392 #define RCC_APB1Periph_TIM12 ((uint32_t)0x00000040)
393 #define RCC_APB1Periph_TIM13 ((uint32_t)0x00000080)
394 #define RCC_APB1Periph_TIM14 ((uint32_t)0x00000100)
395 #define RCC_APB1Periph_WWDG ((uint32_t)0x00000800)
396 #define RCC_APB1Periph_SPI2 ((uint32_t)0x00004000)
397 #define RCC_APB1Periph_SPI3 ((uint32_t)0x00008000)
398 #define RCC_APB1Periph_USART2 ((uint32_t)0x00020000)
399 #define RCC_APB1Periph_USART3 ((uint32_t)0x00040000)
400 #define RCC_APB1Periph_UART4 ((uint32_t)0x00080000)
401 #define RCC_APB1Periph_UART5 ((uint32_t)0x00100000)
402 #define RCC_APB1Periph_I2C1 ((uint32_t)0x00200000)
403 #define RCC_APB1Periph_I2C2 ((uint32_t)0x00400000)
404 #define RCC_APB1Periph_I2C3 ((uint32_t)0x00800000)
405 #define RCC_APB1Periph_CAN1 ((uint32_t)0x02000000)
406 #define RCC_APB1Periph_CAN2 ((uint32_t)0x04000000)
407 #define RCC_APB1Periph_PWR ((uint32_t)0x10000000)
408 #define RCC_APB1Periph_DAC ((uint32_t)0x20000000)
409 #define RCC_APB1Periph_UART7 ((uint32_t)0x40000000)
410 #define RCC_APB1Periph_UART8 ((uint32_t)0x80000000)
411 #define IS_RCC_APB1_PERIPH(PERIPH) ((((PERIPH) & 0x09013600) == 0x00) && ((PERIPH) != 0x00))
412 
419 #define RCC_APB2Periph_TIM1 ((uint32_t)0x00000001)
420 #define RCC_APB2Periph_TIM8 ((uint32_t)0x00000002)
421 #define RCC_APB2Periph_USART1 ((uint32_t)0x00000010)
422 #define RCC_APB2Periph_USART6 ((uint32_t)0x00000020)
423 #define RCC_APB2Periph_ADC ((uint32_t)0x00000100)
424 #define RCC_APB2Periph_ADC1 ((uint32_t)0x00000100)
425 #define RCC_APB2Periph_ADC2 ((uint32_t)0x00000200)
426 #define RCC_APB2Periph_ADC3 ((uint32_t)0x00000400)
427 #define RCC_APB2Periph_SDIO ((uint32_t)0x00000800)
428 #define RCC_APB2Periph_SPI1 ((uint32_t)0x00001000)
429 #define RCC_APB2Periph_SPI4 ((uint32_t)0x00002000)
430 #define RCC_APB2Periph_SYSCFG ((uint32_t)0x00004000)
431 #define RCC_APB2Periph_TIM9 ((uint32_t)0x00010000)
432 #define RCC_APB2Periph_TIM10 ((uint32_t)0x00020000)
433 #define RCC_APB2Periph_TIM11 ((uint32_t)0x00040000)
434 #define RCC_APB2Periph_SPI5 ((uint32_t)0x00100000)
435 #define RCC_APB2Periph_SPI6 ((uint32_t)0x00200000)
436 #define RCC_APB2Periph_SAI1 ((uint32_t)0x00400000)
437 #define RCC_APB2Periph_LTDC ((uint32_t)0x04000000)
438 
439 #define IS_RCC_APB2_PERIPH(PERIPH) ((((PERIPH) & 0xFB8880CC) == 0x00) && ((PERIPH) != 0x00))
440 #define IS_RCC_APB2_RESET_PERIPH(PERIPH) ((((PERIPH) & 0xFB8886CC) == 0x00) && ((PERIPH) != 0x00))
441 
449 #define RCC_MCO1Source_HSI ((uint32_t)0x00000000)
450 #define RCC_MCO1Source_LSE ((uint32_t)0x00200000)
451 #define RCC_MCO1Source_HSE ((uint32_t)0x00400000)
452 #define RCC_MCO1Source_PLLCLK ((uint32_t)0x00600000)
453 #define RCC_MCO1Div_1 ((uint32_t)0x00000000)
454 #define RCC_MCO1Div_2 ((uint32_t)0x04000000)
455 #define RCC_MCO1Div_3 ((uint32_t)0x05000000)
456 #define RCC_MCO1Div_4 ((uint32_t)0x06000000)
457 #define RCC_MCO1Div_5 ((uint32_t)0x07000000)
458 #define IS_RCC_MCO1SOURCE(SOURCE) (((SOURCE) == RCC_MCO1Source_HSI) || ((SOURCE) == RCC_MCO1Source_LSE) || \
459  ((SOURCE) == RCC_MCO1Source_HSE) || ((SOURCE) == RCC_MCO1Source_PLLCLK))
460 
461 #define IS_RCC_MCO1DIV(DIV) (((DIV) == RCC_MCO1Div_1) || ((DIV) == RCC_MCO1Div_2) || \
462  ((DIV) == RCC_MCO1Div_3) || ((DIV) == RCC_MCO1Div_4) || \
463  ((DIV) == RCC_MCO1Div_5))
464 
471 #define RCC_MCO2Source_SYSCLK ((uint32_t)0x00000000)
472 #define RCC_MCO2Source_PLLI2SCLK ((uint32_t)0x40000000)
473 #define RCC_MCO2Source_HSE ((uint32_t)0x80000000)
474 #define RCC_MCO2Source_PLLCLK ((uint32_t)0xC0000000)
475 #define RCC_MCO2Div_1 ((uint32_t)0x00000000)
476 #define RCC_MCO2Div_2 ((uint32_t)0x20000000)
477 #define RCC_MCO2Div_3 ((uint32_t)0x28000000)
478 #define RCC_MCO2Div_4 ((uint32_t)0x30000000)
479 #define RCC_MCO2Div_5 ((uint32_t)0x38000000)
480 #define IS_RCC_MCO2SOURCE(SOURCE) (((SOURCE) == RCC_MCO2Source_SYSCLK) || ((SOURCE) == RCC_MCO2Source_PLLI2SCLK)|| \
481  ((SOURCE) == RCC_MCO2Source_HSE) || ((SOURCE) == RCC_MCO2Source_PLLCLK))
482 
483 #define IS_RCC_MCO2DIV(DIV) (((DIV) == RCC_MCO2Div_1) || ((DIV) == RCC_MCO2Div_2) || \
484  ((DIV) == RCC_MCO2Div_3) || ((DIV) == RCC_MCO2Div_4) || \
485  ((DIV) == RCC_MCO2Div_5))
486 
493 #define RCC_FLAG_HSIRDY ((uint8_t)0x21)
494 #define RCC_FLAG_HSERDY ((uint8_t)0x31)
495 #define RCC_FLAG_PLLRDY ((uint8_t)0x39)
496 #define RCC_FLAG_PLLI2SRDY ((uint8_t)0x3B)
497 #define RCC_FLAG_PLLSAIRDY ((uint8_t)0x3D)
498 #define RCC_FLAG_LSERDY ((uint8_t)0x41)
499 #define RCC_FLAG_LSIRDY ((uint8_t)0x61)
500 #define RCC_FLAG_BORRST ((uint8_t)0x79)
501 #define RCC_FLAG_PINRST ((uint8_t)0x7A)
502 #define RCC_FLAG_PORRST ((uint8_t)0x7B)
503 #define RCC_FLAG_SFTRST ((uint8_t)0x7C)
504 #define RCC_FLAG_IWDGRST ((uint8_t)0x7D)
505 #define RCC_FLAG_WWDGRST ((uint8_t)0x7E)
506 #define RCC_FLAG_LPWRRST ((uint8_t)0x7F)
507 
508 #define IS_RCC_FLAG(FLAG) (((FLAG) == RCC_FLAG_HSIRDY) || ((FLAG) == RCC_FLAG_HSERDY) || \
509  ((FLAG) == RCC_FLAG_PLLRDY) || ((FLAG) == RCC_FLAG_LSERDY) || \
510  ((FLAG) == RCC_FLAG_LSIRDY) || ((FLAG) == RCC_FLAG_BORRST) || \
511  ((FLAG) == RCC_FLAG_PINRST) || ((FLAG) == RCC_FLAG_PORRST) || \
512  ((FLAG) == RCC_FLAG_SFTRST) || ((FLAG) == RCC_FLAG_IWDGRST)|| \
513  ((FLAG) == RCC_FLAG_WWDGRST) || ((FLAG) == RCC_FLAG_LPWRRST)|| \
514  ((FLAG) == RCC_FLAG_PLLI2SRDY)|| ((FLAG) == RCC_FLAG_PLLSAIRDY))
515 
516 #define IS_RCC_CALIBRATION_VALUE(VALUE) ((VALUE) <= 0x1F)
517 
525 /* Exported macro ------------------------------------------------------------*/
526 /* Exported functions --------------------------------------------------------*/
527 
528 /* Function used to set the RCC clock configuration to the default reset state */
529 void RCC_DeInit(void);
530 
531 /* Internal/external clocks, PLL, CSS and MCO configuration functions *********/
532 void RCC_HSEConfig(uint8_t RCC_HSE);
533 ErrorStatus RCC_WaitForHSEStartUp(void);
534 void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue);
535 void RCC_HSICmd(FunctionalState NewState);
536 void RCC_LSEConfig(uint8_t RCC_LSE);
537 void RCC_LSICmd(FunctionalState NewState);
538 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ);
539 void RCC_PLLCmd(FunctionalState NewState);
540 
541 #if defined (STM32F40_41xxx) || defined (STM32F401xx)
542 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR);
543 #endif /* STM32F40_41xxx || STM32F401xx */
544 
545 #if defined (STM32F427_437xx) || defined (STM32F429_439xx)
546 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SQ, uint32_t PLLI2SR);
547 #endif /* STM32F41_43xxx */
548 
549 void RCC_PLLI2SCmd(FunctionalState NewState);
550 void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR);
551 void RCC_PLLSAICmd(FunctionalState NewState);
552 void RCC_ClockSecuritySystemCmd(FunctionalState NewState);
553 void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div);
554 void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div);
555 
556 /* System, AHB and APB busses clocks configuration functions ******************/
557 void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource);
558 uint8_t RCC_GetSYSCLKSource(void);
559 void RCC_HCLKConfig(uint32_t RCC_SYSCLK);
560 void RCC_PCLK1Config(uint32_t RCC_HCLK);
561 void RCC_PCLK2Config(uint32_t RCC_HCLK);
562 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks);
563 
564 /* Peripheral clocks configuration functions **********************************/
565 void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource);
566 void RCC_RTCCLKCmd(FunctionalState NewState);
567 void RCC_BackupResetCmd(FunctionalState NewState);
568 void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource);
569 void RCC_SAIPLLI2SClkDivConfig(uint32_t RCC_PLLI2SDivQ);
570 void RCC_SAIPLLSAIClkDivConfig(uint32_t RCC_PLLSAIDivQ);
571 void RCC_SAIBlockACLKConfig(uint32_t RCC_SAIBlockACLKSource);
572 void RCC_SAIBlockBCLKConfig(uint32_t RCC_SAIBlockBCLKSource);
573 void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR);
574 void RCC_TIMCLKPresConfig(uint32_t RCC_TIMCLKPrescaler);
575 
576 void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
577 void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
578 void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
579 void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
580 void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
581 
582 void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
583 void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
584 void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
585 void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
586 void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
587 
588 void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState);
589 void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState);
590 void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState);
591 void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState);
592 void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState);
593 
594 /* Interrupts and flags management functions **********************************/
595 void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState);
596 FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG);
597 void RCC_ClearFlag(void);
598 ITStatus RCC_GetITStatus(uint8_t RCC_IT);
599 void RCC_ClearITPendingBit(uint8_t RCC_IT);
600 
601 #ifdef __cplusplus
602 }
603 #endif
604 
605 #endif /* __STM32F4xx_RCC_H */
606 
615 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
Enables or disables the AHB3 peripheral clock.
void RCC_ClearFlag(void)
Clears the RCC reset flags. The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST, RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST.
void RCC_PCLK1Config(uint32_t RCC_HCLK)
Configures the Low Speed APB clock (PCLK1).
ITStatus RCC_GetITStatus(uint8_t RCC_IT)
Checks whether the specified RCC interrupt has occurred or not.
void RCC_ClearITPendingBit(uint8_t RCC_IT)
Clears the RCC's interrupt pending bits.
void RCC_ClockSecuritySystemCmd(FunctionalState NewState)
Enables or disables the Clock Security System.
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Enables or disables the High Speed APB (APB2) peripheral clock.
FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
Checks whether the specified RCC flag is set or not.
void RCC_DeInit(void)
Resets the RCC clock configuration to the default reset state.
void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Enables or disables the AHB2 peripheral clock.
void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
Enables or disables the AHB3 peripheral clock during Low Power (Sleep) mode.
void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Enables or disables the AHB2 peripheral clock during Low Power (Sleep) mode.
void RCC_HSICmd(FunctionalState NewState)
Enables or disables the Internal High Speed oscillator (HSI).
void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
Configures the RTC clock (RTCCLK).
void RCC_SAIPLLI2SClkDivConfig(uint32_t RCC_PLLI2SDivQ)
Configures the SAI clock Divider coming from PLLI2S.
void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Enables or disables the APB1 peripheral clock during Low Power (Sleep) mode.
void RCC_LSICmd(FunctionalState NewState)
Enables or disables the Internal Low Speed oscillator (LSI).
uint32_t HCLK_Frequency
Definition: stm32f4xx_rcc.h:51
void RCC_PLLI2SCmd(FunctionalState NewState)
Enables or disables the PLLI2S.
void RCC_PLLSAICmd(FunctionalState NewState)
Enables or disables the PLLSAI.
void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)
Enables or disables the specified RCC interrupts.
void RCC_PCLK2Config(uint32_t RCC_HCLK)
Configures the High Speed APB clock (PCLK2).
void RCC_RTCCLKCmd(FunctionalState NewState)
Enables or disables the RTC clock.
void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
Forces or releases AHB3 peripheral reset.
void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
Adjusts the Internal High Speed oscillator (HSI) calibration value.
void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Enables or disables the AHB1 peripheral clock during Low Power (Sleep) mode.
void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR)
Configures the PLLSAI clock multiplication and division factors.
void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ)
Configures the main PLL clock source, multiplication and division factors.
void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div)
Selects the clock source to output on MCO1 pin(PA8).
void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR)
Configures the LTDC clock Divider coming from PLLSAI.
void RCC_TIMCLKPresConfig(uint32_t RCC_TIMCLKPrescaler)
Configures the Timers clocks prescalers selection.
void RCC_SAIBlockACLKConfig(uint32_t RCC_SAIBlockACLKSource)
Configures SAI1BlockA clock source selection.
void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Enables or disables the AHB1 peripheral clock.
void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div)
Selects the clock source to output on MCO2 pin(PC9).
ErrorStatus RCC_WaitForHSEStartUp(void)
Waits for HSE start-up.
void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Enables or disables the APB2 peripheral clock during Low Power (Sleep) mode.
uint32_t SYSCLK_Frequency
Definition: stm32f4xx_rcc.h:50
void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource)
Configures the I2S clock source (I2SCLK).
void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Forces or releases AHB2 peripheral reset.
void RCC_HCLKConfig(uint32_t RCC_SYSCLK)
Configures the AHB clock (HCLK).
uint8_t RCC_GetSYSCLKSource(void)
Returns the clock source used as system clock.
void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Enables or disables the Low Speed APB (APB1) peripheral clock.
void RCC_HSEConfig(uint8_t RCC_HSE)
Configures the External High Speed oscillator (HSE).
void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Forces or releases AHB1 peripheral reset.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
uint32_t PCLK2_Frequency
Definition: stm32f4xx_rcc.h:53
uint32_t PCLK1_Frequency
Definition: stm32f4xx_rcc.h:52
void RCC_GetClocksFreq(RCC_ClocksTypeDef *RCC_Clocks)
Returns the frequencies of different on chip clocks; SYSCLK, HCLK, PCLK1 and PCLK2.
void RCC_SAIBlockBCLKConfig(uint32_t RCC_SAIBlockBCLKSource)
Configures SAI1BlockB clock source selection.
void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Forces or releases High Speed APB (APB2) peripheral reset.
void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)
Configures the system clock (SYSCLK).
void RCC_LSEConfig(uint8_t RCC_LSE)
Configures the External Low Speed oscillator (LSE).
void RCC_SAIPLLSAIClkDivConfig(uint32_t RCC_PLLSAIDivQ)
Configures the SAI clock Divider coming from PLLSAI.
void RCC_BackupResetCmd(FunctionalState NewState)
Forces or releases the Backup domain reset.
void RCC_PLLCmd(FunctionalState NewState)
Enables or disables the main PLL.