1 /** 2 ****************************************************************************** 3 * @file stm32l0xx_hal_flash_ex.h 4 * @author MCD Application Team 5 * @brief Header file of Flash HAL Extended module. 6 ****************************************************************************** 7 * @attention 8 * 9 * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> 10 * 11 * Redistribution and use in source and binary forms, with or without modification, 12 * are permitted provided that the following conditions are met: 13 * 1. Redistributions of source code must retain the above copyright notice, 14 * this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright notice, 16 * this list of conditions and the following disclaimer in the documentation 17 * and/or other materials provided with the distribution. 18 * 3. Neither the name of STMicroelectronics nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 * 33 ****************************************************************************** 34 */ 35 36 /* Define to prevent recursive inclusion -------------------------------------*/ 37 #ifndef __STM32L0xx_HAL_FLASH_EX_H 38 #define __STM32L0xx_HAL_FLASH_EX_H 39 40 #ifdef __cplusplus 41 extern "C" { 42 #endif 43 44 /* Includes ------------------------------------------------------------------*/ 45 #include "stm32l0xx_hal_def.h" 46 47 /** @addtogroup STM32L0xx_HAL_Driver 48 * @{ 49 */ 50 51 /** @addtogroup FLASHEx 52 * @{ 53 */ 54 55 /** @addtogroup FLASHEx_Private_Constants 56 * @{ 57 */ 58 #define FLASH_SIZE_DATA_REGISTER FLASHSIZE_BASE 59 60 #define FLASH_NBPAGES_MAX (FLASH_SIZE / FLASH_PAGE_SIZE) 61 62 #define WRP_MASK_LOW (0x0000FFFFU) 63 #define WRP_MASK_HIGH (0xFFFF0000U) 64 65 /** 66 * @} 67 */ 68 69 /** @addtogroup FLASHEx_Private_Macros 70 * @{ 71 */ 72 73 #define IS_FLASH_TYPEERASE(__VALUE__) (((__VALUE__) == FLASH_TYPEERASE_PAGES)) 74 75 #define IS_OPTIONBYTE(__VALUE__) (((__VALUE__) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | \ 76 OPTIONBYTE_USER | OPTIONBYTE_BOR | OPTIONBYTE_BOOT_BIT1))) 77 78 #define IS_WRPSTATE(__VALUE__) (((__VALUE__) == OB_WRPSTATE_DISABLE) || \ 79 ((__VALUE__) == OB_WRPSTATE_ENABLE)) 80 81 #define IS_OB_WRP(__PAGE__) (((__PAGE__) != 0x0000000U)) 82 83 #define IS_OB_RDP(__LEVEL__) (((__LEVEL__) == OB_RDP_LEVEL_0) ||\ 84 ((__LEVEL__) == OB_RDP_LEVEL_1) ||\ 85 ((__LEVEL__) == OB_RDP_LEVEL_2)) 86 87 #define IS_OB_BOR_LEVEL(__LEVEL__) (((__LEVEL__) == OB_BOR_OFF) || \ 88 ((__LEVEL__) == OB_BOR_LEVEL1) || \ 89 ((__LEVEL__) == OB_BOR_LEVEL2) || \ 90 ((__LEVEL__) == OB_BOR_LEVEL3) || \ 91 ((__LEVEL__) == OB_BOR_LEVEL4) || \ 92 ((__LEVEL__) == OB_BOR_LEVEL5)) 93 94 #define IS_OB_IWDG_SOURCE(__SOURCE__) (((__SOURCE__) == OB_IWDG_SW) || ((__SOURCE__) == OB_IWDG_HW)) 95 96 #define IS_OB_STOP_SOURCE(__SOURCE__) (((__SOURCE__) == OB_STOP_NORST) || ((__SOURCE__) == OB_STOP_RST)) 97 98 #define IS_OB_STDBY_SOURCE(__SOURCE__) (((__SOURCE__) == OB_STDBY_NORST) || ((__SOURCE__) == OB_STDBY_RST)) 99 100 #if defined(FLASH_OPTR_WPRMOD) && defined(FLASH_OPTR_BFB2) 101 102 #define IS_OBEX(__VALUE__) (((__VALUE__) == OPTIONBYTE_PCROP) || ((__VALUE__) == OPTIONBYTE_BOOTCONFIG)) 103 104 #elif defined(FLASH_OPTR_WPRMOD) && !defined(FLASH_OPTR_BFB2) 105 106 #define IS_OBEX(__VALUE__) ((__VALUE__) == OPTIONBYTE_PCROP) 107 108 #elif !defined(FLASH_OPTR_WPRMOD) && defined(FLASH_OPTR_BFB2) 109 110 #define IS_OBEX(__VALUE__) ((__VALUE__) == OPTIONBYTE_BOOTCONFIG) 111 112 #endif /* FLASH_OPTR_WPRMOD && FLASH_OPTR_BFB2 */ 113 114 #if defined(FLASH_OPTR_WPRMOD) 115 116 #define IS_PCROPSTATE(__VALUE__) (((__VALUE__) == OB_PCROP_STATE_DISABLE) || \ 117 ((__VALUE__) == OB_PCROP_STATE_ENABLE)) 118 119 #define IS_OB_PCROP(__PAGE__) (((__PAGE__) != 0x0000000U)) 120 #endif /* FLASH_OPTR_WPRMOD */ 121 122 #if defined(FLASH_OPTR_BFB2) 123 124 #define IS_OB_BOOT_BANK(__BANK__) (((__BANK__) == OB_BOOT_BANK2) || ((__BANK__) == OB_BOOT_BANK1)) 125 126 #endif /* FLASH_OPTR_BFB2 */ 127 128 #define IS_OB_BOOT1(__BOOT_BIT1__) (((__BOOT_BIT1__) == OB_BOOT_BIT1_RESET) || ((__BOOT_BIT1__) == OB_BOOT_BIT1_SET)) 129 #define IS_TYPEPROGRAMDATA(__VALUE__) (((__VALUE__) == FLASH_TYPEPROGRAMDATA_BYTE) || \ 130 ((__VALUE__) == FLASH_TYPEPROGRAMDATA_HALFWORD) || \ 131 ((__VALUE__) == FLASH_TYPEPROGRAMDATA_WORD)) 132 133 134 /** @defgroup FLASHEx_Address FLASHEx Address 135 * @{ 136 */ 137 138 #if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 139 140 #define IS_FLASH_DATA_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK2_END)) 141 #define IS_FLASH_DATA_BANK1_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK1_END)) 142 #define IS_FLASH_DATA_BANK2_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BANK2_BASE) && ((__ADDRESS__) <= DATA_EEPROM_BANK2_END)) 143 #define IS_FLASH_PROGRAM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE))) 144 #define IS_FLASH_PROGRAM_BANK1_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + (FLASH_SIZE >> 1)))) 145 #define IS_FLASH_PROGRAM_BANK2_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BANK2_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE))) 146 #else 147 #define IS_FLASH_DATA_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= DATA_EEPROM_BASE) && ((__ADDRESS__) <= DATA_EEPROM_END)) 148 #define IS_FLASH_PROGRAM_ADDRESS(__ADDRESS__) (((__ADDRESS__) >= FLASH_BASE) && ((__ADDRESS__) < (FLASH_BASE + FLASH_SIZE))) 149 #endif 150 151 #define IS_NBPAGES(__PAGES__) (((__PAGES__) >= 1) && ((__PAGES__) <= FLASH_NBPAGES_MAX)) 152 153 /** 154 * @} 155 */ 156 157 /** 158 * @} 159 */ 160 /* Exported types ------------------------------------------------------------*/ 161 162 /** @defgroup FLASHEx_Exported_Types FLASHEx Exported Types 163 * @{ 164 */ 165 166 /** 167 * @brief FLASH Erase structure definition 168 */ 169 typedef struct 170 { 171 uint32_t TypeErase; /*!< TypeErase: Page Erase only. 172 This parameter can be a value of @ref FLASHEx_Type_Erase */ 173 174 uint32_t PageAddress; /*!< PageAddress: Initial FLASH address to be erased 175 This parameter must be a value belonging to FLASH Programm address (depending on the devices) */ 176 177 uint32_t NbPages; /*!< NbPages: Number of pages to be erased. 178 This parameter must be a value between 1 and (max number of pages - value of Initial page)*/ 179 180 } FLASH_EraseInitTypeDef; 181 182 /** 183 * @brief FLASH Option Bytes PROGRAM structure definition 184 */ 185 typedef struct 186 { 187 uint32_t OptionType; /*!< OptionType: Option byte to be configured. 188 This parameter can be a value of @ref FLASHEx_Option_Type */ 189 190 uint32_t WRPState; /*!< WRPState: Write protection activation or deactivation. 191 This parameter can be a value of @ref FLASHEx_WRP_State */ 192 193 uint32_t WRPSector; /*!< WRPSector: This bitfield specifies the sector (s) which are write protected. 194 This parameter can be a combination of @ref FLASHEx_Option_Bytes_Write_Protection */ 195 196 #if defined(STM32L071xx) || defined(STM32L072xx) || defined(STM32L073xx) || defined(STM32L081xx) || defined(STM32L082xx) || defined(STM32L083xx) 197 uint32_t WRPSector2; /*!< WRPSector2 : This bitfield specifies the sector(s) upper Sector31 which are write protected. 198 This parameter can be a combination of @ref FLASHEx_Option_Bytes_Write_Protection2 */ 199 #endif 200 201 uint8_t RDPLevel; /*!< RDPLevel: Set the read protection level. 202 This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */ 203 204 uint8_t BORLevel; /*!< BORLevel: Set the BOR Level. 205 This parameter can be a value of @ref FLASHEx_Option_Bytes_BOR_Level */ 206 207 uint8_t USERConfig; /*!< USERConfig: Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. 208 This parameter can be a combination of @ref FLASHEx_Option_Bytes_IWatchdog, 209 @ref FLASHEx_Option_Bytes_nRST_STOP and @ref FLASHEx_Option_Bytes_nRST_STDBY*/ 210 211 uint8_t BOOTBit1Config; /*!< BOOT1Config: Together with input pad Boot0, this bit selects the boot source, flash, ram or system memory 212 This parameter can be a value of @ref FLASHEx_Option_Bytes_BOOTBit1 */ 213 } FLASH_OBProgramInitTypeDef; 214 215 #if defined(FLASH_OPTR_WPRMOD) || defined(FLASH_OPTR_BFB2) 216 /** 217 * @brief FLASH Advanced Option Bytes Program structure definition 218 */ 219 typedef struct 220 { 221 uint32_t OptionType; /*!< OptionType: Option byte to be configured for extension . 222 This parameter can be a value of @ref FLASHEx_OptionAdv_Type */ 223 224 #if defined(FLASH_OPTR_WPRMOD) 225 uint32_t PCROPState; /*!< PCROPState: PCROP activation or deactivation. 226 This parameter can be a value of @ref FLASHEx_PCROP_State */ 227 228 uint32_t PCROPSector; /*!< PCROPSector : This bitfield specifies the sector(s) which are read/write protected. 229 This parameter can be a combination of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */ 230 231 #if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 232 uint32_t PCROPSector2; /*!< PCROPSector : This bitfield specifies the sector(s) upper Sector31 which are read/write protected. 233 This parameter can be a combination of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection2 */ 234 #endif /* STM32L071xx || STM32L072xx || STM32L073xx || STM32L081xx || STM32L082xx || STM32L083xx */ 235 #endif /* FLASH_OPTR_WPRMOD */ 236 237 #if defined(FLASH_OPTR_BFB2) 238 uint16_t BootConfig; /*!< BootConfig: specifies Option bytes for boot config 239 This parameter can be a value of @ref FLASHEx_Option_Bytes_BOOT */ 240 #endif /* FLASH_OPTR_BFB2*/ 241 } FLASH_AdvOBProgramInitTypeDef; 242 243 /** 244 * @} 245 */ 246 #endif /* FLASH_OPTR_WPRMOD || FLASH_OPTR_BFB2 */ 247 248 /* Exported constants --------------------------------------------------------*/ 249 250 251 /** @defgroup FLASHEx_Exported_Constants FLASHEx Exported Constants 252 * @{ 253 */ 254 255 /** @defgroup FLASHEx_Type_Erase FLASHEx_Type_Erase 256 * @{ 257 */ 258 #define FLASH_TYPEERASE_PAGES ((uint32_t)0x00U) /*!<Page erase only*/ 259 260 /** 261 * @} 262 */ 263 264 /** @defgroup FLASHEx_Option_Type FLASHEx Option Type 265 * @{ 266 */ 267 #define OPTIONBYTE_WRP ((uint32_t)0x01U) /*!<WRP option byte configuration*/ 268 #define OPTIONBYTE_RDP ((uint32_t)0x02U) /*!<RDP option byte configuration*/ 269 #define OPTIONBYTE_USER ((uint32_t)0x04U) /*!<USER option byte configuration*/ 270 #define OPTIONBYTE_BOR ((uint32_t)0x08U) /*!<BOR option byte configuration*/ 271 #define OPTIONBYTE_BOOT_BIT1 ((uint32_t)0x10U) /*!< BOOT PIN1 option byte configuration*/ 272 273 /** 274 * @} 275 */ 276 277 /** @defgroup FLASHEx_WRP_State FLASHEx WRP State 278 * @{ 279 */ 280 #define OB_WRPSTATE_DISABLE ((uint32_t)0x00U) /*!<Disable the write protection of the desired sectors*/ 281 #define OB_WRPSTATE_ENABLE ((uint32_t)0x01U) /*!<Enable the write protection of the desired sectors*/ 282 283 /** 284 * @} 285 */ 286 287 #if defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L031xx) || defined (STM32L041xx) 288 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection 289 * @{ 290 */ 291 #define OB_WRP_Pages0to31 ((uint32_t)0x00000001U) /* Write protection of Sector0 */ 292 #define OB_WRP_Pages32to63 ((uint32_t)0x00000002U) /* Write protection of Sector1 */ 293 #define OB_WRP_Pages64to95 ((uint32_t)0x00000004U) /* Write protection of Sector2 */ 294 #define OB_WRP_Pages96to127 ((uint32_t)0x00000008U) /* Write protection of Sector3 */ 295 #define OB_WRP_Pages128to159 ((uint32_t)0x00000010U) /* Write protection of Sector4 */ 296 #define OB_WRP_Pages160to191 ((uint32_t)0x00000020U) /* Write protection of Sector5 */ 297 #define OB_WRP_Pages192to223 ((uint32_t)0x00000040U) /* Write protection of Sector6 */ 298 #define OB_WRP_Pages224to255 ((uint32_t)0x00000080U) /* Write protection of Sector7 */ 299 #define OB_WRP_AllPages ((uint32_t)0x000000FFU) /*!< Write protection of all Sectors */ 300 /** 301 * @} 302 */ 303 #elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || defined (STM32L061xx) || defined (STM32L062xx) || defined (STM32L063xx) 304 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection 305 * @{ 306 */ 307 #define OB_WRP_Pages0to31 ((uint32_t)0x00000001U) /* Write protection of Sector0 */ 308 #define OB_WRP_Pages32to63 ((uint32_t)0x00000002U) /* Write protection of Sector1 */ 309 #define OB_WRP_Pages64to95 ((uint32_t)0x00000004U) /* Write protection of Sector2 */ 310 #define OB_WRP_Pages96to127 ((uint32_t)0x00000008U) /* Write protection of Sector3 */ 311 #define OB_WRP_Pages128to159 ((uint32_t)0x00000010U) /* Write protection of Sector4 */ 312 #define OB_WRP_Pages160to191 ((uint32_t)0x00000020U) /* Write protection of Sector5 */ 313 #define OB_WRP_Pages192to223 ((uint32_t)0x00000040U) /* Write protection of Sector6 */ 314 #define OB_WRP_Pages224to255 ((uint32_t)0x00000080U) /* Write protection of Sector7 */ 315 #define OB_WRP_Pages256to287 ((uint32_t)0x00000100U) /* Write protection of Sector8 */ 316 #define OB_WRP_Pages288to319 ((uint32_t)0x00000200U) /* Write protection of Sector9 */ 317 #define OB_WRP_Pages320to351 ((uint32_t)0x00000400U) /* Write protection of Sector10 */ 318 #define OB_WRP_Pages352to383 ((uint32_t)0x00000800U) /* Write protection of Sector11 */ 319 #define OB_WRP_Pages384to415 ((uint32_t)0x00001000U) /* Write protection of Sector12 */ 320 #define OB_WRP_Pages416to447 ((uint32_t)0x00002000U) /* Write protection of Sector13 */ 321 #define OB_WRP_Pages448to479 ((uint32_t)0x00004000U) /* Write protection of Sector14 */ 322 #define OB_WRP_Pages480to511 ((uint32_t)0x00008000U) /* Write protection of Sector15 */ 323 #define OB_WRP_AllPages ((uint32_t)0x0000FFFFU) /*!< Write protection of all Sectors */ 324 /** 325 * @} 326 */ 327 328 #elif defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 329 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write ProtectionP 330 * @{ 331 */ 332 #define OB_WRP_Pages0to31 ((uint32_t)0x00000001U) /* Write protection of Sector0 */ 333 #define OB_WRP_Pages32to63 ((uint32_t)0x00000002U) /* Write protection of Sector1 */ 334 #define OB_WRP_Pages64to95 ((uint32_t)0x00000004U) /* Write protection of Sector2 */ 335 #define OB_WRP_Pages96to127 ((uint32_t)0x00000008U) /* Write protection of Sector3 */ 336 #define OB_WRP_Pages128to159 ((uint32_t)0x00000010U) /* Write protection of Sector4 */ 337 #define OB_WRP_Pages160to191 ((uint32_t)0x00000020U) /* Write protection of Sector5 */ 338 #define OB_WRP_Pages192to223 ((uint32_t)0x00000040U) /* Write protection of Sector6 */ 339 #define OB_WRP_Pages224to255 ((uint32_t)0x00000080U) /* Write protection of Sector7 */ 340 #define OB_WRP_Pages256to287 ((uint32_t)0x00000100U) /* Write protection of Sector8 */ 341 #define OB_WRP_Pages288to319 ((uint32_t)0x00000200U) /* Write protection of Sector9 */ 342 #define OB_WRP_Pages320to351 ((uint32_t)0x00000400U) /* Write protection of Sector10 */ 343 #define OB_WRP_Pages352to383 ((uint32_t)0x00000800U) /* Write protection of Sector11 */ 344 #define OB_WRP_Pages384to415 ((uint32_t)0x00001000U) /* Write protection of Sector12 */ 345 #define OB_WRP_Pages416to447 ((uint32_t)0x00002000U) /* Write protection of Sector13 */ 346 #define OB_WRP_Pages448to479 ((uint32_t)0x00004000U) /* Write protection of Sector14 */ 347 #define OB_WRP_Pages480to511 ((uint32_t)0x00008000U) /* Write protection of Sector15 */ 348 #define OB_WRP_Pages512to543 ((uint32_t)0x00010000U) /* Write protection of Sector16 */ 349 #define OB_WRP_Pages544to575 ((uint32_t)0x00020000U) /* Write protection of Sector17 */ 350 #define OB_WRP_Pages576to607 ((uint32_t)0x00040000U) /* Write protection of Sector18 */ 351 #define OB_WRP_Pages608to639 ((uint32_t)0x00080000U) /* Write protection of Sector19 */ 352 #define OB_WRP_Pages640to671 ((uint32_t)0x00100000U) /* Write protection of Sector20 */ 353 #define OB_WRP_Pages672to703 ((uint32_t)0x00200000U) /* Write protection of Sector21 */ 354 #define OB_WRP_Pages704to735 ((uint32_t)0x00400000U) /* Write protection of Sector22 */ 355 #define OB_WRP_Pages736to767 ((uint32_t)0x00800000U) /* Write protection of Sector23 */ 356 #define OB_WRP_Pages768to799 ((uint32_t)0x01000000U) /* Write protection of Sector24 */ 357 #define OB_WRP_Pages800to831 ((uint32_t)0x02000000U) /* Write protection of Sector25 */ 358 #define OB_WRP_Pages832to863 ((uint32_t)0x04000000U) /* Write protection of Sector26 */ 359 #define OB_WRP_Pages864to895 ((uint32_t)0x08000000U) /* Write protection of Sector27 */ 360 #define OB_WRP_Pages896to927 ((uint32_t)0x10000000U) /* Write protection of Sector28 */ 361 #define OB_WRP_Pages928to959 ((uint32_t)0x20000000U) /* Write protection of Sector29 */ 362 #define OB_WRP_Pages960to991 ((uint32_t)0x40000000U) /* Write protection of Sector30 */ 363 #define OB_WRP_Pages992to1023 ((uint32_t)0x80000000U) /* Write protection of Sector31 */ 364 #define OB_WRP_AllPages ((uint32_t)0xFFFFFFFFU) /*!<Write protection of all Sectors */ 365 /** 366 * @} 367 */ 368 369 /** @defgroup FLASHEx_Option_Bytes_Write_Protection2 FLASH Option Bytes Write Protection 370 * @{ 371 */ 372 #define OB_WRP2_Pages1024to1055 ((uint32_t)0x00000001U) /* Write protection of Sector32 */ 373 #define OB_WRP2_Pages1056to1087 ((uint32_t)0x00000002U) /* Write protection of Sector33 */ 374 #define OB_WRP2_Pages1088to1119 ((uint32_t)0x00000004U) /* Write protection of Sector34 */ 375 #define OB_WRP2_Pages1120to1151 ((uint32_t)0x00000008U) /* Write protection of Sector35 */ 376 #define OB_WRP2_Pages1152to1183 ((uint32_t)0x00000010U) /* Write protection of Sector36 */ 377 #define OB_WRP2_Pages1184to1215 ((uint32_t)0x00000020U) /* Write protection of Sector37 */ 378 #define OB_WRP2_Pages1216to1247 ((uint32_t)0x00000040U) /* Write protection of Sector38 */ 379 #define OB_WRP2_Pages1248to1279 ((uint32_t)0x00000080U) /* Write protection of Sector39 */ 380 #define OB_WRP2_Pages1280to1311 ((uint32_t)0x00000100U) /* Write protection of Sector40 */ 381 #define OB_WRP2_Pages1312to1343 ((uint32_t)0x00000200U) /* Write protection of Sector41 */ 382 #define OB_WRP2_Pages1344to1375 ((uint32_t)0x00000400U) /* Write protection of Sector42 */ 383 #define OB_WRP2_Pages1376to1407 ((uint32_t)0x00000800U) /* Write protection of Sector43 */ 384 #define OB_WRP2_Pages1408to1439 ((uint32_t)0x00001000U) /* Write protection of Sector44 */ 385 #define OB_WRP2_Pages1440to1471 ((uint32_t)0x00002000U) /* Write protection of Sector45 */ 386 #define OB_WRP2_Pages1472to1503 ((uint32_t)0x00004000U) /* Write protection of Sector46 */ 387 #define OB_WRP2_Pages1504to1535 ((uint32_t)0x00008000U) /* Write protection of Sector47 */ 388 #define OB_WRP2_AllPages ((uint32_t)0x0000FFFFU) /*!< Write protection of all Sectors WRP2 */ 389 /** 390 * @} 391 */ 392 #endif /* STM32L071xx || STM32L072xx || (STM32L073xx) || (STM32L081xx) || (STM32L082xx) || (STM32L083xx) */ 393 394 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASHEx Option Bytes Read Protection 395 * @{ 396 */ 397 #define OB_RDP_LEVEL_0 ((uint8_t)0xAAU) 398 #define OB_RDP_LEVEL_1 ((uint8_t)0xBBU) 399 #define OB_RDP_LEVEL_2 ((uint8_t)0xCCU) /* Warning: When enabling read protection level 2 400 it is no more possible to go back to level 1 or 0 */ 401 402 /** 403 * @} 404 */ 405 406 /** @defgroup FLASHEx_Option_Bytes_BOR_Level FLASHEx Option Bytes BOR Level 407 * @{ 408 */ 409 410 #define OB_BOR_OFF ((uint8_t)0x00U) /*!< BOR is disabled at power down, the reset is asserted when the VDD 411 power supply reaches the PDR(Power Down Reset) threshold (1.5V) */ 412 #define OB_BOR_LEVEL1 ((uint8_t)0x08U) /*!< BOR Reset threshold levels for 1.7V - 1.8V VDD power supply */ 413 #define OB_BOR_LEVEL2 ((uint8_t)0x09U) /*!< BOR Reset threshold levels for 1.9V - 2.0V VDD power supply */ 414 #define OB_BOR_LEVEL3 ((uint8_t)0x0AU) /*!< BOR Reset threshold levels for 2.3V - 2.4V VDD power supply */ 415 #define OB_BOR_LEVEL4 ((uint8_t)0x0BU) /*!< BOR Reset threshold levels for 2.55V - 2.65V VDD power supply */ 416 #define OB_BOR_LEVEL5 ((uint8_t)0x0CU) /*!< BOR Reset threshold levels for 2.8V - 2.9V VDD power supply */ 417 418 /** 419 * @} 420 */ 421 422 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASHEx Option Bytes IWatchdog 423 * @{ 424 */ 425 426 #define OB_IWDG_SW ((uint8_t)0x10U) /*!< Software WDG selected */ 427 #define OB_IWDG_HW ((uint8_t)0x00U) /*!< Hardware WDG selected */ 428 429 /** 430 * @} 431 */ 432 433 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASHEx Option Bytes nRST_STOP 434 * @{ 435 */ 436 437 #define OB_STOP_NORST ((uint8_t)0x20U) /*!< No reset generated when entering in STOP */ 438 #define OB_STOP_RST ((uint8_t)0x00U) /*!< Reset generated when entering in STOP */ 439 /** 440 * @} 441 */ 442 443 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASHEx Option Bytes nRST_STDBY 444 * @{ 445 */ 446 447 #define OB_STDBY_NORST ((uint8_t)0x40U) /*!< No reset generated when entering in STANDBY */ 448 #define OB_STDBY_RST ((uint8_t)0x00U) /*!< Reset generated when entering in STANDBY */ 449 450 /** 451 * @} 452 */ 453 454 #if defined(FLASH_OPTR_WPRMOD) 455 456 /** @defgroup FLASHEx_OptionAdv_Type FLASHEx Option Advanced Type 457 * @{ 458 */ 459 460 #define OPTIONBYTE_PCROP ((uint32_t)0x01U) /*!<PCROP option byte configuration*/ 461 462 /** 463 * @} 464 */ 465 466 #endif /* FLASH_OPTR_WPRMOD */ 467 468 #if defined(FLASH_OPTR_BFB2) 469 470 /** @defgroup FLASHEx_OptionAdv_Type FLASHEx Option Advanced Type 471 * @{ 472 */ 473 474 #define OPTIONBYTE_BOOTCONFIG ((uint32_t)0x02U) /*!<BOOTConfig option byte configuration*/ 475 476 /** 477 * @} 478 */ 479 480 #endif /* FLASH_OPTR_BFB2 */ 481 482 #if defined(FLASH_OPTR_WPRMOD) 483 484 /** @defgroup FLASHEx_PCROP_State FLASHEx PCROP State 485 * @{ 486 */ 487 #define OB_PCROP_STATE_DISABLE ((uint32_t)0x00U) /*!<Disable PCROP for selected sectors */ 488 #define OB_PCROP_STATE_ENABLE ((uint32_t)0x01U) /*!<Enable PCROP for selected sectors */ 489 490 /** 491 * @} 492 */ 493 494 /** @defgroup FLASHEx_Selection_Protection_Mode FLASHEx Selection Protection Mode 495 * @{ 496 */ 497 #define OB_PCROP_DESELECTED ((uint16_t)0x0000U) /*!< Disabled PCROP, nWPRi bits used for Write Protection on sector i */ 498 #define OB_PCROP_SELECTED ((uint16_t)FLASH_OPTR_WPRMOD) /*!< Enable PCROP, nWPRi bits used for PCRoP Protection on sector i */ 499 500 /** 501 * @} 502 */ 503 #endif /* FLASH_OPTR_WPRMOD */ 504 505 #if defined (STM32L011xx) || defined (STM32L021xx) || defined (STM32L031xx) || defined (STM32L041xx) 506 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASHEx Option Bytes PC Read/Write Protection 507 * @{ 508 */ 509 #define OB_PCROP_Pages0to31 ((uint32_t)0x00000001U) /* PC Read/Write protection of Sector0 */ 510 #define OB_PCROP_Pages32to63 ((uint32_t)0x00000002U) /* PC Read/Write protection of Sector1 */ 511 #define OB_PCROP_Pages64to95 ((uint32_t)0x00000004U) /* PC Read/Write protection of Sector2 */ 512 #define OB_PCROP_Pages96to127 ((uint32_t)0x00000008U) /* PC Read/Write protection of Sector3 */ 513 #define OB_PCROP_Pages128to159 ((uint32_t)0x00000010U) /* PC Read/Write protection of Sector4 */ 514 #define OB_PCROP_Pages160to191 ((uint32_t)0x00000020U) /* PC Read/Write protection of Sector5 */ 515 #define OB_PCROP_Pages192to223 ((uint32_t)0x00000040U) /* PC Read/Write protection of Sector6 */ 516 #define OB_PCROP_Pages224to255 ((uint32_t)0x00000080U) /* PC Read/Write protection of Sector7 */ 517 #define OB_PCROP_AllPages ((uint32_t)0x000000FFU) /*!< PC Read/Write protection of all Sectors */ 518 /** 519 * @} 520 */ 521 #elif defined (STM32L051xx) || defined (STM32L052xx) || defined (STM32L053xx) || defined (STM32L061xx) || defined (STM32L062xx) || defined (STM32L063xx) 522 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASHEx Option Bytes PC Read/Write Protection 523 * @{ 524 */ 525 #define OB_PCROP_Pages0to31 ((uint32_t)0x00000001U) /* PC Read/Write protection of Sector0 */ 526 #define OB_PCROP_Pages32to63 ((uint32_t)0x00000002U) /* PC Read/Write protection of Sector1 */ 527 #define OB_PCROP_Pages64to95 ((uint32_t)0x00000004U) /* PC Read/Write protection of Sector2 */ 528 #define OB_PCROP_Pages96to127 ((uint32_t)0x00000008U) /* PC Read/Write protection of Sector3 */ 529 #define OB_PCROP_Pages128to159 ((uint32_t)0x00000010U) /* PC Read/Write protection of Sector4 */ 530 #define OB_PCROP_Pages160to191 ((uint32_t)0x00000020U) /* PC Read/Write protection of Sector5 */ 531 #define OB_PCROP_Pages192to223 ((uint32_t)0x00000040U) /* PC Read/Write protection of Sector6 */ 532 #define OB_PCROP_Pages224to255 ((uint32_t)0x00000080U) /* PC Read/Write protection of Sector7 */ 533 #define OB_PCROP_Pages256to287 ((uint32_t)0x00000100U) /* PC Read/Write protection of Sector8 */ 534 #define OB_PCROP_Pages288to319 ((uint32_t)0x00000200U) /* PC Read/Write protection of Sector9 */ 535 #define OB_PCROP_Pages320to351 ((uint32_t)0x00000400U) /* PC Read/Write protection of Sector10 */ 536 #define OB_PCROP_Pages352to383 ((uint32_t)0x00000800U) /* PC Read/Write protection of Sector11 */ 537 #define OB_PCROP_Pages384to415 ((uint32_t)0x00001000U) /* PC Read/Write protection of Sector12 */ 538 #define OB_PCROP_Pages416to447 ((uint32_t)0x00002000U) /* PC Read/Write protection of Sector13 */ 539 #define OB_PCROP_Pages448to479 ((uint32_t)0x00004000U) /* PC Read/Write protection of Sector14 */ 540 #define OB_PCROP_Pages480to511 ((uint32_t)0x00008000U) /* PC Read/Write protection of Sector15 */ 541 #define OB_PCROP_AllPages ((uint32_t)0x0000FFFFU) /*!< PC Read/Write protection of all Sectors */ 542 /** 543 * @} 544 */ 545 #endif 546 547 #if defined (STM32L071xx) || defined (STM32L072xx) || defined (STM32L073xx) || defined (STM32L081xx) || defined (STM32L082xx) || defined (STM32L083xx) 548 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC Read/Write Protection 549 * @{ 550 */ 551 #define OB_PCROP_Pages0to31 ((uint32_t)0x00000001U) /* PC Read/Write protection of Sector0 */ 552 #define OB_PCROP_Pages32to63 ((uint32_t)0x00000002U) /* PC Read/Write protection of Sector1 */ 553 #define OB_PCROP_Pages64to95 ((uint32_t)0x00000004U) /* PC Read/Write protection of Sector2 */ 554 #define OB_PCROP_Pages96to127 ((uint32_t)0x00000008U) /* PC Read/Write protection of Sector3 */ 555 #define OB_PCROP_Pages128to159 ((uint32_t)0x00000010U) /* PC Read/Write protection of Sector4 */ 556 #define OB_PCROP_Pages160to191 ((uint32_t)0x00000020U) /* PC Read/Write protection of Sector5 */ 557 #define OB_PCROP_Pages192to223 ((uint32_t)0x00000040U) /* PC Read/Write protection of Sector6 */ 558 #define OB_PCROP_Pages224to255 ((uint32_t)0x00000080U) /* PC Read/Write protection of Sector7 */ 559 #define OB_PCROP_Pages256to287 ((uint32_t)0x00000100U) /* PC Read/Write protection of Sector8 */ 560 #define OB_PCROP_Pages288to319 ((uint32_t)0x00000200U) /* PC Read/Write protection of Sector9 */ 561 #define OB_PCROP_Pages320to351 ((uint32_t)0x00000400U) /* PC Read/Write protection of Sector10 */ 562 #define OB_PCROP_Pages352to383 ((uint32_t)0x00000800U) /* PC Read/Write protection of Sector11 */ 563 #define OB_PCROP_Pages384to415 ((uint32_t)0x00001000U) /* PC Read/Write protection of Sector12 */ 564 #define OB_PCROP_Pages416to447 ((uint32_t)0x00002000U) /* PC Read/Write protection of Sector13 */ 565 #define OB_PCROP_Pages448to479 ((uint32_t)0x00004000U) /* PC Read/Write protection of Sector14 */ 566 #define OB_PCROP_Pages480to511 ((uint32_t)0x00008000U) /* PC Read/Write protection of Sector15 */ 567 #define OB_PCROP_Pages512to543 ((uint32_t)0x00010000U) /* PC Read/Write protection of Sector16 */ 568 #define OB_PCROP_Pages544to575 ((uint32_t)0x00020000U) /* PC Read/Write protection of Sector17 */ 569 #define OB_PCROP_Pages576to607 ((uint32_t)0x00040000U) /* PC Read/Write protection of Sector18 */ 570 #define OB_PCROP_Pages608to639 ((uint32_t)0x00080000U) /* PC Read/Write protection of Sector19 */ 571 #define OB_PCROP_Pages640to671 ((uint32_t)0x00100000U) /* PC Read/Write protection of Sector20 */ 572 #define OB_PCROP_Pages672to703 ((uint32_t)0x00200000U) /* PC Read/Write protection of Sector21 */ 573 #define OB_PCROP_Pages704to735 ((uint32_t)0x00400000U) /* PC Read/Write protection of Sector22 */ 574 #define OB_PCROP_Pages736to767 ((uint32_t)0x00800000U) /* PC Read/Write protection of Sector23 */ 575 #define OB_PCROP_Pages768to799 ((uint32_t)0x01000000U) /* PC Read/Write protection of Sector24 */ 576 #define OB_PCROP_Pages800to831 ((uint32_t)0x02000000U) /* PC Read/Write protection of Sector25 */ 577 #define OB_PCROP_Pages832to863 ((uint32_t)0x04000000U) /* PC Read/Write protection of Sector26 */ 578 #define OB_PCROP_Pages864to895 ((uint32_t)0x08000000U) /* PC Read/Write protection of Sector27 */ 579 #define OB_PCROP_Pages896to927 ((uint32_t)0x10000000U) /* PC Read/Write protection of Sector28 */ 580 #define OB_PCROP_Pages928to959 ((uint32_t)0x20000000U) /* PC Read/Write protection of Sector29 */ 581 #define OB_PCROP_Pages960to991 ((uint32_t)0x40000000U) /* PC Read/Write protection of Sector30 */ 582 #define OB_PCROP_Pages992to1023 ((uint32_t)0x80000000U) /* PC Read/Write protection of Sector31 */ 583 #define OB_PCROP_AllPages ((uint32_t)0xFFFFFFFFU) /*!<PC Read/Write protection of all Sectors */ 584 /** 585 * @} 586 */ 587 588 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection2 FLASH Option Bytes PC Read/Write Protection (Sector 2) 589 * @{ 590 */ 591 #define OB_PCROP2_Pages1024to1055 ((uint32_t)0x00000001U) /* PC Read/Write protection of Sector32 */ 592 #define OB_PCROP2_Pages1056to1087 ((uint32_t)0x00000002U) /* PC Read/Write protection of Sector33 */ 593 #define OB_PCROP2_Pages1088to1119 ((uint32_t)0x00000004U) /* PC Read/Write protection of Sector34 */ 594 #define OB_PCROP2_Pages1120to1151 ((uint32_t)0x00000008U) /* PC Read/Write protection of Sector35 */ 595 #define OB_PCROP2_Pages1152to1183 ((uint32_t)0x00000010U) /* PC Read/Write protection of Sector36 */ 596 #define OB_PCROP2_Pages1184to1215 ((uint32_t)0x00000020U) /* PC Read/Write protection of Sector37 */ 597 #define OB_PCROP2_Pages1216to1247 ((uint32_t)0x00000040U) /* PC Read/Write protection of Sector38 */ 598 #define OB_PCROP2_Pages1248to1279 ((uint32_t)0x00000080U) /* PC Read/Write protection of Sector39 */ 599 #define OB_PCROP2_Pages1280to1311 ((uint32_t)0x00000100U) /* PC Read/Write protection of Sector40 */ 600 #define OB_PCROP2_Pages1312to1343 ((uint32_t)0x00000200U) /* PC Read/Write protection of Sector41 */ 601 #define OB_PCROP2_Pages1344to1375 ((uint32_t)0x00000400U) /* PC Read/Write protection of Sector42 */ 602 #define OB_PCROP2_Pages1376to1407 ((uint32_t)0x00000800U) /* PC Read/Write protection of Sector43 */ 603 #define OB_PCROP2_Pages1408to1439 ((uint32_t)0x00001000U) /* PC Read/Write protection of Sector44 */ 604 #define OB_PCROP2_Pages1440to1471 ((uint32_t)0x00002000U) /* PC Read/Write protection of Sector45 */ 605 #define OB_PCROP2_Pages1472to1503 ((uint32_t)0x00004000U) /* PC Read/Write protection of Sector46 */ 606 #define OB_PCROP2_Pages1504to1535 ((uint32_t)0x00008000U) /* PC Read/Write protection of Sector47 */ 607 #define OB_PCROP2_AllPages ((uint32_t)0x0000FFFFU) /*!< PC Read/Write protection of all Sectors PCROP2 */ 608 /** 609 * @} 610 */ 611 #endif /* STM32L071xx || STM32L072xx || STM32L073xx || STM32L081xx || STM32L082xx || STM32L083xx */ 612 613 /** @defgroup FLASHEx_Option_Bytes_BOOTBit1 FLASH Option Bytes BOOT Bit1 Setup 614 * @{ 615 */ 616 #define OB_BOOT_BIT1_RESET (uint8_t)(0x00U) /*!< BOOT Bit 1 Reset */ 617 #define OB_BOOT_BIT1_SET (uint8_t)(0x01U) /*!< BOOT Bit 1 Set */ 618 /** 619 * @} 620 */ 621 622 /** @defgroup FLASHEx_Type_Program_Data FLASHEx Type Program Data 623 * @{ 624 */ 625 #define FLASH_TYPEPROGRAMDATA_BYTE ((uint32_t)0x00U) /*!<Program byte (8-bit) at a specified address.*/ 626 #define FLASH_TYPEPROGRAMDATA_HALFWORD ((uint32_t)0x01U) /*!<Program a half-word (16-bit) at a specified address.*/ 627 #define FLASH_TYPEPROGRAMDATA_WORD ((uint32_t)0x02U) /*!<Program a word (32-bit) at a specified address.*/ 628 629 /** 630 * @} 631 */ 632 633 #if defined(FLASH_OPTR_BFB2) 634 635 /** @defgroup FLASHEx_Option_Bytes_BOOT FLASHEx Option Bytes BOOT 636 * @{ 637 */ 638 639 #define OB_BOOT_BANK1 ((uint8_t)0x00U) /*!< At startup, if boot pin 0 and BOOT1 bit are set in boot from user Flash position 640 and this parameter is selected the device will boot from Bank 1 (Default)*/ 641 #define OB_BOOT_BANK2 ((uint8_t)(FLASH_OPTR_BFB2 >> 16)) /*!< At startup, if boot pin 0 and BOOT1 bit are set in boot from user Flash position 642 and this parameter is selected the device will boot from Bank 2 */ 643 644 /** 645 * @} 646 */ 647 #endif /* FLASH_OPTR_BFB2 */ 648 649 /** 650 * @} 651 */ 652 653 /* Exported macro ------------------------------------------------------------*/ 654 655 /** @defgroup FLASHEx_Exported_Macros FLASHEx Exported Macros 656 * @{ 657 */ 658 659 /** 660 * @brief Set the FLASH Latency. 661 * @param __LATENCY__ FLASH Latency 662 * This parameter can be one of the following values: 663 * @arg @ref FLASH_LATENCY_0 FLASH Zero Latency cycle 664 * @arg @ref FLASH_LATENCY_1 FLASH One Latency cycle 665 * @retval none 666 */ 667 #define __HAL_FLASH_SET_LATENCY(__LATENCY__) \ 668 MODIFY_REG(FLASH->ACR, FLASH_ACR_LATENCY, (uint32_t)(__LATENCY__)) 669 670 /** 671 * @brief Get the FLASH Latency. 672 * @retval FLASH Latency 673 * This parameter can be one of the following values: 674 * @arg @ref FLASH_LATENCY_0 FLASH Zero Latency cycle 675 * @arg @ref FLASH_LATENCY_1 FLASH One Latency cycle 676 */ 677 #define __HAL_FLASH_GET_LATENCY() (READ_BIT((FLASH->ACR), FLASH_ACR_LATENCY)) 678 679 /** 680 * @brief Enable the FLASH prefetch buffer. 681 * @retval none 682 */ 683 #define __HAL_FLASH_PREFETCH_BUFFER_ENABLE() SET_BIT((FLASH->ACR), FLASH_ACR_PRFTEN) 684 685 /** 686 * @brief Disable the FLASH prefetch buffer. 687 * @retval none 688 */ 689 #define __HAL_FLASH_PREFETCH_BUFFER_DISABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_PRFTEN) 690 691 /** 692 * @brief Enable the FLASH Buffer cache. 693 * @retval none 694 */ 695 #define __HAL_FLASH_BUFFER_CACHE_ENABLE() SET_BIT((FLASH->ACR), FLASH_ACR_DISAB_BUF) 696 697 /** 698 * @brief Disable the FLASH Buffer cache. 699 * @retval none 700 */ 701 #define __HAL_FLASH_BUFFER_CACHE_DISABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_DISAB_BUF) 702 703 /** 704 * @brief Enable the FLASH preread buffer. 705 * @retval none 706 */ 707 #define __HAL_FLASH_PREREAD_BUFFER_ENABLE() SET_BIT((FLASH->ACR), FLASH_ACR_PRE_READ) 708 709 /** 710 * @brief Disable the FLASH preread buffer. 711 * @retval none 712 */ 713 #define __HAL_FLASH_PREREAD_BUFFER_DISABLE() CLEAR_BIT((FLASH->ACR), FLASH_ACR_PRE_READ) 714 715 /** 716 * @brief Enable the FLASH power down during Sleep mode 717 * @retval none 718 */ 719 #define __HAL_FLASH_SLEEP_POWERDOWN_ENABLE() SET_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD) 720 721 /** 722 * @brief Disable the FLASH power down during Sleep mode 723 * @retval none 724 */ 725 #define __HAL_FLASH_SLEEP_POWERDOWN_DISABLE() CLEAR_BIT(FLASH->ACR, FLASH_ACR_SLEEP_PD) 726 727 /** 728 * @brief Enable the Flash Run power down mode. 729 * @note Writing this bit to 0 this bit, automatically the keys are 730 * loss and a new unlock sequence is necessary to re-write it to 1. 731 */ 732 #define __HAL_FLASH_POWER_DOWN_ENABLE() do { FLASH->PDKEYR = FLASH_PDKEY1; \ 733 FLASH->PDKEYR = FLASH_PDKEY2; \ 734 SET_BIT((FLASH->ACR), FLASH_ACR_RUN_PD); \ 735 } while (0) 736 737 /** 738 * @brief Disable the Flash Run power down mode. 739 * @note Writing this bit to 0 this bit, automatically the keys are 740 * loss and a new unlock sequence is necessary to re-write it to 1. 741 */ 742 #define __HAL_FLASH_POWER_DOWN_DISABLE() do { FLASH->PDKEYR = FLASH_PDKEY1; \ 743 FLASH->PDKEYR = FLASH_PDKEY2; \ 744 CLEAR_BIT((FLASH->ACR), FLASH_ACR_RUN_PD); \ 745 } while (0) 746 747 /** 748 * @} 749 */ 750 751 /* Exported functions --------------------------------------------------------*/ 752 753 /** @addtogroup FLASHEx_Exported_Functions 754 * @{ 755 */ 756 757 /** @addtogroup FLASHEx_Exported_Functions_Group1 758 * @{ 759 */ 760 761 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *PageError); 762 HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit); 763 764 /** 765 * @} 766 */ 767 768 /** @addtogroup FLASHEx_Exported_Functions_Group2 769 * @{ 770 */ 771 772 HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit); 773 void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit); 774 775 #if defined(FLASH_OPTR_WPRMOD) || defined(FLASH_OPTR_BFB2) 776 777 HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); 778 void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit); 779 780 #endif /* FLASH_OPTR_WPRMOD || FLASH_OPTR_BFB2 */ 781 782 #if defined(FLASH_OPTR_WPRMOD) 783 784 HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void); 785 HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void); 786 787 #endif /* FLASH_OPTR_WPRMOD */ 788 789 /** 790 * @} 791 */ 792 793 /** @addtogroup FLASHEx_Exported_Functions_Group3 794 * @{ 795 */ 796 797 HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Unlock(void); 798 HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Lock(void); 799 800 HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Erase(uint32_t Address); 801 HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_Program(uint32_t TypeProgram, uint32_t Address, uint32_t Data); 802 void HAL_FLASHEx_DATAEEPROM_EnableFixedTimeProgram(void); 803 void HAL_FLASHEx_DATAEEPROM_DisableFixedTimeProgram(void); 804 805 /** 806 * @} 807 */ 808 809 /** 810 * @} 811 */ 812 813 /** 814 * @} 815 */ 816 817 /** 818 * @} 819 */ 820 821 #ifdef __cplusplus 822 } 823 #endif 824 825 #endif /* __STM32L0xx_HAL_FLASH_EX_H */ 826 827 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ 828