L4 HAL Drivers
Embed:
(wiki syntax)
Show/hide line numbers
stm32l4xx_hal.c
Go to the documentation of this file.
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal.c 00004 * @author MCD Application Team 00005 * @version V1.1.0 00006 * @date 16-September-2015 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) 2015 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.1.0 00071 */ 00072 #define __STM32L4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ 00073 #define __STM32L4xx_HAL_VERSION_SUB1 (0x01) /*!< [23:16] sub1 version */ 00074 #define __STM32L4xx_HAL_VERSION_SUB2 (0x00) /*!< [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 #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms (to be confirmed) */ 00082 00083 /* ------------ SYSCFG registers bit address in the alias region ------------ */ 00084 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) 00085 /* --- MEMRMP Register ---*/ 00086 /* Alias word address of FB_MODE bit */ 00087 #define MEMRMP_OFFSET SYSCFG_OFFSET 00088 #define FB_MODE_BitNumber ((uint8_t)0x8) 00089 #define FB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (FB_MODE_BitNumber * 4)) 00090 00091 /* --- SCSR Register ---*/ 00092 /* Alias word address of SRAM2ER bit */ 00093 #define SCSR_OFFSET (SYSCFG_OFFSET + 0x18) 00094 #define BRER_BitNumber ((uint8_t)0x0) 00095 #define SCSR_SRAM2ER_BB (PERIPH_BB_BASE + (SCSR_OFFSET * 32) + (BRER_BitNumber * 4)) 00096 00097 /* Private macro -------------------------------------------------------------*/ 00098 /* Private variables ---------------------------------------------------------*/ 00099 static __IO uint32_t uwTick; 00100 00101 /* Private function prototypes -----------------------------------------------*/ 00102 /* Exported functions --------------------------------------------------------*/ 00103 00104 /** @defgroup HAL_Exported_Functions HAL Exported Functions 00105 * @{ 00106 */ 00107 00108 /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions 00109 * @brief Initialization and de-initialization functions 00110 * 00111 @verbatim 00112 =============================================================================== 00113 ##### Initialization and de-initialization functions ##### 00114 =============================================================================== 00115 [..] This section provides functions allowing to: 00116 (+) Initialize the Flash interface the NVIC allocation and initial time base 00117 clock configuration. 00118 (+) De-initialize common part of the HAL. 00119 (+) Configure the time base source to have 1ms time base with a dedicated 00120 Tick interrupt priority. 00121 (++) SysTick timer is used by default as source of time base, but user 00122 can eventually implement his proper time base source (a general purpose 00123 timer for example or other time source), keeping in mind that Time base 00124 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 00125 handled in milliseconds basis. 00126 (++) Time base configuration function (HAL_InitTick ()) is called automatically 00127 at the beginning of the program after reset by HAL_Init() or at any time 00128 when clock is configured, by HAL_RCC_ClockConfig(). 00129 (++) Source of time base is configured to generate interrupts at regular 00130 time intervals. Care must be taken if HAL_Delay() is called from a 00131 peripheral ISR process, the Tick interrupt line must have higher priority 00132 (numerically lower) than the peripheral interrupt. Otherwise the caller 00133 ISR process will be blocked. 00134 (++) functions affecting time base configurations are declared as __weak 00135 to make override possible in case of other implementations in user file. 00136 @endverbatim 00137 * @{ 00138 */ 00139 00140 /** 00141 * @brief Configure the Flash prefetch, the Instruction and Data caches, 00142 * the time base source, NVIC and any required global low level hardware 00143 * by calling the HAL_MspInit() callback function to be optionally defined in user file 00144 * stm32l4xx_hal_msp.c. 00145 * 00146 * @note HAL_Init() function is called at the beginning of program after reset and before 00147 * the clock configuration. 00148 * 00149 * @note In the default implementation the System Timer (Systick) is used as source of time base. 00150 * The Systick configuration is based on MSI clock, as MSI is the clock 00151 * used after a system Reset and the NVIC configuration is set to Priority group 4. 00152 * Once done, time base tick starts incrementing: the tick variable counter is incremented 00153 * each 1ms in the SysTick_Handler() interrupt handler. 00154 * 00155 * @retval HAL status 00156 */ 00157 HAL_StatusTypeDef HAL_Init(void) 00158 { 00159 /* Configure Flash prefetch, Instruction cache, Data cache */ 00160 /* Default configuration at reset is: */ 00161 /* - Prefetch disabled */ 00162 /* - Instruction cache enabled */ 00163 /* - Data cache enabled */ 00164 #if (INSTRUCTION_CACHE_ENABLE == 0) 00165 __HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); 00166 #endif /* INSTRUCTION_CACHE_ENABLE */ 00167 00168 #if (DATA_CACHE_ENABLE == 0) 00169 __HAL_FLASH_DATA_CACHE_DISABLE(); 00170 #endif /* DATA_CACHE_ENABLE */ 00171 00172 #if (PREFETCH_ENABLE != 0) 00173 __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); 00174 #endif /* PREFETCH_ENABLE */ 00175 00176 /* Set Interrupt Group Priority */ 00177 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 00178 00179 /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */ 00180 HAL_InitTick(TICK_INT_PRIORITY); 00181 00182 /* Init the low level hardware */ 00183 HAL_MspInit(); 00184 00185 /* Return function status */ 00186 return HAL_OK; 00187 } 00188 00189 /** 00190 * @brief De-initialize common part of the HAL and stop the source of time base. 00191 * @note This function is optional. 00192 * @retval HAL status 00193 */ 00194 HAL_StatusTypeDef HAL_DeInit(void) 00195 { 00196 /* Reset of all peripherals */ 00197 __HAL_RCC_APB1_FORCE_RESET(); 00198 __HAL_RCC_APB1_RELEASE_RESET(); 00199 00200 __HAL_RCC_APB2_FORCE_RESET(); 00201 __HAL_RCC_APB2_RELEASE_RESET(); 00202 00203 __HAL_RCC_AHB1_FORCE_RESET(); 00204 __HAL_RCC_AHB1_RELEASE_RESET(); 00205 00206 __HAL_RCC_AHB2_FORCE_RESET(); 00207 __HAL_RCC_AHB2_RELEASE_RESET(); 00208 00209 __HAL_RCC_AHB3_FORCE_RESET(); 00210 __HAL_RCC_AHB3_RELEASE_RESET(); 00211 00212 /* De-Init the low level hardware */ 00213 HAL_MspDeInit(); 00214 00215 /* Return function status */ 00216 return HAL_OK; 00217 } 00218 00219 /** 00220 * @brief Initialize the MSP. 00221 * @retval None 00222 */ 00223 __weak void HAL_MspInit(void) 00224 { 00225 /* NOTE : This function should not be modified, when the callback is needed, 00226 the HAL_MspInit could be implemented in the user file 00227 */ 00228 } 00229 00230 /** 00231 * @brief DeInitialize the MSP. 00232 * @retval None 00233 */ 00234 __weak void HAL_MspDeInit(void) 00235 { 00236 /* NOTE : This function should not be modified, when the callback is needed, 00237 the HAL_MspDeInit could be implemented in the user file 00238 */ 00239 } 00240 00241 /** 00242 * @brief This function configures the source of the time base: 00243 * The time source is configured to have 1ms time base with a dedicated 00244 * Tick interrupt priority. 00245 * @note This function is called automatically at the beginning of program after 00246 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). 00247 * @note In the default implementation, SysTick timer is the source of time base. 00248 * It is used to generate interrupts at regular time intervals. 00249 * Care must be taken if HAL_Delay() is called from a peripheral ISR process, 00250 * The SysTick interrupt must have higher priority (numerically lower) 00251 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. 00252 * The function is declared as __weak to be overwritten in case of other 00253 * implementation in user file. 00254 * @param TickPriority: Tick interrupt priority. 00255 * @retval HAL status 00256 */ 00257 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 00258 { 00259 /*Configure the SysTick to have interrupt in 1ms time basis*/ 00260 HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq()/1000); 00261 00262 /*Configure the SysTick IRQ priority */ 00263 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0); 00264 00265 /* Return function status */ 00266 return HAL_OK; 00267 } 00268 00269 /** 00270 * @} 00271 */ 00272 00273 /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions 00274 * @brief HAL Control functions 00275 * 00276 @verbatim 00277 =============================================================================== 00278 ##### HAL Control functions ##### 00279 =============================================================================== 00280 [..] This section provides functions allowing to: 00281 (+) Provide a tick value in millisecond 00282 (+) Provide a blocking delay in millisecond 00283 (+) Suspend the time base source interrupt 00284 (+) Resume the time base source interrupt 00285 (+) Get the HAL API driver version 00286 (+) Get the device identifier 00287 (+) Get the device revision identifier 00288 00289 @endverbatim 00290 * @{ 00291 */ 00292 00293 /** 00294 * @brief This function is called to increment a global variable "uwTick" 00295 * used as application time base. 00296 * @note In the default implementation, this variable is incremented each 1ms 00297 * in SysTick ISR. 00298 * @note This function is declared as __weak to be overwritten in case of other 00299 * implementations in user file. 00300 * @retval None 00301 */ 00302 __weak void HAL_IncTick(void) 00303 { 00304 uwTick++; 00305 } 00306 00307 /** 00308 * @brief Provide a tick value in millisecond. 00309 * @note This function is declared as __weak to be overwritten in case of other 00310 * implementations in user file. 00311 * @retval tick value 00312 */ 00313 __weak uint32_t HAL_GetTick(void) 00314 { 00315 return uwTick; 00316 } 00317 00318 /** 00319 * @brief Provide accurate delay (in milliseconds) based on variable incremented. 00320 * @note In the default implementation , SysTick timer is the source of time base. 00321 * It is used to generate interrupts at regular time intervals where uwTick 00322 * is incremented. 00323 * @note This function is declared as __weak to be overwritten in case of other 00324 * implementations in user file. 00325 * @param Delay: specifies the delay time length, in milliseconds. 00326 * @retval None 00327 */ 00328 __weak void HAL_Delay(uint32_t Delay) 00329 { 00330 uint32_t tickstart = 0; 00331 tickstart = HAL_GetTick(); 00332 while((HAL_GetTick() - tickstart) < Delay) 00333 { 00334 } 00335 } 00336 00337 /** 00338 * @brief Suspend Tick increment. 00339 * @note In the default implementation , SysTick timer is the source of time base. It is 00340 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() 00341 * is called, the SysTick interrupt will be disabled and so Tick increment 00342 * is suspended. 00343 * @note This function is declared as __weak to be overwritten in case of other 00344 * implementations in user file. 00345 * @retval None 00346 */ 00347 __weak void HAL_SuspendTick(void) 00348 { 00349 /* Disable SysTick Interrupt */ 00350 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; 00351 } 00352 00353 /** 00354 * @brief Resume Tick increment. 00355 * @note In the default implementation , SysTick timer is the source of time base. It is 00356 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() 00357 * is called, the SysTick interrupt will be enabled and so Tick increment 00358 * is resumed. 00359 * @note This function is declared as __weak to be overwritten in case of other 00360 * implementations in user file. 00361 * @retval None 00362 */ 00363 __weak void HAL_ResumeTick(void) 00364 { 00365 /* Enable SysTick Interrupt */ 00366 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; 00367 } 00368 00369 /** 00370 * @brief Return the HAL revision. 00371 * @retval version : 0xXYZR (8bits for each decimal, R for RC) 00372 */ 00373 uint32_t HAL_GetHalVersion(void) 00374 { 00375 return __STM32L4xx_HAL_VERSION; 00376 } 00377 00378 /** 00379 * @brief Return the device revision identifier. 00380 * @retval Device revision identifier 00381 */ 00382 uint32_t HAL_GetREVID(void) 00383 { 00384 return((DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16); 00385 } 00386 00387 /** 00388 * @brief Return the device identifier. 00389 * @retval Device identifier 00390 */ 00391 uint32_t HAL_GetDEVID(void) 00392 { 00393 return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID); 00394 } 00395 00396 /** 00397 * @} 00398 */ 00399 00400 /** @defgroup HAL_Exported_Functions_Group3 HAL Debug functions 00401 * @brief HAL Debug functions 00402 * 00403 @verbatim 00404 =============================================================================== 00405 ##### HAL Debug functions ##### 00406 =============================================================================== 00407 [..] This section provides functions allowing to: 00408 (+) Enable/Disable Debug module during SLEEP mode 00409 (+) Enable/Disable Debug module during STOP1/STOP2 modes 00410 (+) Enable/Disable Debug module during STANDBY mode 00411 00412 @endverbatim 00413 * @{ 00414 */ 00415 00416 /** 00417 * @brief Enable the Debug Module during SLEEP mode. 00418 * @retval None 00419 */ 00420 void HAL_DBGMCU_EnableDBGSleepMode(void) 00421 { 00422 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00423 } 00424 00425 /** 00426 * @brief Disable the Debug Module during SLEEP mode. 00427 * @retval None 00428 */ 00429 void HAL_DBGMCU_DisableDBGSleepMode(void) 00430 { 00431 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00432 } 00433 00434 /** 00435 * @brief Enable the Debug Module during STOP1/STOP2 modes. 00436 * @retval None 00437 */ 00438 void HAL_DBGMCU_EnableDBGStopMode(void) 00439 { 00440 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00441 } 00442 00443 /** 00444 * @brief Disable the Debug Module during STOP1/STOP2 modes. 00445 * @retval None 00446 */ 00447 void HAL_DBGMCU_DisableDBGStopMode(void) 00448 { 00449 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00450 } 00451 00452 /** 00453 * @brief Enable the Debug Module during STANDBY mode. 00454 * @retval None 00455 */ 00456 void HAL_DBGMCU_EnableDBGStandbyMode(void) 00457 { 00458 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00459 } 00460 00461 /** 00462 * @brief Disable the Debug Module during STANDBY mode. 00463 * @retval None 00464 */ 00465 void HAL_DBGMCU_DisableDBGStandbyMode(void) 00466 { 00467 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00468 } 00469 00470 /** 00471 * @} 00472 */ 00473 00474 /** @defgroup HAL_Exported_Functions_Group4 HAL SYSCFG configuration functions 00475 * @brief HAL SYSCFG configuration functions 00476 * 00477 @verbatim 00478 =============================================================================== 00479 ##### HAL SYSCFG configuration functions ##### 00480 =============================================================================== 00481 [..] This section provides functions allowing to: 00482 (+) Start a hardware SRAM2 erase operation 00483 (+) Enable/Disable the Internal FLASH Bank Swapping 00484 (+) Configure the Voltage reference buffer 00485 (+) Enable/Disable the Voltage reference buffer 00486 00487 @endverbatim 00488 * @{ 00489 */ 00490 00491 /** 00492 * @brief Start a hardware SRAM2 erase operation. 00493 * @note As long as SRAM2 is not erased the SRAM2ER bit will be set. 00494 * This bit is automatically reset at the end of the SRAM2 erase operation. 00495 * @retval None 00496 */ 00497 void HAL_SYSCFG_SRAM2Erase(void) 00498 { 00499 /* unlock the write protection of the SRAM2ER bit */ 00500 SYSCFG->SKR = 0xCA; 00501 SYSCFG->SKR = 0x53; 00502 /* Starts a hardware SRAM2 erase operation*/ 00503 *(__IO uint32_t *) SCSR_SRAM2ER_BB = (uint8_t)0x00000001; 00504 } 00505 00506 /** 00507 * @brief Enable the Internal FLASH Bank Swapping. 00508 * 00509 * @note This function can be used only for STM32L4xx devices. 00510 * 00511 * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) 00512 * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) 00513 * 00514 * @retval None 00515 */ 00516 void HAL_SYSCFG_EnableMemorySwappingBank(void) 00517 { 00518 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)ENABLE; 00519 } 00520 00521 /** 00522 * @brief Disable the Internal FLASH Bank Swapping. 00523 * 00524 * @note This function can be used only for STM32L4xx devices. 00525 * 00526 * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) 00527 * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) 00528 * 00529 * @retval None 00530 */ 00531 void HAL_SYSCFG_DisableMemorySwappingBank(void) 00532 { 00533 00534 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)DISABLE; 00535 } 00536 00537 /** 00538 * @brief Configure the internal voltage reference buffer voltage scale. 00539 * @param VoltageScaling: specifies the output voltage to achieve 00540 * This parameter can be one of the following values: 00541 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V. 00542 * This requires VDDA equal to or higher than 2.4 V. 00543 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT1 around 2.5 V. 00544 * This requires VDDA equal to or higher than 2.8 V. 00545 * @retval None 00546 */ 00547 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) 00548 { 00549 /* Check the parameters */ 00550 assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); 00551 00552 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling); 00553 } 00554 00555 /** 00556 * @brief Configure the internal voltage reference buffer high impedance mode. 00557 * @param Mode: specifies the high impedance mode 00558 * This parameter can be one of the following values: 00559 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output. 00560 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance. 00561 * @retval None 00562 */ 00563 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) 00564 { 00565 /* Check the parameters */ 00566 assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); 00567 00568 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); 00569 } 00570 00571 /** 00572 * @brief Tune the Internal Voltage Reference buffer (VREFBUF). 00573 * @retval None 00574 */ 00575 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) 00576 { 00577 /* Check the parameters */ 00578 assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); 00579 00580 MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue); 00581 } 00582 00583 /** 00584 * @brief Enable the Internal Voltage Reference buffer (VREFBUF). 00585 * @retval HAL_OK/HAL_TIMEOUT 00586 */ 00587 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) 00588 { 00589 uint32_t tickstart = 0; 00590 00591 SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00592 00593 /* Get Start Tick*/ 00594 tickstart = HAL_GetTick(); 00595 00596 /* Wait for VRR bit */ 00597 while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == RESET) 00598 { 00599 if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) 00600 { 00601 return HAL_TIMEOUT; 00602 } 00603 } 00604 00605 return HAL_OK; 00606 } 00607 00608 /** 00609 * @brief Disable the Internal Voltage Reference buffer (VREFBUF). 00610 * 00611 * @retval None 00612 */ 00613 void HAL_SYSCFG_DisableVREFBUF(void) 00614 { 00615 CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00616 } 00617 00618 /** 00619 * @} 00620 */ 00621 00622 /** 00623 * @} 00624 */ 00625 00626 #endif /* HAL_MODULE_ENABLED */ 00627 /** 00628 * @} 00629 */ 00630 00631 /** 00632 * @} 00633 */ 00634 00635 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 00636
Generated on Tue Jul 12 2022 10:58:08 by 1.7.2