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

Fork of mbed by mbed official

Committer:
Mikchel
Date:
Sun May 03 16:04:42 2015 +0000
Revision:
99:7f6c6de930c0
Parent:
92:4fc01daae5a5
12

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 86:04dd9b1680ae 1 /**
bogdanm 86:04dd9b1680ae 2 ******************************************************************************
bogdanm 86:04dd9b1680ae 3 * @file stm32f3xx_hal_flash.h
bogdanm 86:04dd9b1680ae 4 * @author MCD Application Team
bogdanm 92:4fc01daae5a5 5 * @version V1.1.0
bogdanm 92:4fc01daae5a5 6 * @date 12-Sept-2014
bogdanm 86:04dd9b1680ae 7 * @brief Header file of Flash HAL module.
bogdanm 86:04dd9b1680ae 8 ******************************************************************************
bogdanm 86:04dd9b1680ae 9 * @attention
bogdanm 86:04dd9b1680ae 10 *
bogdanm 86:04dd9b1680ae 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 86:04dd9b1680ae 12 *
bogdanm 86:04dd9b1680ae 13 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 86:04dd9b1680ae 14 * are permitted provided that the following conditions are met:
bogdanm 86:04dd9b1680ae 15 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 86:04dd9b1680ae 16 * this list of conditions and the following disclaimer.
bogdanm 86:04dd9b1680ae 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 86:04dd9b1680ae 18 * this list of conditions and the following disclaimer in the documentation
bogdanm 86:04dd9b1680ae 19 * and/or other materials provided with the distribution.
bogdanm 86:04dd9b1680ae 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 86:04dd9b1680ae 21 * may be used to endorse or promote products derived from this software
bogdanm 86:04dd9b1680ae 22 * without specific prior written permission.
bogdanm 86:04dd9b1680ae 23 *
bogdanm 86:04dd9b1680ae 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 86:04dd9b1680ae 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 86:04dd9b1680ae 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 86:04dd9b1680ae 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 86:04dd9b1680ae 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 86:04dd9b1680ae 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 86:04dd9b1680ae 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 86:04dd9b1680ae 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 86:04dd9b1680ae 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 86:04dd9b1680ae 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 86:04dd9b1680ae 34 *
bogdanm 86:04dd9b1680ae 35 ******************************************************************************
bogdanm 86:04dd9b1680ae 36 */
bogdanm 86:04dd9b1680ae 37
bogdanm 86:04dd9b1680ae 38 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 86:04dd9b1680ae 39 #ifndef __STM32F3xx_HAL_FLASH_H
bogdanm 86:04dd9b1680ae 40 #define __STM32F3xx_HAL_FLASH_H
bogdanm 86:04dd9b1680ae 41
bogdanm 86:04dd9b1680ae 42 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 43 extern "C" {
bogdanm 86:04dd9b1680ae 44 #endif
bogdanm 86:04dd9b1680ae 45
bogdanm 86:04dd9b1680ae 46 /* Includes ------------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 47 #include "stm32f3xx_hal_def.h"
bogdanm 86:04dd9b1680ae 48
bogdanm 86:04dd9b1680ae 49 /** @addtogroup STM32F3xx_HAL_Driver
bogdanm 86:04dd9b1680ae 50 * @{
bogdanm 86:04dd9b1680ae 51 */
bogdanm 86:04dd9b1680ae 52
bogdanm 92:4fc01daae5a5 53 /** @addtogroup FLASH FLASH HAL module driver
bogdanm 86:04dd9b1680ae 54 * @{
bogdanm 86:04dd9b1680ae 55 */
bogdanm 86:04dd9b1680ae 56
bogdanm 86:04dd9b1680ae 57 /* Exported types ------------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 58 /** @defgroup FLASH_Exported_Types FLASH Exported Types
bogdanm 86:04dd9b1680ae 59 * @{
bogdanm 86:04dd9b1680ae 60 */
bogdanm 86:04dd9b1680ae 61
bogdanm 86:04dd9b1680ae 62 /**
bogdanm 86:04dd9b1680ae 63 * @brief FLASH Error source
bogdanm 86:04dd9b1680ae 64 */
bogdanm 86:04dd9b1680ae 65 typedef enum
bogdanm 86:04dd9b1680ae 66 {
bogdanm 86:04dd9b1680ae 67 FLASH_ERROR_PG = 0x01,
bogdanm 86:04dd9b1680ae 68 FLASH_ERROR_WRP = 0x02
bogdanm 86:04dd9b1680ae 69 } FLASH_ErrorTypeDef;
bogdanm 86:04dd9b1680ae 70
bogdanm 86:04dd9b1680ae 71 /**
bogdanm 86:04dd9b1680ae 72 * @brief FLASH Erase structure definition
bogdanm 86:04dd9b1680ae 73 */
bogdanm 86:04dd9b1680ae 74 typedef struct
bogdanm 86:04dd9b1680ae 75 {
bogdanm 86:04dd9b1680ae 76 uint32_t TypeErase; /*!< TypeErase: Mass erase or page erase.
bogdanm 86:04dd9b1680ae 77 This parameter can be a value of @ref FLASH_Type_Erase */
bogdanm 86:04dd9b1680ae 78
bogdanm 86:04dd9b1680ae 79 uint32_t PageAddress; /*!< PageAdress: Initial FLASH page address to erase when mass erase is disabled
bogdanm 86:04dd9b1680ae 80 This parameter must be a value of @ref FLASHEx_Address */
bogdanm 86:04dd9b1680ae 81
bogdanm 86:04dd9b1680ae 82 uint32_t NbPages; /*!< NbPages: Number of pagess to be erased.
bogdanm 86:04dd9b1680ae 83 This parameter must be a value between 1 and (max number of pages - value of initial page)*/
bogdanm 86:04dd9b1680ae 84
bogdanm 86:04dd9b1680ae 85 } FLASH_EraseInitTypeDef;
bogdanm 86:04dd9b1680ae 86
bogdanm 86:04dd9b1680ae 87 /**
bogdanm 86:04dd9b1680ae 88 * @brief FLASH Options bytes program structure definition
bogdanm 86:04dd9b1680ae 89 */
bogdanm 86:04dd9b1680ae 90 typedef struct
bogdanm 86:04dd9b1680ae 91 {
bogdanm 86:04dd9b1680ae 92 uint32_t OptionType; /*!< OptionType: Option byte to be configured.
bogdanm 86:04dd9b1680ae 93 This parameter can be a value of @ref FLASH_OB_Type */
bogdanm 86:04dd9b1680ae 94
bogdanm 86:04dd9b1680ae 95 uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation.
bogdanm 86:04dd9b1680ae 96 This parameter can be a value of @ref FLASH_OB_WRP_State */
bogdanm 86:04dd9b1680ae 97
bogdanm 86:04dd9b1680ae 98 uint32_t WRPPage; /*!< WRPSector: specifies the page(s) to be write protected
bogdanm 86:04dd9b1680ae 99 This parameter can be a value of @ref FLASHEx_OB_Write_Protection */
bogdanm 86:04dd9b1680ae 100
bogdanm 86:04dd9b1680ae 101 uint8_t RDPLevel; /*!< RDPLevel: Set the read protection level..
bogdanm 86:04dd9b1680ae 102 This parameter can be a value of @ref FLASH_OB_Read_Protection */
bogdanm 86:04dd9b1680ae 103
bogdanm 86:04dd9b1680ae 104 uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte:
bogdanm 86:04dd9b1680ae 105 IWDG / STOP / STDBY / BOOT1 / VDDA_ANALOG / SRAM_PARITY / SDADC12_VDD_MONITOR
bogdanm 86:04dd9b1680ae 106 This parameter can be a combination of @ref FLASH_OB_IWatchdog, @ref FLASH_OB_nRST_STOP,
bogdanm 86:04dd9b1680ae 107 @ref FLASH_OB_nRST_STDBY, @ref FLASH_OB_BOOT1, @ref FLASH_OB_VDDA_Analog_Monitoring,
bogdanm 86:04dd9b1680ae 108 @ref FLASH_OB_SRAM_Parity_Enable and @ref FLASH_OB_SDADC12_VDD_MONITOR */
bogdanm 86:04dd9b1680ae 109
bogdanm 86:04dd9b1680ae 110 uint32_t DATAAddress; /*!< DATAAddress: Address of the option byte DATA to be prgrammed
bogdanm 86:04dd9b1680ae 111 This parameter can be a value of @ref FLASH_OB_Data_Address */
bogdanm 86:04dd9b1680ae 112
bogdanm 86:04dd9b1680ae 113 uint8_t DATAData; /*!< DATAData: Data to be stored in the option byte DATA
bogdanm 86:04dd9b1680ae 114 This parameter can have any value */
bogdanm 86:04dd9b1680ae 115
bogdanm 86:04dd9b1680ae 116 } FLASH_OBProgramInitTypeDef;
bogdanm 86:04dd9b1680ae 117
bogdanm 86:04dd9b1680ae 118 /**
bogdanm 86:04dd9b1680ae 119 * @brief FLASH Procedure structure definition
bogdanm 86:04dd9b1680ae 120 */
bogdanm 86:04dd9b1680ae 121 typedef enum
bogdanm 86:04dd9b1680ae 122 {
bogdanm 86:04dd9b1680ae 123 FLASH_PROC_NONE = 0,
bogdanm 86:04dd9b1680ae 124 FLASH_PROC_PAGEERASE = 1,
bogdanm 86:04dd9b1680ae 125 FLASH_PROC_MASSERASE = 2,
bogdanm 86:04dd9b1680ae 126 FLASH_PROC_PROGRAMHALFWORD = 3,
bogdanm 86:04dd9b1680ae 127 FLASH_PROC_PROGRAMWORD = 4,
bogdanm 86:04dd9b1680ae 128 FLASH_PROC_PROGRAMDOUBLEWORD = 5
bogdanm 86:04dd9b1680ae 129 } FLASH_ProcedureTypeDef;
bogdanm 86:04dd9b1680ae 130
bogdanm 86:04dd9b1680ae 131 /**
bogdanm 86:04dd9b1680ae 132 * @brief FLASH handle Structure definition
bogdanm 86:04dd9b1680ae 133 */
bogdanm 86:04dd9b1680ae 134 typedef struct
bogdanm 86:04dd9b1680ae 135 {
bogdanm 86:04dd9b1680ae 136 __IO FLASH_ProcedureTypeDef ProcedureOnGoing; /* Internal variable to indicate which procedure is ongoing or not in IT context */
bogdanm 86:04dd9b1680ae 137
bogdanm 86:04dd9b1680ae 138 __IO uint32_t DataRemaining; /* Internal variable to save the remaining pages to erase or half-word to program in IT context */
bogdanm 86:04dd9b1680ae 139
bogdanm 86:04dd9b1680ae 140 __IO uint32_t Address; /* Internal variable to save address selected for program or erase */
bogdanm 86:04dd9b1680ae 141
bogdanm 86:04dd9b1680ae 142 __IO uint64_t Data; /* Internal variable to save data to be programmed */
bogdanm 86:04dd9b1680ae 143
bogdanm 86:04dd9b1680ae 144 HAL_LockTypeDef Lock; /* FLASH locking object */
bogdanm 86:04dd9b1680ae 145
bogdanm 86:04dd9b1680ae 146 __IO FLASH_ErrorTypeDef ErrorCode; /* FLASH error code */
bogdanm 86:04dd9b1680ae 147
bogdanm 86:04dd9b1680ae 148 } FLASH_ProcessTypeDef;
bogdanm 86:04dd9b1680ae 149
bogdanm 86:04dd9b1680ae 150 /**
bogdanm 86:04dd9b1680ae 151 * @}
bogdanm 86:04dd9b1680ae 152 */
bogdanm 86:04dd9b1680ae 153
bogdanm 86:04dd9b1680ae 154 /* Exported constants --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 155 /** @defgroup FLASH_Exported_Constants FLASH Exported Constants
bogdanm 86:04dd9b1680ae 156 * @{
bogdanm 86:04dd9b1680ae 157 */
bogdanm 86:04dd9b1680ae 158
bogdanm 86:04dd9b1680ae 159 /** @defgroup FLASH_Type_Erase FLASH Type Erase
bogdanm 86:04dd9b1680ae 160 * @{
bogdanm 86:04dd9b1680ae 161 */
bogdanm 86:04dd9b1680ae 162 #define TYPEERASE_PAGES ((uint32_t)0x00) /*!<Pages erase only*/
bogdanm 86:04dd9b1680ae 163 #define TYPEERASE_MASSERASE ((uint32_t)0x01) /*!<Flash mass erase activation*/
bogdanm 86:04dd9b1680ae 164
bogdanm 86:04dd9b1680ae 165 #define IS_TYPEERASE(VALUE) (((VALUE) == TYPEERASE_PAGES) || \
bogdanm 86:04dd9b1680ae 166 ((VALUE) == TYPEERASE_MASSERASE))
bogdanm 86:04dd9b1680ae 167 /**
bogdanm 86:04dd9b1680ae 168 * @}
bogdanm 86:04dd9b1680ae 169 */
bogdanm 86:04dd9b1680ae 170
bogdanm 86:04dd9b1680ae 171 /** @defgroup FLASH_Type_Program FLASH Type Program
bogdanm 86:04dd9b1680ae 172 * @{
bogdanm 86:04dd9b1680ae 173 */
bogdanm 86:04dd9b1680ae 174 #define TYPEPROGRAM_HALFWORD ((uint32_t)0x01) /*!<Program a half-word (16-bit) at a specified address.*/
bogdanm 86:04dd9b1680ae 175 #define TYPEPROGRAM_WORD ((uint32_t)0x02) /*!<Program a word (32-bit) at a specified address.*/
bogdanm 86:04dd9b1680ae 176 #define TYPEPROGRAM_DOUBLEWORD ((uint32_t)0x03) /*!<Program a double word (64-bit) at a specified address*/
bogdanm 86:04dd9b1680ae 177
bogdanm 86:04dd9b1680ae 178 #define IS_TYPEPROGRAM(VALUE) (((VALUE) == TYPEPROGRAM_HALFWORD) || \
bogdanm 86:04dd9b1680ae 179 ((VALUE) == TYPEPROGRAM_WORD) || \
bogdanm 86:04dd9b1680ae 180 ((VALUE) == TYPEPROGRAM_DOUBLEWORD))
bogdanm 86:04dd9b1680ae 181 /**
bogdanm 86:04dd9b1680ae 182 * @}
bogdanm 86:04dd9b1680ae 183 */
bogdanm 86:04dd9b1680ae 184
bogdanm 86:04dd9b1680ae 185 /** @defgroup FLASH_OB_WRP_State FLASH WRP State
bogdanm 86:04dd9b1680ae 186 * @{
bogdanm 86:04dd9b1680ae 187 */
bogdanm 86:04dd9b1680ae 188 #define WRPSTATE_DISABLE ((uint32_t)0x00) /*!<Disable the write protection of the desired pages*/
bogdanm 86:04dd9b1680ae 189 #define WRPSTATE_ENABLE ((uint32_t)0x01) /*!<Enable the write protection of the desired pagess*/
bogdanm 86:04dd9b1680ae 190
bogdanm 86:04dd9b1680ae 191 #define IS_WRPSTATE(VALUE) (((VALUE) == WRPSTATE_DISABLE) || \
bogdanm 86:04dd9b1680ae 192 ((VALUE) == WRPSTATE_ENABLE))
bogdanm 86:04dd9b1680ae 193 /**
bogdanm 86:04dd9b1680ae 194 * @}
bogdanm 86:04dd9b1680ae 195 */
bogdanm 86:04dd9b1680ae 196
bogdanm 86:04dd9b1680ae 197 /** @defgroup FLASH_OB_Type FLASH Option Bytes Type
bogdanm 86:04dd9b1680ae 198 * @{
bogdanm 86:04dd9b1680ae 199 */
bogdanm 86:04dd9b1680ae 200 #define OPTIONBYTE_WRP ((uint32_t)0x01) /*!<WRP option byte configuration*/
bogdanm 86:04dd9b1680ae 201 #define OPTIONBYTE_RDP ((uint32_t)0x02) /*!<RDP option byte configuration*/
bogdanm 86:04dd9b1680ae 202 #define OPTIONBYTE_USER ((uint32_t)0x04) /*!<USER option byte configuration*/
bogdanm 86:04dd9b1680ae 203 #define OPTIONBYTE_DATA ((uint32_t)0x08) /*!<DATA option byte configuration*/
bogdanm 86:04dd9b1680ae 204
bogdanm 86:04dd9b1680ae 205 #define IS_OPTIONBYTE(VALUE) (((VALUE) < (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER | OPTIONBYTE_DATA)))
bogdanm 86:04dd9b1680ae 206 /**
bogdanm 86:04dd9b1680ae 207 * @}
bogdanm 86:04dd9b1680ae 208 */
bogdanm 86:04dd9b1680ae 209
bogdanm 92:4fc01daae5a5 210 /** @defgroup FLASH_Latency FLASH Latency
bogdanm 86:04dd9b1680ae 211 * @{
bogdanm 86:04dd9b1680ae 212 */
bogdanm 86:04dd9b1680ae 213 #define FLASH_LATENCY_0 ((uint8_t)0x0000) /*!< FLASH Zero Latency cycle */
bogdanm 86:04dd9b1680ae 214 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_0 /*!< FLASH One Latency cycle */
bogdanm 86:04dd9b1680ae 215 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_1 /*!< FLASH Two Latency cycles */
bogdanm 86:04dd9b1680ae 216
bogdanm 86:04dd9b1680ae 217 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
bogdanm 86:04dd9b1680ae 218 ((LATENCY) == FLASH_LATENCY_1) || \
bogdanm 86:04dd9b1680ae 219 ((LATENCY) == FLASH_LATENCY_2))
bogdanm 86:04dd9b1680ae 220 /**
bogdanm 86:04dd9b1680ae 221 * @}
bogdanm 86:04dd9b1680ae 222 */
bogdanm 86:04dd9b1680ae 223
bogdanm 92:4fc01daae5a5 224 /** @defgroup FLASH_OB_Data_Address FLASH Option Byte Data Address
bogdanm 86:04dd9b1680ae 225 * @{
bogdanm 86:04dd9b1680ae 226 */
bogdanm 86:04dd9b1680ae 227 #define IS_OB_DATA_ADDRESS(ADDRESS) (((ADDRESS) == 0x1FFFF804) || ((ADDRESS) == 0x1FFFF806))
bogdanm 86:04dd9b1680ae 228 /**
bogdanm 86:04dd9b1680ae 229 * @}
bogdanm 86:04dd9b1680ae 230 */
bogdanm 86:04dd9b1680ae 231
bogdanm 92:4fc01daae5a5 232 /** @defgroup FLASH_OB_Read_Protection FLASH Option Byte Read Protection
bogdanm 86:04dd9b1680ae 233 * @{
bogdanm 86:04dd9b1680ae 234 */
bogdanm 86:04dd9b1680ae 235 #define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
bogdanm 86:04dd9b1680ae 236 #define OB_RDP_LEVEL_1 ((uint8_t)0xBB)
bogdanm 86:04dd9b1680ae 237 #define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2
bogdanm 86:04dd9b1680ae 238 it's no more possible to go back to level 1 or 0 */
bogdanm 86:04dd9b1680ae 239 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
bogdanm 86:04dd9b1680ae 240 ((LEVEL) == OB_RDP_LEVEL_1))/*||\
bogdanm 86:04dd9b1680ae 241 ((LEVEL) == OB_RDP_LEVEL_2))*/
bogdanm 86:04dd9b1680ae 242 /**
bogdanm 86:04dd9b1680ae 243 * @}
bogdanm 86:04dd9b1680ae 244 */
bogdanm 86:04dd9b1680ae 245
bogdanm 92:4fc01daae5a5 246 /** @defgroup FLASH_OB_IWatchdog FLASH Option Byte IWatchdog
bogdanm 86:04dd9b1680ae 247 * @{
bogdanm 86:04dd9b1680ae 248 */
bogdanm 86:04dd9b1680ae 249 #define OB_IWDG_SW ((uint8_t)0x01) /*!< Software IWDG selected */
bogdanm 86:04dd9b1680ae 250 #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */
bogdanm 86:04dd9b1680ae 251 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
bogdanm 86:04dd9b1680ae 252 /**
bogdanm 86:04dd9b1680ae 253 * @}
bogdanm 86:04dd9b1680ae 254 */
bogdanm 86:04dd9b1680ae 255
bogdanm 92:4fc01daae5a5 256 /** @defgroup FLASH_OB_nRST_STOP FLASH Option Byte nRST STOP
bogdanm 86:04dd9b1680ae 257 * @{
bogdanm 86:04dd9b1680ae 258 */
bogdanm 86:04dd9b1680ae 259 #define OB_STOP_NO_RST ((uint8_t)0x02) /*!< No reset generated when entering in STOP */
bogdanm 86:04dd9b1680ae 260 #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
bogdanm 86:04dd9b1680ae 261 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
bogdanm 86:04dd9b1680ae 262 /**
bogdanm 86:04dd9b1680ae 263 * @}
bogdanm 86:04dd9b1680ae 264 */
bogdanm 86:04dd9b1680ae 265
bogdanm 92:4fc01daae5a5 266 /** @defgroup FLASH_OB_nRST_STDBY FLASH Option Byte nRST STDBY
bogdanm 86:04dd9b1680ae 267 * @{
bogdanm 86:04dd9b1680ae 268 */
bogdanm 86:04dd9b1680ae 269 #define OB_STDBY_NO_RST ((uint8_t)0x04) /*!< No reset generated when entering in STANDBY */
bogdanm 86:04dd9b1680ae 270 #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
bogdanm 86:04dd9b1680ae 271 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
bogdanm 86:04dd9b1680ae 272 /**
bogdanm 86:04dd9b1680ae 273 * @}
bogdanm 86:04dd9b1680ae 274 */
bogdanm 86:04dd9b1680ae 275
bogdanm 92:4fc01daae5a5 276 /** @defgroup FLASH_OB_BOOT1 FLASH Option Byte BOOT1
bogdanm 86:04dd9b1680ae 277 * @{
bogdanm 86:04dd9b1680ae 278 */
bogdanm 86:04dd9b1680ae 279 #define OB_BOOT1_RESET ((uint8_t)0x00) /*!< BOOT1 Reset */
bogdanm 86:04dd9b1680ae 280 #define OB_BOOT1_SET ((uint8_t)0x10) /*!< BOOT1 Set */
bogdanm 86:04dd9b1680ae 281 #define IS_OB_BOOT1(BOOT1) (((BOOT1) == OB_BOOT1_RESET) || ((BOOT1) == OB_BOOT1_SET))
bogdanm 86:04dd9b1680ae 282 /**
bogdanm 86:04dd9b1680ae 283 * @}
bogdanm 86:04dd9b1680ae 284 */
bogdanm 86:04dd9b1680ae 285
bogdanm 92:4fc01daae5a5 286 /** @defgroup FLASH_OB_VDDA_Analog_Monitoring FLASH Option Byte VDDA Analog Monitoring
bogdanm 86:04dd9b1680ae 287 * @{
bogdanm 86:04dd9b1680ae 288 */
bogdanm 86:04dd9b1680ae 289 #define OB_VDDA_ANALOG_ON ((uint8_t)0x20) /*!< Analog monitoring on VDDA Power source ON */
bogdanm 86:04dd9b1680ae 290 #define OB_VDDA_ANALOG_OFF ((uint8_t)0x00) /*!< Analog monitoring on VDDA Power source OFF */
bogdanm 86:04dd9b1680ae 291 #define IS_OB_VDDA_ANALOG(ANALOG) (((ANALOG) == OB_VDDA_ANALOG_ON) || ((ANALOG) == OB_VDDA_ANALOG_OFF))
bogdanm 86:04dd9b1680ae 292 /**
bogdanm 86:04dd9b1680ae 293 * @}
bogdanm 86:04dd9b1680ae 294 */
bogdanm 86:04dd9b1680ae 295
bogdanm 92:4fc01daae5a5 296 /** @defgroup FLASH_OB_SRAM_Parity_Enable FLASH Option Byte SRAM Parity Enable
bogdanm 86:04dd9b1680ae 297 * @{
bogdanm 86:04dd9b1680ae 298 */
bogdanm 86:04dd9b1680ae 299 #define OB_SRAM_PARITY_SET ((uint8_t)0x00) /*!< SRAM parity enable set */
bogdanm 86:04dd9b1680ae 300 #define OB_SRAM_PARITY_RESET ((uint8_t)0x40) /*!< SRAM parity enable reset */
bogdanm 86:04dd9b1680ae 301 #define IS_OB_SRAM_PARITY(PARITY) (((PARITY) == OB_SRAM_PARITY_SET) || ((PARITY) == OB_SRAM_PARITY_RESET))
bogdanm 86:04dd9b1680ae 302 /**
bogdanm 86:04dd9b1680ae 303 * @}
bogdanm 86:04dd9b1680ae 304 */
bogdanm 86:04dd9b1680ae 305
bogdanm 92:4fc01daae5a5 306 /** @defgroup FLASH_OB_SDADC12_VDD_MONITOR FLASH Option Byte SDADC12 VDD MONITOR
bogdanm 86:04dd9b1680ae 307 * @{
bogdanm 86:04dd9b1680ae 308 */
bogdanm 86:04dd9b1680ae 309 #define OB_SDADC12_VDD_MONITOR_SET ((uint8_t)0x80) /*!< SDADC12_VDD power supply supervisor set */
bogdanm 86:04dd9b1680ae 310 #define OB_SDADC12_VDD_MONITOR_RESET ((uint8_t)0x00) /*!< SDADC12_VDD power supply supervisor reset */
bogdanm 86:04dd9b1680ae 311 #define IS_OB_SDADC12_VDD_MONITOR(MONITOR) (((MONITOR) == OB_SDADC12_VDD_MONITOR_SET) || ((MONITOR) == OB_SDADC12_VDD_MONITOR_RESET))
bogdanm 86:04dd9b1680ae 312 /**
bogdanm 86:04dd9b1680ae 313 * @}
bogdanm 86:04dd9b1680ae 314 */
bogdanm 86:04dd9b1680ae 315
bogdanm 92:4fc01daae5a5 316 /** @defgroup FLASH_Flag_definition FLASH Flag definition
bogdanm 86:04dd9b1680ae 317 * @brief Flag definition
bogdanm 86:04dd9b1680ae 318 * @{
bogdanm 86:04dd9b1680ae 319 */
bogdanm 86:04dd9b1680ae 320 #define FLASH_FLAG_BSY FLASH_SR_BSY /*!< FLASH Busy flag */
bogdanm 86:04dd9b1680ae 321 #define FLASH_FLAG_PGERR FLASH_SR_PGERR /*!< FLASH Programming error flag */
bogdanm 86:04dd9b1680ae 322 #define FLASH_FLAG_WRPERR FLASH_SR_WRPERR /*!< FLASH Write protected error flag */
bogdanm 86:04dd9b1680ae 323 #define FLASH_FLAG_EOP FLASH_SR_EOP /*!< FLASH End of Operation flag */
bogdanm 86:04dd9b1680ae 324
bogdanm 86:04dd9b1680ae 325 #define IS_FLASH_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFFFFC3) == 0x00000000) && ((FLAG) != 0x00000000))
bogdanm 86:04dd9b1680ae 326 #define IS_FLASH_GET_FLAG(FLAG) (((FLAG) == FLASH_FLAG_BSY) || ((FLAG) == FLASH_FLAG_PGERR) || \
bogdanm 86:04dd9b1680ae 327 ((FLAG) == FLASH_FLAG_WRPERR) || ((FLAG) == FLASH_FLAG_EOP))
bogdanm 86:04dd9b1680ae 328 /**
bogdanm 86:04dd9b1680ae 329 * @}
bogdanm 86:04dd9b1680ae 330 */
bogdanm 86:04dd9b1680ae 331
bogdanm 92:4fc01daae5a5 332 /** @defgroup FLASH_Interrupt_definition FLASH Interrupt definition
bogdanm 86:04dd9b1680ae 333 * @brief FLASH Interrupt definition
bogdanm 86:04dd9b1680ae 334 * @{
bogdanm 86:04dd9b1680ae 335 */
bogdanm 86:04dd9b1680ae 336 #define FLASH_IT_EOP FLASH_CR_EOPIE /*!< End of FLASH Operation Interrupt source */
bogdanm 86:04dd9b1680ae 337 #define FLASH_IT_ERR FLASH_CR_ERRIE /*!< Error Interrupt source */
bogdanm 86:04dd9b1680ae 338 #define IS_FLASH_IT(IT) ((((IT) & (uint32_t)0xFFFFEBFF) == 0x00000000) && ((IT) != 0x00000000))
bogdanm 86:04dd9b1680ae 339 /**
bogdanm 86:04dd9b1680ae 340 * @}
bogdanm 86:04dd9b1680ae 341 */
bogdanm 86:04dd9b1680ae 342
bogdanm 92:4fc01daae5a5 343 /** @defgroup FLASH_Timeout_definition FLASH Timeout definition
bogdanm 86:04dd9b1680ae 344 * @brief FLASH Timeout definition
bogdanm 86:04dd9b1680ae 345 * @{
bogdanm 86:04dd9b1680ae 346 */
bogdanm 86:04dd9b1680ae 347 #define HAL_FLASH_TIMEOUT_VALUE ((uint32_t)50000)/* 50 s */
bogdanm 86:04dd9b1680ae 348 /**
bogdanm 86:04dd9b1680ae 349 * @}
bogdanm 86:04dd9b1680ae 350 */
bogdanm 86:04dd9b1680ae 351
bogdanm 86:04dd9b1680ae 352 /**
bogdanm 86:04dd9b1680ae 353 * @}
bogdanm 86:04dd9b1680ae 354 */
bogdanm 86:04dd9b1680ae 355
bogdanm 86:04dd9b1680ae 356 /* Exported macro ------------------------------------------------------------*/
bogdanm 86:04dd9b1680ae 357
bogdanm 92:4fc01daae5a5 358 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
bogdanm 86:04dd9b1680ae 359 * @brief macros to control FLASH features
bogdanm 86:04dd9b1680ae 360 * @{
bogdanm 86:04dd9b1680ae 361 */
bogdanm 86:04dd9b1680ae 362
bogdanm 86:04dd9b1680ae 363 /**
bogdanm 86:04dd9b1680ae 364 * @brief Set the FLASH Latency.
bogdanm 86:04dd9b1680ae 365 * @param __LATENCY__: FLASH Latency
bogdanm 86:04dd9b1680ae 366 * The value of this parameter depend on device used within the same series
bogdanm 86:04dd9b1680ae 367 * @retval None
bogdanm 86:04dd9b1680ae 368 */
bogdanm 86:04dd9b1680ae 369 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) (FLASH->ACR = (FLASH->ACR&(~FLASH_ACR_LATENCY)) | (__LATENCY__))
bogdanm 86:04dd9b1680ae 370
bogdanm 86:04dd9b1680ae 371 /**
bogdanm 86:04dd9b1680ae 372 * @brief Enable the FLASH prefetch buffer.
bogdanm 86:04dd9b1680ae 373 * @retval None
bogdanm 86:04dd9b1680ae 374 */
bogdanm 86:04dd9b1680ae 375 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() (FLASH->ACR |= FLASH_ACR_PRFTBE)
bogdanm 86:04dd9b1680ae 376
bogdanm 86:04dd9b1680ae 377 /**
bogdanm 86:04dd9b1680ae 378 * @brief Disable the FLASH prefetch buffer.
bogdanm 86:04dd9b1680ae 379 * @retval None
bogdanm 86:04dd9b1680ae 380 */
bogdanm 86:04dd9b1680ae 381 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() (FLASH->ACR &= (~FLASH_ACR_PRFTBE))
bogdanm 86:04dd9b1680ae 382
bogdanm 86:04dd9b1680ae 383 /**
bogdanm 86:04dd9b1680ae 384 * @brief Enable the FLASH half cycle access.
bogdanm 86:04dd9b1680ae 385 * @retval None
bogdanm 86:04dd9b1680ae 386 */
bogdanm 86:04dd9b1680ae 387 #define __HAL_FLASH_HALF_CYCLE_ACCESS_ENABLE() (FLASH->ACR |= FLASH_ACR_HLFCYA)
bogdanm 86:04dd9b1680ae 388
bogdanm 86:04dd9b1680ae 389 /**
bogdanm 86:04dd9b1680ae 390 * @brief Disable the FLASH half cycle access.
bogdanm 86:04dd9b1680ae 391 * @retval None
bogdanm 86:04dd9b1680ae 392 */
bogdanm 86:04dd9b1680ae 393 #define __HAL_FLASH_HALF_CYCLE_ACCESS_DISABLE() (FLASH->ACR &= (~FLASH_ACR_HLFCYA))
bogdanm 86:04dd9b1680ae 394
bogdanm 92:4fc01daae5a5 395 /** @defgroup FLASH_Interrupt FLASH Interrupt
bogdanm 86:04dd9b1680ae 396 * @brief macros to handle FLASH interrupts
bogdanm 86:04dd9b1680ae 397 * @{
bogdanm 86:04dd9b1680ae 398 */
bogdanm 86:04dd9b1680ae 399
bogdanm 86:04dd9b1680ae 400 /**
bogdanm 86:04dd9b1680ae 401 * @brief Enable the specified FLASH interrupt.
bogdanm 86:04dd9b1680ae 402 * @param __INTERRUPT__ : FLASH interrupt
bogdanm 86:04dd9b1680ae 403 * This parameter can be any combination of the following values:
bogdanm 86:04dd9b1680ae 404 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
bogdanm 86:04dd9b1680ae 405 * @arg FLASH_IT_ERR: Error Interrupt
bogdanm 86:04dd9b1680ae 406 * @retval none
bogdanm 86:04dd9b1680ae 407 */
bogdanm 86:04dd9b1680ae 408 #define __HAL_FLASH_ENABLE_IT(__INTERRUPT__) (FLASH->CR |= (__INTERRUPT__))
bogdanm 86:04dd9b1680ae 409
bogdanm 86:04dd9b1680ae 410 /**
bogdanm 86:04dd9b1680ae 411 * @brief Disable the specified FLASH interrupt.
bogdanm 86:04dd9b1680ae 412 * @param __INTERRUPT__ : FLASH interrupt
bogdanm 86:04dd9b1680ae 413 * This parameter can be any combination of the following values:
bogdanm 86:04dd9b1680ae 414 * @arg FLASH_IT_EOP: End of FLASH Operation Interrupt
bogdanm 86:04dd9b1680ae 415 * @arg FLASH_IT_ERR: Error Interrupt
bogdanm 86:04dd9b1680ae 416 * @retval none
bogdanm 86:04dd9b1680ae 417 */
bogdanm 86:04dd9b1680ae 418 #define __HAL_FLASH_DISABLE_IT(__INTERRUPT__) (FLASH->CR &= ~(uint32_t)(__INTERRUPT__))
bogdanm 86:04dd9b1680ae 419
bogdanm 86:04dd9b1680ae 420 /**
bogdanm 86:04dd9b1680ae 421 * @brief Get the specified FLASH flag status.
bogdanm 86:04dd9b1680ae 422 * @param __FLAG__: specifies the FLASH flag to check.
bogdanm 86:04dd9b1680ae 423 * This parameter can be one of the following values:
bogdanm 86:04dd9b1680ae 424 * @arg FLASH_FLAG_EOP : FLASH End of Operation flag
bogdanm 86:04dd9b1680ae 425 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
bogdanm 86:04dd9b1680ae 426 * @arg FLASH_FLAG_PGERR : FLASH Programming error flag
bogdanm 86:04dd9b1680ae 427 * @arg FLASH_FLAG_BSY : FLASH Busy flag
bogdanm 86:04dd9b1680ae 428 * @retval The new state of __FLAG__ (SET or RESET).
bogdanm 86:04dd9b1680ae 429 */
bogdanm 86:04dd9b1680ae 430 #define __HAL_FLASH_GET_FLAG(__FLAG__) ((FLASH->SR & (__FLAG__)) == (__FLAG__))
bogdanm 86:04dd9b1680ae 431
bogdanm 86:04dd9b1680ae 432 /**
bogdanm 86:04dd9b1680ae 433 * @brief Clear the specified FLASH flag.
bogdanm 86:04dd9b1680ae 434 * @param __FLAG__: specifies the FLASH flags to clear.
bogdanm 86:04dd9b1680ae 435 * This parameter can be any combination of the following values:
bogdanm 86:04dd9b1680ae 436 * @arg FLASH_FLAG_EOP : FLASH End of Operation flag
bogdanm 86:04dd9b1680ae 437 * @arg FLASH_FLAG_WRPERR: FLASH Write protected error flag
bogdanm 86:04dd9b1680ae 438 * @arg FLASH_FLAG_PGERR : FLASH Programming error flag
bogdanm 86:04dd9b1680ae 439 * @retval none
bogdanm 86:04dd9b1680ae 440 */
bogdanm 86:04dd9b1680ae 441 #define __HAL_FLASH_CLEAR_FLAG(__FLAG__) (FLASH->SR = (__FLAG__))
bogdanm 86:04dd9b1680ae 442
bogdanm 86:04dd9b1680ae 443 /**
bogdanm 86:04dd9b1680ae 444 * @}
bogdanm 92:4fc01daae5a5 445 */
bogdanm 92:4fc01daae5a5 446
bogdanm 92:4fc01daae5a5 447 /**
bogdanm 92:4fc01daae5a5 448 * @}
bogdanm 86:04dd9b1680ae 449 */
bogdanm 86:04dd9b1680ae 450
bogdanm 92:4fc01daae5a5 451 /* Include FLASH HAL Extended module */
bogdanm 86:04dd9b1680ae 452 #include "stm32f3xx_hal_flash_ex.h"
bogdanm 86:04dd9b1680ae 453
bogdanm 86:04dd9b1680ae 454 /* Exported functions --------------------------------------------------------*/
bogdanm 92:4fc01daae5a5 455 /** @addtogroup FLASH_Exported_Functions FLASH Exported Functions
bogdanm 86:04dd9b1680ae 456 * @{
bogdanm 92:4fc01daae5a5 457 */
bogdanm 92:4fc01daae5a5 458
bogdanm 92:4fc01daae5a5 459 /** @addtogroup FLASH_Exported_Functions_Group1 Input and Output operation functions
bogdanm 92:4fc01daae5a5 460 * @{
bogdanm 92:4fc01daae5a5 461 */
bogdanm 86:04dd9b1680ae 462 /* IO operation functions *****************************************************/
bogdanm 86:04dd9b1680ae 463 HAL_StatusTypeDef HAL_FLASH_Program(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
bogdanm 86:04dd9b1680ae 464 HAL_StatusTypeDef HAL_FLASH_Program_IT(uint32_t TypeProgram, uint32_t Address, uint64_t Data);
bogdanm 86:04dd9b1680ae 465
bogdanm 86:04dd9b1680ae 466 /* FLASH IRQ handler method */
bogdanm 86:04dd9b1680ae 467 void HAL_FLASH_IRQHandler(void);
bogdanm 86:04dd9b1680ae 468 /* Callbacks in non blocking modes */
bogdanm 86:04dd9b1680ae 469 void HAL_FLASH_EndOfOperationCallback(uint32_t ReturnValue);
bogdanm 86:04dd9b1680ae 470 void HAL_FLASH_OperationErrorCallback(uint32_t ReturnValue);
bogdanm 86:04dd9b1680ae 471
bogdanm 92:4fc01daae5a5 472 /**
bogdanm 92:4fc01daae5a5 473 * @}
bogdanm 92:4fc01daae5a5 474 */
bogdanm 92:4fc01daae5a5 475
bogdanm 92:4fc01daae5a5 476 /** @addtogroup FLASH_Exported_Functions_Group2 Peripheral Control functions
bogdanm 92:4fc01daae5a5 477 * @{
bogdanm 92:4fc01daae5a5 478 */
bogdanm 86:04dd9b1680ae 479 /* Peripheral Control functions ***********************************************/
bogdanm 86:04dd9b1680ae 480 HAL_StatusTypeDef HAL_FLASH_Unlock(void);
bogdanm 86:04dd9b1680ae 481 HAL_StatusTypeDef HAL_FLASH_Lock(void);
bogdanm 86:04dd9b1680ae 482 HAL_StatusTypeDef HAL_FLASH_OB_Unlock(void);
bogdanm 86:04dd9b1680ae 483 HAL_StatusTypeDef HAL_FLASH_OB_Lock(void);
bogdanm 86:04dd9b1680ae 484 /* Option bytes control */
bogdanm 86:04dd9b1680ae 485 HAL_StatusTypeDef HAL_FLASH_OB_Launch(void);
bogdanm 86:04dd9b1680ae 486
bogdanm 92:4fc01daae5a5 487 /**
bogdanm 92:4fc01daae5a5 488 * @}
bogdanm 92:4fc01daae5a5 489 */
bogdanm 92:4fc01daae5a5 490
bogdanm 92:4fc01daae5a5 491 /** @addtogroup FLASH_Exported_Functions_Group3 Peripheral State functions
bogdanm 92:4fc01daae5a5 492 * @{
bogdanm 92:4fc01daae5a5 493 */
bogdanm 86:04dd9b1680ae 494 /* Peripheral State and Error functions ***************************************/
bogdanm 86:04dd9b1680ae 495 FLASH_ErrorTypeDef HAL_FLASH_GetError(void);
bogdanm 86:04dd9b1680ae 496
bogdanm 86:04dd9b1680ae 497 /**
bogdanm 86:04dd9b1680ae 498 * @}
bogdanm 86:04dd9b1680ae 499 */
bogdanm 86:04dd9b1680ae 500
bogdanm 86:04dd9b1680ae 501 /**
bogdanm 86:04dd9b1680ae 502 * @}
bogdanm 86:04dd9b1680ae 503 */
bogdanm 86:04dd9b1680ae 504
bogdanm 92:4fc01daae5a5 505 /* Exported Private function -------------------------------------------------*/
bogdanm 92:4fc01daae5a5 506 /** @addtogroup FLASH_Exported_Private_Functions FLASH Exported Private Functions
bogdanm 92:4fc01daae5a5 507 * @{
bogdanm 92:4fc01daae5a5 508 */
bogdanm 92:4fc01daae5a5 509 /* Erase operations */
bogdanm 92:4fc01daae5a5 510 void FLASH_PageErase(uint32_t PageAddress);
bogdanm 92:4fc01daae5a5 511 HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout);
bogdanm 92:4fc01daae5a5 512
bogdanm 92:4fc01daae5a5 513 /* Program operations */
bogdanm 92:4fc01daae5a5 514 /**
bogdanm 92:4fc01daae5a5 515 * @}
bogdanm 92:4fc01daae5a5 516 */
bogdanm 92:4fc01daae5a5 517
bogdanm 92:4fc01daae5a5 518 /**
bogdanm 92:4fc01daae5a5 519 * @}
bogdanm 92:4fc01daae5a5 520 */
bogdanm 92:4fc01daae5a5 521
bogdanm 86:04dd9b1680ae 522 /**
bogdanm 86:04dd9b1680ae 523 * @}
bogdanm 86:04dd9b1680ae 524 */
bogdanm 86:04dd9b1680ae 525
bogdanm 86:04dd9b1680ae 526 #ifdef __cplusplus
bogdanm 86:04dd9b1680ae 527 }
bogdanm 86:04dd9b1680ae 528 #endif
bogdanm 86:04dd9b1680ae 529
bogdanm 86:04dd9b1680ae 530 #endif /* __STM32F3xx_HAL_FLASH_H */
bogdanm 86:04dd9b1680ae 531
bogdanm 86:04dd9b1680ae 532 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/