STM32L443xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_ll_utils.c 00004 * @author MCD Application Team 00005 * @brief UTILS LL module driver. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 STMicroelectronics. 00010 * All rights reserved. 00011 * 00012 * This software is licensed under terms that can be found in the LICENSE file 00013 * in the root directory of this software component. 00014 * If no LICENSE file comes with this software, it is provided AS-IS. 00015 * 00016 ****************************************************************************** 00017 */ 00018 /* Includes ------------------------------------------------------------------*/ 00019 #include "stm32l4xx_ll_utils.h" 00020 #include "stm32l4xx_ll_rcc.h" 00021 #include "stm32l4xx_ll_system.h" 00022 #include "stm32l4xx_ll_pwr.h" 00023 #ifdef USE_FULL_ASSERT 00024 #include "stm32_assert.h" 00025 #else 00026 #define assert_param(expr) ((void)0U) 00027 #endif /* USE_FULL_ASSERT */ 00028 00029 /** @addtogroup STM32L4xx_LL_Driver 00030 * @{ 00031 */ 00032 00033 /** @addtogroup UTILS_LL 00034 * @{ 00035 */ 00036 00037 /* Private types -------------------------------------------------------------*/ 00038 /* Private variables ---------------------------------------------------------*/ 00039 /* Private constants ---------------------------------------------------------*/ 00040 /** @addtogroup UTILS_LL_Private_Constants 00041 * @{ 00042 */ 00043 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00044 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00045 #define UTILS_MAX_FREQUENCY_SCALE1 120000000U /*!< Maximum frequency for system clock at power scale1, in Hz */ 00046 #define UTILS_MAX_FREQUENCY_SCALE2 26000000U /*!< Maximum frequency for system clock at power scale2, in Hz */ 00047 #else 00048 #define UTILS_MAX_FREQUENCY_SCALE1 80000000U /*!< Maximum frequency for system clock at power scale1, in Hz */ 00049 #define UTILS_MAX_FREQUENCY_SCALE2 26000000U /*!< Maximum frequency for system clock at power scale2, in Hz */ 00050 #endif 00051 00052 /* Defines used for PLL range */ 00053 #define UTILS_PLLVCO_INPUT_MIN 4000000U /*!< Frequency min for PLLVCO input, in Hz */ 00054 #define UTILS_PLLVCO_INPUT_MAX 16000000U /*!< Frequency max for PLLVCO input, in Hz */ 00055 #define UTILS_PLLVCO_OUTPUT_MIN 64000000U /*!< Frequency min for PLLVCO output, in Hz */ 00056 #define UTILS_PLLVCO_OUTPUT_MAX 344000000U /*!< Frequency max for PLLVCO output, in Hz */ 00057 00058 /* Defines used for HSE range */ 00059 #define UTILS_HSE_FREQUENCY_MIN 4000000U /*!< Frequency min for HSE frequency, in Hz */ 00060 #define UTILS_HSE_FREQUENCY_MAX 48000000U /*!< Frequency max for HSE frequency, in Hz */ 00061 00062 /* Defines used for FLASH latency according to HCLK Frequency */ 00063 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00064 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00065 #define UTILS_SCALE1_LATENCY1_FREQ 20000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 1 */ 00066 #define UTILS_SCALE1_LATENCY2_FREQ 40000000U /*!< HCLK frequency to set FLASH latency 2 in power scale 1 */ 00067 #define UTILS_SCALE1_LATENCY3_FREQ 60000000U /*!< HCLK frequency to set FLASH latency 3 in power scale 1 */ 00068 #define UTILS_SCALE1_LATENCY4_FREQ 80000000U /*!< HCLK frequency to set FLASH latency 4 in power scale 1 */ 00069 #define UTILS_SCALE1_LATENCY5_FREQ 100000000U /*!< HCLK frequency to set FLASH latency 4 in power scale 1 */ 00070 #define UTILS_SCALE2_LATENCY1_FREQ 8000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 2 */ 00071 #define UTILS_SCALE2_LATENCY2_FREQ 16000000U /*!< HCLK frequency to set FLASH latency 2 in power scale 2 */ 00072 #else 00073 #define UTILS_SCALE1_LATENCY1_FREQ 16000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 1 */ 00074 #define UTILS_SCALE1_LATENCY2_FREQ 32000000U /*!< HCLK frequency to set FLASH latency 2 in power scale 1 */ 00075 #define UTILS_SCALE1_LATENCY3_FREQ 48000000U /*!< HCLK frequency to set FLASH latency 3 in power scale 1 */ 00076 #define UTILS_SCALE1_LATENCY4_FREQ 64000000U /*!< HCLK frequency to set FLASH latency 4 in power scale 1 */ 00077 #define UTILS_SCALE2_LATENCY1_FREQ 6000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 2 */ 00078 #define UTILS_SCALE2_LATENCY2_FREQ 12000000U /*!< HCLK frequency to set FLASH latency 2 in power scale 2 */ 00079 #define UTILS_SCALE2_LATENCY3_FREQ 18000000U /*!< HCLK frequency to set FLASH latency 3 in power scale 2 */ 00080 #endif 00081 /** 00082 * @} 00083 */ 00084 00085 /* Private macros ------------------------------------------------------------*/ 00086 /** @addtogroup UTILS_LL_Private_Macros 00087 * @{ 00088 */ 00089 #define IS_LL_UTILS_SYSCLK_DIV(__VALUE__) (((__VALUE__) == LL_RCC_SYSCLK_DIV_1) \ 00090 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_2) \ 00091 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_4) \ 00092 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_8) \ 00093 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_16) \ 00094 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_64) \ 00095 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_128) \ 00096 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_256) \ 00097 || ((__VALUE__) == LL_RCC_SYSCLK_DIV_512)) 00098 00099 #define IS_LL_UTILS_APB1_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB1_DIV_1) \ 00100 || ((__VALUE__) == LL_RCC_APB1_DIV_2) \ 00101 || ((__VALUE__) == LL_RCC_APB1_DIV_4) \ 00102 || ((__VALUE__) == LL_RCC_APB1_DIV_8) \ 00103 || ((__VALUE__) == LL_RCC_APB1_DIV_16)) 00104 00105 #define IS_LL_UTILS_APB2_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB2_DIV_1) \ 00106 || ((__VALUE__) == LL_RCC_APB2_DIV_2) \ 00107 || ((__VALUE__) == LL_RCC_APB2_DIV_4) \ 00108 || ((__VALUE__) == LL_RCC_APB2_DIV_8) \ 00109 || ((__VALUE__) == LL_RCC_APB2_DIV_16)) 00110 00111 #define IS_LL_UTILS_PLLM_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLLM_DIV_1) \ 00112 || ((__VALUE__) == LL_RCC_PLLM_DIV_2) \ 00113 || ((__VALUE__) == LL_RCC_PLLM_DIV_3) \ 00114 || ((__VALUE__) == LL_RCC_PLLM_DIV_4) \ 00115 || ((__VALUE__) == LL_RCC_PLLM_DIV_5) \ 00116 || ((__VALUE__) == LL_RCC_PLLM_DIV_6) \ 00117 || ((__VALUE__) == LL_RCC_PLLM_DIV_7) \ 00118 || ((__VALUE__) == LL_RCC_PLLM_DIV_8)) 00119 00120 #define IS_LL_UTILS_PLLN_VALUE(__VALUE__) ((8U <= (__VALUE__)) && ((__VALUE__) <= 86U)) 00121 00122 #define IS_LL_UTILS_PLLR_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLLR_DIV_2) \ 00123 || ((__VALUE__) == LL_RCC_PLLR_DIV_4) \ 00124 || ((__VALUE__) == LL_RCC_PLLR_DIV_6) \ 00125 || ((__VALUE__) == LL_RCC_PLLR_DIV_8)) 00126 00127 #define IS_LL_UTILS_PLLVCO_INPUT(__VALUE__) ((UTILS_PLLVCO_INPUT_MIN <= (__VALUE__)) && ((__VALUE__) <= UTILS_PLLVCO_INPUT_MAX)) 00128 00129 #define IS_LL_UTILS_PLLVCO_OUTPUT(__VALUE__) ((UTILS_PLLVCO_OUTPUT_MIN <= (__VALUE__)) && ((__VALUE__) <= UTILS_PLLVCO_OUTPUT_MAX)) 00130 00131 #define IS_LL_UTILS_PLL_FREQUENCY(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE1) : \ 00132 ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE2)) 00133 00134 #define IS_LL_UTILS_HSE_BYPASS(__STATE__) (((__STATE__) == LL_UTILS_HSEBYPASS_ON) \ 00135 || ((__STATE__) == LL_UTILS_HSEBYPASS_OFF)) 00136 00137 #define IS_LL_UTILS_HSE_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) >= UTILS_HSE_FREQUENCY_MIN) && ((__FREQUENCY__) <= UTILS_HSE_FREQUENCY_MAX)) 00138 /** 00139 * @} 00140 */ 00141 /* Private function prototypes -----------------------------------------------*/ 00142 /** @defgroup UTILS_LL_Private_Functions UTILS Private functions 00143 * @{ 00144 */ 00145 static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, 00146 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct); 00147 static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct); 00148 static ErrorStatus UTILS_PLL_IsBusy(void); 00149 /** 00150 * @} 00151 */ 00152 00153 /* Exported functions --------------------------------------------------------*/ 00154 /** @addtogroup UTILS_LL_Exported_Functions 00155 * @{ 00156 */ 00157 00158 /** @addtogroup UTILS_LL_EF_DELAY 00159 * @{ 00160 */ 00161 00162 /** 00163 * @brief This function configures the Cortex-M SysTick source to have 1ms time base. 00164 * @note When a RTOS is used, it is recommended to avoid changing the Systick 00165 * configuration by calling this function, for a delay use rather osDelay RTOS service. 00166 * @param HCLKFrequency HCLK frequency in Hz 00167 * @note HCLK frequency can be calculated thanks to RCC helper macro or function @ref LL_RCC_GetSystemClocksFreq 00168 * @retval None 00169 */ 00170 void LL_Init1msTick(uint32_t HCLKFrequency) 00171 { 00172 /* Use frequency provided in argument */ 00173 LL_InitTick(HCLKFrequency, 1000U); 00174 } 00175 00176 /** 00177 * @brief This function provides accurate delay (in milliseconds) based 00178 * on SysTick counter flag 00179 * @note When a RTOS is used, it is recommended to avoid using blocking delay 00180 * and use rather osDelay service. 00181 * @note To respect 1ms timebase, user should call @ref LL_Init1msTick function which 00182 * will configure Systick to 1ms 00183 * @param Delay specifies the delay time length, in milliseconds. 00184 * @retval None 00185 */ 00186 void LL_mDelay(uint32_t Delay) 00187 { 00188 __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */ 00189 uint32_t tmpDelay = Delay; 00190 00191 /* Add this code to indicate that local variable is not used */ 00192 ((void)tmp); 00193 00194 /* Add a period to guaranty minimum wait */ 00195 if(tmpDelay < LL_MAX_DELAY) 00196 { 00197 tmpDelay++; 00198 } 00199 00200 while (tmpDelay != 0U) 00201 { 00202 if((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U) 00203 { 00204 tmpDelay--; 00205 } 00206 } 00207 } 00208 00209 /** 00210 * @} 00211 */ 00212 00213 /** @addtogroup UTILS_EF_SYSTEM 00214 * @brief System Configuration functions 00215 * 00216 @verbatim 00217 =============================================================================== 00218 ##### System Configuration functions ##### 00219 =============================================================================== 00220 [..] 00221 System, AHB and APB buses clocks configuration 00222 00223 (+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is 00224 120000000 Hz for STM32L4Rx/STM32L4Sx devices and 80000000 Hz for others. 00225 @endverbatim 00226 @internal 00227 Depending on the device voltage range, the maximum frequency should be 00228 adapted accordingly: 00229 00230 (++) Table 1. HCLK clock frequency for STM32L4+ Series devices 00231 (++) +--------------------------------------------------------+ 00232 (++) | Latency | HCLK clock frequency (MHz) | 00233 (++) | |--------------------------------------| 00234 (++) | | voltage range 1 | voltage range 2 | 00235 (++) | | 1.2 V | 1.0 V | 00236 (++) |-----------------|-------------------|------------------| 00237 (++) |0WS(1 CPU cycles)| 0 < HCLK <= 20 | 0 < HCLK <= 8 | 00238 (++) |-----------------|-------------------|------------------| 00239 (++) |1WS(2 CPU cycles)| 20 < HCLK <= 40 | 8 < HCLK <= 16 | 00240 (++) |-----------------|-------------------|------------------| 00241 (++) |2WS(3 CPU cycles)| 40 < HCLK <= 60 | 16 < HCLK <= 26 | 00242 (++) |-----------------|-------------------|------------------| 00243 (++) |3WS(4 CPU cycles)| 60 < HCLK <= 80 | 16 < HCLK <= 26 | 00244 (++) |-----------------|-------------------|------------------| 00245 (++) |4WS(5 CPU cycles)| 80 < HCLK <= 100 | 16 < HCLK <= 26 | 00246 (++) |-----------------|-------------------|------------------| 00247 (++) |5WS(6 CPU cycles)| 100 < HCLK <= 120 | 16 < HCLK <= 26 | 00248 (++) +--------------------------------------------------------+ 00249 00250 (++) Table 2. HCLK clock frequency for STM32L4 Series devices 00251 (++) +-------------------------------------------------------+ 00252 (++) | Latency | HCLK clock frequency (MHz) | 00253 (++) | |-------------------------------------| 00254 (++) | | voltage range 1 | voltage range 2 | 00255 (++) | | 1.2 V | 1.0 V | 00256 (++) |-----------------|------------------|------------------| 00257 (++) |0WS(1 CPU cycles)| 0 < HCLK <= 16 | 0 < HCLK <= 6 | 00258 (++) |-----------------|------------------|------------------| 00259 (++) |1WS(2 CPU cycles)| 16 < HCLK <= 32 | 6 < HCLK <= 12 | 00260 (++) |-----------------|------------------|------------------| 00261 (++) |2WS(3 CPU cycles)| 32 < HCLK <= 48 | 12 < HCLK <= 18 | 00262 (++) |-----------------|------------------|------------------| 00263 (++) |3WS(4 CPU cycles)| 48 < HCLK <= 64 | 18 < HCLK <= 26 | 00264 (++) |-----------------|------------------|------------------| 00265 (++) |4WS(5 CPU cycles)| 64 < HCLK <= 80 | 18 < HCLK <= 26 | 00266 (++) +-------------------------------------------------------+ 00267 00268 @endinternal 00269 * @{ 00270 */ 00271 00272 /** 00273 * @brief This function sets directly SystemCoreClock CMSIS variable. 00274 * @note Variable can be calculated also through SystemCoreClockUpdate function. 00275 * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro) 00276 * @retval None 00277 */ 00278 void LL_SetSystemCoreClock(uint32_t HCLKFrequency) 00279 { 00280 /* HCLK clock frequency */ 00281 SystemCoreClock = HCLKFrequency; 00282 } 00283 00284 /** 00285 * @brief Update number of Flash wait states in line with new frequency and current 00286 voltage range. 00287 * @param HCLKFrequency HCLK frequency 00288 * @retval An ErrorStatus enumeration value: 00289 * - SUCCESS: Latency has been modified 00290 * - ERROR: Latency cannot be modified 00291 */ 00292 ErrorStatus LL_SetFlashLatency(uint32_t HCLKFrequency) 00293 { 00294 ErrorStatus status = SUCCESS; 00295 00296 uint32_t latency = LL_FLASH_LATENCY_0; /* default value 0WS */ 00297 00298 /* Frequency cannot be equal to 0 or greater than max clock */ 00299 if ((HCLKFrequency == 0U) || (HCLKFrequency > UTILS_MAX_FREQUENCY_SCALE1)) 00300 { 00301 status = ERROR; 00302 } 00303 else 00304 { 00305 if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) 00306 { 00307 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00308 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00309 if(HCLKFrequency > UTILS_SCALE1_LATENCY5_FREQ) 00310 { 00311 /* 100 < HCLK <= 120 => 5WS (6 CPU cycles) */ 00312 latency = LL_FLASH_LATENCY_5; 00313 } 00314 else if(HCLKFrequency > UTILS_SCALE1_LATENCY4_FREQ) 00315 { 00316 /* 80 < HCLK <= 100 => 4WS (5 CPU cycles) */ 00317 latency = LL_FLASH_LATENCY_4; 00318 } 00319 else if(HCLKFrequency > UTILS_SCALE1_LATENCY3_FREQ) 00320 { 00321 /* 60 < HCLK <= 80 => 3WS (4 CPU cycles) */ 00322 latency = LL_FLASH_LATENCY_3; 00323 } 00324 else if(HCLKFrequency > UTILS_SCALE1_LATENCY2_FREQ) 00325 { 00326 /* 40 < HCLK <= 20 => 2WS (3 CPU cycles) */ 00327 latency = LL_FLASH_LATENCY_2; 00328 } 00329 else 00330 { 00331 if(HCLKFrequency > UTILS_SCALE1_LATENCY1_FREQ) 00332 { 00333 /* 20 < HCLK <= 40 => 1WS (2 CPU cycles) */ 00334 latency = LL_FLASH_LATENCY_1; 00335 } 00336 /* else HCLKFrequency <= 10MHz default LL_FLASH_LATENCY_0 0WS */ 00337 } 00338 #else 00339 if(HCLKFrequency > UTILS_SCALE1_LATENCY4_FREQ) 00340 { 00341 /* 64 < HCLK <= 80 => 4WS (5 CPU cycles) */ 00342 latency = LL_FLASH_LATENCY_4; 00343 } 00344 else if(HCLKFrequency > UTILS_SCALE1_LATENCY3_FREQ) 00345 { 00346 /* 48 < HCLK <= 64 => 3WS (4 CPU cycles) */ 00347 latency = LL_FLASH_LATENCY_3; 00348 } 00349 else if(HCLKFrequency > UTILS_SCALE1_LATENCY2_FREQ) 00350 { 00351 /* 32 < HCLK <= 48 => 2WS (3 CPU cycles) */ 00352 latency = LL_FLASH_LATENCY_2; 00353 } 00354 else 00355 { 00356 if(HCLKFrequency > UTILS_SCALE1_LATENCY1_FREQ) 00357 { 00358 /* 16 < HCLK <= 32 => 1WS (2 CPU cycles) */ 00359 latency = LL_FLASH_LATENCY_1; 00360 } 00361 /* else HCLKFrequency <= 16MHz default LL_FLASH_LATENCY_0 0WS */ 00362 } 00363 #endif 00364 } 00365 else /* SCALE2 */ 00366 { 00367 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00368 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00369 if(HCLKFrequency > UTILS_MAX_FREQUENCY_SCALE2) 00370 { 00371 /* Unexpected HCLK > 26 */ 00372 status = ERROR; 00373 } 00374 else if(HCLKFrequency > UTILS_SCALE2_LATENCY2_FREQ) 00375 { 00376 /* 16 < HCLK <= 26 => 2WS (3 CPU cycles) */ 00377 latency = LL_FLASH_LATENCY_2; 00378 } 00379 else 00380 { 00381 if(HCLKFrequency > UTILS_SCALE2_LATENCY1_FREQ) 00382 { 00383 /* 8 < HCLK <= 16 => 1WS (2 CPU cycles) */ 00384 latency = LL_FLASH_LATENCY_1; 00385 } 00386 /* else HCLKFrequency <= 8MHz default LL_FLASH_LATENCY_0 0WS */ 00387 } 00388 #else 00389 if(HCLKFrequency > UTILS_MAX_FREQUENCY_SCALE2) 00390 { 00391 /* Unexpected HCLK > 26 */ 00392 status = ERROR; 00393 } 00394 else if(HCLKFrequency > UTILS_SCALE2_LATENCY3_FREQ) 00395 { 00396 /* 18 < HCLK <= 26 => 3WS (4 CPU cycles) */ 00397 latency = LL_FLASH_LATENCY_3; 00398 } 00399 else if(HCLKFrequency > UTILS_SCALE2_LATENCY2_FREQ) 00400 { 00401 /* 12 < HCLK <= 18 => 2WS (3 CPU cycles) */ 00402 latency = LL_FLASH_LATENCY_2; 00403 } 00404 else 00405 { 00406 if(HCLKFrequency > UTILS_SCALE2_LATENCY1_FREQ) 00407 { 00408 /* 6 < HCLK <= 12 => 1WS (2 CPU cycles) */ 00409 latency = LL_FLASH_LATENCY_1; 00410 } 00411 /* else HCLKFrequency <= 6MHz default LL_FLASH_LATENCY_0 0WS */ 00412 } 00413 #endif 00414 } 00415 00416 LL_FLASH_SetLatency(latency); 00417 00418 /* Check that the new number of wait states is taken into account to access the Flash 00419 memory by reading the FLASH_ACR register */ 00420 if(LL_FLASH_GetLatency() != latency) 00421 { 00422 status = ERROR; 00423 } 00424 } 00425 return status; 00426 } 00427 00428 /** 00429 * @brief This function configures system clock with MSI as clock source of the PLL 00430 * @note The application needs to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled. 00431 * @note Function is based on the following formula: 00432 * - PLL output frequency = (((MSI frequency / PLLM) * PLLN) / PLLR) 00433 * - PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = MSI frequency / PLLM) 00434 * - PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN) 00435 * - PLLR: ensure that max frequency at 120000000 Hz is reached (PLLVCO_output / PLLR) 00436 * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains 00437 * the configuration information for the PLL. 00438 * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains 00439 * the configuration information for the BUS prescalers. 00440 * @retval An ErrorStatus enumeration value: 00441 * - SUCCESS: Max frequency configuration done 00442 * - ERROR: Max frequency configuration not done 00443 */ 00444 ErrorStatus LL_PLL_ConfigSystemClock_MSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00445 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) 00446 { 00447 ErrorStatus status = SUCCESS; 00448 uint32_t pllfreq, msi_range; 00449 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00450 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00451 uint32_t hpre = 0U; /* Set default value */ 00452 #endif 00453 00454 /* Check if one of the PLL is enabled */ 00455 if(UTILS_PLL_IsBusy() == SUCCESS) 00456 { 00457 /* Get the current MSI range */ 00458 if(LL_RCC_MSI_IsEnabledRangeSelect() != 0U) 00459 { 00460 msi_range = LL_RCC_MSI_GetRange(); 00461 switch (msi_range) 00462 { 00463 case LL_RCC_MSIRANGE_0: /* MSI = 100 KHz */ 00464 case LL_RCC_MSIRANGE_1: /* MSI = 200 KHz */ 00465 case LL_RCC_MSIRANGE_2: /* MSI = 400 KHz */ 00466 case LL_RCC_MSIRANGE_3: /* MSI = 800 KHz */ 00467 case LL_RCC_MSIRANGE_4: /* MSI = 1 MHz */ 00468 case LL_RCC_MSIRANGE_5: /* MSI = 2 MHz */ 00469 /* PLLVCO input frequency is not in the range from 4 to 16 MHz*/ 00470 status = ERROR; 00471 break; 00472 00473 case LL_RCC_MSIRANGE_6: /* MSI = 4 MHz */ 00474 case LL_RCC_MSIRANGE_7: /* MSI = 8 MHz */ 00475 case LL_RCC_MSIRANGE_8: /* MSI = 16 MHz */ 00476 case LL_RCC_MSIRANGE_9: /* MSI = 24 MHz */ 00477 case LL_RCC_MSIRANGE_10: /* MSI = 32 MHz */ 00478 case LL_RCC_MSIRANGE_11: /* MSI = 48 MHz */ 00479 default: 00480 break; 00481 } 00482 } 00483 else 00484 { 00485 msi_range = LL_RCC_MSI_GetRangeAfterStandby(); 00486 switch (msi_range) 00487 { 00488 case LL_RCC_MSISRANGE_4: /* MSI = 1 MHz */ 00489 case LL_RCC_MSISRANGE_5: /* MSI = 2 MHz */ 00490 /* PLLVCO input frequency is not in the range from 4 to 16 MHz*/ 00491 status = ERROR; 00492 break; 00493 00494 case LL_RCC_MSISRANGE_7: /* MSI = 8 MHz */ 00495 case LL_RCC_MSISRANGE_6: /* MSI = 4 MHz */ 00496 default: 00497 break; 00498 } 00499 } 00500 00501 /* Main PLL configuration and activation */ 00502 if(status != ERROR) 00503 { 00504 /* Calculate the new PLL output frequency */ 00505 pllfreq = UTILS_GetPLLOutputFrequency(__LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_IsEnabledRangeSelect(), msi_range), 00506 UTILS_PLLInitStruct); 00507 00508 /* Enable MSI if not enabled */ 00509 if(LL_RCC_MSI_IsReady() != 1U) 00510 { 00511 LL_RCC_MSI_Enable(); 00512 while ((LL_RCC_MSI_IsReady() != 1U)) 00513 { 00514 /* Wait for MSI ready */ 00515 } 00516 } 00517 00518 /* Configure PLL */ 00519 LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_MSI, UTILS_PLLInitStruct->PLLM, UTILS_PLLInitStruct->PLLN, 00520 UTILS_PLLInitStruct->PLLR); 00521 00522 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00523 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00524 /* Prevent undershoot at highest frequency by applying intermediate AHB prescaler 2 */ 00525 if(pllfreq > 80000000U) 00526 { 00527 if(UTILS_ClkInitStruct->AHBCLKDivider == LL_RCC_SYSCLK_DIV_1) 00528 { 00529 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_2; 00530 hpre = LL_RCC_SYSCLK_DIV_2; 00531 } 00532 } 00533 #endif 00534 /* Enable PLL and switch system clock to PLL */ 00535 status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct); 00536 00537 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00538 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00539 /* Apply definitive AHB prescaler value if necessary */ 00540 if((status == SUCCESS) && (hpre != LL_RCC_SYSCLK_DIV_1)) 00541 { 00542 /* Set FLASH latency to highest latency */ 00543 status = LL_SetFlashLatency(pllfreq); 00544 if(status == SUCCESS) 00545 { 00546 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_1; 00547 LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider); 00548 LL_SetSystemCoreClock(pllfreq); 00549 } 00550 } 00551 #endif 00552 } 00553 } 00554 else 00555 { 00556 /* Current PLL configuration cannot be modified */ 00557 status = ERROR; 00558 } 00559 00560 return status; 00561 } 00562 00563 /** 00564 * @brief This function configures system clock at maximum frequency with HSI as clock source of the PLL 00565 * @note The application need to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled. 00566 * @note Function is based on the following formula: 00567 * - PLL output frequency = (((HSI frequency / PLLM) * PLLN) / PLLR) 00568 * - PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = HSI frequency / PLLM) 00569 * - PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN) 00570 * - PLLR: ensure that max frequency at 120000000 Hz is reach (PLLVCO_output / PLLR) 00571 * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains 00572 * the configuration information for the PLL. 00573 * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains 00574 * the configuration information for the BUS prescalers. 00575 * @retval An ErrorStatus enumeration value: 00576 * - SUCCESS: Max frequency configuration done 00577 * - ERROR: Max frequency configuration not done 00578 */ 00579 ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, 00580 LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) 00581 { 00582 ErrorStatus status; 00583 uint32_t pllfreq; 00584 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00585 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00586 uint32_t hpre = LL_RCC_SYSCLK_DIV_1; /* Set default value */ 00587 #endif 00588 00589 /* Check if one of the PLL is enabled */ 00590 if(UTILS_PLL_IsBusy() == SUCCESS) 00591 { 00592 /* Calculate the new PLL output frequency */ 00593 pllfreq = UTILS_GetPLLOutputFrequency(HSI_VALUE, UTILS_PLLInitStruct); 00594 00595 /* Enable HSI if not enabled */ 00596 if(LL_RCC_HSI_IsReady() != 1U) 00597 { 00598 LL_RCC_HSI_Enable(); 00599 while (LL_RCC_HSI_IsReady() != 1U) 00600 { 00601 /* Wait for HSI ready */ 00602 } 00603 } 00604 00605 /* Configure PLL */ 00606 LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, UTILS_PLLInitStruct->PLLM, UTILS_PLLInitStruct->PLLN, 00607 UTILS_PLLInitStruct->PLLR); 00608 00609 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00610 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00611 /* Prevent undershoot at highest frequency by applying intermediate AHB prescaler 2 */ 00612 if(pllfreq > 80000000U) 00613 { 00614 if(UTILS_ClkInitStruct->AHBCLKDivider == LL_RCC_SYSCLK_DIV_1) 00615 { 00616 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_2; 00617 hpre = LL_RCC_SYSCLK_DIV_2; 00618 } 00619 } 00620 #endif 00621 /* Enable PLL and switch system clock to PLL */ 00622 status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct); 00623 00624 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00625 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00626 /* Apply definitive AHB prescaler value if necessary */ 00627 if((status == SUCCESS) && (hpre != LL_RCC_SYSCLK_DIV_1)) 00628 { 00629 /* Set FLASH latency to highest latency */ 00630 status = LL_SetFlashLatency(pllfreq); 00631 if(status == SUCCESS) 00632 { 00633 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_1; 00634 LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider); 00635 LL_SetSystemCoreClock(pllfreq); 00636 } 00637 } 00638 #endif 00639 } 00640 else 00641 { 00642 /* Current PLL configuration cannot be modified */ 00643 status = ERROR; 00644 } 00645 00646 return status; 00647 } 00648 00649 /** 00650 * @brief This function configures system clock with HSE as clock source of the PLL 00651 * @note The application need to ensure that PLL, PLLSAI1 and/or PLLSAI2 are disabled. 00652 * @note Function is based on the following formula: 00653 * - PLL output frequency = (((HSE frequency / PLLM) * PLLN) / PLLR) 00654 * - PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz (PLLVCO_input = HSE frequency / PLLM) 00655 * - PLLN: ensure that the VCO output frequency is between 64 and 344 MHz (PLLVCO_output = PLLVCO_input * PLLN) 00656 * - PLLR: ensure that max frequency at 120000000 Hz is reached (PLLVCO_output / PLLR) 00657 * @param HSEFrequency Value between Min_Data = 4000000 and Max_Data = 48000000 00658 * @param HSEBypass This parameter can be one of the following values: 00659 * @arg @ref LL_UTILS_HSEBYPASS_ON 00660 * @arg @ref LL_UTILS_HSEBYPASS_OFF 00661 * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains 00662 * the configuration information for the PLL. 00663 * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains 00664 * the configuration information for the BUS prescalers. 00665 * @retval An ErrorStatus enumeration value: 00666 * - SUCCESS: Max frequency configuration done 00667 * - ERROR: Max frequency configuration not done 00668 */ 00669 ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass, 00670 LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) 00671 { 00672 ErrorStatus status; 00673 uint32_t pllfreq; 00674 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00675 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00676 uint32_t hpre = 0U; /* Set default value */ 00677 #endif 00678 00679 /* Check the parameters */ 00680 assert_param(IS_LL_UTILS_HSE_FREQUENCY(HSEFrequency)); 00681 assert_param(IS_LL_UTILS_HSE_BYPASS(HSEBypass)); 00682 00683 /* Check if one of the PLL is enabled */ 00684 if(UTILS_PLL_IsBusy() == SUCCESS) 00685 { 00686 /* Calculate the new PLL output frequency */ 00687 pllfreq = UTILS_GetPLLOutputFrequency(HSEFrequency, UTILS_PLLInitStruct); 00688 00689 /* Enable HSE if not enabled */ 00690 if(LL_RCC_HSE_IsReady() != 1U) 00691 { 00692 /* Check if need to enable HSE bypass feature or not */ 00693 if(HSEBypass == LL_UTILS_HSEBYPASS_ON) 00694 { 00695 LL_RCC_HSE_EnableBypass(); 00696 } 00697 else 00698 { 00699 LL_RCC_HSE_DisableBypass(); 00700 } 00701 00702 /* Enable HSE */ 00703 LL_RCC_HSE_Enable(); 00704 while (LL_RCC_HSE_IsReady() != 1U) 00705 { 00706 /* Wait for HSE ready */ 00707 } 00708 } 00709 00710 /* Configure PLL */ 00711 LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, UTILS_PLLInitStruct->PLLM, UTILS_PLLInitStruct->PLLN, 00712 UTILS_PLLInitStruct->PLLR); 00713 00714 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00715 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00716 /* Prevent undershoot at highest frequency by applying intermediate AHB prescaler 2 */ 00717 if(pllfreq > 80000000U) 00718 { 00719 if(UTILS_ClkInitStruct->AHBCLKDivider == LL_RCC_SYSCLK_DIV_1) 00720 { 00721 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_2; 00722 hpre = LL_RCC_SYSCLK_DIV_2; 00723 } 00724 } 00725 #endif 00726 /* Enable PLL and switch system clock to PLL */ 00727 status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct); 00728 00729 #if defined(STM32L4P5xx) || defined(STM32L4Q5xx) || \ 00730 defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx) 00731 /* Apply definitive AHB prescaler value if necessary */ 00732 if((status == SUCCESS) && (hpre != LL_RCC_SYSCLK_DIV_1)) 00733 { 00734 /* Set FLASH latency to highest latency */ 00735 status = LL_SetFlashLatency(pllfreq); 00736 if(status == SUCCESS) 00737 { 00738 UTILS_ClkInitStruct->AHBCLKDivider = LL_RCC_SYSCLK_DIV_1; 00739 LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider); 00740 LL_SetSystemCoreClock(pllfreq); 00741 } 00742 } 00743 #endif 00744 } 00745 else 00746 { 00747 /* Current PLL configuration cannot be modified */ 00748 status = ERROR; 00749 } 00750 00751 return status; 00752 } 00753 00754 /** 00755 * @} 00756 */ 00757 00758 /** 00759 * @} 00760 */ 00761 00762 /** @addtogroup UTILS_LL_Private_Functions 00763 * @{ 00764 */ 00765 /** 00766 * @brief Function to check that PLL can be modified 00767 * @param PLL_InputFrequency PLL input frequency (in Hz) 00768 * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains 00769 * the configuration information for the PLL. 00770 * @retval PLL output frequency (in Hz) 00771 */ 00772 static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct) 00773 { 00774 uint32_t pllfreq; 00775 00776 /* Check the parameters */ 00777 assert_param(IS_LL_UTILS_PLLM_VALUE(UTILS_PLLInitStruct->PLLM)); 00778 assert_param(IS_LL_UTILS_PLLN_VALUE(UTILS_PLLInitStruct->PLLN)); 00779 assert_param(IS_LL_UTILS_PLLR_VALUE(UTILS_PLLInitStruct->PLLR)); 00780 00781 /* Check different PLL parameters according to RM */ 00782 /* - PLLM: ensure that the VCO input frequency ranges from 4 to 16 MHz. */ 00783 pllfreq = PLL_InputFrequency / (((UTILS_PLLInitStruct->PLLM >> RCC_PLLCFGR_PLLM_Pos) + 1U)); 00784 assert_param(IS_LL_UTILS_PLLVCO_INPUT(pllfreq)); 00785 00786 /* - PLLN: ensure that the VCO output frequency is between 64 and 344 MHz.*/ 00787 pllfreq = pllfreq * (UTILS_PLLInitStruct->PLLN & (RCC_PLLCFGR_PLLN >> RCC_PLLCFGR_PLLN_Pos)); 00788 assert_param(IS_LL_UTILS_PLLVCO_OUTPUT(pllfreq)); 00789 00790 /* - PLLR: ensure that max frequency at 120000000 Hz is reached */ 00791 pllfreq = pllfreq / (((UTILS_PLLInitStruct->PLLR >> RCC_PLLCFGR_PLLR_Pos) + 1U) * 2U); 00792 assert_param(IS_LL_UTILS_PLL_FREQUENCY(pllfreq)); 00793 00794 return pllfreq; 00795 } 00796 00797 /** 00798 * @brief Function to check that PLL can be modified 00799 * @retval An ErrorStatus enumeration value: 00800 * - SUCCESS: PLL modification can be done 00801 * - ERROR: PLL is busy 00802 */ 00803 static ErrorStatus UTILS_PLL_IsBusy(void) 00804 { 00805 ErrorStatus status = SUCCESS; 00806 00807 /* Check if PLL is busy*/ 00808 if(LL_RCC_PLL_IsReady() != 0U) 00809 { 00810 /* PLL configuration cannot be modified */ 00811 status = ERROR; 00812 } 00813 00814 #if defined(RCC_PLLSAI1_SUPPORT) 00815 /* Check if PLLSAI1 is busy*/ 00816 if(LL_RCC_PLLSAI1_IsReady() != 0U) 00817 { 00818 /* PLLSAI1 configuration cannot be modified */ 00819 status = ERROR; 00820 } 00821 #endif /*RCC_PLLSAI1_SUPPORT*/ 00822 #if defined(RCC_PLLSAI2_SUPPORT) 00823 00824 /* Check if PLLSAI2 is busy*/ 00825 if(LL_RCC_PLLSAI2_IsReady() != 0U) 00826 { 00827 /* PLLSAI2 configuration cannot be modified */ 00828 status = ERROR; 00829 } 00830 #endif /*RCC_PLLSAI2_SUPPORT*/ 00831 00832 return status; 00833 } 00834 00835 /** 00836 * @brief Function to enable PLL and switch system clock to PLL 00837 * @param SYSCLK_Frequency SYSCLK frequency 00838 * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains 00839 * the configuration information for the BUS prescalers. 00840 * @retval An ErrorStatus enumeration value: 00841 * - SUCCESS: No problem to switch system to PLL 00842 * - ERROR: Problem to switch system to PLL 00843 */ 00844 static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct) 00845 { 00846 ErrorStatus status = SUCCESS; 00847 uint32_t hclk_frequency; 00848 00849 assert_param(IS_LL_UTILS_SYSCLK_DIV(UTILS_ClkInitStruct->AHBCLKDivider)); 00850 assert_param(IS_LL_UTILS_APB1_DIV(UTILS_ClkInitStruct->APB1CLKDivider)); 00851 assert_param(IS_LL_UTILS_APB2_DIV(UTILS_ClkInitStruct->APB2CLKDivider)); 00852 00853 /* Calculate HCLK frequency */ 00854 hclk_frequency = __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, UTILS_ClkInitStruct->AHBCLKDivider); 00855 00856 /* Increasing the number of wait states because of higher CPU frequency */ 00857 if(SystemCoreClock < hclk_frequency) 00858 { 00859 /* Set FLASH latency to highest latency */ 00860 status = LL_SetFlashLatency(hclk_frequency); 00861 } 00862 00863 /* Update system clock configuration */ 00864 if(status == SUCCESS) 00865 { 00866 /* Enable PLL */ 00867 LL_RCC_PLL_Enable(); 00868 LL_RCC_PLL_EnableDomain_SYS(); 00869 while (LL_RCC_PLL_IsReady() != 1U) 00870 { 00871 /* Wait for PLL ready */ 00872 } 00873 00874 /* Sysclk activation on the main PLL */ 00875 LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider); 00876 LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL); 00877 while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) 00878 { 00879 /* Wait for system clock switch to PLL */ 00880 } 00881 00882 /* Set APB1 & APB2 prescaler*/ 00883 LL_RCC_SetAPB1Prescaler(UTILS_ClkInitStruct->APB1CLKDivider); 00884 LL_RCC_SetAPB2Prescaler(UTILS_ClkInitStruct->APB2CLKDivider); 00885 } 00886 00887 /* Decreasing the number of wait states because of lower CPU frequency */ 00888 if(SystemCoreClock > hclk_frequency) 00889 { 00890 /* Set FLASH latency to lowest latency */ 00891 status = LL_SetFlashLatency(hclk_frequency); 00892 } 00893 00894 /* Update SystemCoreClock variable */ 00895 if(status == SUCCESS) 00896 { 00897 LL_SetSystemCoreClock(hclk_frequency); 00898 } 00899 00900 return status; 00901 } 00902 00903 /** 00904 * @} 00905 */ 00906 00907 /** 00908 * @} 00909 */ 00910 00911 /** 00912 * @} 00913 */