Mouse code for the MacroRat
mbed-dev/targets/TARGET_STM/TARGET_STM32F2/device/stm32f2xx_hal_flash.c@18:6a4db94011d3, 2017-05-14 (annotated)
- Committer:
- sahilmgandhi
- Date:
- Sun May 14 23:18:57 2017 +0000
- Revision:
- 18:6a4db94011d3
Publishing again
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sahilmgandhi | 18:6a4db94011d3 | 1 | /** |
sahilmgandhi | 18:6a4db94011d3 | 2 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 3 | * @file stm32f2xx_hal_flash.c |
sahilmgandhi | 18:6a4db94011d3 | 4 | * @author MCD Application Team |
sahilmgandhi | 18:6a4db94011d3 | 5 | * @version V1.1.3 |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @date 29-June-2016 |
sahilmgandhi | 18:6a4db94011d3 | 7 | * @brief FLASH HAL module driver. |
sahilmgandhi | 18:6a4db94011d3 | 8 | * This file provides firmware functions to manage the following |
sahilmgandhi | 18:6a4db94011d3 | 9 | * functionalities of the internal FLASH memory: |
sahilmgandhi | 18:6a4db94011d3 | 10 | * + Program operations functions |
sahilmgandhi | 18:6a4db94011d3 | 11 | * + Memory Control functions |
sahilmgandhi | 18:6a4db94011d3 | 12 | * + Peripheral Errors functions |
sahilmgandhi | 18:6a4db94011d3 | 13 | * |
sahilmgandhi | 18:6a4db94011d3 | 14 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 15 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 16 | ##### FLASH peripheral features ##### |
sahilmgandhi | 18:6a4db94011d3 | 17 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 18 | |
sahilmgandhi | 18:6a4db94011d3 | 19 | [..] The Flash memory interface manages CPU AHB I-Code and D-Code accesses |
sahilmgandhi | 18:6a4db94011d3 | 20 | to the Flash memory. It implements the erase and program Flash memory operations |
sahilmgandhi | 18:6a4db94011d3 | 21 | and the read and write protection mechanisms. |
sahilmgandhi | 18:6a4db94011d3 | 22 | |
sahilmgandhi | 18:6a4db94011d3 | 23 | [..] The Flash memory interface accelerates code execution with a system of instruction |
sahilmgandhi | 18:6a4db94011d3 | 24 | prefetch and cache lines. |
sahilmgandhi | 18:6a4db94011d3 | 25 | |
sahilmgandhi | 18:6a4db94011d3 | 26 | [..] The FLASH main features are: |
sahilmgandhi | 18:6a4db94011d3 | 27 | (+) Flash memory read operations |
sahilmgandhi | 18:6a4db94011d3 | 28 | (+) Flash memory program/erase operations |
sahilmgandhi | 18:6a4db94011d3 | 29 | (+) Read / write protections |
sahilmgandhi | 18:6a4db94011d3 | 30 | (+) Prefetch on I-Code |
sahilmgandhi | 18:6a4db94011d3 | 31 | (+) 64 cache lines of 128 bits on I-Code |
sahilmgandhi | 18:6a4db94011d3 | 32 | (+) 8 cache lines of 128 bits on D-Code |
sahilmgandhi | 18:6a4db94011d3 | 33 | |
sahilmgandhi | 18:6a4db94011d3 | 34 | |
sahilmgandhi | 18:6a4db94011d3 | 35 | ##### How to use this driver ##### |
sahilmgandhi | 18:6a4db94011d3 | 36 | ============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 37 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 38 | This driver provides functions and macros to configure and program the FLASH |
sahilmgandhi | 18:6a4db94011d3 | 39 | memory of all STM32F2xx devices. |
sahilmgandhi | 18:6a4db94011d3 | 40 | |
sahilmgandhi | 18:6a4db94011d3 | 41 | (#) FLASH Memory IO Programming functions: |
sahilmgandhi | 18:6a4db94011d3 | 42 | (++) Lock and Unlock the FLASH interface using HAL_FLASH_Unlock() and |
sahilmgandhi | 18:6a4db94011d3 | 43 | HAL_FLASH_Lock() functions |
sahilmgandhi | 18:6a4db94011d3 | 44 | (++) Program functions: byte, half word, word and double word |
sahilmgandhi | 18:6a4db94011d3 | 45 | (++) There Two modes of programming : |
sahilmgandhi | 18:6a4db94011d3 | 46 | (+++) Polling mode using HAL_FLASH_Program() function |
sahilmgandhi | 18:6a4db94011d3 | 47 | (+++) Interrupt mode using HAL_FLASH_Program_IT() function |
sahilmgandhi | 18:6a4db94011d3 | 48 | |
sahilmgandhi | 18:6a4db94011d3 | 49 | (#) Interrupts and flags management functions : |
sahilmgandhi | 18:6a4db94011d3 | 50 | (++) Handle FLASH interrupts by calling HAL_FLASH_IRQHandler() |
sahilmgandhi | 18:6a4db94011d3 | 51 | (++) Wait for last FLASH operation according to its status |
sahilmgandhi | 18:6a4db94011d3 | 52 | (++) Get error flag status by calling HAL_SetErrorCode() |
sahilmgandhi | 18:6a4db94011d3 | 53 | |
sahilmgandhi | 18:6a4db94011d3 | 54 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 55 | In addition to these functions, this driver includes a set of macros allowing |
sahilmgandhi | 18:6a4db94011d3 | 56 | to handle the following operations: |
sahilmgandhi | 18:6a4db94011d3 | 57 | (+) Set the latency |
sahilmgandhi | 18:6a4db94011d3 | 58 | (+) Enable/Disable the prefetch buffer |
sahilmgandhi | 18:6a4db94011d3 | 59 | (+) Enable/Disable the Instruction cache and the Data cache |
sahilmgandhi | 18:6a4db94011d3 | 60 | (+) Reset the Instruction cache and the Data cache |
sahilmgandhi | 18:6a4db94011d3 | 61 | (+) Enable/Disable the FLASH interrupts |
sahilmgandhi | 18:6a4db94011d3 | 62 | (+) Monitor the FLASH flags status |
sahilmgandhi | 18:6a4db94011d3 | 63 | |
sahilmgandhi | 18:6a4db94011d3 | 64 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 65 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 66 | * @attention |
sahilmgandhi | 18:6a4db94011d3 | 67 | * |
sahilmgandhi | 18:6a4db94011d3 | 68 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
sahilmgandhi | 18:6a4db94011d3 | 69 | * |
sahilmgandhi | 18:6a4db94011d3 | 70 | * Redistribution and use in source and binary forms, with or without modification, |
sahilmgandhi | 18:6a4db94011d3 | 71 | * are permitted provided that the following conditions are met: |
sahilmgandhi | 18:6a4db94011d3 | 72 | * 1. Redistributions of source code must retain the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 73 | * this list of conditions and the following disclaimer. |
sahilmgandhi | 18:6a4db94011d3 | 74 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 75 | * this list of conditions and the following disclaimer in the documentation |
sahilmgandhi | 18:6a4db94011d3 | 76 | * and/or other materials provided with the distribution. |
sahilmgandhi | 18:6a4db94011d3 | 77 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
sahilmgandhi | 18:6a4db94011d3 | 78 | * may be used to endorse or promote products derived from this software |
sahilmgandhi | 18:6a4db94011d3 | 79 | * without specific prior written permission. |
sahilmgandhi | 18:6a4db94011d3 | 80 | * |
sahilmgandhi | 18:6a4db94011d3 | 81 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
sahilmgandhi | 18:6a4db94011d3 | 82 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
sahilmgandhi | 18:6a4db94011d3 | 83 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
sahilmgandhi | 18:6a4db94011d3 | 84 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
sahilmgandhi | 18:6a4db94011d3 | 85 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
sahilmgandhi | 18:6a4db94011d3 | 86 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
sahilmgandhi | 18:6a4db94011d3 | 87 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
sahilmgandhi | 18:6a4db94011d3 | 88 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
sahilmgandhi | 18:6a4db94011d3 | 89 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
sahilmgandhi | 18:6a4db94011d3 | 90 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sahilmgandhi | 18:6a4db94011d3 | 91 | * |
sahilmgandhi | 18:6a4db94011d3 | 92 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 93 | */ |
sahilmgandhi | 18:6a4db94011d3 | 94 | |
sahilmgandhi | 18:6a4db94011d3 | 95 | /* Includes ------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 96 | #include "stm32f2xx_hal.h" |
sahilmgandhi | 18:6a4db94011d3 | 97 | |
sahilmgandhi | 18:6a4db94011d3 | 98 | /** @addtogroup STM32F2xx_HAL_Driver |
sahilmgandhi | 18:6a4db94011d3 | 99 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 100 | */ |
sahilmgandhi | 18:6a4db94011d3 | 101 | |
sahilmgandhi | 18:6a4db94011d3 | 102 | /** @defgroup FLASH FLASH |
sahilmgandhi | 18:6a4db94011d3 | 103 | * @brief FLASH HAL module driver |
sahilmgandhi | 18:6a4db94011d3 | 104 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 105 | */ |
sahilmgandhi | 18:6a4db94011d3 | 106 | |
sahilmgandhi | 18:6a4db94011d3 | 107 | #ifdef HAL_FLASH_MODULE_ENABLED |
sahilmgandhi | 18:6a4db94011d3 | 108 | |
sahilmgandhi | 18:6a4db94011d3 | 109 | /* Private typedef -----------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 110 | /* Private define ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 111 | /** @addtogroup FLASH_Private_Constants |
sahilmgandhi | 18:6a4db94011d3 | 112 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 113 | */ |
sahilmgandhi | 18:6a4db94011d3 | 114 | #define FLASH_TIMEOUT_VALUE ((uint32_t)50000U)/* 50 s */ |
sahilmgandhi | 18:6a4db94011d3 | 115 | /** |
sahilmgandhi | 18:6a4db94011d3 | 116 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 117 | */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | /* Private macro -------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 119 | /* Private variables ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 120 | /** @addtogroup FLASH_Private_Variables |
sahilmgandhi | 18:6a4db94011d3 | 121 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 122 | */ |
sahilmgandhi | 18:6a4db94011d3 | 123 | /* Variable used for Erase sectors under interruption */ |
sahilmgandhi | 18:6a4db94011d3 | 124 | FLASH_ProcessTypeDef pFlash; |
sahilmgandhi | 18:6a4db94011d3 | 125 | /** |
sahilmgandhi | 18:6a4db94011d3 | 126 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 127 | */ |
sahilmgandhi | 18:6a4db94011d3 | 128 | |
sahilmgandhi | 18:6a4db94011d3 | 129 | /* Private function prototypes -----------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 130 | /** @addtogroup FLASH_Private_Functions |
sahilmgandhi | 18:6a4db94011d3 | 131 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 132 | */ |
sahilmgandhi | 18:6a4db94011d3 | 133 | /* Program operations */ |
sahilmgandhi | 18:6a4db94011d3 | 134 | static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 135 | static void FLASH_Program_Word(uint32_t Address, uint32_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 136 | static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 137 | static void FLASH_Program_Byte(uint32_t Address, uint8_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 138 | static void FLASH_SetErrorCode(void); |
sahilmgandhi | 18:6a4db94011d3 | 139 | extern void FLASH_FlushCaches(void); |
sahilmgandhi | 18:6a4db94011d3 | 140 | |
sahilmgandhi | 18:6a4db94011d3 | 141 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); |
sahilmgandhi | 18:6a4db94011d3 | 142 | /** |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 144 | */ |
sahilmgandhi | 18:6a4db94011d3 | 145 | |
sahilmgandhi | 18:6a4db94011d3 | 146 | /* Exported functions --------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 147 | /** @defgroup FLASH_Exported_Functions FLASH Exported Functions |
sahilmgandhi | 18:6a4db94011d3 | 148 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 149 | */ |
sahilmgandhi | 18:6a4db94011d3 | 150 | |
sahilmgandhi | 18:6a4db94011d3 | 151 | /** @defgroup FLASH_Exported_Functions_Group1 Programming operation functions |
sahilmgandhi | 18:6a4db94011d3 | 152 | * @brief Programming operation functions |
sahilmgandhi | 18:6a4db94011d3 | 153 | * |
sahilmgandhi | 18:6a4db94011d3 | 154 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 155 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 156 | ##### Programming operation functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 157 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 158 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 159 | This subsection provides a set of functions allowing to manage the FLASH |
sahilmgandhi | 18:6a4db94011d3 | 160 | program operations. |
sahilmgandhi | 18:6a4db94011d3 | 161 | |
sahilmgandhi | 18:6a4db94011d3 | 162 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 163 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 164 | */ |
sahilmgandhi | 18:6a4db94011d3 | 165 | |
sahilmgandhi | 18:6a4db94011d3 | 166 | /** |
sahilmgandhi | 18:6a4db94011d3 | 167 | * @brief Program byte, halfword, word or double word at a specified address |
sahilmgandhi | 18:6a4db94011d3 | 168 | * @param TypeProgram: Indicate the way to program at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 169 | * This parameter can be a value of @ref FLASH_Type_Program |
sahilmgandhi | 18:6a4db94011d3 | 170 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 171 | * @param Data: specifies the data to be programmed |
sahilmgandhi | 18:6a4db94011d3 | 172 | * |
sahilmgandhi | 18:6a4db94011d3 | 173 | * @retval HAL_StatusTypeDef HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 174 | */ |
sahilmgandhi | 18:6a4db94011d3 | 175 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 176 | { |
sahilmgandhi | 18:6a4db94011d3 | 177 | HAL_StatusTypeDef status = HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 178 | |
sahilmgandhi | 18:6a4db94011d3 | 179 | /* Process Locked */ |
sahilmgandhi | 18:6a4db94011d3 | 180 | __HAL_LOCK(&pFlash); |
sahilmgandhi | 18:6a4db94011d3 | 181 | |
sahilmgandhi | 18:6a4db94011d3 | 182 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 183 | assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram)); |
sahilmgandhi | 18:6a4db94011d3 | 184 | |
sahilmgandhi | 18:6a4db94011d3 | 185 | /* Wait for last operation to be completed */ |
sahilmgandhi | 18:6a4db94011d3 | 186 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
sahilmgandhi | 18:6a4db94011d3 | 187 | |
sahilmgandhi | 18:6a4db94011d3 | 188 | if(status == HAL_OK) |
sahilmgandhi | 18:6a4db94011d3 | 189 | { |
sahilmgandhi | 18:6a4db94011d3 | 190 | if(TypeProgram == FLASH_TYPEPROGRAM_BYTE) |
sahilmgandhi | 18:6a4db94011d3 | 191 | { |
sahilmgandhi | 18:6a4db94011d3 | 192 | /*Program byte (8-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 193 | FLASH_Program_Byte(Address, (uint8_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 194 | } |
sahilmgandhi | 18:6a4db94011d3 | 195 | else if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD) |
sahilmgandhi | 18:6a4db94011d3 | 196 | { |
sahilmgandhi | 18:6a4db94011d3 | 197 | /*Program halfword (16-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 198 | FLASH_Program_HalfWord(Address, (uint16_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 199 | } |
sahilmgandhi | 18:6a4db94011d3 | 200 | else if(TypeProgram == FLASH_TYPEPROGRAM_WORD) |
sahilmgandhi | 18:6a4db94011d3 | 201 | { |
sahilmgandhi | 18:6a4db94011d3 | 202 | /*Program word (32-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 203 | FLASH_Program_Word(Address, (uint32_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 204 | } |
sahilmgandhi | 18:6a4db94011d3 | 205 | else |
sahilmgandhi | 18:6a4db94011d3 | 206 | { |
sahilmgandhi | 18:6a4db94011d3 | 207 | /*Program double word (64-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 208 | FLASH_Program_DoubleWord(Address, Data); |
sahilmgandhi | 18:6a4db94011d3 | 209 | } |
sahilmgandhi | 18:6a4db94011d3 | 210 | |
sahilmgandhi | 18:6a4db94011d3 | 211 | /* Wait for last operation to be completed */ |
sahilmgandhi | 18:6a4db94011d3 | 212 | status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE); |
sahilmgandhi | 18:6a4db94011d3 | 213 | |
sahilmgandhi | 18:6a4db94011d3 | 214 | /* If the program operation is completed, disable the PG Bit */ |
sahilmgandhi | 18:6a4db94011d3 | 215 | FLASH->CR &= (~FLASH_CR_PG); |
sahilmgandhi | 18:6a4db94011d3 | 216 | } |
sahilmgandhi | 18:6a4db94011d3 | 217 | |
sahilmgandhi | 18:6a4db94011d3 | 218 | /* Process Unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 219 | __HAL_UNLOCK(&pFlash); |
sahilmgandhi | 18:6a4db94011d3 | 220 | |
sahilmgandhi | 18:6a4db94011d3 | 221 | return status; |
sahilmgandhi | 18:6a4db94011d3 | 222 | } |
sahilmgandhi | 18:6a4db94011d3 | 223 | |
sahilmgandhi | 18:6a4db94011d3 | 224 | /** |
sahilmgandhi | 18:6a4db94011d3 | 225 | * @brief Program byte, halfword, word or double word at a specified address with interrupt enabled. |
sahilmgandhi | 18:6a4db94011d3 | 226 | * @param TypeProgram: Indicate the way to program at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 227 | * This parameter can be a value of @ref FLASH_Type_Program |
sahilmgandhi | 18:6a4db94011d3 | 228 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 229 | * @param Data: specifies the data to be programmed |
sahilmgandhi | 18:6a4db94011d3 | 230 | * |
sahilmgandhi | 18:6a4db94011d3 | 231 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 232 | */ |
sahilmgandhi | 18:6a4db94011d3 | 233 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 234 | { |
sahilmgandhi | 18:6a4db94011d3 | 235 | HAL_StatusTypeDef status = HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 236 | |
sahilmgandhi | 18:6a4db94011d3 | 237 | /* Process Locked */ |
sahilmgandhi | 18:6a4db94011d3 | 238 | __HAL_LOCK(&pFlash); |
sahilmgandhi | 18:6a4db94011d3 | 239 | |
sahilmgandhi | 18:6a4db94011d3 | 240 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 241 | assert_param(IS_FLASH_TYPEPROGRAM(TypeProgram)); |
sahilmgandhi | 18:6a4db94011d3 | 242 | |
sahilmgandhi | 18:6a4db94011d3 | 243 | /* Enable End of FLASH Operation interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 244 | __HAL_FLASH_ENABLE_IT(FLASH_IT_EOP); |
sahilmgandhi | 18:6a4db94011d3 | 245 | |
sahilmgandhi | 18:6a4db94011d3 | 246 | /* Enable Error source interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 247 | __HAL_FLASH_ENABLE_IT(FLASH_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 248 | |
sahilmgandhi | 18:6a4db94011d3 | 249 | pFlash.ProcedureOnGoing = FLASH_PROC_PROGRAM; |
sahilmgandhi | 18:6a4db94011d3 | 250 | pFlash.Address = Address; |
sahilmgandhi | 18:6a4db94011d3 | 251 | |
sahilmgandhi | 18:6a4db94011d3 | 252 | if(TypeProgram == FLASH_TYPEPROGRAM_BYTE) |
sahilmgandhi | 18:6a4db94011d3 | 253 | { |
sahilmgandhi | 18:6a4db94011d3 | 254 | /*Program byte (8-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 255 | FLASH_Program_Byte(Address, (uint8_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 256 | } |
sahilmgandhi | 18:6a4db94011d3 | 257 | else if(TypeProgram == FLASH_TYPEPROGRAM_HALFWORD) |
sahilmgandhi | 18:6a4db94011d3 | 258 | { |
sahilmgandhi | 18:6a4db94011d3 | 259 | /*Program halfword (16-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 260 | FLASH_Program_HalfWord(Address, (uint16_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 261 | } |
sahilmgandhi | 18:6a4db94011d3 | 262 | else if(TypeProgram == FLASH_TYPEPROGRAM_WORD) |
sahilmgandhi | 18:6a4db94011d3 | 263 | { |
sahilmgandhi | 18:6a4db94011d3 | 264 | /*Program word (32-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 265 | FLASH_Program_Word(Address, (uint32_t) Data); |
sahilmgandhi | 18:6a4db94011d3 | 266 | } |
sahilmgandhi | 18:6a4db94011d3 | 267 | else |
sahilmgandhi | 18:6a4db94011d3 | 268 | { |
sahilmgandhi | 18:6a4db94011d3 | 269 | /*Program double word (64-bit) at a specified address.*/ |
sahilmgandhi | 18:6a4db94011d3 | 270 | FLASH_Program_DoubleWord(Address, Data); |
sahilmgandhi | 18:6a4db94011d3 | 271 | } |
sahilmgandhi | 18:6a4db94011d3 | 272 | |
sahilmgandhi | 18:6a4db94011d3 | 273 | return status; |
sahilmgandhi | 18:6a4db94011d3 | 274 | } |
sahilmgandhi | 18:6a4db94011d3 | 275 | |
sahilmgandhi | 18:6a4db94011d3 | 276 | /** |
sahilmgandhi | 18:6a4db94011d3 | 277 | * @brief This function handles FLASH interrupt request. |
sahilmgandhi | 18:6a4db94011d3 | 278 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 279 | */ |
sahilmgandhi | 18:6a4db94011d3 | 280 | void HAL_FLASH_IRQHandler(void) |
sahilmgandhi | 18:6a4db94011d3 | 281 | { |
sahilmgandhi | 18:6a4db94011d3 | 282 | uint32_t addresstmp = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 283 | |
sahilmgandhi | 18:6a4db94011d3 | 284 | /* Check FLASH operation error flags */ |
sahilmgandhi | 18:6a4db94011d3 | 285 | if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ |
sahilmgandhi | 18:6a4db94011d3 | 286 | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR )) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 287 | { |
sahilmgandhi | 18:6a4db94011d3 | 288 | if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) |
sahilmgandhi | 18:6a4db94011d3 | 289 | { |
sahilmgandhi | 18:6a4db94011d3 | 290 | /*return the faulty sector*/ |
sahilmgandhi | 18:6a4db94011d3 | 291 | addresstmp = pFlash.Sector; |
sahilmgandhi | 18:6a4db94011d3 | 292 | pFlash.Sector = 0xFFFFFFFFU; |
sahilmgandhi | 18:6a4db94011d3 | 293 | } |
sahilmgandhi | 18:6a4db94011d3 | 294 | else if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE) |
sahilmgandhi | 18:6a4db94011d3 | 295 | { |
sahilmgandhi | 18:6a4db94011d3 | 296 | /*return the faulty bank*/ |
sahilmgandhi | 18:6a4db94011d3 | 297 | addresstmp = pFlash.Bank; |
sahilmgandhi | 18:6a4db94011d3 | 298 | } |
sahilmgandhi | 18:6a4db94011d3 | 299 | else |
sahilmgandhi | 18:6a4db94011d3 | 300 | { |
sahilmgandhi | 18:6a4db94011d3 | 301 | /*return the faulty address*/ |
sahilmgandhi | 18:6a4db94011d3 | 302 | addresstmp = pFlash.Address; |
sahilmgandhi | 18:6a4db94011d3 | 303 | } |
sahilmgandhi | 18:6a4db94011d3 | 304 | |
sahilmgandhi | 18:6a4db94011d3 | 305 | /*Save the Error code*/ |
sahilmgandhi | 18:6a4db94011d3 | 306 | FLASH_SetErrorCode(); |
sahilmgandhi | 18:6a4db94011d3 | 307 | |
sahilmgandhi | 18:6a4db94011d3 | 308 | /* FLASH error interrupt user callback */ |
sahilmgandhi | 18:6a4db94011d3 | 309 | HAL_FLASH_OperationErrorCallback(addresstmp); |
sahilmgandhi | 18:6a4db94011d3 | 310 | |
sahilmgandhi | 18:6a4db94011d3 | 311 | /*Stop the procedure ongoing*/ |
sahilmgandhi | 18:6a4db94011d3 | 312 | pFlash.ProcedureOnGoing = FLASH_PROC_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 313 | } |
sahilmgandhi | 18:6a4db94011d3 | 314 | |
sahilmgandhi | 18:6a4db94011d3 | 315 | /* Check FLASH End of Operation flag */ |
sahilmgandhi | 18:6a4db94011d3 | 316 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 317 | { |
sahilmgandhi | 18:6a4db94011d3 | 318 | /* Clear FLASH End of Operation pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 319 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP); |
sahilmgandhi | 18:6a4db94011d3 | 320 | |
sahilmgandhi | 18:6a4db94011d3 | 321 | if(pFlash.ProcedureOnGoing == FLASH_PROC_SECTERASE) |
sahilmgandhi | 18:6a4db94011d3 | 322 | { |
sahilmgandhi | 18:6a4db94011d3 | 323 | /*Nb of sector to erased can be decreased*/ |
sahilmgandhi | 18:6a4db94011d3 | 324 | pFlash.NbSectorsToErase--; |
sahilmgandhi | 18:6a4db94011d3 | 325 | |
sahilmgandhi | 18:6a4db94011d3 | 326 | /* Check if there are still sectors to erase*/ |
sahilmgandhi | 18:6a4db94011d3 | 327 | if(pFlash.NbSectorsToErase != 0U) |
sahilmgandhi | 18:6a4db94011d3 | 328 | { |
sahilmgandhi | 18:6a4db94011d3 | 329 | addresstmp = pFlash.Sector; |
sahilmgandhi | 18:6a4db94011d3 | 330 | /*Indicate user which sector has been erased*/ |
sahilmgandhi | 18:6a4db94011d3 | 331 | HAL_FLASH_EndOfOperationCallback(addresstmp); |
sahilmgandhi | 18:6a4db94011d3 | 332 | |
sahilmgandhi | 18:6a4db94011d3 | 333 | /*Increment sector number*/ |
sahilmgandhi | 18:6a4db94011d3 | 334 | pFlash.Sector++; |
sahilmgandhi | 18:6a4db94011d3 | 335 | addresstmp = pFlash.Sector; |
sahilmgandhi | 18:6a4db94011d3 | 336 | FLASH_Erase_Sector(addresstmp, pFlash.VoltageForErase); |
sahilmgandhi | 18:6a4db94011d3 | 337 | } |
sahilmgandhi | 18:6a4db94011d3 | 338 | else |
sahilmgandhi | 18:6a4db94011d3 | 339 | { |
sahilmgandhi | 18:6a4db94011d3 | 340 | /*No more sectors to Erase, user callback can be called.*/ |
sahilmgandhi | 18:6a4db94011d3 | 341 | /*Reset Sector and stop Erase sectors procedure*/ |
sahilmgandhi | 18:6a4db94011d3 | 342 | pFlash.Sector = addresstmp = 0xFFFFFFFFU; |
sahilmgandhi | 18:6a4db94011d3 | 343 | pFlash.ProcedureOnGoing = FLASH_PROC_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 344 | |
sahilmgandhi | 18:6a4db94011d3 | 345 | /* Flush the caches to be sure of the data consistency */ |
sahilmgandhi | 18:6a4db94011d3 | 346 | FLASH_FlushCaches() ; |
sahilmgandhi | 18:6a4db94011d3 | 347 | |
sahilmgandhi | 18:6a4db94011d3 | 348 | /* FLASH EOP interrupt user callback */ |
sahilmgandhi | 18:6a4db94011d3 | 349 | HAL_FLASH_EndOfOperationCallback(addresstmp); |
sahilmgandhi | 18:6a4db94011d3 | 350 | } |
sahilmgandhi | 18:6a4db94011d3 | 351 | } |
sahilmgandhi | 18:6a4db94011d3 | 352 | else |
sahilmgandhi | 18:6a4db94011d3 | 353 | { |
sahilmgandhi | 18:6a4db94011d3 | 354 | if(pFlash.ProcedureOnGoing == FLASH_PROC_MASSERASE) |
sahilmgandhi | 18:6a4db94011d3 | 355 | { |
sahilmgandhi | 18:6a4db94011d3 | 356 | /* MassErase ended. Return the selected bank */ |
sahilmgandhi | 18:6a4db94011d3 | 357 | /* Flush the caches to be sure of the data consistency */ |
sahilmgandhi | 18:6a4db94011d3 | 358 | FLASH_FlushCaches() ; |
sahilmgandhi | 18:6a4db94011d3 | 359 | |
sahilmgandhi | 18:6a4db94011d3 | 360 | /* FLASH EOP interrupt user callback */ |
sahilmgandhi | 18:6a4db94011d3 | 361 | HAL_FLASH_EndOfOperationCallback(pFlash.Bank); |
sahilmgandhi | 18:6a4db94011d3 | 362 | } |
sahilmgandhi | 18:6a4db94011d3 | 363 | else |
sahilmgandhi | 18:6a4db94011d3 | 364 | { |
sahilmgandhi | 18:6a4db94011d3 | 365 | /*Program ended. Return the selected address*/ |
sahilmgandhi | 18:6a4db94011d3 | 366 | /* FLASH EOP interrupt user callback */ |
sahilmgandhi | 18:6a4db94011d3 | 367 | HAL_FLASH_EndOfOperationCallback(pFlash.Address); |
sahilmgandhi | 18:6a4db94011d3 | 368 | } |
sahilmgandhi | 18:6a4db94011d3 | 369 | pFlash.ProcedureOnGoing = FLASH_PROC_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 370 | } |
sahilmgandhi | 18:6a4db94011d3 | 371 | } |
sahilmgandhi | 18:6a4db94011d3 | 372 | |
sahilmgandhi | 18:6a4db94011d3 | 373 | if(pFlash.ProcedureOnGoing == FLASH_PROC_NONE) |
sahilmgandhi | 18:6a4db94011d3 | 374 | { |
sahilmgandhi | 18:6a4db94011d3 | 375 | /* Operation is completed, disable the PG, SER, SNB and MER Bits */ |
sahilmgandhi | 18:6a4db94011d3 | 376 | CLEAR_BIT(FLASH->CR, (FLASH_CR_PG | FLASH_CR_SER | FLASH_CR_SNB | FLASH_MER_BIT)); |
sahilmgandhi | 18:6a4db94011d3 | 377 | |
sahilmgandhi | 18:6a4db94011d3 | 378 | /* Disable End of FLASH Operation interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 379 | __HAL_FLASH_DISABLE_IT(FLASH_IT_EOP); |
sahilmgandhi | 18:6a4db94011d3 | 380 | |
sahilmgandhi | 18:6a4db94011d3 | 381 | /* Disable Error source interrupt */ |
sahilmgandhi | 18:6a4db94011d3 | 382 | __HAL_FLASH_DISABLE_IT(FLASH_IT_ERR); |
sahilmgandhi | 18:6a4db94011d3 | 383 | |
sahilmgandhi | 18:6a4db94011d3 | 384 | /* Process Unlocked */ |
sahilmgandhi | 18:6a4db94011d3 | 385 | __HAL_UNLOCK(&pFlash); |
sahilmgandhi | 18:6a4db94011d3 | 386 | } |
sahilmgandhi | 18:6a4db94011d3 | 387 | } |
sahilmgandhi | 18:6a4db94011d3 | 388 | |
sahilmgandhi | 18:6a4db94011d3 | 389 | /** |
sahilmgandhi | 18:6a4db94011d3 | 390 | * @brief FLASH end of operation interrupt callback |
sahilmgandhi | 18:6a4db94011d3 | 391 | * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure |
sahilmgandhi | 18:6a4db94011d3 | 392 | * Mass Erase: Bank number which has been requested to erase |
sahilmgandhi | 18:6a4db94011d3 | 393 | * Sectors Erase: Sector which has been erased |
sahilmgandhi | 18:6a4db94011d3 | 394 | * (if 0xFFFFFFFF, it means that all the selected sectors have been erased) |
sahilmgandhi | 18:6a4db94011d3 | 395 | * Program: Address which was selected for data program |
sahilmgandhi | 18:6a4db94011d3 | 396 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 397 | */ |
sahilmgandhi | 18:6a4db94011d3 | 398 | __weak void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue) |
sahilmgandhi | 18:6a4db94011d3 | 399 | { |
sahilmgandhi | 18:6a4db94011d3 | 400 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 401 | UNUSED(ReturnValue); |
sahilmgandhi | 18:6a4db94011d3 | 402 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 403 | the HAL_FLASH_EndOfOperationCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 404 | */ |
sahilmgandhi | 18:6a4db94011d3 | 405 | } |
sahilmgandhi | 18:6a4db94011d3 | 406 | |
sahilmgandhi | 18:6a4db94011d3 | 407 | /** |
sahilmgandhi | 18:6a4db94011d3 | 408 | * @brief FLASH operation error interrupt callback |
sahilmgandhi | 18:6a4db94011d3 | 409 | * @param ReturnValue: The value saved in this parameter depends on the ongoing procedure |
sahilmgandhi | 18:6a4db94011d3 | 410 | * Mass Erase: Bank number which has been requested to erase |
sahilmgandhi | 18:6a4db94011d3 | 411 | * Sectors Erase: Sector number which returned an error |
sahilmgandhi | 18:6a4db94011d3 | 412 | * Program: Address which was selected for data program |
sahilmgandhi | 18:6a4db94011d3 | 413 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 414 | */ |
sahilmgandhi | 18:6a4db94011d3 | 415 | __weak void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue) |
sahilmgandhi | 18:6a4db94011d3 | 416 | { |
sahilmgandhi | 18:6a4db94011d3 | 417 | /* Prevent unused argument(s) compilation warning */ |
sahilmgandhi | 18:6a4db94011d3 | 418 | UNUSED(ReturnValue); |
sahilmgandhi | 18:6a4db94011d3 | 419 | /* NOTE : This function Should not be modified, when the callback is needed, |
sahilmgandhi | 18:6a4db94011d3 | 420 | the HAL_FLASH_OperationErrorCallback could be implemented in the user file |
sahilmgandhi | 18:6a4db94011d3 | 421 | */ |
sahilmgandhi | 18:6a4db94011d3 | 422 | } |
sahilmgandhi | 18:6a4db94011d3 | 423 | |
sahilmgandhi | 18:6a4db94011d3 | 424 | /** |
sahilmgandhi | 18:6a4db94011d3 | 425 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 426 | */ |
sahilmgandhi | 18:6a4db94011d3 | 427 | |
sahilmgandhi | 18:6a4db94011d3 | 428 | /** @defgroup FLASH_Exported_Functions_Group2 Peripheral Control functions |
sahilmgandhi | 18:6a4db94011d3 | 429 | * @brief management functions |
sahilmgandhi | 18:6a4db94011d3 | 430 | * |
sahilmgandhi | 18:6a4db94011d3 | 431 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 432 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 433 | ##### Peripheral Control functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 434 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 435 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 436 | This subsection provides a set of functions allowing to control the FLASH |
sahilmgandhi | 18:6a4db94011d3 | 437 | memory operations. |
sahilmgandhi | 18:6a4db94011d3 | 438 | |
sahilmgandhi | 18:6a4db94011d3 | 439 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 440 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 441 | */ |
sahilmgandhi | 18:6a4db94011d3 | 442 | |
sahilmgandhi | 18:6a4db94011d3 | 443 | /** |
sahilmgandhi | 18:6a4db94011d3 | 444 | * @brief Unlock the FLASH control register access |
sahilmgandhi | 18:6a4db94011d3 | 445 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 446 | */ |
sahilmgandhi | 18:6a4db94011d3 | 447 | HAL_StatusTypeDef HAL_FLASH_Unlock(void) |
sahilmgandhi | 18:6a4db94011d3 | 448 | { |
sahilmgandhi | 18:6a4db94011d3 | 449 | if((FLASH->CR & FLASH_CR_LOCK) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 450 | { |
sahilmgandhi | 18:6a4db94011d3 | 451 | /* Authorize the FLASH Registers access */ |
sahilmgandhi | 18:6a4db94011d3 | 452 | FLASH->KEYR = FLASH_KEY1; |
sahilmgandhi | 18:6a4db94011d3 | 453 | FLASH->KEYR = FLASH_KEY2; |
sahilmgandhi | 18:6a4db94011d3 | 454 | } |
sahilmgandhi | 18:6a4db94011d3 | 455 | else |
sahilmgandhi | 18:6a4db94011d3 | 456 | { |
sahilmgandhi | 18:6a4db94011d3 | 457 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 458 | } |
sahilmgandhi | 18:6a4db94011d3 | 459 | |
sahilmgandhi | 18:6a4db94011d3 | 460 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 461 | } |
sahilmgandhi | 18:6a4db94011d3 | 462 | |
sahilmgandhi | 18:6a4db94011d3 | 463 | /** |
sahilmgandhi | 18:6a4db94011d3 | 464 | * @brief Locks the FLASH control register access |
sahilmgandhi | 18:6a4db94011d3 | 465 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 466 | */ |
sahilmgandhi | 18:6a4db94011d3 | 467 | HAL_StatusTypeDef HAL_FLASH_Lock(void) |
sahilmgandhi | 18:6a4db94011d3 | 468 | { |
sahilmgandhi | 18:6a4db94011d3 | 469 | /* Set the LOCK Bit to lock the FLASH Registers access */ |
sahilmgandhi | 18:6a4db94011d3 | 470 | FLASH->CR |= FLASH_CR_LOCK; |
sahilmgandhi | 18:6a4db94011d3 | 471 | |
sahilmgandhi | 18:6a4db94011d3 | 472 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 473 | } |
sahilmgandhi | 18:6a4db94011d3 | 474 | |
sahilmgandhi | 18:6a4db94011d3 | 475 | /** |
sahilmgandhi | 18:6a4db94011d3 | 476 | * @brief Unlock the FLASH Option Control Registers access. |
sahilmgandhi | 18:6a4db94011d3 | 477 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 478 | */ |
sahilmgandhi | 18:6a4db94011d3 | 479 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void) |
sahilmgandhi | 18:6a4db94011d3 | 480 | { |
sahilmgandhi | 18:6a4db94011d3 | 481 | if((FLASH->OPTCR & FLASH_OPTCR_OPTLOCK) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 482 | { |
sahilmgandhi | 18:6a4db94011d3 | 483 | /* Authorizes the Option Byte register programming */ |
sahilmgandhi | 18:6a4db94011d3 | 484 | FLASH->OPTKEYR = FLASH_OPT_KEY1; |
sahilmgandhi | 18:6a4db94011d3 | 485 | FLASH->OPTKEYR = FLASH_OPT_KEY2; |
sahilmgandhi | 18:6a4db94011d3 | 486 | } |
sahilmgandhi | 18:6a4db94011d3 | 487 | else |
sahilmgandhi | 18:6a4db94011d3 | 488 | { |
sahilmgandhi | 18:6a4db94011d3 | 489 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 490 | } |
sahilmgandhi | 18:6a4db94011d3 | 491 | |
sahilmgandhi | 18:6a4db94011d3 | 492 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 493 | } |
sahilmgandhi | 18:6a4db94011d3 | 494 | |
sahilmgandhi | 18:6a4db94011d3 | 495 | /** |
sahilmgandhi | 18:6a4db94011d3 | 496 | * @brief Lock the FLASH Option Control Registers access. |
sahilmgandhi | 18:6a4db94011d3 | 497 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 498 | */ |
sahilmgandhi | 18:6a4db94011d3 | 499 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void) |
sahilmgandhi | 18:6a4db94011d3 | 500 | { |
sahilmgandhi | 18:6a4db94011d3 | 501 | /* Set the OPTLOCK Bit to lock the FLASH Option Byte Registers access */ |
sahilmgandhi | 18:6a4db94011d3 | 502 | FLASH->OPTCR |= FLASH_OPTCR_OPTLOCK; |
sahilmgandhi | 18:6a4db94011d3 | 503 | |
sahilmgandhi | 18:6a4db94011d3 | 504 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 505 | } |
sahilmgandhi | 18:6a4db94011d3 | 506 | |
sahilmgandhi | 18:6a4db94011d3 | 507 | /** |
sahilmgandhi | 18:6a4db94011d3 | 508 | * @brief Launch the option byte loading. |
sahilmgandhi | 18:6a4db94011d3 | 509 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 510 | */ |
sahilmgandhi | 18:6a4db94011d3 | 511 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void) |
sahilmgandhi | 18:6a4db94011d3 | 512 | { |
sahilmgandhi | 18:6a4db94011d3 | 513 | /* Set the OPTSTRT bit in OPTCR register */ |
sahilmgandhi | 18:6a4db94011d3 | 514 | *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= FLASH_OPTCR_OPTSTRT; |
sahilmgandhi | 18:6a4db94011d3 | 515 | |
sahilmgandhi | 18:6a4db94011d3 | 516 | /* Wait for last operation to be completed */ |
sahilmgandhi | 18:6a4db94011d3 | 517 | return(FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE)); |
sahilmgandhi | 18:6a4db94011d3 | 518 | } |
sahilmgandhi | 18:6a4db94011d3 | 519 | |
sahilmgandhi | 18:6a4db94011d3 | 520 | /** |
sahilmgandhi | 18:6a4db94011d3 | 521 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 522 | */ |
sahilmgandhi | 18:6a4db94011d3 | 523 | |
sahilmgandhi | 18:6a4db94011d3 | 524 | /** @defgroup FLASH_Exported_Functions_Group3 Peripheral State and Errors functions |
sahilmgandhi | 18:6a4db94011d3 | 525 | * @brief Peripheral Errors functions |
sahilmgandhi | 18:6a4db94011d3 | 526 | * |
sahilmgandhi | 18:6a4db94011d3 | 527 | @verbatim |
sahilmgandhi | 18:6a4db94011d3 | 528 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 529 | ##### Peripheral Errors functions ##### |
sahilmgandhi | 18:6a4db94011d3 | 530 | =============================================================================== |
sahilmgandhi | 18:6a4db94011d3 | 531 | [..] |
sahilmgandhi | 18:6a4db94011d3 | 532 | This subsection permits to get in run-time Errors of the FLASH peripheral. |
sahilmgandhi | 18:6a4db94011d3 | 533 | |
sahilmgandhi | 18:6a4db94011d3 | 534 | @endverbatim |
sahilmgandhi | 18:6a4db94011d3 | 535 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 536 | */ |
sahilmgandhi | 18:6a4db94011d3 | 537 | |
sahilmgandhi | 18:6a4db94011d3 | 538 | /** |
sahilmgandhi | 18:6a4db94011d3 | 539 | * @brief Get the specific FLASH error flag. |
sahilmgandhi | 18:6a4db94011d3 | 540 | * @retval FLASH_ErrorCode: The returned value can be a combination of: |
sahilmgandhi | 18:6a4db94011d3 | 541 | * @arg HAL_FLASH_ERROR_NONE: FLASH Programming Sequence error flag |
sahilmgandhi | 18:6a4db94011d3 | 542 | * @arg HAL_FLASH_ERROR_PGS: FLASH Programming Sequence error flag |
sahilmgandhi | 18:6a4db94011d3 | 543 | * @arg HAL_FLASH_ERROR_PGP: FLASH Programming Parallelism error flag |
sahilmgandhi | 18:6a4db94011d3 | 544 | * @arg HAL_FLASH_ERROR_PGA: FLASH Programming Alignment error flag |
sahilmgandhi | 18:6a4db94011d3 | 545 | * @arg HAL_FLASH_ERROR_WRP: FLASH Write protected error flag |
sahilmgandhi | 18:6a4db94011d3 | 546 | * @arg HAL_FLASH_ERROR_OPERATION: FLASH operation Error flag |
sahilmgandhi | 18:6a4db94011d3 | 547 | */ |
sahilmgandhi | 18:6a4db94011d3 | 548 | uint32_t HAL_FLASH_GetError(void) |
sahilmgandhi | 18:6a4db94011d3 | 549 | { |
sahilmgandhi | 18:6a4db94011d3 | 550 | return pFlash.ErrorCode; |
sahilmgandhi | 18:6a4db94011d3 | 551 | } |
sahilmgandhi | 18:6a4db94011d3 | 552 | |
sahilmgandhi | 18:6a4db94011d3 | 553 | /** |
sahilmgandhi | 18:6a4db94011d3 | 554 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 555 | */ |
sahilmgandhi | 18:6a4db94011d3 | 556 | |
sahilmgandhi | 18:6a4db94011d3 | 557 | /** |
sahilmgandhi | 18:6a4db94011d3 | 558 | * @brief Wait for a FLASH operation to complete. |
sahilmgandhi | 18:6a4db94011d3 | 559 | * @param Timeout: maximum flash operationtimeout |
sahilmgandhi | 18:6a4db94011d3 | 560 | * @retval HAL Status |
sahilmgandhi | 18:6a4db94011d3 | 561 | */ |
sahilmgandhi | 18:6a4db94011d3 | 562 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout) |
sahilmgandhi | 18:6a4db94011d3 | 563 | { |
sahilmgandhi | 18:6a4db94011d3 | 564 | uint32_t tickstart = 0U; |
sahilmgandhi | 18:6a4db94011d3 | 565 | |
sahilmgandhi | 18:6a4db94011d3 | 566 | /* Clear Error Code */ |
sahilmgandhi | 18:6a4db94011d3 | 567 | pFlash.ErrorCode = HAL_FLASH_ERROR_NONE; |
sahilmgandhi | 18:6a4db94011d3 | 568 | |
sahilmgandhi | 18:6a4db94011d3 | 569 | /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset. |
sahilmgandhi | 18:6a4db94011d3 | 570 | Even if the FLASH operation fails, the BUSY flag will be reset and an error |
sahilmgandhi | 18:6a4db94011d3 | 571 | flag will be set */ |
sahilmgandhi | 18:6a4db94011d3 | 572 | /* Get tick */ |
sahilmgandhi | 18:6a4db94011d3 | 573 | tickstart = HAL_GetTick(); |
sahilmgandhi | 18:6a4db94011d3 | 574 | |
sahilmgandhi | 18:6a4db94011d3 | 575 | while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 576 | { |
sahilmgandhi | 18:6a4db94011d3 | 577 | if(Timeout != HAL_MAX_DELAY) |
sahilmgandhi | 18:6a4db94011d3 | 578 | { |
sahilmgandhi | 18:6a4db94011d3 | 579 | if((Timeout == 0U)||((HAL_GetTick() - tickstart ) > Timeout)) |
sahilmgandhi | 18:6a4db94011d3 | 580 | { |
sahilmgandhi | 18:6a4db94011d3 | 581 | return HAL_TIMEOUT; |
sahilmgandhi | 18:6a4db94011d3 | 582 | } |
sahilmgandhi | 18:6a4db94011d3 | 583 | } |
sahilmgandhi | 18:6a4db94011d3 | 584 | } |
sahilmgandhi | 18:6a4db94011d3 | 585 | |
sahilmgandhi | 18:6a4db94011d3 | 586 | /* Check FLASH End of Operation flag */ |
sahilmgandhi | 18:6a4db94011d3 | 587 | if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP)) |
sahilmgandhi | 18:6a4db94011d3 | 588 | { |
sahilmgandhi | 18:6a4db94011d3 | 589 | /* Clear FLASH End of Operation pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 590 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP); |
sahilmgandhi | 18:6a4db94011d3 | 591 | } |
sahilmgandhi | 18:6a4db94011d3 | 592 | |
sahilmgandhi | 18:6a4db94011d3 | 593 | if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \ |
sahilmgandhi | 18:6a4db94011d3 | 594 | FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR)) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 595 | { |
sahilmgandhi | 18:6a4db94011d3 | 596 | /*Save the error code*/ |
sahilmgandhi | 18:6a4db94011d3 | 597 | FLASH_SetErrorCode(); |
sahilmgandhi | 18:6a4db94011d3 | 598 | return HAL_ERROR; |
sahilmgandhi | 18:6a4db94011d3 | 599 | } |
sahilmgandhi | 18:6a4db94011d3 | 600 | |
sahilmgandhi | 18:6a4db94011d3 | 601 | /* If there is no error flag set */ |
sahilmgandhi | 18:6a4db94011d3 | 602 | return HAL_OK; |
sahilmgandhi | 18:6a4db94011d3 | 603 | |
sahilmgandhi | 18:6a4db94011d3 | 604 | } |
sahilmgandhi | 18:6a4db94011d3 | 605 | |
sahilmgandhi | 18:6a4db94011d3 | 606 | /** |
sahilmgandhi | 18:6a4db94011d3 | 607 | * @brief Program a double word (64-bit) at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 608 | * @note This function must be used when the device voltage range is from |
sahilmgandhi | 18:6a4db94011d3 | 609 | * 2.7V to 3.6V and an External Vpp in the range 7V to 9V. |
sahilmgandhi | 18:6a4db94011d3 | 610 | * |
sahilmgandhi | 18:6a4db94011d3 | 611 | * @note If an erase and a program operations are requested simultaneously, |
sahilmgandhi | 18:6a4db94011d3 | 612 | * the erase operation is performed before the program one. |
sahilmgandhi | 18:6a4db94011d3 | 613 | * |
sahilmgandhi | 18:6a4db94011d3 | 614 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 615 | * @param Data: specifies the data to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 616 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 617 | */ |
sahilmgandhi | 18:6a4db94011d3 | 618 | static void FLASH_Program_DoubleWord(uint32_t Address, uint64_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 619 | { |
sahilmgandhi | 18:6a4db94011d3 | 620 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 621 | assert_param(IS_FLASH_ADDRESS(Address)); |
sahilmgandhi | 18:6a4db94011d3 | 622 | |
sahilmgandhi | 18:6a4db94011d3 | 623 | /* If the previous operation is completed, proceed to program the new data */ |
sahilmgandhi | 18:6a4db94011d3 | 624 | CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE); |
sahilmgandhi | 18:6a4db94011d3 | 625 | FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD; |
sahilmgandhi | 18:6a4db94011d3 | 626 | FLASH->CR |= FLASH_CR_PG; |
sahilmgandhi | 18:6a4db94011d3 | 627 | |
sahilmgandhi | 18:6a4db94011d3 | 628 | *(__IO uint64_t*)Address = Data; |
sahilmgandhi | 18:6a4db94011d3 | 629 | } |
sahilmgandhi | 18:6a4db94011d3 | 630 | |
sahilmgandhi | 18:6a4db94011d3 | 631 | |
sahilmgandhi | 18:6a4db94011d3 | 632 | /** |
sahilmgandhi | 18:6a4db94011d3 | 633 | * @brief Program word (32-bit) at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 634 | * @note This function must be used when the device voltage range is from |
sahilmgandhi | 18:6a4db94011d3 | 635 | * 2.7V to 3.6V. |
sahilmgandhi | 18:6a4db94011d3 | 636 | * |
sahilmgandhi | 18:6a4db94011d3 | 637 | * @note If an erase and a program operations are requested simultaneously, |
sahilmgandhi | 18:6a4db94011d3 | 638 | * the erase operation is performed before the program one. |
sahilmgandhi | 18:6a4db94011d3 | 639 | * |
sahilmgandhi | 18:6a4db94011d3 | 640 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 641 | * @param Data: specifies the data to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 642 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 643 | */ |
sahilmgandhi | 18:6a4db94011d3 | 644 | static void FLASH_Program_Word(uint32_t Address, uint32_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 645 | { |
sahilmgandhi | 18:6a4db94011d3 | 646 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 647 | assert_param(IS_FLASH_ADDRESS(Address)); |
sahilmgandhi | 18:6a4db94011d3 | 648 | |
sahilmgandhi | 18:6a4db94011d3 | 649 | /* If the previous operation is completed, proceed to program the new data */ |
sahilmgandhi | 18:6a4db94011d3 | 650 | CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE); |
sahilmgandhi | 18:6a4db94011d3 | 651 | FLASH->CR |= FLASH_PSIZE_WORD; |
sahilmgandhi | 18:6a4db94011d3 | 652 | FLASH->CR |= FLASH_CR_PG; |
sahilmgandhi | 18:6a4db94011d3 | 653 | |
sahilmgandhi | 18:6a4db94011d3 | 654 | *(__IO uint32_t*)Address = Data; |
sahilmgandhi | 18:6a4db94011d3 | 655 | } |
sahilmgandhi | 18:6a4db94011d3 | 656 | |
sahilmgandhi | 18:6a4db94011d3 | 657 | /** |
sahilmgandhi | 18:6a4db94011d3 | 658 | * @brief Program a half-word (16-bit) at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 659 | * @note This function must be used when the device voltage range is from |
sahilmgandhi | 18:6a4db94011d3 | 660 | * 2.1V to 2.7V. |
sahilmgandhi | 18:6a4db94011d3 | 661 | * |
sahilmgandhi | 18:6a4db94011d3 | 662 | * @note If an erase and a program operations are requested simultaneously, |
sahilmgandhi | 18:6a4db94011d3 | 663 | * the erase operation is performed before the program one. |
sahilmgandhi | 18:6a4db94011d3 | 664 | * |
sahilmgandhi | 18:6a4db94011d3 | 665 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 666 | * @param Data: specifies the data to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 667 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 668 | */ |
sahilmgandhi | 18:6a4db94011d3 | 669 | static void FLASH_Program_HalfWord(uint32_t Address, uint16_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 670 | { |
sahilmgandhi | 18:6a4db94011d3 | 671 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 672 | assert_param(IS_FLASH_ADDRESS(Address)); |
sahilmgandhi | 18:6a4db94011d3 | 673 | |
sahilmgandhi | 18:6a4db94011d3 | 674 | /* If the previous operation is completed, proceed to program the new data */ |
sahilmgandhi | 18:6a4db94011d3 | 675 | CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE); |
sahilmgandhi | 18:6a4db94011d3 | 676 | FLASH->CR |= FLASH_PSIZE_HALF_WORD; |
sahilmgandhi | 18:6a4db94011d3 | 677 | FLASH->CR |= FLASH_CR_PG; |
sahilmgandhi | 18:6a4db94011d3 | 678 | |
sahilmgandhi | 18:6a4db94011d3 | 679 | *(__IO uint16_t*)Address = Data; |
sahilmgandhi | 18:6a4db94011d3 | 680 | } |
sahilmgandhi | 18:6a4db94011d3 | 681 | |
sahilmgandhi | 18:6a4db94011d3 | 682 | /** |
sahilmgandhi | 18:6a4db94011d3 | 683 | * @brief Program byte (8-bit) at a specified address. |
sahilmgandhi | 18:6a4db94011d3 | 684 | * @note This function must be used when the device voltage range is from |
sahilmgandhi | 18:6a4db94011d3 | 685 | * 1.8V to 2.1V. |
sahilmgandhi | 18:6a4db94011d3 | 686 | * |
sahilmgandhi | 18:6a4db94011d3 | 687 | * @note If an erase and a program operations are requested simultaneously, |
sahilmgandhi | 18:6a4db94011d3 | 688 | * the erase operation is performed before the program one. |
sahilmgandhi | 18:6a4db94011d3 | 689 | * |
sahilmgandhi | 18:6a4db94011d3 | 690 | * @param Address: specifies the address to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 691 | * @param Data: specifies the data to be programmed. |
sahilmgandhi | 18:6a4db94011d3 | 692 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 693 | */ |
sahilmgandhi | 18:6a4db94011d3 | 694 | static void FLASH_Program_Byte(uint32_t Address, uint8_t Data) |
sahilmgandhi | 18:6a4db94011d3 | 695 | { |
sahilmgandhi | 18:6a4db94011d3 | 696 | /* Check the parameters */ |
sahilmgandhi | 18:6a4db94011d3 | 697 | assert_param(IS_FLASH_ADDRESS(Address)); |
sahilmgandhi | 18:6a4db94011d3 | 698 | |
sahilmgandhi | 18:6a4db94011d3 | 699 | /* If the previous operation is completed, proceed to program the new data */ |
sahilmgandhi | 18:6a4db94011d3 | 700 | CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE); |
sahilmgandhi | 18:6a4db94011d3 | 701 | FLASH->CR |= FLASH_PSIZE_BYTE; |
sahilmgandhi | 18:6a4db94011d3 | 702 | FLASH->CR |= FLASH_CR_PG; |
sahilmgandhi | 18:6a4db94011d3 | 703 | |
sahilmgandhi | 18:6a4db94011d3 | 704 | *(__IO uint8_t*)Address = Data; |
sahilmgandhi | 18:6a4db94011d3 | 705 | } |
sahilmgandhi | 18:6a4db94011d3 | 706 | |
sahilmgandhi | 18:6a4db94011d3 | 707 | /** |
sahilmgandhi | 18:6a4db94011d3 | 708 | * @brief Set the specific FLASH error flag. |
sahilmgandhi | 18:6a4db94011d3 | 709 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 710 | */ |
sahilmgandhi | 18:6a4db94011d3 | 711 | static void FLASH_SetErrorCode(void) |
sahilmgandhi | 18:6a4db94011d3 | 712 | { |
sahilmgandhi | 18:6a4db94011d3 | 713 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 714 | { |
sahilmgandhi | 18:6a4db94011d3 | 715 | pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP; |
sahilmgandhi | 18:6a4db94011d3 | 716 | |
sahilmgandhi | 18:6a4db94011d3 | 717 | /* Clear FLASH write protection error pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 718 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR); |
sahilmgandhi | 18:6a4db94011d3 | 719 | } |
sahilmgandhi | 18:6a4db94011d3 | 720 | |
sahilmgandhi | 18:6a4db94011d3 | 721 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 722 | { |
sahilmgandhi | 18:6a4db94011d3 | 723 | pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA; |
sahilmgandhi | 18:6a4db94011d3 | 724 | |
sahilmgandhi | 18:6a4db94011d3 | 725 | /* Clear FLASH Programming alignment error pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 726 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR); |
sahilmgandhi | 18:6a4db94011d3 | 727 | } |
sahilmgandhi | 18:6a4db94011d3 | 728 | |
sahilmgandhi | 18:6a4db94011d3 | 729 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 730 | { |
sahilmgandhi | 18:6a4db94011d3 | 731 | pFlash.ErrorCode |= HAL_FLASH_ERROR_PGP; |
sahilmgandhi | 18:6a4db94011d3 | 732 | |
sahilmgandhi | 18:6a4db94011d3 | 733 | /* Clear FLASH Programming parallelism error pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 734 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGPERR); |
sahilmgandhi | 18:6a4db94011d3 | 735 | } |
sahilmgandhi | 18:6a4db94011d3 | 736 | |
sahilmgandhi | 18:6a4db94011d3 | 737 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 738 | { |
sahilmgandhi | 18:6a4db94011d3 | 739 | pFlash.ErrorCode |= HAL_FLASH_ERROR_PGS; |
sahilmgandhi | 18:6a4db94011d3 | 740 | |
sahilmgandhi | 18:6a4db94011d3 | 741 | /* Clear FLASH Programming sequence error pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 742 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR); |
sahilmgandhi | 18:6a4db94011d3 | 743 | } |
sahilmgandhi | 18:6a4db94011d3 | 744 | |
sahilmgandhi | 18:6a4db94011d3 | 745 | if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR) != RESET) |
sahilmgandhi | 18:6a4db94011d3 | 746 | { |
sahilmgandhi | 18:6a4db94011d3 | 747 | pFlash.ErrorCode |= HAL_FLASH_ERROR_OPERATION; |
sahilmgandhi | 18:6a4db94011d3 | 748 | |
sahilmgandhi | 18:6a4db94011d3 | 749 | /* Clear FLASH Operation error pending bit */ |
sahilmgandhi | 18:6a4db94011d3 | 750 | __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR); |
sahilmgandhi | 18:6a4db94011d3 | 751 | } |
sahilmgandhi | 18:6a4db94011d3 | 752 | } |
sahilmgandhi | 18:6a4db94011d3 | 753 | |
sahilmgandhi | 18:6a4db94011d3 | 754 | /** |
sahilmgandhi | 18:6a4db94011d3 | 755 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 756 | */ |
sahilmgandhi | 18:6a4db94011d3 | 757 | |
sahilmgandhi | 18:6a4db94011d3 | 758 | #endif /* HAL_FLASH_MODULE_ENABLED */ |
sahilmgandhi | 18:6a4db94011d3 | 759 | |
sahilmgandhi | 18:6a4db94011d3 | 760 | /** |
sahilmgandhi | 18:6a4db94011d3 | 761 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 762 | */ |
sahilmgandhi | 18:6a4db94011d3 | 763 | |
sahilmgandhi | 18:6a4db94011d3 | 764 | /** |
sahilmgandhi | 18:6a4db94011d3 | 765 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 766 | */ |
sahilmgandhi | 18:6a4db94011d3 | 767 | |
sahilmgandhi | 18:6a4db94011d3 | 768 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |