Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:35

0001 /**
0002   ******************************************************************************
0003   * @file    stm32h7xx_hal_flash_ex.h
0004   * @author  MCD Application Team
0005   * @brief   Header file of FLASH HAL module.
0006   ******************************************************************************
0007   * @attention
0008   *
0009   * Copyright (c) 2017 STMicroelectronics.
0010   * All rights reserved.
0011   *
0012   * This software is licensed under terms that can be found in the LICENSE file in
0013   * the root directory of this software component.
0014   * If no LICENSE file comes with this software, it is provided AS-IS.
0015   ******************************************************************************
0016   */
0017 
0018 /* Define to prevent recursive inclusion -------------------------------------*/
0019 #ifndef STM32H7xx_HAL_FLASH_EX_H
0020 #define STM32H7xx_HAL_FLASH_EX_H
0021 
0022 #ifdef __cplusplus
0023  extern "C" {
0024 #endif
0025 
0026 /* Includes ------------------------------------------------------------------*/
0027 #include "stm32h7xx_hal_def.h"
0028 
0029 /** @addtogroup STM32H7xx_HAL_Driver
0030   * @{
0031   */
0032 
0033 /** @addtogroup FLASHEx
0034   * @{
0035   */
0036 
0037 /* Exported types ------------------------------------------------------------*/
0038 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types
0039   * @ingroup RTEMSBSPsARMSTM32H7
0040   * @{
0041   */
0042 
0043 /**
0044   * @brief  FLASH Erase structure definition
0045   */
0046 typedef struct
0047 {
0048   uint32_t TypeErase;   /*!< Mass erase or sector Erase.
0049                              This parameter can be a value of @ref FLASHEx_Type_Erase */
0050 
0051   uint32_t Banks;       /*!< Select banks to erase when Mass erase is enabled.
0052                              This parameter must be a value of @ref FLASHEx_Banks */
0053 
0054   uint32_t Sector;      /*!< Initial FLASH sector to erase when Mass erase is disabled
0055                              This parameter must be a value of @ref FLASH_Sectors */
0056 
0057   uint32_t NbSectors;   /*!< Number of sectors to be erased.
0058                              This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
0059 
0060   uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism
0061                              This parameter must be a value of @ref FLASHEx_Voltage_Range */
0062 
0063 } FLASH_EraseInitTypeDef;
0064 
0065 
0066 /**
0067   * @brief  FLASH Option Bytes Program structure definition
0068   */
0069 typedef struct
0070 {
0071   uint32_t OptionType;     /*!< Option byte to be configured.
0072                                 This parameter can be a value of @ref FLASHEx_Option_Type */
0073 
0074   uint32_t WRPState;       /*!< Write protection activation or deactivation.
0075                                 This parameter can be a value of @ref FLASHEx_WRP_State */
0076 
0077   uint32_t WRPSector;      /*!< Specifies the sector(s) to be write protected.
0078                                 The value of this parameter depend on device used within the same series */
0079 
0080   uint32_t RDPLevel;       /*!< Set the read protection level.
0081                                 This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
0082 
0083   uint32_t BORLevel;       /*!< Set the BOR Level.
0084                                 This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */
0085 
0086   uint32_t USERType;       /*!< User option byte(s) to be configured (used for OPTIONBYTE_USER).
0087                                 This parameter can be a combination of @ref FLASHEx_OB_USER_Type */
0088 
0089   uint32_t USERConfig;     /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY /
0090                                 IWDG_FREEZE_STOP / IWDG_FREEZE_SANDBY / IO_HSLV / SWAP_BANK_OPT */
0091 
0092   uint32_t Banks;          /*!< Select banks for WRP , PCROP and secure area config .
0093                                 This parameter must be a value of @ref FLASHEx_Banks */
0094 
0095   uint32_t PCROPConfig;    /*!< specifies if the PCROP area shall be erased or not
0096                                 when RDP level decreased from Level 1 to Level 0 or during a mass erase.
0097                                 This parameter must be a value of @ref FLASHEx_OB_PCROP_RDP enumeration */
0098 
0099   uint32_t PCROPStartAddr; /*!< PCROP Start address (used for OPTIONBYTE_PCROP).
0100                                 This parameter must be a value between begin and end of a bank */
0101 
0102   uint32_t PCROPEndAddr;   /*!< PCROP End address (used for OPTIONBYTE_PCROP).
0103                                 This parameter must be a value between PCROP Start address and end of a bank */
0104 
0105   uint32_t BootConfig;     /*!< Specifies if the Boot Address to be configured BOOT_ADD0, BOOT_ADD1
0106                                 or both. This parameter must be a value of @ref FLASHEx_OB_BOOT_OPTION enumeration */
0107 
0108   uint32_t BootAddr0;      /*!< Boot Address 0.
0109                                 This parameter must be a value between begin and end of a bank */
0110 
0111   uint32_t BootAddr1;      /*!< Boot Address 1.
0112                                 This parameter must be a value between begin and end of a bank */
0113 #if defined(DUAL_CORE)
0114   uint32_t CM4BootConfig;  /*!< specifies if the CM4 boot Address to be configured BOOT_ADD0, BOOT_ADD1
0115                                 or both.
0116                                 This parameter must be a value of @ref FLASHEx_OB_BOOT_OPTION enumeration */
0117 
0118   uint32_t CM4BootAddr0;   /*!< CM4 Boot Address 0.
0119                                 This parameter must be a value between begin and end of a bank */
0120 
0121   uint32_t CM4BootAddr1;   /*!< CM4 Boot Address 1.
0122                                 This parameter must be a value between begin and end of a bank */
0123 #endif /*DUAL_CORE*/
0124 
0125   uint32_t SecureAreaConfig;    /*!< specifies if the bank secured area shall be erased or not
0126                                      when RDP level decreased from Level 1 to Level 0 or during a mass erase.
0127                                      This parameter must be a value of @ref FLASHEx_OB_SECURE_RDP enumeration */
0128 
0129   uint32_t SecureAreaStartAddr; /*!< Bank Secure area Start address.
0130                                      This parameter must be a value between begin address and end address of bank1 */
0131 
0132   uint32_t SecureAreaEndAddr;   /*!< Bank Secure area End address.
0133                                      This parameter must be a value between Secure Area Start address and end address of a bank1 */
0134 
0135 #if defined (FLASH_OTPBL_LOCKBL)
0136   uint32_t OTPBlockLock;   /*!< Specifies the OTP block(s) to be locked.
0137                                 This parameter must be a value of @ref FLASHEx_OTP_Blocks */
0138 #endif /* FLASH_OTPBL_LOCKBL */
0139 
0140 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
0141   uint32_t SharedRamConfig; /*!< Specifies the configuration of TCM / AXI shared RAM.
0142                                  This parameter must be a value of @ref FLASHEx_OB_TCM_AXI_SHARED */
0143 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
0144 
0145 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
0146   uint32_t FreqBoostState;  /*!< Specifies the state of CPU Frequency Boost.
0147                                  This parameter must be a value of @ref FLASHEx_OB_CPUFREQ_BOOST */
0148 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
0149 
0150 } FLASH_OBProgramInitTypeDef;
0151 
0152 /**
0153   * @brief  FLASH Erase structure definition
0154   */
0155 typedef struct
0156 {
0157   uint32_t TypeCRC;      /*!< CRC Selection Type.
0158                               This parameter can be a value of @ref FLASHEx_CRC_Selection_Type */
0159 
0160   uint32_t BurstSize;    /*!< CRC Burst Size.
0161                               This parameter can be a value of @ref FLASHEx_CRC_Burst_Size */
0162 
0163   uint32_t Bank;         /*!< Select bank where CRC computation is enabled.
0164                               This parameter must be FLASH_BANK_1 or FLASH_BANK_2 */
0165 
0166   uint32_t Sector;       /*!< Initial FLASH sector from which starts the CRC computation
0167                               This parameter must be a value of @ref FLASH_Sectors */
0168 
0169   uint32_t NbSectors;    /*!< Number of sectors to be computed.
0170                               This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
0171 
0172   uint32_t CRCStartAddr; /*!< CRC Start address.
0173                               This parameter must be a value between begin address and end address of a bank */
0174 
0175   uint32_t CRCEndAddr;   /*!< CRC End address.
0176                               This parameter must be a value between CRC Start address and end address of a bank */
0177 
0178 } FLASH_CRCInitTypeDef;
0179 
0180 #if (USE_FLASH_ECC == 1U)
0181 /**
0182   * @brief  ECC Info Structure definition
0183   */
0184 typedef struct
0185 {
0186   uint32_t               Area;             /*!< Area from which an ECC was detected.
0187                                                 This parameter can be a value of @ref FLASHEx_ECC_Area  */
0188 
0189   uint32_t               Address;          /*!< ECC error address */
0190 
0191 } FLASH_EccInfoTypeDef;
0192 #endif /* USE_FLASH_ECC */
0193 
0194 /**
0195   * @}
0196   */
0197 /* Exported constants --------------------------------------------------------*/
0198 
0199 /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
0200   * @ingroup RTEMSBSPsARMSTM32H7
0201   * @{
0202   */
0203 
0204 /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
0205   * @ingroup RTEMSBSPsARMSTM32H7
0206   * @{
0207   */
0208 #define FLASH_TYPEERASE_SECTORS      0x00U  /*!< Sectors erase only          */
0209 #define FLASH_TYPEERASE_MASSERASE    0x01U  /*!< Flash Mass erase activation */
0210 /**
0211   * @}
0212   */
0213 
0214 #if defined (FLASH_CR_PSIZE)
0215 /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
0216   * @ingroup RTEMSBSPsARMSTM32H7
0217   * @{
0218   */
0219 #define FLASH_VOLTAGE_RANGE_1        0x00000000U       /*!< Flash program/erase by 8 bits  */
0220 #define FLASH_VOLTAGE_RANGE_2        FLASH_CR_PSIZE_0  /*!< Flash program/erase by 16 bits */
0221 #define FLASH_VOLTAGE_RANGE_3        FLASH_CR_PSIZE_1  /*!< Flash program/erase by 32 bits */
0222 #define FLASH_VOLTAGE_RANGE_4        FLASH_CR_PSIZE    /*!< Flash program/erase by 64 bits */
0223 /**
0224   * @}
0225   */
0226 #endif /* FLASH_CR_PSIZE */
0227 
0228 /** @defgroup FLASHEx_WRP_State FLASH WRP State
0229   * @ingroup RTEMSBSPsARMSTM32H7
0230   * @{
0231   */
0232 #define OB_WRPSTATE_DISABLE          0x00000000U  /*!< Disable the write protection of the desired bank 1 sectors */
0233 #define OB_WRPSTATE_ENABLE           0x00000001U  /*!< Enable the write protection of the desired bank 1 sectors  */
0234 /**
0235   * @}
0236   */
0237 
0238 #if (USE_FLASH_ECC == 1U)
0239 /** @defgroup FLASH_ECC_Area FLASH ECC Area
0240   * @brief    FLASH ECC Area
0241   * @{
0242   */
0243 #define FLASH_ECC_AREA_USER_BANK1         0x00000000U        /*!< FLASH bank 1 area */
0244 #define FLASH_ECC_AREA_USER_BANK2         0x00000001U        /*!< FLASH bank 2 area */
0245 /**
0246   * @}
0247   */
0248 #endif /* USE_FLASH_ECC */
0249 
0250 /** @defgroup FLASHEx_Option_Type FLASH Option Type
0251   * @ingroup RTEMSBSPsARMSTM32H7
0252   * @{
0253   */
0254 #define OPTIONBYTE_WRP           0x01U  /*!< WRP option byte configuration  */
0255 #define OPTIONBYTE_RDP           0x02U  /*!< RDP option byte configuration  */
0256 #define OPTIONBYTE_USER          0x04U  /*!< USER option byte configuration */
0257 #define OPTIONBYTE_PCROP         0x08U  /*!< PCROP option byte configuration */
0258 #define OPTIONBYTE_BOR           0x10U  /*!< BOR option byte configuration */
0259 #define OPTIONBYTE_SECURE_AREA   0x20U  /*!< secure area option byte configuration */
0260 #if defined (DUAL_CORE)
0261 #define OPTIONBYTE_CM7_BOOTADD   0x40U  /*!< CM7 BOOT ADD option byte configuration */
0262 #define OPTIONBYTE_CM4_BOOTADD   0x80U  /*!< CM4 BOOT ADD option byte configuration */
0263 #define OPTIONBYTE_BOOTADD       OPTIONBYTE_CM7_BOOTADD  /*!< BOOT ADD option byte configuration */
0264 #else /* Single core */
0265 #define OPTIONBYTE_BOOTADD       0x40U  /*!< BOOT ADD option byte configuration */
0266 #endif /*DUAL_CORE*/
0267 #if defined (FLASH_OTPBL_LOCKBL)
0268 #define OPTIONBYTE_OTP_LOCK      0x80U  /*!< OTP Lock option byte configuration */
0269 #endif /* FLASH_OTPBL_LOCKBL */
0270 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
0271 #define OPTIONBYTE_SHARED_RAM    0x100U /*!< TCM / AXI Shared RAM option byte configuration */
0272 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
0273 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
0274 #define OPTIONBYTE_FREQ_BOOST    0x200U /*!< CPU Frequency Boost option byte configuration */
0275 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
0276 
0277 #if defined (DUAL_CORE)
0278 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
0279                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
0280                                   OPTIONBYTE_CM7_BOOTADD | OPTIONBYTE_CM4_BOOTADD) /*!< All option byte configuration */
0281 #elif defined (FLASH_OTPBL_LOCKBL)
0282 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
0283                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
0284                                   OPTIONBYTE_BOOTADD     | OPTIONBYTE_OTP_LOCK)    /*!< All option byte configuration */
0285 #elif defined (FLASH_OPTSR2_TCM_AXI_SHARED)
0286 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
0287                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
0288                                   OPTIONBYTE_BOOTADD     | OPTIONBYTE_SHARED_RAM | OPTIONBYTE_FREQ_BOOST) /*!< All option byte configuration */
0289 #else
0290 #define OPTIONBYTE_ALL           (OPTIONBYTE_WRP         | OPTIONBYTE_RDP        | OPTIONBYTE_USER        |\
0291                                   OPTIONBYTE_PCROP       | OPTIONBYTE_BOR        | OPTIONBYTE_SECURE_AREA |\
0292                                   OPTIONBYTE_BOOTADD)                              /*!< All option byte configuration */
0293 #endif /* DUAL_CORE */
0294 /**
0295   * @}
0296   */
0297 
0298 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
0299   * @ingroup RTEMSBSPsARMSTM32H7
0300   * @{
0301   */
0302 #define OB_RDP_LEVEL_0       0xAA00U
0303 #define OB_RDP_LEVEL_1       0x5500U
0304 #define OB_RDP_LEVEL_2       0xCC00U   /*!< Warning: When enabling read protection level 2
0305                                             it s no more possible to go back to level 1 or 0 */
0306 /**
0307   * @}
0308   */
0309 
0310 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
0311   * @ingroup RTEMSBSPsARMSTM32H7
0312   * @{
0313   */
0314 #define OB_IWDG_SW           OB_IWDG1_SW  /*!< Software IWDG selected */
0315 #define OB_IWDG_HW           OB_IWDG1_HW  /*!< Hardware IWDG selected */
0316 /**
0317   * @}
0318   */
0319 
0320 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
0321   * @ingroup RTEMSBSPsARMSTM32H7
0322   * @{
0323   */
0324 #define OB_STOP_NO_RST       0x40U /*!< No reset generated when entering in STOP */
0325 #define OB_STOP_RST          0x00U /*!< Reset generated when entering in STOP    */
0326 /**
0327   * @}
0328   */
0329 
0330 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
0331   * @ingroup RTEMSBSPsARMSTM32H7
0332   * @{
0333   */
0334 #define OB_STDBY_NO_RST      0x80U /*!< No reset generated when entering in STANDBY */
0335 #define OB_STDBY_RST         0x00U /*!< Reset generated when entering in STANDBY    */
0336 /**
0337   * @}
0338   */
0339 
0340 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_STOP FLASH IWDG Counter Freeze in STOP
0341   * @ingroup RTEMSBSPsARMSTM32H7
0342   * @{
0343   */
0344 #define OB_IWDG_STOP_FREEZE  0x00000000U /*!< Freeze IWDG counter in STOP mode */
0345 #define OB_IWDG_STOP_ACTIVE  FLASH_OPTSR_FZ_IWDG_STOP /*!< IWDG counter active in STOP mode */
0346 /**
0347   * @}
0348   */
0349 
0350 /** @defgroup FLASHEx_Option_Bytes_IWDG_FREEZE_SANDBY FLASH IWDG Counter Freeze in STANDBY
0351   * @ingroup RTEMSBSPsARMSTM32H7
0352   * @{
0353   */
0354 #define OB_IWDG_STDBY_FREEZE 0x00000000U /*!< Freeze IWDG counter in STANDBY mode */
0355 #define OB_IWDG_STDBY_ACTIVE FLASH_OPTSR_FZ_IWDG_SDBY  /*!< IWDG counter active in STANDBY mode */
0356 /**
0357   * @}
0358   */
0359 
0360 /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
0361   * @ingroup RTEMSBSPsARMSTM32H7
0362   * @{
0363   */
0364 #define OB_BOR_LEVEL0        0x00000000U                /*!< Reset level threshold is set to 1.6V */
0365 #define OB_BOR_LEVEL1        FLASH_OPTSR_BOR_LEV_0      /*!< Reset level threshold is set to 2.1V */
0366 #define OB_BOR_LEVEL2        FLASH_OPTSR_BOR_LEV_1      /*!< Reset level threshold is set to 2.4V */
0367 #define OB_BOR_LEVEL3        (FLASH_OPTSR_BOR_LEV_1 | FLASH_OPTSR_BOR_LEV_0) /*!< Reset level threshold is set to 2.7V  */
0368 /**
0369   * @}
0370   */
0371 
0372 
0373 
0374 /** @defgroup FLASHEx_Boot_Address FLASH Boot Address
0375   * @ingroup RTEMSBSPsARMSTM32H7
0376   * @{
0377   */
0378 #define OB_BOOTADDR_ITCM_RAM     0x0000U  /*!< Boot from ITCM RAM (0x00000000)                 */
0379 #define OB_BOOTADDR_SYSTEM       0x0040U  /*!< Boot from System memory bootloader (0x00100000) */
0380 #define OB_BOOTADDR_ITCM_FLASH   0x0080U  /*!< Boot from Flash on ITCM interface (0x00200000)  */
0381 #define OB_BOOTADDR_AXIM_FLASH   0x2000U  /*!< Boot from Flash on AXIM interface (0x08000000)  */
0382 #define OB_BOOTADDR_DTCM_RAM     0x8000U  /*!< Boot from DTCM RAM (0x20000000)                 */
0383 #define OB_BOOTADDR_SRAM1        0x8004U  /*!< Boot from SRAM1 (0x20010000)                    */
0384 #define OB_BOOTADDR_SRAM2        0x8013U  /*!< Boot from SRAM2 (0x2004C000)                    */
0385 /**
0386   * @}
0387   */
0388 
0389 /** @defgroup FLASH_Latency FLASH Latency
0390   * @ingroup RTEMSBSPsARMSTM32H7
0391   * @{
0392   */
0393 #define FLASH_LATENCY_0          FLASH_ACR_LATENCY_0WS   /*!< FLASH Zero Latency cycle      */
0394 #define FLASH_LATENCY_1          FLASH_ACR_LATENCY_1WS   /*!< FLASH One Latency cycle       */
0395 #define FLASH_LATENCY_2          FLASH_ACR_LATENCY_2WS   /*!< FLASH Two Latency cycles      */
0396 #define FLASH_LATENCY_3          FLASH_ACR_LATENCY_3WS   /*!< FLASH Three Latency cycles    */
0397 #define FLASH_LATENCY_4          FLASH_ACR_LATENCY_4WS   /*!< FLASH Four Latency cycles     */
0398 #define FLASH_LATENCY_5          FLASH_ACR_LATENCY_5WS   /*!< FLASH Five Latency cycles     */
0399 #define FLASH_LATENCY_6          FLASH_ACR_LATENCY_6WS   /*!< FLASH Six Latency cycles      */
0400 #define FLASH_LATENCY_7          FLASH_ACR_LATENCY_7WS   /*!< FLASH Seven Latency cycles    */
0401 
0402 /* Unused FLASH Latency defines */
0403 #define FLASH_LATENCY_8          FLASH_ACR_LATENCY_8WS   /*!< FLASH Eight Latency cycle     */
0404 #define FLASH_LATENCY_9          FLASH_ACR_LATENCY_9WS   /*!< FLASH Nine Latency cycle      */
0405 #define FLASH_LATENCY_10         FLASH_ACR_LATENCY_10WS  /*!< FLASH Ten Latency cycles      */
0406 #define FLASH_LATENCY_11         FLASH_ACR_LATENCY_11WS  /*!< FLASH Eleven Latency cycles   */
0407 #define FLASH_LATENCY_12         FLASH_ACR_LATENCY_12WS  /*!< FLASH Twelve Latency cycles   */
0408 #define FLASH_LATENCY_13         FLASH_ACR_LATENCY_13WS  /*!< FLASH Thirteen Latency cycles */
0409 #define FLASH_LATENCY_14         FLASH_ACR_LATENCY_14WS  /*!< FLASH Fourteen Latency cycles */
0410 #define FLASH_LATENCY_15         FLASH_ACR_LATENCY_15WS  /*!< FLASH Fifteen Latency cycles  */
0411 /**
0412   * @}
0413   */
0414 
0415 /** @defgroup FLASHEx_Banks FLASH Banks
0416   * @ingroup RTEMSBSPsARMSTM32H7
0417   * @{
0418   */
0419 #define FLASH_BANK_1             0x01U                         /*!< Bank 1   */
0420 #if defined (DUAL_BANK)
0421 #define FLASH_BANK_2             0x02U                         /*!< Bank 2   */
0422 #define FLASH_BANK_BOTH          (FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
0423 #endif /* DUAL_BANK */
0424 /**
0425   * @}
0426   */
0427 
0428 /** @defgroup FLASHEx_OB_PCROP_RDP  FLASHEx OB PCROP RDP
0429   * @ingroup RTEMSBSPsARMSTM32H7
0430   * @{
0431   */
0432 #define OB_PCROP_RDP_NOT_ERASE   0x00000000U     /*!< PCROP area is not erased when the RDP level
0433                                                       is decreased from Level 1 to Level 0 or during a mass erase */
0434 #define OB_PCROP_RDP_ERASE       FLASH_PRAR_DMEP /*!< PCROP area is erased when the RDP level is
0435                                                       decreased from Level 1 to Level 0 (full mass erase) */
0436 
0437 /**
0438   * @}
0439   */
0440 
0441 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
0442   * @ingroup RTEMSBSPsARMSTM32H7
0443   * @{
0444   */
0445 #if (FLASH_SECTOR_TOTAL == 128)
0446 #define OB_WRP_SECTOR_0TO3       0x00000001U /*!< Write protection of Sector0  to Sector3    */
0447 #define OB_WRP_SECTOR_4TO7       0x00000002U /*!< Write protection of Sector4  to Sector7    */
0448 #define OB_WRP_SECTOR_8TO11      0x00000004U /*!< Write protection of Sector8  to Sector11   */
0449 #define OB_WRP_SECTOR_12TO15     0x00000008U /*!< Write protection of Sector12 to Sector15   */
0450 #define OB_WRP_SECTOR_16TO19     0x00000010U /*!< Write protection of Sector16 to Sector19   */
0451 #define OB_WRP_SECTOR_20TO23     0x00000020U /*!< Write protection of Sector20 to Sector23   */
0452 #define OB_WRP_SECTOR_24TO27     0x00000040U /*!< Write protection of Sector24 to Sector27   */
0453 #define OB_WRP_SECTOR_28TO31     0x00000080U /*!< Write protection of Sector28 to Sector31   */
0454 #define OB_WRP_SECTOR_32TO35     0x00000100U /*!< Write protection of Sector32 to Sector35   */
0455 #define OB_WRP_SECTOR_36TO39     0x00000200U /*!< Write protection of Sector36 to Sector39   */
0456 #define OB_WRP_SECTOR_40TO43     0x00000400U /*!< Write protection of Sector40 to Sector43   */
0457 #define OB_WRP_SECTOR_44TO47     0x00000800U /*!< Write protection of Sector44 to Sector47   */
0458 #define OB_WRP_SECTOR_48TO51     0x00001000U /*!< Write protection of Sector48 to Sector51   */
0459 #define OB_WRP_SECTOR_52TO55     0x00002000U /*!< Write protection of Sector52 to Sector55   */
0460 #define OB_WRP_SECTOR_56TO59     0x00004000U /*!< Write protection of Sector56 to Sector59   */
0461 #define OB_WRP_SECTOR_60TO63     0x00008000U /*!< Write protection of Sector60 to Sector63   */
0462 #define OB_WRP_SECTOR_64TO67     0x00010000U /*!< Write protection of Sector64 to Sector67   */
0463 #define OB_WRP_SECTOR_68TO71     0x00020000U /*!< Write protection of Sector68 to Sector71   */
0464 #define OB_WRP_SECTOR_72TO75     0x00040000U /*!< Write protection of Sector72 to Sector75   */
0465 #define OB_WRP_SECTOR_76TO79     0x00080000U /*!< Write protection of Sector76 to Sector79   */
0466 #define OB_WRP_SECTOR_80TO83     0x00100000U /*!< Write protection of Sector80 to Sector83   */
0467 #define OB_WRP_SECTOR_84TO87     0x00200000U /*!< Write protection of Sector84 to Sector87   */
0468 #define OB_WRP_SECTOR_88TO91     0x00400000U /*!< Write protection of Sector88 to Sector91   */
0469 #define OB_WRP_SECTOR_92TO95     0x00800000U /*!< Write protection of Sector92 to Sector95   */
0470 #define OB_WRP_SECTOR_96TO99     0x01000000U /*!< Write protection of Sector96  to Sector99  */
0471 #define OB_WRP_SECTOR_100TO103   0x02000000U /*!< Write protection of Sector100 to Sector103 */
0472 #define OB_WRP_SECTOR_104TO107   0x04000000U /*!< Write protection of Sector104 to Sector107 */
0473 #define OB_WRP_SECTOR_108TO111   0x08000000U /*!< Write protection of Sector108 to Sector111 */
0474 #define OB_WRP_SECTOR_112TO115   0x10000000U /*!< Write protection of Sector112 to Sector115 */
0475 #define OB_WRP_SECTOR_116TO119   0x20000000U /*!< Write protection of Sector116 to Sector119 */
0476 #define OB_WRP_SECTOR_120TO123   0x40000000U /*!< Write protection of Sector120 to Sector123 */
0477 #define OB_WRP_SECTOR_124TO127   0x80000000U /*!< Write protection of Sector124 to Sector127 */
0478 #define OB_WRP_SECTOR_ALL        0xFFFFFFFFU /*!< Write protection of all Sectors            */
0479 #else
0480 #define OB_WRP_SECTOR_0          0x00000001U /*!< Write protection of Sector0                */
0481 #define OB_WRP_SECTOR_1          0x00000002U /*!< Write protection of Sector1                */
0482 #define OB_WRP_SECTOR_2          0x00000004U /*!< Write protection of Sector2                */
0483 #define OB_WRP_SECTOR_3          0x00000008U /*!< Write protection of Sector3                */
0484 #define OB_WRP_SECTOR_4          0x00000010U /*!< Write protection of Sector4                */
0485 #define OB_WRP_SECTOR_5          0x00000020U /*!< Write protection of Sector5                */
0486 #define OB_WRP_SECTOR_6          0x00000040U /*!< Write protection of Sector6                */
0487 #define OB_WRP_SECTOR_7          0x00000080U /*!< Write protection of Sector7                */
0488 #define OB_WRP_SECTOR_ALL        0x000000FFU /*!< Write protection of all Sectors            */
0489 #endif /* FLASH_SECTOR_TOTAL == 128 */
0490 /**
0491   * @}
0492   */
0493 
0494 /** @defgroup FLASHEx_OB_SECURITY  FLASHEx OB SECURITY
0495   * @ingroup RTEMSBSPsARMSTM32H7
0496   * @{
0497   */
0498 #define OB_SECURITY_DISABLE   0x00000000U             /*!< security enabled */
0499 #define OB_SECURITY_ENABLE    FLASH_OPTSR_SECURITY    /*!< security disabled */
0500 /**
0501   * @}
0502   */
0503 
0504 /** @defgroup FLASHEx_OB_ST_RAM_SIZE  FLASHEx OB ST RAM SIZE
0505   * @ingroup RTEMSBSPsARMSTM32H7
0506   * @{
0507   */
0508 #define OB_ST_RAM_SIZE_2KB    0x00000000U               /*!< 2 Kbytes reserved to ST code */
0509 #define OB_ST_RAM_SIZE_4KB    FLASH_OPTSR_ST_RAM_SIZE_0 /*!< 4 Kbytes reserved to ST code */
0510 #define OB_ST_RAM_SIZE_8KB    FLASH_OPTSR_ST_RAM_SIZE_1 /*!< 8 Kbytes reserved to ST code */
0511 #define OB_ST_RAM_SIZE_16KB   FLASH_OPTSR_ST_RAM_SIZE   /*!< 16 Kbytes reserved to ST code */
0512 /**
0513   * @}
0514   */
0515 
0516 #if defined(DUAL_CORE)
0517 /** @defgroup FLASHEx_OB_BCM7  FLASHEx OB BCM7
0518   * @ingroup RTEMSBSPsARMSTM32H7
0519   * @{
0520   */
0521 #define OB_BCM7_DISABLE       0x00000000U              /*!< CM7 Boot disabled */
0522 #define OB_BCM7_ENABLE        FLASH_OPTSR_BCM7         /*!< CM7 Boot enabled */
0523 
0524 /**
0525   * @}
0526   */
0527 
0528 /** @defgroup FLASHEx_OB_BCM4  FLASHEx OB BCM4
0529   * @ingroup RTEMSBSPsARMSTM32H7
0530   * @{
0531   */
0532 #define OB_BCM4_DISABLE       0x00000000U              /*!< CM4 Boot disabled */
0533 #define OB_BCM4_ENABLE        FLASH_OPTSR_BCM4         /*!< CM4 Boot enabled */
0534 /**
0535   * @}
0536   */
0537 #endif /* DUAL_CORE */
0538 
0539 /** @defgroup FLASHEx_OB_IWDG1_SW  FLASHEx OB IWDG1 SW
0540   * @ingroup RTEMSBSPsARMSTM32H7
0541   * @{
0542   */
0543 #define OB_IWDG1_SW            FLASH_OPTSR_IWDG1_SW /*!< Hardware independent watchdog 1 */
0544 #define OB_IWDG1_HW            0x00000000U          /*!< Software independent watchdog 1 */
0545 /**
0546   * @}
0547   */
0548 
0549 #if defined(DUAL_CORE)
0550 /** @defgroup FLASHEx_OB_IWDG2_SW  FLASHEx OB IWDG2 SW
0551   * @ingroup RTEMSBSPsARMSTM32H7
0552   * @{
0553   */
0554 #define OB_IWDG2_SW            FLASH_OPTSR_IWDG2_SW  /*!< Hardware independent watchdog 2*/
0555 #define OB_IWDG2_HW            0x00000000U           /*!< Software independent watchdog 2*/
0556 /**
0557   * @}
0558   */
0559 #endif
0560 
0561 /** @defgroup FLASHEx_OB_NRST_STOP_D1  FLASHEx OB NRST STOP D1
0562   * @ingroup RTEMSBSPsARMSTM32H7
0563   * @{
0564   */
0565 #define OB_STOP_RST_D1         0x00000000U              /*!< Reset generated when entering the D1 to stop mode */
0566 #define OB_STOP_NO_RST_D1      FLASH_OPTSR_NRST_STOP_D1 /*!< No reset generated when entering the D1 to stop mode */
0567 /**
0568   * @}
0569   */
0570 
0571 /** @defgroup FLASHEx_OB_NRST_STDBY_D1  FLASHEx OB NRST STDBY D1
0572   * @ingroup RTEMSBSPsARMSTM32H7
0573   * @{
0574   */
0575 #define OB_STDBY_RST_D1        0x00000000U              /*!< Reset generated when entering the D1 to standby mode */
0576 #define OB_STDBY_NO_RST_D1     FLASH_OPTSR_NRST_STBY_D1 /*!< No reset generated when entering the D1 to standby mode */
0577 /**
0578   * @}
0579   */
0580 
0581 #if defined (FLASH_OPTSR_NRST_STOP_D2)
0582 /** @defgroup FLASHEx_OB_NRST_STOP_D2  FLASHEx OB NRST STOP D2
0583   * @ingroup RTEMSBSPsARMSTM32H7
0584   * @{
0585   */
0586 #define OB_STOP_RST_D2         0x00000000U              /*!< Reset generated when entering the D2 to stop mode */
0587 #define OB_STOP_NO_RST_D2      FLASH_OPTSR_NRST_STOP_D2 /*!< No reset generated when entering the D2 to stop mode */
0588 /**
0589   * @}
0590   */
0591 
0592 /** @defgroup FLASHEx_OB_NRST_STDBY_D2  FLASHEx OB NRST STDBY D2
0593   * @ingroup RTEMSBSPsARMSTM32H7
0594   * @{
0595   */
0596 #define OB_STDBY_RST_D2        0x00000000U              /*!< Reset generated when entering the D2 to standby mode */
0597 #define OB_STDBY_NO_RST_D2     FLASH_OPTSR_NRST_STBY_D2 /*!< No reset generated when entering the D2 to standby mode */
0598 /**
0599   * @}
0600   */
0601 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
0602 
0603 #if defined (DUAL_BANK)
0604 /** @defgroup FLASHEx_OB_SWAP_BANK  FLASHEx OB SWAP BANK
0605   * @ingroup RTEMSBSPsARMSTM32H7
0606   * @{
0607   */
0608 #define OB_SWAP_BANK_DISABLE   0x00000000U               /*!< Bank swap disabled */
0609 #define OB_SWAP_BANK_ENABLE    FLASH_OPTSR_SWAP_BANK_OPT /*!< Bank swap enabled */
0610 /**
0611   * @}
0612   */
0613 #endif /* DUAL_BANK */
0614 
0615 /** @defgroup FLASHEx_OB_IOHSLV FLASHEx OB IOHSLV
0616   * @ingroup RTEMSBSPsARMSTM32H7
0617   * @{
0618   */
0619 #define OB_IOHSLV_DISABLE      0x00000000U         /*!< IOHSLV disabled */
0620 #define OB_IOHSLV_ENABLE       FLASH_OPTSR_IO_HSLV /*!< IOHSLV enabled */
0621 /**
0622   * @}
0623   */
0624 
0625 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
0626 /** @defgroup FLASHEx_OB_VDDMMC_HSLV FLASHEx OB VDDMMC HSLV
0627   * @ingroup RTEMSBSPsARMSTM32H7
0628   * @{
0629   */
0630 #define OB_VDDMMC_HSLV_DISABLE 0x00000000U             /*!< VDDMMC HSLV disabled */
0631 #define OB_VDDMMC_HSLV_ENABLE  FLASH_OPTSR_VDDMMC_HSLV /*!< VDDMMC HSLV enabled */
0632 /**
0633   * @}
0634   */
0635 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
0636 
0637 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
0638 /** @defgroup FLASHEx_OB_CPUFREQ_BOOST FLASHEx OB CPUFREQ BOOST
0639   * @ingroup RTEMSBSPsARMSTM32H7
0640   * @{
0641   */
0642 #define OB_CPUFREQ_BOOST_DISABLE     0x00000000U                /*!< CPUFREQ BOOST disabled */
0643 #define OB_CPUFREQ_BOOST_ENABLE      FLASH_OPTSR2_CPUFREQ_BOOST /*!< CPUFREQ BOOST enabled */
0644 /**
0645   * @}
0646   */
0647 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
0648 
0649 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
0650 /** @defgroup FLASHEx_OB_TCM_AXI_SHARED  FLASHEx OB TCM AXI SHARED
0651   * @ingroup RTEMSBSPsARMSTM32H7
0652   * @{
0653   */
0654 #define OB_TCM_AXI_SHARED_ITCM64KB   0x00000000U                   /*!< 64KB ITCM / 320KB system AXI  */
0655 #define OB_TCM_AXI_SHARED_ITCM128KB  FLASH_OPTSR2_TCM_AXI_SHARED_0 /*!< 128KB ITCM / 256KB system AXI */
0656 #define OB_TCM_AXI_SHARED_ITCM192KB  FLASH_OPTSR2_TCM_AXI_SHARED_1 /*!< 192KB ITCM / 192KB system AXI */
0657 #define OB_TCM_AXI_SHARED_ITCM256KB  FLASH_OPTSR2_TCM_AXI_SHARED   /*!< 256KB ITCM / 128KB system AXI */
0658 /**
0659   * @}
0660   */
0661 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
0662 
0663  /** @defgroup FLASHEx_OB_USER_Type  FLASHEx OB USER Type
0664    * @ingroup RTEMSBSPsARMSTM32H7
0665   * @{
0666   */
0667 #define OB_USER_IWDG1_SW          0x0001U /*!< Independent watchdog selection */
0668 #define OB_USER_NRST_STOP_D1      0x0002U /*!< Reset when entering Stop mode selection*/
0669 #define OB_USER_NRST_STDBY_D1     0x0004U /*!< Reset when entering standby mode selection*/
0670 #define OB_USER_IWDG_STOP         0x0008U /*!< Independent watchdog counter freeze in stop mode */
0671 #define OB_USER_IWDG_STDBY        0x0010U /*!< Independent watchdog counter freeze in standby mode */
0672 #define OB_USER_ST_RAM_SIZE       0x0020U /*!< dedicated DTCM Ram size selection */
0673 #define OB_USER_SECURITY          0x0040U /*!< security selection */
0674 #define OB_USER_IOHSLV            0x0080U /*!< IO HSLV selection */
0675 #if defined (DUAL_BANK)
0676 #define OB_USER_SWAP_BANK         0x0100U /*!< Bank swap selection */
0677 #endif /* DUAL_BANK */
0678 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
0679 #define OB_USER_VDDMMC_HSLV       0x0200U /*!< VDDMMC HSLV selection */
0680 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
0681 #if defined (DUAL_CORE)
0682 #define OB_USER_IWDG2_SW          0x0200U /*!< Window watchdog selection */
0683 #define OB_USER_BCM4              0x0400U /*!< CM4 boot selection */
0684 #define OB_USER_BCM7              0x0800U /*!< CM7 boot selection */
0685 #endif /*DUAL_CORE*/
0686 #if defined (FLASH_OPTSR_NRST_STOP_D2)
0687 #define OB_USER_NRST_STOP_D2      0x1000U /*!< Reset when entering Stop mode selection */
0688 #define OB_USER_NRST_STDBY_D2     0x2000U /*!< Reset when entering standby mode selection */
0689 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
0690 
0691 #if defined (DUAL_CORE)
0692 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0693                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0694                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     |\
0695                      OB_USER_IWDG2_SW     | OB_USER_BCM4         | OB_USER_BCM7          |\
0696                      OB_USER_NRST_STOP_D2 | OB_USER_NRST_STDBY_D2)
0697 #elif defined (FLASH_OPTSR_VDDMMC_HSLV)
0698 #if defined (DUAL_BANK)
0699 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0700                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0701                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     |\
0702                      OB_USER_VDDMMC_HSLV)
0703 #else
0704 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0705                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0706                      OB_USER_SECURITY     | OB_USER_IOHSLV                               |\
0707                      OB_USER_VDDMMC_HSLV)
0708 #endif /* DUAL_BANK */
0709 #elif defined (FLASH_OPTSR2_TCM_AXI_SHARED)
0710 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0711                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0712                      OB_USER_SECURITY     | OB_USER_IOHSLV                               |\
0713                      OB_USER_NRST_STOP_D2 | OB_USER_NRST_STDBY_D2)
0714 #else /* Single core */
0715 #if defined (DUAL_BANK)
0716 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0717                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0718                      OB_USER_SECURITY     | OB_USER_IOHSLV       | OB_USER_SWAP_BANK     )
0719 #else
0720 #define OB_USER_ALL (OB_USER_IWDG1_SW     | OB_USER_NRST_STOP_D1 | OB_USER_NRST_STDBY_D1 |\
0721                      OB_USER_IWDG_STOP    | OB_USER_IWDG_STDBY   | OB_USER_ST_RAM_SIZE   |\
0722                      OB_USER_SECURITY     | OB_USER_IOHSLV                               )
0723 #endif /* DUAL_BANK */
0724 #endif /* DUAL_CORE */
0725 /**
0726   * @}
0727   */
0728 
0729 /** @defgroup FLASHEx_OB_BOOT_OPTION  FLASHEx OB BOOT OPTION
0730   * @ingroup RTEMSBSPsARMSTM32H7
0731   * @{
0732   */
0733 #define OB_BOOT_ADD0           0x01U       /*!< Select Boot Address 0 */
0734 #define OB_BOOT_ADD1           0x02U       /*!< Select Boot Address 1 */
0735 #define OB_BOOT_ADD_BOTH       0x03U       /*!< Select Boot Address 0 and 1 */
0736 /**
0737   * @}
0738   */
0739 
0740 /** @defgroup FLASHEx_OB_SECURE_RDP  FLASHEx OB SECURE RDP
0741   * @ingroup RTEMSBSPsARMSTM32H7
0742   * @{
0743   */
0744 #define OB_SECURE_RDP_NOT_ERASE   0x00000000U     /*!< Secure area is not erased when the RDP level
0745                                                        is decreased from Level 1 to Level 0 or during a mass erase */
0746 #define OB_SECURE_RDP_ERASE       FLASH_SCAR_DMES /*!< Secure area is erased when the RDP level is
0747                                                        decreased from Level 1 to Level 0 (full mass erase) */
0748 /**
0749   * @}
0750   */
0751 
0752 /** @defgroup FLASHEx_CRC_Selection_Type FLASH CRC Selection Type
0753   * @ingroup RTEMSBSPsARMSTM32H7
0754   * @{
0755   */
0756 #define FLASH_CRC_ADDR         0x00000000U              /*!< CRC selection type by address  */
0757 #define FLASH_CRC_SECTORS      FLASH_CRCCR_CRC_BY_SECT  /*!< CRC selection type by sectors  */
0758 #define FLASH_CRC_BANK         (FLASH_CRCCR_ALL_BANK | FLASH_CRCCR_CRC_BY_SECT) /*!< CRC selection type by bank */
0759 /**
0760   * @}
0761   */
0762 
0763 /** @defgroup FLASHEx_CRC_Burst_Size FLASH CRC Burst Size
0764   * @ingroup RTEMSBSPsARMSTM32H7
0765   * @{
0766   */
0767 #define FLASH_CRC_BURST_SIZE_4    0x00000000U              /*!< Every burst has a size of 4 Flash words (256-bit)  */
0768 #define FLASH_CRC_BURST_SIZE_16   FLASH_CRCCR_CRC_BURST_0  /*!< Every burst has a size of 16 Flash words (256-bit)   */
0769 #define FLASH_CRC_BURST_SIZE_64   FLASH_CRCCR_CRC_BURST_1  /*!< Every burst has a size of 64 Flash words (256-bit)   */
0770 #define FLASH_CRC_BURST_SIZE_256  FLASH_CRCCR_CRC_BURST    /*!< Every burst has a size of 256 Flash words (256-bit) */
0771 /**
0772   * @}
0773   */
0774 
0775 /** @defgroup FLASHEx_Programming_Delay FLASH Programming Delay
0776   * @ingroup RTEMSBSPsARMSTM32H7
0777   * @{
0778   */
0779 #define FLASH_PROGRAMMING_DELAY_0   0x00000000U            /*!< programming delay set for Flash running at 70 MHz or below          */
0780 #define FLASH_PROGRAMMING_DELAY_1   FLASH_ACR_WRHIGHFREQ_0 /*!< programming delay set for Flash running between 70 MHz and 185 MHz  */
0781 #define FLASH_PROGRAMMING_DELAY_2   FLASH_ACR_WRHIGHFREQ_1 /*!< programming delay set for Flash running between 185 MHz and 225 MHz */
0782 #define FLASH_PROGRAMMING_DELAY_3   FLASH_ACR_WRHIGHFREQ   /*!< programming delay set for Flash at startup */
0783 /**
0784   * @}
0785   */
0786 
0787 #if defined (FLASH_OTPBL_LOCKBL)
0788 /** @defgroup FLASHEx_OTP_Blocks FLASH OTP blocks
0789   * @ingroup RTEMSBSPsARMSTM32H7
0790   * @{
0791   */
0792 #define FLASH_OTP_BLOCK_0          0x00000001U /*!< OTP Block0     */
0793 #define FLASH_OTP_BLOCK_1          0x00000002U /*!< OTP Block1     */
0794 #define FLASH_OTP_BLOCK_2          0x00000004U /*!< OTP Block2     */
0795 #define FLASH_OTP_BLOCK_3          0x00000008U /*!< OTP Block3     */
0796 #define FLASH_OTP_BLOCK_4          0x00000010U /*!< OTP Block4     */
0797 #define FLASH_OTP_BLOCK_5          0x00000020U /*!< OTP Block5     */
0798 #define FLASH_OTP_BLOCK_6          0x00000040U /*!< OTP Block6     */
0799 #define FLASH_OTP_BLOCK_7          0x00000080U /*!< OTP Block7     */
0800 #define FLASH_OTP_BLOCK_8          0x00000100U /*!< OTP Block8     */
0801 #define FLASH_OTP_BLOCK_9          0x00000200U /*!< OTP Block9     */
0802 #define FLASH_OTP_BLOCK_10         0x00000400U /*!< OTP Block10    */
0803 #define FLASH_OTP_BLOCK_11         0x00000800U /*!< OTP Block11    */
0804 #define FLASH_OTP_BLOCK_12         0x00001000U /*!< OTP Block12    */
0805 #define FLASH_OTP_BLOCK_13         0x00002000U /*!< OTP Block13    */
0806 #define FLASH_OTP_BLOCK_14         0x00004000U /*!< OTP Block14    */
0807 #define FLASH_OTP_BLOCK_15         0x00008000U /*!< OTP Block15    */
0808 #define FLASH_OTP_BLOCK_ALL        0x0000FFFFU /*!< OTP All Blocks */
0809 /**
0810   * @}
0811   */
0812 #endif /* FLASH_OTPBL_LOCKBL */
0813 /**
0814   * @}
0815   */
0816 
0817 /* Exported macro ------------------------------------------------------------*/
0818 /** @defgroup FLASHEx_Exported_Macros FLASH Exported Macros
0819   * @ingroup RTEMSBSPsARMSTM32H7
0820   * @{
0821   */
0822 /**
0823   * @brief  Calculate the FLASH Boot Base Address (BOOT_ADD0 or BOOT_ADD1)
0824   * @note   Returned value BOOT_ADDx[15:0] corresponds to boot address [29:14].
0825   * @param  __ADDRESS__: FLASH Boot Address (in the range 0x0000 0000 to 0x2004 FFFF with a granularity of 16KB)
0826   * @retval The FLASH Boot Base Address
0827   */
0828 #define __HAL_FLASH_CALC_BOOT_BASE_ADR(__ADDRESS__) ((__ADDRESS__) >> 14U)
0829 
0830 #if defined (FLASH_CR_PSIZE)
0831 /**
0832   * @brief  Set the FLASH Program/Erase parallelism.
0833   * @param  __PSIZE__ FLASH Program/Erase parallelism
0834   *         This parameter can be a value of @ref FLASH_Program_Parallelism
0835   * @param  __BANK__: Flash bank (FLASH_BANK_1 or FLASH_BANK_2)
0836   * @retval none
0837   */
0838 #if defined (DUAL_BANK)
0839 #define __HAL_FLASH_SET_PSIZE(__PSIZE__, __BANK__) (((__BANK__) == FLASH_BANK_1)  ? \
0840                               MODIFY_REG(FLASH->CR1, FLASH_CR_PSIZE, (__PSIZE__)) : \
0841                               MODIFY_REG(FLASH->CR2, FLASH_CR_PSIZE, (__PSIZE__)))
0842 #else
0843 #define __HAL_FLASH_SET_PSIZE(__PSIZE__, __BANK__)  MODIFY_REG(FLASH->CR1, FLASH_CR_PSIZE, (__PSIZE__))
0844 #endif /* DUAL_BANK */
0845 
0846 /**
0847   * @brief  Get the FLASH Program/Erase parallelism.
0848   * @param  __BANK__ Flash bank (FLASH_BANK_1 or FLASH_BANK_2)
0849   * @retval FLASH Program/Erase parallelism
0850   *         This return value can be a value of @ref FLASH_Program_Parallelism
0851   */
0852 #if defined (DUAL_BANK)
0853 #define __HAL_FLASH_GET_PSIZE(__BANK__) (((__BANK__) == FLASH_BANK_1) ? \
0854                               READ_BIT((FLASH->CR1), FLASH_CR_PSIZE)  : \
0855                               READ_BIT((FLASH->CR2), FLASH_CR_PSIZE))
0856 #else
0857 #define __HAL_FLASH_GET_PSIZE(__BANK__)  READ_BIT((FLASH->CR1), FLASH_CR_PSIZE)
0858 #endif /* DUAL_BANK */
0859 
0860 #endif /* FLASH_CR_PSIZE */
0861 
0862 /**
0863   * @brief  Set the FLASH Programming Delay.
0864   * @param  __DELAY__ FLASH Programming Delay
0865   *         This parameter can be a value of @ref FLASHEx_Programming_Delay
0866   * @retval none
0867   */
0868 #define __HAL_FLASH_SET_PROGRAM_DELAY(__DELAY__)  MODIFY_REG(FLASH->ACR, FLASH_ACR_WRHIGHFREQ, (__DELAY__))
0869 
0870 /**
0871   * @brief  Get the FLASH Programming Delay.
0872   * @retval FLASH Programming Delay
0873   *         This return value can be a value of @ref FLASHEx_Programming_Delay
0874   */
0875 #define __HAL_FLASH_GET_PROGRAM_DELAY()     READ_BIT(FLASH->ACR, FLASH_ACR_WRHIGHFREQ)
0876  /**
0877   * @}
0878   */
0879 
0880 /* Exported functions --------------------------------------------------------*/
0881 /** @addtogroup FLASHEx_Exported_Functions
0882   * @{
0883   */
0884 
0885 /** @addtogroup FLASHEx_Exported_Functions_Group1
0886   * @{
0887   */
0888 /* Extension Program operation functions  *************************************/
0889 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
0890 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit);
0891 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit);
0892 void              HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit);
0893 
0894 HAL_StatusTypeDef HAL_FLASHEx_Unlock_Bank1(void);
0895 HAL_StatusTypeDef HAL_FLASHEx_Lock_Bank1(void);
0896 #if defined (DUAL_BANK)
0897 HAL_StatusTypeDef HAL_FLASHEx_Unlock_Bank2(void);
0898 HAL_StatusTypeDef HAL_FLASHEx_Lock_Bank2(void);
0899 #endif /* DUAL_BANK */
0900 
0901 HAL_StatusTypeDef HAL_FLASHEx_ComputeCRC(FLASH_CRCInitTypeDef *pCRCInit, uint32_t *CRC_Result);
0902 
0903 /**
0904   * @}
0905   */
0906 
0907 #if (USE_FLASH_ECC == 1U)
0908 /** @addtogroup FLASHEx_Exported_Functions_Group3
0909   * @{
0910   */
0911 void              HAL_FLASHEx_EnableEccCorrectionInterrupt(void);
0912 void              HAL_FLASHEx_DisableEccCorrectionInterrupt(void);
0913 void              HAL_FLASHEx_EnableEccCorrectionInterrupt_Bank1(void);
0914 void              HAL_FLASHEx_DisableEccCorrectionInterrupt_Bank1(void);
0915 #if defined (DUAL_BANK)
0916 void              HAL_FLASHEx_EnableEccCorrectionInterrupt_Bank2(void);
0917 void              HAL_FLASHEx_DisableEccCorrectionInterrupt_Bank2(void);
0918 #endif /* DUAL_BANK */
0919 
0920 void              HAL_FLASHEx_EnableEccDetectionInterrupt(void);
0921 void              HAL_FLASHEx_DisableEccDetectionInterrupt(void);
0922 void              HAL_FLASHEx_EnableEccDetectionInterrupt_Bank1(void);
0923 void              HAL_FLASHEx_DisableEccDetectionInterrupt_Bank1(void);
0924 #if defined (DUAL_BANK)
0925 void              HAL_FLASHEx_EnableEccDetectionInterrupt_Bank2(void);
0926 void              HAL_FLASHEx_DisableEccDetectionInterrupt_Bank2(void);
0927 #endif /* DUAL_BANK */
0928 
0929 void              HAL_FLASHEx_GetEccInfo(FLASH_EccInfoTypeDef *pData);
0930 void              HAL_FLASHEx_BusFault_IRQHandler(void);
0931 
0932 __weak void       HAL_FLASHEx_EccDetectionCallback(void);
0933 __weak void       HAL_FLASHEx_EccCorrectionCallback(void);
0934 /**
0935   * @}
0936   */
0937 #endif /* USE_FLASH_ECC */
0938 
0939 /**
0940   * @}
0941   */
0942 /* Private types -------------------------------------------------------------*/
0943 /* Private variables ---------------------------------------------------------*/
0944 /* Private constants ---------------------------------------------------------*/
0945 /* Private macros ------------------------------------------------------------*/
0946 /** @defgroup FLASHEx_Private_Macros FLASHEx Private Macros
0947   * @ingroup RTEMSBSPsARMSTM32H7
0948   * @{
0949   */
0950 
0951 /** @defgroup FLASHEx_IS_FLASH_Definitions FLASHEx Private macros to check input parameters
0952   * @ingroup RTEMSBSPsARMSTM32H7
0953   * @{
0954   */
0955 
0956 #define IS_FLASH_TYPEERASE(VALUE)        (((VALUE) == FLASH_TYPEERASE_SECTORS) || \
0957                                           ((VALUE) == FLASH_TYPEERASE_MASSERASE))
0958 
0959 #if defined (FLASH_CR_PSIZE)
0960 #define IS_VOLTAGERANGE(RANGE)           (((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
0961                                           ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
0962                                           ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
0963                                           ((RANGE) == FLASH_VOLTAGE_RANGE_4))
0964 #endif /* FLASH_CR_PSIZE */
0965 
0966 #define IS_WRPSTATE(VALUE)               (((VALUE) == OB_WRPSTATE_DISABLE) || \
0967                                           ((VALUE) == OB_WRPSTATE_ENABLE))
0968 
0969 #define IS_OPTIONBYTE(VALUE)             ((((VALUE) & OPTIONBYTE_ALL) != 0U) && \
0970                                           (((VALUE) & ~OPTIONBYTE_ALL) == 0U))
0971 
0972 #define IS_OB_BOOT_ADDRESS(ADDRESS)      ((ADDRESS) <= 0x8013U)
0973 
0974 #define IS_OB_RDP_LEVEL(LEVEL)           (((LEVEL) == OB_RDP_LEVEL_0)   ||\
0975                                           ((LEVEL) == OB_RDP_LEVEL_1)   ||\
0976                                           ((LEVEL) == OB_RDP_LEVEL_2))
0977 
0978 #define IS_OB_IWDG_SOURCE(SOURCE)        (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
0979 
0980 #define IS_OB_STOP_SOURCE(SOURCE)        (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
0981 
0982 #define IS_OB_STDBY_SOURCE(SOURCE)       (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
0983 
0984 #define IS_OB_IWDG_STOP_FREEZE(FREEZE)   (((FREEZE) == OB_IWDG_STOP_FREEZE) || ((FREEZE) == OB_IWDG_STOP_ACTIVE))
0985 
0986 #define IS_OB_IWDG_STDBY_FREEZE(FREEZE)  (((FREEZE) == OB_IWDG_STDBY_FREEZE) || ((FREEZE) == OB_IWDG_STDBY_ACTIVE))
0987 
0988 #define IS_OB_BOR_LEVEL(LEVEL)           (((LEVEL) == OB_BOR_LEVEL0) || ((LEVEL) == OB_BOR_LEVEL1) || \
0989                                           ((LEVEL) == OB_BOR_LEVEL2) || ((LEVEL) == OB_BOR_LEVEL3))
0990 
0991 #define IS_FLASH_LATENCY(LATENCY)        (((LATENCY) == FLASH_LATENCY_0)  || \
0992                                           ((LATENCY) == FLASH_LATENCY_1)  || \
0993                                           ((LATENCY) == FLASH_LATENCY_2)  || \
0994                                           ((LATENCY) == FLASH_LATENCY_3)  || \
0995                                           ((LATENCY) == FLASH_LATENCY_4)  || \
0996                                           ((LATENCY) == FLASH_LATENCY_5)  || \
0997                                           ((LATENCY) == FLASH_LATENCY_6)  || \
0998                                           ((LATENCY) == FLASH_LATENCY_7)  || \
0999                                           ((LATENCY) == FLASH_LATENCY_8)  || \
1000                                           ((LATENCY) == FLASH_LATENCY_9)  || \
1001                                           ((LATENCY) == FLASH_LATENCY_10) || \
1002                                           ((LATENCY) == FLASH_LATENCY_11) || \
1003                                           ((LATENCY) == FLASH_LATENCY_12) || \
1004                                           ((LATENCY) == FLASH_LATENCY_13) || \
1005                                           ((LATENCY) == FLASH_LATENCY_14) || \
1006                                           ((LATENCY) == FLASH_LATENCY_15))
1007 
1008 #define IS_FLASH_SECTOR(SECTOR)          ((SECTOR) < FLASH_SECTOR_TOTAL)
1009 
1010 #if (FLASH_SECTOR_TOTAL == 8U)
1011 #define IS_OB_WRP_SECTOR(SECTOR)         ((((SECTOR) & 0xFFFFFF00U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1012 #else
1013 #define IS_OB_WRP_SECTOR(SECTOR)         ((SECTOR) != 0x00000000U)
1014 #endif /* FLASH_SECTOR_TOTAL == 8U */
1015 
1016 #define IS_OB_PCROP_RDP(CONFIG)          (((CONFIG) == OB_PCROP_RDP_NOT_ERASE) || \
1017                                           ((CONFIG) == OB_PCROP_RDP_ERASE))
1018 
1019 #define IS_OB_SECURE_RDP(CONFIG)         (((CONFIG) == OB_SECURE_RDP_NOT_ERASE) || \
1020                                           ((CONFIG) == OB_SECURE_RDP_ERASE))
1021 
1022 #if defined (DUAL_BANK)
1023 #define IS_OB_USER_SWAP_BANK(VALUE)      (((VALUE) == OB_SWAP_BANK_DISABLE) || ((VALUE) == OB_SWAP_BANK_ENABLE))
1024 #endif /* DUAL_BANK */
1025 
1026 #define IS_OB_USER_IOHSLV(VALUE)         (((VALUE) == OB_IOHSLV_DISABLE) || ((VALUE) == OB_IOHSLV_ENABLE))
1027 
1028 #if defined (FLASH_OPTSR_VDDMMC_HSLV)
1029 #define IS_OB_USER_VDDMMC_HSLV(VALUE)    (((VALUE) == OB_VDDMMC_HSLV_DISABLE) || ((VALUE) == OB_VDDMMC_HSLV_ENABLE))
1030 #endif /* FLASH_OPTSR_VDDMMC_HSLV */
1031 
1032 #define IS_OB_IWDG1_SOURCE(SOURCE)       (((SOURCE) == OB_IWDG1_SW) || ((SOURCE) == OB_IWDG1_HW))
1033 #if defined (DUAL_CORE)
1034 #define IS_OB_IWDG2_SOURCE(SOURCE)       (((SOURCE) == OB_IWDG2_SW) || ((SOURCE) == OB_IWDG2_HW))
1035 #endif /* DUAL_CORE */
1036 #define IS_OB_STOP_D1_RESET(VALUE)       (((VALUE) == OB_STOP_NO_RST_D1) || ((VALUE) == OB_STOP_RST_D1))
1037 
1038 #define IS_OB_STDBY_D1_RESET(VALUE)      (((VALUE) == OB_STDBY_NO_RST_D1) || ((VALUE) == OB_STDBY_RST_D1))
1039 
1040 #define IS_OB_USER_IWDG_STOP(VALUE)      (((VALUE) == OB_IWDG_STOP_FREEZE) || ((VALUE) == OB_IWDG_STOP_ACTIVE))
1041 
1042 #define IS_OB_USER_IWDG_STDBY(VALUE)     (((VALUE) == OB_IWDG_STDBY_FREEZE) || ((VALUE) == OB_IWDG_STDBY_ACTIVE))
1043 
1044 #define IS_OB_USER_ST_RAM_SIZE(VALUE)    (((VALUE) == OB_ST_RAM_SIZE_2KB) || ((VALUE) == OB_ST_RAM_SIZE_4KB) || \
1045                                           ((VALUE) == OB_ST_RAM_SIZE_8KB) || ((VALUE) == OB_ST_RAM_SIZE_16KB))
1046 
1047 #define IS_OB_USER_SECURITY(VALUE)       (((VALUE) == OB_SECURITY_ENABLE) || ((VALUE) == OB_SECURITY_DISABLE))
1048 
1049 #if defined (DUAL_CORE)
1050 #define IS_OB_USER_BCM4(VALUE)           (((VALUE) == OB_BCM4_DISABLE) || ((VALUE) == OB_BCM4_ENABLE))
1051 
1052 #define IS_OB_USER_BCM7(VALUE)           (((VALUE) == OB_BCM7_DISABLE) || ((VALUE) == OB_BCM7_ENABLE))
1053 #endif /* DUAL_CORE */
1054 
1055 #if defined (FLASH_OPTSR_NRST_STOP_D2)
1056 #define IS_OB_STOP_D2_RESET(VALUE)       (((VALUE) == OB_STOP_NO_RST_D2) || ((VALUE) == OB_STOP_RST_D2))
1057 
1058 #define IS_OB_STDBY_D2_RESET(VALUE)      (((VALUE) == OB_STDBY_NO_RST_D2) || ((VALUE) == OB_STDBY_RST_D2))
1059 #endif /* FLASH_OPTSR_NRST_STOP_D2 */
1060 
1061 #if defined (FLASH_OPTSR2_TCM_AXI_SHARED)
1062 #define IS_OB_USER_TCM_AXI_SHARED(VALUE) (((VALUE) == OB_TCM_AXI_SHARED_ITCM64KB) || ((VALUE) == OB_TCM_AXI_SHARED_ITCM128KB) || \
1063                                           ((VALUE) == OB_TCM_AXI_SHARED_ITCM192KB) || ((VALUE) == OB_TCM_AXI_SHARED_ITCM256KB))
1064 #endif /* FLASH_OPTSR2_TCM_AXI_SHARED */
1065 
1066 #if defined (FLASH_OPTSR2_CPUFREQ_BOOST)
1067 #define IS_OB_USER_CPUFREQ_BOOST(VALUE)  (((VALUE) == OB_CPUFREQ_BOOST_DISABLE) || ((VALUE) == OB_CPUFREQ_BOOST_ENABLE))
1068 #endif /* FLASH_OPTSR2_CPUFREQ_BOOST */
1069 
1070 #define IS_OB_USER_TYPE(TYPE)            ((((TYPE) & OB_USER_ALL) != 0U) && \
1071                                           (((TYPE) & ~OB_USER_ALL) == 0U))
1072 
1073 #define IS_OB_BOOT_ADD_OPTION(VALUE)     (((VALUE) == OB_BOOT_ADD0)  || \
1074                                           ((VALUE) == OB_BOOT_ADD1)  || \
1075                                           ((VALUE) == OB_BOOT_ADD_BOTH))
1076 
1077 #define IS_FLASH_TYPECRC(VALUE)          (((VALUE) == FLASH_CRC_ADDR)    || \
1078                                           ((VALUE) == FLASH_CRC_SECTORS) || \
1079                                           ((VALUE) == FLASH_CRC_BANK))
1080 
1081 #if defined (FLASH_OTPBL_LOCKBL)
1082 #define IS_OTP_BLOCK(VALUE)              ((((VALUE) & 0xFFFF0000U) == 0x00000000U) && ((VALUE) != 0x00000000U))
1083 #endif /* FLASH_OTPBL_LOCKBL */
1084 /**
1085   * @}
1086   */
1087 
1088 /**
1089   * @}
1090   */
1091 
1092 /* Private functions ---------------------------------------------------------*/
1093 /** @defgroup FLASHEx_Private_Functions FLASHEx Private Functions
1094   * @ingroup RTEMSBSPsARMSTM32H7
1095   * @{
1096   */
1097 void FLASH_Erase_Sector(uint32_t Sector, uint32_t Banks, uint32_t VoltageRange);
1098 /**
1099   * @}
1100   */
1101 
1102 /**
1103   * @}
1104   */
1105 
1106 /**
1107   * @}
1108   */
1109 
1110 #ifdef __cplusplus
1111 }
1112 #endif
1113 
1114 #endif /* STM32H7xx_HAL_FLASH_EX_H */
1115