STM32L486xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32l4xx_hal.c 00004 * @author MCD Application Team 00005 * @brief HAL module driver. 00006 * This is the common part of the HAL initialization 00007 * 00008 @verbatim 00009 ============================================================================== 00010 ##### How to use this driver ##### 00011 ============================================================================== 00012 [..] 00013 The common HAL driver contains a set of generic and common APIs that can be 00014 used by the PPP peripheral drivers and the user to start using the HAL. 00015 [..] 00016 The HAL contains two APIs' categories: 00017 (+) Common HAL APIs 00018 (+) Services HAL APIs 00019 00020 @endverbatim 00021 ****************************************************************************** 00022 * @attention 00023 * 00024 * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> 00025 * 00026 * Redistribution and use in source and binary forms, with or without modification, 00027 * are permitted provided that the following conditions are met: 00028 * 1. Redistributions of source code must retain the above copyright notice, 00029 * this list of conditions and the following disclaimer. 00030 * 2. Redistributions in binary form must reproduce the above copyright notice, 00031 * this list of conditions and the following disclaimer in the documentation 00032 * and/or other materials provided with the distribution. 00033 * 3. Neither the name of STMicroelectronics nor the names of its contributors 00034 * may be used to endorse or promote products derived from this software 00035 * without specific prior written permission. 00036 * 00037 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 00038 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00039 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00040 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 00041 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00042 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 00043 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 00044 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00045 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00046 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00047 * 00048 ****************************************************************************** 00049 */ 00050 00051 /* Includes ------------------------------------------------------------------*/ 00052 #include "stm32l4xx_hal.h" 00053 00054 /** @addtogroup STM32L4xx_HAL_Driver 00055 * @{ 00056 */ 00057 00058 /** @defgroup HAL HAL 00059 * @brief HAL module driver 00060 * @{ 00061 */ 00062 00063 #ifdef HAL_MODULE_ENABLED 00064 00065 /* Private typedef -----------------------------------------------------------*/ 00066 /* Private define ------------------------------------------------------------*/ 00067 /** 00068 * @brief STM32L4xx HAL Driver version number 00069 */ 00070 #define __STM32L4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ 00071 #define __STM32L4xx_HAL_VERSION_SUB1 (0x08) /*!< [23:16] sub1 version */ 00072 #define __STM32L4xx_HAL_VERSION_SUB2 (0x03) /*!< [15:8] sub2 version */ 00073 #define __STM32L4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ 00074 #define __STM32L4xx_HAL_VERSION ((__STM32L4xx_HAL_VERSION_MAIN << 24)\ 00075 |(__STM32L4xx_HAL_VERSION_SUB1 << 16)\ 00076 |(__STM32L4xx_HAL_VERSION_SUB2 << 8 )\ 00077 |(__STM32L4xx_HAL_VERSION_RC)) 00078 00079 #if defined(VREFBUF) 00080 #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms (to be confirmed) */ 00081 #endif /* VREFBUF */ 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 __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(SystemCoreClock/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 This function provides minimum delay (in milliseconds) based 00320 * on variable incremented. 00321 * @note In the default implementation , SysTick timer is the source of time base. 00322 * It is used to generate interrupts at regular time intervals where uwTick 00323 * is incremented. 00324 * @note This function is declared as __weak to be overwritten in case of other 00325 * implementations in user file. 00326 * @param Delay specifies the delay time length, in milliseconds. 00327 * @retval None 00328 */ 00329 __weak void HAL_Delay(uint32_t Delay) 00330 { 00331 uint32_t tickstart = HAL_GetTick(); 00332 uint32_t wait = Delay; 00333 00334 /* Add a period to guaranty minimum wait */ 00335 if (wait < HAL_MAX_DELAY) 00336 { 00337 wait++; 00338 } 00339 00340 while((HAL_GetTick() - tickstart) < wait) 00341 { 00342 } 00343 } 00344 00345 /** 00346 * @brief Suspend Tick increment. 00347 * @note In the default implementation , SysTick timer is the source of time base. It is 00348 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() 00349 * is called, the SysTick interrupt will be disabled and so Tick increment 00350 * is suspended. 00351 * @note This function is declared as __weak to be overwritten in case of other 00352 * implementations in user file. 00353 * @retval None 00354 */ 00355 __weak void HAL_SuspendTick(void) 00356 { 00357 /* Disable SysTick Interrupt */ 00358 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; 00359 } 00360 00361 /** 00362 * @brief Resume Tick increment. 00363 * @note In the default implementation , SysTick timer is the source of time base. It is 00364 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() 00365 * is called, the SysTick interrupt will be enabled and so Tick increment 00366 * is resumed. 00367 * @note This function is declared as __weak to be overwritten in case of other 00368 * implementations in user file. 00369 * @retval None 00370 */ 00371 __weak void HAL_ResumeTick(void) 00372 { 00373 /* Enable SysTick Interrupt */ 00374 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; 00375 } 00376 00377 /** 00378 * @brief Return the HAL revision. 00379 * @retval version : 0xXYZR (8bits for each decimal, R for RC) 00380 */ 00381 uint32_t HAL_GetHalVersion(void) 00382 { 00383 return __STM32L4xx_HAL_VERSION; 00384 } 00385 00386 /** 00387 * @brief Return the device revision identifier. 00388 * @retval Device revision identifier 00389 */ 00390 uint32_t HAL_GetREVID(void) 00391 { 00392 return((DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16); 00393 } 00394 00395 /** 00396 * @brief Return the device identifier. 00397 * @retval Device identifier 00398 */ 00399 uint32_t HAL_GetDEVID(void) 00400 { 00401 return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID); 00402 } 00403 00404 /** 00405 * @brief Return the first word of the unique device identifier (UID based on 96 bits) 00406 * @retval Device identifier 00407 */ 00408 uint32_t HAL_GetUIDw0(void) 00409 { 00410 return(READ_REG(*((uint32_t *)UID_BASE))); 00411 } 00412 00413 /** 00414 * @brief Return the second word of the unique device identifier (UID based on 96 bits) 00415 * @retval Device identifier 00416 */ 00417 uint32_t HAL_GetUIDw1(void) 00418 { 00419 return(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); 00420 } 00421 00422 /** 00423 * @brief Return the third word of the unique device identifier (UID based on 96 bits) 00424 * @retval Device identifier 00425 */ 00426 uint32_t HAL_GetUIDw2(void) 00427 { 00428 return(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); 00429 } 00430 00431 /** 00432 * @} 00433 */ 00434 00435 /** @defgroup HAL_Exported_Functions_Group3 HAL Debug functions 00436 * @brief HAL Debug functions 00437 * 00438 @verbatim 00439 =============================================================================== 00440 ##### HAL Debug functions ##### 00441 =============================================================================== 00442 [..] This section provides functions allowing to: 00443 (+) Enable/Disable Debug module during SLEEP mode 00444 (+) Enable/Disable Debug module during STOP0/STOP1/STOP2 modes 00445 (+) Enable/Disable Debug module during STANDBY mode 00446 00447 @endverbatim 00448 * @{ 00449 */ 00450 00451 /** 00452 * @brief Enable the Debug Module during SLEEP mode. 00453 * @retval None 00454 */ 00455 void HAL_DBGMCU_EnableDBGSleepMode(void) 00456 { 00457 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00458 } 00459 00460 /** 00461 * @brief Disable the Debug Module during SLEEP mode. 00462 * @retval None 00463 */ 00464 void HAL_DBGMCU_DisableDBGSleepMode(void) 00465 { 00466 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); 00467 } 00468 00469 /** 00470 * @brief Enable the Debug Module during STOP0/STOP1/STOP2 modes. 00471 * @retval None 00472 */ 00473 void HAL_DBGMCU_EnableDBGStopMode(void) 00474 { 00475 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00476 } 00477 00478 /** 00479 * @brief Disable the Debug Module during STOP0/STOP1/STOP2 modes. 00480 * @retval None 00481 */ 00482 void HAL_DBGMCU_DisableDBGStopMode(void) 00483 { 00484 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); 00485 } 00486 00487 /** 00488 * @brief Enable the Debug Module during STANDBY mode. 00489 * @retval None 00490 */ 00491 void HAL_DBGMCU_EnableDBGStandbyMode(void) 00492 { 00493 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00494 } 00495 00496 /** 00497 * @brief Disable the Debug Module during STANDBY mode. 00498 * @retval None 00499 */ 00500 void HAL_DBGMCU_DisableDBGStandbyMode(void) 00501 { 00502 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); 00503 } 00504 00505 /** 00506 * @} 00507 */ 00508 00509 /** @defgroup HAL_Exported_Functions_Group4 HAL SYSCFG configuration functions 00510 * @brief HAL SYSCFG configuration functions 00511 * 00512 @verbatim 00513 =============================================================================== 00514 ##### HAL SYSCFG configuration functions ##### 00515 =============================================================================== 00516 [..] This section provides functions allowing to: 00517 (+) Start a hardware SRAM2 erase operation 00518 (+) Enable/Disable the Internal FLASH Bank Swapping 00519 (+) Configure the Voltage reference buffer 00520 (+) Enable/Disable the Voltage reference buffer 00521 (+) Enable/Disable the I/O analog switch voltage booster 00522 00523 @endverbatim 00524 * @{ 00525 */ 00526 00527 /** 00528 * @brief Start a hardware SRAM2 erase operation. 00529 * @note As long as SRAM2 is not erased the SRAM2ER bit will be set. 00530 * This bit is automatically reset at the end of the SRAM2 erase operation. 00531 * @retval None 00532 */ 00533 void HAL_SYSCFG_SRAM2Erase(void) 00534 { 00535 /* unlock the write protection of the SRAM2ER bit */ 00536 SYSCFG->SKR = 0xCA; 00537 SYSCFG->SKR = 0x53; 00538 /* Starts a hardware SRAM2 erase operation*/ 00539 *(__IO uint32_t *) SCSR_SRAM2ER_BB = (uint8_t)0x00000001; 00540 } 00541 00542 /** 00543 * @brief Enable the Internal FLASH Bank Swapping. 00544 * 00545 * @note This function can be used only for STM32L4xx devices. 00546 * 00547 * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) 00548 * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) 00549 * 00550 * @retval None 00551 */ 00552 void HAL_SYSCFG_EnableMemorySwappingBank(void) 00553 { 00554 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)ENABLE; 00555 } 00556 00557 /** 00558 * @brief Disable the Internal FLASH Bank Swapping. 00559 * 00560 * @note This function can be used only for STM32L4xx devices. 00561 * 00562 * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) 00563 * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) 00564 * 00565 * @retval None 00566 */ 00567 void HAL_SYSCFG_DisableMemorySwappingBank(void) 00568 { 00569 00570 *(__IO uint32_t *)FB_MODE_BB = (uint32_t)DISABLE; 00571 } 00572 00573 #if defined(VREFBUF) 00574 /** 00575 * @brief Configure the internal voltage reference buffer voltage scale. 00576 * @param VoltageScaling specifies the output voltage to achieve 00577 * This parameter can be one of the following values: 00578 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V. 00579 * This requires VDDA equal to or higher than 2.4 V. 00580 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.5 V. 00581 * This requires VDDA equal to or higher than 2.8 V. 00582 * @retval None 00583 */ 00584 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) 00585 { 00586 /* Check the parameters */ 00587 assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); 00588 00589 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling); 00590 } 00591 00592 /** 00593 * @brief Configure the internal voltage reference buffer high impedance mode. 00594 * @param Mode specifies the high impedance mode 00595 * This parameter can be one of the following values: 00596 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output. 00597 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance. 00598 * @retval None 00599 */ 00600 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) 00601 { 00602 /* Check the parameters */ 00603 assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); 00604 00605 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); 00606 } 00607 00608 /** 00609 * @brief Tune the Internal Voltage Reference buffer (VREFBUF). 00610 * @retval None 00611 */ 00612 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) 00613 { 00614 /* Check the parameters */ 00615 assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); 00616 00617 MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue); 00618 } 00619 00620 /** 00621 * @brief Enable the Internal Voltage Reference buffer (VREFBUF). 00622 * @retval HAL_OK/HAL_TIMEOUT 00623 */ 00624 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) 00625 { 00626 uint32_t tickstart = 0; 00627 00628 SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00629 00630 /* Get Start Tick*/ 00631 tickstart = HAL_GetTick(); 00632 00633 /* Wait for VRR bit */ 00634 while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == RESET) 00635 { 00636 if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) 00637 { 00638 return HAL_TIMEOUT; 00639 } 00640 } 00641 00642 return HAL_OK; 00643 } 00644 00645 /** 00646 * @brief Disable the Internal Voltage Reference buffer (VREFBUF). 00647 * 00648 * @retval None 00649 */ 00650 void HAL_SYSCFG_DisableVREFBUF(void) 00651 { 00652 CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 00653 } 00654 #endif /* VREFBUF */ 00655 00656 /** 00657 * @brief Enable the I/O analog switch voltage booster 00658 * 00659 * @retval None 00660 */ 00661 void HAL_SYSCFG_EnableIOAnalogSwitchBooster(void) 00662 { 00663 SET_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); 00664 } 00665 00666 /** 00667 * @brief Disable the I/O analog switch voltage booster 00668 * 00669 * @retval None 00670 */ 00671 void HAL_SYSCFG_DisableIOAnalogSwitchBooster(void) 00672 { 00673 CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); 00674 } 00675 00676 /** 00677 * @} 00678 */ 00679 00680 /** 00681 * @} 00682 */ 00683 00684 #endif /* HAL_MODULE_ENABLED */ 00685 /** 00686 * @} 00687 */ 00688 00689 /** 00690 * @} 00691 */ 00692 00693 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/