Mouse code for the MacroRat
mbed-dev/targets/TARGET_STM/TARGET_STM32F4/device/stm32f4xx_hal_flash.h@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 stm32f4xx_hal_flash.h |
sahilmgandhi | 18:6a4db94011d3 | 4 | * @author MCD Application Team |
sahilmgandhi | 18:6a4db94011d3 | 5 | * @version V1.5.0 |
sahilmgandhi | 18:6a4db94011d3 | 6 | * @date 06-May-2016 |
sahilmgandhi | 18:6a4db94011d3 | 7 | * @brief Header file of FLASH HAL module. |
sahilmgandhi | 18:6a4db94011d3 | 8 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 9 | * @attention |
sahilmgandhi | 18:6a4db94011d3 | 10 | * |
sahilmgandhi | 18:6a4db94011d3 | 11 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
sahilmgandhi | 18:6a4db94011d3 | 12 | * |
sahilmgandhi | 18:6a4db94011d3 | 13 | * Redistribution and use in source and binary forms, with or without modification, |
sahilmgandhi | 18:6a4db94011d3 | 14 | * are permitted provided that the following conditions are met: |
sahilmgandhi | 18:6a4db94011d3 | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 16 | * this list of conditions and the following disclaimer. |
sahilmgandhi | 18:6a4db94011d3 | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
sahilmgandhi | 18:6a4db94011d3 | 18 | * this list of conditions and the following disclaimer in the documentation |
sahilmgandhi | 18:6a4db94011d3 | 19 | * and/or other materials provided with the distribution. |
sahilmgandhi | 18:6a4db94011d3 | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
sahilmgandhi | 18:6a4db94011d3 | 21 | * may be used to endorse or promote products derived from this software |
sahilmgandhi | 18:6a4db94011d3 | 22 | * without specific prior written permission. |
sahilmgandhi | 18:6a4db94011d3 | 23 | * |
sahilmgandhi | 18:6a4db94011d3 | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
sahilmgandhi | 18:6a4db94011d3 | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
sahilmgandhi | 18:6a4db94011d3 | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
sahilmgandhi | 18:6a4db94011d3 | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
sahilmgandhi | 18:6a4db94011d3 | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
sahilmgandhi | 18:6a4db94011d3 | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
sahilmgandhi | 18:6a4db94011d3 | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
sahilmgandhi | 18:6a4db94011d3 | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
sahilmgandhi | 18:6a4db94011d3 | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
sahilmgandhi | 18:6a4db94011d3 | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
sahilmgandhi | 18:6a4db94011d3 | 34 | * |
sahilmgandhi | 18:6a4db94011d3 | 35 | ****************************************************************************** |
sahilmgandhi | 18:6a4db94011d3 | 36 | */ |
sahilmgandhi | 18:6a4db94011d3 | 37 | |
sahilmgandhi | 18:6a4db94011d3 | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 39 | #ifndef __STM32F4xx_HAL_FLASH_H |
sahilmgandhi | 18:6a4db94011d3 | 40 | #define __STM32F4xx_HAL_FLASH_H |
sahilmgandhi | 18:6a4db94011d3 | 41 | |
sahilmgandhi | 18:6a4db94011d3 | 42 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 43 | extern "C" { |
sahilmgandhi | 18:6a4db94011d3 | 44 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 45 | |
sahilmgandhi | 18:6a4db94011d3 | 46 | /* Includes ------------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 47 | #include "stm32f4xx_hal_def.h" |
sahilmgandhi | 18:6a4db94011d3 | 48 | |
sahilmgandhi | 18:6a4db94011d3 | 49 | /** @addtogroup STM32F4xx_HAL_Driver |
sahilmgandhi | 18:6a4db94011d3 | 50 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 51 | */ |
sahilmgandhi | 18:6a4db94011d3 | 52 | |
sahilmgandhi | 18:6a4db94011d3 | 53 | /** @addtogroup FLASH |
sahilmgandhi | 18:6a4db94011d3 | 54 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 55 | */ |
sahilmgandhi | 18:6a4db94011d3 | 56 | |
sahilmgandhi | 18:6a4db94011d3 | 57 | /* Exported types ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 58 | /** @defgroup FLASH_Exported_Types FLASH Exported Types |
sahilmgandhi | 18:6a4db94011d3 | 59 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 60 | */ |
sahilmgandhi | 18:6a4db94011d3 | 61 | |
sahilmgandhi | 18:6a4db94011d3 | 62 | /** |
sahilmgandhi | 18:6a4db94011d3 | 63 | * @brief FLASH Procedure structure definition |
sahilmgandhi | 18:6a4db94011d3 | 64 | */ |
sahilmgandhi | 18:6a4db94011d3 | 65 | typedef enum |
sahilmgandhi | 18:6a4db94011d3 | 66 | { |
sahilmgandhi | 18:6a4db94011d3 | 67 | FLASH_PROC_NONE = 0U, |
sahilmgandhi | 18:6a4db94011d3 | 68 | FLASH_PROC_SECTERASE, |
sahilmgandhi | 18:6a4db94011d3 | 69 | FLASH_PROC_MASSERASE, |
sahilmgandhi | 18:6a4db94011d3 | 70 | FLASH_PROC_PROGRAM |
sahilmgandhi | 18:6a4db94011d3 | 71 | } FLASH_ProcedureTypeDef; |
sahilmgandhi | 18:6a4db94011d3 | 72 | |
sahilmgandhi | 18:6a4db94011d3 | 73 | /** |
sahilmgandhi | 18:6a4db94011d3 | 74 | * @brief FLASH handle Structure definition |
sahilmgandhi | 18:6a4db94011d3 | 75 | */ |
sahilmgandhi | 18:6a4db94011d3 | 76 | typedef struct |
sahilmgandhi | 18:6a4db94011d3 | 77 | { |
sahilmgandhi | 18:6a4db94011d3 | 78 | __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /*Internal variable to indicate which procedure is ongoing or not in IT context*/ |
sahilmgandhi | 18:6a4db94011d3 | 79 | |
sahilmgandhi | 18:6a4db94011d3 | 80 | __IO uint32_t NbSectorsToErase; /*Internal variable to save the remaining sectors to erase in IT context*/ |
sahilmgandhi | 18:6a4db94011d3 | 81 | |
sahilmgandhi | 18:6a4db94011d3 | 82 | __IO uint8_t VoltageForErase; /*Internal variable to provide voltage range selected by user in IT context*/ |
sahilmgandhi | 18:6a4db94011d3 | 83 | |
sahilmgandhi | 18:6a4db94011d3 | 84 | __IO uint32_t Sector; /*Internal variable to define the current sector which is erasing*/ |
sahilmgandhi | 18:6a4db94011d3 | 85 | |
sahilmgandhi | 18:6a4db94011d3 | 86 | __IO uint32_t Bank; /*Internal variable to save current bank selected during mass erase*/ |
sahilmgandhi | 18:6a4db94011d3 | 87 | |
sahilmgandhi | 18:6a4db94011d3 | 88 | __IO uint32_t Address; /*Internal variable to save address selected for program*/ |
sahilmgandhi | 18:6a4db94011d3 | 89 | |
sahilmgandhi | 18:6a4db94011d3 | 90 | HAL_LockTypeDef Lock; /* FLASH locking object */ |
sahilmgandhi | 18:6a4db94011d3 | 91 | |
sahilmgandhi | 18:6a4db94011d3 | 92 | __IO uint32_t ErrorCode; /* FLASH error code */ |
sahilmgandhi | 18:6a4db94011d3 | 93 | |
sahilmgandhi | 18:6a4db94011d3 | 94 | }FLASH_ProcessTypeDef; |
sahilmgandhi | 18:6a4db94011d3 | 95 | |
sahilmgandhi | 18:6a4db94011d3 | 96 | /** |
sahilmgandhi | 18:6a4db94011d3 | 97 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 98 | */ |
sahilmgandhi | 18:6a4db94011d3 | 99 | |
sahilmgandhi | 18:6a4db94011d3 | 100 | /* Exported constants --------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 101 | /** @defgroup FLASH_Exported_Constants FLASH Exported Constants |
sahilmgandhi | 18:6a4db94011d3 | 102 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 103 | */ |
sahilmgandhi | 18:6a4db94011d3 | 104 | /** @defgroup FLASH_Error_Code FLASH Error Code |
sahilmgandhi | 18:6a4db94011d3 | 105 | * @brief FLASH Error Code |
sahilmgandhi | 18:6a4db94011d3 | 106 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 107 | */ |
sahilmgandhi | 18:6a4db94011d3 | 108 | #define HAL_FLASH_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */ |
sahilmgandhi | 18:6a4db94011d3 | 109 | #define HAL_FLASH_ERROR_RD ((uint32_t)0x00000001U) /*!< Read Protection error */ |
sahilmgandhi | 18:6a4db94011d3 | 110 | #define HAL_FLASH_ERROR_PGS ((uint32_t)0x00000002U) /*!< Programming Sequence error */ |
sahilmgandhi | 18:6a4db94011d3 | 111 | #define HAL_FLASH_ERROR_PGP ((uint32_t)0x00000004U) /*!< Programming Parallelism error */ |
sahilmgandhi | 18:6a4db94011d3 | 112 | #define HAL_FLASH_ERROR_PGA ((uint32_t)0x00000008U) /*!< Programming Alignment error */ |
sahilmgandhi | 18:6a4db94011d3 | 113 | #define HAL_FLASH_ERROR_WRP ((uint32_t)0x00000010U) /*!< Write protection error */ |
sahilmgandhi | 18:6a4db94011d3 | 114 | #define HAL_FLASH_ERROR_OPERATION ((uint32_t)0x00000020U) /*!< Operation Error */ |
sahilmgandhi | 18:6a4db94011d3 | 115 | /** |
sahilmgandhi | 18:6a4db94011d3 | 116 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 117 | */ |
sahilmgandhi | 18:6a4db94011d3 | 118 | |
sahilmgandhi | 18:6a4db94011d3 | 119 | /** @defgroup FLASH_Type_Program FLASH Type Program |
sahilmgandhi | 18:6a4db94011d3 | 120 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 121 | */ |
sahilmgandhi | 18:6a4db94011d3 | 122 | #define FLASH_TYPEPROGRAM_BYTE ((uint32_t)0x00U) /*!< Program byte (8-bit) at a specified address */ |
sahilmgandhi | 18:6a4db94011d3 | 123 | #define FLASH_TYPEPROGRAM_HALFWORD ((uint32_t)0x01U) /*!< Program a half-word (16-bit) at a specified address */ |
sahilmgandhi | 18:6a4db94011d3 | 124 | #define FLASH_TYPEPROGRAM_WORD ((uint32_t)0x02U) /*!< Program a word (32-bit) at a specified address */ |
sahilmgandhi | 18:6a4db94011d3 | 125 | #define FLASH_TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03U) /*!< Program a double word (64-bit) at a specified address */ |
sahilmgandhi | 18:6a4db94011d3 | 126 | /** |
sahilmgandhi | 18:6a4db94011d3 | 127 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 128 | */ |
sahilmgandhi | 18:6a4db94011d3 | 129 | |
sahilmgandhi | 18:6a4db94011d3 | 130 | /** @defgroup FLASH_Flag_definition FLASH Flag definition |
sahilmgandhi | 18:6a4db94011d3 | 131 | * @brief Flag definition |
sahilmgandhi | 18:6a4db94011d3 | 132 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 133 | */ |
sahilmgandhi | 18:6a4db94011d3 | 134 | #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */ |
sahilmgandhi | 18:6a4db94011d3 | 135 | #define FLASH_FLAG_OPERR FLASH_SR_SOP /*!< FLASH operation Error flag */ |
sahilmgandhi | 18:6a4db94011d3 | 136 | #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */ |
sahilmgandhi | 18:6a4db94011d3 | 137 | #define FLASH_FLAG_PGAERR FLASH_SR_PGAERR /*!< FLASH Programming Alignment error flag */ |
sahilmgandhi | 18:6a4db94011d3 | 138 | #define FLASH_FLAG_PGPERR FLASH_SR_PGPERR /*!< FLASH Programming Parallelism error flag */ |
sahilmgandhi | 18:6a4db94011d3 | 139 | #define FLASH_FLAG_PGSERR FLASH_SR_PGSERR /*!< FLASH Programming Sequence error flag */ |
sahilmgandhi | 18:6a4db94011d3 | 140 | #define FLASH_FLAG_RDERR ((uint32_t)0x00000100U) /*!< Read Protection error flag (PCROP) */ |
sahilmgandhi | 18:6a4db94011d3 | 141 | #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */ |
sahilmgandhi | 18:6a4db94011d3 | 142 | /** |
sahilmgandhi | 18:6a4db94011d3 | 143 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 144 | */ |
sahilmgandhi | 18:6a4db94011d3 | 145 | |
sahilmgandhi | 18:6a4db94011d3 | 146 | /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition |
sahilmgandhi | 18:6a4db94011d3 | 147 | * @brief FLASH Interrupt definition |
sahilmgandhi | 18:6a4db94011d3 | 148 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 149 | */ |
sahilmgandhi | 18:6a4db94011d3 | 150 | #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */ |
sahilmgandhi | 18:6a4db94011d3 | 151 | #define FLASH_IT_ERR ((uint32_t)0x02000000U) /*!< Error Interrupt source */ |
sahilmgandhi | 18:6a4db94011d3 | 152 | /** |
sahilmgandhi | 18:6a4db94011d3 | 153 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 154 | */ |
sahilmgandhi | 18:6a4db94011d3 | 155 | |
sahilmgandhi | 18:6a4db94011d3 | 156 | /** @defgroup FLASH_Program_Parallelism FLASH Program Parallelism |
sahilmgandhi | 18:6a4db94011d3 | 157 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 158 | */ |
sahilmgandhi | 18:6a4db94011d3 | 159 | #define FLASH_PSIZE_BYTE ((uint32_t)0x00000000U) |
sahilmgandhi | 18:6a4db94011d3 | 160 | #define FLASH_PSIZE_HALF_WORD ((uint32_t)0x00000100U) |
sahilmgandhi | 18:6a4db94011d3 | 161 | #define FLASH_PSIZE_WORD ((uint32_t)0x00000200U) |
sahilmgandhi | 18:6a4db94011d3 | 162 | #define FLASH_PSIZE_DOUBLE_WORD ((uint32_t)0x00000300U) |
sahilmgandhi | 18:6a4db94011d3 | 163 | #define CR_PSIZE_MASK ((uint32_t)0xFFFFFCFFU) |
sahilmgandhi | 18:6a4db94011d3 | 164 | /** |
sahilmgandhi | 18:6a4db94011d3 | 165 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 166 | */ |
sahilmgandhi | 18:6a4db94011d3 | 167 | |
sahilmgandhi | 18:6a4db94011d3 | 168 | /** @defgroup FLASH_Keys FLASH Keys |
sahilmgandhi | 18:6a4db94011d3 | 169 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 170 | */ |
sahilmgandhi | 18:6a4db94011d3 | 171 | #define RDP_KEY ((uint16_t)0x00A5U) |
sahilmgandhi | 18:6a4db94011d3 | 172 | #define FLASH_KEY1 ((uint32_t)0x45670123U) |
sahilmgandhi | 18:6a4db94011d3 | 173 | #define FLASH_KEY2 ((uint32_t)0xCDEF89ABU) |
sahilmgandhi | 18:6a4db94011d3 | 174 | #define FLASH_OPT_KEY1 ((uint32_t)0x08192A3BU) |
sahilmgandhi | 18:6a4db94011d3 | 175 | #define FLASH_OPT_KEY2 ((uint32_t)0x4C5D6E7FU) |
sahilmgandhi | 18:6a4db94011d3 | 176 | /** |
sahilmgandhi | 18:6a4db94011d3 | 177 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 178 | */ |
sahilmgandhi | 18:6a4db94011d3 | 179 | |
sahilmgandhi | 18:6a4db94011d3 | 180 | /** |
sahilmgandhi | 18:6a4db94011d3 | 181 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 182 | */ |
sahilmgandhi | 18:6a4db94011d3 | 183 | |
sahilmgandhi | 18:6a4db94011d3 | 184 | /* Exported macro ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 185 | /** @defgroup FLASH_Exported_Macros FLASH Exported Macros |
sahilmgandhi | 18:6a4db94011d3 | 186 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 187 | */ |
sahilmgandhi | 18:6a4db94011d3 | 188 | /** |
sahilmgandhi | 18:6a4db94011d3 | 189 | * @brief Set the FLASH Latency. |
sahilmgandhi | 18:6a4db94011d3 | 190 | * @param __LATENCY__: FLASH Latency |
sahilmgandhi | 18:6a4db94011d3 | 191 | * The value of this parameter depend on device used within the same series |
sahilmgandhi | 18:6a4db94011d3 | 192 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 193 | */ |
sahilmgandhi | 18:6a4db94011d3 | 194 | #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (*(__IO uint8_t *)ACR_BYTE0_ADDRESS = (uint8_t)(__LATENCY__)) |
sahilmgandhi | 18:6a4db94011d3 | 195 | |
sahilmgandhi | 18:6a4db94011d3 | 196 | /** |
sahilmgandhi | 18:6a4db94011d3 | 197 | * @brief Get the FLASH Latency. |
sahilmgandhi | 18:6a4db94011d3 | 198 | * @retval FLASH Latency |
sahilmgandhi | 18:6a4db94011d3 | 199 | * The value of this parameter depend on device used within the same series |
sahilmgandhi | 18:6a4db94011d3 | 200 | */ |
sahilmgandhi | 18:6a4db94011d3 | 201 | #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) |
sahilmgandhi | 18:6a4db94011d3 | 202 | |
sahilmgandhi | 18:6a4db94011d3 | 203 | /** |
sahilmgandhi | 18:6a4db94011d3 | 204 | * @brief Enable the FLASH prefetch buffer. |
sahilmgandhi | 18:6a4db94011d3 | 205 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 206 | */ |
sahilmgandhi | 18:6a4db94011d3 | 207 | #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTEN) |
sahilmgandhi | 18:6a4db94011d3 | 208 | |
sahilmgandhi | 18:6a4db94011d3 | 209 | /** |
sahilmgandhi | 18:6a4db94011d3 | 210 | * @brief Disable the FLASH prefetch buffer. |
sahilmgandhi | 18:6a4db94011d3 | 211 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 212 | */ |
sahilmgandhi | 18:6a4db94011d3 | 213 | #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTEN)) |
sahilmgandhi | 18:6a4db94011d3 | 214 | |
sahilmgandhi | 18:6a4db94011d3 | 215 | /** |
sahilmgandhi | 18:6a4db94011d3 | 216 | * @brief Enable the FLASH instruction cache. |
sahilmgandhi | 18:6a4db94011d3 | 217 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 218 | */ |
sahilmgandhi | 18:6a4db94011d3 | 219 | #define __HAL_FLASH_INSTRUCTION_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_ICEN) |
sahilmgandhi | 18:6a4db94011d3 | 220 | |
sahilmgandhi | 18:6a4db94011d3 | 221 | /** |
sahilmgandhi | 18:6a4db94011d3 | 222 | * @brief Disable the FLASH instruction cache. |
sahilmgandhi | 18:6a4db94011d3 | 223 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 224 | */ |
sahilmgandhi | 18:6a4db94011d3 | 225 | #define __HAL_FLASH_INSTRUCTION_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_ICEN)) |
sahilmgandhi | 18:6a4db94011d3 | 226 | |
sahilmgandhi | 18:6a4db94011d3 | 227 | /** |
sahilmgandhi | 18:6a4db94011d3 | 228 | * @brief Enable the FLASH data cache. |
sahilmgandhi | 18:6a4db94011d3 | 229 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 230 | */ |
sahilmgandhi | 18:6a4db94011d3 | 231 | #define __HAL_FLASH_DATA_CACHE_ENABLE() (FLASH->ACR |= FLASH_ACR_DCEN) |
sahilmgandhi | 18:6a4db94011d3 | 232 | |
sahilmgandhi | 18:6a4db94011d3 | 233 | /** |
sahilmgandhi | 18:6a4db94011d3 | 234 | * @brief Disable the FLASH data cache. |
sahilmgandhi | 18:6a4db94011d3 | 235 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 236 | */ |
sahilmgandhi | 18:6a4db94011d3 | 237 | #define __HAL_FLASH_DATA_CACHE_DISABLE() (FLASH->ACR &= (~FLASH_ACR_DCEN)) |
sahilmgandhi | 18:6a4db94011d3 | 238 | |
sahilmgandhi | 18:6a4db94011d3 | 239 | /** |
sahilmgandhi | 18:6a4db94011d3 | 240 | * @brief Resets the FLASH instruction Cache. |
sahilmgandhi | 18:6a4db94011d3 | 241 | * @note This function must be used only when the Instruction Cache is disabled. |
sahilmgandhi | 18:6a4db94011d3 | 242 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 243 | */ |
sahilmgandhi | 18:6a4db94011d3 | 244 | #define __HAL_FLASH_INSTRUCTION_CACHE_RESET() do {FLASH->ACR |= FLASH_ACR_ICRST; \ |
sahilmgandhi | 18:6a4db94011d3 | 245 | FLASH->ACR &= ~FLASH_ACR_ICRST; \ |
sahilmgandhi | 18:6a4db94011d3 | 246 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 247 | |
sahilmgandhi | 18:6a4db94011d3 | 248 | /** |
sahilmgandhi | 18:6a4db94011d3 | 249 | * @brief Resets the FLASH data Cache. |
sahilmgandhi | 18:6a4db94011d3 | 250 | * @note This function must be used only when the data Cache is disabled. |
sahilmgandhi | 18:6a4db94011d3 | 251 | * @retval None |
sahilmgandhi | 18:6a4db94011d3 | 252 | */ |
sahilmgandhi | 18:6a4db94011d3 | 253 | #define __HAL_FLASH_DATA_CACHE_RESET() do {FLASH->ACR |= FLASH_ACR_DCRST; \ |
sahilmgandhi | 18:6a4db94011d3 | 254 | FLASH->ACR &= ~FLASH_ACR_DCRST; \ |
sahilmgandhi | 18:6a4db94011d3 | 255 | }while(0) |
sahilmgandhi | 18:6a4db94011d3 | 256 | /** |
sahilmgandhi | 18:6a4db94011d3 | 257 | * @brief Enable the specified FLASH interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 258 | * @param __INTERRUPT__ : FLASH interrupt |
sahilmgandhi | 18:6a4db94011d3 | 259 | * This parameter can be any combination of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 260 | * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt |
sahilmgandhi | 18:6a4db94011d3 | 261 | * @arg FLASH_IT_ERR: Error Interrupt |
sahilmgandhi | 18:6a4db94011d3 | 262 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 263 | */ |
sahilmgandhi | 18:6a4db94011d3 | 264 | #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->CR |= (__INTERRUPT__)) |
sahilmgandhi | 18:6a4db94011d3 | 265 | |
sahilmgandhi | 18:6a4db94011d3 | 266 | /** |
sahilmgandhi | 18:6a4db94011d3 | 267 | * @brief Disable the specified FLASH interrupt. |
sahilmgandhi | 18:6a4db94011d3 | 268 | * @param __INTERRUPT__ : FLASH interrupt |
sahilmgandhi | 18:6a4db94011d3 | 269 | * This parameter can be any combination of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 270 | * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt |
sahilmgandhi | 18:6a4db94011d3 | 271 | * @arg FLASH_IT_ERR: Error Interrupt |
sahilmgandhi | 18:6a4db94011d3 | 272 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 273 | */ |
sahilmgandhi | 18:6a4db94011d3 | 274 | #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->CR &= ~(uint32_t)(__INTERRUPT__)) |
sahilmgandhi | 18:6a4db94011d3 | 275 | |
sahilmgandhi | 18:6a4db94011d3 | 276 | /** |
sahilmgandhi | 18:6a4db94011d3 | 277 | * @brief Get the specified FLASH flag status. |
sahilmgandhi | 18:6a4db94011d3 | 278 | * @param __FLAG__: specifies the FLASH flag to check. |
sahilmgandhi | 18:6a4db94011d3 | 279 | * This parameter can be one of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 280 | * @arg FLASH_FLAG_EOP : FLASH End of Operation flag |
sahilmgandhi | 18:6a4db94011d3 | 281 | * @arg FLASH_FLAG_OPERR : FLASH operation Error flag |
sahilmgandhi | 18:6a4db94011d3 | 282 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag |
sahilmgandhi | 18:6a4db94011d3 | 283 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag |
sahilmgandhi | 18:6a4db94011d3 | 284 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag |
sahilmgandhi | 18:6a4db94011d3 | 285 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag |
sahilmgandhi | 18:6a4db94011d3 | 286 | * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) |
sahilmgandhi | 18:6a4db94011d3 | 287 | * @arg FLASH_FLAG_BSY : FLASH Busy flag |
sahilmgandhi | 18:6a4db94011d3 | 288 | * @retval The new state of __FLAG__ (SET or RESET). |
sahilmgandhi | 18:6a4db94011d3 | 289 | */ |
sahilmgandhi | 18:6a4db94011d3 | 290 | #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__))==(__FLAG__)) |
sahilmgandhi | 18:6a4db94011d3 | 291 | |
sahilmgandhi | 18:6a4db94011d3 | 292 | /** |
sahilmgandhi | 18:6a4db94011d3 | 293 | * @brief Clear the specified FLASH flag. |
sahilmgandhi | 18:6a4db94011d3 | 294 | * @param __FLAG__: specifies the FLASH flags to clear. |
sahilmgandhi | 18:6a4db94011d3 | 295 | * This parameter can be any combination of the following values: |
sahilmgandhi | 18:6a4db94011d3 | 296 | * @arg FLASH_FLAG_EOP : FLASH End of Operation flag |
sahilmgandhi | 18:6a4db94011d3 | 297 | * @arg FLASH_FLAG_OPERR : FLASH operation Error flag |
sahilmgandhi | 18:6a4db94011d3 | 298 | * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag |
sahilmgandhi | 18:6a4db94011d3 | 299 | * @arg FLASH_FLAG_PGAERR: FLASH Programming Alignment error flag |
sahilmgandhi | 18:6a4db94011d3 | 300 | * @arg FLASH_FLAG_PGPERR: FLASH Programming Parallelism error flag |
sahilmgandhi | 18:6a4db94011d3 | 301 | * @arg FLASH_FLAG_PGSERR: FLASH Programming Sequence error flag |
sahilmgandhi | 18:6a4db94011d3 | 302 | * @arg FLASH_FLAG_RDERR : FLASH Read Protection error flag (PCROP) |
sahilmgandhi | 18:6a4db94011d3 | 303 | * @retval none |
sahilmgandhi | 18:6a4db94011d3 | 304 | */ |
sahilmgandhi | 18:6a4db94011d3 | 305 | #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__)) |
sahilmgandhi | 18:6a4db94011d3 | 306 | /** |
sahilmgandhi | 18:6a4db94011d3 | 307 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 308 | */ |
sahilmgandhi | 18:6a4db94011d3 | 309 | |
sahilmgandhi | 18:6a4db94011d3 | 310 | /* Include FLASH HAL Extension module */ |
sahilmgandhi | 18:6a4db94011d3 | 311 | #include "stm32f4xx_hal_flash_ex.h" |
sahilmgandhi | 18:6a4db94011d3 | 312 | #include "stm32f4xx_hal_flash_ramfunc.h" |
sahilmgandhi | 18:6a4db94011d3 | 313 | |
sahilmgandhi | 18:6a4db94011d3 | 314 | /* Exported functions --------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 315 | /** @addtogroup FLASH_Exported_Functions |
sahilmgandhi | 18:6a4db94011d3 | 316 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 317 | */ |
sahilmgandhi | 18:6a4db94011d3 | 318 | /** @addtogroup FLASH_Exported_Functions_Group1 |
sahilmgandhi | 18:6a4db94011d3 | 319 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 320 | */ |
sahilmgandhi | 18:6a4db94011d3 | 321 | /* Program operation functions ***********************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 322 | HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 323 | HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data); |
sahilmgandhi | 18:6a4db94011d3 | 324 | /* FLASH IRQ handler method */ |
sahilmgandhi | 18:6a4db94011d3 | 325 | void HAL_FLASH_IRQHandler(void); |
sahilmgandhi | 18:6a4db94011d3 | 326 | /* Callbacks in non blocking modes */ |
sahilmgandhi | 18:6a4db94011d3 | 327 | void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue); |
sahilmgandhi | 18:6a4db94011d3 | 328 | void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue); |
sahilmgandhi | 18:6a4db94011d3 | 329 | /** |
sahilmgandhi | 18:6a4db94011d3 | 330 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 331 | */ |
sahilmgandhi | 18:6a4db94011d3 | 332 | |
sahilmgandhi | 18:6a4db94011d3 | 333 | /** @addtogroup FLASH_Exported_Functions_Group2 |
sahilmgandhi | 18:6a4db94011d3 | 334 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 335 | */ |
sahilmgandhi | 18:6a4db94011d3 | 336 | /* Peripheral Control functions **********************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 337 | HAL_StatusTypeDef HAL_FLASH_Unlock(void); |
sahilmgandhi | 18:6a4db94011d3 | 338 | HAL_StatusTypeDef HAL_FLASH_Lock(void); |
sahilmgandhi | 18:6a4db94011d3 | 339 | HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void); |
sahilmgandhi | 18:6a4db94011d3 | 340 | HAL_StatusTypeDef HAL_FLASH_OB_Lock(void); |
sahilmgandhi | 18:6a4db94011d3 | 341 | /* Option bytes control */ |
sahilmgandhi | 18:6a4db94011d3 | 342 | HAL_StatusTypeDef HAL_FLASH_OB_Launch(void); |
sahilmgandhi | 18:6a4db94011d3 | 343 | /** |
sahilmgandhi | 18:6a4db94011d3 | 344 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 345 | */ |
sahilmgandhi | 18:6a4db94011d3 | 346 | |
sahilmgandhi | 18:6a4db94011d3 | 347 | /** @addtogroup FLASH_Exported_Functions_Group3 |
sahilmgandhi | 18:6a4db94011d3 | 348 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 349 | */ |
sahilmgandhi | 18:6a4db94011d3 | 350 | /* Peripheral State functions ************************************************/ |
sahilmgandhi | 18:6a4db94011d3 | 351 | uint32_t HAL_FLASH_GetError(void); |
sahilmgandhi | 18:6a4db94011d3 | 352 | HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout); |
sahilmgandhi | 18:6a4db94011d3 | 353 | /** |
sahilmgandhi | 18:6a4db94011d3 | 354 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 355 | */ |
sahilmgandhi | 18:6a4db94011d3 | 356 | |
sahilmgandhi | 18:6a4db94011d3 | 357 | /** |
sahilmgandhi | 18:6a4db94011d3 | 358 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 359 | */ |
sahilmgandhi | 18:6a4db94011d3 | 360 | /* Private types -------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 361 | /* Private variables ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 362 | /** @defgroup FLASH_Private_Variables FLASH Private Variables |
sahilmgandhi | 18:6a4db94011d3 | 363 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 364 | */ |
sahilmgandhi | 18:6a4db94011d3 | 365 | |
sahilmgandhi | 18:6a4db94011d3 | 366 | /** |
sahilmgandhi | 18:6a4db94011d3 | 367 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 368 | */ |
sahilmgandhi | 18:6a4db94011d3 | 369 | /* Private constants ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 370 | /** @defgroup FLASH_Private_Constants FLASH Private Constants |
sahilmgandhi | 18:6a4db94011d3 | 371 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 372 | */ |
sahilmgandhi | 18:6a4db94011d3 | 373 | |
sahilmgandhi | 18:6a4db94011d3 | 374 | /** |
sahilmgandhi | 18:6a4db94011d3 | 375 | * @brief ACR register byte 0 (Bits[7:0]) base address |
sahilmgandhi | 18:6a4db94011d3 | 376 | */ |
sahilmgandhi | 18:6a4db94011d3 | 377 | #define ACR_BYTE0_ADDRESS ((uint32_t)0x40023C00U) |
sahilmgandhi | 18:6a4db94011d3 | 378 | /** |
sahilmgandhi | 18:6a4db94011d3 | 379 | * @brief OPTCR register byte 0 (Bits[7:0]) base address |
sahilmgandhi | 18:6a4db94011d3 | 380 | */ |
sahilmgandhi | 18:6a4db94011d3 | 381 | #define OPTCR_BYTE0_ADDRESS ((uint32_t)0x40023C14U) |
sahilmgandhi | 18:6a4db94011d3 | 382 | /** |
sahilmgandhi | 18:6a4db94011d3 | 383 | * @brief OPTCR register byte 1 (Bits[15:8]) base address |
sahilmgandhi | 18:6a4db94011d3 | 384 | */ |
sahilmgandhi | 18:6a4db94011d3 | 385 | #define OPTCR_BYTE1_ADDRESS ((uint32_t)0x40023C15U) |
sahilmgandhi | 18:6a4db94011d3 | 386 | /** |
sahilmgandhi | 18:6a4db94011d3 | 387 | * @brief OPTCR register byte 2 (Bits[23:16]) base address |
sahilmgandhi | 18:6a4db94011d3 | 388 | */ |
sahilmgandhi | 18:6a4db94011d3 | 389 | #define OPTCR_BYTE2_ADDRESS ((uint32_t)0x40023C16U) |
sahilmgandhi | 18:6a4db94011d3 | 390 | /** |
sahilmgandhi | 18:6a4db94011d3 | 391 | * @brief OPTCR register byte 3 (Bits[31:24]) base address |
sahilmgandhi | 18:6a4db94011d3 | 392 | */ |
sahilmgandhi | 18:6a4db94011d3 | 393 | #define OPTCR_BYTE3_ADDRESS ((uint32_t)0x40023C17U) |
sahilmgandhi | 18:6a4db94011d3 | 394 | |
sahilmgandhi | 18:6a4db94011d3 | 395 | /** |
sahilmgandhi | 18:6a4db94011d3 | 396 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 397 | */ |
sahilmgandhi | 18:6a4db94011d3 | 398 | |
sahilmgandhi | 18:6a4db94011d3 | 399 | /* Private macros ------------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 400 | /** @defgroup FLASH_Private_Macros FLASH Private Macros |
sahilmgandhi | 18:6a4db94011d3 | 401 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 402 | */ |
sahilmgandhi | 18:6a4db94011d3 | 403 | |
sahilmgandhi | 18:6a4db94011d3 | 404 | /** @defgroup FLASH_IS_FLASH_Definitions FLASH Private macros to check input parameters |
sahilmgandhi | 18:6a4db94011d3 | 405 | * @{ |
sahilmgandhi | 18:6a4db94011d3 | 406 | */ |
sahilmgandhi | 18:6a4db94011d3 | 407 | #define IS_FLASH_TYPEPROGRAM(VALUE)(((VALUE) == FLASH_TYPEPROGRAM_BYTE) || \ |
sahilmgandhi | 18:6a4db94011d3 | 408 | ((VALUE) == FLASH_TYPEPROGRAM_HALFWORD) || \ |
sahilmgandhi | 18:6a4db94011d3 | 409 | ((VALUE) == FLASH_TYPEPROGRAM_WORD) || \ |
sahilmgandhi | 18:6a4db94011d3 | 410 | ((VALUE) == FLASH_TYPEPROGRAM_DOUBLEWORD)) |
sahilmgandhi | 18:6a4db94011d3 | 411 | /** |
sahilmgandhi | 18:6a4db94011d3 | 412 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 413 | */ |
sahilmgandhi | 18:6a4db94011d3 | 414 | |
sahilmgandhi | 18:6a4db94011d3 | 415 | /** |
sahilmgandhi | 18:6a4db94011d3 | 416 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 417 | */ |
sahilmgandhi | 18:6a4db94011d3 | 418 | |
sahilmgandhi | 18:6a4db94011d3 | 419 | /* Private functions ---------------------------------------------------------*/ |
sahilmgandhi | 18:6a4db94011d3 | 420 | /** @defgroup FLASH_Private_Functions FLASH Private Functions |
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 | /** |
sahilmgandhi | 18:6a4db94011d3 | 429 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 430 | */ |
sahilmgandhi | 18:6a4db94011d3 | 431 | |
sahilmgandhi | 18:6a4db94011d3 | 432 | /** |
sahilmgandhi | 18:6a4db94011d3 | 433 | * @} |
sahilmgandhi | 18:6a4db94011d3 | 434 | */ |
sahilmgandhi | 18:6a4db94011d3 | 435 | |
sahilmgandhi | 18:6a4db94011d3 | 436 | #ifdef __cplusplus |
sahilmgandhi | 18:6a4db94011d3 | 437 | } |
sahilmgandhi | 18:6a4db94011d3 | 438 | #endif |
sahilmgandhi | 18:6a4db94011d3 | 439 | |
sahilmgandhi | 18:6a4db94011d3 | 440 | #endif /* __STM32F4xx_HAL_FLASH_H */ |
sahilmgandhi | 18:6a4db94011d3 | 441 | |
sahilmgandhi | 18:6a4db94011d3 | 442 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |