Prusa MINI Firmware overview
stm32f4xx_hal_flash_ex.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32f4xx_hal_flash_ex.h
4  * @author MCD Application Team
5  * @brief Header file of FLASH HAL Extension module.
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; COPYRIGHT(c) 2017 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 __STM32F4xx_HAL_FLASH_EX_H
38 #define __STM32F4xx_HAL_FLASH_EX_H
39 
40 #ifdef __cplusplus
41  extern "C" {
42 #endif
43 
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f4xx_hal_def.h"
46 
47 /** @addtogroup STM32F4xx_HAL_Driver
48  * @{
49  */
50 
51 /** @addtogroup FLASHEx
52  * @{
53  */
54 
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup FLASHEx_Exported_Types FLASH Exported Types
57  * @{
58  */
59 
60 /**
61  * @brief FLASH Erase structure definition
62  */
63 typedef struct
64 {
65  uint32_t TypeErase; /*!< Mass erase or sector Erase.
66  This parameter can be a value of @ref FLASHEx_Type_Erase */
67 
68  uint32_t Banks; /*!< Select banks to erase when Mass erase is enabled.
69  This parameter must be a value of @ref FLASHEx_Banks */
70 
71  uint32_t Sector; /*!< Initial FLASH sector to erase when Mass erase is disabled
72  This parameter must be a value of @ref FLASHEx_Sectors */
73 
74  uint32_t NbSectors; /*!< Number of sectors to be erased.
75  This parameter must be a value between 1 and (max number of sectors - value of Initial sector)*/
76 
77  uint32_t VoltageRange;/*!< The device voltage range which defines the erase parallelism
78  This parameter must be a value of @ref FLASHEx_Voltage_Range */
79 
81 
82 /**
83  * @brief FLASH Option Bytes Program structure definition
84  */
85 typedef struct
86 {
87  uint32_t OptionType; /*!< Option byte to be configured.
88  This parameter can be a value of @ref FLASHEx_Option_Type */
89 
90  uint32_t WRPState; /*!< Write protection activation or deactivation.
91  This parameter can be a value of @ref FLASHEx_WRP_State */
92 
93  uint32_t WRPSector; /*!< Specifies the sector(s) to be write protected.
94  The value of this parameter depend on device used within the same series */
95 
96  uint32_t Banks; /*!< Select banks for WRP activation/deactivation of all sectors.
97  This parameter must be a value of @ref FLASHEx_Banks */
98 
99  uint32_t RDPLevel; /*!< Set the read protection level.
100  This parameter can be a value of @ref FLASHEx_Option_Bytes_Read_Protection */
101 
102  uint32_t BORLevel; /*!< Set the BOR Level.
103  This parameter can be a value of @ref FLASHEx_BOR_Reset_Level */
104 
105  uint8_t USERConfig; /*!< Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY. */
106 
108 
109 /**
110  * @brief FLASH Advanced Option Bytes Program structure definition
111  */
112 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
113  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
114  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
115  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
116  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
117 typedef struct
118 {
119  uint32_t OptionType; /*!< Option byte to be configured for extension.
120  This parameter can be a value of @ref FLASHEx_Advanced_Option_Type */
121 
122  uint32_t PCROPState; /*!< PCROP activation or deactivation.
123  This parameter can be a value of @ref FLASHEx_PCROP_State */
124 
125 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
126  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
127  uint16_t Sectors; /*!< specifies the sector(s) set for PCROP.
128  This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
129 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx ||\
130  STM32F412Cx || STM32F413xx || STM32F423xx */
131 
132 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
133  uint32_t Banks; /*!< Select banks for PCROP activation/deactivation of all sectors.
134  This parameter must be a value of @ref FLASHEx_Banks */
135 
136  uint16_t SectorsBank1; /*!< Specifies the sector(s) set for PCROP for Bank1.
137  This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
138 
139  uint16_t SectorsBank2; /*!< Specifies the sector(s) set for PCROP for Bank2.
140  This parameter can be a value of @ref FLASHEx_Option_Bytes_PC_ReadWrite_Protection */
141 
142  uint8_t BootConfig; /*!< Specifies Option bytes for boot config.
143  This parameter can be a value of @ref FLASHEx_Dual_Boot */
144 
145 #endif /*STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
146 }FLASH_AdvOBProgramInitTypeDef;
147 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx ||
148  STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
149 /**
150  * @}
151  */
152 
153 /* Exported constants --------------------------------------------------------*/
154 
155 /** @defgroup FLASHEx_Exported_Constants FLASH Exported Constants
156  * @{
157  */
158 
159 /** @defgroup FLASHEx_Type_Erase FLASH Type Erase
160  * @{
161  */
162 #define FLASH_TYPEERASE_SECTORS 0x00000000U /*!< Sectors erase only */
163 #define FLASH_TYPEERASE_MASSERASE 0x00000001U /*!< Flash Mass erase activation */
164 /**
165  * @}
166  */
167 
168 /** @defgroup FLASHEx_Voltage_Range FLASH Voltage Range
169  * @{
170  */
171 #define FLASH_VOLTAGE_RANGE_1 0x00000000U /*!< Device operating range: 1.8V to 2.1V */
172 #define FLASH_VOLTAGE_RANGE_2 0x00000001U /*!< Device operating range: 2.1V to 2.7V */
173 #define FLASH_VOLTAGE_RANGE_3 0x00000002U /*!< Device operating range: 2.7V to 3.6V */
174 #define FLASH_VOLTAGE_RANGE_4 0x00000003U /*!< Device operating range: 2.7V to 3.6V + External Vpp */
175 /**
176  * @}
177  */
178 
179 /** @defgroup FLASHEx_WRP_State FLASH WRP State
180  * @{
181  */
182 #define OB_WRPSTATE_DISABLE 0x00000000U /*!< Disable the write protection of the desired bank 1 sectors */
183 #define OB_WRPSTATE_ENABLE 0x00000001U /*!< Enable the write protection of the desired bank 1 sectors */
184 /**
185  * @}
186  */
187 
188 /** @defgroup FLASHEx_Option_Type FLASH Option Type
189  * @{
190  */
191 #define OPTIONBYTE_WRP 0x00000001U /*!< WRP option byte configuration */
192 #define OPTIONBYTE_RDP 0x00000002U /*!< RDP option byte configuration */
193 #define OPTIONBYTE_USER 0x00000004U /*!< USER option byte configuration */
194 #define OPTIONBYTE_BOR 0x00000008U /*!< BOR option byte configuration */
195 /**
196  * @}
197  */
198 
199 /** @defgroup FLASHEx_Option_Bytes_Read_Protection FLASH Option Bytes Read Protection
200  * @{
201  */
202 #define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
203 #define OB_RDP_LEVEL_1 ((uint8_t)0x55)
204 #define OB_RDP_LEVEL_2 ((uint8_t)0xCC) /*!< Warning: When enabling read protection level 2
205  it s no more possible to go back to level 1 or 0 */
206 /**
207  * @}
208  */
209 
210 /** @defgroup FLASHEx_Option_Bytes_IWatchdog FLASH Option Bytes IWatchdog
211  * @{
212  */
213 #define OB_IWDG_SW ((uint8_t)0x20) /*!< Software IWDG selected */
214 #define OB_IWDG_HW ((uint8_t)0x00) /*!< Hardware IWDG selected */
215 /**
216  * @}
217  */
218 
219 /** @defgroup FLASHEx_Option_Bytes_nRST_STOP FLASH Option Bytes nRST_STOP
220  * @{
221  */
222 #define OB_STOP_NO_RST ((uint8_t)0x40) /*!< No reset generated when entering in STOP */
223 #define OB_STOP_RST ((uint8_t)0x00) /*!< Reset generated when entering in STOP */
224 /**
225  * @}
226  */
227 
228 
229 /** @defgroup FLASHEx_Option_Bytes_nRST_STDBY FLASH Option Bytes nRST_STDBY
230  * @{
231  */
232 #define OB_STDBY_NO_RST ((uint8_t)0x80) /*!< No reset generated when entering in STANDBY */
233 #define OB_STDBY_RST ((uint8_t)0x00) /*!< Reset generated when entering in STANDBY */
234 /**
235  * @}
236  */
237 
238 /** @defgroup FLASHEx_BOR_Reset_Level FLASH BOR Reset Level
239  * @{
240  */
241 #define OB_BOR_LEVEL3 ((uint8_t)0x00) /*!< Supply voltage ranges from 2.70 to 3.60 V */
242 #define OB_BOR_LEVEL2 ((uint8_t)0x04) /*!< Supply voltage ranges from 2.40 to 2.70 V */
243 #define OB_BOR_LEVEL1 ((uint8_t)0x08) /*!< Supply voltage ranges from 2.10 to 2.40 V */
244 #define OB_BOR_OFF ((uint8_t)0x0C) /*!< Supply voltage ranges from 1.62 to 2.10 V */
245 /**
246  * @}
247  */
248 
249 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
250  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
251  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
252  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
253  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
254 /** @defgroup FLASHEx_PCROP_State FLASH PCROP State
255  * @{
256  */
257 #define OB_PCROP_STATE_DISABLE 0x00000000U /*!< Disable PCROP */
258 #define OB_PCROP_STATE_ENABLE 0x00000001U /*!< Enable PCROP */
259 /**
260  * @}
261  */
262 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
263  STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
264  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
265 
266 /** @defgroup FLASHEx_Advanced_Option_Type FLASH Advanced Option Type
267  * @{
268  */
269 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
270  defined(STM32F469xx) || defined(STM32F479xx)
271 #define OPTIONBYTE_PCROP 0x00000001U /*!< PCROP option byte configuration */
272 #define OPTIONBYTE_BOOTCONFIG 0x00000002U /*!< BOOTConfig option byte configuration */
273 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
274 
275 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
276  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
277  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
278  defined(STM32F423xx)
279 #define OPTIONBYTE_PCROP 0x00000001U /*!<PCROP option byte configuration */
280 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||
281  STM32F413xx || STM32F423xx */
282 /**
283  * @}
284  */
285 
286 /** @defgroup FLASH_Latency FLASH Latency
287  * @{
288  */
289 /*------------------------- STM32F42xxx/STM32F43xxx/STM32F446xx/STM32F469xx/STM32F479xx ----------------------*/
290 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
291  defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
292 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */
293 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */
294 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */
295 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */
296 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */
297 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */
298 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */
299 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */
300 #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS /*!< FLASH Eight Latency cycles */
301 #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS /*!< FLASH Nine Latency cycles */
302 #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS /*!< FLASH Ten Latency cycles */
303 #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS /*!< FLASH Eleven Latency cycles */
304 #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS /*!< FLASH Twelve Latency cycles */
305 #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS /*!< FLASH Thirteen Latency cycles */
306 #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS /*!< FLASH Fourteen Latency cycles */
307 #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS /*!< FLASH Fifteen Latency cycles */
308 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
309 /*--------------------------------------------------------------------------------------------------------------*/
310 
311 /*-------------------------- STM32F40xxx/STM32F41xxx/STM32F401xx/STM32F411xx/STM32F423xx -----------------------*/
312 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
313  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
314  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
315  defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
316 
317 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS /*!< FLASH Zero Latency cycle */
318 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS /*!< FLASH One Latency cycle */
319 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS /*!< FLASH Two Latency cycles */
320 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS /*!< FLASH Three Latency cycles */
321 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS /*!< FLASH Four Latency cycles */
322 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS /*!< FLASH Five Latency cycles */
323 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS /*!< FLASH Six Latency cycles */
324 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS /*!< FLASH Seven Latency cycles */
325 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx ||
326  STM32F413xx || STM32F423xx */
327 /*--------------------------------------------------------------------------------------------------------------*/
328 
329 /**
330  * @}
331  */
332 
333 
334 /** @defgroup FLASHEx_Banks FLASH Banks
335  * @{
336  */
337 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
338  defined(STM32F469xx) || defined(STM32F479xx)
339 #define FLASH_BANK_1 1U /*!< Bank 1 */
340 #define FLASH_BANK_2 2U /*!< Bank 2 */
341 #define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2) /*!< Bank1 and Bank2 */
342 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
343 
344 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
345  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
346  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
347  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
348  defined(STM32F423xx)
349 #define FLASH_BANK_1 1U /*!< Bank 1 */
350 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx
351  STM32F413xx || STM32F423xx */
352 /**
353  * @}
354  */
355 
356 /** @defgroup FLASHEx_MassErase_bit FLASH Mass Erase bit
357  * @{
358  */
359 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
360  defined(STM32F469xx) || defined(STM32F479xx)
361 #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2) /*!< 2 MER bits here to clear */
362 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
363 
364 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
365  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
366  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
367  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
368  defined(STM32F423xx)
369 #define FLASH_MER_BIT (FLASH_CR_MER) /*!< only 1 MER Bit */
370 #endif /* STM32F40xxx || STM32F41xxx || STM32F401xx || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx
371  STM32F413xx || STM32F423xx */
372 /**
373  * @}
374  */
375 
376 /** @defgroup FLASHEx_Sectors FLASH Sectors
377  * @{
378  */
379 /*-------------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx ------------------------------------*/
380 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
381  defined(STM32F469xx) || defined(STM32F479xx)
382 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
383 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
384 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
385 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
386 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
387 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
388 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
389 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
390 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
391 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
392 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
393 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
394 #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */
395 #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */
396 #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */
397 #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */
398 #define FLASH_SECTOR_16 16U /*!< Sector Number 16 */
399 #define FLASH_SECTOR_17 17U /*!< Sector Number 17 */
400 #define FLASH_SECTOR_18 18U /*!< Sector Number 18 */
401 #define FLASH_SECTOR_19 19U /*!< Sector Number 19 */
402 #define FLASH_SECTOR_20 20U /*!< Sector Number 20 */
403 #define FLASH_SECTOR_21 21U /*!< Sector Number 21 */
404 #define FLASH_SECTOR_22 22U /*!< Sector Number 22 */
405 #define FLASH_SECTOR_23 23U /*!< Sector Number 23 */
406 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
407 /*-----------------------------------------------------------------------------------------------------*/
408 
409 /*-------------------------------------- STM32F413xx/STM32F423xx --------------------------------------*/
410 #if defined(STM32F413xx) || defined(STM32F423xx)
411 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
412 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
413 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
414 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
415 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
416 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
417 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
418 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
419 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
420 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
421 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
422 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
423 #define FLASH_SECTOR_12 12U /*!< Sector Number 12 */
424 #define FLASH_SECTOR_13 13U /*!< Sector Number 13 */
425 #define FLASH_SECTOR_14 14U /*!< Sector Number 14 */
426 #define FLASH_SECTOR_15 15U /*!< Sector Number 15 */
427 #endif /* STM32F413xx || STM32F423xx */
428 /*-----------------------------------------------------------------------------------------------------*/
429 
430 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
431 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
432  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
433 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
434 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
435 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
436 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
437 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
438 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
439 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
440 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
441 #define FLASH_SECTOR_8 8U /*!< Sector Number 8 */
442 #define FLASH_SECTOR_9 9U /*!< Sector Number 9 */
443 #define FLASH_SECTOR_10 10U /*!< Sector Number 10 */
444 #define FLASH_SECTOR_11 11U /*!< Sector Number 11 */
445 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
446 /*-----------------------------------------------------------------------------------------------------*/
447 
448 /*--------------------------------------------- STM32F401xC -------------------------------------------*/
449 #if defined(STM32F401xC)
450 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
451 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
452 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
453 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
454 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
455 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
456 #endif /* STM32F401xC */
457 /*-----------------------------------------------------------------------------------------------------*/
458 
459 /*--------------------------------------------- STM32F410xx -------------------------------------------*/
460 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
461 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
462 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
463 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
464 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
465 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
466 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
467 /*-----------------------------------------------------------------------------------------------------*/
468 
469 /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
470 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
471 #define FLASH_SECTOR_0 0U /*!< Sector Number 0 */
472 #define FLASH_SECTOR_1 1U /*!< Sector Number 1 */
473 #define FLASH_SECTOR_2 2U /*!< Sector Number 2 */
474 #define FLASH_SECTOR_3 3U /*!< Sector Number 3 */
475 #define FLASH_SECTOR_4 4U /*!< Sector Number 4 */
476 #define FLASH_SECTOR_5 5U /*!< Sector Number 5 */
477 #define FLASH_SECTOR_6 6U /*!< Sector Number 6 */
478 #define FLASH_SECTOR_7 7U /*!< Sector Number 7 */
479 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
480 /*-----------------------------------------------------------------------------------------------------*/
481 
482 /**
483  * @}
484  */
485 
486 /** @defgroup FLASHEx_Option_Bytes_Write_Protection FLASH Option Bytes Write Protection
487  * @{
488  */
489 /*--------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx -------------------------*/
490 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
491  defined(STM32F469xx) || defined(STM32F479xx)
492 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
493 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
494 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
495 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
496 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
497 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
498 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
499 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
500 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
501 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
502 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
503 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
504 #define OB_WRP_SECTOR_12 0x00000001U << 12U /*!< Write protection of Sector12 */
505 #define OB_WRP_SECTOR_13 0x00000002U << 12U /*!< Write protection of Sector13 */
506 #define OB_WRP_SECTOR_14 0x00000004U << 12U /*!< Write protection of Sector14 */
507 #define OB_WRP_SECTOR_15 0x00000008U << 12U /*!< Write protection of Sector15 */
508 #define OB_WRP_SECTOR_16 0x00000010U << 12U /*!< Write protection of Sector16 */
509 #define OB_WRP_SECTOR_17 0x00000020U << 12U /*!< Write protection of Sector17 */
510 #define OB_WRP_SECTOR_18 0x00000040U << 12U /*!< Write protection of Sector18 */
511 #define OB_WRP_SECTOR_19 0x00000080U << 12U /*!< Write protection of Sector19 */
512 #define OB_WRP_SECTOR_20 0x00000100U << 12U /*!< Write protection of Sector20 */
513 #define OB_WRP_SECTOR_21 0x00000200U << 12U /*!< Write protection of Sector21 */
514 #define OB_WRP_SECTOR_22 0x00000400U << 12U /*!< Write protection of Sector22 */
515 #define OB_WRP_SECTOR_23 0x00000800U << 12U /*!< Write protection of Sector23 */
516 #define OB_WRP_SECTOR_All 0x00000FFFU << 12U /*!< Write protection of all Sectors */
517 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
518 /*-----------------------------------------------------------------------------------------------------*/
519 
520 /*--------------------------------------- STM32F413xx/STM32F423xx -------------------------------------*/
521 #if defined(STM32F413xx) || defined(STM32F423xx)
522 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
523 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
524 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
525 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
526 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
527 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
528 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
529 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
530 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
531 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
532 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
533 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
534 #define OB_WRP_SECTOR_12 0x00001000U /*!< Write protection of Sector12 */
535 #define OB_WRP_SECTOR_13 0x00002000U /*!< Write protection of Sector13 */
536 #define OB_WRP_SECTOR_14 0x00004000U /*!< Write protection of Sector14 */
537 #define OB_WRP_SECTOR_15 0x00004000U /*!< Write protection of Sector15 */
538 #define OB_WRP_SECTOR_All 0x00007FFFU /*!< Write protection of all Sectors */
539 #endif /* STM32F413xx || STM32F423xx */
540 /*-----------------------------------------------------------------------------------------------------*/
541 
542 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
543 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
544  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
545 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
546 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
547 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
548 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
549 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
550 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
551 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
552 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
553 #define OB_WRP_SECTOR_8 0x00000100U /*!< Write protection of Sector8 */
554 #define OB_WRP_SECTOR_9 0x00000200U /*!< Write protection of Sector9 */
555 #define OB_WRP_SECTOR_10 0x00000400U /*!< Write protection of Sector10 */
556 #define OB_WRP_SECTOR_11 0x00000800U /*!< Write protection of Sector11 */
557 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
558 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
559 /*-----------------------------------------------------------------------------------------------------*/
560 
561 /*--------------------------------------------- STM32F401xC -------------------------------------------*/
562 #if defined(STM32F401xC)
563 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
564 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
565 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
566 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
567 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
568 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
569 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
570 #endif /* STM32F401xC */
571 /*-----------------------------------------------------------------------------------------------------*/
572 
573 /*--------------------------------------------- STM32F410xx -------------------------------------------*/
574 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
575 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
576 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
577 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
578 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
579 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
580 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
581 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
582 /*-----------------------------------------------------------------------------------------------------*/
583 
584 /*---------------------------------- STM32F401xE/STM32F411xE/STM32F446xx ------------------------------*/
585 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
586 #define OB_WRP_SECTOR_0 0x00000001U /*!< Write protection of Sector0 */
587 #define OB_WRP_SECTOR_1 0x00000002U /*!< Write protection of Sector1 */
588 #define OB_WRP_SECTOR_2 0x00000004U /*!< Write protection of Sector2 */
589 #define OB_WRP_SECTOR_3 0x00000008U /*!< Write protection of Sector3 */
590 #define OB_WRP_SECTOR_4 0x00000010U /*!< Write protection of Sector4 */
591 #define OB_WRP_SECTOR_5 0x00000020U /*!< Write protection of Sector5 */
592 #define OB_WRP_SECTOR_6 0x00000040U /*!< Write protection of Sector6 */
593 #define OB_WRP_SECTOR_7 0x00000080U /*!< Write protection of Sector7 */
594 #define OB_WRP_SECTOR_All 0x00000FFFU /*!< Write protection of all Sectors */
595 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
596 /*-----------------------------------------------------------------------------------------------------*/
597 /**
598  * @}
599  */
600 
601 /** @defgroup FLASHEx_Option_Bytes_PC_ReadWrite_Protection FLASH Option Bytes PC ReadWrite Protection
602  * @{
603  */
604 /*-------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx ---------------------------*/
605 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
606  defined(STM32F469xx) || defined(STM32F479xx)
607 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
608 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
609 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
610 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
611 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
612 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
613 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
614 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
615 #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */
616 #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */
617 #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */
618 #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */
619 #define OB_PCROP_SECTOR_12 0x00000001U /*!< PC Read/Write protection of Sector12 */
620 #define OB_PCROP_SECTOR_13 0x00000002U /*!< PC Read/Write protection of Sector13 */
621 #define OB_PCROP_SECTOR_14 0x00000004U /*!< PC Read/Write protection of Sector14 */
622 #define OB_PCROP_SECTOR_15 0x00000008U /*!< PC Read/Write protection of Sector15 */
623 #define OB_PCROP_SECTOR_16 0x00000010U /*!< PC Read/Write protection of Sector16 */
624 #define OB_PCROP_SECTOR_17 0x00000020U /*!< PC Read/Write protection of Sector17 */
625 #define OB_PCROP_SECTOR_18 0x00000040U /*!< PC Read/Write protection of Sector18 */
626 #define OB_PCROP_SECTOR_19 0x00000080U /*!< PC Read/Write protection of Sector19 */
627 #define OB_PCROP_SECTOR_20 0x00000100U /*!< PC Read/Write protection of Sector20 */
628 #define OB_PCROP_SECTOR_21 0x00000200U /*!< PC Read/Write protection of Sector21 */
629 #define OB_PCROP_SECTOR_22 0x00000400U /*!< PC Read/Write protection of Sector22 */
630 #define OB_PCROP_SECTOR_23 0x00000800U /*!< PC Read/Write protection of Sector23 */
631 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
632 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
633 /*-----------------------------------------------------------------------------------------------------*/
634 
635 /*------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/
636 #if defined(STM32F413xx) || defined(STM32F423xx)
637 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
638 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
639 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
640 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
641 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
642 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
643 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
644 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
645 #define OB_PCROP_SECTOR_8 0x00000100U /*!< PC Read/Write protection of Sector8 */
646 #define OB_PCROP_SECTOR_9 0x00000200U /*!< PC Read/Write protection of Sector9 */
647 #define OB_PCROP_SECTOR_10 0x00000400U /*!< PC Read/Write protection of Sector10 */
648 #define OB_PCROP_SECTOR_11 0x00000800U /*!< PC Read/Write protection of Sector11 */
649 #define OB_PCROP_SECTOR_12 0x00001000U /*!< PC Read/Write protection of Sector12 */
650 #define OB_PCROP_SECTOR_13 0x00002000U /*!< PC Read/Write protection of Sector13 */
651 #define OB_PCROP_SECTOR_14 0x00004000U /*!< PC Read/Write protection of Sector14 */
652 #define OB_PCROP_SECTOR_15 0x00004000U /*!< PC Read/Write protection of Sector15 */
653 #define OB_PCROP_SECTOR_All 0x00007FFFU /*!< PC Read/Write protection of all Sectors */
654 #endif /* STM32F413xx || STM32F423xx */
655 /*-----------------------------------------------------------------------------------------------------*/
656 
657 /*--------------------------------------------- STM32F401xC -------------------------------------------*/
658 #if defined(STM32F401xC)
659 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
660 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
661 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
662 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
663 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
664 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
665 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
666 #endif /* STM32F401xC */
667 /*-----------------------------------------------------------------------------------------------------*/
668 
669 /*--------------------------------------------- STM32F410xx -------------------------------------------*/
670 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
671 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
672 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
673 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
674 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
675 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
676 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
677 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
678 /*-----------------------------------------------------------------------------------------------------*/
679 
680 /*-------------- STM32F401xE/STM32F411xE/STM32F412Zx/STM32F412Vx/STM32F412Rx/STM32F412Cx/STM32F446xx --*/
681 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
682  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
683 #define OB_PCROP_SECTOR_0 0x00000001U /*!< PC Read/Write protection of Sector0 */
684 #define OB_PCROP_SECTOR_1 0x00000002U /*!< PC Read/Write protection of Sector1 */
685 #define OB_PCROP_SECTOR_2 0x00000004U /*!< PC Read/Write protection of Sector2 */
686 #define OB_PCROP_SECTOR_3 0x00000008U /*!< PC Read/Write protection of Sector3 */
687 #define OB_PCROP_SECTOR_4 0x00000010U /*!< PC Read/Write protection of Sector4 */
688 #define OB_PCROP_SECTOR_5 0x00000020U /*!< PC Read/Write protection of Sector5 */
689 #define OB_PCROP_SECTOR_6 0x00000040U /*!< PC Read/Write protection of Sector6 */
690 #define OB_PCROP_SECTOR_7 0x00000080U /*!< PC Read/Write protection of Sector7 */
691 #define OB_PCROP_SECTOR_All 0x00000FFFU /*!< PC Read/Write protection of all Sectors */
692 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
693 /*-----------------------------------------------------------------------------------------------------*/
694 
695 /**
696  * @}
697  */
698 
699 /** @defgroup FLASHEx_Dual_Boot FLASH Dual Boot
700  * @{
701  */
702 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
703  defined(STM32F469xx) || defined(STM32F479xx)
704 #define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10) /*!< Dual Bank Boot Enable */
705 #define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00) /*!< Dual Bank Boot Disable, always boot on User Flash */
706 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
707 /**
708  * @}
709  */
710 
711 /** @defgroup FLASHEx_Selection_Protection_Mode FLASH Selection Protection Mode
712  * @{
713  */
714 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
715  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
716  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
717  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
718  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
719 #define OB_PCROP_DESELECTED ((uint8_t)0x00) /*!< Disabled PcROP, nWPRi bits used for Write Protection on sector i */
720 #define OB_PCROP_SELECTED ((uint8_t)0x80) /*!< Enable PcROP, nWPRi bits used for PCRoP Protection on sector i */
721 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
722  STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
723  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
724 /**
725  * @}
726  */
727 
728 /**
729  * @}
730  */
731 
732 /* Exported macro ------------------------------------------------------------*/
733 
734 /* Exported functions --------------------------------------------------------*/
735 /** @addtogroup FLASHEx_Exported_Functions
736  * @{
737  */
738 
739 /** @addtogroup FLASHEx_Exported_Functions_Group1
740  * @{
741  */
742 /* Extension Program operation functions *************************************/
743 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
747 
748 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
749  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
750  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
751  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
752  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
753 HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram (FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
754 void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit);
755 HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void);
756 HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void);
757 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
758  STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
759  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
760 
761 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
762  defined(STM32F469xx) || defined(STM32F479xx)
763 uint16_t HAL_FLASHEx_OB_GetBank2WRP(void);
764 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
765 /**
766  * @}
767  */
768 
769 /**
770  * @}
771  */
772 /* Private types -------------------------------------------------------------*/
773 /* Private variables ---------------------------------------------------------*/
774 /* Private constants ---------------------------------------------------------*/
775 /** @defgroup FLASHEx_Private_Constants FLASH Private Constants
776  * @{
777  */
778 /*--------------------------------- STM32F42xxx/STM32F43xxx/STM32F469xx/STM32F479xx---------------------*/
779 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
780 #define FLASH_SECTOR_TOTAL 24U
781 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
782 
783 /*-------------------------------------- STM32F413xx/STM32F423xx ---------------------------------------*/
784 #if defined(STM32F413xx) || defined(STM32F423xx)
785 #define FLASH_SECTOR_TOTAL 16U
786 #endif /* STM32F413xx || STM32F423xx */
787 
788 /*--------------------------------------- STM32F40xxx/STM32F41xxx -------------------------------------*/
789 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
790  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
791 #define FLASH_SECTOR_TOTAL 12U
792 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
793 
794 /*--------------------------------------------- STM32F401xC -------------------------------------------*/
795 #if defined(STM32F401xC)
796 #define FLASH_SECTOR_TOTAL 6U
797 #endif /* STM32F401xC */
798 
799 /*--------------------------------------------- STM32F410xx -------------------------------------------*/
800 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
801 #define FLASH_SECTOR_TOTAL 5U
802 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
803 
804 /*--------------------------------- STM32F401xE/STM32F411xE/STM32F412xG/STM32F446xx -------------------*/
805 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
806 #define FLASH_SECTOR_TOTAL 8U
807 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
808 
809 /**
810  * @brief OPTCR1 register byte 2 (Bits[23:16]) base address
811  */
812 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
813 #define OPTCR1_BYTE2_ADDRESS 0x40023C1AU
814 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
815 
816 /**
817  * @}
818  */
819 
820 /* Private macros ------------------------------------------------------------*/
821 /** @defgroup FLASHEx_Private_Macros FLASH Private Macros
822  * @{
823  */
824 
825 /** @defgroup FLASHEx_IS_FLASH_Definitions FLASH Private macros to check input parameters
826  * @{
827  */
828 
829 #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
830  ((VALUE) == FLASH_TYPEERASE_MASSERASE))
831 
832 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
833  ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
834  ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
835  ((RANGE) == FLASH_VOLTAGE_RANGE_4))
836 
837 #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
838  ((VALUE) == OB_WRPSTATE_ENABLE))
839 
840 #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR)))
841 
842 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
843  ((LEVEL) == OB_RDP_LEVEL_1) ||\
844  ((LEVEL) == OB_RDP_LEVEL_2))
845 
846 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
847 
848 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
849 
850 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
851 
852 #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
853  ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
854 
855 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
856  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
857  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
858  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
859  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
860 #define IS_PCROPSTATE(VALUE)(((VALUE) == OB_PCROP_STATE_DISABLE) || \
861  ((VALUE) == OB_PCROP_STATE_ENABLE))
862 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
863  STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
864  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
865 
866 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
867  defined(STM32F469xx) || defined(STM32F479xx)
868 #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP) || \
869  ((VALUE) == OPTIONBYTE_BOOTCONFIG))
870 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
871 
872 #if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
873  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
874  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
875  defined(STM32F423xx)
876 #define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP))
877 #endif /* STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx ||\
878  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
879 
880 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
881  defined(STM32F446xx) || defined(STM32F469xx) || defined(STM32F479xx)
882 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
883  ((LATENCY) == FLASH_LATENCY_1) || \
884  ((LATENCY) == FLASH_LATENCY_2) || \
885  ((LATENCY) == FLASH_LATENCY_3) || \
886  ((LATENCY) == FLASH_LATENCY_4) || \
887  ((LATENCY) == FLASH_LATENCY_5) || \
888  ((LATENCY) == FLASH_LATENCY_6) || \
889  ((LATENCY) == FLASH_LATENCY_7) || \
890  ((LATENCY) == FLASH_LATENCY_8) || \
891  ((LATENCY) == FLASH_LATENCY_9) || \
892  ((LATENCY) == FLASH_LATENCY_10) || \
893  ((LATENCY) == FLASH_LATENCY_11) || \
894  ((LATENCY) == FLASH_LATENCY_12) || \
895  ((LATENCY) == FLASH_LATENCY_13) || \
896  ((LATENCY) == FLASH_LATENCY_14) || \
897  ((LATENCY) == FLASH_LATENCY_15))
898 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F446xx || STM32F469xx || STM32F479xx */
899 
900 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
901  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
902  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
903  defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
904 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
905  ((LATENCY) == FLASH_LATENCY_1) || \
906  ((LATENCY) == FLASH_LATENCY_2) || \
907  ((LATENCY) == FLASH_LATENCY_3) || \
908  ((LATENCY) == FLASH_LATENCY_4) || \
909  ((LATENCY) == FLASH_LATENCY_5) || \
910  ((LATENCY) == FLASH_LATENCY_6) || \
911  ((LATENCY) == FLASH_LATENCY_7))
912 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F412Zx || STM32F412Vx ||\
913  STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
914 
915 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
916 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
917  ((BANK) == FLASH_BANK_2) || \
918  ((BANK) == FLASH_BANK_BOTH))
919 #endif /* STM32F427xx || STM32F437xx || STM32F429xx|| STM32F439xx || STM32F469xx || STM32F479xx */
920 
921 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
922  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
923  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) ||\
924  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) ||\
925  defined(STM32F423xx)
926 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1))
927 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F410xx || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx ||\
928  STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
929 
930 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
931 #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
932  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
933  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
934  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
935  ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
936  ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
937  ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
938  ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
939  ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
940  ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
941  ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
942  ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
943 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
944 
945 #if defined(STM32F413xx) || defined(STM32F423xx)
946 #define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
947  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
948  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
949  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
950  ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
951  ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
952  ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
953  ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15))
954 #endif /* STM32F413xx || STM32F423xx */
955 
956 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || defined(STM32F412Zx) ||\
957  defined(STM32F412Vx) || defined(STM32F412Rx) || defined(STM32F412Cx)
958 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
959  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
960  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
961  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
962  ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
963  ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11))
964 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
965 
966 #if defined(STM32F401xC)
967 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
968  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
969  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5))
970 #endif /* STM32F401xC */
971 
972 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
973 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
974  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
975  ((SECTOR) == FLASH_SECTOR_4))
976 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
977 
978 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
979 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
980  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
981  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
982  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
983 #endif /* STM32F401xE || STM32F411xE || STM32F446xx */
984 
985 #define IS_FLASH_ADDRESS(ADDRESS) ((((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END)) || \
986  (((ADDRESS) >= FLASH_OTP_BASE) && ((ADDRESS) <= FLASH_OTP_END)))
987 
988 #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
989 
990 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
991 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFF000000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
992 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
993 
994 #if defined(STM32F413xx) || defined(STM32F423xx)
995 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
996 #endif /* STM32F413xx || STM32F423xx */
997 
998 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
999 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1000 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx */
1001 
1002 #if defined(STM32F401xC)
1003 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1004 #endif /* STM32F401xC */
1005 
1006 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
1007 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1008 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
1009 
1010 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
1011  defined(STM32F412Rx) || defined(STM32F412Cx)
1012 #define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1013 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
1014 
1015 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
1016 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1017 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
1018 
1019 #if defined(STM32F413xx) || defined(STM32F423xx)
1020 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFF8000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1021 #endif /* STM32F413xx || STM32F423xx */
1022 
1023 #if defined(STM32F401xC)
1024 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1025 #endif /* STM32F401xC */
1026 
1027 #if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
1028 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1029 #endif /* STM32F410Tx || STM32F410Cx || STM32F410Rx */
1030 
1031 #if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F412Zx) || defined(STM32F412Vx) ||\
1032  defined(STM32F412Rx) || defined(STM32F412Cx)
1033 #define IS_OB_PCROP(SECTOR)((((SECTOR) & 0xFFFFF000U) == 0x00000000U) && ((SECTOR) != 0x00000000U))
1034 #endif /* STM32F401xE || STM32F411xE || STM32F446xx || STM32F412Zx || STM32F412Vx || STM32F412Rx || STM32F412Cx */
1035 
1036 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
1037  defined(STM32F469xx) || defined(STM32F479xx)
1038 #define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE))
1039 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F469xx || STM32F479xx */
1040 
1041 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
1042  defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
1043  defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
1044  defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || defined(STM32F412Rx) ||\
1045  defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
1046 #define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED))
1047 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx || STM32F401xC || STM32F401xE ||\
1048  STM32F410xx || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx ||\
1049  STM32F412Vx || STM32F412Rx || STM32F412Cx || STM32F413xx || STM32F423xx */
1050 /**
1051  * @}
1052  */
1053 
1054 /**
1055  * @}
1056  */
1057 
1058 /* Private functions ---------------------------------------------------------*/
1059 /** @defgroup FLASHEx_Private_Functions FLASH Private Functions
1060  * @{
1061  */
1062 void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange);
1063 void FLASH_FlushCaches(void);
1064 /**
1065  * @}
1066  */
1067 
1068 /**
1069  * @}
1070  */
1071 
1072 /**
1073  * @}
1074  */
1075 
1076 #ifdef __cplusplus
1077 }
1078 #endif
1079 
1080 #endif /* __STM32F4xx_HAL_FLASH_EX_H */
1081 
1082 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
FLASH_OBProgramInitTypeDef
FLASH Option Bytes Program structure definition.
Definition: stm32f4xx_hal_flash_ex.h:85
FLASH_EraseInitTypeDef::NbSectors
uint32_t NbSectors
Definition: stm32f4xx_hal_flash_ex.h:74
stm32f4xx_hal_def.h
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_FLASHEx_Erase
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError)
HAL_FLASHEx_OBGetConfig
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit)
FLASH_OBProgramInitTypeDef::USERConfig
uint8_t USERConfig
Definition: stm32f4xx_hal_flash_ex.h:105
FLASH_EraseInitTypeDef::Sector
uint32_t Sector
Definition: stm32f4xx_hal_flash_ex.h:71
FLASH_OBProgramInitTypeDef::WRPState
uint32_t WRPState
Definition: stm32f4xx_hal_flash_ex.h:90
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
FLASH_OBProgramInitTypeDef::RDPLevel
uint32_t RDPLevel
Definition: stm32f4xx_hal_flash_ex.h:99
HAL_FLASHEx_OBProgram
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit)
FLASH_OBProgramInitTypeDef::BORLevel
uint32_t BORLevel
Definition: stm32f4xx_hal_flash_ex.h:102
FLASH_EraseInitTypeDef::TypeErase
uint32_t TypeErase
Definition: stm32f4xx_hal_flash_ex.h:65
FLASH_Erase_Sector
void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange)
FLASH_EraseInitTypeDef::VoltageRange
uint32_t VoltageRange
Definition: stm32f4xx_hal_flash_ex.h:77
uint8_t
const uint8_t[]
Definition: 404_html.c:3
HAL_FLASHEx_Erase_IT
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)
FLASH_OBProgramInitTypeDef::Banks
uint32_t Banks
Definition: stm32f4xx_hal_flash_ex.h:96
FLASH_FlushCaches
void FLASH_FlushCaches(void)
FLASH_EraseInitTypeDef::Banks
uint32_t Banks
Definition: stm32f4xx_hal_flash_ex.h:68
FLASH_OBProgramInitTypeDef::OptionType
uint32_t OptionType
Definition: stm32f4xx_hal_flash_ex.h:87
FLASH_EraseInitTypeDef
FLASH Erase structure definition.
Definition: stm32f4xx_hal_flash_ex.h:63
FLASH_OBProgramInitTypeDef::WRPSector
uint32_t WRPSector
Definition: stm32f4xx_hal_flash_ex.h:93