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.
HAL_L476/stm32l4xx_hal.c@1:d0dfbce63a89, 2017-02-24 (annotated)
- Committer:
- elmot
- Date:
- Fri Feb 24 21:13:56 2017 +0000
- Revision:
- 1:d0dfbce63a89
Ready-to-copy
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| elmot | 1:d0dfbce63a89 | 1 | /** |
| elmot | 1:d0dfbce63a89 | 2 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 3 | * @file stm32l4xx_hal.c |
| elmot | 1:d0dfbce63a89 | 4 | * @author MCD Application Team |
| elmot | 1:d0dfbce63a89 | 5 | * @version V1.5.1 |
| elmot | 1:d0dfbce63a89 | 6 | * @date 31-May-2016 |
| elmot | 1:d0dfbce63a89 | 7 | * @brief HAL module driver. |
| elmot | 1:d0dfbce63a89 | 8 | * This is the common part of the HAL initialization |
| elmot | 1:d0dfbce63a89 | 9 | * |
| elmot | 1:d0dfbce63a89 | 10 | @verbatim |
| elmot | 1:d0dfbce63a89 | 11 | ============================================================================== |
| elmot | 1:d0dfbce63a89 | 12 | ##### How to use this driver ##### |
| elmot | 1:d0dfbce63a89 | 13 | ============================================================================== |
| elmot | 1:d0dfbce63a89 | 14 | [..] |
| elmot | 1:d0dfbce63a89 | 15 | The common HAL driver contains a set of generic and common APIs that can be |
| elmot | 1:d0dfbce63a89 | 16 | used by the PPP peripheral drivers and the user to start using the HAL. |
| elmot | 1:d0dfbce63a89 | 17 | [..] |
| elmot | 1:d0dfbce63a89 | 18 | The HAL contains two APIs' categories: |
| elmot | 1:d0dfbce63a89 | 19 | (+) Common HAL APIs |
| elmot | 1:d0dfbce63a89 | 20 | (+) Services HAL APIs |
| elmot | 1:d0dfbce63a89 | 21 | |
| elmot | 1:d0dfbce63a89 | 22 | @endverbatim |
| elmot | 1:d0dfbce63a89 | 23 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 24 | * @attention |
| elmot | 1:d0dfbce63a89 | 25 | * |
| elmot | 1:d0dfbce63a89 | 26 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
| elmot | 1:d0dfbce63a89 | 27 | * |
| elmot | 1:d0dfbce63a89 | 28 | * Redistribution and use in source and binary forms, with or without modification, |
| elmot | 1:d0dfbce63a89 | 29 | * are permitted provided that the following conditions are met: |
| elmot | 1:d0dfbce63a89 | 30 | * 1. Redistributions of source code must retain the above copyright notice, |
| elmot | 1:d0dfbce63a89 | 31 | * this list of conditions and the following disclaimer. |
| elmot | 1:d0dfbce63a89 | 32 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| elmot | 1:d0dfbce63a89 | 33 | * this list of conditions and the following disclaimer in the documentation |
| elmot | 1:d0dfbce63a89 | 34 | * and/or other materials provided with the distribution. |
| elmot | 1:d0dfbce63a89 | 35 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
| elmot | 1:d0dfbce63a89 | 36 | * may be used to endorse or promote products derived from this software |
| elmot | 1:d0dfbce63a89 | 37 | * without specific prior written permission. |
| elmot | 1:d0dfbce63a89 | 38 | * |
| elmot | 1:d0dfbce63a89 | 39 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| elmot | 1:d0dfbce63a89 | 40 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| elmot | 1:d0dfbce63a89 | 41 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| elmot | 1:d0dfbce63a89 | 42 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| elmot | 1:d0dfbce63a89 | 43 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| elmot | 1:d0dfbce63a89 | 44 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| elmot | 1:d0dfbce63a89 | 45 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| elmot | 1:d0dfbce63a89 | 46 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| elmot | 1:d0dfbce63a89 | 47 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| elmot | 1:d0dfbce63a89 | 48 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| elmot | 1:d0dfbce63a89 | 49 | * |
| elmot | 1:d0dfbce63a89 | 50 | ****************************************************************************** |
| elmot | 1:d0dfbce63a89 | 51 | */ |
| elmot | 1:d0dfbce63a89 | 52 | |
| elmot | 1:d0dfbce63a89 | 53 | /* Includes ------------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 54 | #include "stm32l4xx_hal.h" |
| elmot | 1:d0dfbce63a89 | 55 | |
| elmot | 1:d0dfbce63a89 | 56 | /** @addtogroup STM32L4xx_HAL_Driver |
| elmot | 1:d0dfbce63a89 | 57 | * @{ |
| elmot | 1:d0dfbce63a89 | 58 | */ |
| elmot | 1:d0dfbce63a89 | 59 | |
| elmot | 1:d0dfbce63a89 | 60 | /** @defgroup HAL HAL |
| elmot | 1:d0dfbce63a89 | 61 | * @brief HAL module driver |
| elmot | 1:d0dfbce63a89 | 62 | * @{ |
| elmot | 1:d0dfbce63a89 | 63 | */ |
| elmot | 1:d0dfbce63a89 | 64 | |
| elmot | 1:d0dfbce63a89 | 65 | #ifdef HAL_MODULE_ENABLED |
| elmot | 1:d0dfbce63a89 | 66 | |
| elmot | 1:d0dfbce63a89 | 67 | /* Private typedef -----------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 68 | /* Private define ------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 69 | /** |
| elmot | 1:d0dfbce63a89 | 70 | * @brief STM32L4xx HAL Driver version number V1.5.1 |
| elmot | 1:d0dfbce63a89 | 71 | */ |
| elmot | 1:d0dfbce63a89 | 72 | #define __STM32L4xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */ |
| elmot | 1:d0dfbce63a89 | 73 | #define __STM32L4xx_HAL_VERSION_SUB1 (0x05) /*!< [23:16] sub1 version */ |
| elmot | 1:d0dfbce63a89 | 74 | #define __STM32L4xx_HAL_VERSION_SUB2 (0x01) /*!< [15:8] sub2 version */ |
| elmot | 1:d0dfbce63a89 | 75 | #define __STM32L4xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */ |
| elmot | 1:d0dfbce63a89 | 76 | #define __STM32L4xx_HAL_VERSION ((__STM32L4xx_HAL_VERSION_MAIN << 24)\ |
| elmot | 1:d0dfbce63a89 | 77 | |(__STM32L4xx_HAL_VERSION_SUB1 << 16)\ |
| elmot | 1:d0dfbce63a89 | 78 | |(__STM32L4xx_HAL_VERSION_SUB2 << 8 )\ |
| elmot | 1:d0dfbce63a89 | 79 | |(__STM32L4xx_HAL_VERSION_RC)) |
| elmot | 1:d0dfbce63a89 | 80 | |
| elmot | 1:d0dfbce63a89 | 81 | #if defined(VREFBUF) |
| elmot | 1:d0dfbce63a89 | 82 | #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms (to be confirmed) */ |
| elmot | 1:d0dfbce63a89 | 83 | #endif /* VREFBUF */ |
| elmot | 1:d0dfbce63a89 | 84 | |
| elmot | 1:d0dfbce63a89 | 85 | /* ------------ SYSCFG registers bit address in the alias region ------------ */ |
| elmot | 1:d0dfbce63a89 | 86 | #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) |
| elmot | 1:d0dfbce63a89 | 87 | /* --- MEMRMP Register ---*/ |
| elmot | 1:d0dfbce63a89 | 88 | /* Alias word address of FB_MODE bit */ |
| elmot | 1:d0dfbce63a89 | 89 | #define MEMRMP_OFFSET SYSCFG_OFFSET |
| elmot | 1:d0dfbce63a89 | 90 | #define FB_MODE_BitNumber ((uint8_t)0x8) |
| elmot | 1:d0dfbce63a89 | 91 | #define FB_MODE_BB (PERIPH_BB_BASE + (MEMRMP_OFFSET * 32) + (FB_MODE_BitNumber * 4)) |
| elmot | 1:d0dfbce63a89 | 92 | |
| elmot | 1:d0dfbce63a89 | 93 | /* --- SCSR Register ---*/ |
| elmot | 1:d0dfbce63a89 | 94 | /* Alias word address of SRAM2ER bit */ |
| elmot | 1:d0dfbce63a89 | 95 | #define SCSR_OFFSET (SYSCFG_OFFSET + 0x18) |
| elmot | 1:d0dfbce63a89 | 96 | #define BRER_BitNumber ((uint8_t)0x0) |
| elmot | 1:d0dfbce63a89 | 97 | #define SCSR_SRAM2ER_BB (PERIPH_BB_BASE + (SCSR_OFFSET * 32) + (BRER_BitNumber * 4)) |
| elmot | 1:d0dfbce63a89 | 98 | |
| elmot | 1:d0dfbce63a89 | 99 | /* Private macro -------------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 100 | /* Private variables ---------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 101 | __IO uint32_t uwTick; |
| elmot | 1:d0dfbce63a89 | 102 | |
| elmot | 1:d0dfbce63a89 | 103 | /* Private function prototypes -----------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 104 | /* Exported functions --------------------------------------------------------*/ |
| elmot | 1:d0dfbce63a89 | 105 | |
| elmot | 1:d0dfbce63a89 | 106 | /** @defgroup HAL_Exported_Functions HAL Exported Functions |
| elmot | 1:d0dfbce63a89 | 107 | * @{ |
| elmot | 1:d0dfbce63a89 | 108 | */ |
| elmot | 1:d0dfbce63a89 | 109 | |
| elmot | 1:d0dfbce63a89 | 110 | /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions |
| elmot | 1:d0dfbce63a89 | 111 | * @brief Initialization and de-initialization functions |
| elmot | 1:d0dfbce63a89 | 112 | * |
| elmot | 1:d0dfbce63a89 | 113 | @verbatim |
| elmot | 1:d0dfbce63a89 | 114 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 115 | ##### Initialization and de-initialization functions ##### |
| elmot | 1:d0dfbce63a89 | 116 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 117 | [..] This section provides functions allowing to: |
| elmot | 1:d0dfbce63a89 | 118 | (+) Initialize the Flash interface the NVIC allocation and initial time base |
| elmot | 1:d0dfbce63a89 | 119 | clock configuration. |
| elmot | 1:d0dfbce63a89 | 120 | (+) De-initialize common part of the HAL. |
| elmot | 1:d0dfbce63a89 | 121 | (+) Configure the time base source to have 1ms time base with a dedicated |
| elmot | 1:d0dfbce63a89 | 122 | Tick interrupt priority. |
| elmot | 1:d0dfbce63a89 | 123 | (++) SysTick timer is used by default as source of time base, but user |
| elmot | 1:d0dfbce63a89 | 124 | can eventually implement his proper time base source (a general purpose |
| elmot | 1:d0dfbce63a89 | 125 | timer for example or other time source), keeping in mind that Time base |
| elmot | 1:d0dfbce63a89 | 126 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and |
| elmot | 1:d0dfbce63a89 | 127 | handled in milliseconds basis. |
| elmot | 1:d0dfbce63a89 | 128 | (++) Time base configuration function (HAL_InitTick ()) is called automatically |
| elmot | 1:d0dfbce63a89 | 129 | at the beginning of the program after reset by HAL_Init() or at any time |
| elmot | 1:d0dfbce63a89 | 130 | when clock is configured, by HAL_RCC_ClockConfig(). |
| elmot | 1:d0dfbce63a89 | 131 | (++) Source of time base is configured to generate interrupts at regular |
| elmot | 1:d0dfbce63a89 | 132 | time intervals. Care must be taken if HAL_Delay() is called from a |
| elmot | 1:d0dfbce63a89 | 133 | peripheral ISR process, the Tick interrupt line must have higher priority |
| elmot | 1:d0dfbce63a89 | 134 | (numerically lower) than the peripheral interrupt. Otherwise the caller |
| elmot | 1:d0dfbce63a89 | 135 | ISR process will be blocked. |
| elmot | 1:d0dfbce63a89 | 136 | (++) functions affecting time base configurations are declared as __weak |
| elmot | 1:d0dfbce63a89 | 137 | to make override possible in case of other implementations in user file. |
| elmot | 1:d0dfbce63a89 | 138 | @endverbatim |
| elmot | 1:d0dfbce63a89 | 139 | * @{ |
| elmot | 1:d0dfbce63a89 | 140 | */ |
| elmot | 1:d0dfbce63a89 | 141 | |
| elmot | 1:d0dfbce63a89 | 142 | /** |
| elmot | 1:d0dfbce63a89 | 143 | * @brief Configure the Flash prefetch, the Instruction and Data caches, |
| elmot | 1:d0dfbce63a89 | 144 | * the time base source, NVIC and any required global low level hardware |
| elmot | 1:d0dfbce63a89 | 145 | * by calling the HAL_MspInit() callback function to be optionally defined in user file |
| elmot | 1:d0dfbce63a89 | 146 | * stm32l4xx_hal_msp.c. |
| elmot | 1:d0dfbce63a89 | 147 | * |
| elmot | 1:d0dfbce63a89 | 148 | * @note HAL_Init() function is called at the beginning of program after reset and before |
| elmot | 1:d0dfbce63a89 | 149 | * the clock configuration. |
| elmot | 1:d0dfbce63a89 | 150 | * |
| elmot | 1:d0dfbce63a89 | 151 | * @note In the default implementation the System Timer (Systick) is used as source of time base. |
| elmot | 1:d0dfbce63a89 | 152 | * The Systick configuration is based on MSI clock, as MSI is the clock |
| elmot | 1:d0dfbce63a89 | 153 | * used after a system Reset and the NVIC configuration is set to Priority group 4. |
| elmot | 1:d0dfbce63a89 | 154 | * Once done, time base tick starts incrementing: the tick variable counter is incremented |
| elmot | 1:d0dfbce63a89 | 155 | * each 1ms in the SysTick_Handler() interrupt handler. |
| elmot | 1:d0dfbce63a89 | 156 | * |
| elmot | 1:d0dfbce63a89 | 157 | * @retval HAL status |
| elmot | 1:d0dfbce63a89 | 158 | */ |
| elmot | 1:d0dfbce63a89 | 159 | HAL_StatusTypeDef HAL_Init(void) |
| elmot | 1:d0dfbce63a89 | 160 | { |
| elmot | 1:d0dfbce63a89 | 161 | /* Configure Flash prefetch, Instruction cache, Data cache */ |
| elmot | 1:d0dfbce63a89 | 162 | /* Default configuration at reset is: */ |
| elmot | 1:d0dfbce63a89 | 163 | /* - Prefetch disabled */ |
| elmot | 1:d0dfbce63a89 | 164 | /* - Instruction cache enabled */ |
| elmot | 1:d0dfbce63a89 | 165 | /* - Data cache enabled */ |
| elmot | 1:d0dfbce63a89 | 166 | #if (INSTRUCTION_CACHE_ENABLE == 0) |
| elmot | 1:d0dfbce63a89 | 167 | __HAL_FLASH_INSTRUCTION_CACHE_DISABLE(); |
| elmot | 1:d0dfbce63a89 | 168 | #endif /* INSTRUCTION_CACHE_ENABLE */ |
| elmot | 1:d0dfbce63a89 | 169 | |
| elmot | 1:d0dfbce63a89 | 170 | #if (DATA_CACHE_ENABLE == 0) |
| elmot | 1:d0dfbce63a89 | 171 | __HAL_FLASH_DATA_CACHE_DISABLE(); |
| elmot | 1:d0dfbce63a89 | 172 | #endif /* DATA_CACHE_ENABLE */ |
| elmot | 1:d0dfbce63a89 | 173 | |
| elmot | 1:d0dfbce63a89 | 174 | #if (PREFETCH_ENABLE != 0) |
| elmot | 1:d0dfbce63a89 | 175 | __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); |
| elmot | 1:d0dfbce63a89 | 176 | #endif /* PREFETCH_ENABLE */ |
| elmot | 1:d0dfbce63a89 | 177 | |
| elmot | 1:d0dfbce63a89 | 178 | /* Set Interrupt Group Priority */ |
| elmot | 1:d0dfbce63a89 | 179 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
| elmot | 1:d0dfbce63a89 | 180 | |
| elmot | 1:d0dfbce63a89 | 181 | /* Use SysTick as time base source and configure 1ms tick (default clock after Reset is MSI) */ |
| elmot | 1:d0dfbce63a89 | 182 | HAL_InitTick(TICK_INT_PRIORITY); |
| elmot | 1:d0dfbce63a89 | 183 | |
| elmot | 1:d0dfbce63a89 | 184 | /* Init the low level hardware */ |
| elmot | 1:d0dfbce63a89 | 185 | HAL_MspInit(); |
| elmot | 1:d0dfbce63a89 | 186 | |
| elmot | 1:d0dfbce63a89 | 187 | /* Return function status */ |
| elmot | 1:d0dfbce63a89 | 188 | return HAL_OK; |
| elmot | 1:d0dfbce63a89 | 189 | } |
| elmot | 1:d0dfbce63a89 | 190 | |
| elmot | 1:d0dfbce63a89 | 191 | /** |
| elmot | 1:d0dfbce63a89 | 192 | * @brief De-initialize common part of the HAL and stop the source of time base. |
| elmot | 1:d0dfbce63a89 | 193 | * @note This function is optional. |
| elmot | 1:d0dfbce63a89 | 194 | * @retval HAL status |
| elmot | 1:d0dfbce63a89 | 195 | */ |
| elmot | 1:d0dfbce63a89 | 196 | HAL_StatusTypeDef HAL_DeInit(void) |
| elmot | 1:d0dfbce63a89 | 197 | { |
| elmot | 1:d0dfbce63a89 | 198 | /* Reset of all peripherals */ |
| elmot | 1:d0dfbce63a89 | 199 | __HAL_RCC_APB1_FORCE_RESET(); |
| elmot | 1:d0dfbce63a89 | 200 | __HAL_RCC_APB1_RELEASE_RESET(); |
| elmot | 1:d0dfbce63a89 | 201 | |
| elmot | 1:d0dfbce63a89 | 202 | __HAL_RCC_APB2_FORCE_RESET(); |
| elmot | 1:d0dfbce63a89 | 203 | __HAL_RCC_APB2_RELEASE_RESET(); |
| elmot | 1:d0dfbce63a89 | 204 | |
| elmot | 1:d0dfbce63a89 | 205 | __HAL_RCC_AHB1_FORCE_RESET(); |
| elmot | 1:d0dfbce63a89 | 206 | __HAL_RCC_AHB1_RELEASE_RESET(); |
| elmot | 1:d0dfbce63a89 | 207 | |
| elmot | 1:d0dfbce63a89 | 208 | __HAL_RCC_AHB2_FORCE_RESET(); |
| elmot | 1:d0dfbce63a89 | 209 | __HAL_RCC_AHB2_RELEASE_RESET(); |
| elmot | 1:d0dfbce63a89 | 210 | |
| elmot | 1:d0dfbce63a89 | 211 | __HAL_RCC_AHB3_FORCE_RESET(); |
| elmot | 1:d0dfbce63a89 | 212 | __HAL_RCC_AHB3_RELEASE_RESET(); |
| elmot | 1:d0dfbce63a89 | 213 | |
| elmot | 1:d0dfbce63a89 | 214 | /* De-Init the low level hardware */ |
| elmot | 1:d0dfbce63a89 | 215 | HAL_MspDeInit(); |
| elmot | 1:d0dfbce63a89 | 216 | |
| elmot | 1:d0dfbce63a89 | 217 | /* Return function status */ |
| elmot | 1:d0dfbce63a89 | 218 | return HAL_OK; |
| elmot | 1:d0dfbce63a89 | 219 | } |
| elmot | 1:d0dfbce63a89 | 220 | |
| elmot | 1:d0dfbce63a89 | 221 | /** |
| elmot | 1:d0dfbce63a89 | 222 | * @brief Initialize the MSP. |
| elmot | 1:d0dfbce63a89 | 223 | * @retval None |
| elmot | 1:d0dfbce63a89 | 224 | */ |
| elmot | 1:d0dfbce63a89 | 225 | __weak void HAL_MspInit(void) |
| elmot | 1:d0dfbce63a89 | 226 | { |
| elmot | 1:d0dfbce63a89 | 227 | /* NOTE : This function should not be modified, when the callback is needed, |
| elmot | 1:d0dfbce63a89 | 228 | the HAL_MspInit could be implemented in the user file |
| elmot | 1:d0dfbce63a89 | 229 | */ |
| elmot | 1:d0dfbce63a89 | 230 | } |
| elmot | 1:d0dfbce63a89 | 231 | |
| elmot | 1:d0dfbce63a89 | 232 | /** |
| elmot | 1:d0dfbce63a89 | 233 | * @brief DeInitialize the MSP. |
| elmot | 1:d0dfbce63a89 | 234 | * @retval None |
| elmot | 1:d0dfbce63a89 | 235 | */ |
| elmot | 1:d0dfbce63a89 | 236 | __weak void HAL_MspDeInit(void) |
| elmot | 1:d0dfbce63a89 | 237 | { |
| elmot | 1:d0dfbce63a89 | 238 | /* NOTE : This function should not be modified, when the callback is needed, |
| elmot | 1:d0dfbce63a89 | 239 | the HAL_MspDeInit could be implemented in the user file |
| elmot | 1:d0dfbce63a89 | 240 | */ |
| elmot | 1:d0dfbce63a89 | 241 | } |
| elmot | 1:d0dfbce63a89 | 242 | |
| elmot | 1:d0dfbce63a89 | 243 | /** |
| elmot | 1:d0dfbce63a89 | 244 | * @brief This function configures the source of the time base: |
| elmot | 1:d0dfbce63a89 | 245 | * The time source is configured to have 1ms time base with a dedicated |
| elmot | 1:d0dfbce63a89 | 246 | * Tick interrupt priority. |
| elmot | 1:d0dfbce63a89 | 247 | * @note This function is called automatically at the beginning of program after |
| elmot | 1:d0dfbce63a89 | 248 | * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). |
| elmot | 1:d0dfbce63a89 | 249 | * @note In the default implementation, SysTick timer is the source of time base. |
| elmot | 1:d0dfbce63a89 | 250 | * It is used to generate interrupts at regular time intervals. |
| elmot | 1:d0dfbce63a89 | 251 | * Care must be taken if HAL_Delay() is called from a peripheral ISR process, |
| elmot | 1:d0dfbce63a89 | 252 | * The SysTick interrupt must have higher priority (numerically lower) |
| elmot | 1:d0dfbce63a89 | 253 | * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. |
| elmot | 1:d0dfbce63a89 | 254 | * The function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 255 | * implementation in user file. |
| elmot | 1:d0dfbce63a89 | 256 | * @param TickPriority: Tick interrupt priority. |
| elmot | 1:d0dfbce63a89 | 257 | * @retval HAL status |
| elmot | 1:d0dfbce63a89 | 258 | */ |
| elmot | 1:d0dfbce63a89 | 259 | __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) |
| elmot | 1:d0dfbce63a89 | 260 | { |
| elmot | 1:d0dfbce63a89 | 261 | /*Configure the SysTick to have interrupt in 1ms time basis*/ |
| elmot | 1:d0dfbce63a89 | 262 | HAL_SYSTICK_Config(SystemCoreClock/1000); |
| elmot | 1:d0dfbce63a89 | 263 | |
| elmot | 1:d0dfbce63a89 | 264 | /*Configure the SysTick IRQ priority */ |
| elmot | 1:d0dfbce63a89 | 265 | HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority ,0); |
| elmot | 1:d0dfbce63a89 | 266 | |
| elmot | 1:d0dfbce63a89 | 267 | /* Return function status */ |
| elmot | 1:d0dfbce63a89 | 268 | return HAL_OK; |
| elmot | 1:d0dfbce63a89 | 269 | } |
| elmot | 1:d0dfbce63a89 | 270 | |
| elmot | 1:d0dfbce63a89 | 271 | /** |
| elmot | 1:d0dfbce63a89 | 272 | * @} |
| elmot | 1:d0dfbce63a89 | 273 | */ |
| elmot | 1:d0dfbce63a89 | 274 | |
| elmot | 1:d0dfbce63a89 | 275 | /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions |
| elmot | 1:d0dfbce63a89 | 276 | * @brief HAL Control functions |
| elmot | 1:d0dfbce63a89 | 277 | * |
| elmot | 1:d0dfbce63a89 | 278 | @verbatim |
| elmot | 1:d0dfbce63a89 | 279 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 280 | ##### HAL Control functions ##### |
| elmot | 1:d0dfbce63a89 | 281 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 282 | [..] This section provides functions allowing to: |
| elmot | 1:d0dfbce63a89 | 283 | (+) Provide a tick value in millisecond |
| elmot | 1:d0dfbce63a89 | 284 | (+) Provide a blocking delay in millisecond |
| elmot | 1:d0dfbce63a89 | 285 | (+) Suspend the time base source interrupt |
| elmot | 1:d0dfbce63a89 | 286 | (+) Resume the time base source interrupt |
| elmot | 1:d0dfbce63a89 | 287 | (+) Get the HAL API driver version |
| elmot | 1:d0dfbce63a89 | 288 | (+) Get the device identifier |
| elmot | 1:d0dfbce63a89 | 289 | (+) Get the device revision identifier |
| elmot | 1:d0dfbce63a89 | 290 | |
| elmot | 1:d0dfbce63a89 | 291 | @endverbatim |
| elmot | 1:d0dfbce63a89 | 292 | * @{ |
| elmot | 1:d0dfbce63a89 | 293 | */ |
| elmot | 1:d0dfbce63a89 | 294 | |
| elmot | 1:d0dfbce63a89 | 295 | /** |
| elmot | 1:d0dfbce63a89 | 296 | * @brief This function is called to increment a global variable "uwTick" |
| elmot | 1:d0dfbce63a89 | 297 | * used as application time base. |
| elmot | 1:d0dfbce63a89 | 298 | * @note In the default implementation, this variable is incremented each 1ms |
| elmot | 1:d0dfbce63a89 | 299 | * in SysTick ISR. |
| elmot | 1:d0dfbce63a89 | 300 | * @note This function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 301 | * implementations in user file. |
| elmot | 1:d0dfbce63a89 | 302 | * @retval None |
| elmot | 1:d0dfbce63a89 | 303 | */ |
| elmot | 1:d0dfbce63a89 | 304 | __weak void HAL_IncTick(void) |
| elmot | 1:d0dfbce63a89 | 305 | { |
| elmot | 1:d0dfbce63a89 | 306 | uwTick++; |
| elmot | 1:d0dfbce63a89 | 307 | } |
| elmot | 1:d0dfbce63a89 | 308 | |
| elmot | 1:d0dfbce63a89 | 309 | /** |
| elmot | 1:d0dfbce63a89 | 310 | * @brief Provide a tick value in millisecond. |
| elmot | 1:d0dfbce63a89 | 311 | * @note This function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 312 | * implementations in user file. |
| elmot | 1:d0dfbce63a89 | 313 | * @retval tick value |
| elmot | 1:d0dfbce63a89 | 314 | */ |
| elmot | 1:d0dfbce63a89 | 315 | __weak uint32_t HAL_GetTick(void) |
| elmot | 1:d0dfbce63a89 | 316 | { |
| elmot | 1:d0dfbce63a89 | 317 | return uwTick; |
| elmot | 1:d0dfbce63a89 | 318 | } |
| elmot | 1:d0dfbce63a89 | 319 | |
| elmot | 1:d0dfbce63a89 | 320 | /** |
| elmot | 1:d0dfbce63a89 | 321 | * @brief Provide accurate delay (in milliseconds) based on variable incremented. |
| elmot | 1:d0dfbce63a89 | 322 | * @note In the default implementation , SysTick timer is the source of time base. |
| elmot | 1:d0dfbce63a89 | 323 | * It is used to generate interrupts at regular time intervals where uwTick |
| elmot | 1:d0dfbce63a89 | 324 | * is incremented. |
| elmot | 1:d0dfbce63a89 | 325 | * @note This function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 326 | * implementations in user file. |
| elmot | 1:d0dfbce63a89 | 327 | * @param Delay: specifies the delay time length, in milliseconds. |
| elmot | 1:d0dfbce63a89 | 328 | * @retval None |
| elmot | 1:d0dfbce63a89 | 329 | */ |
| elmot | 1:d0dfbce63a89 | 330 | __weak void HAL_Delay(uint32_t Delay) |
| elmot | 1:d0dfbce63a89 | 331 | { |
| elmot | 1:d0dfbce63a89 | 332 | uint32_t tickstart = 0; |
| elmot | 1:d0dfbce63a89 | 333 | tickstart = HAL_GetTick(); |
| elmot | 1:d0dfbce63a89 | 334 | while((HAL_GetTick() - tickstart) < Delay) |
| elmot | 1:d0dfbce63a89 | 335 | { |
| elmot | 1:d0dfbce63a89 | 336 | } |
| elmot | 1:d0dfbce63a89 | 337 | } |
| elmot | 1:d0dfbce63a89 | 338 | |
| elmot | 1:d0dfbce63a89 | 339 | /** |
| elmot | 1:d0dfbce63a89 | 340 | * @brief Suspend Tick increment. |
| elmot | 1:d0dfbce63a89 | 341 | * @note In the default implementation , SysTick timer is the source of time base. It is |
| elmot | 1:d0dfbce63a89 | 342 | * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() |
| elmot | 1:d0dfbce63a89 | 343 | * is called, the SysTick interrupt will be disabled and so Tick increment |
| elmot | 1:d0dfbce63a89 | 344 | * is suspended. |
| elmot | 1:d0dfbce63a89 | 345 | * @note This function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 346 | * implementations in user file. |
| elmot | 1:d0dfbce63a89 | 347 | * @retval None |
| elmot | 1:d0dfbce63a89 | 348 | */ |
| elmot | 1:d0dfbce63a89 | 349 | __weak void HAL_SuspendTick(void) |
| elmot | 1:d0dfbce63a89 | 350 | { |
| elmot | 1:d0dfbce63a89 | 351 | /* Disable SysTick Interrupt */ |
| elmot | 1:d0dfbce63a89 | 352 | SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; |
| elmot | 1:d0dfbce63a89 | 353 | } |
| elmot | 1:d0dfbce63a89 | 354 | |
| elmot | 1:d0dfbce63a89 | 355 | /** |
| elmot | 1:d0dfbce63a89 | 356 | * @brief Resume Tick increment. |
| elmot | 1:d0dfbce63a89 | 357 | * @note In the default implementation , SysTick timer is the source of time base. It is |
| elmot | 1:d0dfbce63a89 | 358 | * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() |
| elmot | 1:d0dfbce63a89 | 359 | * is called, the SysTick interrupt will be enabled and so Tick increment |
| elmot | 1:d0dfbce63a89 | 360 | * is resumed. |
| elmot | 1:d0dfbce63a89 | 361 | * @note This function is declared as __weak to be overwritten in case of other |
| elmot | 1:d0dfbce63a89 | 362 | * implementations in user file. |
| elmot | 1:d0dfbce63a89 | 363 | * @retval None |
| elmot | 1:d0dfbce63a89 | 364 | */ |
| elmot | 1:d0dfbce63a89 | 365 | __weak void HAL_ResumeTick(void) |
| elmot | 1:d0dfbce63a89 | 366 | { |
| elmot | 1:d0dfbce63a89 | 367 | /* Enable SysTick Interrupt */ |
| elmot | 1:d0dfbce63a89 | 368 | SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; |
| elmot | 1:d0dfbce63a89 | 369 | } |
| elmot | 1:d0dfbce63a89 | 370 | |
| elmot | 1:d0dfbce63a89 | 371 | /** |
| elmot | 1:d0dfbce63a89 | 372 | * @brief Return the HAL revision. |
| elmot | 1:d0dfbce63a89 | 373 | * @retval version : 0xXYZR (8bits for each decimal, R for RC) |
| elmot | 1:d0dfbce63a89 | 374 | */ |
| elmot | 1:d0dfbce63a89 | 375 | uint32_t HAL_GetHalVersion(void) |
| elmot | 1:d0dfbce63a89 | 376 | { |
| elmot | 1:d0dfbce63a89 | 377 | return __STM32L4xx_HAL_VERSION; |
| elmot | 1:d0dfbce63a89 | 378 | } |
| elmot | 1:d0dfbce63a89 | 379 | |
| elmot | 1:d0dfbce63a89 | 380 | /** |
| elmot | 1:d0dfbce63a89 | 381 | * @brief Return the device revision identifier. |
| elmot | 1:d0dfbce63a89 | 382 | * @retval Device revision identifier |
| elmot | 1:d0dfbce63a89 | 383 | */ |
| elmot | 1:d0dfbce63a89 | 384 | uint32_t HAL_GetREVID(void) |
| elmot | 1:d0dfbce63a89 | 385 | { |
| elmot | 1:d0dfbce63a89 | 386 | return((DBGMCU->IDCODE & DBGMCU_IDCODE_REV_ID) >> 16); |
| elmot | 1:d0dfbce63a89 | 387 | } |
| elmot | 1:d0dfbce63a89 | 388 | |
| elmot | 1:d0dfbce63a89 | 389 | /** |
| elmot | 1:d0dfbce63a89 | 390 | * @brief Return the device identifier. |
| elmot | 1:d0dfbce63a89 | 391 | * @retval Device identifier |
| elmot | 1:d0dfbce63a89 | 392 | */ |
| elmot | 1:d0dfbce63a89 | 393 | uint32_t HAL_GetDEVID(void) |
| elmot | 1:d0dfbce63a89 | 394 | { |
| elmot | 1:d0dfbce63a89 | 395 | return(DBGMCU->IDCODE & DBGMCU_IDCODE_DEV_ID); |
| elmot | 1:d0dfbce63a89 | 396 | } |
| elmot | 1:d0dfbce63a89 | 397 | |
| elmot | 1:d0dfbce63a89 | 398 | /** |
| elmot | 1:d0dfbce63a89 | 399 | * @} |
| elmot | 1:d0dfbce63a89 | 400 | */ |
| elmot | 1:d0dfbce63a89 | 401 | |
| elmot | 1:d0dfbce63a89 | 402 | /** @defgroup HAL_Exported_Functions_Group3 HAL Debug functions |
| elmot | 1:d0dfbce63a89 | 403 | * @brief HAL Debug functions |
| elmot | 1:d0dfbce63a89 | 404 | * |
| elmot | 1:d0dfbce63a89 | 405 | @verbatim |
| elmot | 1:d0dfbce63a89 | 406 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 407 | ##### HAL Debug functions ##### |
| elmot | 1:d0dfbce63a89 | 408 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 409 | [..] This section provides functions allowing to: |
| elmot | 1:d0dfbce63a89 | 410 | (+) Enable/Disable Debug module during SLEEP mode |
| elmot | 1:d0dfbce63a89 | 411 | (+) Enable/Disable Debug module during STOP0/STOP1/STOP2 modes |
| elmot | 1:d0dfbce63a89 | 412 | (+) Enable/Disable Debug module during STANDBY mode |
| elmot | 1:d0dfbce63a89 | 413 | |
| elmot | 1:d0dfbce63a89 | 414 | @endverbatim |
| elmot | 1:d0dfbce63a89 | 415 | * @{ |
| elmot | 1:d0dfbce63a89 | 416 | */ |
| elmot | 1:d0dfbce63a89 | 417 | |
| elmot | 1:d0dfbce63a89 | 418 | /** |
| elmot | 1:d0dfbce63a89 | 419 | * @brief Enable the Debug Module during SLEEP mode. |
| elmot | 1:d0dfbce63a89 | 420 | * @retval None |
| elmot | 1:d0dfbce63a89 | 421 | */ |
| elmot | 1:d0dfbce63a89 | 422 | void HAL_DBGMCU_EnableDBGSleepMode(void) |
| elmot | 1:d0dfbce63a89 | 423 | { |
| elmot | 1:d0dfbce63a89 | 424 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); |
| elmot | 1:d0dfbce63a89 | 425 | } |
| elmot | 1:d0dfbce63a89 | 426 | |
| elmot | 1:d0dfbce63a89 | 427 | /** |
| elmot | 1:d0dfbce63a89 | 428 | * @brief Disable the Debug Module during SLEEP mode. |
| elmot | 1:d0dfbce63a89 | 429 | * @retval None |
| elmot | 1:d0dfbce63a89 | 430 | */ |
| elmot | 1:d0dfbce63a89 | 431 | void HAL_DBGMCU_DisableDBGSleepMode(void) |
| elmot | 1:d0dfbce63a89 | 432 | { |
| elmot | 1:d0dfbce63a89 | 433 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); |
| elmot | 1:d0dfbce63a89 | 434 | } |
| elmot | 1:d0dfbce63a89 | 435 | |
| elmot | 1:d0dfbce63a89 | 436 | /** |
| elmot | 1:d0dfbce63a89 | 437 | * @brief Enable the Debug Module during STOP0/STOP1/STOP2 modes. |
| elmot | 1:d0dfbce63a89 | 438 | * @retval None |
| elmot | 1:d0dfbce63a89 | 439 | */ |
| elmot | 1:d0dfbce63a89 | 440 | void HAL_DBGMCU_EnableDBGStopMode(void) |
| elmot | 1:d0dfbce63a89 | 441 | { |
| elmot | 1:d0dfbce63a89 | 442 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); |
| elmot | 1:d0dfbce63a89 | 443 | } |
| elmot | 1:d0dfbce63a89 | 444 | |
| elmot | 1:d0dfbce63a89 | 445 | /** |
| elmot | 1:d0dfbce63a89 | 446 | * @brief Disable the Debug Module during STOP0/STOP1/STOP2 modes. |
| elmot | 1:d0dfbce63a89 | 447 | * @retval None |
| elmot | 1:d0dfbce63a89 | 448 | */ |
| elmot | 1:d0dfbce63a89 | 449 | void HAL_DBGMCU_DisableDBGStopMode(void) |
| elmot | 1:d0dfbce63a89 | 450 | { |
| elmot | 1:d0dfbce63a89 | 451 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); |
| elmot | 1:d0dfbce63a89 | 452 | } |
| elmot | 1:d0dfbce63a89 | 453 | |
| elmot | 1:d0dfbce63a89 | 454 | /** |
| elmot | 1:d0dfbce63a89 | 455 | * @brief Enable the Debug Module during STANDBY mode. |
| elmot | 1:d0dfbce63a89 | 456 | * @retval None |
| elmot | 1:d0dfbce63a89 | 457 | */ |
| elmot | 1:d0dfbce63a89 | 458 | void HAL_DBGMCU_EnableDBGStandbyMode(void) |
| elmot | 1:d0dfbce63a89 | 459 | { |
| elmot | 1:d0dfbce63a89 | 460 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); |
| elmot | 1:d0dfbce63a89 | 461 | } |
| elmot | 1:d0dfbce63a89 | 462 | |
| elmot | 1:d0dfbce63a89 | 463 | /** |
| elmot | 1:d0dfbce63a89 | 464 | * @brief Disable the Debug Module during STANDBY mode. |
| elmot | 1:d0dfbce63a89 | 465 | * @retval None |
| elmot | 1:d0dfbce63a89 | 466 | */ |
| elmot | 1:d0dfbce63a89 | 467 | void HAL_DBGMCU_DisableDBGStandbyMode(void) |
| elmot | 1:d0dfbce63a89 | 468 | { |
| elmot | 1:d0dfbce63a89 | 469 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); |
| elmot | 1:d0dfbce63a89 | 470 | } |
| elmot | 1:d0dfbce63a89 | 471 | |
| elmot | 1:d0dfbce63a89 | 472 | /** |
| elmot | 1:d0dfbce63a89 | 473 | * @} |
| elmot | 1:d0dfbce63a89 | 474 | */ |
| elmot | 1:d0dfbce63a89 | 475 | |
| elmot | 1:d0dfbce63a89 | 476 | /** @defgroup HAL_Exported_Functions_Group4 HAL SYSCFG configuration functions |
| elmot | 1:d0dfbce63a89 | 477 | * @brief HAL SYSCFG configuration functions |
| elmot | 1:d0dfbce63a89 | 478 | * |
| elmot | 1:d0dfbce63a89 | 479 | @verbatim |
| elmot | 1:d0dfbce63a89 | 480 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 481 | ##### HAL SYSCFG configuration functions ##### |
| elmot | 1:d0dfbce63a89 | 482 | =============================================================================== |
| elmot | 1:d0dfbce63a89 | 483 | [..] This section provides functions allowing to: |
| elmot | 1:d0dfbce63a89 | 484 | (+) Start a hardware SRAM2 erase operation |
| elmot | 1:d0dfbce63a89 | 485 | (+) Enable/Disable the Internal FLASH Bank Swapping |
| elmot | 1:d0dfbce63a89 | 486 | (+) Configure the Voltage reference buffer |
| elmot | 1:d0dfbce63a89 | 487 | (+) Enable/Disable the Voltage reference buffer |
| elmot | 1:d0dfbce63a89 | 488 | (+) Enable/Disable the I/O analog switch voltage booster |
| elmot | 1:d0dfbce63a89 | 489 | |
| elmot | 1:d0dfbce63a89 | 490 | @endverbatim |
| elmot | 1:d0dfbce63a89 | 491 | * @{ |
| elmot | 1:d0dfbce63a89 | 492 | */ |
| elmot | 1:d0dfbce63a89 | 493 | |
| elmot | 1:d0dfbce63a89 | 494 | /** |
| elmot | 1:d0dfbce63a89 | 495 | * @brief Start a hardware SRAM2 erase operation. |
| elmot | 1:d0dfbce63a89 | 496 | * @note As long as SRAM2 is not erased the SRAM2ER bit will be set. |
| elmot | 1:d0dfbce63a89 | 497 | * This bit is automatically reset at the end of the SRAM2 erase operation. |
| elmot | 1:d0dfbce63a89 | 498 | * @retval None |
| elmot | 1:d0dfbce63a89 | 499 | */ |
| elmot | 1:d0dfbce63a89 | 500 | void HAL_SYSCFG_SRAM2Erase(void) |
| elmot | 1:d0dfbce63a89 | 501 | { |
| elmot | 1:d0dfbce63a89 | 502 | /* unlock the write protection of the SRAM2ER bit */ |
| elmot | 1:d0dfbce63a89 | 503 | SYSCFG->SKR = 0xCA; |
| elmot | 1:d0dfbce63a89 | 504 | SYSCFG->SKR = 0x53; |
| elmot | 1:d0dfbce63a89 | 505 | /* Starts a hardware SRAM2 erase operation*/ |
| elmot | 1:d0dfbce63a89 | 506 | *(__IO uint32_t *) SCSR_SRAM2ER_BB = (uint8_t)0x00000001; |
| elmot | 1:d0dfbce63a89 | 507 | } |
| elmot | 1:d0dfbce63a89 | 508 | |
| elmot | 1:d0dfbce63a89 | 509 | /** |
| elmot | 1:d0dfbce63a89 | 510 | * @brief Enable the Internal FLASH Bank Swapping. |
| elmot | 1:d0dfbce63a89 | 511 | * |
| elmot | 1:d0dfbce63a89 | 512 | * @note This function can be used only for STM32L4xx devices. |
| elmot | 1:d0dfbce63a89 | 513 | * |
| elmot | 1:d0dfbce63a89 | 514 | * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) |
| elmot | 1:d0dfbce63a89 | 515 | * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) |
| elmot | 1:d0dfbce63a89 | 516 | * |
| elmot | 1:d0dfbce63a89 | 517 | * @retval None |
| elmot | 1:d0dfbce63a89 | 518 | */ |
| elmot | 1:d0dfbce63a89 | 519 | void HAL_SYSCFG_EnableMemorySwappingBank(void) |
| elmot | 1:d0dfbce63a89 | 520 | { |
| elmot | 1:d0dfbce63a89 | 521 | *(__IO uint32_t *)FB_MODE_BB = (uint32_t)ENABLE; |
| elmot | 1:d0dfbce63a89 | 522 | } |
| elmot | 1:d0dfbce63a89 | 523 | |
| elmot | 1:d0dfbce63a89 | 524 | /** |
| elmot | 1:d0dfbce63a89 | 525 | * @brief Disable the Internal FLASH Bank Swapping. |
| elmot | 1:d0dfbce63a89 | 526 | * |
| elmot | 1:d0dfbce63a89 | 527 | * @note This function can be used only for STM32L4xx devices. |
| elmot | 1:d0dfbce63a89 | 528 | * |
| elmot | 1:d0dfbce63a89 | 529 | * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x0000 0000) |
| elmot | 1:d0dfbce63a89 | 530 | * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) |
| elmot | 1:d0dfbce63a89 | 531 | * |
| elmot | 1:d0dfbce63a89 | 532 | * @retval None |
| elmot | 1:d0dfbce63a89 | 533 | */ |
| elmot | 1:d0dfbce63a89 | 534 | void HAL_SYSCFG_DisableMemorySwappingBank(void) |
| elmot | 1:d0dfbce63a89 | 535 | { |
| elmot | 1:d0dfbce63a89 | 536 | |
| elmot | 1:d0dfbce63a89 | 537 | *(__IO uint32_t *)FB_MODE_BB = (uint32_t)DISABLE; |
| elmot | 1:d0dfbce63a89 | 538 | } |
| elmot | 1:d0dfbce63a89 | 539 | |
| elmot | 1:d0dfbce63a89 | 540 | #if defined(VREFBUF) |
| elmot | 1:d0dfbce63a89 | 541 | /** |
| elmot | 1:d0dfbce63a89 | 542 | * @brief Configure the internal voltage reference buffer voltage scale. |
| elmot | 1:d0dfbce63a89 | 543 | * @param VoltageScaling: specifies the output voltage to achieve |
| elmot | 1:d0dfbce63a89 | 544 | * This parameter can be one of the following values: |
| elmot | 1:d0dfbce63a89 | 545 | * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V. |
| elmot | 1:d0dfbce63a89 | 546 | * This requires VDDA equal to or higher than 2.4 V. |
| elmot | 1:d0dfbce63a89 | 547 | * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT1 around 2.5 V. |
| elmot | 1:d0dfbce63a89 | 548 | * This requires VDDA equal to or higher than 2.8 V. |
| elmot | 1:d0dfbce63a89 | 549 | * @retval None |
| elmot | 1:d0dfbce63a89 | 550 | */ |
| elmot | 1:d0dfbce63a89 | 551 | void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) |
| elmot | 1:d0dfbce63a89 | 552 | { |
| elmot | 1:d0dfbce63a89 | 553 | /* Check the parameters */ |
| elmot | 1:d0dfbce63a89 | 554 | assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); |
| elmot | 1:d0dfbce63a89 | 555 | |
| elmot | 1:d0dfbce63a89 | 556 | MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling); |
| elmot | 1:d0dfbce63a89 | 557 | } |
| elmot | 1:d0dfbce63a89 | 558 | |
| elmot | 1:d0dfbce63a89 | 559 | /** |
| elmot | 1:d0dfbce63a89 | 560 | * @brief Configure the internal voltage reference buffer high impedance mode. |
| elmot | 1:d0dfbce63a89 | 561 | * @param Mode: specifies the high impedance mode |
| elmot | 1:d0dfbce63a89 | 562 | * This parameter can be one of the following values: |
| elmot | 1:d0dfbce63a89 | 563 | * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output. |
| elmot | 1:d0dfbce63a89 | 564 | * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance. |
| elmot | 1:d0dfbce63a89 | 565 | * @retval None |
| elmot | 1:d0dfbce63a89 | 566 | */ |
| elmot | 1:d0dfbce63a89 | 567 | void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) |
| elmot | 1:d0dfbce63a89 | 568 | { |
| elmot | 1:d0dfbce63a89 | 569 | /* Check the parameters */ |
| elmot | 1:d0dfbce63a89 | 570 | assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); |
| elmot | 1:d0dfbce63a89 | 571 | |
| elmot | 1:d0dfbce63a89 | 572 | MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); |
| elmot | 1:d0dfbce63a89 | 573 | } |
| elmot | 1:d0dfbce63a89 | 574 | |
| elmot | 1:d0dfbce63a89 | 575 | /** |
| elmot | 1:d0dfbce63a89 | 576 | * @brief Tune the Internal Voltage Reference buffer (VREFBUF). |
| elmot | 1:d0dfbce63a89 | 577 | * @retval None |
| elmot | 1:d0dfbce63a89 | 578 | */ |
| elmot | 1:d0dfbce63a89 | 579 | void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) |
| elmot | 1:d0dfbce63a89 | 580 | { |
| elmot | 1:d0dfbce63a89 | 581 | /* Check the parameters */ |
| elmot | 1:d0dfbce63a89 | 582 | assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); |
| elmot | 1:d0dfbce63a89 | 583 | |
| elmot | 1:d0dfbce63a89 | 584 | MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue); |
| elmot | 1:d0dfbce63a89 | 585 | } |
| elmot | 1:d0dfbce63a89 | 586 | |
| elmot | 1:d0dfbce63a89 | 587 | /** |
| elmot | 1:d0dfbce63a89 | 588 | * @brief Enable the Internal Voltage Reference buffer (VREFBUF). |
| elmot | 1:d0dfbce63a89 | 589 | * @retval HAL_OK/HAL_TIMEOUT |
| elmot | 1:d0dfbce63a89 | 590 | */ |
| elmot | 1:d0dfbce63a89 | 591 | HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) |
| elmot | 1:d0dfbce63a89 | 592 | { |
| elmot | 1:d0dfbce63a89 | 593 | uint32_t tickstart = 0; |
| elmot | 1:d0dfbce63a89 | 594 | |
| elmot | 1:d0dfbce63a89 | 595 | SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); |
| elmot | 1:d0dfbce63a89 | 596 | |
| elmot | 1:d0dfbce63a89 | 597 | /* Get Start Tick*/ |
| elmot | 1:d0dfbce63a89 | 598 | tickstart = HAL_GetTick(); |
| elmot | 1:d0dfbce63a89 | 599 | |
| elmot | 1:d0dfbce63a89 | 600 | /* Wait for VRR bit */ |
| elmot | 1:d0dfbce63a89 | 601 | while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == RESET) |
| elmot | 1:d0dfbce63a89 | 602 | { |
| elmot | 1:d0dfbce63a89 | 603 | if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) |
| elmot | 1:d0dfbce63a89 | 604 | { |
| elmot | 1:d0dfbce63a89 | 605 | return HAL_TIMEOUT; |
| elmot | 1:d0dfbce63a89 | 606 | } |
| elmot | 1:d0dfbce63a89 | 607 | } |
| elmot | 1:d0dfbce63a89 | 608 | |
| elmot | 1:d0dfbce63a89 | 609 | return HAL_OK; |
| elmot | 1:d0dfbce63a89 | 610 | } |
| elmot | 1:d0dfbce63a89 | 611 | |
| elmot | 1:d0dfbce63a89 | 612 | /** |
| elmot | 1:d0dfbce63a89 | 613 | * @brief Disable the Internal Voltage Reference buffer (VREFBUF). |
| elmot | 1:d0dfbce63a89 | 614 | * |
| elmot | 1:d0dfbce63a89 | 615 | * @retval None |
| elmot | 1:d0dfbce63a89 | 616 | */ |
| elmot | 1:d0dfbce63a89 | 617 | void HAL_SYSCFG_DisableVREFBUF(void) |
| elmot | 1:d0dfbce63a89 | 618 | { |
| elmot | 1:d0dfbce63a89 | 619 | CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); |
| elmot | 1:d0dfbce63a89 | 620 | } |
| elmot | 1:d0dfbce63a89 | 621 | #endif /* VREFBUF */ |
| elmot | 1:d0dfbce63a89 | 622 | |
| elmot | 1:d0dfbce63a89 | 623 | /** |
| elmot | 1:d0dfbce63a89 | 624 | * @brief Enable the I/O analog switch voltage booster |
| elmot | 1:d0dfbce63a89 | 625 | * |
| elmot | 1:d0dfbce63a89 | 626 | * @retval None |
| elmot | 1:d0dfbce63a89 | 627 | */ |
| elmot | 1:d0dfbce63a89 | 628 | void HAL_SYSCFG_EnableIOAnalogSwitchBooster(void) |
| elmot | 1:d0dfbce63a89 | 629 | { |
| elmot | 1:d0dfbce63a89 | 630 | SET_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); |
| elmot | 1:d0dfbce63a89 | 631 | } |
| elmot | 1:d0dfbce63a89 | 632 | |
| elmot | 1:d0dfbce63a89 | 633 | /** |
| elmot | 1:d0dfbce63a89 | 634 | * @brief Disable the I/O analog switch voltage booster |
| elmot | 1:d0dfbce63a89 | 635 | * |
| elmot | 1:d0dfbce63a89 | 636 | * @retval None |
| elmot | 1:d0dfbce63a89 | 637 | */ |
| elmot | 1:d0dfbce63a89 | 638 | void HAL_SYSCFG_DisableIOAnalogSwitchBooster(void) |
| elmot | 1:d0dfbce63a89 | 639 | { |
| elmot | 1:d0dfbce63a89 | 640 | CLEAR_BIT(SYSCFG->CFGR1, SYSCFG_CFGR1_BOOSTEN); |
| elmot | 1:d0dfbce63a89 | 641 | } |
| elmot | 1:d0dfbce63a89 | 642 | |
| elmot | 1:d0dfbce63a89 | 643 | /** |
| elmot | 1:d0dfbce63a89 | 644 | * @} |
| elmot | 1:d0dfbce63a89 | 645 | */ |
| elmot | 1:d0dfbce63a89 | 646 | |
| elmot | 1:d0dfbce63a89 | 647 | /** |
| elmot | 1:d0dfbce63a89 | 648 | * @} |
| elmot | 1:d0dfbce63a89 | 649 | */ |
| elmot | 1:d0dfbce63a89 | 650 | |
| elmot | 1:d0dfbce63a89 | 651 | #endif /* HAL_MODULE_ENABLED */ |
| elmot | 1:d0dfbce63a89 | 652 | /** |
| elmot | 1:d0dfbce63a89 | 653 | * @} |
| elmot | 1:d0dfbce63a89 | 654 | */ |
| elmot | 1:d0dfbce63a89 | 655 | |
| elmot | 1:d0dfbce63a89 | 656 | /** |
| elmot | 1:d0dfbce63a89 | 657 | * @} |
| elmot | 1:d0dfbce63a89 | 658 | */ |
| elmot | 1:d0dfbce63a89 | 659 | |
| elmot | 1:d0dfbce63a89 | 660 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |