2 ******************************************************************************
3 * @file stm32f7xx_hal_rcc.c
4 * @author MCD Application Team
5 * @brief RCC HAL module driver.
6 * This file provides firmware functions to manage the following
7 * functionalities of the Reset and Clock Control (RCC) peripheral:
8 * + Initialization and de-initialization functions
9 * + Peripheral Control functions
12 ==============================================================================
13 ##### RCC specific features #####
14 ==============================================================================
16 After reset the device is running from Internal High Speed oscillator
17 (HSI 16MHz) with Flash 0 wait state, Flash prefetch buffer, D-Cache
18 and I-Cache are disabled, and all peripherals are off except internal
20 (+) There is no prescaler on High speed (AHB) and Low speed (APB) busses;
21 all peripherals mapped on these busses are running at HSI speed.
22 (+) The clock for all peripherals is switched off, except the SRAM and FLASH.
23 (+) All GPIOs are in input floating state, except the JTAG pins which
24 are assigned to be used for debug purpose.
27 Once the device started from reset, the user application has to:
28 (+) Configure the clock source to be used to drive the System clock
29 (if the application needs higher frequency/performance)
30 (+) Configure the System clock frequency and Flash settings
31 (+) Configure the AHB and APB busses prescalers
32 (+) Enable the clock for the peripheral(s) to be used
33 (+) Configure the clock source(s) for peripherals which clocks are not
34 derived from the System clock (I2S, RTC, ADC, USB OTG FS/SDIO/RNG)
36 ##### RCC Limitations #####
37 ==============================================================================
39 A delay between an RCC peripheral clock enable and the effective peripheral
40 enabling should be taken into account in order to manage the peripheral read/write
42 (+) This delay depends on the peripheral mapping.
43 (+) If peripheral is mapped on AHB: the delay is 2 AHB clock cycle
44 after the clock enable bit is set on the hardware register
45 (+) If peripheral is mapped on APB: the delay is 2 APB clock cycle
46 after the clock enable bit is set on the hardware register
49 Implemented Workaround:
50 (+) For AHB & APB peripherals, a dummy read to the peripheral register has been
51 inserted in each __HAL_RCC_PPP_CLK_ENABLE() macro.
54 ******************************************************************************
57 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
58 * All rights reserved.</center></h2>
60 * This software component is licensed by ST under BSD 3-Clause license,
61 * the "License"; You may not use this file except in compliance with the
62 * License. You may obtain a copy of the License at:
63 * opensource.org/licenses/BSD-3-Clause
65 ******************************************************************************
68 /* Includes ------------------------------------------------------------------*/
69 #include "stm32f7xx_hal.h"
71 /** @addtogroup STM32F7xx_HAL_Driver
76 * @brief RCC HAL module driver
80 #ifdef HAL_RCC_MODULE_ENABLED
82 /* Private typedef -----------------------------------------------------------*/
83 /* Private define ------------------------------------------------------------*/
84 /* Private macro -------------------------------------------------------------*/
85 /** @defgroup RCC_Private_Macros RCC Private Macros
89 #define MCO1_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
90 #define MCO1_GPIO_PORT GPIOA
91 #define MCO1_PIN GPIO_PIN_8
93 #define MCO2_CLK_ENABLE() __HAL_RCC_GPIOC_CLK_ENABLE()
94 #define MCO2_GPIO_PORT GPIOC
95 #define MCO2_PIN GPIO_PIN_9
100 /* Private variables ---------------------------------------------------------*/
101 /** @defgroup RCC_Private_Variables RCC Private Variables
109 /* Private function prototypes -----------------------------------------------*/
110 /* Exported functions ---------------------------------------------------------*/
112 /** @defgroup RCC_Exported_Functions RCC Exported Functions
116 /** @defgroup RCC_Exported_Functions_Group1 Initialization and de-initialization functions
117 * @brief Initialization and Configuration functions
120 ===============================================================================
121 ##### Initialization and de-initialization functions #####
122 ===============================================================================
124 This section provides functions allowing to configure the internal/external oscillators
125 (HSE, HSI, LSE, LSI, PLL, CSS and MCO) and the System buses clocks (SYSCLK, AHB, APB1
128 [..] Internal/external clock and PLL configuration
129 (#) HSI (high-speed internal), 16 MHz factory-trimmed RC used directly or through
130 the PLL as System clock source.
132 (#) LSI (low-speed internal), 32 KHz low consumption RC used as IWDG and/or RTC
135 (#) HSE (high-speed external), 4 to 26 MHz crystal oscillator used directly or
136 through the PLL as System clock source. Can be used also as RTC clock source.
138 (#) LSE (low-speed external), 32 KHz oscillator used as RTC clock source.
140 (#) PLL (clocked by HSI or HSE), featuring two different output clocks:
141 (++) The first output is used to generate the high speed system clock (up to 216 MHz)
142 (++) The second output is used to generate the clock for the USB OTG FS (48 MHz),
143 the random analog generator (<=48 MHz) and the SDIO (<= 48 MHz).
145 (#) CSS (Clock security system), once enable using the function HAL_RCC_EnableCSS()
146 and if a HSE clock failure occurs(HSE used directly or through PLL as System
147 clock source), the System clock is automatically switched to HSI and an interrupt
148 is generated if enabled. The interrupt is linked to the Cortex-M7 NMI
149 (Non-Maskable Interrupt) exception vector.
151 (#) MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL
152 clock (through a configurable prescaler) on PA8 pin.
154 (#) MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or PLLI2S
155 clock (through a configurable prescaler) on PC9 pin.
157 [..] System, AHB and APB busses clocks configuration
158 (#) Several clock sources can be used to drive the System clock (SYSCLK): HSI,
160 The AHB clock (HCLK) is derived from System clock through configurable
161 prescaler and used to clock the CPU, memory and peripherals mapped
162 on AHB bus (DMA, GPIO...). APB1 (PCLK1) and APB2 (PCLK2) clocks are derived
163 from AHB clock through configurable prescalers and used to clock
164 the peripherals mapped on these busses. You can use
165 "HAL_RCC_GetSysClockFreq()" function to retrieve the frequencies of these clocks.
167 -@- All the peripheral clocks are derived from the System clock (SYSCLK) except:
168 (+@) I2S: the I2S clock can be derived either from a specific PLL (PLLI2S) or
169 from an external clock mapped on the I2S_CKIN pin.
170 You have to use __HAL_RCC_PLLI2S_CONFIG() macro to configure this clock.
171 (+@) SAI: the SAI clock can be derived either from a specific PLL (PLLI2S) or (PLLSAI) or
172 from an external clock mapped on the I2S_CKIN pin.
173 You have to use __HAL_RCC_PLLI2S_CONFIG() macro to configure this clock.
174 (+@) RTC: the RTC clock can be derived either from the LSI, LSE or HSE clock
175 divided by 2 to 31. You have to use __HAL_RCC_RTC_CONFIG() and __HAL_RCC_RTC_ENABLE()
176 macros to configure this clock.
177 (+@) USB OTG FS, SDIO and RTC: USB OTG FS require a frequency equal to 48 MHz
178 to work correctly, while the SDIO require a frequency equal or lower than
179 to 48. This clock is derived of the main PLL through PLLQ divider.
180 (+@) IWDG clock which is always the LSI clock.
186 * @brief Resets the RCC clock configuration to the default reset state.
187 * @note The default reset state of the clock configuration is given below:
188 * - HSI ON and used as system clock source
189 * - HSE, PLL, PLLI2S and PLLSAI OFF
190 * - AHB, APB1 and APB2 prescaler set to 1.
191 * - CSS, MCO1 and MCO2 OFF
192 * - All interrupts disabled
193 * @note This function doesn't modify the configuration of the
194 * - Peripheral clocks
195 * - LSI, LSE and RTC clocks
198 HAL_StatusTypeDef
HAL_RCC_DeInit(void)
203 tickstart
= HAL_GetTick();
205 /* Set HSION bit to the reset value */
206 SET_BIT(RCC
->CR
, RCC_CR_HSION
);
208 /* Wait till HSI is ready */
209 while (READ_BIT(RCC
->CR
, RCC_CR_HSIRDY
) == RESET
)
211 if ((HAL_GetTick() - tickstart
) > HSI_TIMEOUT_VALUE
)
217 /* Set HSITRIM[4:0] bits to the reset value */
218 SET_BIT(RCC
->CR
, RCC_CR_HSITRIM_4
);
221 tickstart
= HAL_GetTick();
223 /* Reset CFGR register */
224 CLEAR_REG(RCC
->CFGR
);
226 /* Wait till clock switch is ready */
227 while (READ_BIT(RCC
->CFGR
, RCC_CFGR_SWS
) != RESET
)
229 if ((HAL_GetTick() - tickstart
) > CLOCKSWITCH_TIMEOUT_VALUE
)
236 tickstart
= HAL_GetTick();
238 /* Clear HSEON, HSEBYP and CSSON bits */
239 CLEAR_BIT(RCC
->CR
, RCC_CR_HSEON
| RCC_CR_HSEBYP
| RCC_CR_CSSON
);
241 /* Wait till HSE is disabled */
242 while (READ_BIT(RCC
->CR
, RCC_CR_HSERDY
) != RESET
)
244 if ((HAL_GetTick() - tickstart
) > HSE_TIMEOUT_VALUE
)
251 tickstart
= HAL_GetTick();
253 /* Clear PLLON bit */
254 CLEAR_BIT(RCC
->CR
, RCC_CR_PLLON
);
256 /* Wait till PLL is disabled */
257 while (READ_BIT(RCC
->CR
, RCC_CR_PLLRDY
) != RESET
)
259 if ((HAL_GetTick() - tickstart
) > PLL_TIMEOUT_VALUE
)
266 tickstart
= HAL_GetTick();
268 /* Reset PLLI2SON bit */
269 CLEAR_BIT(RCC
->CR
, RCC_CR_PLLI2SON
);
271 /* Wait till PLLI2S is disabled */
272 while (READ_BIT(RCC
->CR
, RCC_CR_PLLI2SRDY
) != RESET
)
274 if ((HAL_GetTick() - tickstart
) > PLLI2S_TIMEOUT_VALUE
)
281 tickstart
= HAL_GetTick();
283 /* Reset PLLSAI bit */
284 CLEAR_BIT(RCC
->CR
, RCC_CR_PLLSAION
);
286 /* Wait till PLLSAI is disabled */
287 while (READ_BIT(RCC
->CR
, RCC_CR_PLLSAIRDY
) != RESET
)
289 if ((HAL_GetTick() - tickstart
) > PLLSAI_TIMEOUT_VALUE
)
295 /* Once PLL, PLLI2S and PLLSAI are OFF, reset PLLCFGR register to default value */
296 RCC
->PLLCFGR
= RCC_PLLCFGR_PLLM_4
| RCC_PLLCFGR_PLLN_6
| RCC_PLLCFGR_PLLN_7
| RCC_PLLCFGR_PLLQ_2
| 0x20000000U
;
298 /* Reset PLLI2SCFGR register to default value */
299 RCC
->PLLI2SCFGR
= RCC_PLLI2SCFGR_PLLI2SN_6
| RCC_PLLI2SCFGR_PLLI2SN_7
| RCC_PLLI2SCFGR_PLLI2SQ_2
| RCC_PLLI2SCFGR_PLLI2SR_1
;
301 /* Reset PLLSAICFGR register to default value */
302 RCC
->PLLSAICFGR
= RCC_PLLSAICFGR_PLLSAIN_6
| RCC_PLLSAICFGR_PLLSAIN_7
| RCC_PLLSAICFGR_PLLSAIQ_2
| 0x20000000U
;
304 /* Disable all interrupts */
305 CLEAR_BIT(RCC
->CIR
, RCC_CIR_LSIRDYIE
| RCC_CIR_LSERDYIE
| RCC_CIR_HSIRDYIE
| RCC_CIR_HSERDYIE
| RCC_CIR_PLLRDYIE
| RCC_CIR_PLLI2SRDYIE
| RCC_CIR_PLLSAIRDYIE
);
307 /* Clear all interrupt flags */
308 SET_BIT(RCC
->CIR
, RCC_CIR_LSIRDYC
| RCC_CIR_LSERDYC
| RCC_CIR_HSIRDYC
| RCC_CIR_HSERDYC
| RCC_CIR_PLLRDYC
| RCC_CIR_PLLI2SRDYC
| RCC_CIR_PLLSAIRDYC
| RCC_CIR_CSSC
);
310 /* Clear LSION bit */
311 CLEAR_BIT(RCC
->CSR
, RCC_CSR_LSION
);
313 /* Reset all CSR flags */
314 SET_BIT(RCC
->CSR
, RCC_CSR_RMVF
);
316 /* Update the SystemCoreClock global variable */
317 SystemCoreClock
= HSI_VALUE
;
319 /* Adapt Systick interrupt period */
320 if(HAL_InitTick(TICK_INT_PRIORITY
) != HAL_OK
)
331 * @brief Initializes the RCC Oscillators according to the specified parameters in the
332 * RCC_OscInitTypeDef.
333 * @param RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
334 * contains the configuration information for the RCC Oscillators.
335 * @note The PLL is not disabled when used as system clock.
336 * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
337 * supported by this function. User should request a transition to LSE Off
338 * first and then LSE On or LSE Bypass.
339 * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
340 * supported by this function. User should request a transition to HSE Off
341 * first and then HSE On or HSE Bypass.
344 HAL_StatusTypeDef
HAL_RCC_OscConfig(RCC_OscInitTypeDef
*RCC_OscInitStruct
)
347 FlagStatus pwrclkchanged
= RESET
;
349 /* Check Null pointer */
350 if(RCC_OscInitStruct
== NULL
)
355 /* Check the parameters */
356 assert_param(IS_RCC_OSCILLATORTYPE(RCC_OscInitStruct
->OscillatorType
));
358 /*------------------------------- HSE Configuration ------------------------*/
359 if(((RCC_OscInitStruct
->OscillatorType
) & RCC_OSCILLATORTYPE_HSE
) == RCC_OSCILLATORTYPE_HSE
)
361 /* Check the parameters */
362 assert_param(IS_RCC_HSE(RCC_OscInitStruct
->HSEState
));
363 /* When the HSE is used as system clock or clock source for PLL, It can not be disabled */
364 if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSE
)
365 || ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK
) && ((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLSRC
) == RCC_PLLCFGR_PLLSRC_HSE
)))
367 if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY
) != RESET
) && (RCC_OscInitStruct
->HSEState
== RCC_HSE_OFF
))
374 /* Set the new HSE configuration ---------------------------------------*/
375 __HAL_RCC_HSE_CONFIG(RCC_OscInitStruct
->HSEState
);
377 /* Check the HSE State */
378 if(RCC_OscInitStruct
->HSEState
!= RCC_HSE_OFF
)
381 tickstart
= HAL_GetTick();
383 /* Wait till HSE is ready */
384 while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY
) == RESET
)
386 if((HAL_GetTick() - tickstart
) > HSE_TIMEOUT_VALUE
)
395 tickstart
= HAL_GetTick();
397 /* Wait till HSE is bypassed or disabled */
398 while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY
) != RESET
)
400 if((HAL_GetTick() - tickstart
) > HSE_TIMEOUT_VALUE
)
408 /*----------------------------- HSI Configuration --------------------------*/
409 if(((RCC_OscInitStruct
->OscillatorType
) & RCC_OSCILLATORTYPE_HSI
) == RCC_OSCILLATORTYPE_HSI
)
411 /* Check the parameters */
412 assert_param(IS_RCC_HSI(RCC_OscInitStruct
->HSIState
));
413 assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct
->HSICalibrationValue
));
415 /* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */
416 if((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_HSI
)
417 || ((__HAL_RCC_GET_SYSCLK_SOURCE() == RCC_SYSCLKSOURCE_STATUS_PLLCLK
) && ((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLSRC
) == RCC_PLLCFGR_PLLSRC_HSI
)))
419 /* When HSI is used as system clock it will not disabled */
420 if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY
) != RESET
) && (RCC_OscInitStruct
->HSIState
!= RCC_HSI_ON
))
424 /* Otherwise, just the calibration is allowed */
427 /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/
428 __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct
->HSICalibrationValue
);
433 /* Check the HSI State */
434 if((RCC_OscInitStruct
->HSIState
)!= RCC_HSI_OFF
)
436 /* Enable the Internal High Speed oscillator (HSI). */
437 __HAL_RCC_HSI_ENABLE();
440 tickstart
= HAL_GetTick();
442 /* Wait till HSI is ready */
443 while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY
) == RESET
)
445 if((HAL_GetTick() - tickstart
) > HSI_TIMEOUT_VALUE
)
451 /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/
452 __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct
->HSICalibrationValue
);
456 /* Disable the Internal High Speed oscillator (HSI). */
457 __HAL_RCC_HSI_DISABLE();
460 tickstart
= HAL_GetTick();
462 /* Wait till HSI is ready */
463 while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY
) != RESET
)
465 if((HAL_GetTick() - tickstart
) > HSI_TIMEOUT_VALUE
)
473 /*------------------------------ LSI Configuration -------------------------*/
474 if(((RCC_OscInitStruct
->OscillatorType
) & RCC_OSCILLATORTYPE_LSI
) == RCC_OSCILLATORTYPE_LSI
)
476 /* Check the parameters */
477 assert_param(IS_RCC_LSI(RCC_OscInitStruct
->LSIState
));
479 /* Check the LSI State */
480 if((RCC_OscInitStruct
->LSIState
)!= RCC_LSI_OFF
)
482 /* Enable the Internal Low Speed oscillator (LSI). */
483 __HAL_RCC_LSI_ENABLE();
486 tickstart
= HAL_GetTick();
488 /* Wait till LSI is ready */
489 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY
) == RESET
)
491 if((HAL_GetTick() - tickstart
) > LSI_TIMEOUT_VALUE
)
499 /* Disable the Internal Low Speed oscillator (LSI). */
500 __HAL_RCC_LSI_DISABLE();
503 tickstart
= HAL_GetTick();
505 /* Wait till LSI is ready */
506 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY
) != RESET
)
508 if((HAL_GetTick() - tickstart
) > LSI_TIMEOUT_VALUE
)
515 /*------------------------------ LSE Configuration -------------------------*/
516 if(((RCC_OscInitStruct
->OscillatorType
) & RCC_OSCILLATORTYPE_LSE
) == RCC_OSCILLATORTYPE_LSE
)
518 /* Check the parameters */
519 assert_param(IS_RCC_LSE(RCC_OscInitStruct
->LSEState
));
521 /* Update LSE configuration in Backup Domain control register */
522 /* Requires to enable write access to Backup Domain of necessary */
523 if(__HAL_RCC_PWR_IS_CLK_DISABLED())
525 /* Enable Power Clock*/
526 __HAL_RCC_PWR_CLK_ENABLE();
530 if(HAL_IS_BIT_CLR(PWR
->CR1
, PWR_CR1_DBP
))
532 /* Enable write access to Backup domain */
533 PWR
->CR1
|= PWR_CR1_DBP
;
535 /* Wait for Backup domain Write protection disable */
536 tickstart
= HAL_GetTick();
538 while(HAL_IS_BIT_CLR(PWR
->CR1
, PWR_CR1_DBP
))
540 if((HAL_GetTick() - tickstart
) > RCC_DBP_TIMEOUT_VALUE
)
547 /* Set the new LSE configuration -----------------------------------------*/
548 __HAL_RCC_LSE_CONFIG(RCC_OscInitStruct
->LSEState
);
549 /* Check the LSE State */
550 if((RCC_OscInitStruct
->LSEState
) != RCC_LSE_OFF
)
553 tickstart
= HAL_GetTick();
555 /* Wait till LSE is ready */
556 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY
) == RESET
)
558 if((HAL_GetTick() - tickstart
) > RCC_LSE_TIMEOUT_VALUE
)
567 tickstart
= HAL_GetTick();
569 /* Wait till LSE is ready */
570 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY
) != RESET
)
572 if((HAL_GetTick() - tickstart
) > RCC_LSE_TIMEOUT_VALUE
)
579 /* Restore clock configuration if changed */
580 if(pwrclkchanged
== SET
)
582 __HAL_RCC_PWR_CLK_DISABLE();
585 /*-------------------------------- PLL Configuration -----------------------*/
586 /* Check the parameters */
587 assert_param(IS_RCC_PLL(RCC_OscInitStruct
->PLL
.PLLState
));
588 if ((RCC_OscInitStruct
->PLL
.PLLState
) != RCC_PLL_NONE
)
590 /* Check if the PLL is used as system clock or not */
591 if(__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_PLLCLK
)
593 if((RCC_OscInitStruct
->PLL
.PLLState
) == RCC_PLL_ON
)
595 /* Check the parameters */
596 assert_param(IS_RCC_PLLSOURCE(RCC_OscInitStruct
->PLL
.PLLSource
));
597 assert_param(IS_RCC_PLLM_VALUE(RCC_OscInitStruct
->PLL
.PLLM
));
598 assert_param(IS_RCC_PLLN_VALUE(RCC_OscInitStruct
->PLL
.PLLN
));
599 assert_param(IS_RCC_PLLP_VALUE(RCC_OscInitStruct
->PLL
.PLLP
));
600 assert_param(IS_RCC_PLLQ_VALUE(RCC_OscInitStruct
->PLL
.PLLQ
));
601 #if defined (RCC_PLLCFGR_PLLR)
602 assert_param(IS_RCC_PLLR_VALUE(RCC_OscInitStruct
->PLL
.PLLR
));
605 /* Disable the main PLL. */
606 __HAL_RCC_PLL_DISABLE();
609 tickstart
= HAL_GetTick();
611 /* Wait till PLL is ready */
612 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY
) != RESET
)
614 if((HAL_GetTick() - tickstart
) > PLL_TIMEOUT_VALUE
)
620 /* Configure the main PLL clock source, multiplication and division factors. */
621 #if defined (RCC_PLLCFGR_PLLR)
622 __HAL_RCC_PLL_CONFIG(RCC_OscInitStruct
->PLL
.PLLSource
,
623 RCC_OscInitStruct
->PLL
.PLLM
,
624 RCC_OscInitStruct
->PLL
.PLLN
,
625 RCC_OscInitStruct
->PLL
.PLLP
,
626 RCC_OscInitStruct
->PLL
.PLLQ
,
627 RCC_OscInitStruct
->PLL
.PLLR
);
629 __HAL_RCC_PLL_CONFIG(RCC_OscInitStruct
->PLL
.PLLSource
,
630 RCC_OscInitStruct
->PLL
.PLLM
,
631 RCC_OscInitStruct
->PLL
.PLLN
,
632 RCC_OscInitStruct
->PLL
.PLLP
,
633 RCC_OscInitStruct
->PLL
.PLLQ
);
636 /* Enable the main PLL. */
637 __HAL_RCC_PLL_ENABLE();
640 tickstart
= HAL_GetTick();
642 /* Wait till PLL is ready */
643 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY
) == RESET
)
645 if((HAL_GetTick() - tickstart
) > PLL_TIMEOUT_VALUE
)
653 /* Disable the main PLL. */
654 __HAL_RCC_PLL_DISABLE();
657 tickstart
= HAL_GetTick();
659 /* Wait till PLL is ready */
660 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY
) != RESET
)
662 if((HAL_GetTick() - tickstart
) > PLL_TIMEOUT_VALUE
)
678 * @brief Initializes the CPU, AHB and APB busses clocks according to the specified
679 * parameters in the RCC_ClkInitStruct.
680 * @param RCC_ClkInitStruct pointer to an RCC_OscInitTypeDef structure that
681 * contains the configuration information for the RCC peripheral.
682 * @param FLatency FLASH Latency, this parameter depend on device selected
684 * @note The SystemCoreClock CMSIS variable is used to store System Clock Frequency
685 * and updated by HAL_RCC_GetHCLKFreq() function called within this function
687 * @note The HSI is used (enabled by hardware) as system clock source after
688 * startup from Reset, wake-up from STOP and STANDBY mode, or in case
689 * of failure of the HSE used directly or indirectly as system clock
690 * (if the Clock Security System CSS is enabled).
692 * @note A switch from one clock source to another occurs only if the target
693 * clock source is ready (clock stable after startup delay or PLL locked).
694 * If a clock source which is not yet ready is selected, the switch will
695 * occur when the clock source will be ready.
696 * You can use HAL_RCC_GetClockConfig() function to know which clock is
697 * currently used as system clock source.
698 * @note Depending on the device voltage range, the software has to set correctly
699 * HPRE[3:0] bits to ensure that HCLK not exceed the maximum allowed frequency
700 * (for more details refer to section above "Initialization/de-initialization functions")
703 HAL_StatusTypeDef
HAL_RCC_ClockConfig(RCC_ClkInitTypeDef
*RCC_ClkInitStruct
, uint32_t FLatency
)
705 uint32_t tickstart
= 0;
707 /* Check Null pointer */
708 if(RCC_ClkInitStruct
== NULL
)
713 /* Check the parameters */
714 assert_param(IS_RCC_CLOCKTYPE(RCC_ClkInitStruct
->ClockType
));
715 assert_param(IS_FLASH_LATENCY(FLatency
));
717 /* To correctly read data from FLASH memory, the number of wait states (LATENCY)
718 must be correctly programmed according to the frequency of the CPU clock
719 (HCLK) and the supply voltage of the device. */
721 /* Increasing the CPU frequency */
722 if(FLatency
> __HAL_FLASH_GET_LATENCY())
724 /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
725 __HAL_FLASH_SET_LATENCY(FLatency
);
727 /* Check that the new number of wait states is taken into account to access the Flash
728 memory by reading the FLASH_ACR register */
729 if(__HAL_FLASH_GET_LATENCY() != FLatency
)
735 /*-------------------------- HCLK Configuration --------------------------*/
736 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_HCLK
) == RCC_CLOCKTYPE_HCLK
)
738 /* Set the highest APBx dividers in order to ensure that we do not go through
739 a non-spec phase whatever we decrease or increase HCLK. */
740 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_PCLK1
) == RCC_CLOCKTYPE_PCLK1
)
742 MODIFY_REG(RCC
->CFGR
, RCC_CFGR_PPRE1
, RCC_HCLK_DIV16
);
745 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_PCLK2
) == RCC_CLOCKTYPE_PCLK2
)
747 MODIFY_REG(RCC
->CFGR
, RCC_CFGR_PPRE2
, (RCC_HCLK_DIV16
<< 3));
750 /* Set the new HCLK clock divider */
751 assert_param(IS_RCC_HCLK(RCC_ClkInitStruct
->AHBCLKDivider
));
752 MODIFY_REG(RCC
->CFGR
, RCC_CFGR_HPRE
, RCC_ClkInitStruct
->AHBCLKDivider
);
755 /*------------------------- SYSCLK Configuration ---------------------------*/
756 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_SYSCLK
) == RCC_CLOCKTYPE_SYSCLK
)
758 assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct
->SYSCLKSource
));
760 /* HSE is selected as System Clock Source */
761 if(RCC_ClkInitStruct
->SYSCLKSource
== RCC_SYSCLKSOURCE_HSE
)
763 /* Check the HSE ready flag */
764 if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY
) == RESET
)
769 /* PLL is selected as System Clock Source */
770 else if(RCC_ClkInitStruct
->SYSCLKSource
== RCC_SYSCLKSOURCE_PLLCLK
)
772 /* Check the PLL ready flag */
773 if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY
) == RESET
)
778 /* HSI is selected as System Clock Source */
781 /* Check the HSI ready flag */
782 if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY
) == RESET
)
788 __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct
->SYSCLKSource
);
791 tickstart
= HAL_GetTick();
793 while (__HAL_RCC_GET_SYSCLK_SOURCE() != (RCC_ClkInitStruct
->SYSCLKSource
<< RCC_CFGR_SWS_Pos
))
795 if ((HAL_GetTick() - tickstart
) > CLOCKSWITCH_TIMEOUT_VALUE
)
802 /* Decreasing the number of wait states because of lower CPU frequency */
803 if(FLatency
< __HAL_FLASH_GET_LATENCY())
805 /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
806 __HAL_FLASH_SET_LATENCY(FLatency
);
808 /* Check that the new number of wait states is taken into account to access the Flash
809 memory by reading the FLASH_ACR register */
810 if(__HAL_FLASH_GET_LATENCY() != FLatency
)
816 /*-------------------------- PCLK1 Configuration ---------------------------*/
817 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_PCLK1
) == RCC_CLOCKTYPE_PCLK1
)
819 assert_param(IS_RCC_PCLK(RCC_ClkInitStruct
->APB1CLKDivider
));
820 MODIFY_REG(RCC
->CFGR
, RCC_CFGR_PPRE1
, RCC_ClkInitStruct
->APB1CLKDivider
);
823 /*-------------------------- PCLK2 Configuration ---------------------------*/
824 if(((RCC_ClkInitStruct
->ClockType
) & RCC_CLOCKTYPE_PCLK2
) == RCC_CLOCKTYPE_PCLK2
)
826 assert_param(IS_RCC_PCLK(RCC_ClkInitStruct
->APB2CLKDivider
));
827 MODIFY_REG(RCC
->CFGR
, RCC_CFGR_PPRE2
, ((RCC_ClkInitStruct
->APB2CLKDivider
) << 3));
830 /* Update the SystemCoreClock global variable */
831 SystemCoreClock
= HAL_RCC_GetSysClockFreq() >> AHBPrescTable
[(RCC
->CFGR
& RCC_CFGR_HPRE
)>> RCC_CFGR_HPRE_Pos
];
833 /* Configure the source of time base considering new system clocks settings*/
834 HAL_InitTick (TICK_INT_PRIORITY
);
843 /** @defgroup RCC_Exported_Functions_Group2 Peripheral Control functions
844 * @brief RCC clocks control functions
847 ===============================================================================
848 ##### Peripheral Control functions #####
849 ===============================================================================
851 This subsection provides a set of functions allowing to control the RCC Clocks
859 * @brief Selects the clock source to output on MCO1 pin(PA8) or on MCO2 pin(PC9).
860 * @note PA8/PC9 should be configured in alternate function mode.
861 * @param RCC_MCOx specifies the output direction for the clock source.
862 * This parameter can be one of the following values:
863 * @arg RCC_MCO1: Clock source to output on MCO1 pin(PA8).
864 * @arg RCC_MCO2: Clock source to output on MCO2 pin(PC9).
865 * @param RCC_MCOSource specifies the clock source to output.
866 * This parameter can be one of the following values:
867 * @arg RCC_MCO1SOURCE_HSI: HSI clock selected as MCO1 source
868 * @arg RCC_MCO1SOURCE_LSE: LSE clock selected as MCO1 source
869 * @arg RCC_MCO1SOURCE_HSE: HSE clock selected as MCO1 source
870 * @arg RCC_MCO1SOURCE_PLLCLK: main PLL clock selected as MCO1 source
871 * @arg RCC_MCO2SOURCE_SYSCLK: System clock (SYSCLK) selected as MCO2 source
872 * @arg RCC_MCO2SOURCE_PLLI2SCLK: PLLI2S clock selected as MCO2 source
873 * @arg RCC_MCO2SOURCE_HSE: HSE clock selected as MCO2 source
874 * @arg RCC_MCO2SOURCE_PLLCLK: main PLL clock selected as MCO2 source
875 * @param RCC_MCODiv specifies the MCOx prescaler.
876 * This parameter can be one of the following values:
877 * @arg RCC_MCODIV_1: no division applied to MCOx clock
878 * @arg RCC_MCODIV_2: division by 2 applied to MCOx clock
879 * @arg RCC_MCODIV_3: division by 3 applied to MCOx clock
880 * @arg RCC_MCODIV_4: division by 4 applied to MCOx clock
881 * @arg RCC_MCODIV_5: division by 5 applied to MCOx clock
884 void HAL_RCC_MCOConfig(uint32_t RCC_MCOx
, uint32_t RCC_MCOSource
, uint32_t RCC_MCODiv
)
886 GPIO_InitTypeDef GPIO_InitStruct
;
887 /* Check the parameters */
888 assert_param(IS_RCC_MCO(RCC_MCOx
));
889 assert_param(IS_RCC_MCODIV(RCC_MCODiv
));
891 if(RCC_MCOx
== RCC_MCO1
)
893 assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource
));
895 /* MCO1 Clock Enable */
898 /* Configure the MCO1 pin in alternate function mode */
899 GPIO_InitStruct
.Pin
= MCO1_PIN
;
900 GPIO_InitStruct
.Mode
= GPIO_MODE_AF_PP
;
901 GPIO_InitStruct
.Speed
= GPIO_SPEED_HIGH
;
902 GPIO_InitStruct
.Pull
= GPIO_NOPULL
;
903 GPIO_InitStruct
.Alternate
= GPIO_AF0_MCO
;
904 HAL_GPIO_Init(MCO1_GPIO_PORT
, &GPIO_InitStruct
);
906 /* Mask MCO1 and MCO1PRE[2:0] bits then Select MCO1 clock source and prescaler */
907 MODIFY_REG(RCC
->CFGR
, (RCC_CFGR_MCO1
| RCC_CFGR_MCO1PRE
), (RCC_MCOSource
| RCC_MCODiv
));
911 assert_param(IS_RCC_MCO2SOURCE(RCC_MCOSource
));
913 /* MCO2 Clock Enable */
916 /* Configure the MCO2 pin in alternate function mode */
917 GPIO_InitStruct
.Pin
= MCO2_PIN
;
918 GPIO_InitStruct
.Mode
= GPIO_MODE_AF_PP
;
919 GPIO_InitStruct
.Speed
= GPIO_SPEED_HIGH
;
920 GPIO_InitStruct
.Pull
= GPIO_NOPULL
;
921 GPIO_InitStruct
.Alternate
= GPIO_AF0_MCO
;
922 HAL_GPIO_Init(MCO2_GPIO_PORT
, &GPIO_InitStruct
);
924 /* Mask MCO2 and MCO2PRE[2:0] bits then Select MCO2 clock source and prescaler */
925 MODIFY_REG(RCC
->CFGR
, (RCC_CFGR_MCO2
| RCC_CFGR_MCO2PRE
), (RCC_MCOSource
| (RCC_MCODiv
<< 3)));
930 * @brief Enables the Clock Security System.
931 * @note If a failure is detected on the HSE oscillator clock, this oscillator
932 * is automatically disabled and an interrupt is generated to inform the
933 * software about the failure (Clock Security System Interrupt, CSSI),
934 * allowing the MCU to perform rescue operations. The CSSI is linked to
935 * the Cortex-M7 NMI (Non-Maskable Interrupt) exception vector.
938 void HAL_RCC_EnableCSS(void)
940 SET_BIT(RCC
->CR
, RCC_CR_CSSON
);
944 * @brief Disables the Clock Security System.
947 void HAL_RCC_DisableCSS(void)
949 CLEAR_BIT(RCC
->CR
, RCC_CR_CSSON
);
953 * @brief Returns the SYSCLK frequency
955 * @note The system frequency computed by this function is not the real
956 * frequency in the chip. It is calculated based on the predefined
957 * constant and the selected clock source:
958 * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(*)
959 * @note If SYSCLK source is HSE, function returns values based on HSE_VALUE(**)
960 * @note If SYSCLK source is PLL, function returns values based on HSE_VALUE(**)
961 * or HSI_VALUE(*) multiplied/divided by the PLL factors.
962 * @note (*) HSI_VALUE is a constant defined in stm32f7xx_hal_conf.h file (default value
963 * 16 MHz) but the real value may vary depending on the variations
964 * in voltage and temperature.
965 * @note (**) HSE_VALUE is a constant defined in stm32f7xx_hal_conf.h file (default value
966 * 25 MHz), user has to ensure that HSE_VALUE is same as the real
967 * frequency of the crystal used. Otherwise, this function may
970 * @note The result of this function could be not correct when using fractional
971 * value for HSE crystal.
973 * @note This function can be used by the user application to compute the
974 * baudrate for the communication peripherals or configure other parameters.
976 * @note Each time SYSCLK changes, this function must be called to update the
977 * right SYSCLK value. Otherwise, any configuration based on this function will be incorrect.
980 * @retval SYSCLK frequency
982 uint32_t HAL_RCC_GetSysClockFreq(void)
984 uint32_t pllm
= 0, pllvco
= 0, pllp
= 0;
985 uint32_t sysclockfreq
= 0;
987 /* Get SYSCLK source -------------------------------------------------------*/
988 switch (RCC
->CFGR
& RCC_CFGR_SWS
)
990 case RCC_SYSCLKSOURCE_STATUS_HSI
: /* HSI used as system clock source */
992 sysclockfreq
= HSI_VALUE
;
995 case RCC_SYSCLKSOURCE_STATUS_HSE
: /* HSE used as system clock source */
997 sysclockfreq
= HSE_VALUE
;
1000 case RCC_SYSCLKSOURCE_STATUS_PLLCLK
: /* PLL used as system clock source */
1002 /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN
1003 SYSCLK = PLL_VCO / PLLP */
1004 pllm
= RCC
->PLLCFGR
& RCC_PLLCFGR_PLLM
;
1005 if (__HAL_RCC_GET_PLL_OSCSOURCE() != RCC_PLLCFGR_PLLSRC_HSI
)
1007 /* HSE used as PLL clock source */
1008 pllvco
= (uint32_t) ((((uint64_t) HSE_VALUE
* ((uint64_t) ((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLN
) >> RCC_PLLCFGR_PLLN_Pos
)))) / (uint64_t)pllm
);
1012 /* HSI used as PLL clock source */
1013 pllvco
= (uint32_t) ((((uint64_t) HSI_VALUE
* ((uint64_t) ((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLN
) >> RCC_PLLCFGR_PLLN_Pos
)))) / (uint64_t)pllm
);
1015 pllp
= ((((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLP
) >> RCC_PLLCFGR_PLLP_Pos
) + 1 ) *2);
1017 sysclockfreq
= pllvco
/pllp
;
1022 sysclockfreq
= HSI_VALUE
;
1026 return sysclockfreq
;
1030 * @brief Returns the HCLK frequency
1031 * @note Each time HCLK changes, this function must be called to update the
1032 * right HCLK value. Otherwise, any configuration based on this function will be incorrect.
1033 * @note The SystemCoreClock CMSIS variable is used to store System Clock Frequency.
1034 * @retval HCLK frequency
1036 uint32_t HAL_RCC_GetHCLKFreq(void)
1038 return SystemCoreClock
;
1042 * @brief Returns the PCLK1 frequency
1043 * @note Each time PCLK1 changes, this function must be called to update the
1044 * right PCLK1 value. Otherwise, any configuration based on this function will be incorrect.
1045 * @retval PCLK1 frequency
1047 uint32_t HAL_RCC_GetPCLK1Freq(void)
1049 /* Get HCLK source and Compute PCLK1 frequency ---------------------------*/
1050 return (HAL_RCC_GetHCLKFreq() >> APBPrescTable
[(RCC
->CFGR
& RCC_CFGR_PPRE1
)>> RCC_CFGR_PPRE1_Pos
]);
1054 * @brief Returns the PCLK2 frequency
1055 * @note Each time PCLK2 changes, this function must be called to update the
1056 * right PCLK2 value. Otherwise, any configuration based on this function will be incorrect.
1057 * @retval PCLK2 frequency
1059 uint32_t HAL_RCC_GetPCLK2Freq(void)
1061 /* Get HCLK source and Compute PCLK2 frequency ---------------------------*/
1062 return (HAL_RCC_GetHCLKFreq()>> APBPrescTable
[(RCC
->CFGR
& RCC_CFGR_PPRE2
)>> RCC_CFGR_PPRE2_Pos
]);
1066 * @brief Configures the RCC_OscInitStruct according to the internal
1067 * RCC configuration registers.
1068 * @param RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
1069 * will be configured.
1072 void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef
*RCC_OscInitStruct
)
1074 /* Set all possible values for the Oscillator type parameter ---------------*/
1075 RCC_OscInitStruct
->OscillatorType
= RCC_OSCILLATORTYPE_HSE
| RCC_OSCILLATORTYPE_HSI
| RCC_OSCILLATORTYPE_LSE
| RCC_OSCILLATORTYPE_LSI
;
1077 /* Get the HSE configuration -----------------------------------------------*/
1078 if((RCC
->CR
&RCC_CR_HSEBYP
) == RCC_CR_HSEBYP
)
1080 RCC_OscInitStruct
->HSEState
= RCC_HSE_BYPASS
;
1082 else if((RCC
->CR
&RCC_CR_HSEON
) == RCC_CR_HSEON
)
1084 RCC_OscInitStruct
->HSEState
= RCC_HSE_ON
;
1088 RCC_OscInitStruct
->HSEState
= RCC_HSE_OFF
;
1091 /* Get the HSI configuration -----------------------------------------------*/
1092 if((RCC
->CR
&RCC_CR_HSION
) == RCC_CR_HSION
)
1094 RCC_OscInitStruct
->HSIState
= RCC_HSI_ON
;
1098 RCC_OscInitStruct
->HSIState
= RCC_HSI_OFF
;
1101 RCC_OscInitStruct
->HSICalibrationValue
= (uint32_t)((RCC
->CR
&RCC_CR_HSITRIM
) >> RCC_CR_HSITRIM_Pos
);
1103 /* Get the LSE configuration -----------------------------------------------*/
1104 if((RCC
->BDCR
&RCC_BDCR_LSEBYP
) == RCC_BDCR_LSEBYP
)
1106 RCC_OscInitStruct
->LSEState
= RCC_LSE_BYPASS
;
1108 else if((RCC
->BDCR
&RCC_BDCR_LSEON
) == RCC_BDCR_LSEON
)
1110 RCC_OscInitStruct
->LSEState
= RCC_LSE_ON
;
1114 RCC_OscInitStruct
->LSEState
= RCC_LSE_OFF
;
1117 /* Get the LSI configuration -----------------------------------------------*/
1118 if((RCC
->CSR
&RCC_CSR_LSION
) == RCC_CSR_LSION
)
1120 RCC_OscInitStruct
->LSIState
= RCC_LSI_ON
;
1124 RCC_OscInitStruct
->LSIState
= RCC_LSI_OFF
;
1127 /* Get the PLL configuration -----------------------------------------------*/
1128 if((RCC
->CR
&RCC_CR_PLLON
) == RCC_CR_PLLON
)
1130 RCC_OscInitStruct
->PLL
.PLLState
= RCC_PLL_ON
;
1134 RCC_OscInitStruct
->PLL
.PLLState
= RCC_PLL_OFF
;
1136 RCC_OscInitStruct
->PLL
.PLLSource
= (uint32_t)(RCC
->PLLCFGR
& RCC_PLLCFGR_PLLSRC
);
1137 RCC_OscInitStruct
->PLL
.PLLM
= (uint32_t)(RCC
->PLLCFGR
& RCC_PLLCFGR_PLLM
);
1138 RCC_OscInitStruct
->PLL
.PLLN
= (uint32_t)((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLN
) >> RCC_PLLCFGR_PLLN_Pos
);
1139 RCC_OscInitStruct
->PLL
.PLLP
= (uint32_t)((((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLP
) + RCC_PLLCFGR_PLLP_0
) << 1) >> RCC_PLLCFGR_PLLP_Pos
);
1140 RCC_OscInitStruct
->PLL
.PLLQ
= (uint32_t)((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLQ
) >> RCC_PLLCFGR_PLLQ_Pos
);
1141 #if defined (RCC_PLLCFGR_PLLR)
1142 RCC_OscInitStruct
->PLL
.PLLR
= (uint32_t)((RCC
->PLLCFGR
& RCC_PLLCFGR_PLLR
) >> POSITION_VAL(RCC_PLLCFGR_PLLR
));
1147 * @brief Configures the RCC_ClkInitStruct according to the internal
1148 * RCC configuration registers.
1149 * @param RCC_ClkInitStruct pointer to an RCC_ClkInitTypeDef structure that
1150 * will be configured.
1151 * @param pFLatency Pointer on the Flash Latency.
1154 void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef
*RCC_ClkInitStruct
, uint32_t *pFLatency
)
1156 /* Set all possible values for the Clock type parameter --------------------*/
1157 RCC_ClkInitStruct
->ClockType
= RCC_CLOCKTYPE_SYSCLK
| RCC_CLOCKTYPE_HCLK
| RCC_CLOCKTYPE_PCLK1
| RCC_CLOCKTYPE_PCLK2
;
1159 /* Get the SYSCLK configuration --------------------------------------------*/
1160 RCC_ClkInitStruct
->SYSCLKSource
= (uint32_t)(RCC
->CFGR
& RCC_CFGR_SW
);
1162 /* Get the HCLK configuration ----------------------------------------------*/
1163 RCC_ClkInitStruct
->AHBCLKDivider
= (uint32_t)(RCC
->CFGR
& RCC_CFGR_HPRE
);
1165 /* Get the APB1 configuration ----------------------------------------------*/
1166 RCC_ClkInitStruct
->APB1CLKDivider
= (uint32_t)(RCC
->CFGR
& RCC_CFGR_PPRE1
);
1168 /* Get the APB2 configuration ----------------------------------------------*/
1169 RCC_ClkInitStruct
->APB2CLKDivider
= (uint32_t)((RCC
->CFGR
& RCC_CFGR_PPRE2
) >> 3);
1171 /* Get the Flash Wait State (Latency) configuration ------------------------*/
1172 *pFLatency
= (uint32_t)(FLASH
->ACR
& FLASH_ACR_LATENCY
);
1176 * @brief This function handles the RCC CSS interrupt request.
1177 * @note This API should be called under the NMI_Handler().
1180 void HAL_RCC_NMI_IRQHandler(void)
1182 /* Check RCC CSSF flag */
1183 if(__HAL_RCC_GET_IT(RCC_IT_CSS
))
1185 /* RCC Clock Security System interrupt user callback */
1186 HAL_RCC_CSSCallback();
1188 /* Clear RCC CSS pending bit */
1189 __HAL_RCC_CLEAR_IT(RCC_IT_CSS
);
1194 * @brief RCC Clock Security System interrupt callback
1197 __weak
void HAL_RCC_CSSCallback(void)
1199 /* NOTE : This function Should not be modified, when the callback is needed,
1200 the HAL_RCC_CSSCallback could be implemented in the user file
1212 #endif /* HAL_RCC_MODULE_ENABLED */
1221 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/