Create release.yml
[betaflight.git] / lib / main / STM32F4 / Drivers / STM32F4xx_StdPeriph_Driver / src / stm32f4xx_rcc.c
blob330c776e8feea2c7caa9f14628ca3b6c83499b6f
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_rcc.c
4 * @author MCD Application Team
5 * @version V1.7.1
6 * @date 20-May-2016
7 * @brief This file provides firmware functions to manage the following
8 * functionalities of the Reset and clock control (RCC) peripheral:
9 * + Internal/external clocks, PLL, CSS and MCO configuration
10 * + System, AHB and APB busses clocks configuration
11 * + Peripheral clocks configuration
12 * + Interrupts and flags management
14 @verbatim
15 ===============================================================================
16 ##### RCC specific features #####
17 ===============================================================================
18 [..]
19 After reset the device is running from Internal High Speed oscillator
20 (HSI 16MHz) with Flash 0 wait state, Flash prefetch buffer, D-Cache
21 and I-Cache are disabled, and all peripherals are off except internal
22 SRAM, Flash and JTAG.
23 (+) There is no prescaler on High speed (AHB) and Low speed (APB) busses;
24 all peripherals mapped on these busses are running at HSI speed.
25 (+) The clock for all peripherals is switched off, except the SRAM and FLASH.
26 (+) All GPIOs are in input floating state, except the JTAG pins which
27 are assigned to be used for debug purpose.
28 [..]
29 Once the device started from reset, the user application has to:
30 (+) Configure the clock source to be used to drive the System clock
31 (if the application needs higher frequency/performance)
32 (+) Configure the System clock frequency and Flash settings
33 (+) Configure the AHB and APB busses prescalers
34 (+) Enable the clock for the peripheral(s) to be used
35 (+) Configure the clock source(s) for peripherals which clocks are not
36 derived from the System clock (I2S, RTC, ADC, USB OTG FS/SDIO/RNG)
37 @endverbatim
38 ******************************************************************************
39 * @attention
41 * <h2><center>&copy; COPYRIGHT 2016 STMicroelectronics</center></h2>
43 * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
44 * You may not use this file except in compliance with the License.
45 * You may obtain a copy of the License at:
47 * http://www.st.com/software_license_agreement_liberty_v2
49 * Unless required by applicable law or agreed to in writing, software
50 * distributed under the License is distributed on an "AS IS" BASIS,
51 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
52 * See the License for the specific language governing permissions and
53 * limitations under the License.
55 ******************************************************************************
58 /* Includes ------------------------------------------------------------------*/
59 #include "stm32f4xx_rcc.h"
61 /** @addtogroup STM32F4xx_StdPeriph_Driver
62 * @{
65 /** @defgroup RCC
66 * @brief RCC driver modules
67 * @{
68 */
70 /* Private typedef -----------------------------------------------------------*/
71 /* Private define ------------------------------------------------------------*/
72 /* ------------ RCC registers bit address in the alias region ----------- */
73 #define RCC_OFFSET (RCC_BASE - PERIPH_BASE)
74 /* --- CR Register ---*/
75 /* Alias word address of HSION bit */
76 #define CR_OFFSET (RCC_OFFSET + 0x00)
77 #define HSION_BitNumber 0x00
78 #define CR_HSION_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (HSION_BitNumber * 4))
79 /* Alias word address of CSSON bit */
80 #define CSSON_BitNumber 0x13
81 #define CR_CSSON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (CSSON_BitNumber * 4))
82 /* Alias word address of PLLON bit */
83 #define PLLON_BitNumber 0x18
84 #define CR_PLLON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLON_BitNumber * 4))
85 /* Alias word address of PLLI2SON bit */
86 #define PLLI2SON_BitNumber 0x1A
87 #define CR_PLLI2SON_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLI2SON_BitNumber * 4))
89 /* Alias word address of PLLSAION bit */
90 #define PLLSAION_BitNumber 0x1C
91 #define CR_PLLSAION_BB (PERIPH_BB_BASE + (CR_OFFSET * 32) + (PLLSAION_BitNumber * 4))
93 /* --- CFGR Register ---*/
94 /* Alias word address of I2SSRC bit */
95 #define CFGR_OFFSET (RCC_OFFSET + 0x08)
96 #define I2SSRC_BitNumber 0x17
97 #define CFGR_I2SSRC_BB (PERIPH_BB_BASE + (CFGR_OFFSET * 32) + (I2SSRC_BitNumber * 4))
99 /* --- BDCR Register ---*/
100 /* Alias word address of RTCEN bit */
101 #define BDCR_OFFSET (RCC_OFFSET + 0x70)
102 #define RTCEN_BitNumber 0x0F
103 #define BDCR_RTCEN_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (RTCEN_BitNumber * 4))
104 /* Alias word address of BDRST bit */
105 #define BDRST_BitNumber 0x10
106 #define BDCR_BDRST_BB (PERIPH_BB_BASE + (BDCR_OFFSET * 32) + (BDRST_BitNumber * 4))
108 /* --- CSR Register ---*/
109 /* Alias word address of LSION bit */
110 #define CSR_OFFSET (RCC_OFFSET + 0x74)
111 #define LSION_BitNumber 0x00
112 #define CSR_LSION_BB (PERIPH_BB_BASE + (CSR_OFFSET * 32) + (LSION_BitNumber * 4))
114 /* --- DCKCFGR Register ---*/
115 /* Alias word address of TIMPRE bit */
116 #define DCKCFGR_OFFSET (RCC_OFFSET + 0x8C)
117 #define TIMPRE_BitNumber 0x18
118 #define DCKCFGR_TIMPRE_BB (PERIPH_BB_BASE + (DCKCFGR_OFFSET * 32) + (TIMPRE_BitNumber * 4))
120 /* --- CFGR Register ---*/
121 #define RCC_CFGR_OFFSET (RCC_OFFSET + 0x08)
122 #if defined(STM32F410xx)
123 /* Alias word address of MCO1EN bit */
124 #define RCC_MCO1EN_BIT_NUMBER 0x8
125 #define RCC_CFGR_MCO1EN_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32) + (RCC_MCO1EN_BIT_NUMBER * 4))
127 /* Alias word address of MCO2EN bit */
128 #define RCC_MCO2EN_BIT_NUMBER 0x9
129 #define RCC_CFGR_MCO2EN_BB (PERIPH_BB_BASE + (RCC_CFGR_OFFSET * 32) + (RCC_MCO2EN_BIT_NUMBER * 4))
130 #endif /* STM32F410xx */
131 /* ---------------------- RCC registers bit mask ------------------------ */
132 /* CFGR register bit mask */
133 #define CFGR_MCO2_RESET_MASK ((uint32_t)0x07FFFFFF)
134 #define CFGR_MCO1_RESET_MASK ((uint32_t)0xF89FFFFF)
136 /* RCC Flag Mask */
137 #define FLAG_MASK ((uint8_t)0x1F)
139 /* CR register byte 3 (Bits[23:16]) base address */
140 #define CR_BYTE3_ADDRESS ((uint32_t)0x40023802)
142 /* CIR register byte 2 (Bits[15:8]) base address */
143 #define CIR_BYTE2_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x01))
145 /* CIR register byte 3 (Bits[23:16]) base address */
146 #define CIR_BYTE3_ADDRESS ((uint32_t)(RCC_BASE + 0x0C + 0x02))
148 /* BDCR register base address */
149 #define BDCR_ADDRESS (PERIPH_BASE + BDCR_OFFSET)
151 /* Private macro -------------------------------------------------------------*/
152 /* Private variables ---------------------------------------------------------*/
153 static __I uint8_t APBAHBPrescTable[16] = {0, 0, 0, 0, 1, 2, 3, 4, 1, 2, 3, 4, 6, 7, 8, 9};
155 /* Private function prototypes -----------------------------------------------*/
156 /* Private functions ---------------------------------------------------------*/
158 /** @defgroup RCC_Private_Functions
159 * @{
162 /** @defgroup RCC_Group1 Internal and external clocks, PLL, CSS and MCO configuration functions
163 * @brief Internal and external clocks, PLL, CSS and MCO configuration functions
165 @verbatim
166 ===================================================================================
167 ##### Internal and external clocks, PLL, CSS and MCO configuration functions #####
168 ===================================================================================
169 [..]
170 This section provide functions allowing to configure the internal/external clocks,
171 PLLs, CSS and MCO pins.
173 (#) HSI (high-speed internal), 16 MHz factory-trimmed RC used directly or through
174 the PLL as System clock source.
176 (#) LSI (low-speed internal), 32 KHz low consumption RC used as IWDG and/or RTC
177 clock source.
179 (#) HSE (high-speed external), 4 to 26 MHz crystal oscillator used directly or
180 through the PLL as System clock source. Can be used also as RTC clock source.
182 (#) LSE (low-speed external), 32 KHz oscillator used as RTC clock source.
184 (#) PLL (clocked by HSI or HSE), featuring two different output clocks:
185 (++) The first output is used to generate the high speed system clock (up to 168 MHz)
186 (++) The second output is used to generate the clock for the USB OTG FS (48 MHz),
187 the random analog generator (<=48 MHz) and the SDIO (<= 48 MHz).
189 (#) PLLI2S (clocked by HSI or HSE), used to generate an accurate clock to achieve
190 high-quality audio performance on the I2S interface or SAI interface in case
191 of STM32F429x/439x devices.
193 (#) PLLSAI clocked by (HSI or HSE), used to generate an accurate clock to SAI
194 interface and LCD TFT controller available only for STM32F42xxx/43xxx/446xx/469xx/479xx devices.
196 (#) CSS (Clock security system), once enable and if a HSE clock failure occurs
197 (HSE used directly or through PLL as System clock source), the System clock
198 is automatically switched to HSI and an interrupt is generated if enabled.
199 The interrupt is linked to the Cortex-M4 NMI (Non-Maskable Interrupt)
200 exception vector.
202 (#) MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL
203 clock (through a configurable prescaler) on PA8 pin.
205 (#) MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or PLLI2S
206 clock (through a configurable prescaler) on PC9 pin.
207 @endverbatim
208 * @{
212 * @brief Resets the RCC clock configuration to the default reset state.
213 * @note The default reset state of the clock configuration is given below:
214 * - HSI ON and used as system clock source
215 * - HSE, PLL and PLLI2S OFF
216 * - AHB, APB1 and APB2 prescaler set to 1.
217 * - CSS, MCO1 and MCO2 OFF
218 * - All interrupts disabled
219 * @note This function doesn't modify the configuration of the
220 * - Peripheral clocks
221 * - LSI, LSE and RTC clocks
222 * @param None
223 * @retval None
225 void RCC_DeInit(void)
227 /* Set HSION bit */
228 RCC->CR |= (uint32_t)0x00000001;
230 /* Reset CFGR register */
231 RCC->CFGR = 0x00000000;
233 /* Reset HSEON, CSSON, PLLON, PLLI2S and PLLSAI(STM32F42xxx/43xxx/446xx/469xx/479xx devices) bits */
234 RCC->CR &= (uint32_t)0xEAF6FFFF;
236 /* Reset PLLCFGR register */
237 RCC->PLLCFGR = 0x24003010;
239 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469_479xx)
240 /* Reset PLLI2SCFGR register */
241 RCC->PLLI2SCFGR = 0x20003000;
242 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE || STM32F446xx || STM32F469_479xx */
244 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
245 /* Reset PLLSAICFGR register, only available for STM32F42xxx/43xxx/446xx/469xx/479xx devices */
246 RCC->PLLSAICFGR = 0x24003000;
247 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
249 /* Reset HSEBYP bit */
250 RCC->CR &= (uint32_t)0xFFFBFFFF;
252 /* Disable all interrupts */
253 RCC->CIR = 0x00000000;
255 /* Disable Timers clock prescalers selection, only available for STM32F42/43xxx devices */
256 RCC->DCKCFGR = 0x00000000;
258 #if defined(STM32F410xx)
259 /* Disable LPTIM and FMPI2C clock prescalers selection, only available for STM32F410xx devices */
260 RCC->DCKCFGR2 = 0x00000000;
261 #endif /* STM32F410xx */
265 * @brief Configures the External High Speed oscillator (HSE).
266 * @note After enabling the HSE (RCC_HSE_ON or RCC_HSE_Bypass), the application
267 * software should wait on HSERDY flag to be set indicating that HSE clock
268 * is stable and can be used to clock the PLL and/or system clock.
269 * @note HSE state can not be changed if it is used directly or through the
270 * PLL as system clock. In this case, you have to select another source
271 * of the system clock then change the HSE state (ex. disable it).
272 * @note The HSE is stopped by hardware when entering STOP and STANDBY modes.
273 * @note This function reset the CSSON bit, so if the Clock security system(CSS)
274 * was previously enabled you have to enable it again after calling this
275 * function.
276 * @param RCC_HSE: specifies the new state of the HSE.
277 * This parameter can be one of the following values:
278 * @arg RCC_HSE_OFF: turn OFF the HSE oscillator, HSERDY flag goes low after
279 * 6 HSE oscillator clock cycles.
280 * @arg RCC_HSE_ON: turn ON the HSE oscillator
281 * @arg RCC_HSE_Bypass: HSE oscillator bypassed with external clock
282 * @retval None
284 void RCC_HSEConfig(uint8_t RCC_HSE)
286 /* Check the parameters */
287 assert_param(IS_RCC_HSE(RCC_HSE));
289 /* Reset HSEON and HSEBYP bits before configuring the HSE ------------------*/
290 *(__IO uint8_t *) CR_BYTE3_ADDRESS = RCC_HSE_OFF;
292 /* Set the new HSE configuration -------------------------------------------*/
293 *(__IO uint8_t *) CR_BYTE3_ADDRESS = RCC_HSE;
297 * @brief Waits for HSE start-up.
298 * @note This functions waits on HSERDY flag to be set and return SUCCESS if
299 * this flag is set, otherwise returns ERROR if the timeout is reached
300 * and this flag is not set. The timeout value is defined by the constant
301 * HSE_STARTUP_TIMEOUT in stm32f4xx.h file. You can tailor it depending
302 * on the HSE crystal used in your application.
303 * @param None
304 * @retval An ErrorStatus enumeration value:
305 * - SUCCESS: HSE oscillator is stable and ready to use
306 * - ERROR: HSE oscillator not yet ready
308 ErrorStatus RCC_WaitForHSEStartUp(void)
310 __IO uint32_t startupcounter = 0;
311 ErrorStatus status = ERROR;
312 FlagStatus hsestatus = RESET;
313 /* Wait till HSE is ready and if Time out is reached exit */
316 hsestatus = RCC_GetFlagStatus(RCC_FLAG_HSERDY);
317 startupcounter++;
318 } while((startupcounter != HSE_STARTUP_TIMEOUT) && (hsestatus == RESET));
320 if (RCC_GetFlagStatus(RCC_FLAG_HSERDY) != RESET)
322 status = SUCCESS;
324 else
326 status = ERROR;
328 return (status);
332 * @brief Adjusts the Internal High Speed oscillator (HSI) calibration value.
333 * @note The calibration is used to compensate for the variations in voltage
334 * and temperature that influence the frequency of the internal HSI RC.
335 * @param HSICalibrationValue: specifies the calibration trimming value.
336 * This parameter must be a number between 0 and 0x1F.
337 * @retval None
339 void RCC_AdjustHSICalibrationValue(uint8_t HSICalibrationValue)
341 uint32_t tmpreg = 0;
342 /* Check the parameters */
343 assert_param(IS_RCC_CALIBRATION_VALUE(HSICalibrationValue));
345 tmpreg = RCC->CR;
347 /* Clear HSITRIM[4:0] bits */
348 tmpreg &= ~RCC_CR_HSITRIM;
350 /* Set the HSITRIM[4:0] bits according to HSICalibrationValue value */
351 tmpreg |= (uint32_t)HSICalibrationValue << 3;
353 /* Store the new value */
354 RCC->CR = tmpreg;
358 * @brief Enables or disables the Internal High Speed oscillator (HSI).
359 * @note The HSI is stopped by hardware when entering STOP and STANDBY modes.
360 * It is used (enabled by hardware) as system clock source after startup
361 * from Reset, wakeup from STOP and STANDBY mode, or in case of failure
362 * of the HSE used directly or indirectly as system clock (if the Clock
363 * Security System CSS is enabled).
364 * @note HSI can not be stopped if it is used as system clock source. In this case,
365 * you have to select another source of the system clock then stop the HSI.
366 * @note After enabling the HSI, the application software should wait on HSIRDY
367 * flag to be set indicating that HSI clock is stable and can be used as
368 * system clock source.
369 * @param NewState: new state of the HSI.
370 * This parameter can be: ENABLE or DISABLE.
371 * @note When the HSI is stopped, HSIRDY flag goes low after 6 HSI oscillator
372 * clock cycles.
373 * @retval None
375 void RCC_HSICmd(FunctionalState NewState)
377 /* Check the parameters */
378 assert_param(IS_FUNCTIONAL_STATE(NewState));
380 *(__IO uint32_t *) CR_HSION_BB = (uint32_t)NewState;
384 * @brief Configures the External Low Speed oscillator (LSE).
385 * @note As the LSE is in the Backup domain and write access is denied to
386 * this domain after reset, you have to enable write access using
387 * PWR_BackupAccessCmd(ENABLE) function before to configure the LSE
388 * (to be done once after reset).
389 * @note After enabling the LSE (RCC_LSE_ON or RCC_LSE_Bypass), the application
390 * software should wait on LSERDY flag to be set indicating that LSE clock
391 * is stable and can be used to clock the RTC.
392 * @param RCC_LSE: specifies the new state of the LSE.
393 * This parameter can be one of the following values:
394 * @arg RCC_LSE_OFF: turn OFF the LSE oscillator, LSERDY flag goes low after
395 * 6 LSE oscillator clock cycles.
396 * @arg RCC_LSE_ON: turn ON the LSE oscillator
397 * @arg RCC_LSE_Bypass: LSE oscillator bypassed with external clock
398 * @retval None
400 void RCC_LSEConfig(uint8_t RCC_LSE)
402 /* Check the parameters */
403 assert_param(IS_RCC_LSE(RCC_LSE));
405 /* Reset LSEON and LSEBYP bits before configuring the LSE ------------------*/
406 /* Reset LSEON bit */
407 *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;
409 /* Reset LSEBYP bit */
410 *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_OFF;
412 /* Configure LSE (RCC_LSE_OFF is already covered by the code section above) */
413 switch (RCC_LSE)
415 case RCC_LSE_ON:
416 /* Set LSEON bit */
417 *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_ON;
418 break;
419 case RCC_LSE_Bypass:
420 /* Set LSEBYP and LSEON bits */
421 *(__IO uint8_t *) BDCR_ADDRESS = RCC_LSE_Bypass | RCC_LSE_ON;
422 break;
423 default:
424 break;
429 * @brief Enables or disables the Internal Low Speed oscillator (LSI).
430 * @note After enabling the LSI, the application software should wait on
431 * LSIRDY flag to be set indicating that LSI clock is stable and can
432 * be used to clock the IWDG and/or the RTC.
433 * @note LSI can not be disabled if the IWDG is running.
434 * @param NewState: new state of the LSI.
435 * This parameter can be: ENABLE or DISABLE.
436 * @note When the LSI is stopped, LSIRDY flag goes low after 6 LSI oscillator
437 * clock cycles.
438 * @retval None
440 void RCC_LSICmd(FunctionalState NewState)
442 /* Check the parameters */
443 assert_param(IS_FUNCTIONAL_STATE(NewState));
445 *(__IO uint32_t *) CSR_LSION_BB = (uint32_t)NewState;
448 #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F446xx) || defined(STM32F469_479xx)
450 * @brief Configures the main PLL clock source, multiplication and division factors.
451 * @note This function must be used only when the main PLL is disabled.
453 * @param RCC_PLLSource: specifies the PLL entry clock source.
454 * This parameter can be one of the following values:
455 * @arg RCC_PLLSource_HSI: HSI oscillator clock selected as PLL clock entry
456 * @arg RCC_PLLSource_HSE: HSE oscillator clock selected as PLL clock entry
457 * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
459 * @param PLLM: specifies the division factor for PLL VCO input clock
460 * This parameter must be a number between 0 and 63.
461 * @note You have to set the PLLM parameter correctly to ensure that the VCO input
462 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
463 * of 2 MHz to limit PLL jitter.
465 * @param PLLN: specifies the multiplication factor for PLL VCO output clock
466 * This parameter must be a number between 50 and 432.
467 * @note You have to set the PLLN parameter correctly to ensure that the VCO
468 * output frequency is between 100 and 432 MHz.
470 * @param PLLP: specifies the division factor for main system clock (SYSCLK)
471 * This parameter must be a number in the range {2, 4, 6, or 8}.
472 * @note You have to set the PLLP parameter correctly to not exceed 168 MHz on
473 * the System clock frequency.
475 * @param PLLQ: specifies the division factor for OTG FS, SDIO and RNG clocks
476 * This parameter must be a number between 4 and 15.
478 * @param PLLR: specifies the division factor for I2S, SAI, SYSTEM, SPDIF in STM32F446xx devices
479 * This parameter must be a number between 2 and 7.
481 * @note If the USB OTG FS is used in your application, you have to set the
482 * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
483 * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
484 * correctly.
486 * @retval None
488 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ, uint32_t PLLR)
490 /* Check the parameters */
491 assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
492 assert_param(IS_RCC_PLLM_VALUE(PLLM));
493 assert_param(IS_RCC_PLLN_VALUE(PLLN));
494 assert_param(IS_RCC_PLLP_VALUE(PLLP));
495 assert_param(IS_RCC_PLLQ_VALUE(PLLQ));
496 assert_param(IS_RCC_PLLR_VALUE(PLLR));
498 RCC->PLLCFGR = PLLM | (PLLN << 6) | (((PLLP >> 1) -1) << 16) | (RCC_PLLSource) |
499 (PLLQ << 24) | (PLLR << 28);
501 #endif /* STM32F410xx || STM32F412xG || STM32F446xx || STM32F469_479xx */
503 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
505 * @brief Configures the main PLL clock source, multiplication and division factors.
506 * @note This function must be used only when the main PLL is disabled.
508 * @param RCC_PLLSource: specifies the PLL entry clock source.
509 * This parameter can be one of the following values:
510 * @arg RCC_PLLSource_HSI: HSI oscillator clock selected as PLL clock entry
511 * @arg RCC_PLLSource_HSE: HSE oscillator clock selected as PLL clock entry
512 * @note This clock source (RCC_PLLSource) is common for the main PLL and PLLI2S.
514 * @param PLLM: specifies the division factor for PLL VCO input clock
515 * This parameter must be a number between 0 and 63.
516 * @note You have to set the PLLM parameter correctly to ensure that the VCO input
517 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
518 * of 2 MHz to limit PLL jitter.
520 * @param PLLN: specifies the multiplication factor for PLL VCO output clock
521 * This parameter must be a number between 50 and 432.
522 * @note You have to set the PLLN parameter correctly to ensure that the VCO
523 * output frequency is between 100 and 432 MHz.
525 * @param PLLP: specifies the division factor for main system clock (SYSCLK)
526 * This parameter must be a number in the range {2, 4, 6, or 8}.
527 * @note You have to set the PLLP parameter correctly to not exceed 168 MHz on
528 * the System clock frequency.
530 * @param PLLQ: specifies the division factor for OTG FS, SDIO and RNG clocks
531 * This parameter must be a number between 4 and 15.
532 * @note If the USB OTG FS is used in your application, you have to set the
533 * PLLQ parameter correctly to have 48 MHz clock for the USB. However,
534 * the SDIO and RNG need a frequency lower than or equal to 48 MHz to work
535 * correctly.
537 * @retval None
539 void RCC_PLLConfig(uint32_t RCC_PLLSource, uint32_t PLLM, uint32_t PLLN, uint32_t PLLP, uint32_t PLLQ)
541 /* Check the parameters */
542 assert_param(IS_RCC_PLL_SOURCE(RCC_PLLSource));
543 assert_param(IS_RCC_PLLM_VALUE(PLLM));
544 assert_param(IS_RCC_PLLN_VALUE(PLLN));
545 assert_param(IS_RCC_PLLP_VALUE(PLLP));
546 assert_param(IS_RCC_PLLQ_VALUE(PLLQ));
548 RCC->PLLCFGR = PLLM | (PLLN << 6) | (((PLLP >> 1) -1) << 16) | (RCC_PLLSource) |
549 (PLLQ << 24);
551 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE */
554 * @brief Enables or disables the main PLL.
555 * @note After enabling the main PLL, the application software should wait on
556 * PLLRDY flag to be set indicating that PLL clock is stable and can
557 * be used as system clock source.
558 * @note The main PLL can not be disabled if it is used as system clock source
559 * @note The main PLL is disabled by hardware when entering STOP and STANDBY modes.
560 * @param NewState: new state of the main PLL. This parameter can be: ENABLE or DISABLE.
561 * @retval None
563 void RCC_PLLCmd(FunctionalState NewState)
565 /* Check the parameters */
566 assert_param(IS_FUNCTIONAL_STATE(NewState));
567 *(__IO uint32_t *) CR_PLLON_BB = (uint32_t)NewState;
570 #if defined(STM32F40_41xxx) || defined(STM32F401xx)
572 * @brief Configures the PLLI2S clock multiplication and division factors.
574 * @note This function can be used only for STM32F405xx/407xx, STM32F415xx/417xx
575 * or STM32F401xx devices.
577 * @note This function must be used only when the PLLI2S is disabled.
578 * @note PLLI2S clock source is common with the main PLL (configured in
579 * RCC_PLLConfig function )
581 * @param PLLI2SN: specifies the multiplication factor for PLLI2S VCO output clock
582 * This parameter must be a number between 50 and 432.
583 * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
584 * output frequency is between 100 and 432 MHz.
586 * @param PLLI2SR: specifies the division factor for I2S clock
587 * This parameter must be a number between 2 and 7.
588 * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
589 * on the I2S clock frequency.
591 * @retval None
593 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR)
595 /* Check the parameters */
596 assert_param(IS_RCC_PLLI2SN_VALUE(PLLI2SN));
597 assert_param(IS_RCC_PLLI2SR_VALUE(PLLI2SR));
599 RCC->PLLI2SCFGR = (PLLI2SN << 6) | (PLLI2SR << 28);
601 #endif /* STM32F40_41xxx || STM32F401xx */
603 #if defined(STM32F411xE)
605 * @brief Configures the PLLI2S clock multiplication and division factors.
607 * @note This function can be used only for STM32F411xE devices.
609 * @note This function must be used only when the PLLI2S is disabled.
610 * @note PLLI2S clock source is common with the main PLL (configured in
611 * RCC_PLLConfig function )
613 * @param PLLI2SM: specifies the division factor for PLLI2S VCO input clock
614 * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
615 * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
616 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
617 * of 2 MHz to limit PLLI2S jitter.
619 * @param PLLI2SN: specifies the multiplication factor for PLLI2S VCO output clock
620 * This parameter must be a number between 50 and 432.
621 * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
622 * output frequency is between 100 and 432 MHz.
624 * @param PLLI2SR: specifies the division factor for I2S clock
625 * This parameter must be a number between 2 and 7.
626 * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
627 * on the I2S clock frequency.
629 * @retval None
631 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SR, uint32_t PLLI2SM)
633 /* Check the parameters */
634 assert_param(IS_RCC_PLLI2SN_VALUE(PLLI2SN));
635 assert_param(IS_RCC_PLLI2SM_VALUE(PLLI2SM));
636 assert_param(IS_RCC_PLLI2SR_VALUE(PLLI2SR));
638 RCC->PLLI2SCFGR = (PLLI2SN << 6) | (PLLI2SR << 28) | PLLI2SM;
640 #endif /* STM32F411xE */
642 #if defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
644 * @brief Configures the PLLI2S clock multiplication and division factors.
646 * @note This function can be used only for STM32F42xxx/43xxx devices
648 * @note This function must be used only when the PLLI2S is disabled.
649 * @note PLLI2S clock source is common with the main PLL (configured in
650 * RCC_PLLConfig function )
652 * @param PLLI2SN: specifies the multiplication factor for PLLI2S VCO output clock
653 * This parameter must be a number between 50 and 432.
654 * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
655 * output frequency is between 100 and 432 MHz.
657 * @param PLLI2SQ: specifies the division factor for SAI1 clock
658 * This parameter must be a number between 2 and 15.
660 * @param PLLI2SR: specifies the division factor for I2S clock
661 * This parameter must be a number between 2 and 7.
662 * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
663 * on the I2S clock frequency.
665 * @retval None
667 void RCC_PLLI2SConfig(uint32_t PLLI2SN, uint32_t PLLI2SQ, uint32_t PLLI2SR)
669 /* Check the parameters */
670 assert_param(IS_RCC_PLLI2SN_VALUE(PLLI2SN));
671 assert_param(IS_RCC_PLLI2SQ_VALUE(PLLI2SQ));
672 assert_param(IS_RCC_PLLI2SR_VALUE(PLLI2SR));
674 RCC->PLLI2SCFGR = (PLLI2SN << 6) | (PLLI2SQ << 24) | (PLLI2SR << 28);
676 #endif /* STM32F427_437xx || STM32F429_439xx || STM32F469_479xx */
678 #if defined(STM32F412xG ) || defined(STM32F446xx)
680 * @brief Configures the PLLI2S clock multiplication and division factors.
682 * @note This function can be used only for STM32F446xx devices
684 * @note This function must be used only when the PLLI2S is disabled.
685 * @note PLLI2S clock source is common with the main PLL (configured in
686 * RCC_PLLConfig function )
688 * @param PLLI2SM: specifies the division factor for PLLI2S VCO input clock
689 * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
690 * @note You have to set the PLLI2SM parameter correctly to ensure that the VCO input
691 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
692 * of 2 MHz to limit PLLI2S jitter.
694 * @param PLLI2SN: specifies the multiplication factor for PLLI2S VCO output clock
695 * This parameter must be a number between 50 and 432.
696 * @note You have to set the PLLI2SN parameter correctly to ensure that the VCO
697 * output frequency is between 100 and 432 MHz.
699 * @param PLLI2SP: specifies the division factor for PLL 48Mhz clock output
700 * This parameter must be a number in the range {2, 4, 6, or 8}.
702 * @param PLLI2SQ: specifies the division factor for SAI1 clock
703 * This parameter must be a number between 2 and 15.
705 * @param PLLI2SR: specifies the division factor for I2S clock
706 * This parameter must be a number between 2 and 7.
707 * @note You have to set the PLLI2SR parameter correctly to not exceed 192 MHz
708 * on the I2S clock frequency.
709 * @note the PLLI2SR parameter is only available with STM32F42xxx/43xxx devices.
711 * @retval None
713 void RCC_PLLI2SConfig(uint32_t PLLI2SM, uint32_t PLLI2SN, uint32_t PLLI2SP, uint32_t PLLI2SQ, uint32_t PLLI2SR)
715 /* Check the parameters */
716 assert_param(IS_RCC_PLLI2SM_VALUE(PLLI2SM));
717 assert_param(IS_RCC_PLLI2SN_VALUE(PLLI2SN));
718 assert_param(IS_RCC_PLLI2SP_VALUE(PLLI2SP));
719 assert_param(IS_RCC_PLLI2SQ_VALUE(PLLI2SQ));
720 assert_param(IS_RCC_PLLI2SR_VALUE(PLLI2SR));
722 RCC->PLLI2SCFGR = PLLI2SM | (PLLI2SN << 6) | (((PLLI2SP >> 1) -1) << 16) | (PLLI2SQ << 24) | (PLLI2SR << 28);
724 #endif /* STM32F412xG || STM32F446xx */
727 * @brief Enables or disables the PLLI2S.
728 * @note The PLLI2S is disabled by hardware when entering STOP and STANDBY modes.
729 * @param NewState: new state of the PLLI2S. This parameter can be: ENABLE or DISABLE.
730 * @retval None
732 void RCC_PLLI2SCmd(FunctionalState NewState)
734 /* Check the parameters */
735 assert_param(IS_FUNCTIONAL_STATE(NewState));
736 *(__IO uint32_t *) CR_PLLI2SON_BB = (uint32_t)NewState;
739 #if defined(STM32F469_479xx)
741 * @brief Configures the PLLSAI clock multiplication and division factors.
743 * @note This function can be used only for STM32F469_479xx devices
745 * @note This function must be used only when the PLLSAI is disabled.
746 * @note PLLSAI clock source is common with the main PLL (configured in
747 * RCC_PLLConfig function )
749 * @param PLLSAIN: specifies the multiplication factor for PLLSAI VCO output clock
750 * This parameter must be a number between 50 and 432.
751 * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
752 * output frequency is between 100 and 432 MHz.
754 * @param PLLSAIP: specifies the division factor for PLL 48Mhz clock output
755 * This parameter must be a number in the range {2, 4, 6, or 8}..
757 * @param PLLSAIQ: specifies the division factor for SAI1 clock
758 * This parameter must be a number between 2 and 15.
760 * @param PLLSAIR: specifies the division factor for LTDC clock
761 * This parameter must be a number between 2 and 7.
763 * @retval None
765 void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIP, uint32_t PLLSAIQ, uint32_t PLLSAIR)
767 /* Check the parameters */
768 assert_param(IS_RCC_PLLSAIN_VALUE(PLLSAIN));
769 assert_param(IS_RCC_PLLSAIP_VALUE(PLLSAIP));
770 assert_param(IS_RCC_PLLSAIQ_VALUE(PLLSAIQ));
771 assert_param(IS_RCC_PLLSAIR_VALUE(PLLSAIR));
773 RCC->PLLSAICFGR = (PLLSAIN << 6) | (((PLLSAIP >> 1) -1) << 16) | (PLLSAIQ << 24) | (PLLSAIR << 28);
775 #endif /* STM32F469_479xx */
777 #if defined(STM32F446xx)
779 * @brief Configures the PLLSAI clock multiplication and division factors.
781 * @note This function can be used only for STM32F446xx devices
783 * @note This function must be used only when the PLLSAI is disabled.
784 * @note PLLSAI clock source is common with the main PLL (configured in
785 * RCC_PLLConfig function )
787 * @param PLLSAIM: specifies the division factor for PLLSAI VCO input clock
788 * This parameter must be a number between Min_Data = 2 and Max_Data = 63.
789 * @note You have to set the PLLSAIM parameter correctly to ensure that the VCO input
790 * frequency ranges from 1 to 2 MHz. It is recommended to select a frequency
791 * of 2 MHz to limit PLLSAI jitter.
793 * @param PLLSAIN: specifies the multiplication factor for PLLSAI VCO output clock
794 * This parameter must be a number between 50 and 432.
795 * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
796 * output frequency is between 100 and 432 MHz.
798 * @param PLLSAIP: specifies the division factor for PLL 48Mhz clock output
799 * This parameter must be a number in the range {2, 4, 6, or 8}.
801 * @param PLLSAIQ: specifies the division factor for SAI1 clock
802 * This parameter must be a number between 2 and 15.
804 * @retval None
806 void RCC_PLLSAIConfig(uint32_t PLLSAIM, uint32_t PLLSAIN, uint32_t PLLSAIP, uint32_t PLLSAIQ)
808 /* Check the parameters */
809 assert_param(IS_RCC_PLLSAIM_VALUE(PLLSAIM));
810 assert_param(IS_RCC_PLLSAIN_VALUE(PLLSAIN));
811 assert_param(IS_RCC_PLLSAIP_VALUE(PLLSAIP));
812 assert_param(IS_RCC_PLLSAIQ_VALUE(PLLSAIQ));
814 RCC->PLLSAICFGR = PLLSAIM | (PLLSAIN << 6) | (((PLLSAIP >> 1) -1) << 16) | (PLLSAIQ << 24);
816 #endif /* STM32F446xx */
818 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE)
820 * @brief Configures the PLLSAI clock multiplication and division factors.
822 * @note This function can be used only for STM32F42xxx/43xxx devices
824 * @note This function must be used only when the PLLSAI is disabled.
825 * @note PLLSAI clock source is common with the main PLL (configured in
826 * RCC_PLLConfig function )
828 * @param PLLSAIN: specifies the multiplication factor for PLLSAI VCO output clock
829 * This parameter must be a number between 50 and 432.
830 * @note You have to set the PLLSAIN parameter correctly to ensure that the VCO
831 * output frequency is between 100 and 432 MHz.
833 * @param PLLSAIQ: specifies the division factor for SAI1 clock
834 * This parameter must be a number between 2 and 15.
836 * @param PLLSAIR: specifies the division factor for LTDC clock
837 * This parameter must be a number between 2 and 7.
839 * @retval None
841 void RCC_PLLSAIConfig(uint32_t PLLSAIN, uint32_t PLLSAIQ, uint32_t PLLSAIR)
843 /* Check the parameters */
844 assert_param(IS_RCC_PLLSAIN_VALUE(PLLSAIN));
845 assert_param(IS_RCC_PLLSAIR_VALUE(PLLSAIR));
846 assert_param(IS_RCC_PLLSAIQ_VALUE(PLLSAIQ));
848 RCC->PLLSAICFGR = (PLLSAIN << 6) | (PLLSAIQ << 24) | (PLLSAIR << 28);
850 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE */
853 * @brief Enables or disables the PLLSAI.
855 * @note This function can be used only for STM32F42xxx/43xxx/446xx/469xx/479xx devices
857 * @note The PLLSAI is disabled by hardware when entering STOP and STANDBY modes.
858 * @param NewState: new state of the PLLSAI. This parameter can be: ENABLE or DISABLE.
859 * @retval None
861 void RCC_PLLSAICmd(FunctionalState NewState)
863 /* Check the parameters */
864 assert_param(IS_FUNCTIONAL_STATE(NewState));
865 *(__IO uint32_t *) CR_PLLSAION_BB = (uint32_t)NewState;
869 * @brief Enables or disables the Clock Security System.
870 * @note If a failure is detected on the HSE oscillator clock, this oscillator
871 * is automatically disabled and an interrupt is generated to inform the
872 * software about the failure (Clock Security System Interrupt, CSSI),
873 * allowing the MCU to perform rescue operations. The CSSI is linked to
874 * the Cortex-M4 NMI (Non-Maskable Interrupt) exception vector.
875 * @param NewState: new state of the Clock Security System.
876 * This parameter can be: ENABLE or DISABLE.
877 * @retval None
879 void RCC_ClockSecuritySystemCmd(FunctionalState NewState)
881 /* Check the parameters */
882 assert_param(IS_FUNCTIONAL_STATE(NewState));
883 *(__IO uint32_t *) CR_CSSON_BB = (uint32_t)NewState;
887 * @brief Selects the clock source to output on MCO1 pin(PA8).
888 * @note PA8 should be configured in alternate function mode.
889 * @param RCC_MCO1Source: specifies the clock source to output.
890 * This parameter can be one of the following values:
891 * @arg RCC_MCO1Source_HSI: HSI clock selected as MCO1 source
892 * @arg RCC_MCO1Source_LSE: LSE clock selected as MCO1 source
893 * @arg RCC_MCO1Source_HSE: HSE clock selected as MCO1 source
894 * @arg RCC_MCO1Source_PLLCLK: main PLL clock selected as MCO1 source
895 * @param RCC_MCO1Div: specifies the MCO1 prescaler.
896 * This parameter can be one of the following values:
897 * @arg RCC_MCO1Div_1: no division applied to MCO1 clock
898 * @arg RCC_MCO1Div_2: division by 2 applied to MCO1 clock
899 * @arg RCC_MCO1Div_3: division by 3 applied to MCO1 clock
900 * @arg RCC_MCO1Div_4: division by 4 applied to MCO1 clock
901 * @arg RCC_MCO1Div_5: division by 5 applied to MCO1 clock
902 * @retval None
904 void RCC_MCO1Config(uint32_t RCC_MCO1Source, uint32_t RCC_MCO1Div)
906 uint32_t tmpreg = 0;
908 /* Check the parameters */
909 assert_param(IS_RCC_MCO1SOURCE(RCC_MCO1Source));
910 assert_param(IS_RCC_MCO1DIV(RCC_MCO1Div));
912 tmpreg = RCC->CFGR;
914 /* Clear MCO1[1:0] and MCO1PRE[2:0] bits */
915 tmpreg &= CFGR_MCO1_RESET_MASK;
917 /* Select MCO1 clock source and prescaler */
918 tmpreg |= RCC_MCO1Source | RCC_MCO1Div;
920 /* Store the new value */
921 RCC->CFGR = tmpreg;
923 #if defined(STM32F410xx)
924 RCC_MCO1Cmd(ENABLE);
925 #endif /* STM32F410xx */
929 * @brief Selects the clock source to output on MCO2 pin(PC9).
930 * @note PC9 should be configured in alternate function mode.
931 * @param RCC_MCO2Source: specifies the clock source to output.
932 * This parameter can be one of the following values:
933 * @arg RCC_MCO2Source_SYSCLK: System clock (SYSCLK) selected as MCO2 source
934 * @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source, available for all STM32F4 devices except STM32F410xx
935 * @arg RCC_MCO2SOURCE_I2SCLK: I2SCLK clock selected as MCO2 source, available only for STM32F410xx devices
936 * @arg RCC_MCO2Source_HSE: HSE clock selected as MCO2 source
937 * @arg RCC_MCO2Source_PLLCLK: main PLL clock selected as MCO2 source
938 * @param RCC_MCO2Div: specifies the MCO2 prescaler.
939 * This parameter can be one of the following values:
940 * @arg RCC_MCO2Div_1: no division applied to MCO2 clock
941 * @arg RCC_MCO2Div_2: division by 2 applied to MCO2 clock
942 * @arg RCC_MCO2Div_3: division by 3 applied to MCO2 clock
943 * @arg RCC_MCO2Div_4: division by 4 applied to MCO2 clock
944 * @arg RCC_MCO2Div_5: division by 5 applied to MCO2 clock
945 * @note For STM32F410xx devices to output I2SCLK clock on MCO2 you should have
946 * at last one of the SPI clocks enabled (SPI1, SPI2 or SPI5).
947 * @retval None
949 void RCC_MCO2Config(uint32_t RCC_MCO2Source, uint32_t RCC_MCO2Div)
951 uint32_t tmpreg = 0;
953 /* Check the parameters */
954 assert_param(IS_RCC_MCO2SOURCE(RCC_MCO2Source));
955 assert_param(IS_RCC_MCO2DIV(RCC_MCO2Div));
957 tmpreg = RCC->CFGR;
959 /* Clear MCO2 and MCO2PRE[2:0] bits */
960 tmpreg &= CFGR_MCO2_RESET_MASK;
962 /* Select MCO2 clock source and prescaler */
963 tmpreg |= RCC_MCO2Source | RCC_MCO2Div;
965 /* Store the new value */
966 RCC->CFGR = tmpreg;
968 #if defined(STM32F410xx)
969 RCC_MCO2Cmd(ENABLE);
970 #endif /* STM32F410xx */
974 * @}
977 /** @defgroup RCC_Group2 System AHB and APB busses clocks configuration functions
978 * @brief System, AHB and APB busses clocks configuration functions
980 @verbatim
981 ===============================================================================
982 ##### System, AHB and APB busses clocks configuration functions #####
983 ===============================================================================
984 [..]
985 This section provide functions allowing to configure the System, AHB, APB1 and
986 APB2 busses clocks.
988 (#) Several clock sources can be used to drive the System clock (SYSCLK): HSI,
989 HSE and PLL.
990 The AHB clock (HCLK) is derived from System clock through configurable
991 prescaler and used to clock the CPU, memory and peripherals mapped
992 on AHB bus (DMA, GPIO...). APB1 (PCLK1) and APB2 (PCLK2) clocks are derived
993 from AHB clock through configurable prescalers and used to clock
994 the peripherals mapped on these busses. You can use
995 "RCC_GetClocksFreq()" function to retrieve the frequencies of these clocks.
997 -@- All the peripheral clocks are derived from the System clock (SYSCLK) except:
998 (+@) I2S: the I2S clock can be derived either from a specific PLL (PLLI2S) or
999 from an external clock mapped on the I2S_CKIN pin.
1000 You have to use RCC_I2SCLKConfig() function to configure this clock.
1001 (+@) RTC: the RTC clock can be derived either from the LSI, LSE or HSE clock
1002 divided by 2 to 31. You have to use RCC_RTCCLKConfig() and RCC_RTCCLKCmd()
1003 functions to configure this clock.
1004 (+@) USB OTG FS, SDIO and RTC: USB OTG FS require a frequency equal to 48 MHz
1005 to work correctly, while the SDIO require a frequency equal or lower than
1006 to 48. This clock is derived of the main PLL through PLLQ divider.
1007 (+@) IWDG clock which is always the LSI clock.
1009 (#) For STM32F405xx/407xx and STM32F415xx/417xx devices, the maximum frequency
1010 of the SYSCLK and HCLK is 168 MHz, PCLK2 84 MHz and PCLK1 42 MHz. Depending
1011 on the device voltage range, the maximum frequency should be adapted accordingly:
1012 +-------------------------------------------------------------------------------------+
1013 | Latency | HCLK clock frequency (MHz) |
1014 | |---------------------------------------------------------------------|
1015 | | voltage range | voltage range | voltage range | voltage range |
1016 | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V |
1017 |---------------|----------------|----------------|-----------------|-----------------|
1018 |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 |
1019 |---------------|----------------|----------------|-----------------|-----------------|
1020 |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 |
1021 |---------------|----------------|----------------|-----------------|-----------------|
1022 |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 |
1023 |---------------|----------------|----------------|-----------------|-----------------|
1024 |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 |
1025 |---------------|----------------|----------------|-----------------|-----------------|
1026 |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 |
1027 |---------------|----------------|----------------|-----------------|-----------------|
1028 |5WS(6CPU cycle)|150< HCLK <= 168|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120|
1029 |---------------|----------------|----------------|-----------------|-----------------|
1030 |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140|
1031 |---------------|----------------|----------------|-----------------|-----------------|
1032 |7WS(8CPU cycle)| NA | NA |154 < HCLK <= 168|140 < HCLK <= 160|
1033 +---------------|----------------|----------------|-----------------|-----------------+
1034 (#) For STM32F42xxx/43xxx/469xx/479xx devices, the maximum frequency of the SYSCLK and HCLK is 180 MHz,
1035 PCLK2 90 MHz and PCLK1 45 MHz. Depending on the device voltage range, the maximum
1036 frequency should be adapted accordingly:
1037 +-------------------------------------------------------------------------------------+
1038 | Latency | HCLK clock frequency (MHz) |
1039 | |---------------------------------------------------------------------|
1040 | | voltage range | voltage range | voltage range | voltage range |
1041 | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V |
1042 |---------------|----------------|----------------|-----------------|-----------------|
1043 |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 |
1044 |---------------|----------------|----------------|-----------------|-----------------|
1045 |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 |
1046 |---------------|----------------|----------------|-----------------|-----------------|
1047 |2WS(3CPU cycle)|60 < HCLK <= 90 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 |
1048 |---------------|----------------|----------------|-----------------|-----------------|
1049 |3WS(4CPU cycle)|90 < HCLK <= 120|72 < HCLK <= 96 |66 < HCLK <= 88 |60 < HCLK <= 80 |
1050 |---------------|----------------|----------------|-----------------|-----------------|
1051 |4WS(5CPU cycle)|120< HCLK <= 150|96 < HCLK <= 120|88 < HCLK <= 110 |80 < HCLK <= 100 |
1052 |---------------|----------------|----------------|-----------------|-----------------|
1053 |5WS(6CPU cycle)|120< HCLK <= 180|120< HCLK <= 144|110 < HCLK <= 132|100 < HCLK <= 120|
1054 |---------------|----------------|----------------|-----------------|-----------------|
1055 |6WS(7CPU cycle)| NA |144< HCLK <= 168|132 < HCLK <= 154|120 < HCLK <= 140|
1056 |---------------|----------------|----------------|-----------------|-----------------|
1057 |7WS(8CPU cycle)| NA |168< HCLK <= 180|154 < HCLK <= 176|140 < HCLK <= 160|
1058 |---------------|----------------|----------------|-----------------|-----------------|
1059 |8WS(9CPU cycle)| NA | NA |176 < HCLK <= 180|160 < HCLK <= 168|
1060 +-------------------------------------------------------------------------------------+
1062 (#) For STM32F401xx devices, the maximum frequency of the SYSCLK and HCLK is 84 MHz,
1063 PCLK2 84 MHz and PCLK1 42 MHz. Depending on the device voltage range, the maximum
1064 frequency should be adapted accordingly:
1065 +-------------------------------------------------------------------------------------+
1066 | Latency | HCLK clock frequency (MHz) |
1067 | |---------------------------------------------------------------------|
1068 | | voltage range | voltage range | voltage range | voltage range |
1069 | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V |
1070 |---------------|----------------|----------------|-----------------|-----------------|
1071 |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 22 |0 < HCLK <= 20 |
1072 |---------------|----------------|----------------|-----------------|-----------------|
1073 |1WS(2CPU cycle)|30 < HCLK <= 60 |24 < HCLK <= 48 |22 < HCLK <= 44 |20 < HCLK <= 40 |
1074 |---------------|----------------|----------------|-----------------|-----------------|
1075 |2WS(3CPU cycle)|60 < HCLK <= 84 |48 < HCLK <= 72 |44 < HCLK <= 66 |40 < HCLK <= 60 |
1076 |---------------|----------------|----------------|-----------------|-----------------|
1077 |3WS(4CPU cycle)| NA |72 < HCLK <= 84 |66 < HCLK <= 84 |60 < HCLK <= 80 |
1078 |---------------|----------------|----------------|-----------------|-----------------|
1079 |4WS(5CPU cycle)| NA | NA | NA |80 < HCLK <= 84 |
1080 +-------------------------------------------------------------------------------------+
1082 (#) For STM32F410xx/STM32F411xE devices, the maximum frequency of the SYSCLK and HCLK is 100 MHz,
1083 PCLK2 100 MHz and PCLK1 50 MHz. Depending on the device voltage range, the maximum
1084 frequency should be adapted accordingly:
1085 +-------------------------------------------------------------------------------------+
1086 | Latency | HCLK clock frequency (MHz) |
1087 | |---------------------------------------------------------------------|
1088 | | voltage range | voltage range | voltage range | voltage range |
1089 | | 2.7 V - 3.6 V | 2.4 V - 2.7 V | 2.1 V - 2.4 V | 1.8 V - 2.1 V |
1090 |---------------|----------------|----------------|-----------------|-----------------|
1091 |0WS(1CPU cycle)|0 < HCLK <= 30 |0 < HCLK <= 24 |0 < HCLK <= 18 |0 < HCLK <= 16 |
1092 |---------------|----------------|----------------|-----------------|-----------------|
1093 |1WS(2CPU cycle)|30 < HCLK <= 64 |24 < HCLK <= 48 |18 < HCLK <= 36 |16 < HCLK <= 32 |
1094 |---------------|----------------|----------------|-----------------|-----------------|
1095 |2WS(3CPU cycle)|64 < HCLK <= 90 |48 < HCLK <= 72 |36 < HCLK <= 54 |32 < HCLK <= 48 |
1096 |---------------|----------------|----------------|-----------------|-----------------|
1097 |3WS(4CPU cycle)|90 < HCLK <= 100|72 < HCLK <= 96 |54 < HCLK <= 72 |48 < HCLK <= 64 |
1098 |---------------|----------------|----------------|-----------------|-----------------|
1099 |4WS(5CPU cycle)| NA |96 < HCLK <= 100|72 < HCLK <= 90 |64 < HCLK <= 80 |
1100 |---------------|----------------|----------------|-----------------|-----------------|
1101 |5WS(6CPU cycle)| NA | NA |90 < HCLK <= 100 |80 < HCLK <= 96 |
1102 |---------------|----------------|----------------|-----------------|-----------------|
1103 |6WS(7CPU cycle)| NA | NA | NA |96 < HCLK <= 100 |
1104 +-------------------------------------------------------------------------------------+
1106 -@- On STM32F405xx/407xx and STM32F415xx/417xx devices:
1107 (++) when VOS = '0', the maximum value of fHCLK = 144MHz.
1108 (++) when VOS = '1', the maximum value of fHCLK = 168MHz.
1109 [..]
1110 On STM32F42xxx/43xxx/469xx/479xx devices:
1111 (++) when VOS[1:0] = '0x01', the maximum value of fHCLK is 120MHz.
1112 (++) when VOS[1:0] = '0x10', the maximum value of fHCLK is 144MHz.
1113 (++) when VOS[1:0] = '0x11', the maximum value of f is 168MHz
1114 [..]
1115 On STM32F401x devices:
1116 (++) when VOS[1:0] = '0x01', the maximum value of fHCLK is 64MHz.
1117 (++) when VOS[1:0] = '0x10', the maximum value of fHCLK is 84MHz.
1118 On STM32F410xx/STM32F411xE devices:
1119 (++) when VOS[1:0] = '0x01' the maximum value of fHCLK is 64MHz.
1120 (++) when VOS[1:0] = '0x10' the maximum value of fHCLK is 84MHz.
1121 (++) when VOS[1:0] = '0x11' the maximum value of fHCLK is 100MHz.
1123 You can use PWR_MainRegulatorModeConfig() function to control VOS bits.
1125 @endverbatim
1126 * @{
1130 * @brief Configures the system clock (SYSCLK).
1131 * @note The HSI is used (enabled by hardware) as system clock source after
1132 * startup from Reset, wake-up from STOP and STANDBY mode, or in case
1133 * of failure of the HSE used directly or indirectly as system clock
1134 * (if the Clock Security System CSS is enabled).
1135 * @note A switch from one clock source to another occurs only if the target
1136 * clock source is ready (clock stable after startup delay or PLL locked).
1137 * If a clock source which is not yet ready is selected, the switch will
1138 * occur when the clock source will be ready.
1139 * You can use RCC_GetSYSCLKSource() function to know which clock is
1140 * currently used as system clock source.
1141 * @param RCC_SYSCLKSource: specifies the clock source used as system clock.
1142 * This parameter can be one of the following values:
1143 * @arg RCC_SYSCLKSource_HSI: HSI selected as system clock source
1144 * @arg RCC_SYSCLKSource_HSE: HSE selected as system clock source
1145 * @arg RCC_SYSCLKSource_PLLCLK: PLL selected as system clock source (RCC_SYSCLKSource_PLLPCLK for STM32F446xx devices)
1146 * @arg RCC_SYSCLKSource_PLLRCLK: PLL R selected as system clock source only for STM32F412xG and STM32F446xx devices
1147 * @retval None
1149 void RCC_SYSCLKConfig(uint32_t RCC_SYSCLKSource)
1151 uint32_t tmpreg = 0;
1153 /* Check the parameters */
1154 assert_param(IS_RCC_SYSCLK_SOURCE(RCC_SYSCLKSource));
1156 tmpreg = RCC->CFGR;
1158 /* Clear SW[1:0] bits */
1159 tmpreg &= ~RCC_CFGR_SW;
1161 /* Set SW[1:0] bits according to RCC_SYSCLKSource value */
1162 tmpreg |= RCC_SYSCLKSource;
1164 /* Store the new value */
1165 RCC->CFGR = tmpreg;
1169 * @brief Returns the clock source used as system clock.
1170 * @param None
1171 * @retval The clock source used as system clock. The returned value can be one
1172 * of the following:
1173 * - 0x00: HSI used as system clock
1174 * - 0x04: HSE used as system clock
1175 * - 0x08: PLL used as system clock (PLL P for STM32F446xx devices)
1176 * - 0x0C: PLL R used as system clock (only for STM32F412xG and STM32F446xx devices)
1178 uint8_t RCC_GetSYSCLKSource(void)
1180 return ((uint8_t)(RCC->CFGR & RCC_CFGR_SWS));
1184 * @brief Configures the AHB clock (HCLK).
1185 * @note Depending on the device voltage range, the software has to set correctly
1186 * these bits to ensure that HCLK not exceed the maximum allowed frequency
1187 * (for more details refer to section above
1188 * "CPU, AHB and APB busses clocks configuration functions")
1189 * @param RCC_SYSCLK: defines the AHB clock divider. This clock is derived from
1190 * the system clock (SYSCLK).
1191 * This parameter can be one of the following values:
1192 * @arg RCC_SYSCLK_Div1: AHB clock = SYSCLK
1193 * @arg RCC_SYSCLK_Div2: AHB clock = SYSCLK/2
1194 * @arg RCC_SYSCLK_Div4: AHB clock = SYSCLK/4
1195 * @arg RCC_SYSCLK_Div8: AHB clock = SYSCLK/8
1196 * @arg RCC_SYSCLK_Div16: AHB clock = SYSCLK/16
1197 * @arg RCC_SYSCLK_Div64: AHB clock = SYSCLK/64
1198 * @arg RCC_SYSCLK_Div128: AHB clock = SYSCLK/128
1199 * @arg RCC_SYSCLK_Div256: AHB clock = SYSCLK/256
1200 * @arg RCC_SYSCLK_Div512: AHB clock = SYSCLK/512
1201 * @retval None
1203 void RCC_HCLKConfig(uint32_t RCC_SYSCLK)
1205 uint32_t tmpreg = 0;
1207 /* Check the parameters */
1208 assert_param(IS_RCC_HCLK(RCC_SYSCLK));
1210 tmpreg = RCC->CFGR;
1212 /* Clear HPRE[3:0] bits */
1213 tmpreg &= ~RCC_CFGR_HPRE;
1215 /* Set HPRE[3:0] bits according to RCC_SYSCLK value */
1216 tmpreg |= RCC_SYSCLK;
1218 /* Store the new value */
1219 RCC->CFGR = tmpreg;
1223 * @brief Configures the Low Speed APB clock (PCLK1).
1224 * @param RCC_HCLK: defines the APB1 clock divider. This clock is derived from
1225 * the AHB clock (HCLK).
1226 * This parameter can be one of the following values:
1227 * @arg RCC_HCLK_Div1: APB1 clock = HCLK
1228 * @arg RCC_HCLK_Div2: APB1 clock = HCLK/2
1229 * @arg RCC_HCLK_Div4: APB1 clock = HCLK/4
1230 * @arg RCC_HCLK_Div8: APB1 clock = HCLK/8
1231 * @arg RCC_HCLK_Div16: APB1 clock = HCLK/16
1232 * @retval None
1234 void RCC_PCLK1Config(uint32_t RCC_HCLK)
1236 uint32_t tmpreg = 0;
1238 /* Check the parameters */
1239 assert_param(IS_RCC_PCLK(RCC_HCLK));
1241 tmpreg = RCC->CFGR;
1243 /* Clear PPRE1[2:0] bits */
1244 tmpreg &= ~RCC_CFGR_PPRE1;
1246 /* Set PPRE1[2:0] bits according to RCC_HCLK value */
1247 tmpreg |= RCC_HCLK;
1249 /* Store the new value */
1250 RCC->CFGR = tmpreg;
1254 * @brief Configures the High Speed APB clock (PCLK2).
1255 * @param RCC_HCLK: defines the APB2 clock divider. This clock is derived from
1256 * the AHB clock (HCLK).
1257 * This parameter can be one of the following values:
1258 * @arg RCC_HCLK_Div1: APB2 clock = HCLK
1259 * @arg RCC_HCLK_Div2: APB2 clock = HCLK/2
1260 * @arg RCC_HCLK_Div4: APB2 clock = HCLK/4
1261 * @arg RCC_HCLK_Div8: APB2 clock = HCLK/8
1262 * @arg RCC_HCLK_Div16: APB2 clock = HCLK/16
1263 * @retval None
1265 void RCC_PCLK2Config(uint32_t RCC_HCLK)
1267 uint32_t tmpreg = 0;
1269 /* Check the parameters */
1270 assert_param(IS_RCC_PCLK(RCC_HCLK));
1272 tmpreg = RCC->CFGR;
1274 /* Clear PPRE2[2:0] bits */
1275 tmpreg &= ~RCC_CFGR_PPRE2;
1277 /* Set PPRE2[2:0] bits according to RCC_HCLK value */
1278 tmpreg |= RCC_HCLK << 3;
1280 /* Store the new value */
1281 RCC->CFGR = tmpreg;
1285 * @brief Returns the frequencies of different on chip clocks; SYSCLK, HCLK,
1286 * PCLK1 and PCLK2.
1288 * @note The system frequency computed by this function is not the real
1289 * frequency in the chip. It is calculated based on the predefined
1290 * constant and the selected clock source:
1291 * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(*)
1292 * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(**)
1293 * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(**)
1294 * or HSI_VALUE(*) multiplied/divided by the PLL factors.
1295 * @note (*) HSI_VALUE is a constant defined in stm32f4xx.h file (default value
1296 * 16 MHz) but the real value may vary depending on the variations
1297 * in voltage and temperature.
1298 * @note (**) HSE_VALUE is a constant defined in stm32f4xx.h file (default value
1299 * 25 MHz), user has to ensure that HSE_VALUE is same as the real
1300 * frequency of the crystal used. Otherwise, this function may
1301 * have wrong result.
1303 * @note The result of this function could be not correct when using fractional
1304 * value for HSE crystal.
1306 * @param RCC_Clocks: pointer to a RCC_ClocksTypeDef structure which will hold
1307 * the clocks frequencies.
1309 * @note This function can be used by the user application to compute the
1310 * baudrate for the communication peripherals or configure other parameters.
1311 * @note Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function
1312 * must be called to update the structure's field. Otherwise, any
1313 * configuration based on this function will be incorrect.
1315 * @retval None
1317 void RCC_GetClocksFreq(RCC_ClocksTypeDef* RCC_Clocks)
1319 uint32_t tmp = 0, presc = 0, pllvco = 0, pllp = 2, pllsource = 0, pllm = 2;
1320 #if defined(STM32F412xG) || defined(STM32F446xx)
1321 uint32_t pllr = 2;
1322 #endif /* STM32F412xG || STM32F446xx */
1324 /* Get SYSCLK source -------------------------------------------------------*/
1325 tmp = RCC->CFGR & RCC_CFGR_SWS;
1327 switch (tmp)
1329 case 0x00: /* HSI used as system clock source */
1330 RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
1331 break;
1332 case 0x04: /* HSE used as system clock source */
1333 RCC_Clocks->SYSCLK_Frequency = HSE_VALUE;
1334 break;
1335 case 0x08: /* PLL P used as system clock source */
1337 /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN
1338 SYSCLK = PLL_VCO / PLLP
1340 pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
1341 pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
1343 if (pllsource != 0)
1345 /* HSE used as PLL clock source */
1346 pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
1348 else
1350 /* HSI used as PLL clock source */
1351 pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
1354 pllp = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLP) >>16) + 1 ) *2;
1355 RCC_Clocks->SYSCLK_Frequency = pllvco/pllp;
1356 break;
1358 #if defined(STM32F412xG) || defined(STM32F446xx)
1359 case 0x0C: /* PLL R used as system clock source */
1360 /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN
1361 SYSCLK = PLL_VCO / PLLR
1363 pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC) >> 22;
1364 pllm = RCC->PLLCFGR & RCC_PLLCFGR_PLLM;
1366 if (pllsource != 0)
1368 /* HSE used as PLL clock source */
1369 pllvco = (HSE_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
1371 else
1373 /* HSI used as PLL clock source */
1374 pllvco = (HSI_VALUE / pllm) * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 6);
1377 pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >>28) + 1 ) *2;
1378 RCC_Clocks->SYSCLK_Frequency = pllvco/pllr;
1379 break;
1380 #endif /* STM32F412xG || STM32F446xx */
1382 default:
1383 RCC_Clocks->SYSCLK_Frequency = HSI_VALUE;
1384 break;
1386 /* Compute HCLK, PCLK1 and PCLK2 clocks frequencies ------------------------*/
1388 /* Get HCLK prescaler */
1389 tmp = RCC->CFGR & RCC_CFGR_HPRE;
1390 tmp = tmp >> 4;
1391 presc = APBAHBPrescTable[tmp];
1392 /* HCLK clock frequency */
1393 RCC_Clocks->HCLK_Frequency = RCC_Clocks->SYSCLK_Frequency >> presc;
1395 /* Get PCLK1 prescaler */
1396 tmp = RCC->CFGR & RCC_CFGR_PPRE1;
1397 tmp = tmp >> 10;
1398 presc = APBAHBPrescTable[tmp];
1399 /* PCLK1 clock frequency */
1400 RCC_Clocks->PCLK1_Frequency = RCC_Clocks->HCLK_Frequency >> presc;
1402 /* Get PCLK2 prescaler */
1403 tmp = RCC->CFGR & RCC_CFGR_PPRE2;
1404 tmp = tmp >> 13;
1405 presc = APBAHBPrescTable[tmp];
1406 /* PCLK2 clock frequency */
1407 RCC_Clocks->PCLK2_Frequency = RCC_Clocks->HCLK_Frequency >> presc;
1411 * @}
1414 /** @defgroup RCC_Group3 Peripheral clocks configuration functions
1415 * @brief Peripheral clocks configuration functions
1417 @verbatim
1418 ===============================================================================
1419 ##### Peripheral clocks configuration functions #####
1420 ===============================================================================
1421 [..] This section provide functions allowing to configure the Peripheral clocks.
1423 (#) The RTC clock which is derived from the LSI, LSE or HSE clock divided
1424 by 2 to 31.
1426 (#) After restart from Reset or wakeup from STANDBY, all peripherals are off
1427 except internal SRAM, Flash and JTAG. Before to start using a peripheral
1428 you have to enable its interface clock. You can do this using
1429 RCC_AHBPeriphClockCmd(), RCC_APB2PeriphClockCmd() and RCC_APB1PeriphClockCmd() functions.
1431 (#) To reset the peripherals configuration (to the default state after device reset)
1432 you can use RCC_AHBPeriphResetCmd(), RCC_APB2PeriphResetCmd() and
1433 RCC_APB1PeriphResetCmd() functions.
1435 (#) To further reduce power consumption in SLEEP mode the peripheral clocks
1436 can be disabled prior to executing the WFI or WFE instructions.
1437 You can do this using RCC_AHBPeriphClockLPModeCmd(),
1438 RCC_APB2PeriphClockLPModeCmd() and RCC_APB1PeriphClockLPModeCmd() functions.
1440 @endverbatim
1441 * @{
1445 * @brief Configures the RTC clock (RTCCLK).
1446 * @note As the RTC clock configuration bits are in the Backup domain and write
1447 * access is denied to this domain after reset, you have to enable write
1448 * access using PWR_BackupAccessCmd(ENABLE) function before to configure
1449 * the RTC clock source (to be done once after reset).
1450 * @note Once the RTC clock is configured it can't be changed unless the
1451 * Backup domain is reset using RCC_BackupResetCmd() function, or by
1452 * a Power On Reset (POR).
1454 * @param RCC_RTCCLKSource: specifies the RTC clock source.
1455 * This parameter can be one of the following values:
1456 * @arg RCC_RTCCLKSource_LSE: LSE selected as RTC clock
1457 * @arg RCC_RTCCLKSource_LSI: LSI selected as RTC clock
1458 * @arg RCC_RTCCLKSource_HSE_Divx: HSE clock divided by x selected
1459 * as RTC clock, where x:[2,31]
1461 * @note If the LSE or LSI is used as RTC clock source, the RTC continues to
1462 * work in STOP and STANDBY modes, and can be used as wakeup source.
1463 * However, when the HSE clock is used as RTC clock source, the RTC
1464 * cannot be used in STOP and STANDBY modes.
1465 * @note The maximum input clock frequency for RTC is 1MHz (when using HSE as
1466 * RTC clock source).
1468 * @retval None
1470 void RCC_RTCCLKConfig(uint32_t RCC_RTCCLKSource)
1472 uint32_t tmpreg = 0;
1474 /* Check the parameters */
1475 assert_param(IS_RCC_RTCCLK_SOURCE(RCC_RTCCLKSource));
1477 if ((RCC_RTCCLKSource & 0x00000300) == 0x00000300)
1478 { /* If HSE is selected as RTC clock source, configure HSE division factor for RTC clock */
1479 tmpreg = RCC->CFGR;
1481 /* Clear RTCPRE[4:0] bits */
1482 tmpreg &= ~RCC_CFGR_RTCPRE;
1484 /* Configure HSE division factor for RTC clock */
1485 tmpreg |= (RCC_RTCCLKSource & 0xFFFFCFF);
1487 /* Store the new value */
1488 RCC->CFGR = tmpreg;
1491 /* Select the RTC clock source */
1492 RCC->BDCR |= (RCC_RTCCLKSource & 0x00000FFF);
1496 * @brief Enables or disables the RTC clock.
1497 * @note This function must be used only after the RTC clock source was selected
1498 * using the RCC_RTCCLKConfig function.
1499 * @param NewState: new state of the RTC clock. This parameter can be: ENABLE or DISABLE.
1500 * @retval None
1502 void RCC_RTCCLKCmd(FunctionalState NewState)
1504 /* Check the parameters */
1505 assert_param(IS_FUNCTIONAL_STATE(NewState));
1507 *(__IO uint32_t *) BDCR_RTCEN_BB = (uint32_t)NewState;
1511 * @brief Forces or releases the Backup domain reset.
1512 * @note This function resets the RTC peripheral (including the backup registers)
1513 * and the RTC clock source selection in RCC_CSR register.
1514 * @note The BKPSRAM is not affected by this reset.
1515 * @param NewState: new state of the Backup domain reset.
1516 * This parameter can be: ENABLE or DISABLE.
1517 * @retval None
1519 void RCC_BackupResetCmd(FunctionalState NewState)
1521 /* Check the parameters */
1522 assert_param(IS_FUNCTIONAL_STATE(NewState));
1523 *(__IO uint32_t *) BDCR_BDRST_BB = (uint32_t)NewState;
1526 #if defined (STM32F412xG) || defined(STM32F446xx)
1528 * @brief Configures the I2S clock source (I2SCLK).
1529 * @note This function must be called before enabling the I2S APB clock.
1531 * @param RCC_I2SAPBx: specifies the APBx I2S clock source.
1532 * This parameter can be one of the following values:
1533 * @arg RCC_I2SBus_APB1: I2S peripheral instance is on APB1 Bus
1534 * @arg RCC_I2SBus_APB2: I2S peripheral instance is on APB2 Bus
1536 * @param RCC_I2SCLKSource: specifies the I2S clock source.
1537 * This parameter can be one of the following values:
1538 * @arg RCC_I2SCLKSource_PLLI2S: PLLI2S clock used as I2S clock source
1539 * @arg RCC_I2SCLKSource_Ext: External clock mapped on the I2S_CKIN pin
1540 * used as I2S clock source
1541 * @arg RCC_I2SCLKSource_PLL: PLL clock used as I2S clock source
1542 * @arg RCC_I2SCLKSource_HSI_HSE: HSI or HSE depends on PLLSRC used as I2S clock source
1543 * @retval None
1545 void RCC_I2SCLKConfig(uint32_t RCC_I2SAPBx, uint32_t RCC_I2SCLKSource)
1547 /* Check the parameters */
1548 assert_param(IS_RCC_I2SCLK_SOURCE(RCC_I2SCLKSource));
1549 assert_param(IS_RCC_I2S_APBx(RCC_I2SAPBx));
1551 if(RCC_I2SAPBx == RCC_I2SBus_APB1)
1553 /* Clear APB1 I2Sx clock source selection bits */
1554 RCC->DCKCFGR &= ~RCC_DCKCFGR_I2S1SRC;
1555 /* Set new APB1 I2Sx clock source*/
1556 RCC->DCKCFGR |= RCC_I2SCLKSource;
1558 else
1560 /* Clear APB2 I2Sx clock source selection bits */
1561 RCC->DCKCFGR &= ~RCC_DCKCFGR_I2S2SRC;
1562 /* Set new APB2 I2Sx clock source */
1563 RCC->DCKCFGR |= (RCC_I2SCLKSource << 2);
1566 #if defined(STM32F446xx)
1568 * @brief Configures the SAIx clock source (SAIxCLK).
1569 * @note This function must be called before enabling the SAIx APB clock.
1571 * @param RCC_SAIInstance: specifies the SAIx clock source.
1572 * This parameter can be one of the following values:
1573 * @arg RCC_SAIInstance_SAI1: SAI1 clock source selection
1574 * @arg RCC_SAIInstance_SAI2: SAI2 clock source selections
1576 * @param RCC_SAICLKSource: specifies the SAI clock source.
1577 * This parameter can be one of the following values:
1578 * @arg RCC_SAICLKSource_PLLSAI: PLLSAI clock used as SAI clock source
1579 * @arg RCC_SAICLKSource_PLLI2S: PLLI2S clock used as SAI clock source
1580 * @arg RCC_SAICLKSource_PLL: PLL clock used as SAI clock source
1581 * @arg RCC_SAICLKSource_HSI_HSE: HSI or HSE depends on PLLSRC used as SAI clock source
1582 * @retval None
1584 void RCC_SAICLKConfig(uint32_t RCC_SAIInstance, uint32_t RCC_SAICLKSource)
1586 /* Check the parameters */
1587 assert_param(IS_RCC_SAICLK_SOURCE(RCC_SAICLKSource));
1588 assert_param(IS_RCC_SAI_INSTANCE(RCC_SAIInstance));
1590 if(RCC_SAIInstance == RCC_SAIInstance_SAI1)
1592 /* Clear SAI1 clock source selection bits */
1593 RCC->DCKCFGR &= ~RCC_DCKCFGR_SAI1SRC;
1594 /* Set new SAI1 clock source */
1595 RCC->DCKCFGR |= RCC_SAICLKSource;
1597 else
1599 /* Clear SAI2 clock source selection bits */
1600 RCC->DCKCFGR &= ~RCC_DCKCFGR_SAI2SRC;
1601 /* Set new SAI2 clock source */
1602 RCC->DCKCFGR |= (RCC_SAICLKSource << 2);
1605 #endif /* STM32F446xx */
1606 #endif /* STM32F412xG || STM32F446xx */
1608 #if defined(STM32F410xx)
1610 * @brief Configures the I2S clock source (I2SCLK).
1611 * @note This function must be called before enabling the I2S clock.
1613 * @param RCC_I2SCLKSource: specifies the I2S clock source.
1614 * This parameter can be one of the following values:
1615 * @arg RCC_I2SAPBCLKSOURCE_PLLR: PLL VCO output clock divided by PLLR.
1616 * @arg RCC_I2SAPBCLKSOURCE_EXT: External clock mapped on the I2S_CKIN pin.
1617 * @arg RCC_I2SAPBCLKSOURCE_PLLSRC: HSI/HSE depends on PLLSRC.
1618 * @retval None
1620 void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource)
1622 /* Check the parameters */
1623 assert_param(IS_RCC_I2SCLK_SOURCE(RCC_I2SCLKSource));
1625 /* Clear I2Sx clock source selection bits */
1626 RCC->DCKCFGR &= ~RCC_DCKCFGR_I2SSRC;
1627 /* Set new I2Sx clock source*/
1628 RCC->DCKCFGR |= RCC_I2SCLKSource;
1630 #endif /* STM32F410xx */
1632 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F401xx) || defined(STM32F411xE) || defined(STM32F469_479xx)
1634 * @brief Configures the I2S clock source (I2SCLK).
1635 * @note This function must be called before enabling the I2S APB clock.
1636 * @param RCC_I2SCLKSource: specifies the I2S clock source.
1637 * This parameter can be one of the following values:
1638 * @arg RCC_I2S2CLKSource_PLLI2S: PLLI2S clock used as I2S clock source
1639 * @arg RCC_I2S2CLKSource_Ext: External clock mapped on the I2S_CKIN pin
1640 * used as I2S clock source
1641 * @retval None
1643 void RCC_I2SCLKConfig(uint32_t RCC_I2SCLKSource)
1645 /* Check the parameters */
1646 assert_param(IS_RCC_I2SCLK_SOURCE(RCC_I2SCLKSource));
1648 *(__IO uint32_t *) CFGR_I2SSRC_BB = RCC_I2SCLKSource;
1650 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F401xx || STM32F411xE || STM32F469_479xx */
1652 #if defined(STM32F40_41xxx) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F469_479xx)
1654 * @brief Configures SAI1BlockA clock source selection.
1656 * @note This function can be used only for STM32F42xxx/43xxx/446xx/469xx/479xx devices.
1658 * @note This function must be called before enabling PLLSAI, PLLI2S and
1659 * the SAI clock.
1660 * @param RCC_SAIBlockACLKSource: specifies the SAI Block A clock source.
1661 * This parameter can be one of the following values:
1662 * @arg RCC_SAIACLKSource_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
1663 * as SAI1 Block A clock
1664 * @arg RCC_SAIACLKSource_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
1665 * as SAI1 Block A clock
1666 * @arg RCC_SAIACLKSource_Ext: External clock mapped on the I2S_CKIN pin
1667 * used as SAI1 Block A clock
1668 * @retval None
1670 void RCC_SAIBlockACLKConfig(uint32_t RCC_SAIBlockACLKSource)
1672 uint32_t tmpreg = 0;
1674 /* Check the parameters */
1675 assert_param(IS_RCC_SAIACLK_SOURCE(RCC_SAIBlockACLKSource));
1677 tmpreg = RCC->DCKCFGR;
1679 /* Clear RCC_DCKCFGR_SAI1ASRC[1:0] bits */
1680 tmpreg &= ~RCC_DCKCFGR_SAI1ASRC;
1682 /* Set SAI Block A source selection value */
1683 tmpreg |= RCC_SAIBlockACLKSource;
1685 /* Store the new value */
1686 RCC->DCKCFGR = tmpreg;
1690 * @brief Configures SAI1BlockB clock source selection.
1692 * @note This function can be used only for STM32F42xxx/43xxx/446xx/469xx/479xx devices.
1694 * @note This function must be called before enabling PLLSAI, PLLI2S and
1695 * the SAI clock.
1696 * @param RCC_SAIBlockBCLKSource: specifies the SAI Block B clock source.
1697 * This parameter can be one of the following values:
1698 * @arg RCC_SAIBCLKSource_PLLI2S: PLLI2S_Q clock divided by PLLI2SDIVQ used
1699 * as SAI1 Block B clock
1700 * @arg RCC_SAIBCLKSource_PLLSAI: PLLISAI_Q clock divided by PLLSAIDIVQ used
1701 * as SAI1 Block B clock
1702 * @arg RCC_SAIBCLKSource_Ext: External clock mapped on the I2S_CKIN pin
1703 * used as SAI1 Block B clock
1704 * @retval None
1706 void RCC_SAIBlockBCLKConfig(uint32_t RCC_SAIBlockBCLKSource)
1708 uint32_t tmpreg = 0;
1710 /* Check the parameters */
1711 assert_param(IS_RCC_SAIBCLK_SOURCE(RCC_SAIBlockBCLKSource));
1713 tmpreg = RCC->DCKCFGR;
1715 /* Clear RCC_DCKCFGR_SAI1BSRC[1:0] bits */
1716 tmpreg &= ~RCC_DCKCFGR_SAI1BSRC;
1718 /* Set SAI Block B source selection value */
1719 tmpreg |= RCC_SAIBlockBCLKSource;
1721 /* Store the new value */
1722 RCC->DCKCFGR = tmpreg;
1724 #endif /* STM32F40_41xxx || STM32F427_437xx || STM32F429_439xx || STM32F469_479xx */
1727 * @brief Configures the SAI clock Divider coming from PLLI2S.
1729 * @note This function can be used only for STM32F42xxx/43xxx/446xx/469xx/479xx devices.
1731 * @note This function must be called before enabling the PLLI2S.
1733 * @param RCC_PLLI2SDivQ: specifies the PLLI2S division factor for SAI1 clock .
1734 * This parameter must be a number between 1 and 32.
1735 * SAI1 clock frequency = f(PLLI2S_Q) / RCC_PLLI2SDivQ
1737 * @retval None
1739 void RCC_SAIPLLI2SClkDivConfig(uint32_t RCC_PLLI2SDivQ)
1741 uint32_t tmpreg = 0;
1743 /* Check the parameters */
1744 assert_param(IS_RCC_PLLI2S_DIVQ_VALUE(RCC_PLLI2SDivQ));
1746 tmpreg = RCC->DCKCFGR;
1748 /* Clear PLLI2SDIVQ[4:0] bits */
1749 tmpreg &= ~(RCC_DCKCFGR_PLLI2SDIVQ);
1751 /* Set PLLI2SDIVQ values */
1752 tmpreg |= (RCC_PLLI2SDivQ - 1);
1754 /* Store the new value */
1755 RCC->DCKCFGR = tmpreg;
1759 * @brief Configures the SAI clock Divider coming from PLLSAI.
1761 * @note This function can be used only for STM32F42xxx/43xxx/446xx/469xx/479xx devices.
1763 * @note This function must be called before enabling the PLLSAI.
1765 * @param RCC_PLLSAIDivQ: specifies the PLLSAI division factor for SAI1 clock .
1766 * This parameter must be a number between 1 and 32.
1767 * SAI1 clock frequency = f(PLLSAI_Q) / RCC_PLLSAIDivQ
1769 * @retval None
1771 void RCC_SAIPLLSAIClkDivConfig(uint32_t RCC_PLLSAIDivQ)
1773 uint32_t tmpreg = 0;
1775 /* Check the parameters */
1776 assert_param(IS_RCC_PLLSAI_DIVQ_VALUE(RCC_PLLSAIDivQ));
1778 tmpreg = RCC->DCKCFGR;
1780 /* Clear PLLI2SDIVQ[4:0] and PLLSAIDIVQ[4:0] bits */
1781 tmpreg &= ~(RCC_DCKCFGR_PLLSAIDIVQ);
1783 /* Set PLLSAIDIVQ values */
1784 tmpreg |= ((RCC_PLLSAIDivQ - 1) << 8);
1786 /* Store the new value */
1787 RCC->DCKCFGR = tmpreg;
1791 * @brief Configures the LTDC clock Divider coming from PLLSAI.
1793 * @note The LTDC peripheral is only available with STM32F42xxx/43xxx/446xx/469xx/479xx Devices.
1795 * @note This function must be called before enabling the PLLSAI.
1797 * @param RCC_PLLSAIDivR: specifies the PLLSAI division factor for LTDC clock .
1798 * LTDC clock frequency = f(PLLSAI_R) / RCC_PLLSAIDivR
1799 * This parameter can be one of the following values:
1800 * @arg RCC_PLLSAIDivR_Div2: LTDC clock = f(PLLSAI_R)/2
1801 * @arg RCC_PLLSAIDivR_Div4: LTDC clock = f(PLLSAI_R)/4
1802 * @arg RCC_PLLSAIDivR_Div8: LTDC clock = f(PLLSAI_R)/8
1803 * @arg RCC_PLLSAIDivR_Div16: LTDC clock = f(PLLSAI_R)/16
1805 * @retval None
1807 void RCC_LTDCCLKDivConfig(uint32_t RCC_PLLSAIDivR)
1809 uint32_t tmpreg = 0;
1811 /* Check the parameters */
1812 assert_param(IS_RCC_PLLSAI_DIVR_VALUE(RCC_PLLSAIDivR));
1814 tmpreg = RCC->DCKCFGR;
1816 /* Clear PLLSAIDIVR[2:0] bits */
1817 tmpreg &= ~RCC_DCKCFGR_PLLSAIDIVR;
1819 /* Set PLLSAIDIVR values */
1820 tmpreg |= RCC_PLLSAIDivR;
1822 /* Store the new value */
1823 RCC->DCKCFGR = tmpreg;
1826 #if defined(STM32F412xG)
1828 * @brief Configures the DFSDM clock source (DFSDMCLK).
1829 * @note This function must be called before enabling the DFSDM APB clock.
1830 * @param RCC_DFSDMCLKSource: specifies the DFSDM clock source.
1831 * This parameter can be one of the following values:
1832 * @arg RCC_DFSDM1CLKSource_APB: APB clock used as DFSDM clock source.
1833 * @arg RCC_DFSDM1CLKSource_SYS: System clock used as DFSDM clock source.
1835 * @retval None
1837 void RCC_DFSDM1CLKConfig(uint32_t RCC_DFSDM1CLKSource)
1839 uint32_t tmpreg = 0;
1841 /* Check the parameters */
1842 assert_param(IS_RCC_DFSDM1CLK_SOURCE(RCC_DFSDM1CLKSource));
1844 tmpreg = RCC->DCKCFGR;
1846 /* Clear CKDFSDM-SEL bit */
1847 tmpreg &= ~RCC_DCKCFGR_CKDFSDM1SEL;
1849 /* Set CKDFSDM-SEL bit according to RCC_DFSDMCLKSource value */
1850 tmpreg |= (RCC_DFSDM1CLKSource << 31) ;
1852 /* Store the new value */
1853 RCC->DCKCFGR = tmpreg;
1857 * @brief Configures the DFSDM Audio clock source (DFSDMACLK).
1858 * @note This function must be called before enabling the DFSDM APB clock.
1859 * @param RCC_DFSDMACLKSource: specifies the DFSDM clock source.
1860 * This parameter can be one of the following values:
1861 * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB1: APB clock used as DFSDM clock source.
1862 * @arg RCC_DFSDM1AUDIOCLKSOURCE_I2SAPB2: System clock used as DFSDM clock source.
1864 * @retval None
1866 void RCC_DFSDM1ACLKConfig(uint32_t RCC_DFSDMACLKSource)
1868 uint32_t tmpreg = 0;
1870 /* Check the parameters */
1871 assert_param(IS_RCC_DFSDMACLK_SOURCE(RCC_DFSDMACLKSource));
1873 tmpreg = RCC->DCKCFGR;
1875 /* Clear CKDFSDMA SEL bit */
1876 tmpreg &= ~RCC_DCKCFGR_CKDFSDM1ASEL;
1878 /* Set CKDFSDM-SEL bt according to RCC_DFSDMCLKSource value */
1879 tmpreg |= RCC_DFSDMACLKSource;
1881 /* Store the new value */
1882 RCC->DCKCFGR = tmpreg;
1884 #endif /* STM32F412xG */
1887 * @brief Configures the Timers clocks prescalers selection.
1889 * @note This function can be used only for STM32F42xxx/43xxx and STM32F401xx/411xE devices.
1891 * @param RCC_TIMCLKPrescaler : specifies the Timers clocks prescalers selection
1892 * This parameter can be one of the following values:
1893 * @arg RCC_TIMPrescDesactivated: The Timers kernels clocks prescaler is
1894 * equal to HPRE if PPREx is corresponding to division by 1 or 2,
1895 * else it is equal to [(HPRE * PPREx) / 2] if PPREx is corresponding to
1896 * division by 4 or more.
1898 * @arg RCC_TIMPrescActivated: The Timers kernels clocks prescaler is
1899 * equal to HPRE if PPREx is corresponding to division by 1, 2 or 4,
1900 * else it is equal to [(HPRE * PPREx) / 4] if PPREx is corresponding
1901 * to division by 8 or more.
1902 * @retval None
1904 void RCC_TIMCLKPresConfig(uint32_t RCC_TIMCLKPrescaler)
1906 /* Check the parameters */
1907 assert_param(IS_RCC_TIMCLK_PRESCALER(RCC_TIMCLKPrescaler));
1909 *(__IO uint32_t *) DCKCFGR_TIMPRE_BB = RCC_TIMCLKPrescaler;
1913 * @brief Enables or disables the AHB1 peripheral clock.
1914 * @note After reset, the peripheral clock (used for registers read/write access)
1915 * is disabled and the application software has to enable this clock before
1916 * using it.
1917 * @param RCC_AHBPeriph: specifies the AHB1 peripheral to gates its clock.
1918 * This parameter can be any combination of the following values:
1919 * @arg RCC_AHB1Periph_GPIOA: GPIOA clock
1920 * @arg RCC_AHB1Periph_GPIOB: GPIOB clock
1921 * @arg RCC_AHB1Periph_GPIOC: GPIOC clock
1922 * @arg RCC_AHB1Periph_GPIOD: GPIOD clock
1923 * @arg RCC_AHB1Periph_GPIOE: GPIOE clock
1924 * @arg RCC_AHB1Periph_GPIOF: GPIOF clock
1925 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
1926 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
1927 * @arg RCC_AHB1Periph_GPIOI: GPIOI clock
1928 * @arg RCC_AHB1Periph_GPIOJ: GPIOJ clock (STM32F42xxx/43xxx devices)
1929 * @arg RCC_AHB1Periph_GPIOK: GPIOK clock (STM32F42xxx/43xxx devices)
1930 * @arg RCC_AHB1Periph_CRC: CRC clock
1931 * @arg RCC_AHB1Periph_BKPSRAM: BKPSRAM interface clock
1932 * @arg RCC_AHB1Periph_CCMDATARAMEN CCM data RAM interface clock
1933 * @arg RCC_AHB1Periph_DMA1: DMA1 clock
1934 * @arg RCC_AHB1Periph_DMA2: DMA2 clock
1935 * @arg RCC_AHB1Periph_DMA2D: DMA2D clock (STM32F429xx/439xx devices)
1936 * @arg RCC_AHB1Periph_ETH_MAC: Ethernet MAC clock
1937 * @arg RCC_AHB1Periph_ETH_MAC_Tx: Ethernet Transmission clock
1938 * @arg RCC_AHB1Periph_ETH_MAC_Rx: Ethernet Reception clock
1939 * @arg RCC_AHB1Periph_ETH_MAC_PTP: Ethernet PTP clock
1940 * @arg RCC_AHB1Periph_OTG_HS: USB OTG HS clock
1941 * @arg RCC_AHB1Periph_OTG_HS_ULPI: USB OTG HS ULPI clock
1942 * @param NewState: new state of the specified peripheral clock.
1943 * This parameter can be: ENABLE or DISABLE.
1944 * @retval None
1946 void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
1948 /* Check the parameters */
1949 assert_param(IS_RCC_AHB1_CLOCK_PERIPH(RCC_AHB1Periph));
1951 assert_param(IS_FUNCTIONAL_STATE(NewState));
1952 if (NewState != DISABLE)
1954 RCC->AHB1ENR |= RCC_AHB1Periph;
1956 else
1958 RCC->AHB1ENR &= ~RCC_AHB1Periph;
1963 * @brief Enables or disables the AHB2 peripheral clock.
1964 * @note After reset, the peripheral clock (used for registers read/write access)
1965 * is disabled and the application software has to enable this clock before
1966 * using it.
1967 * @param RCC_AHBPeriph: specifies the AHB2 peripheral to gates its clock.
1968 * This parameter can be any combination of the following values:
1969 * @arg RCC_AHB2Periph_DCMI: DCMI clock
1970 * @arg RCC_AHB2Periph_CRYP: CRYP clock
1971 * @arg RCC_AHB2Periph_HASH: HASH clock
1972 * @arg RCC_AHB2Periph_RNG: RNG clock
1973 * @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock
1974 * @param NewState: new state of the specified peripheral clock.
1975 * This parameter can be: ENABLE or DISABLE.
1976 * @retval None
1978 void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
1980 /* Check the parameters */
1981 assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));
1982 assert_param(IS_FUNCTIONAL_STATE(NewState));
1984 if (NewState != DISABLE)
1986 RCC->AHB2ENR |= RCC_AHB2Periph;
1988 else
1990 RCC->AHB2ENR &= ~RCC_AHB2Periph;
1994 #if defined(STM32F40_41xxx) || defined(STM32F412xG) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
1996 * @brief Enables or disables the AHB3 peripheral clock.
1997 * @note After reset, the peripheral clock (used for registers read/write access)
1998 * is disabled and the application software has to enable this clock before
1999 * using it.
2000 * @param RCC_AHBPeriph: specifies the AHB3 peripheral to gates its clock.
2001 * This parameter must be:
2002 * - RCC_AHB3Periph_FSMC or RCC_AHB3Periph_FMC (STM32F412xG/STM32F429x/439x devices)
2003 * - RCC_AHB3Periph_QSPI (STM32F412xG/STM32F446xx/STM32F469_479xx devices)
2004 * @param NewState: new state of the specified peripheral clock.
2005 * This parameter can be: ENABLE or DISABLE.
2006 * @retval None
2008 void RCC_AHB3PeriphClockCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
2010 /* Check the parameters */
2011 assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));
2012 assert_param(IS_FUNCTIONAL_STATE(NewState));
2014 if (NewState != DISABLE)
2016 RCC->AHB3ENR |= RCC_AHB3Periph;
2018 else
2020 RCC->AHB3ENR &= ~RCC_AHB3Periph;
2023 #endif /* STM32F40_41xxx || STM32F412xG || STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
2026 * @brief Enables or disables the Low Speed APB (APB1) peripheral clock.
2027 * @note After reset, the peripheral clock (used for registers read/write access)
2028 * is disabled and the application software has to enable this clock before
2029 * using it.
2030 * @param RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.
2031 * This parameter can be any combination of the following values:
2032 * @arg RCC_APB1Periph_TIM2: TIM2 clock
2033 * @arg RCC_APB1Periph_TIM3: TIM3 clock
2034 * @arg RCC_APB1Periph_TIM4: TIM4 clock
2035 * @arg RCC_APB1Periph_TIM5: TIM5 clock
2036 * @arg RCC_APB1Periph_TIM6: TIM6 clock
2037 * @arg RCC_APB1Periph_TIM7: TIM7 clock
2038 * @arg RCC_APB1Periph_TIM12: TIM12 clock
2039 * @arg RCC_APB1Periph_TIM13: TIM13 clock
2040 * @arg RCC_APB1Periph_TIM14: TIM14 clock
2041 * @arg RCC_APB1Periph_LPTIM1: LPTIM1 clock (STM32F410xx devices)
2042 * @arg RCC_APB1Periph_WWDG: WWDG clock
2043 * @arg RCC_APB1Periph_SPI2: SPI2 clock
2044 * @arg RCC_APB1Periph_SPI3: SPI3 clock
2045 * @arg RCC_APB1Periph_SPDIF: SPDIF RX clock (STM32F446xx devices)
2046 * @arg RCC_APB1Periph_USART2: USART2 clock
2047 * @arg RCC_APB1Periph_USART3: USART3 clock
2048 * @arg RCC_APB1Periph_UART4: UART4 clock
2049 * @arg RCC_APB1Periph_UART5: UART5 clock
2050 * @arg RCC_APB1Periph_I2C1: I2C1 clock
2051 * @arg RCC_APB1Periph_I2C2: I2C2 clock
2052 * @arg RCC_APB1Periph_I2C3: I2C3 clock
2053 * @arg RCC_APB1Periph_FMPI2C1: FMPI2C1 clock
2054 * @arg RCC_APB1Periph_CAN1: CAN1 clock
2055 * @arg RCC_APB1Periph_CAN2: CAN2 clock
2056 * @arg RCC_APB1Periph_CEC: CEC clock (STM32F446xx devices)
2057 * @arg RCC_APB1Periph_PWR: PWR clock
2058 * @arg RCC_APB1Periph_DAC: DAC clock
2059 * @arg RCC_APB1Periph_UART7: UART7 clock
2060 * @arg RCC_APB1Periph_UART8: UART8 clock
2061 * @param NewState: new state of the specified peripheral clock.
2062 * This parameter can be: ENABLE or DISABLE.
2063 * @retval None
2065 void RCC_APB1PeriphClockCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
2067 /* Check the parameters */
2068 assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
2069 assert_param(IS_FUNCTIONAL_STATE(NewState));
2071 if (NewState != DISABLE)
2073 RCC->APB1ENR |= RCC_APB1Periph;
2075 else
2077 RCC->APB1ENR &= ~RCC_APB1Periph;
2082 * @brief Enables or disables the High Speed APB (APB2) peripheral clock.
2083 * @note After reset, the peripheral clock (used for registers read/write access)
2084 * is disabled and the application software has to enable this clock before
2085 * using it.
2086 * @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
2087 * This parameter can be any combination of the following values:
2088 * @arg RCC_APB2Periph_TIM1: TIM1 clock
2089 * @arg RCC_APB2Periph_TIM8: TIM8 clock
2090 * @arg RCC_APB2Periph_USART1: USART1 clock
2091 * @arg RCC_APB2Periph_USART6: USART6 clock
2092 * @arg RCC_APB2Periph_ADC1: ADC1 clock
2093 * @arg RCC_APB2Periph_ADC2: ADC2 clock
2094 * @arg RCC_APB2Periph_ADC3: ADC3 clock
2095 * @arg RCC_APB2Periph_SDIO: SDIO clock
2096 * @arg RCC_APB2Periph_SPI1: SPI1 clock
2097 * @arg RCC_APB2Periph_SPI4: SPI4 clock
2098 * @arg RCC_APB2Periph_SYSCFG: SYSCFG clock
2099 * @arg RCC_APB2Periph_TIM9: TIM9 clock
2100 * @arg RCC_APB2Periph_TIM10: TIM10 clock
2101 * @arg RCC_APB2Periph_TIM11: TIM11 clock
2102 * @arg RCC_APB2Periph_SPI5: SPI5 clock
2103 * @arg RCC_APB2Periph_SPI6: SPI6 clock
2104 * @arg RCC_APB2Periph_SAI1: SAI1 clock (STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2105 * @arg RCC_APB2Periph_SAI2: SAI2 clock (STM32F446xx devices)
2106 * @arg RCC_APB2Periph_LTDC: LTDC clock (STM32F429xx/439xx devices)
2107 * @arg RCC_APB2Periph_DSI: DSI clock (STM32F469_479xx devices)
2108 * @arg RCC_APB2Periph_DFSDM: DFSDM Clock (STM32F412xG Devices)
2109 * @param NewState: new state of the specified peripheral clock.
2110 * This parameter can be: ENABLE or DISABLE.
2111 * @retval None
2113 void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
2115 /* Check the parameters */
2116 assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
2117 assert_param(IS_FUNCTIONAL_STATE(NewState));
2119 if (NewState != DISABLE)
2121 RCC->APB2ENR |= RCC_APB2Periph;
2123 else
2125 RCC->APB2ENR &= ~RCC_APB2Periph;
2130 * @brief Forces or releases AHB1 peripheral reset.
2131 * @param RCC_AHB1Periph: specifies the AHB1 peripheral to reset.
2132 * This parameter can be any combination of the following values:
2133 * @arg RCC_AHB1Periph_GPIOA: GPIOA clock
2134 * @arg RCC_AHB1Periph_GPIOB: GPIOB clock
2135 * @arg RCC_AHB1Periph_GPIOC: GPIOC clock
2136 * @arg RCC_AHB1Periph_GPIOD: GPIOD clock
2137 * @arg RCC_AHB1Periph_GPIOE: GPIOE clock
2138 * @arg RCC_AHB1Periph_GPIOF: GPIOF clock
2139 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
2140 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
2141 * @arg RCC_AHB1Periph_GPIOI: GPIOI clock
2142 * @arg RCC_AHB1Periph_GPIOJ: GPIOJ clock (STM32F42xxx/43xxx devices)
2143 * @arg RCC_AHB1Periph_GPIOK: GPIOK clock (STM32F42xxx/43xxxdevices)
2144 * @arg RCC_AHB1Periph_CRC: CRC clock
2145 * @arg RCC_AHB1Periph_DMA1: DMA1 clock
2146 * @arg RCC_AHB1Periph_DMA2: DMA2 clock
2147 * @arg RCC_AHB1Periph_DMA2D: DMA2D clock (STM32F429xx/439xx devices)
2148 * @arg RCC_AHB1Periph_ETH_MAC: Ethernet MAC clock
2149 * @arg RCC_AHB1Periph_OTG_HS: USB OTG HS clock
2150 * @arg RCC_AHB1Periph_RNG: RNG clock for STM32F410xx devices
2152 * @param NewState: new state of the specified peripheral reset.
2153 * This parameter can be: ENABLE or DISABLE.
2154 * @retval None
2156 void RCC_AHB1PeriphResetCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
2158 /* Check the parameters */
2159 assert_param(IS_RCC_AHB1_RESET_PERIPH(RCC_AHB1Periph));
2160 assert_param(IS_FUNCTIONAL_STATE(NewState));
2162 if (NewState != DISABLE)
2164 RCC->AHB1RSTR |= RCC_AHB1Periph;
2166 else
2168 RCC->AHB1RSTR &= ~RCC_AHB1Periph;
2173 * @brief Forces or releases AHB2 peripheral reset.
2174 * @param RCC_AHB2Periph: specifies the AHB2 peripheral to reset.
2175 * This parameter can be any combination of the following values:
2176 * @arg RCC_AHB2Periph_DCMI: DCMI clock
2177 * @arg RCC_AHB2Periph_CRYP: CRYP clock
2178 * @arg RCC_AHB2Periph_HASH: HASH clock
2179 * @arg RCC_AHB2Periph_RNG: RNG clock for STM32F40_41xxx/STM32F412xG/STM32F427_437xx/STM32F429_439xx/STM32F469_479xx devices
2180 * @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock
2181 * @param NewState: new state of the specified peripheral reset.
2182 * This parameter can be: ENABLE or DISABLE.
2183 * @retval None
2185 void RCC_AHB2PeriphResetCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
2187 /* Check the parameters */
2188 assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));
2189 assert_param(IS_FUNCTIONAL_STATE(NewState));
2191 if (NewState != DISABLE)
2193 RCC->AHB2RSTR |= RCC_AHB2Periph;
2195 else
2197 RCC->AHB2RSTR &= ~RCC_AHB2Periph;
2201 #if defined(STM32F40_41xxx) || defined(STM32F412xG) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
2203 * @brief Forces or releases AHB3 peripheral reset.
2204 * @param RCC_AHB3Periph: specifies the AHB3 peripheral to reset.
2205 * This parameter must be:
2206 * - RCC_AHB3Periph_FSMC or RCC_AHB3Periph_FMC (STM32F412xG and STM32F429x/439x devices)
2207 * - RCC_AHB3Periph_QSPI (STM32F412xG/STM32F446xx/STM32F469_479xx devices)
2208 * @param NewState: new state of the specified peripheral reset.
2209 * This parameter can be: ENABLE or DISABLE.
2210 * @retval None
2212 void RCC_AHB3PeriphResetCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
2214 /* Check the parameters */
2215 assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));
2216 assert_param(IS_FUNCTIONAL_STATE(NewState));
2218 if (NewState != DISABLE)
2220 RCC->AHB3RSTR |= RCC_AHB3Periph;
2222 else
2224 RCC->AHB3RSTR &= ~RCC_AHB3Periph;
2227 #endif /* STM32F40_41xxx || STM32F412xG || STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
2230 * @brief Forces or releases Low Speed APB (APB1) peripheral reset.
2231 * @param RCC_APB1Periph: specifies the APB1 peripheral to reset.
2232 * This parameter can be any combination of the following values:
2233 * @arg RCC_APB1Periph_TIM2: TIM2 clock
2234 * @arg RCC_APB1Periph_TIM3: TIM3 clock
2235 * @arg RCC_APB1Periph_TIM4: TIM4 clock
2236 * @arg RCC_APB1Periph_TIM5: TIM5 clock
2237 * @arg RCC_APB1Periph_TIM6: TIM6 clock
2238 * @arg RCC_APB1Periph_TIM7: TIM7 clock
2239 * @arg RCC_APB1Periph_TIM12: TIM12 clock
2240 * @arg RCC_APB1Periph_TIM13: TIM13 clock
2241 * @arg RCC_APB1Periph_TIM14: TIM14 clock
2242 * @arg RCC_APB1Periph_LPTIM1: LPTIM1 clock (STM32F410xx devices)
2243 * @arg RCC_APB1Periph_WWDG: WWDG clock
2244 * @arg RCC_APB1Periph_SPI2: SPI2 clock
2245 * @arg RCC_APB1Periph_SPI3: SPI3 clock
2246 * @arg RCC_APB1Periph_SPDIF: SPDIF RX clock (STM32F446xx devices)
2247 * @arg RCC_APB1Periph_USART2: USART2 clock
2248 * @arg RCC_APB1Periph_USART3: USART3 clock
2249 * @arg RCC_APB1Periph_UART4: UART4 clock
2250 * @arg RCC_APB1Periph_UART5: UART5 clock
2251 * @arg RCC_APB1Periph_I2C1: I2C1 clock
2252 * @arg RCC_APB1Periph_I2C2: I2C2 clock
2253 * @arg RCC_APB1Periph_I2C3: I2C3 clock
2254 * @arg RCC_APB1Periph_FMPI2C1: FMPI2C1 clock
2255 * @arg RCC_APB1Periph_CAN1: CAN1 clock
2256 * @arg RCC_APB1Periph_CAN2: CAN2 clock
2257 * @arg RCC_APB1Periph_CEC: CEC clock(STM32F446xx devices)
2258 * @arg RCC_APB1Periph_PWR: PWR clock
2259 * @arg RCC_APB1Periph_DAC: DAC clock
2260 * @arg RCC_APB1Periph_UART7: UART7 clock
2261 * @arg RCC_APB1Periph_UART8: UART8 clock
2262 * @param NewState: new state of the specified peripheral reset.
2263 * This parameter can be: ENABLE or DISABLE.
2264 * @retval None
2266 void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
2268 /* Check the parameters */
2269 assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
2270 assert_param(IS_FUNCTIONAL_STATE(NewState));
2271 if (NewState != DISABLE)
2273 RCC->APB1RSTR |= RCC_APB1Periph;
2275 else
2277 RCC->APB1RSTR &= ~RCC_APB1Periph;
2282 * @brief Forces or releases High Speed APB (APB2) peripheral reset.
2283 * @param RCC_APB2Periph: specifies the APB2 peripheral to reset.
2284 * This parameter can be any combination of the following values:
2285 * @arg RCC_APB2Periph_TIM1: TIM1 clock
2286 * @arg RCC_APB2Periph_TIM8: TIM8 clock
2287 * @arg RCC_APB2Periph_USART1: USART1 clock
2288 * @arg RCC_APB2Periph_USART6: USART6 clock
2289 * @arg RCC_APB2Periph_ADC1: ADC1 clock
2290 * @arg RCC_APB2Periph_ADC2: ADC2 clock
2291 * @arg RCC_APB2Periph_ADC3: ADC3 clock
2292 * @arg RCC_APB2Periph_SDIO: SDIO clock
2293 * @arg RCC_APB2Periph_SPI1: SPI1 clock
2294 * @arg RCC_APB2Periph_SPI4: SPI4 clock
2295 * @arg RCC_APB2Periph_SYSCFG: SYSCFG clock
2296 * @arg RCC_APB2Periph_TIM9: TIM9 clock
2297 * @arg RCC_APB2Periph_TIM10: TIM10 clock
2298 * @arg RCC_APB2Periph_TIM11: TIM11 clock
2299 * @arg RCC_APB2Periph_SPI5: SPI5 clock
2300 * @arg RCC_APB2Periph_SPI6: SPI6 clock
2301 * @arg RCC_APB2Periph_SAI1: SAI1 clock (STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2302 * @arg RCC_APB2Periph_SAI2: SAI2 clock (STM32F446xx devices)
2303 * @arg RCC_APB2Periph_LTDC: LTDC clock (STM32F429xx/439xx devices)
2304 * @arg RCC_APB2Periph_DSI: DSI clock (STM32F469_479xx devices)
2305 * @param NewState: new state of the specified peripheral reset.
2306 * This parameter can be: ENABLE or DISABLE.
2307 * @retval None
2309 void RCC_APB2PeriphResetCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
2311 /* Check the parameters */
2312 assert_param(IS_RCC_APB2_RESET_PERIPH(RCC_APB2Periph));
2313 assert_param(IS_FUNCTIONAL_STATE(NewState));
2314 if (NewState != DISABLE)
2316 RCC->APB2RSTR |= RCC_APB2Periph;
2318 else
2320 RCC->APB2RSTR &= ~RCC_APB2Periph;
2325 * @brief Enables or disables the AHB1 peripheral clock during Low Power (Sleep) mode.
2326 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
2327 * power consumption.
2328 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
2329 * @note By default, all peripheral clocks are enabled during SLEEP mode.
2330 * @param RCC_AHBPeriph: specifies the AHB1 peripheral to gates its clock.
2331 * This parameter can be any combination of the following values:
2332 * @arg RCC_AHB1Periph_GPIOA: GPIOA clock
2333 * @arg RCC_AHB1Periph_GPIOB: GPIOB clock
2334 * @arg RCC_AHB1Periph_GPIOC: GPIOC clock
2335 * @arg RCC_AHB1Periph_GPIOD: GPIOD clock
2336 * @arg RCC_AHB1Periph_GPIOE: GPIOE clock
2337 * @arg RCC_AHB1Periph_GPIOF: GPIOF clock
2338 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
2339 * @arg RCC_AHB1Periph_GPIOG: GPIOG clock
2340 * @arg RCC_AHB1Periph_GPIOI: GPIOI clock
2341 * @arg RCC_AHB1Periph_GPIOJ: GPIOJ clock (STM32F42xxx/43xxx devices)
2342 * @arg RCC_AHB1Periph_GPIOK: GPIOK clock (STM32F42xxx/43xxx devices)
2343 * @arg RCC_AHB1Periph_CRC: CRC clock
2344 * @arg RCC_AHB1Periph_BKPSRAM: BKPSRAM interface clock
2345 * @arg RCC_AHB1Periph_DMA1: DMA1 clock
2346 * @arg RCC_AHB1Periph_DMA2: DMA2 clock
2347 * @arg RCC_AHB1Periph_DMA2D: DMA2D clock (STM32F429xx/439xx devices)
2348 * @arg RCC_AHB1Periph_ETH_MAC: Ethernet MAC clock
2349 * @arg RCC_AHB1Periph_ETH_MAC_Tx: Ethernet Transmission clock
2350 * @arg RCC_AHB1Periph_ETH_MAC_Rx: Ethernet Reception clock
2351 * @arg RCC_AHB1Periph_ETH_MAC_PTP: Ethernet PTP clock
2352 * @arg RCC_AHB1Periph_OTG_HS: USB OTG HS clock
2353 * @arg RCC_AHB1Periph_OTG_HS_ULPI: USB OTG HS ULPI clock
2354 * @param NewState: new state of the specified peripheral clock.
2355 * This parameter can be: ENABLE or DISABLE.
2356 * @retval None
2358 void RCC_AHB1PeriphClockLPModeCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
2360 /* Check the parameters */
2361 assert_param(IS_RCC_AHB1_LPMODE_PERIPH(RCC_AHB1Periph));
2362 assert_param(IS_FUNCTIONAL_STATE(NewState));
2363 if (NewState != DISABLE)
2365 RCC->AHB1LPENR |= RCC_AHB1Periph;
2367 else
2369 RCC->AHB1LPENR &= ~RCC_AHB1Periph;
2374 * @brief Enables or disables the AHB2 peripheral clock during Low Power (Sleep) mode.
2375 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
2376 * power consumption.
2377 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
2378 * @note By default, all peripheral clocks are enabled during SLEEP mode.
2379 * @param RCC_AHBPeriph: specifies the AHB2 peripheral to gates its clock.
2380 * This parameter can be any combination of the following values:
2381 * @arg RCC_AHB2Periph_DCMI: DCMI clock
2382 * @arg RCC_AHB2Periph_CRYP: CRYP clock
2383 * @arg RCC_AHB2Periph_HASH: HASH clock
2384 * @arg RCC_AHB2Periph_RNG: RNG clock
2385 * @arg RCC_AHB2Periph_OTG_FS: USB OTG FS clock
2386 * @param NewState: new state of the specified peripheral clock.
2387 * This parameter can be: ENABLE or DISABLE.
2388 * @retval None
2390 void RCC_AHB2PeriphClockLPModeCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
2392 /* Check the parameters */
2393 assert_param(IS_RCC_AHB2_PERIPH(RCC_AHB2Periph));
2394 assert_param(IS_FUNCTIONAL_STATE(NewState));
2395 if (NewState != DISABLE)
2397 RCC->AHB2LPENR |= RCC_AHB2Periph;
2399 else
2401 RCC->AHB2LPENR &= ~RCC_AHB2Periph;
2405 #if defined(STM32F40_41xxx) || defined(STM32F412xG) || defined(STM32F427_437xx) || defined(STM32F429_439xx) || defined(STM32F446xx) || defined(STM32F469_479xx)
2407 * @brief Enables or disables the AHB3 peripheral clock during Low Power (Sleep) mode.
2408 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
2409 * power consumption.
2410 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
2411 * @note By default, all peripheral clocks are enabled during SLEEP mode.
2412 * @param RCC_AHBPeriph: specifies the AHB3 peripheral to gates its clock.
2413 * This parameter must be:
2414 * - RCC_AHB3Periph_FSMC or RCC_AHB3Periph_FMC (STM32F412xG/STM32F429x/439x devices)
2415 * - RCC_AHB3Periph_QSPI (STM32F412xG/STM32F446xx/STM32F469_479xx devices)
2416 * @param NewState: new state of the specified peripheral clock.
2417 * This parameter can be: ENABLE or DISABLE.
2418 * @retval None
2420 void RCC_AHB3PeriphClockLPModeCmd(uint32_t RCC_AHB3Periph, FunctionalState NewState)
2422 /* Check the parameters */
2423 assert_param(IS_RCC_AHB3_PERIPH(RCC_AHB3Periph));
2424 assert_param(IS_FUNCTIONAL_STATE(NewState));
2425 if (NewState != DISABLE)
2427 RCC->AHB3LPENR |= RCC_AHB3Periph;
2429 else
2431 RCC->AHB3LPENR &= ~RCC_AHB3Periph;
2434 #endif /* STM32F40_41xxx || STM32F412xG || STM32F427_437xx || STM32F429_439xx || STM32F446xx || STM32F469_479xx */
2437 * @brief Enables or disables the APB1 peripheral clock during Low Power (Sleep) mode.
2438 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
2439 * power consumption.
2440 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
2441 * @note By default, all peripheral clocks are enabled during SLEEP mode.
2442 * @param RCC_APB1Periph: specifies the APB1 peripheral to gates its clock.
2443 * This parameter can be any combination of the following values:
2444 * @arg RCC_APB1Periph_TIM2: TIM2 clock
2445 * @arg RCC_APB1Periph_TIM3: TIM3 clock
2446 * @arg RCC_APB1Periph_TIM4: TIM4 clock
2447 * @arg RCC_APB1Periph_TIM5: TIM5 clock
2448 * @arg RCC_APB1Periph_TIM6: TIM6 clock
2449 * @arg RCC_APB1Periph_TIM7: TIM7 clock
2450 * @arg RCC_APB1Periph_TIM12: TIM12 clock
2451 * @arg RCC_APB1Periph_TIM13: TIM13 clock
2452 * @arg RCC_APB1Periph_TIM14: TIM14 clock
2453 * @arg RCC_APB1Periph_LPTIM1: LPTIM1 clock (STM32F410xx devices)
2454 * @arg RCC_APB1Periph_WWDG: WWDG clock
2455 * @arg RCC_APB1Periph_SPI2: SPI2 clock
2456 * @arg RCC_APB1Periph_SPI3: SPI3 clock
2457 * @arg RCC_APB1Periph_SPDIF: SPDIF RX clock (STM32F446xx devices)
2458 * @arg RCC_APB1Periph_USART2: USART2 clock
2459 * @arg RCC_APB1Periph_USART3: USART3 clock
2460 * @arg RCC_APB1Periph_UART4: UART4 clock
2461 * @arg RCC_APB1Periph_UART5: UART5 clock
2462 * @arg RCC_APB1Periph_I2C1: I2C1 clock
2463 * @arg RCC_APB1Periph_I2C2: I2C2 clock
2464 * @arg RCC_APB1Periph_I2C3: I2C3 clock
2465 * @arg RCC_APB1Periph_FMPI2C1: FMPI2C1 clock
2466 * @arg RCC_APB1Periph_CAN1: CAN1 clock
2467 * @arg RCC_APB1Periph_CAN2: CAN2 clock
2468 * @arg RCC_APB1Periph_CEC: CEC clock (STM32F446xx devices)
2469 * @arg RCC_APB1Periph_PWR: PWR clock
2470 * @arg RCC_APB1Periph_DAC: DAC clock
2471 * @arg RCC_APB1Periph_UART7: UART7 clock
2472 * @arg RCC_APB1Periph_UART8: UART8 clock
2473 * @param NewState: new state of the specified peripheral clock.
2474 * This parameter can be: ENABLE or DISABLE.
2475 * @retval None
2477 void RCC_APB1PeriphClockLPModeCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
2479 /* Check the parameters */
2480 assert_param(IS_RCC_APB1_PERIPH(RCC_APB1Periph));
2481 assert_param(IS_FUNCTIONAL_STATE(NewState));
2482 if (NewState != DISABLE)
2484 RCC->APB1LPENR |= RCC_APB1Periph;
2486 else
2488 RCC->APB1LPENR &= ~RCC_APB1Periph;
2493 * @brief Enables or disables the APB2 peripheral clock during Low Power (Sleep) mode.
2494 * @note Peripheral clock gating in SLEEP mode can be used to further reduce
2495 * power consumption.
2496 * @note After wakeup from SLEEP mode, the peripheral clock is enabled again.
2497 * @note By default, all peripheral clocks are enabled during SLEEP mode.
2498 * @param RCC_APB2Periph: specifies the APB2 peripheral to gates its clock.
2499 * This parameter can be any combination of the following values:
2500 * @arg RCC_APB2Periph_TIM1: TIM1 clock
2501 * @arg RCC_APB2Periph_TIM8: TIM8 clock
2502 * @arg RCC_APB2Periph_USART1: USART1 clock
2503 * @arg RCC_APB2Periph_USART6: USART6 clock
2504 * @arg RCC_APB2Periph_ADC1: ADC1 clock
2505 * @arg RCC_APB2Periph_ADC2: ADC2 clock
2506 * @arg RCC_APB2Periph_ADC3: ADC3 clock
2507 * @arg RCC_APB2Periph_SDIO: SDIO clock
2508 * @arg RCC_APB2Periph_SPI1: SPI1 clock
2509 * @arg RCC_APB2Periph_SPI4: SPI4 clock
2510 * @arg RCC_APB2Periph_SYSCFG: SYSCFG clock
2511 * @arg RCC_APB2Periph_TIM9: TIM9 clock
2512 * @arg RCC_APB2Periph_TIM10: TIM10 clock
2513 * @arg RCC_APB2Periph_TIM11: TIM11 clock
2514 * @arg RCC_APB2Periph_SPI5: SPI5 clock
2515 * @arg RCC_APB2Periph_SPI6: SPI6 clock
2516 * @arg RCC_APB2Periph_SAI1: SAI1 clock (STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2517 * @arg RCC_APB2Periph_SAI2: SAI2 clock (STM32F446xx devices)
2518 * @arg RCC_APB2Periph_LTDC: LTDC clock (STM32F429xx/439xx devices)
2519 * @arg RCC_APB2Periph_DSI: DSI clock (STM32F469_479xx devices)
2520 * @param NewState: new state of the specified peripheral clock.
2521 * This parameter can be: ENABLE or DISABLE.
2522 * @retval None
2524 void RCC_APB2PeriphClockLPModeCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
2526 /* Check the parameters */
2527 assert_param(IS_RCC_APB2_PERIPH(RCC_APB2Periph));
2528 assert_param(IS_FUNCTIONAL_STATE(NewState));
2529 if (NewState != DISABLE)
2531 RCC->APB2LPENR |= RCC_APB2Periph;
2533 else
2535 RCC->APB2LPENR &= ~RCC_APB2Periph;
2540 * @brief Configures the External Low Speed oscillator mode (LSE mode).
2541 * @note This mode is only available for STM32F410xx/STM32F411xx/STM32F446xx/STM32F469_479xx devices.
2542 * @param Mode: specifies the LSE mode.
2543 * This parameter can be one of the following values:
2544 * @arg RCC_LSE_LOWPOWER_MODE: LSE oscillator in low power mode.
2545 * @arg RCC_LSE_HIGHDRIVE_MODE: LSE oscillator in High Drive mode.
2546 * @retval None
2548 void RCC_LSEModeConfig(uint8_t RCC_Mode)
2550 /* Check the parameters */
2551 assert_param(IS_RCC_LSE_MODE(RCC_Mode));
2553 if(RCC_Mode == RCC_LSE_HIGHDRIVE_MODE)
2555 SET_BIT(RCC->BDCR, RCC_BDCR_LSEMOD);
2557 else
2559 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEMOD);
2563 #if defined(STM32F410xx)
2565 * @brief Configures the LPTIM1 clock Source.
2566 * @note This feature is only available for STM32F410xx devices.
2567 * @param RCC_ClockSource: specifies the LPTIM1 clock Source.
2568 * This parameter can be one of the following values:
2569 * @arg RCC_LPTIM1CLKSOURCE_PCLK: LPTIM1 clock from APB1 selected.
2570 * @arg RCC_LPTIM1CLKSOURCE_HSI: LPTIM1 clock from HSI selected.
2571 * @arg RCC_LPTIM1CLKSOURCE_LSI: LPTIM1 clock from LSI selected.
2572 * @arg RCC_LPTIM1CLKSOURCE_LSE: LPTIM1 clock from LSE selected.
2573 * @retval None
2575 void RCC_LPTIM1ClockSourceConfig(uint32_t RCC_ClockSource)
2577 /* Check the parameters */
2578 assert_param(IS_RCC_LPTIM1_CLOCKSOURCE(RCC_ClockSource));
2580 /* Clear LPTIM1 clock source selection source bits */
2581 RCC->DCKCFGR2 &= ~RCC_DCKCFGR2_LPTIM1SEL;
2582 /* Set new LPTIM1 clock source */
2583 RCC->DCKCFGR2 |= RCC_ClockSource;
2585 #endif /* STM32F410xx */
2587 #if defined(STM32F469_479xx)
2589 * @brief Configures the DSI clock Source.
2590 * @note This feature is only available for STM32F469_479xx devices.
2591 * @param RCC_ClockSource: specifies the DSI clock Source.
2592 * This parameter can be one of the following values:
2593 * @arg RCC_DSICLKSource_PHY: DSI-PHY used as DSI byte lane clock source (usual case).
2594 * @arg RCC_DSICLKSource_PLLR: PLL_R used as DSI byte lane clock source, used in case DSI PLL and DSI-PHY are off (low power mode).
2595 * @retval None
2597 void RCC_DSIClockSourceConfig(uint8_t RCC_ClockSource)
2599 /* Check the parameters */
2600 assert_param(IS_RCC_DSI_CLOCKSOURCE(RCC_ClockSource));
2602 if(RCC_ClockSource == RCC_DSICLKSource_PLLR)
2604 SET_BIT(RCC->DCKCFGR, RCC_DCKCFGR_DSISEL);
2606 else
2608 CLEAR_BIT(RCC->DCKCFGR, RCC_DCKCFGR_DSISEL);
2611 #endif /* STM32F469_479xx */
2613 #if defined(STM32F412xG) || defined(STM32F446xx) || defined(STM32F469_479xx)
2615 * @brief Configures the 48MHz clock Source.
2616 * @note This feature is only available for STM32F446xx/STM32F469_479xx devices.
2617 * @param RCC_ClockSource: specifies the 48MHz clock Source.
2618 * This parameter can be one of the following values:
2619 * @arg RCC_48MHZCLKSource_PLL: 48MHz from PLL selected.
2620 * @arg RCC_48MHZCLKSource_PLLSAI: 48MHz from PLLSAI selected.
2621 * @arg RCC_CK48CLKSOURCE_PLLI2SQ : 48MHz from PLLI2SQ
2622 * @retval None
2624 void RCC_48MHzClockSourceConfig(uint8_t RCC_ClockSource)
2626 /* Check the parameters */
2627 assert_param(IS_RCC_48MHZ_CLOCKSOURCE(RCC_ClockSource));
2628 #if defined(STM32F469_479xx)
2629 if(RCC_ClockSource == RCC_48MHZCLKSource_PLLSAI)
2631 SET_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL);
2633 else
2635 CLEAR_BIT(RCC->DCKCFGR, RCC_DCKCFGR_CK48MSEL);
2637 #elif defined(STM32F446xx)
2638 if(RCC_ClockSource == RCC_48MHZCLKSource_PLLSAI)
2640 SET_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL);
2642 else
2644 CLEAR_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL);
2646 #elif defined(STM32F412xG)
2647 if(RCC_ClockSource == RCC_CK48CLKSOURCE_PLLI2SQ)
2649 SET_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL);
2651 else
2653 CLEAR_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CK48MSEL);
2655 #else
2656 #endif /* STM32F469_479xx */
2660 * @brief Configures the SDIO clock Source.
2661 * @note This feature is only available for STM32F469_479xx/STM32F446xx devices.
2662 * @param RCC_ClockSource: specifies the SDIO clock Source.
2663 * This parameter can be one of the following values:
2664 * @arg RCC_SDIOCLKSource_48MHZ: 48MHz clock selected.
2665 * @arg RCC_SDIOCLKSource_SYSCLK: system clock selected.
2666 * @retval None
2668 void RCC_SDIOClockSourceConfig(uint8_t RCC_ClockSource)
2670 /* Check the parameters */
2671 assert_param(IS_RCC_SDIO_CLOCKSOURCE(RCC_ClockSource));
2672 #if defined(STM32F469_479xx)
2673 if(RCC_ClockSource == RCC_SDIOCLKSource_SYSCLK)
2675 SET_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SDIOSEL);
2677 else
2679 CLEAR_BIT(RCC->DCKCFGR, RCC_DCKCFGR_SDIOSEL);
2681 #elif defined(STM32F412xG) || defined(STM32F446xx)
2682 if(RCC_ClockSource == RCC_SDIOCLKSource_SYSCLK)
2684 SET_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL);
2686 else
2688 CLEAR_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SDIOSEL);
2690 #else
2691 #endif /* STM32F469_479xx */
2693 #endif /* STM32F412xG || STM32F446xx || STM32F469_479xx */
2695 #if defined(STM32F446xx)
2697 * @brief Enables or disables the AHB1 clock gating for the specified IPs.
2698 * @note This feature is only available for STM32F446xx devices.
2699 * @param RCC_AHB1ClockGating: specifies the AHB1 clock gating.
2700 * This parameter can be any combination of the following values:
2701 * @arg RCC_AHB1ClockGating_APB1Bridge: AHB1 to APB1 clock
2702 * @arg RCC_AHB1ClockGating_APB2Bridge: AHB1 to APB2 clock
2703 * @arg RCC_AHB1ClockGating_CM4DBG: Cortex M4 ETM clock
2704 * @arg RCC_AHB1ClockGating_SPARE: Spare clock
2705 * @arg RCC_AHB1ClockGating_SRAM: SRAM controller clock
2706 * @arg RCC_AHB1ClockGating_FLITF: Flash interface clock
2707 * @arg RCC_AHB1ClockGating_RCC: RCC clock
2708 * @param NewState: new state of the specified peripheral clock.
2709 * This parameter can be: ENABLE or DISABLE.
2710 * @retval None
2712 void RCC_AHB1ClockGatingCmd(uint32_t RCC_AHB1ClockGating, FunctionalState NewState)
2714 /* Check the parameters */
2715 assert_param(IS_RCC_AHB1_CLOCKGATING(RCC_AHB1ClockGating));
2717 assert_param(IS_FUNCTIONAL_STATE(NewState));
2718 if (NewState != DISABLE)
2720 RCC->CKGATENR &= ~RCC_AHB1ClockGating;
2722 else
2724 RCC->CKGATENR |= RCC_AHB1ClockGating;
2729 * @brief Configures the SPDIFRX clock Source.
2730 * @note This feature is only available for STM32F446xx devices.
2731 * @param RCC_ClockSource: specifies the SPDIFRX clock Source.
2732 * This parameter can be one of the following values:
2733 * @arg RCC_SPDIFRXCLKSource_PLLR: SPDIFRX clock from PLL_R selected.
2734 * @arg RCC_SPDIFRXCLKSource_PLLI2SP: SPDIFRX clock from PLLI2S_P selected.
2735 * @retval None
2737 void RCC_SPDIFRXClockSourceConfig(uint8_t RCC_ClockSource)
2739 /* Check the parameters */
2740 assert_param(IS_RCC_SPDIFRX_CLOCKSOURCE(RCC_ClockSource));
2742 if(RCC_ClockSource == RCC_SPDIFRXCLKSource_PLLI2SP)
2744 SET_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL);
2746 else
2748 CLEAR_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_SPDIFRXSEL);
2753 * @brief Configures the CEC clock Source.
2754 * @note This feature is only available for STM32F446xx devices.
2755 * @param RCC_ClockSource: specifies the CEC clock Source.
2756 * This parameter can be one of the following values:
2757 * @arg RCC_CECCLKSource_HSIDiv488: CEC clock from HSI/488 selected.
2758 * @arg RCC_CECCLKSource_LSE: CEC clock from LSE selected.
2759 * @retval None
2761 void RCC_CECClockSourceConfig(uint8_t RCC_ClockSource)
2763 /* Check the parameters */
2764 assert_param(IS_RCC_CEC_CLOCKSOURCE(RCC_ClockSource));
2766 if(RCC_ClockSource == RCC_CECCLKSource_LSE)
2768 SET_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL);
2770 else
2772 CLEAR_BIT(RCC->DCKCFGR2, RCC_DCKCFGR2_CECSEL);
2775 #endif /* STM32F446xx */
2777 #if defined(STM32F410xx) || defined(STM32F412xG) || defined(STM32F446xx)
2779 * @brief Configures the FMPI2C1 clock Source.
2780 * @note This feature is only available for STM32F446xx devices.
2781 * @param RCC_ClockSource: specifies the FMPI2C1 clock Source.
2782 * This parameter can be one of the following values:
2783 * @arg RCC_FMPI2C1CLKSource_APB1: FMPI2C1 clock from APB1 selected.
2784 * @arg RCC_FMPI2C1CLKSource_SYSCLK: FMPI2C1 clock from Sytem clock selected.
2785 * @arg RCC_FMPI2C1CLKSource_HSI: FMPI2C1 clock from HSI selected.
2786 * @retval None
2788 void RCC_FMPI2C1ClockSourceConfig(uint32_t RCC_ClockSource)
2790 /* Check the parameters */
2791 assert_param(IS_RCC_FMPI2C1_CLOCKSOURCE(RCC_ClockSource));
2793 /* Clear FMPI2C1 clock source selection source bits */
2794 RCC->DCKCFGR2 &= ~RCC_DCKCFGR2_FMPI2C1SEL;
2795 /* Set new FMPI2C1 clock source */
2796 RCC->DCKCFGR2 |= RCC_ClockSource;
2798 #endif /* STM32F410xx || STM32F412xG || STM32F446xx */
2800 * @}
2803 #if defined(STM32F410xx)
2805 * @brief Enables or disables the MCO1.
2806 * @param NewState: new state of the MCO1.
2807 * This parameter can be: ENABLE or DISABLE.
2808 * @retval None
2810 void RCC_MCO1Cmd(FunctionalState NewState)
2812 /* Check the parameters */
2813 assert_param(IS_FUNCTIONAL_STATE(NewState));
2815 *(__IO uint32_t *) RCC_CFGR_MCO1EN_BB = (uint32_t)NewState;
2819 * @brief Enables or disables the MCO2.
2820 * @param NewState: new state of the MCO2.
2821 * This parameter can be: ENABLE or DISABLE.
2822 * @retval None
2824 void RCC_MCO2Cmd(FunctionalState NewState)
2826 /* Check the parameters */
2827 assert_param(IS_FUNCTIONAL_STATE(NewState));
2829 *(__IO uint32_t *) RCC_CFGR_MCO2EN_BB = (uint32_t)NewState;
2831 #endif /* STM32F410xx */
2833 /** @defgroup RCC_Group4 Interrupts and flags management functions
2834 * @brief Interrupts and flags management functions
2836 @verbatim
2837 ===============================================================================
2838 ##### Interrupts and flags management functions #####
2839 ===============================================================================
2841 @endverbatim
2842 * @{
2846 * @brief Enables or disables the specified RCC interrupts.
2847 * @param RCC_IT: specifies the RCC interrupt sources to be enabled or disabled.
2848 * This parameter can be any combination of the following values:
2849 * @arg RCC_IT_LSIRDY: LSI ready interrupt
2850 * @arg RCC_IT_LSERDY: LSE ready interrupt
2851 * @arg RCC_IT_HSIRDY: HSI ready interrupt
2852 * @arg RCC_IT_HSERDY: HSE ready interrupt
2853 * @arg RCC_IT_PLLRDY: main PLL ready interrupt
2854 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt
2855 * @arg RCC_IT_PLLSAIRDY: PLLSAI ready interrupt (only for STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2856 * @param NewState: new state of the specified RCC interrupts.
2857 * This parameter can be: ENABLE or DISABLE.
2858 * @retval None
2860 void RCC_ITConfig(uint8_t RCC_IT, FunctionalState NewState)
2862 /* Check the parameters */
2863 assert_param(IS_RCC_IT(RCC_IT));
2864 assert_param(IS_FUNCTIONAL_STATE(NewState));
2865 if (NewState != DISABLE)
2867 /* Perform Byte access to RCC_CIR[14:8] bits to enable the selected interrupts */
2868 *(__IO uint8_t *) CIR_BYTE2_ADDRESS |= RCC_IT;
2870 else
2872 /* Perform Byte access to RCC_CIR[14:8] bits to disable the selected interrupts */
2873 *(__IO uint8_t *) CIR_BYTE2_ADDRESS &= (uint8_t)~RCC_IT;
2878 * @brief Checks whether the specified RCC flag is set or not.
2879 * @param RCC_FLAG: specifies the flag to check.
2880 * This parameter can be one of the following values:
2881 * @arg RCC_FLAG_HSIRDY: HSI oscillator clock ready
2882 * @arg RCC_FLAG_HSERDY: HSE oscillator clock ready
2883 * @arg RCC_FLAG_PLLRDY: main PLL clock ready
2884 * @arg RCC_FLAG_PLLI2SRDY: PLLI2S clock ready
2885 * @arg RCC_FLAG_PLLSAIRDY: PLLSAI clock ready (only for STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2886 * @arg RCC_FLAG_LSERDY: LSE oscillator clock ready
2887 * @arg RCC_FLAG_LSIRDY: LSI oscillator clock ready
2888 * @arg RCC_FLAG_BORRST: POR/PDR or BOR reset
2889 * @arg RCC_FLAG_PINRST: Pin reset
2890 * @arg RCC_FLAG_PORRST: POR/PDR reset
2891 * @arg RCC_FLAG_SFTRST: Software reset
2892 * @arg RCC_FLAG_IWDGRST: Independent Watchdog reset
2893 * @arg RCC_FLAG_WWDGRST: Window Watchdog reset
2894 * @arg RCC_FLAG_LPWRRST: Low Power reset
2895 * @retval The new state of RCC_FLAG (SET or RESET).
2897 FlagStatus RCC_GetFlagStatus(uint8_t RCC_FLAG)
2899 uint32_t tmp = 0;
2900 uint32_t statusreg = 0;
2901 FlagStatus bitstatus = RESET;
2903 /* Check the parameters */
2904 assert_param(IS_RCC_FLAG(RCC_FLAG));
2906 /* Get the RCC register index */
2907 tmp = RCC_FLAG >> 5;
2908 if (tmp == 1) /* The flag to check is in CR register */
2910 statusreg = RCC->CR;
2912 else if (tmp == 2) /* The flag to check is in BDCR register */
2914 statusreg = RCC->BDCR;
2916 else /* The flag to check is in CSR register */
2918 statusreg = RCC->CSR;
2921 /* Get the flag position */
2922 tmp = RCC_FLAG & FLAG_MASK;
2923 if ((statusreg & ((uint32_t)1 << tmp)) != (uint32_t)RESET)
2925 bitstatus = SET;
2927 else
2929 bitstatus = RESET;
2931 /* Return the flag status */
2932 return bitstatus;
2936 * @brief Clears the RCC reset flags.
2937 * The reset flags are: RCC_FLAG_PINRST, RCC_FLAG_PORRST, RCC_FLAG_SFTRST,
2938 * RCC_FLAG_IWDGRST, RCC_FLAG_WWDGRST, RCC_FLAG_LPWRRST
2939 * @param None
2940 * @retval None
2942 void RCC_ClearFlag(void)
2944 /* Set RMVF bit to clear the reset flags */
2945 RCC->CSR |= RCC_CSR_RMVF;
2949 * @brief Checks whether the specified RCC interrupt has occurred or not.
2950 * @param RCC_IT: specifies the RCC interrupt source to check.
2951 * This parameter can be one of the following values:
2952 * @arg RCC_IT_LSIRDY: LSI ready interrupt
2953 * @arg RCC_IT_LSERDY: LSE ready interrupt
2954 * @arg RCC_IT_HSIRDY: HSI ready interrupt
2955 * @arg RCC_IT_HSERDY: HSE ready interrupt
2956 * @arg RCC_IT_PLLRDY: main PLL ready interrupt
2957 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt
2958 * @arg RCC_IT_PLLSAIRDY: PLLSAI clock ready interrupt (only for STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2959 * @arg RCC_IT_CSS: Clock Security System interrupt
2960 * @retval The new state of RCC_IT (SET or RESET).
2962 ITStatus RCC_GetITStatus(uint8_t RCC_IT)
2964 ITStatus bitstatus = RESET;
2966 /* Check the parameters */
2967 assert_param(IS_RCC_GET_IT(RCC_IT));
2969 /* Check the status of the specified RCC interrupt */
2970 if ((RCC->CIR & RCC_IT) != (uint32_t)RESET)
2972 bitstatus = SET;
2974 else
2976 bitstatus = RESET;
2978 /* Return the RCC_IT status */
2979 return bitstatus;
2983 * @brief Clears the RCC's interrupt pending bits.
2984 * @param RCC_IT: specifies the interrupt pending bit to clear.
2985 * This parameter can be any combination of the following values:
2986 * @arg RCC_IT_LSIRDY: LSI ready interrupt
2987 * @arg RCC_IT_LSERDY: LSE ready interrupt
2988 * @arg RCC_IT_HSIRDY: HSI ready interrupt
2989 * @arg RCC_IT_HSERDY: HSE ready interrupt
2990 * @arg RCC_IT_PLLRDY: main PLL ready interrupt
2991 * @arg RCC_IT_PLLI2SRDY: PLLI2S ready interrupt
2992 * @arg RCC_IT_PLLSAIRDY: PLLSAI ready interrupt (only for STM32F42xxx/43xxx/446xx/469xx/479xx devices)
2993 * @arg RCC_IT_CSS: Clock Security System interrupt
2994 * @retval None
2996 void RCC_ClearITPendingBit(uint8_t RCC_IT)
2998 /* Check the parameters */
2999 assert_param(IS_RCC_CLEAR_IT(RCC_IT));
3001 /* Perform Byte access to RCC_CIR[23:16] bits to clear the selected interrupt
3002 pending bits */
3003 *(__IO uint8_t *) CIR_BYTE3_ADDRESS = RCC_IT;
3007 * @}
3011 * @}
3015 * @}
3019 * @}
3022 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/