mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Mon Sep 28 20:15:09 2015 +0100
Revision:
634:ac7d6880524d
Parent:
632:7687fb9c4f91
Synchronized with git revision 9b7d23d47153c298a6d24de9a415202705889d11

Full URL: https://github.com/mbedmicro/mbed/commit/9b7d23d47153c298a6d24de9a415202705889d11/

Revert "[NUCLEO_F303K8] add support of the STM32F303K8"

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 237:f3da66175598 1 /**
mbed_official 237:f3da66175598 2 ******************************************************************************
mbed_official 237:f3da66175598 3 * @file stm32f3xx_hal_flash.c
mbed_official 237:f3da66175598 4 * @author MCD Application Team
mbed_official 634:ac7d6880524d 5 * @version V1.1.0
mbed_official 634:ac7d6880524d 6 * @date 12-Sept-2014
mbed_official 237:f3da66175598 7 * @brief FLASH HAL module driver.
mbed_official 237:f3da66175598 8 *
mbed_official 237:f3da66175598 9 * This file provides firmware functions to manage the following
mbed_official 237:f3da66175598 10 * functionalities of the internal FLASH memory:
mbed_official 237:f3da66175598 11 * + Program operations functions
mbed_official 237:f3da66175598 12 * + Memory Control functions
mbed_official 237:f3da66175598 13 * + Peripheral State functions
mbed_official 237:f3da66175598 14 *
mbed_official 237:f3da66175598 15 @verbatim
mbed_official 237:f3da66175598 16 ==============================================================================
mbed_official 237:f3da66175598 17 ##### FLASH peripheral features #####
mbed_official 237:f3da66175598 18 ==============================================================================
mbed_official 237:f3da66175598 19
mbed_official 237:f3da66175598 20 [..] The Flash memory interface manages CPU AHB I-Code and D-Code accesses
mbed_official 237:f3da66175598 21 to the Flash memory. It implements the erase and program Flash memory operations
mbed_official 237:f3da66175598 22 and the read and write protection mechanisms.
mbed_official 237:f3da66175598 23
mbed_official 237:f3da66175598 24 [..] The Flash memory interface accelerates code execution with a system of instruction
mbed_official 237:f3da66175598 25 prefetch.
mbed_official 237:f3da66175598 26
mbed_official 237:f3da66175598 27 [..] The FLASH main features are:
mbed_official 237:f3da66175598 28 (+) Flash memory read operations
mbed_official 237:f3da66175598 29 (+) Flash memory program/erase operations
mbed_official 237:f3da66175598 30 (+) Read / write protections
mbed_official 237:f3da66175598 31 (+) Prefetch on I-Code
mbed_official 237:f3da66175598 32
mbed_official 237:f3da66175598 33
mbed_official 237:f3da66175598 34 ##### How to use this driver #####
mbed_official 237:f3da66175598 35 ==============================================================================
mbed_official 237:f3da66175598 36 [..]
mbed_official 237:f3da66175598 37 This driver provides functions and macros to configure and program the FLASH
mbed_official 237:f3da66175598 38 memory of all STM32F3xx devices. These functions are split in 3 groups:
mbed_official 237:f3da66175598 39
mbed_official 237:f3da66175598 40 (#) FLASH Memory I/O Programming functions: this group includes all needed
mbed_official 237:f3da66175598 41 functions to erase and program the main memory:
mbed_official 237:f3da66175598 42 (++) Lock and Unlock the FLASH interface
mbed_official 237:f3da66175598 43 (++) Erase function: Erase page, erase all pages
mbed_official 237:f3da66175598 44 (++) Program functions: half word and word
mbed_official 237:f3da66175598 45
mbed_official 237:f3da66175598 46 (#) Option Bytes Programming functions: this group includes all needed
mbed_official 237:f3da66175598 47 functions to manage the Option Bytes:
mbed_official 237:f3da66175598 48 (++) Lock and Unlock the Option Bytes
mbed_official 237:f3da66175598 49 (++) Erase Option Bytes
mbed_official 237:f3da66175598 50 (++) Set/Reset the write protection
mbed_official 237:f3da66175598 51 (++) Set the Read protection Level
mbed_official 237:f3da66175598 52 (++) Program the user Option Bytes
mbed_official 237:f3da66175598 53 (++) Program the data Option Bytes
mbed_official 237:f3da66175598 54 (++) Launch the Option Bytes loader
mbed_official 237:f3da66175598 55
mbed_official 237:f3da66175598 56 (#) Interrupts and flags management functions : this group
mbed_official 237:f3da66175598 57 includes all needed functions to:
mbed_official 237:f3da66175598 58 (++) Handle FLASH interrupts
mbed_official 237:f3da66175598 59 (++) Wait for last FLASH operation according to its status
mbed_official 237:f3da66175598 60 (++) Get error flag status
mbed_official 237:f3da66175598 61
mbed_official 237:f3da66175598 62 [..] In addition to these function, this driver includes a set of macros allowing
mbed_official 237:f3da66175598 63 to handle the following operations:
mbed_official 237:f3da66175598 64
mbed_official 237:f3da66175598 65 (+) Set the latency
mbed_official 237:f3da66175598 66 (+) Enable/Disable the prefetch buffer
mbed_official 237:f3da66175598 67 (+) Enable/Disable the half cycle access
mbed_official 237:f3da66175598 68 (+) Enable/Disable the FLASH interrupts
mbed_official 237:f3da66175598 69 (+) Monitor the FLASH flags status
mbed_official 237:f3da66175598 70
mbed_official 237:f3da66175598 71 @endverbatim
mbed_official 237:f3da66175598 72 ******************************************************************************
mbed_official 237:f3da66175598 73 * @attention
mbed_official 237:f3da66175598 74 *
mbed_official 634:ac7d6880524d 75 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 237:f3da66175598 76 *
mbed_official 237:f3da66175598 77 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 237:f3da66175598 78 * are permitted provided that the following conditions are met:
mbed_official 237:f3da66175598 79 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 237:f3da66175598 80 * this list of conditions and the following disclaimer.
mbed_official 237:f3da66175598 81 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 237:f3da66175598 82 * this list of conditions and the following disclaimer in the documentation
mbed_official 237:f3da66175598 83 * and/or other materials provided with the distribution.
mbed_official 237:f3da66175598 84 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 237:f3da66175598 85 * may be used to endorse or promote products derived from this software
mbed_official 237:f3da66175598 86 * without specific prior written permission.
mbed_official 237:f3da66175598 87 *
mbed_official 237:f3da66175598 88 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 237:f3da66175598 89 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 237:f3da66175598 90 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 237:f3da66175598 91 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 237:f3da66175598 92 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 237:f3da66175598 93 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 237:f3da66175598 94 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 237:f3da66175598 95 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 237:f3da66175598 96 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 237:f3da66175598 97 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 237:f3da66175598 98 *
mbed_official 237:f3da66175598 99 ******************************************************************************
mbed_official 237:f3da66175598 100 */
mbed_official 237:f3da66175598 101
mbed_official 237:f3da66175598 102 /* Includes ------------------------------------------------------------------*/
mbed_official 237:f3da66175598 103 #include "stm32f3xx_hal.h"
mbed_official 237:f3da66175598 104
mbed_official 237:f3da66175598 105 /** @addtogroup STM32F3xx_HAL_Driver
mbed_official 237:f3da66175598 106 * @{
mbed_official 237:f3da66175598 107 */
mbed_official 237:f3da66175598 108
mbed_official 375:3d36234a1087 109 /** @defgroup FLASH FLASH HAL module driver
mbed_official 237:f3da66175598 110 * @brief FLASH HAL module driver
mbed_official 237:f3da66175598 111 * @{
mbed_official 237:f3da66175598 112 */
mbed_official 237:f3da66175598 113
mbed_official 237:f3da66175598 114 #ifdef HAL_FLASH_MODULE_ENABLED
mbed_official 237:f3da66175598 115
mbed_official 237:f3da66175598 116 /* Private typedef -----------------------------------------------------------*/
mbed_official 237:f3da66175598 117 /* Private define ------------------------------------------------------------*/
mbed_official 375:3d36234a1087 118 /** @defgroup FLASH_Private_Defines FLASH Private Define
mbed_official 375:3d36234a1087 119 * @{
mbed_official 375:3d36234a1087 120 */
mbed_official 237:f3da66175598 121 #define HAL_FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
mbed_official 375:3d36234a1087 122 /**
mbed_official 375:3d36234a1087 123 * @}
mbed_official 375:3d36234a1087 124 */
mbed_official 375:3d36234a1087 125
mbed_official 237:f3da66175598 126 /* Private macro -------------------------------------------------------------*/
mbed_official 237:f3da66175598 127 /* Private variables ---------------------------------------------------------*/
mbed_official 375:3d36234a1087 128 /** @defgroup FLASH_Private_Variables FLASH Private Variables
mbed_official 375:3d36234a1087 129 * @{
mbed_official 375:3d36234a1087 130 */
mbed_official 237:f3da66175598 131 /* Variables used for Erase pages under interruption*/
mbed_official 237:f3da66175598 132 FLASH_ProcessTypeDef pFlash;
mbed_official 375:3d36234a1087 133 /**
mbed_official 375:3d36234a1087 134 * @}
mbed_official 375:3d36234a1087 135 */
mbed_official 237:f3da66175598 136
mbed_official 237:f3da66175598 137 /* Private function prototypes -----------------------------------------------*/
mbed_official 375:3d36234a1087 138 /** @defgroup FLASH_Private_Functions FLASH Private Functions
mbed_official 375:3d36234a1087 139 * @{
mbed_official 375:3d36234a1087 140 */
mbed_official 237:f3da66175598 141 /* Program operations */
mbed_official 375:3d36234a1087 142 static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data);
mbed_official 375:3d36234a1087 143 static void FLASH_SetErrorCode(void);
mbed_official 375:3d36234a1087 144 /**
mbed_official 375:3d36234a1087 145 * @}
mbed_official 375:3d36234a1087 146 */
mbed_official 237:f3da66175598 147
mbed_official 375:3d36234a1087 148 /* Exported functions ---------------------------------------------------------*/
mbed_official 375:3d36234a1087 149 /** @defgroup FLASH_Exported_Functions FLASH Exported Functions
mbed_official 237:f3da66175598 150 * @{
mbed_official 237:f3da66175598 151 */
mbed_official 237:f3da66175598 152
mbed_official 375:3d36234a1087 153 /** @defgroup FLASH_Exported_Functions_Group1 Input and Output operation functions
mbed_official 237:f3da66175598 154 * @brief Data transfers functions
mbed_official 237:f3da66175598 155 *
mbed_official 237:f3da66175598 156 @verbatim
mbed_official 237:f3da66175598 157 ===============================================================================
mbed_official 237:f3da66175598 158 ##### IO operation functions #####
mbed_official 237:f3da66175598 159 ===============================================================================
mbed_official 237:f3da66175598 160 [..]
mbed_official 237:f3da66175598 161 This subsection provides a set of functions allowing to manage the FLASH
mbed_official 237:f3da66175598 162 program operations (write/erase).
mbed_official 237:f3da66175598 163
mbed_official 237:f3da66175598 164 @endverbatim
mbed_official 237:f3da66175598 165 * @{
mbed_official 237:f3da66175598 166 */
mbed_official 237:f3da66175598 167
mbed_official 237:f3da66175598 168 /**
mbed_official 237:f3da66175598 169 * @brief Program halfword, word or double word at a specified address
mbed_official 237:f3da66175598 170 * @note The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface
mbed_official 237:f3da66175598 171 * The function HAL_FLASH_Lock() should be called after to lock the FLASH interface
mbed_official 237:f3da66175598 172 *
mbed_official 237:f3da66175598 173 * @note If an erase and a program operations are requested simultaneously,
mbed_official 237:f3da66175598 174 * the erase operation is performed before the program one.
mbed_official 237:f3da66175598 175 *
mbed_official 237:f3da66175598 176 * @param TypeProgram: Indicate the way to program at a specified address.
mbed_official 237:f3da66175598 177 * This parameter can be a value of @ref FLASH_Type_Program
mbed_official 237:f3da66175598 178 * @param Address: Specifies the address to be programmed.
mbed_official 237:f3da66175598 179 * @param Data: Specifies the data to be programmed
mbed_official 237:f3da66175598 180 *
mbed_official 237:f3da66175598 181 * @retval HAL_StatusTypeDef HAL Status
mbed_official 237:f3da66175598 182 */
mbed_official 237:f3da66175598 183 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
mbed_official 237:f3da66175598 184 {
mbed_official 237:f3da66175598 185 HAL_StatusTypeDef status = HAL_ERROR;
mbed_official 237:f3da66175598 186 uint8_t index = 0;
mbed_official 237:f3da66175598 187 uint8_t nbiterations = 0;
mbed_official 237:f3da66175598 188
mbed_official 237:f3da66175598 189 /* Process Locked */
mbed_official 237:f3da66175598 190 __HAL_LOCK(&pFlash);
mbed_official 237:f3da66175598 191
mbed_official 237:f3da66175598 192 /* Check the parameters */
mbed_official 237:f3da66175598 193 assert_param(IS_TYPEPROGRAM(TypeProgram));
mbed_official 237:f3da66175598 194 assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
mbed_official 237:f3da66175598 195
mbed_official 237:f3da66175598 196 /* Wait for last operation to be completed */
mbed_official 237:f3da66175598 197 status = FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE);
mbed_official 237:f3da66175598 198
mbed_official 237:f3da66175598 199 if(status == HAL_OK)
mbed_official 237:f3da66175598 200 {
mbed_official 237:f3da66175598 201 if(TypeProgram == TYPEPROGRAM_HALFWORD)
mbed_official 237:f3da66175598 202 {
mbed_official 237:f3da66175598 203 /* Program halfword (16-bit) at a specified address. */
mbed_official 237:f3da66175598 204 nbiterations = 1;
mbed_official 237:f3da66175598 205 }
mbed_official 237:f3da66175598 206 else if(TypeProgram == TYPEPROGRAM_WORD)
mbed_official 237:f3da66175598 207 {
mbed_official 237:f3da66175598 208 /* Program word (32-bit = 2*16-bit) at a specified address. */
mbed_official 237:f3da66175598 209 nbiterations = 2;
mbed_official 237:f3da66175598 210 }
mbed_official 237:f3da66175598 211 else
mbed_official 237:f3da66175598 212 {
mbed_official 237:f3da66175598 213 /* Program double word (64-bit = 4*16-bit) at a specified address. */
mbed_official 237:f3da66175598 214 nbiterations = 4;
mbed_official 237:f3da66175598 215 }
mbed_official 237:f3da66175598 216
mbed_official 237:f3da66175598 217 for (index = 0; index < nbiterations; index++)
mbed_official 237:f3da66175598 218 {
mbed_official 237:f3da66175598 219 FLASH_Program_HalfWord((Address + (2*index)), (uint16_t)(Data >> (16*index)));
mbed_official 237:f3da66175598 220
mbed_official 237:f3da66175598 221 /* Wait for last operation to be completed */
mbed_official 237:f3da66175598 222 status = FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE);
mbed_official 237:f3da66175598 223
mbed_official 237:f3da66175598 224 /* Check FLASH End of Operation flag */
mbed_official 237:f3da66175598 225 if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
mbed_official 237:f3da66175598 226 {
mbed_official 237:f3da66175598 227 /* Clear FLASH End of Operation pending bit */
mbed_official 237:f3da66175598 228 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
mbed_official 237:f3da66175598 229 }
mbed_official 237:f3da66175598 230
mbed_official 237:f3da66175598 231 /* If the program operation is completed, disable the PG Bit */
mbed_official 237:f3da66175598 232 CLEAR_BIT(FLASH->CR, FLASH_CR_PG);
mbed_official 237:f3da66175598 233 }
mbed_official 237:f3da66175598 234 }
mbed_official 237:f3da66175598 235
mbed_official 237:f3da66175598 236 /* Process Unlocked */
mbed_official 237:f3da66175598 237 __HAL_UNLOCK(&pFlash);
mbed_official 237:f3da66175598 238
mbed_official 237:f3da66175598 239 return status;
mbed_official 237:f3da66175598 240 }
mbed_official 237:f3da66175598 241
mbed_official 237:f3da66175598 242 /**
mbed_official 237:f3da66175598 243 * @brief Program halfword, word or double word at a specified address with interrupt enabled.
mbed_official 237:f3da66175598 244 * @note The function HAL_FLASH_Unlock() should be called before to unlock the FLASH interface
mbed_official 237:f3da66175598 245 * The function HAL_FLASH_Lock() should be called after to lock the FLASH interface
mbed_official 237:f3da66175598 246 *
mbed_official 237:f3da66175598 247 * @note If an erase and a program operations are requested simultaneously,
mbed_official 237:f3da66175598 248 * the erase operation is performed before the program one.
mbed_official 237:f3da66175598 249 *
mbed_official 237:f3da66175598 250 * @param TypeProgram: Indicate the way to program at a specified address.
mbed_official 237:f3da66175598 251 * This parameter can be a value of @ref FLASH_Type_Program
mbed_official 237:f3da66175598 252 * @param Address: Specifies the address to be programmed.
mbed_official 237:f3da66175598 253 * @param Data: Specifies the data to be programmed
mbed_official 237:f3da66175598 254 *
mbed_official 237:f3da66175598 255 * @retval HAL_StatusTypeDef HAL Status
mbed_official 237:f3da66175598 256 */
mbed_official 237:f3da66175598 257 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data)
mbed_official 237:f3da66175598 258 {
mbed_official 237:f3da66175598 259 HAL_StatusTypeDef status = HAL_OK;
mbed_official 237:f3da66175598 260
mbed_official 237:f3da66175598 261 /* Process Locked */
mbed_official 237:f3da66175598 262 __HAL_LOCK(&pFlash);
mbed_official 237:f3da66175598 263
mbed_official 237:f3da66175598 264 /* Check the parameters */
mbed_official 237:f3da66175598 265 assert_param(IS_TYPEPROGRAM(TypeProgram));
mbed_official 237:f3da66175598 266 assert_param(IS_FLASH_PROGRAM_ADDRESS(Address));
mbed_official 237:f3da66175598 267
mbed_official 237:f3da66175598 268 /* Enable End of FLASH Operation and Error source interrupts */
mbed_official 237:f3da66175598 269 __HAL_FLASH_ENABLE_IT((FLASH_IT_EOP | FLASH_IT_ERR));
mbed_official 237:f3da66175598 270
mbed_official 237:f3da66175598 271 pFlash.Address = Address;
mbed_official 237:f3da66175598 272 pFlash.Data = Data;
mbed_official 237:f3da66175598 273
mbed_official 237:f3da66175598 274 if(TypeProgram == TYPEPROGRAM_HALFWORD)
mbed_official 237:f3da66175598 275 {
mbed_official 237:f3da66175598 276 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMHALFWORD;
mbed_official 237:f3da66175598 277 /*Program halfword (16-bit) at a specified address.*/
mbed_official 237:f3da66175598 278 pFlash.DataRemaining = 1;
mbed_official 237:f3da66175598 279 }
mbed_official 237:f3da66175598 280 else if(TypeProgram == TYPEPROGRAM_WORD)
mbed_official 237:f3da66175598 281 {
mbed_official 237:f3da66175598 282 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMWORD;
mbed_official 237:f3da66175598 283 /*Program word (32-bit : 2*16-bit) at a specified address.*/
mbed_official 237:f3da66175598 284 pFlash.DataRemaining = 2;
mbed_official 237:f3da66175598 285 }
mbed_official 237:f3da66175598 286 else
mbed_official 237:f3da66175598 287 {
mbed_official 237:f3da66175598 288 pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAMDOUBLEWORD;
mbed_official 237:f3da66175598 289 /*Program double word (64-bit : 4*16-bit) at a specified address.*/
mbed_official 237:f3da66175598 290 pFlash.DataRemaining = 4;
mbed_official 237:f3da66175598 291 }
mbed_official 237:f3da66175598 292
mbed_official 237:f3da66175598 293 /*Program halfword (16-bit) at a specified address.*/
mbed_official 237:f3da66175598 294 FLASH_Program_HalfWord(Address, (uint16_t)Data);
mbed_official 237:f3da66175598 295
mbed_official 237:f3da66175598 296 return status;
mbed_official 237:f3da66175598 297 }
mbed_official 237:f3da66175598 298
mbed_official 237:f3da66175598 299 /**
mbed_official 237:f3da66175598 300 * @brief This function handles FLASH interrupt request.
mbed_official 237:f3da66175598 301 * @retval None
mbed_official 237:f3da66175598 302 */
mbed_official 237:f3da66175598 303 void HAL_FLASH_IRQHandler(void)
mbed_official 237:f3da66175598 304 {
mbed_official 237:f3da66175598 305 uint32_t addresstmp;
mbed_official 237:f3da66175598 306 /* If the operation is completed, disable the PG, PER and MER Bits */
mbed_official 237:f3da66175598 307 CLEAR_BIT(FLASH->CR, (FLASH_CR_PG | FLASH_CR_PER | FLASH_CR_MER));
mbed_official 237:f3da66175598 308
mbed_official 237:f3da66175598 309 /* Check FLASH End of Operation flag */
mbed_official 237:f3da66175598 310 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
mbed_official 237:f3da66175598 311 {
mbed_official 237:f3da66175598 312 /* Clear FLASH End of Operation pending bit */
mbed_official 237:f3da66175598 313 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
mbed_official 237:f3da66175598 314
mbed_official 237:f3da66175598 315 if(pFlash.ProcedureOnGoing == FLASH_PROC_PAGEERASE)
mbed_official 237:f3da66175598 316 {
mbed_official 237:f3da66175598 317 /* Nb of pages to erased can be decreased */
mbed_official 237:f3da66175598 318 pFlash.DataRemaining--;
mbed_official 237:f3da66175598 319
mbed_official 237:f3da66175598 320 /* Indicate user which page address has been erased*/
mbed_official 237:f3da66175598 321 HAL_FLASH_EndOfOperationCallback(pFlash.Address);
mbed_official 237:f3da66175598 322
mbed_official 237:f3da66175598 323 /* Check if there are still pages to erase*/
mbed_official 237:f3da66175598 324 if(pFlash.DataRemaining != 0)
mbed_official 237:f3da66175598 325 {
mbed_official 237:f3da66175598 326 /* Increment page address to next page */
mbed_official 237:f3da66175598 327 pFlash.Address += FLASH_PAGE_SIZE;
mbed_official 237:f3da66175598 328 addresstmp = pFlash.Address;
mbed_official 237:f3da66175598 329 FLASH_PageErase(addresstmp);
mbed_official 237:f3da66175598 330 }
mbed_official 237:f3da66175598 331 else
mbed_official 237:f3da66175598 332 {
mbed_official 237:f3da66175598 333 /*No more pages to Erase*/
mbed_official 237:f3da66175598 334
mbed_official 237:f3da66175598 335 /*Reset Address and stop Erase pages procedure*/
mbed_official 237:f3da66175598 336 pFlash.Address = 0xFFFFFFFF;
mbed_official 237:f3da66175598 337 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
mbed_official 237:f3da66175598 338 }
mbed_official 237:f3da66175598 339 }
mbed_official 237:f3da66175598 340 else if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE)
mbed_official 237:f3da66175598 341 {
mbed_official 237:f3da66175598 342 /*MassErase ended. Return the selected bank*/
mbed_official 237:f3da66175598 343 /* FLASH EOP interrupt user callback */
mbed_official 237:f3da66175598 344 HAL_FLASH_EndOfOperationCallback(0);
mbed_official 237:f3da66175598 345
mbed_official 237:f3da66175598 346 /* Stop Mass Erase procedure*/
mbed_official 237:f3da66175598 347 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
mbed_official 237:f3da66175598 348 }
mbed_official 237:f3da66175598 349 else
mbed_official 237:f3da66175598 350 {
mbed_official 237:f3da66175598 351 /* Nb of 16-bit data to program can be decreased */
mbed_official 237:f3da66175598 352 pFlash.DataRemaining--;
mbed_official 237:f3da66175598 353
mbed_official 237:f3da66175598 354 /* Check if there are still 16-bit data to program */
mbed_official 237:f3da66175598 355 if(pFlash.DataRemaining != 0)
mbed_official 237:f3da66175598 356 {
mbed_official 237:f3da66175598 357 /* Increment address to 16-bit */
mbed_official 237:f3da66175598 358 pFlash.Address += 2;
mbed_official 237:f3da66175598 359 addresstmp = pFlash.Address;
mbed_official 237:f3da66175598 360
mbed_official 237:f3da66175598 361 /* Shift to have next 16-bit data */
mbed_official 237:f3da66175598 362 pFlash.Data = (pFlash.Data >> 16);
mbed_official 237:f3da66175598 363
mbed_official 237:f3da66175598 364 /*Program halfword (16-bit) at a specified address.*/
mbed_official 237:f3da66175598 365 FLASH_Program_HalfWord(addresstmp, (uint16_t)pFlash.Data);
mbed_official 237:f3da66175598 366 }
mbed_official 237:f3da66175598 367 else
mbed_official 237:f3da66175598 368 {
mbed_official 237:f3da66175598 369 /*Program ended. Return the selected address*/
mbed_official 237:f3da66175598 370 /* FLASH EOP interrupt user callback */
mbed_official 237:f3da66175598 371 if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMHALFWORD)
mbed_official 237:f3da66175598 372 {
mbed_official 237:f3da66175598 373 HAL_FLASH_EndOfOperationCallback(pFlash.Address);
mbed_official 237:f3da66175598 374 }
mbed_official 237:f3da66175598 375 else if (pFlash.ProcedureOnGoing == FLASH_PROC_PROGRAMWORD)
mbed_official 237:f3da66175598 376 {
mbed_official 237:f3da66175598 377 HAL_FLASH_EndOfOperationCallback(pFlash.Address-2);
mbed_official 237:f3da66175598 378 }
mbed_official 237:f3da66175598 379 else
mbed_official 237:f3da66175598 380 {
mbed_official 237:f3da66175598 381 HAL_FLASH_EndOfOperationCallback(pFlash.Address-6);
mbed_official 237:f3da66175598 382 }
mbed_official 237:f3da66175598 383
mbed_official 237:f3da66175598 384 /* Reset Address and stop Program procedure*/
mbed_official 237:f3da66175598 385 pFlash.Address = 0xFFFFFFFF;
mbed_official 237:f3da66175598 386 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
mbed_official 237:f3da66175598 387 }
mbed_official 237:f3da66175598 388 }
mbed_official 237:f3da66175598 389 }
mbed_official 237:f3da66175598 390
mbed_official 237:f3da66175598 391 /* Check FLASH operation error flags */
mbed_official 237:f3da66175598 392 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR))
mbed_official 237:f3da66175598 393 {
mbed_official 237:f3da66175598 394 /*Save the Error code*/
mbed_official 237:f3da66175598 395 FLASH_SetErrorCode();
mbed_official 237:f3da66175598 396
mbed_official 237:f3da66175598 397 /* FLASH error interrupt user callback */
mbed_official 237:f3da66175598 398 HAL_FLASH_OperationErrorCallback(pFlash.Address);
mbed_official 237:f3da66175598 399
mbed_official 237:f3da66175598 400 /* Clear FLASH error pending bits */
mbed_official 237:f3da66175598 401 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR);
mbed_official 237:f3da66175598 402
mbed_official 237:f3da66175598 403 /* Reset address and stop the procedure ongoing*/
mbed_official 237:f3da66175598 404 pFlash.Address = 0xFFFFFFFF;
mbed_official 237:f3da66175598 405 pFlash.ProcedureOnGoing = FLASH_PROC_NONE;
mbed_official 237:f3da66175598 406 }
mbed_official 237:f3da66175598 407
mbed_official 237:f3da66175598 408 if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE)
mbed_official 237:f3da66175598 409 {
mbed_official 237:f3da66175598 410 /* Disable End of FLASH Operation and Error source interrupts */
mbed_official 237:f3da66175598 411 __HAL_FLASH_DISABLE_IT((FLASH_IT_EOP | FLASH_IT_ERR));
mbed_official 237:f3da66175598 412
mbed_official 237:f3da66175598 413 /* Process Unlocked */
mbed_official 237:f3da66175598 414 __HAL_UNLOCK(&pFlash);
mbed_official 237:f3da66175598 415 }
mbed_official 237:f3da66175598 416 }
mbed_official 237:f3da66175598 417
mbed_official 237:f3da66175598 418
mbed_official 237:f3da66175598 419 /**
mbed_official 237:f3da66175598 420 * @brief FLASH end of operation interrupt callback
mbed_official 237:f3da66175598 421 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
mbed_official 237:f3da66175598 422 * - Mass Erase: No return value expected
mbed_official 237:f3da66175598 423 * - Pages Erase: Address of the page which has been erased
mbed_official 237:f3da66175598 424 * - Program: Address which was selected for data program
mbed_official 237:f3da66175598 425 * @retval none
mbed_official 237:f3da66175598 426 */
mbed_official 237:f3da66175598 427 __weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue)
mbed_official 237:f3da66175598 428 {
mbed_official 237:f3da66175598 429 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 430 the HAL_FLASH_EndOfOperationCallback could be implemented in the user file
mbed_official 237:f3da66175598 431 */
mbed_official 237:f3da66175598 432 }
mbed_official 237:f3da66175598 433
mbed_official 237:f3da66175598 434 /**
mbed_official 237:f3da66175598 435 * @brief FLASH operation error interrupt callback
mbed_official 237:f3da66175598 436 * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure
mbed_official 237:f3da66175598 437 * - Mass Erase: No return value expected
mbed_official 237:f3da66175598 438 * - Pages Erase: Address of the page which returned an error
mbed_official 237:f3da66175598 439 * - Program: Address which was selected for data program
mbed_official 237:f3da66175598 440 * @retval none
mbed_official 237:f3da66175598 441 */
mbed_official 237:f3da66175598 442 __weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue)
mbed_official 237:f3da66175598 443 {
mbed_official 237:f3da66175598 444 /* NOTE : This function Should not be modified, when the callback is needed,
mbed_official 237:f3da66175598 445 the HAL_FLASH_OperationErrorCallback could be implemented in the user file
mbed_official 237:f3da66175598 446 */
mbed_official 237:f3da66175598 447 }
mbed_official 237:f3da66175598 448
mbed_official 237:f3da66175598 449 /**
mbed_official 237:f3da66175598 450 * @}
mbed_official 237:f3da66175598 451 */
mbed_official 237:f3da66175598 452
mbed_official 375:3d36234a1087 453 /** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions
mbed_official 237:f3da66175598 454 * @brief management functions
mbed_official 237:f3da66175598 455 *
mbed_official 237:f3da66175598 456 @verbatim
mbed_official 237:f3da66175598 457 ===============================================================================
mbed_official 237:f3da66175598 458 ##### Peripheral Control functions #####
mbed_official 237:f3da66175598 459 ===============================================================================
mbed_official 237:f3da66175598 460 [..]
mbed_official 237:f3da66175598 461 This subsection provides a set of functions allowing to control the FLASH
mbed_official 237:f3da66175598 462 memory operations.
mbed_official 237:f3da66175598 463
mbed_official 237:f3da66175598 464 @endverbatim
mbed_official 237:f3da66175598 465 * @{
mbed_official 237:f3da66175598 466 */
mbed_official 237:f3da66175598 467
mbed_official 237:f3da66175598 468 /**
mbed_official 237:f3da66175598 469 * @brief Unlock the FLASH control register access
mbed_official 237:f3da66175598 470 * @retval HAL Status
mbed_official 237:f3da66175598 471 */
mbed_official 237:f3da66175598 472 HAL_StatusTypeDef HAL_FLASH_Unlock(void)
mbed_official 237:f3da66175598 473 {
mbed_official 237:f3da66175598 474 if((READ_BIT(FLASH->CR, FLASH_CR_LOCK)) != RESET)
mbed_official 237:f3da66175598 475 {
mbed_official 237:f3da66175598 476 /* Authorize the FLASH Registers access */
mbed_official 237:f3da66175598 477 WRITE_REG(FLASH->KEYR, FLASH_KEY1);
mbed_official 237:f3da66175598 478 WRITE_REG(FLASH->KEYR, FLASH_KEY2);
mbed_official 237:f3da66175598 479 }
mbed_official 237:f3da66175598 480 else
mbed_official 237:f3da66175598 481 {
mbed_official 237:f3da66175598 482 return HAL_ERROR;
mbed_official 237:f3da66175598 483 }
mbed_official 237:f3da66175598 484
mbed_official 237:f3da66175598 485 return HAL_OK;
mbed_official 237:f3da66175598 486 }
mbed_official 237:f3da66175598 487
mbed_official 237:f3da66175598 488 /**
mbed_official 237:f3da66175598 489 * @brief Locks the FLASH control register access
mbed_official 237:f3da66175598 490 * @retval HAL Status
mbed_official 237:f3da66175598 491 */
mbed_official 237:f3da66175598 492 HAL_StatusTypeDef HAL_FLASH_Lock(void)
mbed_official 237:f3da66175598 493 {
mbed_official 237:f3da66175598 494 /* Set the LOCK Bit to lock the FLASH Registers access */
mbed_official 237:f3da66175598 495 SET_BIT(FLASH->CR, FLASH_CR_LOCK);
mbed_official 237:f3da66175598 496
mbed_official 237:f3da66175598 497 return HAL_OK;
mbed_official 237:f3da66175598 498 }
mbed_official 237:f3da66175598 499
mbed_official 237:f3da66175598 500
mbed_official 237:f3da66175598 501 /**
mbed_official 237:f3da66175598 502 * @brief Unlock the FLASH Option Control Registers access.
mbed_official 237:f3da66175598 503 * @retval HAL Status
mbed_official 237:f3da66175598 504 */
mbed_official 237:f3da66175598 505 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void)
mbed_official 237:f3da66175598 506 {
mbed_official 237:f3da66175598 507 if((READ_BIT(FLASH->CR, FLASH_CR_OPTWRE)) == RESET)
mbed_official 237:f3da66175598 508 {
mbed_official 237:f3da66175598 509 /* Authorizes the Option Byte register programming */
mbed_official 237:f3da66175598 510 WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY1);
mbed_official 237:f3da66175598 511 WRITE_REG(FLASH->OPTKEYR, FLASH_OPTKEY2);
mbed_official 237:f3da66175598 512 }
mbed_official 237:f3da66175598 513 else
mbed_official 237:f3da66175598 514 {
mbed_official 237:f3da66175598 515 return HAL_ERROR;
mbed_official 237:f3da66175598 516 }
mbed_official 237:f3da66175598 517
mbed_official 237:f3da66175598 518 return HAL_OK;
mbed_official 237:f3da66175598 519 }
mbed_official 237:f3da66175598 520
mbed_official 237:f3da66175598 521 /**
mbed_official 237:f3da66175598 522 * @brief Lock the FLASH Option Control Registers access.
mbed_official 237:f3da66175598 523 * @retval HAL Status
mbed_official 237:f3da66175598 524 */
mbed_official 237:f3da66175598 525 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void)
mbed_official 237:f3da66175598 526 {
mbed_official 237:f3da66175598 527 /* Clear the OPTWRE Bit to lock the FLASH Option Byte Registers access */
mbed_official 237:f3da66175598 528 CLEAR_BIT(FLASH->CR, FLASH_CR_OPTWRE);
mbed_official 237:f3da66175598 529
mbed_official 237:f3da66175598 530 return HAL_OK;
mbed_official 237:f3da66175598 531 }
mbed_official 237:f3da66175598 532
mbed_official 237:f3da66175598 533 /**
mbed_official 237:f3da66175598 534 * @brief Launch the option byte loading.
mbed_official 237:f3da66175598 535 * @retval HAL status
mbed_official 237:f3da66175598 536 */
mbed_official 237:f3da66175598 537 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void)
mbed_official 237:f3da66175598 538 {
mbed_official 237:f3da66175598 539 /* Set the bit to force the option byte reloading */
mbed_official 237:f3da66175598 540 SET_BIT(FLASH->CR, FLASH_CR_OBL_LAUNCH);
mbed_official 237:f3da66175598 541
mbed_official 237:f3da66175598 542 /* Wait for last operation to be completed */
mbed_official 237:f3da66175598 543 return(FLASH_WaitForLastOperation((uint32_t)HAL_FLASH_TIMEOUT_VALUE));
mbed_official 237:f3da66175598 544 }
mbed_official 237:f3da66175598 545
mbed_official 237:f3da66175598 546 /**
mbed_official 237:f3da66175598 547 * @}
mbed_official 237:f3da66175598 548 */
mbed_official 237:f3da66175598 549
mbed_official 237:f3da66175598 550
mbed_official 375:3d36234a1087 551 /** @defgroup FLASH_Exported_Functions_Group3 Peripheral State functions
mbed_official 237:f3da66175598 552 * @brief Peripheral State functions
mbed_official 237:f3da66175598 553 *
mbed_official 237:f3da66175598 554 @verbatim
mbed_official 237:f3da66175598 555 ===============================================================================
mbed_official 237:f3da66175598 556 ##### Peripheral State functions #####
mbed_official 237:f3da66175598 557 ===============================================================================
mbed_official 237:f3da66175598 558 [..]
mbed_official 237:f3da66175598 559 This subsection permit to get in run-time the status of the FLASH peripheral.
mbed_official 237:f3da66175598 560
mbed_official 237:f3da66175598 561 @endverbatim
mbed_official 237:f3da66175598 562 * @{
mbed_official 237:f3da66175598 563 */
mbed_official 237:f3da66175598 564
mbed_official 237:f3da66175598 565 /**
mbed_official 237:f3da66175598 566 * @brief Get the specific FLASH error flag.
mbed_official 237:f3da66175598 567 * @retval FLASH_ErrorCode: The returned value can be:
mbed_official 237:f3da66175598 568 * @arg FLASH_ERROR_PG: FLASH Programming error flag
mbed_official 237:f3da66175598 569 * @arg FLASH_ERROR_WRP: FLASH Write protected error flag
mbed_official 237:f3da66175598 570 */
mbed_official 237:f3da66175598 571 FLASH_ErrorTypeDef HAL_FLASH_GetError(void)
mbed_official 237:f3da66175598 572 {
mbed_official 237:f3da66175598 573 return pFlash.ErrorCode;
mbed_official 237:f3da66175598 574 }
mbed_official 237:f3da66175598 575
mbed_official 237:f3da66175598 576 /**
mbed_official 237:f3da66175598 577 * @}
mbed_official 237:f3da66175598 578 */
mbed_official 237:f3da66175598 579
mbed_official 237:f3da66175598 580 /**
mbed_official 375:3d36234a1087 581 * @}
mbed_official 375:3d36234a1087 582 */
mbed_official 375:3d36234a1087 583
mbed_official 375:3d36234a1087 584 /** @addtogroup FLASH_Private_Functions FLASH Private Functions
mbed_official 375:3d36234a1087 585 * @{
mbed_official 375:3d36234a1087 586 */
mbed_official 375:3d36234a1087 587 /**
mbed_official 237:f3da66175598 588 * @brief Program a half-word (16-bit) at a specified address.
mbed_official 237:f3da66175598 589 * @param Address: specifies the address to be programmed.
mbed_official 237:f3da66175598 590 * @param Data: specifies the data to be programmed.
mbed_official 237:f3da66175598 591 * @retval None
mbed_official 237:f3da66175598 592 */
mbed_official 237:f3da66175598 593 static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data)
mbed_official 237:f3da66175598 594 {
mbed_official 237:f3da66175598 595 /* Clear pending flags (if any) */
mbed_official 237:f3da66175598 596 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR);
mbed_official 237:f3da66175598 597
mbed_official 237:f3da66175598 598 /* Proceed to program the new data */
mbed_official 237:f3da66175598 599 SET_BIT(FLASH->CR, FLASH_CR_PG);
mbed_official 237:f3da66175598 600
mbed_official 237:f3da66175598 601 *(__IO uint16_t*)Address = Data;
mbed_official 237:f3da66175598 602 }
mbed_official 237:f3da66175598 603
mbed_official 237:f3da66175598 604 /**
mbed_official 237:f3da66175598 605 * @brief Wait for a FLASH operation to complete.
mbed_official 237:f3da66175598 606 * @param Timeout: maximum flash operationtimeout
mbed_official 237:f3da66175598 607 * @retval HAL_StatusTypeDef HAL Status
mbed_official 237:f3da66175598 608 */
mbed_official 237:f3da66175598 609 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
mbed_official 237:f3da66175598 610 {
mbed_official 237:f3da66175598 611 /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
mbed_official 237:f3da66175598 612 Even if the FLASH operation fails, the BUSY flag will be reset and an error
mbed_official 237:f3da66175598 613 flag will be set */
mbed_official 237:f3da66175598 614
mbed_official 237:f3da66175598 615 uint32_t tickstart = HAL_GetTick();
mbed_official 237:f3da66175598 616
mbed_official 237:f3da66175598 617 while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY))
mbed_official 237:f3da66175598 618 {
mbed_official 237:f3da66175598 619 if (Timeout != HAL_MAX_DELAY)
mbed_official 237:f3da66175598 620 {
mbed_official 237:f3da66175598 621 if((Timeout == 0) || ((HAL_GetTick()-tickstart) > Timeout))
mbed_official 237:f3da66175598 622 {
mbed_official 237:f3da66175598 623 return HAL_TIMEOUT;
mbed_official 237:f3da66175598 624 }
mbed_official 237:f3da66175598 625 }
mbed_official 237:f3da66175598 626 }
mbed_official 237:f3da66175598 627
mbed_official 237:f3da66175598 628 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) || __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR))
mbed_official 237:f3da66175598 629 {
mbed_official 237:f3da66175598 630 /*Save the error code*/
mbed_official 237:f3da66175598 631 FLASH_SetErrorCode();
mbed_official 237:f3da66175598 632 return HAL_ERROR;
mbed_official 237:f3da66175598 633 }
mbed_official 237:f3da66175598 634
mbed_official 237:f3da66175598 635 /* If there is an error flag set */
mbed_official 237:f3da66175598 636 return HAL_OK;
mbed_official 237:f3da66175598 637
mbed_official 237:f3da66175598 638 }
mbed_official 237:f3da66175598 639
mbed_official 237:f3da66175598 640 /**
mbed_official 237:f3da66175598 641 * @brief Erase the specified FLASH memory page
mbed_official 237:f3da66175598 642 * @param PageAddress: FLASH page to erase
mbed_official 237:f3da66175598 643 * The value of this parameter depend on device used within the same series
mbed_official 237:f3da66175598 644 *
mbed_official 237:f3da66175598 645 * @retval None
mbed_official 237:f3da66175598 646 */
mbed_official 237:f3da66175598 647 void FLASH_PageErase(uint32_t PageAddress)
mbed_official 237:f3da66175598 648 {
mbed_official 237:f3da66175598 649 /* Clear pending flags (if any) */
mbed_official 237:f3da66175598 650 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP | FLASH_FLAG_WRPERR | FLASH_FLAG_PGERR);
mbed_official 237:f3da66175598 651
mbed_official 237:f3da66175598 652 /* Proceed to erase the page */
mbed_official 237:f3da66175598 653 SET_BIT(FLASH->CR, FLASH_CR_PER);
mbed_official 237:f3da66175598 654 WRITE_REG(FLASH->AR, PageAddress);
mbed_official 237:f3da66175598 655 SET_BIT(FLASH->CR, FLASH_CR_STRT);
mbed_official 237:f3da66175598 656 }
mbed_official 237:f3da66175598 657
mbed_official 237:f3da66175598 658 /**
mbed_official 237:f3da66175598 659 * @brief Set the specific FLASH error flag.
mbed_official 237:f3da66175598 660 * @retval None
mbed_official 237:f3da66175598 661 */
mbed_official 237:f3da66175598 662 static void FLASH_SetErrorCode(void)
mbed_official 237:f3da66175598 663 {
mbed_official 237:f3da66175598 664 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR))
mbed_official 237:f3da66175598 665 {
mbed_official 237:f3da66175598 666 pFlash.ErrorCode = FLASH_ERROR_WRP;
mbed_official 237:f3da66175598 667 }
mbed_official 237:f3da66175598 668 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGERR))
mbed_official 237:f3da66175598 669 {
mbed_official 237:f3da66175598 670 pFlash.ErrorCode |= FLASH_ERROR_PG;
mbed_official 237:f3da66175598 671 }
mbed_official 237:f3da66175598 672 }
mbed_official 237:f3da66175598 673
mbed_official 237:f3da66175598 674 /**
mbed_official 237:f3da66175598 675 * @}
mbed_official 237:f3da66175598 676 */
mbed_official 237:f3da66175598 677
mbed_official 237:f3da66175598 678 #endif /* HAL_FLASH_MODULE_ENABLED */
mbed_official 237:f3da66175598 679
mbed_official 237:f3da66175598 680 /**
mbed_official 237:f3da66175598 681 * @}
mbed_official 237:f3da66175598 682 */
mbed_official 237:f3da66175598 683
mbed_official 237:f3da66175598 684 /**
mbed_official 237:f3da66175598 685 * @}
mbed_official 237:f3da66175598 686 */
mbed_official 237:f3da66175598 687
mbed_official 237:f3da66175598 688 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/