1 /** 2 ****************************************************************************** 3 * @file stm32f4xx_hal_flash_ex.h 4 * @author MCD Application Team 5 * @brief Header file of FLASH HAL Extension module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved.</center></h2> 11 * 12 * This software component is licensed by ST under BSD 3-Clause license, 13 * the "License"; You may not use this file except in compliance with the 14 * License. You may obtain a copy of the License at: 15 * opensource.org/licenses/BSD-3-Clause 16 * 17 ****************************************************************************** 18 */ 19 20 /* Define to prevent recursive inclusion -------------------------------------*/ 21 #ifndef __STM32F4xx_HAL_FLASH_EX_H 22 #define __STM32F4xx_HAL_FLASH_EX_H 23 24 #ifdef __cplusplus 25 extern "C" { 26 #endif 27 28 /* Includes ------------------------------------------------------------------*/ 29 #include "stm32f4xx_hal_def.h" 30 31 /** @addtogroup STM32F4xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @addtogroup FLASHEx 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types 41 * @{ 42 */ 43 44 /** 45 * @brief FLASH Erase structure definition 46 */ 47 typedef struct 48 { 49 uint32_t TypeErase; /*!< Mass erase or sector Erase. 50 This parameter can be a value of @ref FLASHEx_Type_Erase */ 51 52 uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled. 53 This parameter must be a value of @ref FLASHEx_Banks */ 54 55 uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled 56 This parameter must be a value of @ref FLASHEx_Sectors */ 57 58 uint32_t NbSectors; /*!< Number of sectors to be erased. 59 This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/ 60 61 uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism 62 This parameter must be a value of @ref FLASHEx_Voltage_Range */ 63 64 } FLASH_EraseInitTypeDef; 65 66 /** 67 * @brief FLASH Option Bytes Program structure definition 68 */ 69 typedef struct 70 { 71 uint32_t OptionType; /*!< Option byte to be configured. 72 This parameter can be a value of @ref FLASHEx_Option_Type */ 73 74 uint32_t WRPState; /*!< Write protection activation or deactivation. 75 This parameter can be a value of @ref FLASHEx_WRP_State */ 76 77 uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected. 78 The value of this parameter depend on device used within the same series */ 79 80 uint32_t Banks; /*!< Select banks for WRP activation/deactivation of all sectors. 81 This parameter must be a value of @ref FLASHEx_Banks */ 82 83 uint32_t RDPLevel; /*!< Set the read protection level. 84 This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */ 85 86 uint32_t BORLevel; /*!< Set the BOR Level. 87 This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */ 88 89 uint8_t USERConfig; /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */ 90 91 } FLASH_OBProgramInitTypeDef; 92 93 /** 94 * @brief FLASH Advanced Option Bytes Program structure definition 95 */ 96 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 97 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 98 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 99 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 100 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 101 typedef struct 102 { 103 uint32_t OptionType; /*!< Option byte to be configured for extension. 104 This parameter can be a value of @ref FLASHEx_Advanced_Option_Type */ 105 106 uint32_t PCROPState; /*!< PCROP activation or deactivation. 107 This parameter can be a value of @ref FLASHEx_PCROP_State */ 108 109 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 110 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 111 uint16_t Sectors; /*!< specifies the sector(s) set for PCROP. 112 This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ 113 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx ||\ 114 STM32F412Cx || STM32F413xx || STM32F423xx */ 115 116 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 117 uint32_t Banks; /*!< Select banks for PCROP activation/deactivation of all sectors. 118 This parameter must be a value of @ref FLASHEx_Banks */ 119 120 uint16_t SectorsBank1; /*!< Specifies the sector(s) set for PCROP for Bank1. 121 This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ 122 123 uint16_t SectorsBank2; /*!< Specifies the sector(s) set for PCROP for Bank2. 124 This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ 125 126 uint8_t BootConfig; /*!< Specifies Option bytes for boot config. 127 This parameter can be a value of @ref FLASHEx_Dual_Boot */ 128 129 #endif /*STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 130 }FLASH_AdvOBProgramInitTypeDef; 131 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || 132 STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 133 /** 134 * @} 135 */ 136 137 /* Exported constants --------------------------------------------------------*/ 138 139 /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants 140 * @{ 141 */ 142 143 /** @defgroup FLASHEx_Type_Erase FLASH Type Erase 144 * @{ 145 */ 146 #define FLASH_TYPEERASE_SECTORS 0x00000000U /*!< Sectors erase only */ 147 #define FLASH_TYPEERASE_MASSERASE 0x00000001U /*!< Flash Mass erase activation */ 148 /** 149 * @} 150 */ 151 152 /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range 153 * @{ 154 */ 155 #define FLASH_VOLTAGE_RANGE_1 0x00000000U /*!< Device operating range: 1.8V to 2.1V */ 156 #define FLASH_VOLTAGE_RANGE_2 0x00000001U /*!< Device operating range: 2.1V to 2.7V */ 157 #define FLASH_VOLTAGE_RANGE_3 0x00000002U /*!< Device operating range: 2.7V to 3.6V */ 158 #define FLASH_VOLTAGE_RANGE_4 0x00000003U /*!< Device operating range: 2.7V to 3.6V + External Vpp */ 159 /** 160 * @} 161 */ 162 163 /** @defgroup FLASHEx_WRP_State FLASH WRP State 164 * @{ 165 */ 166 #define OB_WRPSTATE_DISABLE 0x00000000U /*!< Disable the write protection of the desired bank 1 sectors */ 167 #define OB_WRPSTATE_ENABLE 0x00000001U /*!< Enable the write protection of the desired bank 1 sectors */ 168 /** 169 * @} 170 */ 171 172 /** @defgroup FLASHEx_Option_Type FLASH Option Type 173 * @{ 174 */ 175 #define OPTIONBYTE_WRP 0x00000001U /*!< WRP option byte configuration */ 176 #define OPTIONBYTE_RDP 0x00000002U /*!< RDP option byte configuration */ 177 #define OPTIONBYTE_USER 0x00000004U /*!< USER option byte configuration */ 178 #define OPTIONBYTE_BOR 0x00000008U /*!< BOR option byte configuration */ 179 /** 180 * @} 181 */ 182 183 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection 184 * @{ 185 */ 186 #define OB_RDP_LEVEL_0 ((uint8_t)0xAA) 187 #define OB_RDP_LEVEL_1 ((uint8_t)0x55) 188 #define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2 189 it s no more possible to go back to level 1 or 0 */ 190 /** 191 * @} 192 */ 193 194 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog 195 * @{ 196 */ 197 #define OB_IWDG_SW ((uint8_t)0x20) /*!< Software IWDG selected */ 198 #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */ 199 /** 200 * @} 201 */ 202 203 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP 204 * @{ 205 */ 206 #define OB_STOP_NO_RST ((uint8_t)0x40) /*!< No reset generated when entering in STOP */ 207 #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */ 208 /** 209 * @} 210 */ 211 212 213 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY 214 * @{ 215 */ 216 #define OB_STDBY_NO_RST ((uint8_t)0x80) /*!< No reset generated when entering in STANDBY */ 217 #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */ 218 /** 219 * @} 220 */ 221 222 /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level 223 * @{ 224 */ 225 #define OB_BOR_LEVEL3 ((uint8_t)0x00) /*!< Supply voltage ranges from 2.70 to 3.60 V */ 226 #define OB_BOR_LEVEL2 ((uint8_t)0x04) /*!< Supply voltage ranges from 2.40 to 2.70 V */ 227 #define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< Supply voltage ranges from 2.10 to 2.40 V */ 228 #define OB_BOR_OFF ((uint8_t)0x0C) /*!< Supply voltage ranges from 1.62 to 2.10 V */ 229 /** 230 * @} 231 */ 232 233 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 234 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 235 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 236 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 237 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 238 /** @defgroup FLASHEx_PCROP_State FLASH PCROP State 239 * @{ 240 */ 241 #define OB_PCROP_STATE_DISABLE 0x00000000U /*!< Disable PCROP */ 242 #define OB_PCROP_STATE_ENABLE 0x00000001U /*!< Enable PCROP */ 243 /** 244 * @} 245 */ 246 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\ 247 STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ 248 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 249 250 /** @defgroup FLASHEx_Advanced_Option_Type FLASH Advanced Option Type 251 * @{ 252 */ 253 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 254 defined(STM32F469xx) || defined(STM32F479xx) 255 #define OPTIONBYTE_PCROP 0x00000001U /*!< PCROP option byte configuration */ 256 #define OPTIONBYTE_BOOTCONFIG 0x00000002U /*!< BOOTConfig option byte configuration */ 257 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 258 259 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 260 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 261 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\ 262 defined(STM32F423xx) 263 #define OPTIONBYTE_PCROP 0x00000001U /*!<PCROP option byte configuration */ 264 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || 265 STM32F413xx || STM32F423xx */ 266 /** 267 * @} 268 */ 269 270 /** @defgroup FLASH_Latency FLASH Latency 271 * @{ 272 */ 273 /*------------------------- STM32F42xxx/STM32F43xxx/STM32F446xx/STM32F469xx/STM32F479xx ----------------------*/ 274 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 275 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 276 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */ 277 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */ 278 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */ 279 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */ 280 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */ 281 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */ 282 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */ 283 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */ 284 #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight Latency cycles */ 285 #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine Latency cycles */ 286 #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten Latency cycles */ 287 #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven Latency cycles */ 288 #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve Latency cycles */ 289 #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen Latency cycles */ 290 #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen Latency cycles */ 291 #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen Latency cycles */ 292 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 293 /*--------------------------------------------------------------------------------------------------------------*/ 294 295 /*-------------------------- STM32F40xxx/STM32F41xxx/STM32F401xx/STM32F411xx/STM32F423xx -----------------------*/ 296 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ 297 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 298 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\ 299 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 300 301 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */ 302 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */ 303 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */ 304 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */ 305 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */ 306 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */ 307 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */ 308 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */ 309 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || 310 STM32F413xx || STM32F423xx */ 311 /*--------------------------------------------------------------------------------------------------------------*/ 312 313 /** 314 * @} 315 */ 316 317 318 /** @defgroup FLASHEx_Banks FLASH Banks 319 * @{ 320 */ 321 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 322 defined(STM32F469xx) || defined(STM32F479xx) 323 #define FLASH_BANK_1 1U /*!< Bank 1 */ 324 #define FLASH_BANK_2 2U /*!< Bank 2 */ 325 #define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */ 326 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 327 328 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ 329 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 330 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 331 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\ 332 defined(STM32F423xx) 333 #define FLASH_BANK_1 1U /*!< Bank 1 */ 334 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx 335 STM32F413xx || STM32F423xx */ 336 /** 337 * @} 338 */ 339 340 /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit 341 * @{ 342 */ 343 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 344 defined(STM32F469xx) || defined(STM32F479xx) 345 #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits here to clear */ 346 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 347 348 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ 349 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 350 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 351 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\ 352 defined(STM32F423xx) 353 #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER Bit */ 354 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx 355 STM32F413xx || STM32F423xx */ 356 /** 357 * @} 358 */ 359 360 /** @defgroup FLASHEx_Sectors FLASH Sectors 361 * @{ 362 */ 363 /*-------------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx ------------------------------------*/ 364 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 365 defined(STM32F469xx) || defined(STM32F479xx) 366 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 367 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 368 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 369 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 370 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 371 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */ 372 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */ 373 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */ 374 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */ 375 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */ 376 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */ 377 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */ 378 #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */ 379 #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */ 380 #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */ 381 #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */ 382 #define FLASH_SECTOR_16 16U /*!< Sector Number 16 */ 383 #define FLASH_SECTOR_17 17U /*!< Sector Number 17 */ 384 #define FLASH_SECTOR_18 18U /*!< Sector Number 18 */ 385 #define FLASH_SECTOR_19 19U /*!< Sector Number 19 */ 386 #define FLASH_SECTOR_20 20U /*!< Sector Number 20 */ 387 #define FLASH_SECTOR_21 21U /*!< Sector Number 21 */ 388 #define FLASH_SECTOR_22 22U /*!< Sector Number 22 */ 389 #define FLASH_SECTOR_23 23U /*!< Sector Number 23 */ 390 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 391 /*-----------------------------------------------------------------------------------------------------*/ 392 393 /*-------------------------------------- STM32F413xx/STM32F423xx --------------------------------------*/ 394 #if defined(STM32F413xx) || defined(STM32F423xx) 395 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 396 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 397 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 398 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 399 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 400 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */ 401 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */ 402 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */ 403 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */ 404 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */ 405 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */ 406 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */ 407 #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */ 408 #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */ 409 #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */ 410 #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */ 411 #endif /* STM32F413xx || STM32F423xx */ 412 /*-----------------------------------------------------------------------------------------------------*/ 413 414 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/ 415 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\ 416 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 417 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 418 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 419 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 420 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 421 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 422 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */ 423 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */ 424 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */ 425 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */ 426 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */ 427 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */ 428 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */ 429 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 430 /*-----------------------------------------------------------------------------------------------------*/ 431 432 /*--------------------------------------------- STM32F401xC -------------------------------------------*/ 433 #if defined(STM32F401xC) 434 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 435 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 436 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 437 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 438 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 439 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */ 440 #endif /* STM32F401xC */ 441 /*-----------------------------------------------------------------------------------------------------*/ 442 443 /*--------------------------------------------- STM32F410xx -------------------------------------------*/ 444 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 445 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 446 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 447 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 448 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 449 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 450 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 451 /*-----------------------------------------------------------------------------------------------------*/ 452 453 /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/ 454 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) 455 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */ 456 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */ 457 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */ 458 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */ 459 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */ 460 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */ 461 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */ 462 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */ 463 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */ 464 /*-----------------------------------------------------------------------------------------------------*/ 465 466 /** 467 * @} 468 */ 469 470 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection 471 * @{ 472 */ 473 /*--------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx -------------------------*/ 474 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 475 defined(STM32F469xx) || defined(STM32F479xx) 476 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 477 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 478 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 479 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 480 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 481 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */ 482 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */ 483 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */ 484 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */ 485 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */ 486 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */ 487 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */ 488 #define OB_WRP_SECTOR_12 0x00000001U << 12U /*!< Write protection of Sector12 */ 489 #define OB_WRP_SECTOR_13 0x00000002U << 12U /*!< Write protection of Sector13 */ 490 #define OB_WRP_SECTOR_14 0x00000004U << 12U /*!< Write protection of Sector14 */ 491 #define OB_WRP_SECTOR_15 0x00000008U << 12U /*!< Write protection of Sector15 */ 492 #define OB_WRP_SECTOR_16 0x00000010U << 12U /*!< Write protection of Sector16 */ 493 #define OB_WRP_SECTOR_17 0x00000020U << 12U /*!< Write protection of Sector17 */ 494 #define OB_WRP_SECTOR_18 0x00000040U << 12U /*!< Write protection of Sector18 */ 495 #define OB_WRP_SECTOR_19 0x00000080U << 12U /*!< Write protection of Sector19 */ 496 #define OB_WRP_SECTOR_20 0x00000100U << 12U /*!< Write protection of Sector20 */ 497 #define OB_WRP_SECTOR_21 0x00000200U << 12U /*!< Write protection of Sector21 */ 498 #define OB_WRP_SECTOR_22 0x00000400U << 12U /*!< Write protection of Sector22 */ 499 #define OB_WRP_SECTOR_23 0x00000800U << 12U /*!< Write protection of Sector23 */ 500 #define OB_WRP_SECTOR_All 0x00000FFFU << 12U /*!< Write protection of all Sectors */ 501 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 502 /*-----------------------------------------------------------------------------------------------------*/ 503 504 /*--------------------------------------- STM32F413xx/STM32F423xx -------------------------------------*/ 505 #if defined(STM32F413xx) || defined(STM32F423xx) 506 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 507 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 508 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 509 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 510 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 511 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */ 512 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */ 513 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */ 514 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */ 515 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */ 516 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */ 517 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */ 518 #define OB_WRP_SECTOR_12 0x00001000U /*!< Write protection of Sector12 */ 519 #define OB_WRP_SECTOR_13 0x00002000U /*!< Write protection of Sector13 */ 520 #define OB_WRP_SECTOR_14 0x00004000U /*!< Write protection of Sector14 */ 521 #define OB_WRP_SECTOR_15 0x00004000U /*!< Write protection of Sector15 */ 522 #define OB_WRP_SECTOR_All 0x00007FFFU /*!< Write protection of all Sectors */ 523 #endif /* STM32F413xx || STM32F423xx */ 524 /*-----------------------------------------------------------------------------------------------------*/ 525 526 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/ 527 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\ 528 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 529 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 530 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 531 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 532 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 533 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 534 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */ 535 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */ 536 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */ 537 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */ 538 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */ 539 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */ 540 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */ 541 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */ 542 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 543 /*-----------------------------------------------------------------------------------------------------*/ 544 545 /*--------------------------------------------- STM32F401xC -------------------------------------------*/ 546 #if defined(STM32F401xC) 547 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 548 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 549 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 550 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 551 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 552 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */ 553 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */ 554 #endif /* STM32F401xC */ 555 /*-----------------------------------------------------------------------------------------------------*/ 556 557 /*--------------------------------------------- STM32F410xx -------------------------------------------*/ 558 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 559 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 560 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 561 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 562 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 563 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 564 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */ 565 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 566 /*-----------------------------------------------------------------------------------------------------*/ 567 568 /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/ 569 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) 570 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */ 571 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */ 572 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */ 573 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */ 574 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */ 575 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */ 576 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */ 577 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */ 578 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */ 579 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */ 580 /*-----------------------------------------------------------------------------------------------------*/ 581 /** 582 * @} 583 */ 584 585 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC ReadWrite Protection 586 * @{ 587 */ 588 /*-------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx ---------------------------*/ 589 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 590 defined(STM32F469xx) || defined(STM32F479xx) 591 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */ 592 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */ 593 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */ 594 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */ 595 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */ 596 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */ 597 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */ 598 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */ 599 #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */ 600 #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */ 601 #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */ 602 #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */ 603 #define OB_PCROP_SECTOR_12 0x00000001U /*!< PC Read/Write protection of Sector12 */ 604 #define OB_PCROP_SECTOR_13 0x00000002U /*!< PC Read/Write protection of Sector13 */ 605 #define OB_PCROP_SECTOR_14 0x00000004U /*!< PC Read/Write protection of Sector14 */ 606 #define OB_PCROP_SECTOR_15 0x00000008U /*!< PC Read/Write protection of Sector15 */ 607 #define OB_PCROP_SECTOR_16 0x00000010U /*!< PC Read/Write protection of Sector16 */ 608 #define OB_PCROP_SECTOR_17 0x00000020U /*!< PC Read/Write protection of Sector17 */ 609 #define OB_PCROP_SECTOR_18 0x00000040U /*!< PC Read/Write protection of Sector18 */ 610 #define OB_PCROP_SECTOR_19 0x00000080U /*!< PC Read/Write protection of Sector19 */ 611 #define OB_PCROP_SECTOR_20 0x00000100U /*!< PC Read/Write protection of Sector20 */ 612 #define OB_PCROP_SECTOR_21 0x00000200U /*!< PC Read/Write protection of Sector21 */ 613 #define OB_PCROP_SECTOR_22 0x00000400U /*!< PC Read/Write protection of Sector22 */ 614 #define OB_PCROP_SECTOR_23 0x00000800U /*!< PC Read/Write protection of Sector23 */ 615 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */ 616 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 617 /*-----------------------------------------------------------------------------------------------------*/ 618 619 /*------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/ 620 #if defined(STM32F413xx) || defined(STM32F423xx) 621 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */ 622 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */ 623 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */ 624 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */ 625 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */ 626 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */ 627 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */ 628 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */ 629 #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */ 630 #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */ 631 #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */ 632 #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */ 633 #define OB_PCROP_SECTOR_12 0x00001000U /*!< PC Read/Write protection of Sector12 */ 634 #define OB_PCROP_SECTOR_13 0x00002000U /*!< PC Read/Write protection of Sector13 */ 635 #define OB_PCROP_SECTOR_14 0x00004000U /*!< PC Read/Write protection of Sector14 */ 636 #define OB_PCROP_SECTOR_15 0x00004000U /*!< PC Read/Write protection of Sector15 */ 637 #define OB_PCROP_SECTOR_All 0x00007FFFU /*!< PC Read/Write protection of all Sectors */ 638 #endif /* STM32F413xx || STM32F423xx */ 639 /*-----------------------------------------------------------------------------------------------------*/ 640 641 /*--------------------------------------------- STM32F401xC -------------------------------------------*/ 642 #if defined(STM32F401xC) 643 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */ 644 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */ 645 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */ 646 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */ 647 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */ 648 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */ 649 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */ 650 #endif /* STM32F401xC */ 651 /*-----------------------------------------------------------------------------------------------------*/ 652 653 /*--------------------------------------------- STM32F410xx -------------------------------------------*/ 654 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 655 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */ 656 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */ 657 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */ 658 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */ 659 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */ 660 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */ 661 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 662 /*-----------------------------------------------------------------------------------------------------*/ 663 664 /*-------------- STM32F401xE/STM32F411xE/STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F446xx --*/ 665 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 666 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 667 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */ 668 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */ 669 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */ 670 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */ 671 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */ 672 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */ 673 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */ 674 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */ 675 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */ 676 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 677 /*-----------------------------------------------------------------------------------------------------*/ 678 679 /** 680 * @} 681 */ 682 683 /** @defgroup FLASHEx_Dual_Boot FLASH Dual Boot 684 * @{ 685 */ 686 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 687 defined(STM32F469xx) || defined(STM32F479xx) 688 #define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10) /*!< Dual Bank Boot Enable */ 689 #define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00) /*!< Dual Bank Boot Disable, always boot on User Flash */ 690 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 691 /** 692 * @} 693 */ 694 695 /** @defgroup FLASHEx_Selection_Protection_Mode FLASH Selection Protection Mode 696 * @{ 697 */ 698 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 699 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 700 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 701 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 702 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 703 #define OB_PCROP_DESELECTED ((uint8_t)0x00) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */ 704 #define OB_PCROP_SELECTED ((uint8_t)0x80) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */ 705 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\ 706 STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ 707 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 708 /** 709 * @} 710 */ 711 712 /** 713 * @} 714 */ 715 716 /* Exported macro ------------------------------------------------------------*/ 717 718 /* Exported functions --------------------------------------------------------*/ 719 /** @addtogroup FLASHEx_Exported_Functions 720 * @{ 721 */ 722 723 /** @addtogroup FLASHEx_Exported_Functions_Group1 724 * @{ 725 */ 726 /* Extension Program operation functions *************************************/ 727 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError); 728 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 729 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 730 void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 731 732 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 733 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 734 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 735 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 736 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 737 HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); 738 void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); 739 HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void); 740 HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void); 741 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\ 742 STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ 743 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 744 745 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 746 defined(STM32F469xx) || defined(STM32F479xx) 747 uint16_t HAL_FLASHEx_OB_GetBank2WRP(void); 748 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 749 /** 750 * @} 751 */ 752 753 /** 754 * @} 755 */ 756 /* Private types -------------------------------------------------------------*/ 757 /* Private variables ---------------------------------------------------------*/ 758 /* Private constants ---------------------------------------------------------*/ 759 /** @defgroup FLASHEx_Private_Constants FLASH Private Constants 760 * @{ 761 */ 762 /*--------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx---------------------*/ 763 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 764 #define FLASH_SECTOR_TOTAL 24U 765 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 766 767 /*-------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/ 768 #if defined(STM32F413xx) || defined(STM32F423xx) 769 #define FLASH_SECTOR_TOTAL 16U 770 #endif /* STM32F413xx || STM32F423xx */ 771 772 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/ 773 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\ 774 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 775 #define FLASH_SECTOR_TOTAL 12U 776 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 777 778 /*--------------------------------------------- STM32F401xC -------------------------------------------*/ 779 #if defined(STM32F401xC) 780 #define FLASH_SECTOR_TOTAL 6U 781 #endif /* STM32F401xC */ 782 783 /*--------------------------------------------- STM32F410xx -------------------------------------------*/ 784 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 785 #define FLASH_SECTOR_TOTAL 5U 786 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 787 788 /*--------------------------------- STM32F401xE/STM32F411xE/STM32F412xG/STM32F446xx -------------------*/ 789 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) 790 #define FLASH_SECTOR_TOTAL 8U 791 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */ 792 793 /** 794 * @brief OPTCR1 register byte 2 (Bits[23:16]) base address 795 */ 796 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 797 #define OPTCR1_BYTE2_ADDRESS 0x40023C1AU 798 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 799 800 /** 801 * @} 802 */ 803 804 /* Private macros ------------------------------------------------------------*/ 805 /** @defgroup FLASHEx_Private_Macros FLASH Private Macros 806 * @{ 807 */ 808 809 /** @defgroup FLASHEx_IS_FLASH_Definitions FLASH Private macros to check input parameters 810 * @{ 811 */ 812 813 #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \ 814 ((VALUE) == FLASH_TYPEERASE_MASSERASE)) 815 816 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \ 817 ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \ 818 ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \ 819 ((RANGE) == FLASH_VOLTAGE_RANGE_4)) 820 821 #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \ 822 ((VALUE) == OB_WRPSTATE_ENABLE)) 823 824 #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR))) 825 826 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\ 827 ((LEVEL) == OB_RDP_LEVEL_1) ||\ 828 ((LEVEL) == OB_RDP_LEVEL_2)) 829 830 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW)) 831 832 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST)) 833 834 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST)) 835 836 #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\ 837 ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF)) 838 839 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 840 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 841 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 842 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 843 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 844 #define IS_PCROPSTATE(VALUE)(((VALUE) == OB_PCROP_STATE_DISABLE) || \ 845 ((VALUE) == OB_PCROP_STATE_ENABLE)) 846 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\ 847 STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ 848 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 849 850 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 851 defined(STM32F469xx) || defined(STM32F479xx) 852 #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP) || \ 853 ((VALUE) == OPTIONBYTE_BOOTCONFIG)) 854 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 855 856 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 857 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 858 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\ 859 defined(STM32F423xx) 860 #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP)) 861 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx ||\ 862 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 863 864 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\ 865 defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx) 866 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \ 867 ((LATENCY) == FLASH_LATENCY_1) || \ 868 ((LATENCY) == FLASH_LATENCY_2) || \ 869 ((LATENCY) == FLASH_LATENCY_3) || \ 870 ((LATENCY) == FLASH_LATENCY_4) || \ 871 ((LATENCY) == FLASH_LATENCY_5) || \ 872 ((LATENCY) == FLASH_LATENCY_6) || \ 873 ((LATENCY) == FLASH_LATENCY_7) || \ 874 ((LATENCY) == FLASH_LATENCY_8) || \ 875 ((LATENCY) == FLASH_LATENCY_9) || \ 876 ((LATENCY) == FLASH_LATENCY_10) || \ 877 ((LATENCY) == FLASH_LATENCY_11) || \ 878 ((LATENCY) == FLASH_LATENCY_12) || \ 879 ((LATENCY) == FLASH_LATENCY_13) || \ 880 ((LATENCY) == FLASH_LATENCY_14) || \ 881 ((LATENCY) == FLASH_LATENCY_15)) 882 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */ 883 884 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ 885 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 886 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\ 887 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 888 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \ 889 ((LATENCY) == FLASH_LATENCY_1) || \ 890 ((LATENCY) == FLASH_LATENCY_2) || \ 891 ((LATENCY) == FLASH_LATENCY_3) || \ 892 ((LATENCY) == FLASH_LATENCY_4) || \ 893 ((LATENCY) == FLASH_LATENCY_5) || \ 894 ((LATENCY) == FLASH_LATENCY_6) || \ 895 ((LATENCY) == FLASH_LATENCY_7)) 896 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx ||\ 897 STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 898 899 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 900 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \ 901 ((BANK) == FLASH_BANK_2) || \ 902 ((BANK) == FLASH_BANK_BOTH)) 903 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */ 904 905 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\ 906 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 907 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\ 908 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\ 909 defined(STM32F423xx) 910 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1)) 911 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx ||\ 912 STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 913 914 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 915 #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 916 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 917 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ 918 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\ 919 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\ 920 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\ 921 ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\ 922 ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\ 923 ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\ 924 ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\ 925 ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\ 926 ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23)) 927 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 928 929 #if defined(STM32F413xx) || defined(STM32F423xx) 930 #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 931 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 932 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ 933 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\ 934 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\ 935 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\ 936 ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\ 937 ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15)) 938 #endif /* STM32F413xx || STM32F423xx */ 939 940 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\ 941 defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) 942 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 943 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 944 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ 945 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\ 946 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\ 947 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11)) 948 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 949 950 #if defined(STM32F401xC) 951 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 952 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 953 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5)) 954 #endif /* STM32F401xC */ 955 956 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 957 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 958 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 959 ((SECTOR) == FLASH_SECTOR_4)) 960 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 961 962 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) 963 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\ 964 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\ 965 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\ 966 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7)) 967 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */ 968 969 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END)) || \ 970 (((ADDRESS) >= FLASH_OTP_BASE) && ((ADDRESS) <= FLASH_OTP_END))) 971 972 #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL)) 973 974 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 975 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFF000000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 976 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 977 978 #if defined(STM32F413xx) || defined(STM32F423xx) 979 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 980 #endif /* STM32F413xx || STM32F423xx */ 981 982 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) 983 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 984 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */ 985 986 #if defined(STM32F401xC) 987 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 988 #endif /* STM32F401xC */ 989 990 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 991 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 992 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 993 994 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\ 995 defined(STM32F412Rx) || defined(STM32F412Cx) 996 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 997 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 998 999 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx) 1000 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 1001 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 1002 1003 #if defined(STM32F413xx) || defined(STM32F423xx) 1004 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 1005 #endif /* STM32F413xx || STM32F423xx */ 1006 1007 #if defined(STM32F401xC) 1008 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 1009 #endif /* STM32F401xC */ 1010 1011 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) 1012 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 1013 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */ 1014 1015 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\ 1016 defined(STM32F412Rx) || defined(STM32F412Cx) 1017 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U)) 1018 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */ 1019 1020 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 1021 defined(STM32F469xx) || defined(STM32F479xx) 1022 #define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE)) 1023 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */ 1024 1025 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\ 1026 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\ 1027 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\ 1028 defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\ 1029 defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx) 1030 #define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED)) 1031 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\ 1032 STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\ 1033 STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */ 1034 /** 1035 * @} 1036 */ 1037 1038 /** 1039 * @} 1040 */ 1041 1042 /* Private functions ---------------------------------------------------------*/ 1043 /** @defgroup FLASHEx_Private_Functions FLASH Private Functions 1044 * @{ 1045 */ 1046 void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange); 1047 void FLASH_FlushCaches(void); 1048 /** 1049 * @} 1050 */ 1051 1052 /** 1053 * @} 1054 */ 1055 1056 /** 1057 * @} 1058 */ 1059 1060 #ifdef __cplusplus 1061 } 1062 #endif 1063 1064 #endif /* __STM32F4xx_HAL_FLASH_EX_H */ 1065 1066 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 1067