Initial commit
mbed-dev-master/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal.c@0:bb348c97df44, 2020-09-16 (annotated)
- Committer:
- lypinator
- Date:
- Wed Sep 16 01:11:49 2020 +0000
- Revision:
- 0:bb348c97df44
Added PWM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
lypinator | 0:bb348c97df44 | 1 | /** |
lypinator | 0:bb348c97df44 | 2 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 3 | * @file stm32f4xx_hal.c |
lypinator | 0:bb348c97df44 | 4 | * @author MCD Application Team |
lypinator | 0:bb348c97df44 | 5 | * @brief HAL module driver. |
lypinator | 0:bb348c97df44 | 6 | * This is the common part of the HAL initialization |
lypinator | 0:bb348c97df44 | 7 | * |
lypinator | 0:bb348c97df44 | 8 | @verbatim |
lypinator | 0:bb348c97df44 | 9 | ============================================================================== |
lypinator | 0:bb348c97df44 | 10 | ##### How to use this driver ##### |
lypinator | 0:bb348c97df44 | 11 | ============================================================================== |
lypinator | 0:bb348c97df44 | 12 | [..] |
lypinator | 0:bb348c97df44 | 13 | The common HAL driver contains a set of generic and common APIs that can be |
lypinator | 0:bb348c97df44 | 14 | used by the PPP peripheral drivers and the user to start using the HAL. |
lypinator | 0:bb348c97df44 | 15 | [..] |
lypinator | 0:bb348c97df44 | 16 | The HAL contains two APIs' categories: |
lypinator | 0:bb348c97df44 | 17 | (+) Common HAL APIs |
lypinator | 0:bb348c97df44 | 18 | (+) Services HAL APIs |
lypinator | 0:bb348c97df44 | 19 | |
lypinator | 0:bb348c97df44 | 20 | @endverbatim |
lypinator | 0:bb348c97df44 | 21 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 22 | * @attention |
lypinator | 0:bb348c97df44 | 23 | * |
lypinator | 0:bb348c97df44 | 24 | * <h2><center>© COPYRIGHT(c) 2017 STMicroelectronics</center></h2> |
lypinator | 0:bb348c97df44 | 25 | * |
lypinator | 0:bb348c97df44 | 26 | * Redistribution and use in source and binary forms, with or without modification, |
lypinator | 0:bb348c97df44 | 27 | * are permitted provided that the following conditions are met: |
lypinator | 0:bb348c97df44 | 28 | * 1. Redistributions of source code must retain the above copyright notice, |
lypinator | 0:bb348c97df44 | 29 | * this list of conditions and the following disclaimer. |
lypinator | 0:bb348c97df44 | 30 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
lypinator | 0:bb348c97df44 | 31 | * this list of conditions and the following disclaimer in the documentation |
lypinator | 0:bb348c97df44 | 32 | * and/or other materials provided with the distribution. |
lypinator | 0:bb348c97df44 | 33 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
lypinator | 0:bb348c97df44 | 34 | * may be used to endorse or promote products derived from this software |
lypinator | 0:bb348c97df44 | 35 | * without specific prior written permission. |
lypinator | 0:bb348c97df44 | 36 | * |
lypinator | 0:bb348c97df44 | 37 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
lypinator | 0:bb348c97df44 | 38 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
lypinator | 0:bb348c97df44 | 39 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
lypinator | 0:bb348c97df44 | 40 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
lypinator | 0:bb348c97df44 | 41 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
lypinator | 0:bb348c97df44 | 42 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
lypinator | 0:bb348c97df44 | 43 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
lypinator | 0:bb348c97df44 | 44 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
lypinator | 0:bb348c97df44 | 45 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
lypinator | 0:bb348c97df44 | 46 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
lypinator | 0:bb348c97df44 | 47 | * |
lypinator | 0:bb348c97df44 | 48 | ****************************************************************************** |
lypinator | 0:bb348c97df44 | 49 | */ |
lypinator | 0:bb348c97df44 | 50 | |
lypinator | 0:bb348c97df44 | 51 | /* Includes ------------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 52 | #include "stm32f4xx_hal.h" |
lypinator | 0:bb348c97df44 | 53 | |
lypinator | 0:bb348c97df44 | 54 | /** @addtogroup STM32F4xx_HAL_Driver |
lypinator | 0:bb348c97df44 | 55 | * @{ |
lypinator | 0:bb348c97df44 | 56 | */ |
lypinator | 0:bb348c97df44 | 57 | |
lypinator | 0:bb348c97df44 | 58 | /** @defgroup HAL HAL |
lypinator | 0:bb348c97df44 | 59 | * @brief HAL module driver. |
lypinator | 0:bb348c97df44 | 60 | * @{ |
lypinator | 0:bb348c97df44 | 61 | */ |
lypinator | 0:bb348c97df44 | 62 | |
lypinator | 0:bb348c97df44 | 63 | /* Private typedef -----------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 64 | /* Private define ------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 65 | /** @addtogroup HAL_Private_Constants |
lypinator | 0:bb348c97df44 | 66 | * @{ |
lypinator | 0:bb348c97df44 | 67 | */ |
lypinator | 0:bb348c97df44 | 68 | /** |
lypinator | 0:bb348c97df44 | 69 | * @brief STM32F4xx HAL Driver version number V1.7.3 |
lypinator | 0:bb348c97df44 | 70 | */ |
lypinator | 0:bb348c97df44 | 71 | #define __STM32F4xx_HAL_VERSION_MAIN (0x01U) /*!< [31:24] main version */ |
lypinator | 0:bb348c97df44 | 72 | #define __STM32F4xx_HAL_VERSION_SUB1 (0x07U) /*!< [23:16] sub1 version */ |
lypinator | 0:bb348c97df44 | 73 | #define __STM32F4xx_HAL_VERSION_SUB2 (0x03U) /*!< [15:8] sub2 version */ |
lypinator | 0:bb348c97df44 | 74 | #define __STM32F4xx_HAL_VERSION_RC (0x00U) /*!< [7:0] release candidate */ |
lypinator | 0:bb348c97df44 | 75 | #define __STM32F4xx_HAL_VERSION ((__STM32F4xx_HAL_VERSION_MAIN << 24U)\ |
lypinator | 0:bb348c97df44 | 76 | |(__STM32F4xx_HAL_VERSION_SUB1 << 16U)\ |
lypinator | 0:bb348c97df44 | 77 | |(__STM32F4xx_HAL_VERSION_SUB2 << 8U )\ |
lypinator | 0:bb348c97df44 | 78 | |(__STM32F4xx_HAL_VERSION_RC)) |
lypinator | 0:bb348c97df44 | 79 | |
lypinator | 0:bb348c97df44 | 80 | #define IDCODE_DEVID_MASK 0x00000FFFU |
lypinator | 0:bb348c97df44 | 81 | |
lypinator | 0:bb348c97df44 | 82 | /* ------------ RCC registers bit address in the alias region ----------- */ |
lypinator | 0:bb348c97df44 | 83 | #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE) |
lypinator | 0:bb348c97df44 | 84 | /* --- MEMRMP Register ---*/ |
lypinator | 0:bb348c97df44 | 85 | /* Alias word address of UFB_MODE bit */ |
lypinator | 0:bb348c97df44 | 86 | #define MEMRMP_OFFSET SYSCFG_OFFSET |
lypinator | 0:bb348c97df44 | 87 | #define UFB_MODE_BIT_NUMBER SYSCFG_MEMRMP_UFB_MODE_Pos |
lypinator | 0:bb348c97df44 | 88 | #define UFB_MODE_BB (uint32_t)(PERIPH_BB_BASE + (MEMRMP_OFFSET * 32U) + (UFB_MODE_BIT_NUMBER * 4U)) |
lypinator | 0:bb348c97df44 | 89 | |
lypinator | 0:bb348c97df44 | 90 | /* --- CMPCR Register ---*/ |
lypinator | 0:bb348c97df44 | 91 | /* Alias word address of CMP_PD bit */ |
lypinator | 0:bb348c97df44 | 92 | #define CMPCR_OFFSET (SYSCFG_OFFSET + 0x20U) |
lypinator | 0:bb348c97df44 | 93 | #define CMP_PD_BIT_NUMBER SYSCFG_CMPCR_CMP_PD_Pos |
lypinator | 0:bb348c97df44 | 94 | #define CMPCR_CMP_PD_BB (uint32_t)(PERIPH_BB_BASE + (CMPCR_OFFSET * 32U) + (CMP_PD_BIT_NUMBER * 4U)) |
lypinator | 0:bb348c97df44 | 95 | |
lypinator | 0:bb348c97df44 | 96 | /* --- MCHDLYCR Register ---*/ |
lypinator | 0:bb348c97df44 | 97 | /* Alias word address of BSCKSEL bit */ |
lypinator | 0:bb348c97df44 | 98 | #define MCHDLYCR_OFFSET (SYSCFG_OFFSET + 0x30U) |
lypinator | 0:bb348c97df44 | 99 | #define BSCKSEL_BIT_NUMBER SYSCFG_MCHDLYCR_BSCKSEL_Pos |
lypinator | 0:bb348c97df44 | 100 | #define MCHDLYCR_BSCKSEL_BB (uint32_t)(PERIPH_BB_BASE + (MCHDLYCR_OFFSET * 32U) + (BSCKSEL_BIT_NUMBER * 4U)) |
lypinator | 0:bb348c97df44 | 101 | /** |
lypinator | 0:bb348c97df44 | 102 | * @} |
lypinator | 0:bb348c97df44 | 103 | */ |
lypinator | 0:bb348c97df44 | 104 | |
lypinator | 0:bb348c97df44 | 105 | /* Private macro -------------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 106 | /* Private variables ---------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 107 | /** @addtogroup HAL_Private_Variables |
lypinator | 0:bb348c97df44 | 108 | * @{ |
lypinator | 0:bb348c97df44 | 109 | */ |
lypinator | 0:bb348c97df44 | 110 | __IO uint32_t uwTick; |
lypinator | 0:bb348c97df44 | 111 | uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */ |
lypinator | 0:bb348c97df44 | 112 | HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */ |
lypinator | 0:bb348c97df44 | 113 | /** |
lypinator | 0:bb348c97df44 | 114 | * @} |
lypinator | 0:bb348c97df44 | 115 | */ |
lypinator | 0:bb348c97df44 | 116 | /* Private function prototypes -----------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 117 | /* Private functions ---------------------------------------------------------*/ |
lypinator | 0:bb348c97df44 | 118 | |
lypinator | 0:bb348c97df44 | 119 | /** @defgroup HAL_Exported_Functions HAL Exported Functions |
lypinator | 0:bb348c97df44 | 120 | * @{ |
lypinator | 0:bb348c97df44 | 121 | */ |
lypinator | 0:bb348c97df44 | 122 | |
lypinator | 0:bb348c97df44 | 123 | /** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions |
lypinator | 0:bb348c97df44 | 124 | * @brief Initialization and de-initialization functions |
lypinator | 0:bb348c97df44 | 125 | * |
lypinator | 0:bb348c97df44 | 126 | @verbatim |
lypinator | 0:bb348c97df44 | 127 | =============================================================================== |
lypinator | 0:bb348c97df44 | 128 | ##### Initialization and Configuration functions ##### |
lypinator | 0:bb348c97df44 | 129 | =============================================================================== |
lypinator | 0:bb348c97df44 | 130 | [..] This section provides functions allowing to: |
lypinator | 0:bb348c97df44 | 131 | (+) Initializes the Flash interface the NVIC allocation and initial clock |
lypinator | 0:bb348c97df44 | 132 | configuration. It initializes the systick also when timeout is needed |
lypinator | 0:bb348c97df44 | 133 | and the backup domain when enabled. |
lypinator | 0:bb348c97df44 | 134 | (+) De-Initializes common part of the HAL. |
lypinator | 0:bb348c97df44 | 135 | (+) Configure the time base source to have 1ms time base with a dedicated |
lypinator | 0:bb348c97df44 | 136 | Tick interrupt priority. |
lypinator | 0:bb348c97df44 | 137 | (++) SysTick timer is used by default as source of time base, but user |
lypinator | 0:bb348c97df44 | 138 | can eventually implement his proper time base source (a general purpose |
lypinator | 0:bb348c97df44 | 139 | timer for example or other time source), keeping in mind that Time base |
lypinator | 0:bb348c97df44 | 140 | duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and |
lypinator | 0:bb348c97df44 | 141 | handled in milliseconds basis. |
lypinator | 0:bb348c97df44 | 142 | (++) Time base configuration function (HAL_InitTick ()) is called automatically |
lypinator | 0:bb348c97df44 | 143 | at the beginning of the program after reset by HAL_Init() or at any time |
lypinator | 0:bb348c97df44 | 144 | when clock is configured, by HAL_RCC_ClockConfig(). |
lypinator | 0:bb348c97df44 | 145 | (++) Source of time base is configured to generate interrupts at regular |
lypinator | 0:bb348c97df44 | 146 | time intervals. Care must be taken if HAL_Delay() is called from a |
lypinator | 0:bb348c97df44 | 147 | peripheral ISR process, the Tick interrupt line must have higher priority |
lypinator | 0:bb348c97df44 | 148 | (numerically lower) than the peripheral interrupt. Otherwise the caller |
lypinator | 0:bb348c97df44 | 149 | ISR process will be blocked. |
lypinator | 0:bb348c97df44 | 150 | (++) functions affecting time base configurations are declared as __weak |
lypinator | 0:bb348c97df44 | 151 | to make override possible in case of other implementations in user file. |
lypinator | 0:bb348c97df44 | 152 | @endverbatim |
lypinator | 0:bb348c97df44 | 153 | * @{ |
lypinator | 0:bb348c97df44 | 154 | */ |
lypinator | 0:bb348c97df44 | 155 | |
lypinator | 0:bb348c97df44 | 156 | /** |
lypinator | 0:bb348c97df44 | 157 | * @brief This function is used to initialize the HAL Library; it must be the first |
lypinator | 0:bb348c97df44 | 158 | * instruction to be executed in the main program (before to call any other |
lypinator | 0:bb348c97df44 | 159 | * HAL function), it performs the following: |
lypinator | 0:bb348c97df44 | 160 | * Configure the Flash prefetch, instruction and Data caches. |
lypinator | 0:bb348c97df44 | 161 | * Configures the SysTick to generate an interrupt each 1 millisecond, |
lypinator | 0:bb348c97df44 | 162 | * which is clocked by the HSI (at this stage, the clock is not yet |
lypinator | 0:bb348c97df44 | 163 | * configured and thus the system is running from the internal HSI at 16 MHz). |
lypinator | 0:bb348c97df44 | 164 | * Set NVIC Group Priority to 4. |
lypinator | 0:bb348c97df44 | 165 | * Calls the HAL_MspInit() callback function defined in user file |
lypinator | 0:bb348c97df44 | 166 | * "stm32f4xx_hal_msp.c" to do the global low level hardware initialization |
lypinator | 0:bb348c97df44 | 167 | * |
lypinator | 0:bb348c97df44 | 168 | * @note SysTick is used as time base for the HAL_Delay() function, the application |
lypinator | 0:bb348c97df44 | 169 | * need to ensure that the SysTick time base is always set to 1 millisecond |
lypinator | 0:bb348c97df44 | 170 | * to have correct HAL operation. |
lypinator | 0:bb348c97df44 | 171 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 172 | */ |
lypinator | 0:bb348c97df44 | 173 | HAL_StatusTypeDef HAL_Init(void) |
lypinator | 0:bb348c97df44 | 174 | { |
lypinator | 0:bb348c97df44 | 175 | /* Configure Flash prefetch, Instruction cache, Data cache */ |
lypinator | 0:bb348c97df44 | 176 | #if (INSTRUCTION_CACHE_ENABLE != 0U) |
lypinator | 0:bb348c97df44 | 177 | __HAL_FLASH_INSTRUCTION_CACHE_ENABLE(); |
lypinator | 0:bb348c97df44 | 178 | #endif /* INSTRUCTION_CACHE_ENABLE */ |
lypinator | 0:bb348c97df44 | 179 | |
lypinator | 0:bb348c97df44 | 180 | #if (DATA_CACHE_ENABLE != 0U) |
lypinator | 0:bb348c97df44 | 181 | __HAL_FLASH_DATA_CACHE_ENABLE(); |
lypinator | 0:bb348c97df44 | 182 | #endif /* DATA_CACHE_ENABLE */ |
lypinator | 0:bb348c97df44 | 183 | |
lypinator | 0:bb348c97df44 | 184 | #if (PREFETCH_ENABLE != 0U) |
lypinator | 0:bb348c97df44 | 185 | __HAL_FLASH_PREFETCH_BUFFER_ENABLE(); |
lypinator | 0:bb348c97df44 | 186 | #endif /* PREFETCH_ENABLE */ |
lypinator | 0:bb348c97df44 | 187 | |
lypinator | 0:bb348c97df44 | 188 | /* Set Interrupt Group Priority */ |
lypinator | 0:bb348c97df44 | 189 | /* MBED : moved to HAL_InitPre() */ |
lypinator | 0:bb348c97df44 | 190 | #if !defined (TARGET_STM32F429xI) |
lypinator | 0:bb348c97df44 | 191 | HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); |
lypinator | 0:bb348c97df44 | 192 | #endif |
lypinator | 0:bb348c97df44 | 193 | |
lypinator | 0:bb348c97df44 | 194 | /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ |
lypinator | 0:bb348c97df44 | 195 | HAL_InitTick(TICK_INT_PRIORITY); |
lypinator | 0:bb348c97df44 | 196 | |
lypinator | 0:bb348c97df44 | 197 | /* Init the low level hardware */ |
lypinator | 0:bb348c97df44 | 198 | HAL_MspInit(); |
lypinator | 0:bb348c97df44 | 199 | |
lypinator | 0:bb348c97df44 | 200 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 201 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 202 | } |
lypinator | 0:bb348c97df44 | 203 | |
lypinator | 0:bb348c97df44 | 204 | /** |
lypinator | 0:bb348c97df44 | 205 | * @brief This function de-Initializes common part of the HAL and stops the systick. |
lypinator | 0:bb348c97df44 | 206 | * This function is optional. |
lypinator | 0:bb348c97df44 | 207 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 208 | */ |
lypinator | 0:bb348c97df44 | 209 | HAL_StatusTypeDef HAL_DeInit(void) |
lypinator | 0:bb348c97df44 | 210 | { |
lypinator | 0:bb348c97df44 | 211 | /* Reset of all peripherals */ |
lypinator | 0:bb348c97df44 | 212 | __HAL_RCC_APB1_FORCE_RESET(); |
lypinator | 0:bb348c97df44 | 213 | __HAL_RCC_APB1_RELEASE_RESET(); |
lypinator | 0:bb348c97df44 | 214 | |
lypinator | 0:bb348c97df44 | 215 | __HAL_RCC_APB2_FORCE_RESET(); |
lypinator | 0:bb348c97df44 | 216 | __HAL_RCC_APB2_RELEASE_RESET(); |
lypinator | 0:bb348c97df44 | 217 | |
lypinator | 0:bb348c97df44 | 218 | __HAL_RCC_AHB1_FORCE_RESET(); |
lypinator | 0:bb348c97df44 | 219 | __HAL_RCC_AHB1_RELEASE_RESET(); |
lypinator | 0:bb348c97df44 | 220 | |
lypinator | 0:bb348c97df44 | 221 | __HAL_RCC_AHB2_FORCE_RESET(); |
lypinator | 0:bb348c97df44 | 222 | __HAL_RCC_AHB2_RELEASE_RESET(); |
lypinator | 0:bb348c97df44 | 223 | |
lypinator | 0:bb348c97df44 | 224 | __HAL_RCC_AHB3_FORCE_RESET(); |
lypinator | 0:bb348c97df44 | 225 | __HAL_RCC_AHB3_RELEASE_RESET(); |
lypinator | 0:bb348c97df44 | 226 | |
lypinator | 0:bb348c97df44 | 227 | /* De-Init the low level hardware */ |
lypinator | 0:bb348c97df44 | 228 | HAL_MspDeInit(); |
lypinator | 0:bb348c97df44 | 229 | |
lypinator | 0:bb348c97df44 | 230 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 231 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 232 | } |
lypinator | 0:bb348c97df44 | 233 | |
lypinator | 0:bb348c97df44 | 234 | /** |
lypinator | 0:bb348c97df44 | 235 | * @brief Initialize the MSP. |
lypinator | 0:bb348c97df44 | 236 | * @retval None |
lypinator | 0:bb348c97df44 | 237 | */ |
lypinator | 0:bb348c97df44 | 238 | __weak void HAL_MspInit(void) |
lypinator | 0:bb348c97df44 | 239 | { |
lypinator | 0:bb348c97df44 | 240 | /* NOTE : This function should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 241 | the HAL_MspInit could be implemented in the user file |
lypinator | 0:bb348c97df44 | 242 | */ |
lypinator | 0:bb348c97df44 | 243 | } |
lypinator | 0:bb348c97df44 | 244 | |
lypinator | 0:bb348c97df44 | 245 | /** |
lypinator | 0:bb348c97df44 | 246 | * @brief DeInitializes the MSP. |
lypinator | 0:bb348c97df44 | 247 | * @retval None |
lypinator | 0:bb348c97df44 | 248 | */ |
lypinator | 0:bb348c97df44 | 249 | __weak void HAL_MspDeInit(void) |
lypinator | 0:bb348c97df44 | 250 | { |
lypinator | 0:bb348c97df44 | 251 | /* NOTE : This function should not be modified, when the callback is needed, |
lypinator | 0:bb348c97df44 | 252 | the HAL_MspDeInit could be implemented in the user file |
lypinator | 0:bb348c97df44 | 253 | */ |
lypinator | 0:bb348c97df44 | 254 | } |
lypinator | 0:bb348c97df44 | 255 | |
lypinator | 0:bb348c97df44 | 256 | /** |
lypinator | 0:bb348c97df44 | 257 | * @brief This function configures the source of the time base. |
lypinator | 0:bb348c97df44 | 258 | * The time source is configured to have 1ms time base with a dedicated |
lypinator | 0:bb348c97df44 | 259 | * Tick interrupt priority. |
lypinator | 0:bb348c97df44 | 260 | * @note This function is called automatically at the beginning of program after |
lypinator | 0:bb348c97df44 | 261 | * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). |
lypinator | 0:bb348c97df44 | 262 | * @note In the default implementation, SysTick timer is the source of time base. |
lypinator | 0:bb348c97df44 | 263 | * It is used to generate interrupts at regular time intervals. |
lypinator | 0:bb348c97df44 | 264 | * Care must be taken if HAL_Delay() is called from a peripheral ISR process, |
lypinator | 0:bb348c97df44 | 265 | * The SysTick interrupt must have higher priority (numerically lower) |
lypinator | 0:bb348c97df44 | 266 | * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. |
lypinator | 0:bb348c97df44 | 267 | * The function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 268 | * implementation in user file. |
lypinator | 0:bb348c97df44 | 269 | * @param TickPriority Tick interrupt priority. |
lypinator | 0:bb348c97df44 | 270 | * @retval HAL status |
lypinator | 0:bb348c97df44 | 271 | */ |
lypinator | 0:bb348c97df44 | 272 | __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) |
lypinator | 0:bb348c97df44 | 273 | { |
lypinator | 0:bb348c97df44 | 274 | /* Configure the SysTick to have interrupt in 1ms time basis*/ |
lypinator | 0:bb348c97df44 | 275 | if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) > 0U) |
lypinator | 0:bb348c97df44 | 276 | { |
lypinator | 0:bb348c97df44 | 277 | return HAL_ERROR; |
lypinator | 0:bb348c97df44 | 278 | } |
lypinator | 0:bb348c97df44 | 279 | |
lypinator | 0:bb348c97df44 | 280 | /* Configure the SysTick IRQ priority */ |
lypinator | 0:bb348c97df44 | 281 | if (TickPriority < (1UL << __NVIC_PRIO_BITS)) |
lypinator | 0:bb348c97df44 | 282 | { |
lypinator | 0:bb348c97df44 | 283 | HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U); |
lypinator | 0:bb348c97df44 | 284 | uwTickPrio = TickPriority; |
lypinator | 0:bb348c97df44 | 285 | } |
lypinator | 0:bb348c97df44 | 286 | else |
lypinator | 0:bb348c97df44 | 287 | { |
lypinator | 0:bb348c97df44 | 288 | return HAL_ERROR; |
lypinator | 0:bb348c97df44 | 289 | } |
lypinator | 0:bb348c97df44 | 290 | |
lypinator | 0:bb348c97df44 | 291 | /* Return function status */ |
lypinator | 0:bb348c97df44 | 292 | return HAL_OK; |
lypinator | 0:bb348c97df44 | 293 | } |
lypinator | 0:bb348c97df44 | 294 | |
lypinator | 0:bb348c97df44 | 295 | /** |
lypinator | 0:bb348c97df44 | 296 | * @} |
lypinator | 0:bb348c97df44 | 297 | */ |
lypinator | 0:bb348c97df44 | 298 | |
lypinator | 0:bb348c97df44 | 299 | /** @defgroup HAL_Exported_Functions_Group2 HAL Control functions |
lypinator | 0:bb348c97df44 | 300 | * @brief HAL Control functions |
lypinator | 0:bb348c97df44 | 301 | * |
lypinator | 0:bb348c97df44 | 302 | @verbatim |
lypinator | 0:bb348c97df44 | 303 | =============================================================================== |
lypinator | 0:bb348c97df44 | 304 | ##### HAL Control functions ##### |
lypinator | 0:bb348c97df44 | 305 | =============================================================================== |
lypinator | 0:bb348c97df44 | 306 | [..] This section provides functions allowing to: |
lypinator | 0:bb348c97df44 | 307 | (+) Provide a tick value in millisecond |
lypinator | 0:bb348c97df44 | 308 | (+) Provide a blocking delay in millisecond |
lypinator | 0:bb348c97df44 | 309 | (+) Suspend the time base source interrupt |
lypinator | 0:bb348c97df44 | 310 | (+) Resume the time base source interrupt |
lypinator | 0:bb348c97df44 | 311 | (+) Get the HAL API driver version |
lypinator | 0:bb348c97df44 | 312 | (+) Get the device identifier |
lypinator | 0:bb348c97df44 | 313 | (+) Get the device revision identifier |
lypinator | 0:bb348c97df44 | 314 | (+) Enable/Disable Debug module during SLEEP mode |
lypinator | 0:bb348c97df44 | 315 | (+) Enable/Disable Debug module during STOP mode |
lypinator | 0:bb348c97df44 | 316 | (+) Enable/Disable Debug module during STANDBY mode |
lypinator | 0:bb348c97df44 | 317 | |
lypinator | 0:bb348c97df44 | 318 | @endverbatim |
lypinator | 0:bb348c97df44 | 319 | * @{ |
lypinator | 0:bb348c97df44 | 320 | */ |
lypinator | 0:bb348c97df44 | 321 | |
lypinator | 0:bb348c97df44 | 322 | /** |
lypinator | 0:bb348c97df44 | 323 | * @brief This function is called to increment a global variable "uwTick" |
lypinator | 0:bb348c97df44 | 324 | * used as application time base. |
lypinator | 0:bb348c97df44 | 325 | * @note In the default implementation, this variable is incremented each 1ms |
lypinator | 0:bb348c97df44 | 326 | * in SysTick ISR. |
lypinator | 0:bb348c97df44 | 327 | * @note This function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 328 | * implementations in user file. |
lypinator | 0:bb348c97df44 | 329 | * @retval None |
lypinator | 0:bb348c97df44 | 330 | */ |
lypinator | 0:bb348c97df44 | 331 | __weak void HAL_IncTick(void) |
lypinator | 0:bb348c97df44 | 332 | { |
lypinator | 0:bb348c97df44 | 333 | uwTick += uwTickFreq; |
lypinator | 0:bb348c97df44 | 334 | } |
lypinator | 0:bb348c97df44 | 335 | |
lypinator | 0:bb348c97df44 | 336 | /** |
lypinator | 0:bb348c97df44 | 337 | * @brief Provides a tick value in millisecond. |
lypinator | 0:bb348c97df44 | 338 | * @note This function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 339 | * implementations in user file. |
lypinator | 0:bb348c97df44 | 340 | * @retval tick value |
lypinator | 0:bb348c97df44 | 341 | */ |
lypinator | 0:bb348c97df44 | 342 | __weak uint32_t HAL_GetTick(void) |
lypinator | 0:bb348c97df44 | 343 | { |
lypinator | 0:bb348c97df44 | 344 | return uwTick; |
lypinator | 0:bb348c97df44 | 345 | } |
lypinator | 0:bb348c97df44 | 346 | |
lypinator | 0:bb348c97df44 | 347 | /** |
lypinator | 0:bb348c97df44 | 348 | * @brief This function returns a tick priority. |
lypinator | 0:bb348c97df44 | 349 | * @retval tick priority |
lypinator | 0:bb348c97df44 | 350 | */ |
lypinator | 0:bb348c97df44 | 351 | uint32_t HAL_GetTickPrio(void) |
lypinator | 0:bb348c97df44 | 352 | { |
lypinator | 0:bb348c97df44 | 353 | return uwTickPrio; |
lypinator | 0:bb348c97df44 | 354 | } |
lypinator | 0:bb348c97df44 | 355 | |
lypinator | 0:bb348c97df44 | 356 | /** |
lypinator | 0:bb348c97df44 | 357 | * @brief Set new tick Freq. |
lypinator | 0:bb348c97df44 | 358 | * @retval Status |
lypinator | 0:bb348c97df44 | 359 | */ |
lypinator | 0:bb348c97df44 | 360 | HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq) |
lypinator | 0:bb348c97df44 | 361 | { |
lypinator | 0:bb348c97df44 | 362 | HAL_StatusTypeDef status = HAL_OK; |
lypinator | 0:bb348c97df44 | 363 | assert_param(IS_TICKFREQ(Freq)); |
lypinator | 0:bb348c97df44 | 364 | |
lypinator | 0:bb348c97df44 | 365 | if (uwTickFreq != Freq) |
lypinator | 0:bb348c97df44 | 366 | { |
lypinator | 0:bb348c97df44 | 367 | uwTickFreq = Freq; |
lypinator | 0:bb348c97df44 | 368 | |
lypinator | 0:bb348c97df44 | 369 | /* Apply the new tick Freq */ |
lypinator | 0:bb348c97df44 | 370 | status = HAL_InitTick(uwTickPrio); |
lypinator | 0:bb348c97df44 | 371 | } |
lypinator | 0:bb348c97df44 | 372 | |
lypinator | 0:bb348c97df44 | 373 | return status; |
lypinator | 0:bb348c97df44 | 374 | } |
lypinator | 0:bb348c97df44 | 375 | |
lypinator | 0:bb348c97df44 | 376 | /** |
lypinator | 0:bb348c97df44 | 377 | * @brief Return tick frequency. |
lypinator | 0:bb348c97df44 | 378 | * @retval tick period in Hz |
lypinator | 0:bb348c97df44 | 379 | */ |
lypinator | 0:bb348c97df44 | 380 | HAL_TickFreqTypeDef HAL_GetTickFreq(void) |
lypinator | 0:bb348c97df44 | 381 | { |
lypinator | 0:bb348c97df44 | 382 | return uwTickFreq; |
lypinator | 0:bb348c97df44 | 383 | } |
lypinator | 0:bb348c97df44 | 384 | |
lypinator | 0:bb348c97df44 | 385 | /** |
lypinator | 0:bb348c97df44 | 386 | * @brief This function provides minimum delay (in milliseconds) based |
lypinator | 0:bb348c97df44 | 387 | * on variable incremented. |
lypinator | 0:bb348c97df44 | 388 | * @note In the default implementation , SysTick timer is the source of time base. |
lypinator | 0:bb348c97df44 | 389 | * It is used to generate interrupts at regular time intervals where uwTick |
lypinator | 0:bb348c97df44 | 390 | * is incremented. |
lypinator | 0:bb348c97df44 | 391 | * @note This function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 392 | * implementations in user file. |
lypinator | 0:bb348c97df44 | 393 | * @param Delay specifies the delay time length, in milliseconds. |
lypinator | 0:bb348c97df44 | 394 | * @retval None |
lypinator | 0:bb348c97df44 | 395 | */ |
lypinator | 0:bb348c97df44 | 396 | __weak void HAL_Delay(uint32_t Delay) |
lypinator | 0:bb348c97df44 | 397 | { |
lypinator | 0:bb348c97df44 | 398 | uint32_t tickstart = HAL_GetTick(); |
lypinator | 0:bb348c97df44 | 399 | uint32_t wait = Delay; |
lypinator | 0:bb348c97df44 | 400 | |
lypinator | 0:bb348c97df44 | 401 | /* Add a freq to guarantee minimum wait */ |
lypinator | 0:bb348c97df44 | 402 | if (wait < HAL_MAX_DELAY) |
lypinator | 0:bb348c97df44 | 403 | { |
lypinator | 0:bb348c97df44 | 404 | wait += (uint32_t)(uwTickFreq); |
lypinator | 0:bb348c97df44 | 405 | } |
lypinator | 0:bb348c97df44 | 406 | |
lypinator | 0:bb348c97df44 | 407 | while((HAL_GetTick() - tickstart) < wait) |
lypinator | 0:bb348c97df44 | 408 | { |
lypinator | 0:bb348c97df44 | 409 | } |
lypinator | 0:bb348c97df44 | 410 | } |
lypinator | 0:bb348c97df44 | 411 | |
lypinator | 0:bb348c97df44 | 412 | /** |
lypinator | 0:bb348c97df44 | 413 | * @brief Suspend Tick increment. |
lypinator | 0:bb348c97df44 | 414 | * @note In the default implementation , SysTick timer is the source of time base. It is |
lypinator | 0:bb348c97df44 | 415 | * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() |
lypinator | 0:bb348c97df44 | 416 | * is called, the SysTick interrupt will be disabled and so Tick increment |
lypinator | 0:bb348c97df44 | 417 | * is suspended. |
lypinator | 0:bb348c97df44 | 418 | * @note This function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 419 | * implementations in user file. |
lypinator | 0:bb348c97df44 | 420 | * @retval None |
lypinator | 0:bb348c97df44 | 421 | */ |
lypinator | 0:bb348c97df44 | 422 | __weak void HAL_SuspendTick(void) |
lypinator | 0:bb348c97df44 | 423 | { |
lypinator | 0:bb348c97df44 | 424 | /* Disable SysTick Interrupt */ |
lypinator | 0:bb348c97df44 | 425 | SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; |
lypinator | 0:bb348c97df44 | 426 | } |
lypinator | 0:bb348c97df44 | 427 | |
lypinator | 0:bb348c97df44 | 428 | /** |
lypinator | 0:bb348c97df44 | 429 | * @brief Resume Tick increment. |
lypinator | 0:bb348c97df44 | 430 | * @note In the default implementation , SysTick timer is the source of time base. It is |
lypinator | 0:bb348c97df44 | 431 | * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() |
lypinator | 0:bb348c97df44 | 432 | * is called, the SysTick interrupt will be enabled and so Tick increment |
lypinator | 0:bb348c97df44 | 433 | * is resumed. |
lypinator | 0:bb348c97df44 | 434 | * @note This function is declared as __weak to be overwritten in case of other |
lypinator | 0:bb348c97df44 | 435 | * implementations in user file. |
lypinator | 0:bb348c97df44 | 436 | * @retval None |
lypinator | 0:bb348c97df44 | 437 | */ |
lypinator | 0:bb348c97df44 | 438 | __weak void HAL_ResumeTick(void) |
lypinator | 0:bb348c97df44 | 439 | { |
lypinator | 0:bb348c97df44 | 440 | /* Enable SysTick Interrupt */ |
lypinator | 0:bb348c97df44 | 441 | SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; |
lypinator | 0:bb348c97df44 | 442 | } |
lypinator | 0:bb348c97df44 | 443 | |
lypinator | 0:bb348c97df44 | 444 | /** |
lypinator | 0:bb348c97df44 | 445 | * @brief Returns the HAL revision |
lypinator | 0:bb348c97df44 | 446 | * @retval version : 0xXYZR (8bits for each decimal, R for RC) |
lypinator | 0:bb348c97df44 | 447 | */ |
lypinator | 0:bb348c97df44 | 448 | uint32_t HAL_GetHalVersion(void) |
lypinator | 0:bb348c97df44 | 449 | { |
lypinator | 0:bb348c97df44 | 450 | return __STM32F4xx_HAL_VERSION; |
lypinator | 0:bb348c97df44 | 451 | } |
lypinator | 0:bb348c97df44 | 452 | |
lypinator | 0:bb348c97df44 | 453 | /** |
lypinator | 0:bb348c97df44 | 454 | * @brief Returns the device revision identifier. |
lypinator | 0:bb348c97df44 | 455 | * @retval Device revision identifier |
lypinator | 0:bb348c97df44 | 456 | */ |
lypinator | 0:bb348c97df44 | 457 | uint32_t HAL_GetREVID(void) |
lypinator | 0:bb348c97df44 | 458 | { |
lypinator | 0:bb348c97df44 | 459 | return((DBGMCU->IDCODE) >> 16U); |
lypinator | 0:bb348c97df44 | 460 | } |
lypinator | 0:bb348c97df44 | 461 | |
lypinator | 0:bb348c97df44 | 462 | /** |
lypinator | 0:bb348c97df44 | 463 | * @brief Returns the device identifier. |
lypinator | 0:bb348c97df44 | 464 | * @retval Device identifier |
lypinator | 0:bb348c97df44 | 465 | */ |
lypinator | 0:bb348c97df44 | 466 | uint32_t HAL_GetDEVID(void) |
lypinator | 0:bb348c97df44 | 467 | { |
lypinator | 0:bb348c97df44 | 468 | return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK); |
lypinator | 0:bb348c97df44 | 469 | } |
lypinator | 0:bb348c97df44 | 470 | |
lypinator | 0:bb348c97df44 | 471 | /** |
lypinator | 0:bb348c97df44 | 472 | * @brief Enable the Debug Module during SLEEP mode |
lypinator | 0:bb348c97df44 | 473 | * @retval None |
lypinator | 0:bb348c97df44 | 474 | */ |
lypinator | 0:bb348c97df44 | 475 | void HAL_DBGMCU_EnableDBGSleepMode(void) |
lypinator | 0:bb348c97df44 | 476 | { |
lypinator | 0:bb348c97df44 | 477 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); |
lypinator | 0:bb348c97df44 | 478 | } |
lypinator | 0:bb348c97df44 | 479 | |
lypinator | 0:bb348c97df44 | 480 | /** |
lypinator | 0:bb348c97df44 | 481 | * @brief Disable the Debug Module during SLEEP mode |
lypinator | 0:bb348c97df44 | 482 | * @retval None |
lypinator | 0:bb348c97df44 | 483 | */ |
lypinator | 0:bb348c97df44 | 484 | void HAL_DBGMCU_DisableDBGSleepMode(void) |
lypinator | 0:bb348c97df44 | 485 | { |
lypinator | 0:bb348c97df44 | 486 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP); |
lypinator | 0:bb348c97df44 | 487 | } |
lypinator | 0:bb348c97df44 | 488 | |
lypinator | 0:bb348c97df44 | 489 | /** |
lypinator | 0:bb348c97df44 | 490 | * @brief Enable the Debug Module during STOP mode |
lypinator | 0:bb348c97df44 | 491 | * @retval None |
lypinator | 0:bb348c97df44 | 492 | */ |
lypinator | 0:bb348c97df44 | 493 | void HAL_DBGMCU_EnableDBGStopMode(void) |
lypinator | 0:bb348c97df44 | 494 | { |
lypinator | 0:bb348c97df44 | 495 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); |
lypinator | 0:bb348c97df44 | 496 | } |
lypinator | 0:bb348c97df44 | 497 | |
lypinator | 0:bb348c97df44 | 498 | /** |
lypinator | 0:bb348c97df44 | 499 | * @brief Disable the Debug Module during STOP mode |
lypinator | 0:bb348c97df44 | 500 | * @retval None |
lypinator | 0:bb348c97df44 | 501 | */ |
lypinator | 0:bb348c97df44 | 502 | void HAL_DBGMCU_DisableDBGStopMode(void) |
lypinator | 0:bb348c97df44 | 503 | { |
lypinator | 0:bb348c97df44 | 504 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP); |
lypinator | 0:bb348c97df44 | 505 | } |
lypinator | 0:bb348c97df44 | 506 | |
lypinator | 0:bb348c97df44 | 507 | /** |
lypinator | 0:bb348c97df44 | 508 | * @brief Enable the Debug Module during STANDBY mode |
lypinator | 0:bb348c97df44 | 509 | * @retval None |
lypinator | 0:bb348c97df44 | 510 | */ |
lypinator | 0:bb348c97df44 | 511 | void HAL_DBGMCU_EnableDBGStandbyMode(void) |
lypinator | 0:bb348c97df44 | 512 | { |
lypinator | 0:bb348c97df44 | 513 | SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); |
lypinator | 0:bb348c97df44 | 514 | } |
lypinator | 0:bb348c97df44 | 515 | |
lypinator | 0:bb348c97df44 | 516 | /** |
lypinator | 0:bb348c97df44 | 517 | * @brief Disable the Debug Module during STANDBY mode |
lypinator | 0:bb348c97df44 | 518 | * @retval None |
lypinator | 0:bb348c97df44 | 519 | */ |
lypinator | 0:bb348c97df44 | 520 | void HAL_DBGMCU_DisableDBGStandbyMode(void) |
lypinator | 0:bb348c97df44 | 521 | { |
lypinator | 0:bb348c97df44 | 522 | CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY); |
lypinator | 0:bb348c97df44 | 523 | } |
lypinator | 0:bb348c97df44 | 524 | |
lypinator | 0:bb348c97df44 | 525 | /** |
lypinator | 0:bb348c97df44 | 526 | * @brief Enables the I/O Compensation Cell. |
lypinator | 0:bb348c97df44 | 527 | * @note The I/O compensation cell can be used only when the device supply |
lypinator | 0:bb348c97df44 | 528 | * voltage ranges from 2.4 to 3.6 V. |
lypinator | 0:bb348c97df44 | 529 | * @retval None |
lypinator | 0:bb348c97df44 | 530 | */ |
lypinator | 0:bb348c97df44 | 531 | void HAL_EnableCompensationCell(void) |
lypinator | 0:bb348c97df44 | 532 | { |
lypinator | 0:bb348c97df44 | 533 | *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)ENABLE; |
lypinator | 0:bb348c97df44 | 534 | } |
lypinator | 0:bb348c97df44 | 535 | |
lypinator | 0:bb348c97df44 | 536 | /** |
lypinator | 0:bb348c97df44 | 537 | * @brief Power-down the I/O Compensation Cell. |
lypinator | 0:bb348c97df44 | 538 | * @note The I/O compensation cell can be used only when the device supply |
lypinator | 0:bb348c97df44 | 539 | * voltage ranges from 2.4 to 3.6 V. |
lypinator | 0:bb348c97df44 | 540 | * @retval None |
lypinator | 0:bb348c97df44 | 541 | */ |
lypinator | 0:bb348c97df44 | 542 | void HAL_DisableCompensationCell(void) |
lypinator | 0:bb348c97df44 | 543 | { |
lypinator | 0:bb348c97df44 | 544 | *(__IO uint32_t *)CMPCR_CMP_PD_BB = (uint32_t)DISABLE; |
lypinator | 0:bb348c97df44 | 545 | } |
lypinator | 0:bb348c97df44 | 546 | |
lypinator | 0:bb348c97df44 | 547 | /** |
lypinator | 0:bb348c97df44 | 548 | * @brief Return the unique device identifier (UID based on 96 bits) |
lypinator | 0:bb348c97df44 | 549 | * @param UID pointer to 3 words array. |
lypinator | 0:bb348c97df44 | 550 | * @retval Device identifier |
lypinator | 0:bb348c97df44 | 551 | */ |
lypinator | 0:bb348c97df44 | 552 | void HAL_GetUID(uint32_t *UID) |
lypinator | 0:bb348c97df44 | 553 | { |
lypinator | 0:bb348c97df44 | 554 | UID[0] = (uint32_t)(READ_REG(*((uint32_t *)UID_BASE))); |
lypinator | 0:bb348c97df44 | 555 | UID[1] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); |
lypinator | 0:bb348c97df44 | 556 | UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); |
lypinator | 0:bb348c97df44 | 557 | } |
lypinator | 0:bb348c97df44 | 558 | |
lypinator | 0:bb348c97df44 | 559 | #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ |
lypinator | 0:bb348c97df44 | 560 | defined(STM32F469xx) || defined(STM32F479xx) |
lypinator | 0:bb348c97df44 | 561 | /** |
lypinator | 0:bb348c97df44 | 562 | * @brief Enables the Internal FLASH Bank Swapping. |
lypinator | 0:bb348c97df44 | 563 | * |
lypinator | 0:bb348c97df44 | 564 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
lypinator | 0:bb348c97df44 | 565 | * |
lypinator | 0:bb348c97df44 | 566 | * @note Flash Bank2 mapped at 0x08000000 (and aliased @0x00000000) |
lypinator | 0:bb348c97df44 | 567 | * and Flash Bank1 mapped at 0x08100000 (and aliased at 0x00100000) |
lypinator | 0:bb348c97df44 | 568 | * |
lypinator | 0:bb348c97df44 | 569 | * @retval None |
lypinator | 0:bb348c97df44 | 570 | */ |
lypinator | 0:bb348c97df44 | 571 | void HAL_EnableMemorySwappingBank(void) |
lypinator | 0:bb348c97df44 | 572 | { |
lypinator | 0:bb348c97df44 | 573 | *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)ENABLE; |
lypinator | 0:bb348c97df44 | 574 | } |
lypinator | 0:bb348c97df44 | 575 | |
lypinator | 0:bb348c97df44 | 576 | /** |
lypinator | 0:bb348c97df44 | 577 | * @brief Disables the Internal FLASH Bank Swapping. |
lypinator | 0:bb348c97df44 | 578 | * |
lypinator | 0:bb348c97df44 | 579 | * @note This function can be used only for STM32F42xxx/43xxx devices. |
lypinator | 0:bb348c97df44 | 580 | * |
lypinator | 0:bb348c97df44 | 581 | * @note The default state : Flash Bank1 mapped at 0x08000000 (and aliased @0x00000000) |
lypinator | 0:bb348c97df44 | 582 | * and Flash Bank2 mapped at 0x08100000 (and aliased at 0x00100000) |
lypinator | 0:bb348c97df44 | 583 | * |
lypinator | 0:bb348c97df44 | 584 | * @retval None |
lypinator | 0:bb348c97df44 | 585 | */ |
lypinator | 0:bb348c97df44 | 586 | void HAL_DisableMemorySwappingBank(void) |
lypinator | 0:bb348c97df44 | 587 | { |
lypinator | 0:bb348c97df44 | 588 | *(__IO uint32_t *)UFB_MODE_BB = (uint32_t)DISABLE; |
lypinator | 0:bb348c97df44 | 589 | } |
lypinator | 0:bb348c97df44 | 590 | #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ |
lypinator | 0:bb348c97df44 | 591 | /** |
lypinator | 0:bb348c97df44 | 592 | * @} |
lypinator | 0:bb348c97df44 | 593 | */ |
lypinator | 0:bb348c97df44 | 594 | |
lypinator | 0:bb348c97df44 | 595 | /** |
lypinator | 0:bb348c97df44 | 596 | * @} |
lypinator | 0:bb348c97df44 | 597 | */ |
lypinator | 0:bb348c97df44 | 598 | |
lypinator | 0:bb348c97df44 | 599 | /** |
lypinator | 0:bb348c97df44 | 600 | * @} |
lypinator | 0:bb348c97df44 | 601 | */ |
lypinator | 0:bb348c97df44 | 602 | |
lypinator | 0:bb348c97df44 | 603 | /** |
lypinator | 0:bb348c97df44 | 604 | * @} |
lypinator | 0:bb348c97df44 | 605 | */ |
lypinator | 0:bb348c97df44 | 606 | |
lypinator | 0:bb348c97df44 | 607 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |