STM32H735xx HAL User Manual
stm32h7xx_hal_flash_ex.h
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal_flash_ex.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of FLASH HAL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2017 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file in
00013   * the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   ******************************************************************************
00016   */
00017 
00018 /* Define to prevent recursive inclusion -------------------------------------*/
00019 #ifndef STM32H7xx_HAL_FLASH_EX_H
00020 #define STM32H7xx_HAL_FLASH_EX_H
00021 
00022 #ifdef __cplusplus
00023  extern "C" {
00024 #endif
00025 
00026 /* Includes ------------------------------------------------------------------*/
00027 #include "stm32h7xx_hal_def.h"
00028 
00029 /** @addtogroup STM32H7xx_HAL_Driver
00030   * @{
00031   */
00032 
00033 /** @addtogroup FLASHEx
00034   * @{
00035   */
00036 
00037 /* Exported types ------------------------------------------------------------*/
00038 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types
00039   * @{
00040   */
00041 
00042 /**
00043   * @brief  FLASH Erase structure definition
00044   */
00045 typedef struct
00046 {
00047   uint32_t TypeErase;   /*!< Mass erase or sector Erase.
00048                              This parameter can be a value of @ref FLASHEx_Type_Erase */
00049 
00050   uint32_t Banks;       /*!< Select banks to erase when Mass erase is enabled.
00051                              This parameter must be a value of @ref FLASHEx_Banks */
00052 
00053   uint32_t Sector;      /*!< Initial FLASH sector to erase when Mass erase is disabled
00054                              This parameter must be a value of @ref FLASH_Sectors */
00055 
00056   uint32_t NbSectors;   /*!< Number of sectors to be erased.
00057                              This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
00058 
00059   uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism
00060                              This parameter must be a value of @ref FLASHEx_Voltage_Range */
00061 
00062 } FLASH_EraseInitTypeDef;
00063 
00064 
00065 /**
00066   * @brief  FLASH Option Bytes Program structure definition
00067   */
00068 typedef struct
00069 {
00070   uint32_t OptionType;     /*!< Option byte to be configured.
00071                                 This parameter can be a value of @ref FLASHEx_Option_Type */
00072 
00073   uint32_t WRPState;       /*!< Write protection activation or deactivation.
00074                                 This parameter can be a value of @ref FLASHEx_WRP_State */
00075 
00076   uint32_t WRPSector;      /*!< Specifies the sector(s) to be write protected.
00077                                 The value of this parameter depend on device used within the same series */
00078 
00079   uint32_t RDPLevel;       /*!< Set the read protection level.
00080                                 This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
00081 
00082   uint32_t BORLevel;       /*!< Set the BOR Level.
00083                                 This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */
00084 
00085   uint32_t USERType;       /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
00086                                 This parameter can be a combination of @ref FLASHEx_OB_USER_Type */
00087 
00088   uint32_t USERConfig;     /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY /
00089                                 IWDG_FREEZE_STOP / IWDG_FREEZE_SANDBY / IO_HSLV / SWAP_BANK_OPT */
00090 
00091   uint32_t Banks;          /*!< Select banks for WRP , PCROP and secure area config .
00092                                 This parameter must be a value of @ref FLASHEx_Banks */
00093 
00094   uint32_t PCROPConfig;    /*!< specifies if the PCROP area shall be erased or not
00095                                 when RDP level decreased from Level 1 to Level 0 or during a mass erase.
00096                                 This parameter must be a value of @ref FLASHEx_OB_PCROP_RDP enumeration */
00097 
00098   uint32_t PCROPStartAddr; /*!< PCROP Start address (used for OPTIONBYTE_PCROP).
00099                                 This parameter must be a value between begin and end of a bank */
00100 
00101   uint32_t PCROPEndAddr;   /*!< PCROP End address (used for OPTIONBYTE_PCROP).
00102                                 This parameter must be a value between PCROP Start address and end of a bank */
00103 
00104   uint32_t BootConfig;     /*!< Specifies if the Boot Address to be configured BOOT_ADD0, BOOT_ADD1
00105                                 or both. This parameter must be a value of @ref FLASHEx_OB_BOOT_OPTION enumeration */
00106 
00107   uint32_t BootAddr0;      /*!< Boot Address 0.
00108                                 This parameter must be a value between begin and end of a bank */
00109 
00110   uint32_t BootAddr1;      /*!< Boot Address 1.
00111                                 This parameter must be a value between begin and end of a bank */
00112 #if defined(DUAL_CORE)
00113   uint32_t CM4BootConfig;  /*!< specifies if the CM4 boot Address to be configured BOOT_ADD0, BOOT_ADD1
00114                                 or both.
00115                                 This parameter must be a value of @ref FLASHEx_OB_BOOT_OPTION enumeration */
00116 
00117   uint32_t CM4BootAddr0;   /*!< CM4 Boot Address 0.
00118                                 This parameter must be a value between begin and end of a bank */
00119 
00120   uint32_t CM4BootAddr1;   /*!< CM4 Boot Address 1.
00121                                 This parameter must be a value between begin and end of a bank */
00122 #endif /*DUAL_CORE*/
00123 
00124   uint32_t SecureAreaConfig;    /*!< specifies if the bank secured area shall be erased or not
00125                                      when RDP level decreased from Level 1 to Level 0 or during a mass erase.
00126                                      This parameter must be a value of @ref FLASHEx_OB_SECURE_RDP enumeration */
00127 
00128   uint32_t SecureAreaStartAddr; /*!< Bank Secure area Start address.
00129                                      This parameter must be a value between begin address and end address of bank1 */
00130 
00131   uint32_t SecureAreaEndAddr;   /*!< Bank Secure area End address.
00132                                      This parameter must be a value between Secure Area Start address and end address of a bank1 */
00133 
00134 #if defined (FLASH_OTPBL_LOCKBL)
00135   uint32_t OTPBlockLock;   /*!< Specifies the OTP block(s) to be locked.
00136                                 This parameter must be a value of @ref FLASHEx_OTP_Blocks */
00137 #endif /* FLASH_OTPBL_LOCKBL */
00138 
00139 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00140   uint32_t SharedRamConfig; /*!< Specifies the configuration of TCM / AXI shared RAM.
00141                                  This parameter must be a value of @ref FLASHEx_OB_TCM_AXI_SHARED */
00142 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
00143 
00144 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
00145   uint32_t FreqBoostState;  /*!< Specifies the state of CPU Frequency Boost.
00146                                  This parameter must be a value of @ref FLASHEx_OB_CPUFREQ_BOOST */
00147 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
00148 
00149 } FLASH_OBProgramInitTypeDef;
00150 
00151 /**
00152   * @brief  FLASH Erase structure definition
00153   */
00154 typedef struct
00155 {
00156   uint32_t TypeCRC;      /*!< CRC Selection Type.
00157                               This parameter can be a value of @ref FLASHEx_CRC_Selection_Type */
00158 
00159   uint32_t BurstSize;    /*!< CRC Burst Size.
00160                               This parameter can be a value of @ref FLASHEx_CRC_Burst_Size */
00161 
00162   uint32_t Bank;         /*!< Select bank where CRC computation is enabled.
00163                               This parameter must be FLASH_BANK_1 or FLASH_BANK_2 */
00164 
00165   uint32_t Sector;       /*!< Initial FLASH sector from which starts the CRC computation
00166                               This parameter must be a value of @ref FLASH_Sectors */
00167 
00168   uint32_t NbSectors;    /*!< Number of sectors to be computed.
00169                               This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
00170 
00171   uint32_t CRCStartAddr; /*!< CRC Start address.
00172                               This parameter must be a value between begin address and end address of a bank */
00173 
00174   uint32_t CRCEndAddr;   /*!< CRC End address.
00175                               This parameter must be a value between CRC Start address and end address of a bank */
00176 
00177 } FLASH_CRCInitTypeDef;
00178 
00179 /**
00180   * @}
00181   */
00182 /* Exported constants --------------------------------------------------------*/
00183 
00184 /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
00185   * @{
00186   */
00187 
00188 /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
00189   * @{
00190   */
00191 #define FLASH_TYPEERASE_SECTORS      0x00U  /*!< Sectors erase only          */
00192 #define FLASH_TYPEERASE_MASSERASE    0x01U  /*!< Flash Mass erase activation */
00193 /**
00194   * @}
00195   */
00196 
00197 #if defined (FLASH_CR_PSIZE)
00198 /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
00199   * @{
00200   */
00201 #define FLASH_VOLTAGE_RANGE_1        0x00000000U       /*!< Flash program/erase by 8 bits  */
00202 #define FLASH_VOLTAGE_RANGE_2        FLASH_CR_PSIZE_0  /*!< Flash program/erase by 16 bits */
00203 #define FLASH_VOLTAGE_RANGE_3        FLASH_CR_PSIZE_1  /*!< Flash program/erase by 32 bits */
00204 #define FLASH_VOLTAGE_RANGE_4        FLASH_CR_PSIZE    /*!< Flash program/erase by 64 bits */
00205 /**
00206   * @}
00207   */
00208 #endif /* FLASH_CR_PSIZE */
00209 
00210 /** @defgroup FLASHEx_WRP_State FLASH WRP State
00211   * @{
00212   */
00213 #define OB_WRPSTATE_DISABLE          0x00000000U  /*!< Disable the write protection of the desired bank 1 sectors */
00214 #define OB_WRPSTATE_ENABLE           0x00000001U  /*!< Enable the write protection of the desired bank 1 sectors  */
00215 /**
00216   * @}
00217   */
00218 
00219 /** @defgroup FLASHEx_Option_Type FLASH Option Type
00220   * @{
00221   */
00222 #define OPTIONBYTE_WRP           0x01U  /*!< WRP option byte configuration  */
00223 #define OPTIONBYTE_RDP           0x02U  /*!< RDP option byte configuration  */
00224 #define OPTIONBYTE_USER          0x04U  /*!< USER option byte configuration */
00225 #define OPTIONBYTE_PCROP         0x08U  /*!< PCROP option byte configuration */
00226 #define OPTIONBYTE_BOR           0x10U  /*!< BOR option byte configuration */
00227 #define OPTIONBYTE_SECURE_AREA   0x20U  /*!< secure area option byte configuration */
00228 #if defined (DUAL_CORE)
00229 #define OPTIONBYTE_CM7_BOOTADD   0x40U  /*!< CM7 BOOT ADD option byte configuration */
00230 #define OPTIONBYTE_CM4_BOOTADD   0x80U  /*!< CM4 BOOT ADD option byte configuration */
00231 #define OPTIONBYTE_BOOTADD       OPTIONBYTE_CM7_BOOTADD  /*!< BOOT ADD option byte configuration */
00232 #else /* Single core */
00233 #define OPTIONBYTE_BOOTADD       0x40U  /*!< BOOT ADD option byte configuration */
00234 #endif /*DUAL_CORE*/
00235 #if defined (FLASH_OTPBL_LOCKBL)
00236 #define OPTIONBYTE_OTP_LOCK      0x80U  /*!< OTP Lock option byte configuration */
00237 #endif /* FLASH_OTPBL_LOCKBL */
00238 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00239 #define OPTIONBYTE_SHARED_RAM    0x100U /*!< TCM / AXI Shared RAM option byte configuration */
00240 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
00241 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
00242 #define OPTIONBYTE_FREQ_BOOST    0x200U /*!< CPU Frequency Boost option byte configuration */
00243 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
00244 
00245 #if defined (DUAL_CORE)
00246 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
00247                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
00248                                   OPTIONBYTE_CM7_BOOTADD | OPTIONBYTE_CM4_BOOTADD) /*!< All option byte configuration */
00249 #elif defined (FLASH_OTPBL_LOCKBL)
00250 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
00251                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
00252                                   OPTIONBYTE_BOOTADD     | OPTIONBYTE_OTP_LOCK)    /*!< All option byte configuration */
00253 #elif defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00254 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
00255                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
00256                                   OPTIONBYTE_BOOTADD     | OPTIONBYTE_SHARED_RAM | OPTIONBYTE_FREQ_BOOST) /*!< All option byte configuration */
00257 #else
00258 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
00259                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
00260                                   OPTIONBYTE_BOOTADD)                              /*!< All option byte configuration */
00261 #endif /* DUAL_CORE */
00262 /**
00263   * @}
00264   */
00265 
00266 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
00267   * @{
00268   */
00269 #define OB_RDP_LEVEL_0       0xAA00U
00270 #define OB_RDP_LEVEL_1       0x5500U
00271 #define OB_RDP_LEVEL_2       0xCC00U   /*!< Warning: When enabling read protection level 2
00272                                             it s no more possible to go back to level 1 or 0 */
00273 /**
00274   * @}
00275   */
00276 
00277 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
00278   * @{
00279   */
00280 #define OB_IWDG_SW           OB_IWDG1_SW  /*!< Software IWDG selected */
00281 #define OB_IWDG_HW           OB_IWDG1_HW  /*!< Hardware IWDG selected */
00282 /**
00283   * @}
00284   */
00285 
00286 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
00287   * @{
00288   */
00289 #define OB_STOP_NO_RST       0x40U /*!< No reset generated when entering in STOP */
00290 #define OB_STOP_RST          0x00U /*!< Reset generated when entering in STOP    */
00291 /**
00292   * @}
00293   */
00294 
00295 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
00296   * @{
00297   */
00298 #define OB_STDBY_NO_RST      0x80U /*!< No reset generated when entering in STANDBY */
00299 #define OB_STDBY_RST         0x00U /*!< Reset generated when entering in STANDBY    */
00300 /**
00301   * @}
00302   */
00303 
00304 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_STOP FLASH IWDG Counter Freeze in STOP
00305   * @{
00306   */
00307 #define OB_IWDG_STOP_FREEZE  0x00000000U /*!< Freeze IWDG counter in STOP mode */
00308 #define OB_IWDG_STOP_ACTIVE  FLASH_OPTSR_FZ_IWDG_STOP /*!< IWDG counter active in STOP mode */
00309 /**
00310   * @}
00311   */
00312 
00313 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_SANDBY FLASH IWDG Counter Freeze in STANDBY
00314   * @{
00315   */
00316 #define OB_IWDG_STDBY_FREEZE 0x00000000U /*!< Freeze IWDG counter in STANDBY mode */
00317 #define OB_IWDG_STDBY_ACTIVE FLASH_OPTSR_FZ_IWDG_SDBY  /*!< IWDG counter active in STANDBY mode */
00318 /**
00319   * @}
00320   */
00321 
00322 /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
00323   * @{
00324   */
00325 #define OB_BOR_LEVEL0        0x00000000U                /*!< Reset level threshold is set to 1.6V */
00326 #define OB_BOR_LEVEL1        FLASH_OPTSR_BOR_LEV_0      /*!< Reset level threshold is set to 2.1V */
00327 #define OB_BOR_LEVEL2        FLASH_OPTSR_BOR_LEV_1      /*!< Reset level threshold is set to 2.4V */
00328 #define OB_BOR_LEVEL3        (FLASH_OPTSR_BOR_LEV_1 | FLASH_OPTSR_BOR_LEV_0) /*!< Reset level threshold is set to 2.7V  */
00329 /**
00330   * @}
00331   */
00332 
00333 
00334 
00335 /** @defgroup FLASHEx_Boot_Address FLASH Boot Address
00336   * @{
00337   */
00338 #define OB_BOOTADDR_ITCM_RAM     0x0000U  /*!< Boot from ITCM RAM (0x00000000)                 */
00339 #define OB_BOOTADDR_SYSTEM       0x0040U  /*!< Boot from System memory bootloader (0x00100000) */
00340 #define OB_BOOTADDR_ITCM_FLASH   0x0080U  /*!< Boot from Flash on ITCM interface (0x00200000)  */
00341 #define OB_BOOTADDR_AXIM_FLASH   0x2000U  /*!< Boot from Flash on AXIM interface (0x08000000)  */
00342 #define OB_BOOTADDR_DTCM_RAM     0x8000U  /*!< Boot from DTCM RAM (0x20000000)                 */
00343 #define OB_BOOTADDR_SRAM1        0x8004U  /*!< Boot from SRAM1 (0x20010000)                    */
00344 #define OB_BOOTADDR_SRAM2        0x8013U  /*!< Boot from SRAM2 (0x2004C000)                    */
00345 /**
00346   * @}
00347   */
00348 
00349 /** @defgroup FLASH_Latency FLASH Latency
00350   * @{
00351   */
00352 #define FLASH_LATENCY_0          FLASH_ACR_LATENCY_0WS   /*!< FLASH Zero Latency cycle      */
00353 #define FLASH_LATENCY_1          FLASH_ACR_LATENCY_1WS   /*!< FLASH One Latency cycle       */
00354 #define FLASH_LATENCY_2          FLASH_ACR_LATENCY_2WS   /*!< FLASH Two Latency cycles      */
00355 #define FLASH_LATENCY_3          FLASH_ACR_LATENCY_3WS   /*!< FLASH Three Latency cycles    */
00356 #define FLASH_LATENCY_4          FLASH_ACR_LATENCY_4WS   /*!< FLASH Four Latency cycles     */
00357 #define FLASH_LATENCY_5          FLASH_ACR_LATENCY_5WS   /*!< FLASH Five Latency cycles     */
00358 #define FLASH_LATENCY_6          FLASH_ACR_LATENCY_6WS   /*!< FLASH Six Latency cycles      */
00359 #define FLASH_LATENCY_7          FLASH_ACR_LATENCY_7WS   /*!< FLASH Seven Latency cycles    */
00360 
00361 /* Unused FLASH Latency defines */
00362 #define FLASH_LATENCY_8          FLASH_ACR_LATENCY_8WS   /*!< FLASH Eight Latency cycle     */
00363 #define FLASH_LATENCY_9          FLASH_ACR_LATENCY_9WS   /*!< FLASH Nine Latency cycle      */
00364 #define FLASH_LATENCY_10         FLASH_ACR_LATENCY_10WS  /*!< FLASH Ten Latency cycles      */
00365 #define FLASH_LATENCY_11         FLASH_ACR_LATENCY_11WS  /*!< FLASH Eleven Latency cycles   */
00366 #define FLASH_LATENCY_12         FLASH_ACR_LATENCY_12WS  /*!< FLASH Twelve Latency cycles   */
00367 #define FLASH_LATENCY_13         FLASH_ACR_LATENCY_13WS  /*!< FLASH Thirteen Latency cycles */
00368 #define FLASH_LATENCY_14         FLASH_ACR_LATENCY_14WS  /*!< FLASH Fourteen Latency cycles */
00369 #define FLASH_LATENCY_15         FLASH_ACR_LATENCY_15WS  /*!< FLASH Fifteen Latency cycles  */
00370 /**
00371   * @}
00372   */
00373 
00374 /** @defgroup FLASHEx_Banks FLASH Banks
00375   * @{
00376   */
00377 #define FLASH_BANK_1             0x01U                         /*!< Bank 1   */
00378 #if defined (DUAL_BANK)
00379 #define FLASH_BANK_2             0x02U                         /*!< Bank 2   */
00380 #define FLASH_BANK_BOTH          (FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
00381 #endif /* DUAL_BANK */
00382 /**
00383   * @}
00384   */
00385 
00386 /** @defgroup FLASHEx_OB_PCROP_RDP  FLASHEx OB PCROP RDP
00387   * @{
00388   */
00389 #define OB_PCROP_RDP_NOT_ERASE   0x00000000U     /*!< PCROP area is not erased when the RDP level
00390                                                       is decreased from Level 1 to Level 0 or during a mass erase */
00391 #define OB_PCROP_RDP_ERASE       FLASH_PRAR_DMEP /*!< PCROP area is erased when the RDP level is
00392                                                       decreased from Level 1 to Level 0 (full mass erase) */
00393 
00394 /**
00395   * @}
00396   */
00397 
00398 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
00399   * @{
00400   */
00401 #if (FLASH_SECTOR_TOTAL == 128)
00402 #define OB_WRP_SECTOR_0TO3       0x00000001U /*!< Write protection of Sector0  to Sector3    */
00403 #define OB_WRP_SECTOR_4TO7       0x00000002U /*!< Write protection of Sector4  to Sector7    */
00404 #define OB_WRP_SECTOR_8TO11      0x00000004U /*!< Write protection of Sector8  to Sector11   */
00405 #define OB_WRP_SECTOR_12TO15     0x00000008U /*!< Write protection of Sector12 to Sector15   */
00406 #define OB_WRP_SECTOR_16TO19     0x00000010U /*!< Write protection of Sector16 to Sector19   */
00407 #define OB_WRP_SECTOR_20TO23     0x00000020U /*!< Write protection of Sector20 to Sector23   */
00408 #define OB_WRP_SECTOR_24TO27     0x00000040U /*!< Write protection of Sector24 to Sector27   */
00409 #define OB_WRP_SECTOR_28TO31     0x00000080U /*!< Write protection of Sector28 to Sector31   */
00410 #define OB_WRP_SECTOR_32TO35     0x00000100U /*!< Write protection of Sector32 to Sector35   */
00411 #define OB_WRP_SECTOR_36TO39     0x00000200U /*!< Write protection of Sector36 to Sector39   */
00412 #define OB_WRP_SECTOR_40TO43     0x00000400U /*!< Write protection of Sector40 to Sector43   */
00413 #define OB_WRP_SECTOR_44TO47     0x00000800U /*!< Write protection of Sector44 to Sector47   */
00414 #define OB_WRP_SECTOR_48TO51     0x00001000U /*!< Write protection of Sector48 to Sector51   */
00415 #define OB_WRP_SECTOR_52TO55     0x00002000U /*!< Write protection of Sector52 to Sector55   */
00416 #define OB_WRP_SECTOR_56TO59     0x00004000U /*!< Write protection of Sector56 to Sector59   */
00417 #define OB_WRP_SECTOR_60TO63     0x00008000U /*!< Write protection of Sector60 to Sector63   */
00418 #define OB_WRP_SECTOR_64TO67     0x00010000U /*!< Write protection of Sector64 to Sector67   */
00419 #define OB_WRP_SECTOR_68TO71     0x00020000U /*!< Write protection of Sector68 to Sector71   */
00420 #define OB_WRP_SECTOR_72TO75     0x00040000U /*!< Write protection of Sector72 to Sector75   */
00421 #define OB_WRP_SECTOR_76TO79     0x00080000U /*!< Write protection of Sector76 to Sector79   */
00422 #define OB_WRP_SECTOR_80TO83     0x00100000U /*!< Write protection of Sector80 to Sector83   */
00423 #define OB_WRP_SECTOR_84TO87     0x00200000U /*!< Write protection of Sector84 to Sector87   */
00424 #define OB_WRP_SECTOR_88TO91     0x00400000U /*!< Write protection of Sector88 to Sector91   */
00425 #define OB_WRP_SECTOR_92TO95     0x00800000U /*!< Write protection of Sector92 to Sector95   */
00426 #define OB_WRP_SECTOR_96TO99     0x01000000U /*!< Write protection of Sector96  to Sector99  */
00427 #define OB_WRP_SECTOR_100TO103   0x02000000U /*!< Write protection of Sector100 to Sector103 */
00428 #define OB_WRP_SECTOR_104TO107   0x04000000U /*!< Write protection of Sector104 to Sector107 */
00429 #define OB_WRP_SECTOR_108TO111   0x08000000U /*!< Write protection of Sector108 to Sector111 */
00430 #define OB_WRP_SECTOR_112TO115   0x10000000U /*!< Write protection of Sector112 to Sector115 */
00431 #define OB_WRP_SECTOR_116TO119   0x20000000U /*!< Write protection of Sector116 to Sector119 */
00432 #define OB_WRP_SECTOR_120TO123   0x40000000U /*!< Write protection of Sector120 to Sector123 */
00433 #define OB_WRP_SECTOR_124TO127   0x80000000U /*!< Write protection of Sector124 to Sector127 */
00434 #define OB_WRP_SECTOR_ALL        0xFFFFFFFFU /*!< Write protection of all Sectors            */
00435 #else
00436 #define OB_WRP_SECTOR_0          0x00000001U /*!< Write protection of Sector0                */
00437 #define OB_WRP_SECTOR_1          0x00000002U /*!< Write protection of Sector1                */
00438 #define OB_WRP_SECTOR_2          0x00000004U /*!< Write protection of Sector2                */
00439 #define OB_WRP_SECTOR_3          0x00000008U /*!< Write protection of Sector3                */
00440 #define OB_WRP_SECTOR_4          0x00000010U /*!< Write protection of Sector4                */
00441 #define OB_WRP_SECTOR_5          0x00000020U /*!< Write protection of Sector5                */
00442 #define OB_WRP_SECTOR_6          0x00000040U /*!< Write protection of Sector6                */
00443 #define OB_WRP_SECTOR_7          0x00000080U /*!< Write protection of Sector7                */
00444 #define OB_WRP_SECTOR_ALL        0x000000FFU /*!< Write protection of all Sectors            */
00445 #endif /* FLASH_SECTOR_TOTAL == 128 */
00446 /**
00447   * @}
00448   */
00449 
00450 /** @defgroup FLASHEx_OB_SECURITY  FLASHEx OB SECURITY
00451   * @{
00452   */
00453 #define OB_SECURITY_DISABLE   0x00000000U             /*!< security enabled */
00454 #define OB_SECURITY_ENABLE    FLASH_OPTSR_SECURITY    /*!< security disabled */
00455 /**
00456   * @}
00457   */
00458 
00459 /** @defgroup FLASHEx_OB_ST_RAM_SIZE  FLASHEx OB ST RAM SIZE
00460   * @{
00461   */
00462 #define OB_ST_RAM_SIZE_2KB    0x00000000U               /*!< 2 Kbytes reserved to ST code */
00463 #define OB_ST_RAM_SIZE_4KB    FLASH_OPTSR_ST_RAM_SIZE_0 /*!< 4 Kbytes reserved to ST code */
00464 #define OB_ST_RAM_SIZE_8KB    FLASH_OPTSR_ST_RAM_SIZE_1 /*!< 8 Kbytes reserved to ST code */
00465 #define OB_ST_RAM_SIZE_16KB   FLASH_OPTSR_ST_RAM_SIZE   /*!< 16 Kbytes reserved to ST code */
00466 /**
00467   * @}
00468   */
00469 
00470 #if defined(DUAL_CORE)
00471 /** @defgroup FLASHEx_OB_BCM7  FLASHEx OB BCM7
00472   * @{
00473   */
00474 #define OB_BCM7_DISABLE       0x00000000U              /*!< CM7 Boot disabled */
00475 #define OB_BCM7_ENABLE        FLASH_OPTSR_BCM7         /*!< CM7 Boot enabled */
00476 
00477 /**
00478   * @}
00479   */
00480 
00481 /** @defgroup FLASHEx_OB_BCM4  FLASHEx OB BCM4
00482   * @{
00483   */
00484 #define OB_BCM4_DISABLE       0x00000000U              /*!< CM4 Boot disabled */
00485 #define OB_BCM4_ENABLE        FLASH_OPTSR_BCM4         /*!< CM4 Boot enabled */
00486 /**
00487   * @}
00488   */
00489 #endif /* DUAL_CORE */
00490 
00491 /** @defgroup FLASHEx_OB_IWDG1_SW  FLASHEx OB IWDG1 SW
00492   * @{
00493   */
00494 #define OB_IWDG1_SW            FLASH_OPTSR_IWDG1_SW /*!< Hardware independent watchdog 1 */
00495 #define OB_IWDG1_HW            0x00000000U          /*!< Software independent watchdog 1 */
00496 /**
00497   * @}
00498   */
00499 
00500 #if defined(DUAL_CORE)
00501 /** @defgroup FLASHEx_OB_IWDG2_SW  FLASHEx OB IWDG2 SW
00502   * @{
00503   */
00504 #define OB_IWDG2_SW            FLASH_OPTSR_IWDG2_SW  /*!< Hardware independent watchdog 2*/
00505 #define OB_IWDG2_HW            0x00000000U           /*!< Software independent watchdog 2*/
00506 /**
00507   * @}
00508   */
00509 #endif
00510 
00511 /** @defgroup FLASHEx_OB_NRST_STOP_D1  FLASHEx OB NRST STOP D1
00512   * @{
00513   */
00514 #define OB_STOP_RST_D1         0x00000000U              /*!< Reset generated when entering the D1 to stop mode */
00515 #define OB_STOP_NO_RST_D1      FLASH_OPTSR_NRST_STOP_D1 /*!< No reset generated when entering the D1 to stop mode */
00516 /**
00517   * @}
00518   */
00519 
00520 /** @defgroup FLASHEx_OB_NRST_STDBY_D1  FLASHEx OB NRST STDBY D1
00521   * @{
00522   */
00523 #define OB_STDBY_RST_D1        0x00000000U              /*!< Reset generated when entering the D1 to standby mode */
00524 #define OB_STDBY_NO_RST_D1     FLASH_OPTSR_NRST_STBY_D1 /*!< No reset generated when entering the D1 to standby mode */
00525 /**
00526   * @}
00527   */
00528 
00529 #if defined (FLASH_OPTSR_NRST_STOP_D2)
00530 /** @defgroup FLASHEx_OB_NRST_STOP_D2  FLASHEx OB NRST STOP D2
00531   * @{
00532   */
00533 #define OB_STOP_RST_D2         0x00000000U              /*!< Reset generated when entering the D2 to stop mode */
00534 #define OB_STOP_NO_RST_D2      FLASH_OPTSR_NRST_STOP_D2 /*!< No reset generated when entering the D2 to stop mode */
00535 /**
00536   * @}
00537   */
00538 
00539 /** @defgroup FLASHEx_OB_NRST_STDBY_D2  FLASHEx OB NRST STDBY D2
00540   * @{
00541   */
00542 #define OB_STDBY_RST_D2        0x00000000U              /*!< Reset generated when entering the D2 to standby mode */
00543 #define OB_STDBY_NO_RST_D2     FLASH_OPTSR_NRST_STBY_D2 /*!< No reset generated when entering the D2 to standby mode */
00544 /**
00545   * @}
00546   */
00547 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
00548 
00549 #if defined (DUAL_BANK)
00550 /** @defgroup FLASHEx_OB_SWAP_BANK  FLASHEx OB SWAP BANK
00551   * @{
00552   */
00553 #define OB_SWAP_BANK_DISABLE   0x00000000U               /*!< Bank swap disabled */
00554 #define OB_SWAP_BANK_ENABLE    FLASH_OPTSR_SWAP_BANK_OPT /*!< Bank swap enabled */
00555 /**
00556   * @}
00557   */
00558 #endif /* DUAL_BANK */
00559 
00560 /** @defgroup FLASHEx_OB_IOHSLV FLASHEx OB IOHSLV
00561   * @{
00562   */
00563 #define OB_IOHSLV_DISABLE      0x00000000U         /*!< IOHSLV disabled */
00564 #define OB_IOHSLV_ENABLE       FLASH_OPTSR_IO_HSLV /*!< IOHSLV enabled */
00565 /**
00566   * @}
00567   */
00568 
00569 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
00570 /** @defgroup FLASHEx_OB_VDDMMC_HSLV FLASHEx OB VDDMMC HSLV
00571   * @{
00572   */
00573 #define OB_VDDMMC_HSLV_DISABLE 0x00000000U             /*!< VDDMMC HSLV disabled */
00574 #define OB_VDDMMC_HSLV_ENABLE  FLASH_OPTSR_VDDMMC_HSLV /*!< VDDMMC HSLV enabled */
00575 /**
00576   * @}
00577   */
00578 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
00579 
00580 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
00581 /** @defgroup FLASHEx_OB_CPUFREQ_BOOST FLASHEx OB CPUFREQ BOOST
00582   * @{
00583   */
00584 #define OB_CPUFREQ_BOOST_DISABLE     0x00000000U                /*!< CPUFREQ BOOST disabled */
00585 #define OB_CPUFREQ_BOOST_ENABLE      FLASH_OPTSR2_CPUFREQ_BOOST /*!< CPUFREQ BOOST enabled */
00586 /**
00587   * @}
00588   */
00589 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
00590 
00591 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00592 /** @defgroup FLASHEx_OB_TCM_AXI_SHARED  FLASHEx OB TCM AXI SHARED
00593   * @{
00594   */
00595 #define OB_TCM_AXI_SHARED_ITCM64KB   0x00000000U                   /*!< 64KB ITCM / 320KB system AXI  */
00596 #define OB_TCM_AXI_SHARED_ITCM128KB  FLASH_OPTSR2_TCM_AXI_SHARED_0 /*!< 128KB ITCM / 256KB system AXI */
00597 #define OB_TCM_AXI_SHARED_ITCM192KB  FLASH_OPTSR2_TCM_AXI_SHARED_1 /*!< 192KB ITCM / 192KB system AXI */
00598 #define OB_TCM_AXI_SHARED_ITCM256KB  FLASH_OPTSR2_TCM_AXI_SHARED   /*!< 256KB ITCM / 128KB system AXI */
00599 /**
00600   * @}
00601   */
00602 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
00603 
00604  /** @defgroup FLASHEx_OB_USER_Type  FLASHEx OB USER Type
00605   * @{
00606   */
00607 #define OB_USER_IWDG1_SW          0x0001U /*!< Independent watchdog selection */
00608 #define OB_USER_NRST_STOP_D1      0x0002U /*!< Reset when entering Stop mode selection*/
00609 #define OB_USER_NRST_STDBY_D1     0x0004U /*!< Reset when entering standby mode selection*/
00610 #define OB_USER_IWDG_STOP         0x0008U /*!< Independent watchdog counter freeze in stop mode */
00611 #define OB_USER_IWDG_STDBY        0x0010U /*!< Independent watchdog counter freeze in standby mode */
00612 #define OB_USER_ST_RAM_SIZE       0x0020U /*!< dedicated DTCM Ram size selection */
00613 #define OB_USER_SECURITY          0x0040U /*!< security selection */
00614 #define OB_USER_IOHSLV            0x0080U /*!< IO HSLV selection */
00615 #if defined (DUAL_BANK)
00616 #define OB_USER_SWAP_BANK         0x0100U /*!< Bank swap selection */
00617 #endif /* DUAL_BANK */
00618 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
00619 #define OB_USER_VDDMMC_HSLV       0x0200U /*!< VDDMMC HSLV selection */
00620 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
00621 #if defined (DUAL_CORE)
00622 #define OB_USER_IWDG2_SW          0x0200U /*!< Window watchdog selection */
00623 #define OB_USER_BCM4              0x0400U /*!< CM4 boot selection */
00624 #define OB_USER_BCM7              0x0800U /*!< CM7 boot selection */
00625 #endif /*DUAL_CORE*/
00626 #if defined (FLASH_OPTSR_NRST_STOP_D2)
00627 #define OB_USER_NRST_STOP_D2      0x1000U /*!< Reset when entering Stop mode selection */
00628 #define OB_USER_NRST_STDBY_D2     0x2000U /*!< Reset when entering standby mode selection */
00629 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
00630 
00631 #if defined (DUAL_CORE)
00632 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00633                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00634                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     |\
00635                      OB_USER_IWDG2_SW     | OB_USER_BCM4         | OB_USER_BCM7          |\
00636                      OB_USER_NRST_STOP_D2 | OB_USER_NRST_STDBY_D2)
00637 #elif defined (FLASH_OPTSR_VDDMMC_HSLV)
00638 #if defined (DUAL_BANK)
00639 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00640                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00641                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     |\
00642                      OB_USER_VDDMMC_HSLV)
00643 #else
00644 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00645                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00646                      OB_USER_SECURITY     | OB_USER_IOHSLV                               |\
00647                      OB_USER_VDDMMC_HSLV)
00648 #endif /* DUAL_BANK */
00649 #elif defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00650 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00651                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00652                      OB_USER_SECURITY     | OB_USER_IOHSLV                               |\
00653                      OB_USER_NRST_STOP_D2 | OB_USER_NRST_STDBY_D2)
00654 #else /* Single core */
00655 #if defined (DUAL_BANK)
00656 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00657                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00658                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     )
00659 #else
00660 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
00661                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
00662                      OB_USER_SECURITY     | OB_USER_IOHSLV                               )
00663 #endif /* DUAL_BANK */
00664 #endif /* DUAL_CORE */
00665 /**
00666   * @}
00667   */
00668 
00669 /** @defgroup FLASHEx_OB_BOOT_OPTION  FLASHEx OB BOOT OPTION
00670   * @{
00671   */
00672 #define OB_BOOT_ADD0           0x01U       /*!< Select Boot Address 0 */
00673 #define OB_BOOT_ADD1           0x02U       /*!< Select Boot Address 1 */
00674 #define OB_BOOT_ADD_BOTH       0x03U       /*!< Select Boot Address 0 and 1 */
00675 /**
00676   * @}
00677   */
00678 
00679 /** @defgroup FLASHEx_OB_SECURE_RDP  FLASHEx OB SECURE RDP
00680   * @{
00681   */
00682 #define OB_SECURE_RDP_NOT_ERASE   0x00000000U     /*!< Secure area is not erased when the RDP level
00683                                                        is decreased from Level 1 to Level 0 or during a mass erase */
00684 #define OB_SECURE_RDP_ERASE       FLASH_SCAR_DMES /*!< Secure area is erased when the RDP level is
00685                                                        decreased from Level 1 to Level 0 (full mass erase) */
00686 /**
00687   * @}
00688   */
00689 
00690 /** @defgroup FLASHEx_CRC_Selection_Type FLASH CRC Selection Type
00691   * @{
00692   */
00693 #define FLASH_CRC_ADDR         0x00000000U              /*!< CRC selection type by address  */
00694 #define FLASH_CRC_SECTORS      FLASH_CRCCR_CRC_BY_SECT  /*!< CRC selection type by sectors  */
00695 #define FLASH_CRC_BANK         (FLASH_CRCCR_ALL_BANK | FLASH_CRCCR_CRC_BY_SECT) /*!< CRC selection type by bank */
00696 /**
00697   * @}
00698   */
00699 
00700 /** @defgroup FLASHEx_CRC_Burst_Size FLASH CRC Burst Size
00701   * @{
00702   */
00703 #define FLASH_CRC_BURST_SIZE_4    0x00000000U              /*!< Every burst has a size of 4 Flash words (256-bit)  */
00704 #define FLASH_CRC_BURST_SIZE_16   FLASH_CRCCR_CRC_BURST_0  /*!< Every burst has a size of 16 Flash words (256-bit)   */
00705 #define FLASH_CRC_BURST_SIZE_64   FLASH_CRCCR_CRC_BURST_1  /*!< Every burst has a size of 64 Flash words (256-bit)   */
00706 #define FLASH_CRC_BURST_SIZE_256  FLASH_CRCCR_CRC_BURST    /*!< Every burst has a size of 256 Flash words (256-bit) */
00707 /**
00708   * @}
00709   */
00710 
00711 /** @defgroup FLASHEx_Programming_Delay FLASH Programming Delay
00712   * @{
00713   */
00714 #define FLASH_PROGRAMMING_DELAY_0   0x00000000U            /*!< programming delay set for Flash running at 70 MHz or below          */
00715 #define FLASH_PROGRAMMING_DELAY_1   FLASH_ACR_WRHIGHFREQ_0 /*!< programming delay set for Flash running between 70 MHz and 185 MHz  */
00716 #define FLASH_PROGRAMMING_DELAY_2   FLASH_ACR_WRHIGHFREQ_1 /*!< programming delay set for Flash running between 185 MHz and 225 MHz */
00717 #define FLASH_PROGRAMMING_DELAY_3   FLASH_ACR_WRHIGHFREQ   /*!< programming delay set for Flash at startup */
00718 /**
00719   * @}
00720   */
00721 
00722 #if defined (FLASH_OTPBL_LOCKBL)
00723 /** @defgroup FLASHEx_OTP_Blocks FLASH OTP blocks
00724   * @{
00725   */
00726 #define FLASH_OTP_BLOCK_0          0x00000001U /*!< OTP Block0     */
00727 #define FLASH_OTP_BLOCK_1          0x00000002U /*!< OTP Block1     */
00728 #define FLASH_OTP_BLOCK_2          0x00000004U /*!< OTP Block2     */
00729 #define FLASH_OTP_BLOCK_3          0x00000008U /*!< OTP Block3     */
00730 #define FLASH_OTP_BLOCK_4          0x00000010U /*!< OTP Block4     */
00731 #define FLASH_OTP_BLOCK_5          0x00000020U /*!< OTP Block5     */
00732 #define FLASH_OTP_BLOCK_6          0x00000040U /*!< OTP Block6     */
00733 #define FLASH_OTP_BLOCK_7          0x00000080U /*!< OTP Block7     */
00734 #define FLASH_OTP_BLOCK_8          0x00000100U /*!< OTP Block8     */
00735 #define FLASH_OTP_BLOCK_9          0x00000200U /*!< OTP Block9     */
00736 #define FLASH_OTP_BLOCK_10         0x00000400U /*!< OTP Block10    */
00737 #define FLASH_OTP_BLOCK_11         0x00000800U /*!< OTP Block11    */
00738 #define FLASH_OTP_BLOCK_12         0x00001000U /*!< OTP Block12    */
00739 #define FLASH_OTP_BLOCK_13         0x00002000U /*!< OTP Block13    */
00740 #define FLASH_OTP_BLOCK_14         0x00004000U /*!< OTP Block14    */
00741 #define FLASH_OTP_BLOCK_15         0x00008000U /*!< OTP Block15    */
00742 #define FLASH_OTP_BLOCK_ALL        0x0000FFFFU /*!< OTP All Blocks */
00743 /**
00744   * @}
00745   */
00746 #endif /* FLASH_OTPBL_LOCKBL */
00747 
00748 /* Exported macro ------------------------------------------------------------*/
00749 /** @defgroup FLASHEx_Exported_Macros FLASH Exported Macros
00750   * @{
00751   */
00752 /**
00753   * @brief  Calculate the FLASH Boot Base Address (BOOT_ADD0 or BOOT_ADD1)
00754   * @note   Returned value BOOT_ADDx[15:0] corresponds to boot address [29:14].
00755   * @param  __ADDRESS__: FLASH Boot Address (in the range 0x0000 0000 to 0x2004 FFFF with a granularity of 16KB)
00756   * @retval The FLASH Boot Base Address
00757   */
00758 #define __HAL_FLASH_CALC_BOOT_BASE_ADR(__ADDRESS__) ((__ADDRESS__) >> 14U)
00759  /**
00760   * @}
00761   */
00762 
00763 #if defined (FLASH_CR_PSIZE)
00764 /**
00765   * @brief  Set the FLASH Program/Erase parallelism.
00766   * @param  __PSIZE__ FLASH Program/Erase parallelism
00767   *         This parameter can be a value of @ref FLASH_Program_Parallelism
00768   * @param  __BANK__: Flash bank (FLASH_BANK_1 or FLASH_BANK_2)
00769   * @retval none
00770   */
00771 #if defined (DUAL_BANK)
00772 #define __HAL_FLASH_SET_PSIZE(__PSIZE__, __BANK__) (((__BANK__) == FLASH_BANK_1)  ? \
00773                               MODIFY_REG(FLASH->CR1, FLASH_CR_PSIZE, (__PSIZE__)) : \
00774                               MODIFY_REG(FLASH->CR2, FLASH_CR_PSIZE, (__PSIZE__)))
00775 #else
00776 #define __HAL_FLASH_SET_PSIZE(__PSIZE__, __BANK__)  MODIFY_REG(FLASH->CR1, FLASH_CR_PSIZE, (__PSIZE__))
00777 #endif /* DUAL_BANK */
00778 
00779 /**
00780   * @brief  Get the FLASH Program/Erase parallelism.
00781   * @param  __BANK__ Flash bank (FLASH_BANK_1 or FLASH_BANK_2)
00782   * @retval FLASH Program/Erase parallelism
00783   *         This return value can be a value of @ref FLASH_Program_Parallelism
00784   */
00785 #if defined (DUAL_BANK)
00786 #define __HAL_FLASH_GET_PSIZE(__BANK__) (((__BANK__) == FLASH_BANK_1) ? \
00787                               READ_BIT((FLASH->CR1), FLASH_CR_PSIZE)  : \
00788                               READ_BIT((FLASH->CR2), FLASH_CR_PSIZE))
00789 #else
00790 #define __HAL_FLASH_GET_PSIZE(__BANK__)  READ_BIT((FLASH->CR1), FLASH_CR_PSIZE)
00791 #endif /* DUAL_BANK */
00792 
00793 #endif /* FLASH_CR_PSIZE */
00794 
00795 /**
00796   * @brief  Set the FLASH Programming Delay.
00797   * @param  __DELAY__ FLASH Programming Delay
00798   *         This parameter can be a value of @ref FLASHEx_Programming_Delay
00799   * @retval none
00800   */
00801 #define __HAL_FLASH_SET_PROGRAM_DELAY(__DELAY__)  MODIFY_REG(FLASH->ACR, FLASH_ACR_WRHIGHFREQ, (__DELAY__))
00802 
00803 /**
00804   * @brief  Get the FLASH Programming Delay.
00805   * @retval FLASH Programming Delay
00806   *         This return value can be a value of @ref FLASHEx_Programming_Delay
00807   */
00808 #define __HAL_FLASH_GET_PROGRAM_DELAY()     READ_BIT(FLASH->ACR, FLASH_ACR_WRHIGHFREQ)
00809 
00810 /* Exported functions --------------------------------------------------------*/
00811 /** @addtogroup FLASHEx_Exported_Functions
00812   * @{
00813   */
00814 
00815 /** @addtogroup FLASHEx_Exported_Functions_Group1
00816   * @{
00817   */
00818 /* Extension Program operation functions  *************************************/
00819 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
00820 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
00821 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
00822 void              HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
00823 
00824 HAL_StatusTypeDef HAL_FLASHEx_Unlock_Bank1(void);
00825 HAL_StatusTypeDef HAL_FLASHEx_Lock_Bank1(void);
00826 #if defined (DUAL_BANK)
00827 HAL_StatusTypeDef HAL_FLASHEx_Unlock_Bank2(void);
00828 HAL_StatusTypeDef HAL_FLASHEx_Lock_Bank2(void);
00829 #endif /* DUAL_BANK */
00830 
00831 HAL_StatusTypeDef HAL_FLASHEx_ComputeCRC(FLASH_CRCInitTypeDef *pCRCInit, uint32_t *CRC_Result);
00832 
00833 /**
00834   * @}
00835   */
00836 
00837 /**
00838   * @}
00839   */
00840 /* Private types -------------------------------------------------------------*/
00841 /* Private variables ---------------------------------------------------------*/
00842 /* Private constants ---------------------------------------------------------*/
00843 /* Private macros ------------------------------------------------------------*/
00844 /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros
00845   * @{
00846   */
00847 
00848 /** @defgroup FLASHEx_IS_FLASH_Definitions FLASHEx Private macros to check input parameters
00849   * @{
00850   */
00851 
00852 #define IS_FLASH_TYPEERASE(VALUE)        (((VALUE) == FLASH_TYPEERASE_SECTORS) || \
00853                                           ((VALUE) == FLASH_TYPEERASE_MASSERASE))
00854 
00855 #if defined (FLASH_CR_PSIZE)
00856 #define IS_VOLTAGERANGE(RANGE)           (((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
00857                                           ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
00858                                           ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
00859                                           ((RANGE) == FLASH_VOLTAGE_RANGE_4))
00860 #endif /* FLASH_CR_PSIZE */
00861 
00862 #define IS_WRPSTATE(VALUE)               (((VALUE) == OB_WRPSTATE_DISABLE) || \
00863                                           ((VALUE) == OB_WRPSTATE_ENABLE))
00864 
00865 #define IS_OPTIONBYTE(VALUE)             ((((VALUE) & OPTIONBYTE_ALL) != 0U) && \
00866                                           (((VALUE) & ~OPTIONBYTE_ALL) == 0U))
00867 
00868 #define IS_OB_BOOT_ADDRESS(ADDRESS)      ((ADDRESS) <= 0x8013U)
00869 
00870 #define IS_OB_RDP_LEVEL(LEVEL)           (((LEVEL) == OB_RDP_LEVEL_0)   ||\
00871                                           ((LEVEL) == OB_RDP_LEVEL_1)   ||\
00872                                           ((LEVEL) == OB_RDP_LEVEL_2))
00873 
00874 #define IS_OB_IWDG_SOURCE(SOURCE)        (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
00875 
00876 #define IS_OB_STOP_SOURCE(SOURCE)        (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
00877 
00878 #define IS_OB_STDBY_SOURCE(SOURCE)       (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
00879 
00880 #define IS_OB_IWDG_STOP_FREEZE(FREEZE)   (((FREEZE) == OB_IWDG_STOP_FREEZE) || ((FREEZE) == OB_IWDG_STOP_ACTIVE))
00881 
00882 #define IS_OB_IWDG_STDBY_FREEZE(FREEZE)  (((FREEZE) == OB_IWDG_STDBY_FREEZE) || ((FREEZE) == OB_IWDG_STDBY_ACTIVE))
00883 
00884 #define IS_OB_BOR_LEVEL(LEVEL)           (((LEVEL) == OB_BOR_LEVEL0) || ((LEVEL) == OB_BOR_LEVEL1) || \
00885                                           ((LEVEL) == OB_BOR_LEVEL2) || ((LEVEL) == OB_BOR_LEVEL3))
00886 
00887 #define IS_FLASH_LATENCY(LATENCY)        (((LATENCY) == FLASH_LATENCY_0)  || \
00888                                           ((LATENCY) == FLASH_LATENCY_1)  || \
00889                                           ((LATENCY) == FLASH_LATENCY_2)  || \
00890                                           ((LATENCY) == FLASH_LATENCY_3)  || \
00891                                           ((LATENCY) == FLASH_LATENCY_4)  || \
00892                                           ((LATENCY) == FLASH_LATENCY_5)  || \
00893                                           ((LATENCY) == FLASH_LATENCY_6)  || \
00894                                           ((LATENCY) == FLASH_LATENCY_7)  || \
00895                                           ((LATENCY) == FLASH_LATENCY_8)  || \
00896                                           ((LATENCY) == FLASH_LATENCY_9)  || \
00897                                           ((LATENCY) == FLASH_LATENCY_10) || \
00898                                           ((LATENCY) == FLASH_LATENCY_11) || \
00899                                           ((LATENCY) == FLASH_LATENCY_12) || \
00900                                           ((LATENCY) == FLASH_LATENCY_13) || \
00901                                           ((LATENCY) == FLASH_LATENCY_14) || \
00902                                           ((LATENCY) == FLASH_LATENCY_15))
00903 
00904 #define IS_FLASH_SECTOR(SECTOR)          ((SECTOR) < FLASH_SECTOR_TOTAL)
00905 
00906 #if (FLASH_SECTOR_TOTAL == 8U)
00907 #define IS_OB_WRP_SECTOR(SECTOR)         ((((SECTOR) & 0xFFFFFF00U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
00908 #else
00909 #define IS_OB_WRP_SECTOR(SECTOR)         ((SECTOR) != 0x00000000U)
00910 #endif /* FLASH_SECTOR_TOTAL == 8U */
00911 
00912 #define IS_OB_PCROP_RDP(CONFIG)          (((CONFIG) == OB_PCROP_RDP_NOT_ERASE) || \
00913                                           ((CONFIG) == OB_PCROP_RDP_ERASE))
00914 
00915 #define IS_OB_SECURE_RDP(CONFIG)         (((CONFIG) == OB_SECURE_RDP_NOT_ERASE) || \
00916                                           ((CONFIG) == OB_SECURE_RDP_ERASE))
00917 
00918 #if defined (DUAL_BANK)
00919 #define IS_OB_USER_SWAP_BANK(VALUE)      (((VALUE) == OB_SWAP_BANK_DISABLE) || ((VALUE) == OB_SWAP_BANK_ENABLE))
00920 #endif /* DUAL_BANK */
00921 
00922 #define IS_OB_USER_IOHSLV(VALUE)         (((VALUE) == OB_IOHSLV_DISABLE) || ((VALUE) == OB_IOHSLV_ENABLE))
00923 
00924 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
00925 #define IS_OB_USER_VDDMMC_HSLV(VALUE)    (((VALUE) == OB_VDDMMC_HSLV_DISABLE) || ((VALUE) == OB_VDDMMC_HSLV_ENABLE))
00926 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
00927 
00928 #define IS_OB_IWDG1_SOURCE(SOURCE)       (((SOURCE) == OB_IWDG1_SW) || ((SOURCE) == OB_IWDG1_HW))
00929 #if defined (DUAL_CORE)
00930 #define IS_OB_IWDG2_SOURCE(SOURCE)       (((SOURCE) == OB_IWDG2_SW) || ((SOURCE) == OB_IWDG2_HW))
00931 #endif /* DUAL_CORE */
00932 #define IS_OB_STOP_D1_RESET(VALUE)       (((VALUE) == OB_STOP_NO_RST_D1) || ((VALUE) == OB_STOP_RST_D1))
00933 
00934 #define IS_OB_STDBY_D1_RESET(VALUE)      (((VALUE) == OB_STDBY_NO_RST_D1) || ((VALUE) == OB_STDBY_RST_D1))
00935 
00936 #define IS_OB_USER_IWDG_STOP(VALUE)      (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_ACTIVE))
00937 
00938 #define IS_OB_USER_IWDG_STDBY(VALUE)     (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_ACTIVE))
00939 
00940 #define IS_OB_USER_ST_RAM_SIZE(VALUE)    (((VALUE) == OB_ST_RAM_SIZE_2KB) || ((VALUE) == OB_ST_RAM_SIZE_4KB) || \
00941                                           ((VALUE) == OB_ST_RAM_SIZE_8KB) || ((VALUE) == OB_ST_RAM_SIZE_16KB))
00942 
00943 #define IS_OB_USER_SECURITY(VALUE)       (((VALUE) == OB_SECURITY_ENABLE) || ((VALUE) == OB_SECURITY_DISABLE))
00944 
00945 #if defined (DUAL_CORE)
00946 #define IS_OB_USER_BCM4(VALUE)           (((VALUE) == OB_BCM4_DISABLE) || ((VALUE) == OB_BCM4_ENABLE))
00947 
00948 #define IS_OB_USER_BCM7(VALUE)           (((VALUE) == OB_BCM7_DISABLE) || ((VALUE) == OB_BCM7_ENABLE))
00949 #endif /* DUAL_CORE */
00950 
00951 #if defined (FLASH_OPTSR_NRST_STOP_D2)
00952 #define IS_OB_STOP_D2_RESET(VALUE)       (((VALUE) == OB_STOP_NO_RST_D2) || ((VALUE) == OB_STOP_RST_D2))
00953 
00954 #define IS_OB_STDBY_D2_RESET(VALUE)      (((VALUE) == OB_STDBY_NO_RST_D2) || ((VALUE) == OB_STDBY_RST_D2))
00955 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
00956 
00957 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
00958 #define IS_OB_USER_TCM_AXI_SHARED(VALUE) (((VALUE) == OB_TCM_AXI_SHARED_ITCM64KB) || ((VALUE) == OB_TCM_AXI_SHARED_ITCM128KB) || \
00959                                           ((VALUE) == OB_TCM_AXI_SHARED_ITCM192KB) || ((VALUE) == OB_TCM_AXI_SHARED_ITCM256KB))
00960 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
00961 
00962 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
00963 #define IS_OB_USER_CPUFREQ_BOOST(VALUE)  (((VALUE) == OB_CPUFREQ_BOOST_DISABLE) || ((VALUE) == OB_CPUFREQ_BOOST_ENABLE))
00964 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
00965 
00966 #define IS_OB_USER_TYPE(TYPE)            ((((TYPE) & OB_USER_ALL) != 0U) && \
00967                                           (((TYPE) & ~OB_USER_ALL) == 0U))
00968 
00969 #define IS_OB_BOOT_ADD_OPTION(VALUE)     (((VALUE) == OB_BOOT_ADD0)  || \
00970                                           ((VALUE) == OB_BOOT_ADD1)  || \
00971                                           ((VALUE) == OB_BOOT_ADD_BOTH))
00972 
00973 #define IS_FLASH_TYPECRC(VALUE)          (((VALUE) == FLASH_CRC_ADDR)    || \
00974                                           ((VALUE) == FLASH_CRC_SECTORS) || \
00975                                           ((VALUE) == FLASH_CRC_BANK))
00976 
00977 #if defined (FLASH_OTPBL_LOCKBL)
00978 #define IS_OTP_BLOCK(VALUE)              ((((VALUE) & 0xFFFF0000U) == 0x00000000U) && ((VALUE) != 0x00000000U))
00979 #endif /* FLASH_OTPBL_LOCKBL */
00980 /**
00981   * @}
00982   */
00983 
00984 /**
00985   * @}
00986   */
00987 
00988 /* Private functions ---------------------------------------------------------*/
00989 /** @defgroup FLASHEx_Private_Functions FLASHEx Private Functions
00990   * @{
00991   */
00992 void FLASH_Erase_Sector(uint32_t Sector, uint32_t Banks, uint32_t VoltageRange);
00993 /**
00994   * @}
00995   */
00996 
00997 /**
00998   * @}
00999   */
01000 
01001 /**
01002   * @}
01003   */
01004 
01005 /**
01006   * @}
01007   */
01008 
01009 #ifdef __cplusplus
01010 }
01011 #endif
01012 
01013 #endif /* STM32H7xx_HAL_FLASH_EX_H */
01014