2 ******************************************************************************
\r
3 * @file stm32f7xx_hal_flash_ex.h
\r
4 * @author MCD Application Team
\r
5 * @brief Header file of FLASH HAL Extension module.
\r
6 ******************************************************************************
\r
9 * <h2><center>© Copyright (c) 2017 STMicroelectronics.
\r
10 * All rights reserved.</center></h2>
\r
12 * This software component is licensed by ST under BSD 3-Clause license,
\r
13 * the "License"; You may not use this file except in compliance with the
\r
14 * License. You may obtain a copy of the License at:
\r
15 * opensource.org/licenses/BSD-3-Clause
\r
17 ******************************************************************************
\r
20 /* Define to prevent recursive inclusion -------------------------------------*/
\r
21 #ifndef __STM32F7xx_HAL_FLASH_EX_H
\r
22 #define __STM32F7xx_HAL_FLASH_EX_H
\r
28 /* Includes ------------------------------------------------------------------*/
\r
29 #include "stm32f7xx_hal_def.h"
\r
31 /** @addtogroup STM32F7xx_HAL_Driver
\r
35 /** @addtogroup FLASHEx
\r
39 /* Exported types ------------------------------------------------------------*/
\r
40 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types
\r
45 * @brief FLASH Erase structure definition
\r
49 uint32_t TypeErase; /*!< Mass erase or sector Erase.
\r
50 This parameter can be a value of @ref FLASHEx_Type_Erase */
\r
52 #if defined (FLASH_OPTCR_nDBANK)
\r
53 uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled.
\r
54 This parameter must be a value of @ref FLASHEx_Banks */
\r
55 #endif /* FLASH_OPTCR_nDBANK */
\r
57 uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled
\r
58 This parameter must be a value of @ref FLASHEx_Sectors */
\r
60 uint32_t NbSectors; /*!< Number of sectors to be erased.
\r
61 This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
\r
63 uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism
\r
64 This parameter must be a value of @ref FLASHEx_Voltage_Range */
\r
66 } FLASH_EraseInitTypeDef;
\r
69 * @brief FLASH Option Bytes Program structure definition
\r
73 uint32_t OptionType; /*!< Option byte to be configured.
\r
74 This parameter can be a value of @ref FLASHEx_Option_Type */
\r
76 uint32_t WRPState; /*!< Write protection activation or deactivation.
\r
77 This parameter can be a value of @ref FLASHEx_WRP_State */
\r
79 uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected.
\r
80 The value of this parameter depend on device used within the same series */
\r
82 uint32_t RDPLevel; /*!< Set the read protection level.
\r
83 This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
\r
85 uint32_t BORLevel; /*!< Set the BOR Level.
\r
86 This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */
\r
88 uint32_t USERConfig; /*!< Program the FLASH User Option Byte: WWDG_SW / IWDG_SW / RST_STOP / RST_STDBY /
\r
89 IWDG_FREEZE_STOP / IWDG_FREEZE_SANDBY / nDBANK / nDBOOT.
\r
90 nDBANK / nDBOOT are only available for STM32F76xxx/STM32F77xxx devices */
\r
92 uint32_t BootAddr0; /*!< Boot base address when Boot pin = 0.
\r
93 This parameter can be a value of @ref FLASHEx_Boot_Address */
\r
95 uint32_t BootAddr1; /*!< Boot base address when Boot pin = 1.
\r
96 This parameter can be a value of @ref FLASHEx_Boot_Address */
\r
98 #if defined (FLASH_OPTCR2_PCROP)
\r
99 uint32_t PCROPSector; /*!< Set the PCROP sector.
\r
100 This parameter can be a value of @ref FLASHEx_Option_Bytes_PCROP_Sectors */
\r
102 uint32_t PCROPRdp; /*!< Set the PCROP_RDP option.
\r
103 This parameter can be a value of @ref FLASHEx_Option_Bytes_PCROP_RDP */
\r
104 #endif /* FLASH_OPTCR2_PCROP */
\r
106 } FLASH_OBProgramInitTypeDef;
\r
111 /* Exported constants --------------------------------------------------------*/
\r
113 /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
\r
117 /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
\r
120 #define FLASH_TYPEERASE_SECTORS ((uint32_t)0x00U) /*!< Sectors erase only */
\r
121 #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01U) /*!< Flash Mass erase activation */
\r
126 /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
\r
129 #define FLASH_VOLTAGE_RANGE_1 ((uint32_t)0x00U) /*!< Device operating range: 1.8V to 2.1V */
\r
130 #define FLASH_VOLTAGE_RANGE_2 ((uint32_t)0x01U) /*!< Device operating range: 2.1V to 2.7V */
\r
131 #define FLASH_VOLTAGE_RANGE_3 ((uint32_t)0x02U) /*!< Device operating range: 2.7V to 3.6V */
\r
132 #define FLASH_VOLTAGE_RANGE_4 ((uint32_t)0x03U) /*!< Device operating range: 2.7V to 3.6V + External Vpp */
\r
137 /** @defgroup FLASHEx_WRP_State FLASH WRP State
\r
140 #define OB_WRPSTATE_DISABLE ((uint32_t)0x00U) /*!< Disable the write protection of the desired bank 1 sectors */
\r
141 #define OB_WRPSTATE_ENABLE ((uint32_t)0x01U) /*!< Enable the write protection of the desired bank 1 sectors */
\r
146 /** @defgroup FLASHEx_Option_Type FLASH Option Type
\r
149 #define OPTIONBYTE_WRP ((uint32_t)0x01U) /*!< WRP option byte configuration */
\r
150 #define OPTIONBYTE_RDP ((uint32_t)0x02U) /*!< RDP option byte configuration */
\r
151 #define OPTIONBYTE_USER ((uint32_t)0x04U) /*!< USER option byte configuration */
\r
152 #define OPTIONBYTE_BOR ((uint32_t)0x08U) /*!< BOR option byte configuration */
\r
153 #define OPTIONBYTE_BOOTADDR_0 ((uint32_t)0x10U) /*!< Boot 0 Address configuration */
\r
154 #define OPTIONBYTE_BOOTADDR_1 ((uint32_t)0x20U) /*!< Boot 1 Address configuration */
\r
155 #if defined (FLASH_OPTCR2_PCROP)
\r
156 #define OPTIONBYTE_PCROP ((uint32_t)0x40U) /*!< PCROP configuration */
\r
157 #define OPTIONBYTE_PCROP_RDP ((uint32_t)0x80U) /*!< PCROP_RDP configuration */
\r
158 #endif /* FLASH_OPTCR2_PCROP */
\r
163 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
\r
166 #define OB_RDP_LEVEL_0 ((uint8_t)0xAAU)
\r
167 #define OB_RDP_LEVEL_1 ((uint8_t)0x55U)
\r
168 #define OB_RDP_LEVEL_2 ((uint8_t)0xCCU) /*!< Warning: When enabling read protection level 2
\r
169 it s no more possible to go back to level 1 or 0 */
\r
174 /** @defgroup FLASHEx_Option_Bytes_WWatchdog FLASH Option Bytes WWatchdog
\r
177 #define OB_WWDG_SW ((uint32_t)0x10U) /*!< Software WWDG selected */
\r
178 #define OB_WWDG_HW ((uint32_t)0x00U) /*!< Hardware WWDG selected */
\r
184 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
\r
187 #define OB_IWDG_SW ((uint32_t)0x20U) /*!< Software IWDG selected */
\r
188 #define OB_IWDG_HW ((uint32_t)0x00U) /*!< Hardware IWDG selected */
\r
193 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
\r
196 #define OB_STOP_NO_RST ((uint32_t)0x40U) /*!< No reset generated when entering in STOP */
\r
197 #define OB_STOP_RST ((uint32_t)0x00U) /*!< Reset generated when entering in STOP */
\r
202 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
\r
205 #define OB_STDBY_NO_RST ((uint32_t)0x80U) /*!< No reset generated when entering in STANDBY */
\r
206 #define OB_STDBY_RST ((uint32_t)0x00U) /*!< Reset generated when entering in STANDBY */
\r
211 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_STOP FLASH IWDG Counter Freeze in STOP
\r
214 #define OB_IWDG_STOP_FREEZE ((uint32_t)0x00000000U) /*!< Freeze IWDG counter in STOP mode */
\r
215 #define OB_IWDG_STOP_ACTIVE ((uint32_t)0x80000000U) /*!< IWDG counter active in STOP mode */
\r
220 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_SANDBY FLASH IWDG Counter Freeze in STANDBY
\r
223 #define OB_IWDG_STDBY_FREEZE ((uint32_t)0x00000000U) /*!< Freeze IWDG counter in STANDBY mode */
\r
224 #define OB_IWDG_STDBY_ACTIVE ((uint32_t)0x40000000U) /*!< IWDG counter active in STANDBY mode */
\r
229 /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
\r
232 #define OB_BOR_LEVEL3 ((uint32_t)0x00U) /*!< Supply voltage ranges from 2.70 to 3.60 V */
\r
233 #define OB_BOR_LEVEL2 ((uint32_t)0x04U) /*!< Supply voltage ranges from 2.40 to 2.70 V */
\r
234 #define OB_BOR_LEVEL1 ((uint32_t)0x08U) /*!< Supply voltage ranges from 2.10 to 2.40 V */
\r
235 #define OB_BOR_OFF ((uint32_t)0x0CU) /*!< Supply voltage ranges from 1.62 to 2.10 V */
\r
240 #if defined (FLASH_OPTCR_nDBOOT)
\r
241 /** @defgroup FLASHEx_Option_Bytes_nDBOOT FLASH Option Bytes nDBOOT
\r
244 #define OB_DUAL_BOOT_DISABLE ((uint32_t)0x10000000U) /* !< Dual Boot disable. Boot according to boot address option */
\r
245 #define OB_DUAL_BOOT_ENABLE ((uint32_t)0x00000000U) /* !< Dual Boot enable. Boot always from system memory if boot address in flash
\r
246 (Dual bank Boot mode), or RAM if Boot address option in RAM */
\r
250 #endif /* FLASH_OPTCR_nDBOOT */
\r
252 #if defined (FLASH_OPTCR_nDBANK)
\r
253 /** @defgroup FLASHEx_Option_Bytes_nDBank FLASH Single Bank or Dual Bank
\r
256 #define OB_NDBANK_SINGLE_BANK ((uint32_t)0x20000000U) /*!< NDBANK bit is set : Single Bank mode */
\r
257 #define OB_NDBANK_DUAL_BANK ((uint32_t)0x00000000U) /*!< NDBANK bit is reset : Dual Bank mode */
\r
261 #endif /* FLASH_OPTCR_nDBANK */
\r
263 /** @defgroup FLASHEx_Boot_Address FLASH Boot Address
\r
266 #define OB_BOOTADDR_ITCM_RAM ((uint32_t)0x0000U) /*!< Boot from ITCM RAM (0x00000000) */
\r
267 #define OB_BOOTADDR_SYSTEM ((uint32_t)0x0040U) /*!< Boot from System memory bootloader (0x00100000) */
\r
268 #define OB_BOOTADDR_ITCM_FLASH ((uint32_t)0x0080U) /*!< Boot from Flash on ITCM interface (0x00200000) */
\r
269 #define OB_BOOTADDR_AXIM_FLASH ((uint32_t)0x2000U) /*!< Boot from Flash on AXIM interface (0x08000000) */
\r
270 #define OB_BOOTADDR_DTCM_RAM ((uint32_t)0x8000U) /*!< Boot from DTCM RAM (0x20000000) */
\r
271 #define OB_BOOTADDR_SRAM1 ((uint32_t)0x8004U) /*!< Boot from SRAM1 (0x20010000) */
\r
272 #if (SRAM2_BASE == 0x2003C000U)
\r
273 #define OB_BOOTADDR_SRAM2 ((uint32_t)0x800FU) /*!< Boot from SRAM2 (0x2003C000) */
\r
275 #define OB_BOOTADDR_SRAM2 ((uint32_t)0x8013U) /*!< Boot from SRAM2 (0x2004C000) */
\r
276 #endif /* SRAM2_BASE == 0x2003C000U */
\r
281 /** @defgroup FLASH_Latency FLASH Latency
\r
284 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */
\r
285 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */
\r
286 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */
\r
287 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */
\r
288 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */
\r
289 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */
\r
290 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */
\r
291 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */
\r
292 #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight Latency cycles */
\r
293 #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine Latency cycles */
\r
294 #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten Latency cycles */
\r
295 #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven Latency cycles */
\r
296 #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve Latency cycles */
\r
297 #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen Latency cycles */
\r
298 #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen Latency cycles */
\r
299 #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen Latency cycles */
\r
304 #if defined (FLASH_OPTCR_nDBANK)
\r
305 /** @defgroup FLASHEx_Banks FLASH Banks
\r
308 #define FLASH_BANK_1 ((uint32_t)0x01U) /*!< Bank 1 */
\r
309 #define FLASH_BANK_2 ((uint32_t)0x02U) /*!< Bank 2 */
\r
310 #define FLASH_BANK_BOTH ((uint32_t)(FLASH_BANK_1 | FLASH_BANK_2)) /*!< Bank1 and Bank2 */
\r
314 #endif /* FLASH_OPTCR_nDBANK */
\r
316 /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit
\r
319 #if defined (FLASH_OPTCR_nDBANK)
\r
320 #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits */
\r
322 #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER bit */
\r
323 #endif /* FLASH_OPTCR_nDBANK */
\r
328 /** @defgroup FLASHEx_Sectors FLASH Sectors
\r
331 #if (FLASH_SECTOR_TOTAL == 24)
\r
332 #define FLASH_SECTOR_8 ((uint32_t)8U) /*!< Sector Number 8 */
\r
333 #define FLASH_SECTOR_9 ((uint32_t)9U) /*!< Sector Number 9 */
\r
334 #define FLASH_SECTOR_10 ((uint32_t)10U) /*!< Sector Number 10 */
\r
335 #define FLASH_SECTOR_11 ((uint32_t)11U) /*!< Sector Number 11 */
\r
336 #define FLASH_SECTOR_12 ((uint32_t)12U) /*!< Sector Number 12 */
\r
337 #define FLASH_SECTOR_13 ((uint32_t)13U) /*!< Sector Number 13 */
\r
338 #define FLASH_SECTOR_14 ((uint32_t)14U) /*!< Sector Number 14 */
\r
339 #define FLASH_SECTOR_15 ((uint32_t)15U) /*!< Sector Number 15 */
\r
340 #define FLASH_SECTOR_16 ((uint32_t)16U) /*!< Sector Number 16 */
\r
341 #define FLASH_SECTOR_17 ((uint32_t)17U) /*!< Sector Number 17 */
\r
342 #define FLASH_SECTOR_18 ((uint32_t)18U) /*!< Sector Number 18 */
\r
343 #define FLASH_SECTOR_19 ((uint32_t)19U) /*!< Sector Number 19 */
\r
344 #define FLASH_SECTOR_20 ((uint32_t)20U) /*!< Sector Number 20 */
\r
345 #define FLASH_SECTOR_21 ((uint32_t)21U) /*!< Sector Number 21 */
\r
346 #define FLASH_SECTOR_22 ((uint32_t)22U) /*!< Sector Number 22 */
\r
347 #define FLASH_SECTOR_23 ((uint32_t)23U) /*!< Sector Number 23 */
\r
348 #endif /* FLASH_SECTOR_TOTAL == 24 */
\r
353 #if (FLASH_SECTOR_TOTAL == 24)
\r
354 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
\r
355 * @note For Single Bank mode, use OB_WRP_SECTOR_x defines: In fact, in FLASH_OPTCR register,
\r
356 * nWRP[11:0] bits contain the value of the write-protection option bytes for sectors 0 to 11.
\r
357 * For Dual Bank mode, use OB_WRP_DB_SECTOR_x defines: In fact, in FLASH_OPTCR register,
\r
358 * nWRP[11:0] bits are divided on two groups, one group dedicated for bank 1 and
\r
359 * a second one dedicated for bank 2 (nWRP[i] activates Write protection on sector 2*i and 2*i+1).
\r
360 * This behavior is applicable only for STM32F76xxx / STM32F77xxx devices.
\r
363 /* Single Bank Sectors */
\r
364 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U) /*!< Write protection of Single Bank Sector0 */
\r
365 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U) /*!< Write protection of Single Bank Sector1 */
\r
366 #define OB_WRP_SECTOR_2 ((uint32_t)0x00040000U) /*!< Write protection of Single Bank Sector2 */
\r
367 #define OB_WRP_SECTOR_3 ((uint32_t)0x00080000U) /*!< Write protection of Single Bank Sector3 */
\r
368 #define OB_WRP_SECTOR_4 ((uint32_t)0x00100000U) /*!< Write protection of Single Bank Sector4 */
\r
369 #define OB_WRP_SECTOR_5 ((uint32_t)0x00200000U) /*!< Write protection of Single Bank Sector5 */
\r
370 #define OB_WRP_SECTOR_6 ((uint32_t)0x00400000U) /*!< Write protection of Single Bank Sector6 */
\r
371 #define OB_WRP_SECTOR_7 ((uint32_t)0x00800000U) /*!< Write protection of Single Bank Sector7 */
\r
372 #define OB_WRP_SECTOR_8 ((uint32_t)0x01000000U) /*!< Write protection of Single Bank Sector8 */
\r
373 #define OB_WRP_SECTOR_9 ((uint32_t)0x02000000U) /*!< Write protection of Single Bank Sector9 */
\r
374 #define OB_WRP_SECTOR_10 ((uint32_t)0x04000000U) /*!< Write protection of Single Bank Sector10 */
\r
375 #define OB_WRP_SECTOR_11 ((uint32_t)0x08000000U) /*!< Write protection of Single Bank Sector11 */
\r
376 #define OB_WRP_SECTOR_All ((uint32_t)0x0FFF0000U) /*!< Write protection of all Sectors for Single Bank Flash */
\r
378 /* Dual Bank Sectors */
\r
379 #define OB_WRP_DB_SECTOR_0 ((uint32_t)0x00010000U) /*!< Write protection of Dual Bank Sector0 */
\r
380 #define OB_WRP_DB_SECTOR_1 ((uint32_t)0x00010000U) /*!< Write protection of Dual Bank Sector1 */
\r
381 #define OB_WRP_DB_SECTOR_2 ((uint32_t)0x00020000U) /*!< Write protection of Dual Bank Sector2 */
\r
382 #define OB_WRP_DB_SECTOR_3 ((uint32_t)0x00020000U) /*!< Write protection of Dual Bank Sector3 */
\r
383 #define OB_WRP_DB_SECTOR_4 ((uint32_t)0x00040000U) /*!< Write protection of Dual Bank Sector4 */
\r
384 #define OB_WRP_DB_SECTOR_5 ((uint32_t)0x00040000U) /*!< Write protection of Dual Bank Sector5 */
\r
385 #define OB_WRP_DB_SECTOR_6 ((uint32_t)0x00080000U) /*!< Write protection of Dual Bank Sector6 */
\r
386 #define OB_WRP_DB_SECTOR_7 ((uint32_t)0x00080000U) /*!< Write protection of Dual Bank Sector7 */
\r
387 #define OB_WRP_DB_SECTOR_8 ((uint32_t)0x00100000U) /*!< Write protection of Dual Bank Sector8 */
\r
388 #define OB_WRP_DB_SECTOR_9 ((uint32_t)0x00100000U) /*!< Write protection of Dual Bank Sector9 */
\r
389 #define OB_WRP_DB_SECTOR_10 ((uint32_t)0x00200000U) /*!< Write protection of Dual Bank Sector10 */
\r
390 #define OB_WRP_DB_SECTOR_11 ((uint32_t)0x00200000U) /*!< Write protection of Dual Bank Sector11 */
\r
391 #define OB_WRP_DB_SECTOR_12 ((uint32_t)0x00400000U) /*!< Write protection of Dual Bank Sector12 */
\r
392 #define OB_WRP_DB_SECTOR_13 ((uint32_t)0x00400000U) /*!< Write protection of Dual Bank Sector13 */
\r
393 #define OB_WRP_DB_SECTOR_14 ((uint32_t)0x00800000U) /*!< Write protection of Dual Bank Sector14 */
\r
394 #define OB_WRP_DB_SECTOR_15 ((uint32_t)0x00800000U) /*!< Write protection of Dual Bank Sector15 */
\r
395 #define OB_WRP_DB_SECTOR_16 ((uint32_t)0x01000000U) /*!< Write protection of Dual Bank Sector16 */
\r
396 #define OB_WRP_DB_SECTOR_17 ((uint32_t)0x01000000U) /*!< Write protection of Dual Bank Sector17 */
\r
397 #define OB_WRP_DB_SECTOR_18 ((uint32_t)0x02000000U) /*!< Write protection of Dual Bank Sector18 */
\r
398 #define OB_WRP_DB_SECTOR_19 ((uint32_t)0x02000000U) /*!< Write protection of Dual Bank Sector19 */
\r
399 #define OB_WRP_DB_SECTOR_20 ((uint32_t)0x04000000U) /*!< Write protection of Dual Bank Sector20 */
\r
400 #define OB_WRP_DB_SECTOR_21 ((uint32_t)0x04000000U) /*!< Write protection of Dual Bank Sector21 */
\r
401 #define OB_WRP_DB_SECTOR_22 ((uint32_t)0x08000000U) /*!< Write protection of Dual Bank Sector22 */
\r
402 #define OB_WRP_DB_SECTOR_23 ((uint32_t)0x08000000U) /*!< Write protection of Dual Bank Sector23 */
\r
403 #define OB_WRP_DB_SECTOR_All ((uint32_t)0x0FFF0000U) /*!< Write protection of all Sectors for Dual Bank Flash */
\r
407 #endif /* FLASH_SECTOR_TOTAL == 24 */
\r
409 #if (FLASH_SECTOR_TOTAL == 8)
\r
410 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
\r
413 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U) /*!< Write protection of Sector0 */
\r
414 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U) /*!< Write protection of Sector1 */
\r
415 #define OB_WRP_SECTOR_2 ((uint32_t)0x00040000U) /*!< Write protection of Sector2 */
\r
416 #define OB_WRP_SECTOR_3 ((uint32_t)0x00080000U) /*!< Write protection of Sector3 */
\r
417 #define OB_WRP_SECTOR_4 ((uint32_t)0x00100000U) /*!< Write protection of Sector4 */
\r
418 #define OB_WRP_SECTOR_5 ((uint32_t)0x00200000U) /*!< Write protection of Sector5 */
\r
419 #define OB_WRP_SECTOR_6 ((uint32_t)0x00400000U) /*!< Write protection of Sector6 */
\r
420 #define OB_WRP_SECTOR_7 ((uint32_t)0x00800000U) /*!< Write protection of Sector7 */
\r
421 #define OB_WRP_SECTOR_All ((uint32_t)0x00FF0000U) /*!< Write protection of all Sectors */
\r
425 #endif /* FLASH_SECTOR_TOTAL == 8 */
\r
427 #if (FLASH_SECTOR_TOTAL == 4)
\r
428 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
\r
431 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U) /*!< Write protection of Sector0 */
\r
432 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U) /*!< Write protection of Sector1 */
\r
433 #define OB_WRP_SECTOR_2 ((uint32_t)0x00040000U) /*!< Write protection of Sector2 */
\r
434 #define OB_WRP_SECTOR_3 ((uint32_t)0x00080000U) /*!< Write protection of Sector3 */
\r
435 #define OB_WRP_SECTOR_All ((uint32_t)0x000F0000U) /*!< Write protection of all Sectors */
\r
439 #endif /* FLASH_SECTOR_TOTAL == 4 */
\r
441 #if (FLASH_SECTOR_TOTAL == 2)
\r
442 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
\r
445 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U) /*!< Write protection of Sector0 */
\r
446 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U) /*!< Write protection of Sector1 */
\r
447 #define OB_WRP_SECTOR_All ((uint32_t)0x00030000U) /*!< Write protection of all Sectors */
\r
451 #endif /* FLASH_SECTOR_TOTAL == 2 */
\r
453 #if defined (FLASH_OPTCR2_PCROP)
\r
454 #if (FLASH_SECTOR_TOTAL == 8)
\r
455 /** @defgroup FLASHEx_Option_Bytes_PCROP_Sectors FLASH Option Bytes PCROP Sectors
\r
458 #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Readout protection of Sector0 */
\r
459 #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Readout protection of Sector1 */
\r
460 #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Readout protection of Sector2 */
\r
461 #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Readout protection of Sector3 */
\r
462 #define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010U) /*!< PC Readout protection of Sector4 */
\r
463 #define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020U) /*!< PC Readout protection of Sector5 */
\r
464 #define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040U) /*!< PC Readout protection of Sector6 */
\r
465 #define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080U) /*!< PC Readout protection of Sector7 */
\r
466 #define OB_PCROP_SECTOR_All ((uint32_t)0x000000FFU) /*!< PC Readout protection of all Sectors */
\r
470 #endif /* FLASH_SECTOR_TOTAL == 8 */
\r
472 #if (FLASH_SECTOR_TOTAL == 4)
\r
473 /** @defgroup FLASHEx_Option_Bytes_PCROP_Sectors FLASH Option Bytes PCROP Sectors
\r
476 #define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001U) /*!< PC Readout protection of Sector0 */
\r
477 #define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002U) /*!< PC Readout protection of Sector1 */
\r
478 #define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004U) /*!< PC Readout protection of Sector2 */
\r
479 #define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008U) /*!< PC Readout protection of Sector3 */
\r
480 #define OB_PCROP_SECTOR_All ((uint32_t)0x0000000FU) /*!< PC Readout protection of all Sectors */
\r
484 #endif /* FLASH_SECTOR_TOTAL == 4 */
\r
486 /** @defgroup FLASHEx_Option_Bytes_PCROP_RDP FLASH Option Bytes PCROP_RDP Bit
\r
489 #define OB_PCROP_RDP_ENABLE ((uint32_t)0x80000000U) /*!< PCROP_RDP Enable */
\r
490 #define OB_PCROP_RDP_DISABLE ((uint32_t)0x00000000U) /*!< PCROP_RDP Disable */
\r
494 #endif /* FLASH_OPTCR2_PCROP */
\r
500 /* Exported macro ------------------------------------------------------------*/
\r
501 /** @defgroup FLASH_Exported_Macros FLASH Exported Macros
\r
505 * @brief Calculate the FLASH Boot Base Adress (BOOT_ADD0 or BOOT_ADD1)
\r
506 * @note Returned value BOOT_ADDx[15:0] corresponds to boot address [29:14].
\r
507 * @param __ADDRESS__ FLASH Boot Address (in the range 0x0000 0000 to 0x2004 FFFF with a granularity of 16KB)
\r
508 * @retval The FLASH Boot Base Adress
\r
510 #define __HAL_FLASH_CALC_BOOT_BASE_ADR(__ADDRESS__) ((__ADDRESS__) >> 14)
\r
515 /* Exported functions --------------------------------------------------------*/
\r
516 /** @addtogroup FLASHEx_Exported_Functions
\r
520 /** @addtogroup FLASHEx_Exported_Functions_Group1
\r
523 /* Extension Program operation functions *************************************/
\r
524 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
\r
525 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
\r
526 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
\r
527 void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
\r
536 /* Private types -------------------------------------------------------------*/
\r
537 /* Private variables ---------------------------------------------------------*/
\r
538 /* Private constants ---------------------------------------------------------*/
\r
539 /* Private macros ------------------------------------------------------------*/
\r
540 /** @defgroup FLASHEx_Private_Macros FLASH Private Macros
\r
544 /** @defgroup FLASHEx_IS_FLASH_Definitions FLASH Private macros to check input parameters
\r
548 #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
\r
549 ((VALUE) == FLASH_TYPEERASE_MASSERASE))
\r
551 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
\r
552 ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
\r
553 ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
\r
554 ((RANGE) == FLASH_VOLTAGE_RANGE_4))
\r
556 #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
\r
557 ((VALUE) == OB_WRPSTATE_ENABLE))
\r
559 #if defined (FLASH_OPTCR2_PCROP)
\r
560 #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER |\
\r
561 OPTIONBYTE_BOR | OPTIONBYTE_BOOTADDR_0 | OPTIONBYTE_BOOTADDR_1 |\
\r
562 OPTIONBYTE_PCROP | OPTIONBYTE_PCROP_RDP)))
\r
564 #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER |\
\r
565 OPTIONBYTE_BOR | OPTIONBYTE_BOOTADDR_0 | OPTIONBYTE_BOOTADDR_1)))
\r
566 #endif /* FLASH_OPTCR2_PCROP */
\r
568 #define IS_OB_BOOT_ADDRESS(ADDRESS) ((ADDRESS) <= 0x8013)
\r
570 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
\r
571 ((LEVEL) == OB_RDP_LEVEL_1) ||\
\r
572 ((LEVEL) == OB_RDP_LEVEL_2))
\r
574 #define IS_OB_WWDG_SOURCE(SOURCE) (((SOURCE) == OB_WWDG_SW) || ((SOURCE) == OB_WWDG_HW))
\r
576 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
\r
578 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
\r
580 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
\r
582 #define IS_OB_IWDG_STOP_FREEZE(FREEZE) (((FREEZE) == OB_IWDG_STOP_FREEZE) || ((FREEZE) == OB_IWDG_STOP_ACTIVE))
\r
584 #define IS_OB_IWDG_STDBY_FREEZE(FREEZE) (((FREEZE) == OB_IWDG_STDBY_FREEZE) || ((FREEZE) == OB_IWDG_STDBY_ACTIVE))
\r
586 #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
\r
587 ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
\r
589 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
\r
590 ((LATENCY) == FLASH_LATENCY_1) || \
\r
591 ((LATENCY) == FLASH_LATENCY_2) || \
\r
592 ((LATENCY) == FLASH_LATENCY_3) || \
\r
593 ((LATENCY) == FLASH_LATENCY_4) || \
\r
594 ((LATENCY) == FLASH_LATENCY_5) || \
\r
595 ((LATENCY) == FLASH_LATENCY_6) || \
\r
596 ((LATENCY) == FLASH_LATENCY_7) || \
\r
597 ((LATENCY) == FLASH_LATENCY_8) || \
\r
598 ((LATENCY) == FLASH_LATENCY_9) || \
\r
599 ((LATENCY) == FLASH_LATENCY_10) || \
\r
600 ((LATENCY) == FLASH_LATENCY_11) || \
\r
601 ((LATENCY) == FLASH_LATENCY_12) || \
\r
602 ((LATENCY) == FLASH_LATENCY_13) || \
\r
603 ((LATENCY) == FLASH_LATENCY_14) || \
\r
604 ((LATENCY) == FLASH_LATENCY_15))
\r
606 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END)) || \
\r
607 (((ADDRESS) >= FLASH_OTP_BASE) && ((ADDRESS) <= FLASH_OTP_END)))
\r
608 #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0U) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
\r
610 #if (FLASH_SECTOR_TOTAL == 8)
\r
611 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
\r
612 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
\r
613 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
\r
614 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
\r
616 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & 0xFF00FFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
\r
617 #endif /* FLASH_SECTOR_TOTAL == 8 */
\r
619 #if (FLASH_SECTOR_TOTAL == 24)
\r
620 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
\r
621 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
\r
622 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
\r
623 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
\r
624 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
\r
625 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
\r
626 ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
\r
627 ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
\r
628 ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
\r
629 ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
\r
630 ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
\r
631 ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
\r
633 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & 0xF000FFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
\r
634 #endif /* FLASH_SECTOR_TOTAL == 24 */
\r
636 #if (FLASH_SECTOR_TOTAL == 4)
\r
637 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
\r
638 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3))
\r
640 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & 0xFFF0FFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
\r
641 #endif /* FLASH_SECTOR_TOTAL == 4 */
\r
643 #if (FLASH_SECTOR_TOTAL == 2)
\r
644 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1))
\r
646 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & 0xFFFCFFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
\r
647 #endif /* FLASH_SECTOR_TOTAL == 2 */
\r
649 #if defined (FLASH_OPTCR_nDBANK)
\r
650 #define IS_OB_NDBANK(VALUE) (((VALUE) == OB_NDBANK_SINGLE_BANK) || \
\r
651 ((VALUE) == OB_NDBANK_DUAL_BANK))
\r
653 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
\r
654 ((BANK) == FLASH_BANK_2) || \
\r
655 ((BANK) == FLASH_BANK_BOTH))
\r
656 #endif /* FLASH_OPTCR_nDBANK */
\r
658 #if defined (FLASH_OPTCR_nDBOOT)
\r
659 #define IS_OB_NDBOOT(VALUE) (((VALUE) == OB_DUAL_BOOT_DISABLE) || \
\r
660 ((VALUE) == OB_DUAL_BOOT_ENABLE))
\r
661 #endif /* FLASH_OPTCR_nDBOOT */
\r
663 #if defined (FLASH_OPTCR2_PCROP)
\r
664 #define IS_OB_PCROP_SECTOR(SECTOR) (((SECTOR) & (uint32_t)0xFFFFFF00U) == 0x00000000U)
\r
665 #define IS_OB_PCROP_RDP_VALUE(VALUE) (((VALUE) == OB_PCROP_RDP_DISABLE) || \
\r
666 ((VALUE) == OB_PCROP_RDP_ENABLE))
\r
667 #endif /* FLASH_OPTCR2_PCROP */
\r
677 /* Private functions ---------------------------------------------------------*/
\r
678 /** @defgroup FLASHEx_Private_Functions FLASH Private Functions
\r
681 void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange);
\r
698 #endif /* __STM32F7xx_HAL_FLASH_EX_H */
\r
700 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
\r