Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
stm32l4xx_hal.c
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal.c 00004 * @author MCD Application Team 00005 * @version V1.5.1 00006 * @date 31-May-2016 00007 * @brief HAL module driver. 00008 * This is the common part of the HAL initialization 00009 * 00010 @verbatim 00011 ============================================================================== 00012 ##### How to use this driver ##### 00013 ============================================================================== 00014 [..] 00015 The common HAL driver contains a set of generic and common APIs that can be 00016 used by the PPP peripheral drivers and the user to start using the HAL. 00017 [..] 00018 The HAL contains two APIs' categories: 00019 (+) Common HAL APIs 00020 (+) Services HAL APIs 00021 00022 @endverbatim 00023 ****************************************************************************** 00024 * @attention 00025 * 00026 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 00027 * 00028 * Redistribution and use in source and binary forms, with or without modification, 00029 * are permitted provided that the following conditions are met: 00030 * 1. Redistributions of source code must retain the above copyright notice, 00031 * this list of conditions and the following disclaimer. 00032 * 2. Redistributions in binary form must reproduce the above copyright notice, 00033 * this list of conditions and the following disclaimer in the documentation 00034 * and/or other materials provided with the distribution. 00035 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00036 * may be used to endorse or promote products derived from this software 00037 * without specific prior written permission. 00038 * 00039 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00040 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00041 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00042 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00043 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00044 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00045 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00046 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00047 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00048 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00049 * 00050 ****************************************************************************** 00051 */ 00052 00053 /* Includes ------------------------------------------------------------------*/ 00054 #include "stm32l4xx_hal.h" 00055 00056 /** @addtogroup STM32L4xx_HAL_Driver 00057 * @{ 00058 */ 00059 00060 /** @defgroup HAL HAL 00061 * @brief HAL module driver 00062 * @{ 00063 */ 00064 00065 #ifdef HAL_MODULE_ENABLED 00066 00067 /* Private typedef -----------------------------------------------------------*/ 00068 /* Private define ------------------------------------------------------------*/ 00069 /** 00070 * @brief STM32L4xx HAL Driver version number V1.5.1 00071 */ 00072 #define __STM32L4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ 00073 #define __STM32L4xx_HAL_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */ 00074 #define __STM32L4xx_HAL_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ 00075 #define __STM32L4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ 00076 #define __STM32L4xx_HAL_VERSION ((__STM32L4xx_HAL_VERSION_MAIN << 24)\ 00077 |(__STM32L4xx_HAL_VERSION_SUB1 << 16)\ 00078 |(__STM32L4xx_HAL_VERSION_SUB2 << 8 )\ 00079 |(__STM32L4xx_HAL_VERSION_RC)) 00080 00081 #if defined(VREFBUF) 00082 #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms (to be confirmed) */ 00083 #endif /* VREFBUF */ 00084 00085 /* ------------ SYSCFG registers bit address in the alias region ------------ */ 00086 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) 00087 /* --- MEMRMP Register ---*/ 00088 /* Alias word address of FB_MODE bit */ 00089 #define MEMRMP_OFFSET SYSCFG_OFFSET 00090 #define FB_MODE_BitNumber ((uint8_t)0x8) 00091 #define FB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (FB_MODE_BitNumber * 4)) 00092 00093 /* --- SCSR Register ---*/ 00094 /* Alias word address of SRAM2ER bit */ 00095 #define SCSR_OFFSET (SYSCFG_OFFSET + 0x18) 00096 #define BRER_BitNumber ((uint8_t)0x0) 00097 #define SCSR_SRAM2ER_BB (PERIPH_BB_BASE + (SCSR_OFFSET * 32) + (BRER_BitNumber * 4)) 00098 00099 /* Private macro -------------------------------------------------------------*/ 00100 /* Private variables ---------------------------------------------------------*/ 00101 __IO uint32_t uwTick; 00102 00103 /* Private function prototypes -----------------------------------------------*/ 00104 /* Exported functions --------------------------------------------------------*/ 00105 00106 /** @defgroup HAL_Exported_Functions HAL Exported Functions 00107 * @{ 00108 */ 00109 00110 /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions 00111 * @brief Initialization and de-initialization functions 00112 * 00113 @verbatim 00114 =============================================================================== 00115 ##### Initialization and de-initialization functions ##### 00116 =============================================================================== 00117 [..] This section provides functions allowing to: 00118 (+) Initialize the Flash interface the NVIC allocation and initial time base 00119 clock configuration. 00120 (+) De-initialize common part of the HAL. 00121 (+) Configure the time base source to have 1ms time base with a dedicated 00122 Tick interrupt priority. 00123 (++) SysTick timer is used by default as source of time base, but user 00124 can eventually implement his proper time base source (a general purpose 00125 timer for example or other time source), keeping in mind that Time base 00126 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 00127 handled in milliseconds basis. 00128 (++) Time base configuration function (HAL_InitTick ()) is called automatically 00129 at the beginning of the program after reset by HAL_Init() or at any time 00130 when clock is configured, by HAL_RCC_ClockConfig(). 00131 (++) Source of time base is configured to generate interrupts at regular 00132 time intervals. Care must be taken if HAL_Delay() is called from a 00133 peripheral ISR process, the Tick interrupt line must have higher priority 00134 (numerically lower) than the peripheral interrupt. Otherwise the caller 00135 ISR process will be blocked. 00136 (++) functions affecting time base configurations are declared as __weak 00137 to make override possible in case of other implementations in user file. 00138 @endverbatim 00139 * @{ 00140 */ 00141 00142 /** 00143 * @brief Configure the Flash prefetch, the Instruction and Data caches, 00144 * the time base source, NVIC and any required global low level hardware 00145 * by calling the HAL_MspInit() callback function to be optionally defined in user file 00146 * stm32l4xx_hal_msp.c. 00147 * 00148 * @note HAL_Init() function is called at the beginning of program after reset and before 00149 * the clock configuration. 00150 * 00151 * @note In the default implementation the System Timer (Systick) is used as source of time base. 00152 * The Systick configuration is based on MSI clock, as MSI is the clock 00153 * used after a system Reset and the NVIC configuration is set to Priority group 4. 00154 * Once done, time base tick starts incrementing: the tick variable counter is incremented 00155 * each 1ms in the SysTick_Handler() interrupt handler. 00156 * 00157 * @retval HAL status 00158 */ 00159 HAL_StatusTypeDef HAL_Init(void) 00160 { 00161 /* Configure Flash prefetch, Instruction cache, Data cache */ 00162 /* Default configuration at reset is: */ 00163 /* - Prefetch disabled */ 00164 /* - Instruction cache enabled */ 00165 /* - Data cache enabled */ 00166 #if (INSTRUCTION_CACHE_ENABLE == 0) 00167 __HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); 00168 #endif /* INSTRUCTION_CACHE_ENABLE */ 00169 00170 #if (DATA_CACHE_ENABLE == 0) 00171 __HAL_FLASH_DATA_CACHE_DISABLE(); 00172 #endif /* DATA_CACHE_ENABLE */ 00173 00174 #if (PREFETCH_ENABLE != 0) 00175 __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); 00176 #endif /* PREFETCH_ENABLE */ 00177 00178 /* Set Interrupt Group Priority */ 00179 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 00180 00181 /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */ 00182 HAL_InitTick(TICK_INT_PRIORITY); 00183 00184 /* Init the low level hardware */ 00185 HAL_MspInit(); 00186 00187 /* Return function status */ 00188 return HAL_OK; 00189 } 00190 00191 /** 00192 * @brief De-initialize common part of the HAL and stop the source of time base. 00193 * @note This function is optional. 00194 * @retval HAL status 00195 */ 00196 HAL_StatusTypeDef HAL_DeInit(void) 00197 { 00198 /* Reset of all peripherals */ 00199 __HAL_RCC_APB1_FORCE_RESET(); 00200 __HAL_RCC_APB1_RELEASE_RESET(); 00201 00202 __HAL_RCC_APB2_FORCE_RESET(); 00203 __HAL_RCC_APB2_RELEASE_RESET(); 00204 00205 __HAL_RCC_AHB1_FORCE_RESET(); 00206 __HAL_RCC_AHB1_RELEASE_RESET(); 00207 00208 __HAL_RCC_AHB2_FORCE_RESET(); 00209 __HAL_RCC_AHB2_RELEASE_RESET(); 00210 00211 __HAL_RCC_AHB3_FORCE_RESET(); 00212 __HAL_RCC_AHB3_RELEASE_RESET(); 00213 00214 /* De-Init the low level hardware */ 00215 HAL_MspDeInit(); 00216 00217 /* Return function status */ 00218 return HAL_OK; 00219 } 00220 00221 /** 00222 * @brief Initialize the MSP. 00223 * @retval None 00224 */ 00225 __weak void HAL_MspInit(void) 00226 { 00227 /* NOTE : This function should not be modified, when the callback is needed, 00228 the HAL_MspInit could be implemented in the user file 00229 */ 00230 } 00231 00232 /** 00233 * @brief DeInitialize the MSP. 00234 * @retval None 00235 */ 00236 __weak void HAL_MspDeInit(void) 00237 { 00238 /* NOTE : This function should not be modified, when the callback is needed, 00239 the HAL_MspDeInit could be implemented in the user file 00240 */ 00241 } 00242 00243 /** 00244 * @brief This function configures the source of the time base: 00245 * The time source is configured to have 1ms time base with a dedicated 00246 * Tick interrupt priority. 00247 * @note This function is called automatically at the beginning of program after 00248 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). 00249 * @note In the default implementation, SysTick timer is the source of time base. 00250 * It is used to generate interrupts at regular time intervals. 00251 * Care must be taken if HAL_Delay() is called from a peripheral ISR process, 00252 * The SysTick interrupt must have higher priority (numerically lower) 00253 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. 00254 * The function is declared as __weak to be overwritten in case of other 00255 * implementation in user file. 00256 * @param TickPriority: Tick interrupt priority. 00257 * @retval HAL status 00258 */ 00259 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 00260 { 00261 /*Configure the SysTick to have interrupt in 1ms time basis*/ 00262 HAL_SYSTICK_Config(SystemCoreClock/1000); 00263 00264 /*Configure the SysTick IRQ priority */ 00265 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0); 00266 00267 /* Return function status */ 00268 return HAL_OK; 00269 } 00270 00271 /** 00272 * @} 00273 */ 00274 00275 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions 00276 * @brief HAL Control functions 00277 * 00278 @verbatim 00279 =============================================================================== 00280 ##### HAL Control functions ##### 00281 =============================================================================== 00282 [..] This section provides functions allowing to: 00283 (+) Provide a tick value in millisecond 00284 (+) Provide a blocking delay in millisecond 00285 (+) Suspend the time base source interrupt 00286 (+) Resume the time base source interrupt 00287 (+) Get the HAL API driver version 00288 (+) Get the device identifier 00289 (+) Get the device revision identifier 00290 00291 @endverbatim 00292 * @{ 00293 */ 00294 00295 /** 00296 * @brief This function is called to increment a global variable "uwTick" 00297 * used as application time base. 00298 * @note In the default implementation, this variable is incremented each 1ms 00299 * in SysTick ISR. 00300 * @note This function is declared as __weak to be overwritten in case of other 00301 * implementations in user file. 00302 * @retval None 00303 */ 00304 __weak void HAL_IncTick(void) 00305 { 00306 uwTick++; 00307 } 00308 00309 /** 00310 * @brief Provide a tick value in millisecond. 00311 * @note This function is declared as __weak to be overwritten in case of other 00312 * implementations in user file. 00313 * @retval tick value 00314 */ 00315 __weak uint32_t HAL_GetTick(void) 00316 { 00317 return uwTick; 00318 } 00319 00320 /** 00321 * @brief Provide accurate delay (in milliseconds) based on variable incremented. 00322 * @note In the default implementation , SysTick timer is the source of time base. 00323 * It is used to generate interrupts at regular time intervals where uwTick 00324 * is incremented. 00325 * @note This function is declared as __weak to be overwritten in case of other 00326 * implementations in user file. 00327 * @param Delay: specifies the delay time length, in milliseconds. 00328 * @retval None 00329 */ 00330 __weak void HAL_Delay(uint32_t Delay) 00331 { 00332 uint32_t tickstart = 0; 00333 tickstart = HAL_GetTick(); 00334 while((HAL_GetTick() - tickstart) < Delay) 00335 { 00336 } 00337 } 00338 00339 /** 00340 * @brief Suspend Tick increment. 00341 * @note In the default implementation , SysTick timer is the source of time base. It is 00342 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() 00343 * is called, the SysTick interrupt will be disabled and so Tick increment 00344 * is suspended. 00345 * @note This function is declared as __weak to be overwritten in case of other 00346 * implementations in user file. 00347 * @retval None 00348 */ 00349 __weak void HAL_SuspendTick(void) 00350 { 00351 /* Disable SysTick Interrupt */ 00352 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; 00353 } 00354 00355 /** 00356 * @brief Resume Tick increment. 00357 * @note In the default implementation , SysTick timer is the source of time base. It is 00358 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() 00359 * is called, the SysTick interrupt will be enabled and so Tick increment 00360 * is resumed. 00361 * @note This function is declared as __weak to be overwritten in case of other 00362 * implementations in user file. 00363 * @retval None 00364 */ 00365 __weak void HAL_ResumeTick(void) 00366 { 00367 /* Enable SysTick Interrupt */ 00368 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; 00369 } 00370 00371 /** 00372 * @brief Return the HAL revision. 00373 * @retval version : 0xXYZR (8bits for each decimal, R for RC) 00374 */ 00375 uint32_t HAL_GetHalVersion(void) 00376 { 00377 return __STM32L4xx_HAL_VERSION; 00378 } 00379 00380 /** 00381 * @brief Return the device revision identifier. 00382 * @retval Device revision identifier 00383 */ 00384 uint32_t HAL_GetREVID(void) 00385 { 00386 return((DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16); 00387 } 00388 00389 /** 00390 * @brief Return the device identifier. 00391 * @retval Device identifier 00392 */ 00393 uint32_t HAL_GetDEVID(void) 00394 { 00395 return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID); 00396 } 00397 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup HAL_Exported_Functions_Group3 HAL Debug functions 00403 * @brief HAL Debug functions 00404 * 00405 @verbatim 00406 =============================================================================== 00407 ##### HAL Debug functions ##### 00408 =============================================================================== 00409 [..] This section provides functions allowing to: 00410 (+) Enable/Disable Debug module during SLEEP mode 00411 (+) Enable/Disable Debug module during STOP0/STOP1/STOP2 modes 00412 (+) Enable/Disable Debug module during STANDBY mode 00413 00414 @endverbatim 00415 * @{ 00416 */ 00417 00418 /** 00419 * @brief Enable the Debug Module during SLEEP mode. 00420 * @retval None 00421 */ 00422 void HAL_DBGMCU_EnableDBGSleepMode(void) 00423 { 00424 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00425 } 00426 00427 /** 00428 * @brief Disable the Debug Module during SLEEP mode. 00429 * @retval None 00430 */ 00431 void HAL_DBGMCU_DisableDBGSleepMode(void) 00432 { 00433 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00434 } 00435 00436 /** 00437 * @brief Enable the Debug Module during STOP0/STOP1/STOP2 modes. 00438 * @retval None 00439 */ 00440 void HAL_DBGMCU_EnableDBGStopMode(void) 00441 { 00442 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00443 } 00444 00445 /** 00446 * @brief Disable the Debug Module during STOP0/STOP1/STOP2 modes. 00447 * @retval None 00448 */ 00449 void HAL_DBGMCU_DisableDBGStopMode(void) 00450 { 00451 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00452 } 00453 00454 /** 00455 * @brief Enable the Debug Module during STANDBY mode. 00456 * @retval None 00457 */ 00458 void HAL_DBGMCU_EnableDBGStandbyMode(void) 00459 { 00460 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00461 } 00462 00463 /** 00464 * @brief Disable the Debug Module during STANDBY mode. 00465 * @retval None 00466 */ 00467 void HAL_DBGMCU_DisableDBGStandbyMode(void) 00468 { 00469 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00470 } 00471 00472 /** 00473 * @} 00474 */ 00475 00476 /** @defgroup HAL_Exported_Functions_Group4 HAL SYSCFG configuration functions 00477 * @brief HAL SYSCFG configuration functions 00478 * 00479 @verbatim 00480 =============================================================================== 00481 ##### HAL SYSCFG configuration functions ##### 00482 =============================================================================== 00483 [..] This section provides functions allowing to: 00484 (+) Start a hardware SRAM2 erase operation 00485 (+) Enable/Disable the Internal FLASH Bank Swapping 00486 (+) Configure the Voltage reference buffer 00487 (+) Enable/Disable the Voltage reference buffer 00488 (+) Enable/Disable the I/O analog switch voltage booster 00489 00490 @endverbatim 00491 * @{ 00492 */ 00493 00494 /** 00495 * @brief Start a hardware SRAM2 erase operation. 00496 * @note As long as SRAM2 is not erased the SRAM2ER bit will be set. 00497 * This bit is automatically reset at the end of the SRAM2 erase operation. 00498 * @retval None 00499 */ 00500 void HAL_SYSCFG_SRAM2Erase(void) 00501 { 00502 /* unlock the write protection of the SRAM2ER bit */ 00503 SYSCFG->SKR = 0xCA; 00504 SYSCFG->SKR = 0x53; 00505 /* Starts a hardware SRAM2 erase operation*/ 00506 *(__IO uint32_t *) SCSR_SRAM2ER_BB = (uint8_t)0x00000001; 00507 } 00508 00509 /** 00510 * @brief Enable the Internal FLASH Bank Swapping. 00511 * 00512 * @note This function can be used only for STM32L4xx devices. 00513 * 00514 * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) 00515 * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) 00516 * 00517 * @retval None 00518 */ 00519 void HAL_SYSCFG_EnableMemorySwappingBank(void) 00520 { 00521 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)ENABLE; 00522 } 00523 00524 /** 00525 * @brief Disable the Internal FLASH Bank Swapping. 00526 * 00527 * @note This function can be used only for STM32L4xx devices. 00528 * 00529 * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) 00530 * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) 00531 * 00532 * @retval None 00533 */ 00534 void HAL_SYSCFG_DisableMemorySwappingBank(void) 00535 { 00536 00537 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)DISABLE; 00538 } 00539 00540 #if defined(VREFBUF) 00541 /** 00542 * @brief Configure the internal voltage reference buffer voltage scale. 00543 * @param VoltageScaling: specifies the output voltage to achieve 00544 * This parameter can be one of the following values: 00545 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V. 00546 * This requires VDDA equal to or higher than 2.4 V. 00547 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT1 around 2.5 V. 00548 * This requires VDDA equal to or higher than 2.8 V. 00549 * @retval None 00550 */ 00551 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) 00552 { 00553 /* Check the parameters */ 00554 assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); 00555 00556 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling); 00557 } 00558 00559 /** 00560 * @brief Configure the internal voltage reference buffer high impedance mode. 00561 * @param Mode: specifies the high impedance mode 00562 * This parameter can be one of the following values: 00563 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output. 00564 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance. 00565 * @retval None 00566 */ 00567 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) 00568 { 00569 /* Check the parameters */ 00570 assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); 00571 00572 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); 00573 } 00574 00575 /** 00576 * @brief Tune the Internal Voltage Reference buffer (VREFBUF). 00577 * @retval None 00578 */ 00579 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) 00580 { 00581 /* Check the parameters */ 00582 assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); 00583 00584 MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue); 00585 } 00586 00587 /** 00588 * @brief Enable the Internal Voltage Reference buffer (VREFBUF). 00589 * @retval HAL_OK/HAL_TIMEOUT 00590 */ 00591 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) 00592 { 00593 uint32_t tickstart = 0; 00594 00595 SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00596 00597 /* Get Start Tick*/ 00598 tickstart = HAL_GetTick(); 00599 00600 /* Wait for VRR bit */ 00601 while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == RESET) 00602 { 00603 if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) 00604 { 00605 return HAL_TIMEOUT; 00606 } 00607 } 00608 00609 return HAL_OK; 00610 } 00611 00612 /** 00613 * @brief Disable the Internal Voltage Reference buffer (VREFBUF). 00614 * 00615 * @retval None 00616 */ 00617 void HAL_SYSCFG_DisableVREFBUF(void) 00618 { 00619 CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00620 } 00621 #endif /* VREFBUF */ 00622 00623 /** 00624 * @brief Enable the I/O analog switch voltage booster 00625 * 00626 * @retval None 00627 */ 00628 void HAL_SYSCFG_EnableIOAnalogSwitchBooster(void) 00629 { 00630 SET_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); 00631 } 00632 00633 /** 00634 * @brief Disable the I/O analog switch voltage booster 00635 * 00636 * @retval None 00637 */ 00638 void HAL_SYSCFG_DisableIOAnalogSwitchBooster(void) 00639 { 00640 CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); 00641 } 00642 00643 /** 00644 * @} 00645 */ 00646 00647 /** 00648 * @} 00649 */ 00650 00651 #endif /* HAL_MODULE_ENABLED */ 00652 /** 00653 * @} 00654 */ 00655 00656 /** 00657 * @} 00658 */ 00659 00660 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
Generated on Tue Jul 12 2022 10:59:57 by
