1 /** 2 ****************************************************************************** 3 * @file stm32l5xx_hal_flash_ex.h 4 * @author MCD Application Team 5 * @brief Header file of FLASH HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2019 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file in 13 * the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 ****************************************************************************** 16 */ 17 18 /* Define to prevent recursive inclusion -------------------------------------*/ 19 #ifndef STM32L5xx_HAL_FLASH_EX_H 20 #define STM32L5xx_HAL_FLASH_EX_H 21 22 #ifdef __cplusplus 23 extern "C" { 24 #endif 25 26 /* Includes ------------------------------------------------------------------*/ 27 #include "stm32l5xx_hal_def.h" 28 29 /** @addtogroup STM32L5xx_HAL_Driver 30 * @{ 31 */ 32 33 /** @addtogroup FLASHEx 34 * @{ 35 */ 36 37 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 38 /* Private constants ---------------------------------------------------------*/ 39 /** @defgroup FLASHEx_Private_Constants FLASH Extended Private Constants 40 * @{ 41 */ 42 #define FLASH_BLOCKBASED_NB_REG (4U) /*!< Number of block-based registers available */ 43 /** 44 * @} 45 */ 46 47 /* Exported types ------------------------------------------------------------*/ 48 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types 49 * @{ 50 */ 51 52 /** 53 * @brief FLASH Block-based security structure definition 54 */ 55 typedef struct 56 { 57 uint32_t Bank; /*!< Configuration of the associated bank of Block-based Secure Area. 58 This parameter must be a value of @ref FLASH_Banks */ 59 uint32_t BBAttributesType; /*!< Block-Based Attributes type. 60 This parameter must be a value of @ref FLASHEx_BB_Attributes */ 61 uint32_t BBAttributes_array[FLASH_BLOCKBASED_NB_REG]; /*!< Each bit specifies the block-based attribute configuration of a page. 62 0 means non-secure, 1 means secure */ 63 } FLASH_BBAttributesTypeDef; 64 /** 65 * @} 66 */ 67 #endif 68 69 /* Exported constants --------------------------------------------------------*/ 70 /** @defgroup FLASHEx_Exported_Constants FLASH Extended Exported Constants 71 * @{ 72 */ 73 74 /** @defgroup FLASHEx_PRIV_MODE_CFG FLASH privilege mode configuration 75 * @{ 76 */ 77 #define FLASH_PRIV_GRANTED 0x00000000U /*!< access to Flash registers is granted */ 78 #define FLASH_PRIV_DENIED FLASH_PRIVCFGR_PRIV /*!< access to Flash registers is denied to non-privilege access */ 79 /** 80 * @} 81 */ 82 83 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 84 /** @defgroup FLASHEx_SEC_INVERSION_CFG FLASH security inversion configuration 85 * @{ 86 */ 87 #define FLASH_INV_DISABLE 0x00000000U /*!< Security state of Flash is not inverted */ 88 #define FLASH_INV_ENABLE FLASH_SECCR_SECINV /*!< Security state of Flash is inverted */ 89 /** 90 * @} 91 */ 92 #endif 93 94 /** @defgroup FLASHEx_LVE_PIN_CFG FLASH LVE pin configuration 95 * @{ 96 */ 97 #define FLASH_LVE_PIN_CTRL 0x00000000U /*!< LVEA/B FLASH pin controlled by power controller */ 98 #define FLASH_LVE_PIN_FORCED FLASH_ACR_LVEN /*!< LVEA/B FLASH pin enforced to low */ 99 /** 100 * @} 101 */ 102 103 /** @defgroup FLASHEx_BB_Attributes FLASH Block-Based Attributes 104 * @{ 105 */ 106 #define FLASH_BB_SEC 0x00000001U /*!< Flash Block-Based Security Attributes */ 107 /** 108 * @} 109 */ 110 111 /** 112 * @} 113 */ 114 115 /* Exported macro ------------------------------------------------------------*/ 116 117 /* Exported functions --------------------------------------------------------*/ 118 /** @addtogroup FLASHEx_Exported_Functions 119 * @{ 120 */ 121 122 /* Extended Program operation functions *************************************/ 123 /** @addtogroup FLASHEx_Exported_Functions_Group1 124 * @{ 125 */ 126 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 127 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 128 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 129 void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 130 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 131 HAL_StatusTypeDef HAL_FLASHEx_ConfigBBAttributes(FLASH_BBAttributesTypeDef *pBBAttributes); 132 void HAL_FLASHEx_GetConfigBBAttributes(FLASH_BBAttributesTypeDef *pBBAttributes); 133 void HAL_FLASHEx_EnableSecHideProtection(uint32_t Banks); 134 #endif 135 /** 136 * @} 137 */ 138 139 /* Extended Peripheral Control functions ************************************/ 140 /** @addtogroup FLASHEx_Exported_Functions_Group2 141 * @{ 142 */ 143 void HAL_FLASHEx_ConfigPrivMode(uint32_t PrivMode); 144 uint32_t HAL_FLASHEx_GetPrivMode(void); 145 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 146 HAL_StatusTypeDef HAL_FLASHEx_ConfigSecInversion(uint32_t SecInvState); 147 uint32_t HAL_FLASHEx_GetSecInversion(void); 148 #endif 149 HAL_StatusTypeDef HAL_FLASHEx_ConfigLVEPin(uint32_t ConfigLVE); 150 uint32_t HAL_FLASHEx_GetLVEPin(void); 151 /** 152 * @} 153 */ 154 155 /** 156 * @} 157 */ 158 159 /* Private function ----------------------------------------------------------*/ 160 /** @addtogroup FLASHEx_Private_Functions FLASHEx Private Functions 161 * @{ 162 */ 163 void FLASH_PageErase(uint32_t Page, uint32_t Banks); 164 /** 165 * @} 166 */ 167 168 /* Private macros ------------------------------------------------------------*/ 169 /** @defgroup FLASHEx_Private_Macros FLASH Extended Private Macros 170 * @{ 171 */ 172 #define IS_FLASH_CFGPRIVMODE(CFG) (((CFG) == FLASH_PRIV_GRANTED) || \ 173 ((CFG) == FLASH_PRIV_DENIED)) 174 175 #if defined (__ARM_FEATURE_CMSE) && (__ARM_FEATURE_CMSE == 3U) 176 #define IS_FLASH_CFGSECINV(CFG) (((CFG) == FLASH_INV_DISABLE) || \ 177 ((CFG) == FLASH_INV_ENABLE)) 178 #endif 179 180 #define IS_FLASH_CFGLVEPIN(CFG) (((CFG) == FLASH_LVE_PIN_CTRL) || \ 181 ((CFG) == FLASH_LVE_PIN_FORCED)) 182 183 /** 184 * @} 185 */ 186 187 /** 188 * @} 189 */ 190 191 /** 192 * @} 193 */ 194 195 #ifdef __cplusplus 196 } 197 #endif 198 199 #endif /* STM32L5xx_HAL_FLASH_EX_H */ 200 201