39#ifndef __STM32F4xx_HAL_FLASH_EX_H
40#define __STM32F4xx_HAL_FLASH_EX_H
79 uint32_t VoltageRange;
82} FLASH_EraseInitTypeDef;
114#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
115 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
116 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
126#if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
131#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
160#define FLASH_TYPEERASE_SECTORS ((uint32_t)0x00)
161#define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01)
169#define FLASH_VOLTAGE_RANGE_1 ((uint32_t)0x00)
170#define FLASH_VOLTAGE_RANGE_2 ((uint32_t)0x01)
171#define FLASH_VOLTAGE_RANGE_3 ((uint32_t)0x02)
172#define FLASH_VOLTAGE_RANGE_4 ((uint32_t)0x03)
180#define OB_WRPSTATE_DISABLE ((uint32_t)0x00)
181#define OB_WRPSTATE_ENABLE ((uint32_t)0x01)
189#define OPTIONBYTE_WRP ((uint32_t)0x01)
190#define OPTIONBYTE_RDP ((uint32_t)0x02)
191#define OPTIONBYTE_USER ((uint32_t)0x04)
192#define OPTIONBYTE_BOR ((uint32_t)0x08)
200#define OB_RDP_LEVEL_0 ((uint8_t)0xAA)
201#define OB_RDP_LEVEL_1 ((uint8_t)0x55)
202#define OB_RDP_LEVEL_2 ((uint8_t)0xCC)
211#define OB_IWDG_SW ((uint8_t)0x20)
212#define OB_IWDG_HW ((uint8_t)0x00)
220#define OB_STOP_NO_RST ((uint8_t)0x40)
221#define OB_STOP_RST ((uint8_t)0x00)
230#define OB_STDBY_NO_RST ((uint8_t)0x80)
231#define OB_STDBY_RST ((uint8_t)0x00)
239#define OB_BOR_LEVEL3 ((uint8_t)0x00)
240#define OB_BOR_LEVEL2 ((uint8_t)0x04)
241#define OB_BOR_LEVEL1 ((uint8_t)0x08)
242#define OB_BOR_OFF ((uint8_t)0x0C)
247#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
248 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
249 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
254#define OB_PCROP_STATE_DISABLE ((uint32_t)0x00)
255#define OB_PCROP_STATE_ENABLE ((uint32_t)0x01)
265#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
266 defined(STM32F469xx) || defined(STM32F479xx)
267#define OPTIONBYTE_PCROP ((uint32_t)0x01)
268#define OPTIONBYTE_BOOTCONFIG ((uint32_t)0x02)
271#if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
272 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
273#define OPTIONBYTE_PCROP ((uint32_t)0x01)
283#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
284 defined(STM32F469xx) || defined(STM32F479xx)
285#define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS
286#define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS
287#define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS
288#define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS
289#define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS
290#define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS
291#define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS
292#define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS
293#define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS
294#define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS
295#define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS
296#define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS
297#define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS
298#define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS
299#define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS
300#define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS
305#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
306 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
307 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
309#define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS
310#define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS
311#define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS
312#define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS
313#define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS
314#define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS
315#define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS
316#define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS
328#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
329 defined(STM32F469xx) || defined(STM32F479xx)
330#define FLASH_BANK_1 ((uint32_t)1)
331#define FLASH_BANK_2 ((uint32_t)2)
332#define FLASH_BANK_BOTH ((uint32_t)FLASH_BANK_1 | FLASH_BANK_2)
335#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
336 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
337 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
338#define FLASH_BANK_1 ((uint32_t)1)
347#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
348 defined(STM32F469xx) || defined(STM32F479xx)
349#define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2)
352#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
353 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
354 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
355#define FLASH_MER_BIT (FLASH_CR_MER)
365#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
366 defined(STM32F469xx) || defined(STM32F479xx)
367#define FLASH_SECTOR_0 ((uint32_t)0)
368#define FLASH_SECTOR_1 ((uint32_t)1)
369#define FLASH_SECTOR_2 ((uint32_t)2)
370#define FLASH_SECTOR_3 ((uint32_t)3)
371#define FLASH_SECTOR_4 ((uint32_t)4)
372#define FLASH_SECTOR_5 ((uint32_t)5)
373#define FLASH_SECTOR_6 ((uint32_t)6)
374#define FLASH_SECTOR_7 ((uint32_t)7)
375#define FLASH_SECTOR_8 ((uint32_t)8)
376#define FLASH_SECTOR_9 ((uint32_t)9)
377#define FLASH_SECTOR_10 ((uint32_t)10)
378#define FLASH_SECTOR_11 ((uint32_t)11)
379#define FLASH_SECTOR_12 ((uint32_t)12)
380#define FLASH_SECTOR_13 ((uint32_t)13)
381#define FLASH_SECTOR_14 ((uint32_t)14)
382#define FLASH_SECTOR_15 ((uint32_t)15)
383#define FLASH_SECTOR_16 ((uint32_t)16)
384#define FLASH_SECTOR_17 ((uint32_t)17)
385#define FLASH_SECTOR_18 ((uint32_t)18)
386#define FLASH_SECTOR_19 ((uint32_t)19)
387#define FLASH_SECTOR_20 ((uint32_t)20)
388#define FLASH_SECTOR_21 ((uint32_t)21)
389#define FLASH_SECTOR_22 ((uint32_t)22)
390#define FLASH_SECTOR_23 ((uint32_t)23)
395#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
396#define FLASH_SECTOR_0 ((uint32_t)0)
397#define FLASH_SECTOR_1 ((uint32_t)1)
398#define FLASH_SECTOR_2 ((uint32_t)2)
399#define FLASH_SECTOR_3 ((uint32_t)3)
400#define FLASH_SECTOR_4 ((uint32_t)4)
401#define FLASH_SECTOR_5 ((uint32_t)5)
402#define FLASH_SECTOR_6 ((uint32_t)6)
403#define FLASH_SECTOR_7 ((uint32_t)7)
404#define FLASH_SECTOR_8 ((uint32_t)8)
405#define FLASH_SECTOR_9 ((uint32_t)9)
406#define FLASH_SECTOR_10 ((uint32_t)10)
407#define FLASH_SECTOR_11 ((uint32_t)11)
412#if defined(STM32F401xC)
413#define FLASH_SECTOR_0 ((uint32_t)0)
414#define FLASH_SECTOR_1 ((uint32_t)1)
415#define FLASH_SECTOR_2 ((uint32_t)2)
416#define FLASH_SECTOR_3 ((uint32_t)3)
417#define FLASH_SECTOR_4 ((uint32_t)4)
418#define FLASH_SECTOR_5 ((uint32_t)5)
423#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
424#define FLASH_SECTOR_0 ((uint32_t)0)
425#define FLASH_SECTOR_1 ((uint32_t)1)
426#define FLASH_SECTOR_2 ((uint32_t)2)
427#define FLASH_SECTOR_3 ((uint32_t)3)
428#define FLASH_SECTOR_4 ((uint32_t)4)
433#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
434#define FLASH_SECTOR_0 ((uint32_t)0)
435#define FLASH_SECTOR_1 ((uint32_t)1)
436#define FLASH_SECTOR_2 ((uint32_t)2)
437#define FLASH_SECTOR_3 ((uint32_t)3)
438#define FLASH_SECTOR_4 ((uint32_t)4)
439#define FLASH_SECTOR_5 ((uint32_t)5)
440#define FLASH_SECTOR_6 ((uint32_t)6)
441#define FLASH_SECTOR_7 ((uint32_t)7)
453#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
454 defined(STM32F469xx) || defined(STM32F479xx)
455#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001)
456#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002)
457#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004)
458#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008)
459#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010)
460#define OB_WRP_SECTOR_5 ((uint32_t)0x00000020)
461#define OB_WRP_SECTOR_6 ((uint32_t)0x00000040)
462#define OB_WRP_SECTOR_7 ((uint32_t)0x00000080)
463#define OB_WRP_SECTOR_8 ((uint32_t)0x00000100)
464#define OB_WRP_SECTOR_9 ((uint32_t)0x00000200)
465#define OB_WRP_SECTOR_10 ((uint32_t)0x00000400)
466#define OB_WRP_SECTOR_11 ((uint32_t)0x00000800)
467#define OB_WRP_SECTOR_12 ((uint32_t)0x00000001 << 12)
468#define OB_WRP_SECTOR_13 ((uint32_t)0x00000002 << 12)
469#define OB_WRP_SECTOR_14 ((uint32_t)0x00000004 << 12)
470#define OB_WRP_SECTOR_15 ((uint32_t)0x00000008 << 12)
471#define OB_WRP_SECTOR_16 ((uint32_t)0x00000010 << 12)
472#define OB_WRP_SECTOR_17 ((uint32_t)0x00000020 << 12)
473#define OB_WRP_SECTOR_18 ((uint32_t)0x00000040 << 12)
474#define OB_WRP_SECTOR_19 ((uint32_t)0x00000080 << 12)
475#define OB_WRP_SECTOR_20 ((uint32_t)0x00000100 << 12)
476#define OB_WRP_SECTOR_21 ((uint32_t)0x00000200 << 12)
477#define OB_WRP_SECTOR_22 ((uint32_t)0x00000400 << 12)
478#define OB_WRP_SECTOR_23 ((uint32_t)0x00000800 << 12)
479#define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF << 12)
484#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
485#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001)
486#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002)
487#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004)
488#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008)
489#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010)
490#define OB_WRP_SECTOR_5 ((uint32_t)0x00000020)
491#define OB_WRP_SECTOR_6 ((uint32_t)0x00000040)
492#define OB_WRP_SECTOR_7 ((uint32_t)0x00000080)
493#define OB_WRP_SECTOR_8 ((uint32_t)0x00000100)
494#define OB_WRP_SECTOR_9 ((uint32_t)0x00000200)
495#define OB_WRP_SECTOR_10 ((uint32_t)0x00000400)
496#define OB_WRP_SECTOR_11 ((uint32_t)0x00000800)
497#define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF)
502#if defined(STM32F401xC)
503#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001)
504#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002)
505#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004)
506#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008)
507#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010)
508#define OB_WRP_SECTOR_5 ((uint32_t)0x00000020)
509#define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF)
514#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
515#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001)
516#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002)
517#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004)
518#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008)
519#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010)
520#define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF)
525#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
526#define OB_WRP_SECTOR_0 ((uint32_t)0x00000001)
527#define OB_WRP_SECTOR_1 ((uint32_t)0x00000002)
528#define OB_WRP_SECTOR_2 ((uint32_t)0x00000004)
529#define OB_WRP_SECTOR_3 ((uint32_t)0x00000008)
530#define OB_WRP_SECTOR_4 ((uint32_t)0x00000010)
531#define OB_WRP_SECTOR_5 ((uint32_t)0x00000020)
532#define OB_WRP_SECTOR_6 ((uint32_t)0x00000040)
533#define OB_WRP_SECTOR_7 ((uint32_t)0x00000080)
534#define OB_WRP_SECTOR_All ((uint32_t)0x00000FFF)
545#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
546 defined(STM32F469xx) || defined(STM32F479xx)
547#define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001)
548#define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002)
549#define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004)
550#define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008)
551#define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010)
552#define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020)
553#define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040)
554#define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080)
555#define OB_PCROP_SECTOR_8 ((uint32_t)0x00000100)
556#define OB_PCROP_SECTOR_9 ((uint32_t)0x00000200)
557#define OB_PCROP_SECTOR_10 ((uint32_t)0x00000400)
558#define OB_PCROP_SECTOR_11 ((uint32_t)0x00000800)
559#define OB_PCROP_SECTOR_12 ((uint32_t)0x00000001)
560#define OB_PCROP_SECTOR_13 ((uint32_t)0x00000002)
561#define OB_PCROP_SECTOR_14 ((uint32_t)0x00000004)
562#define OB_PCROP_SECTOR_15 ((uint32_t)0x00000008)
563#define OB_PCROP_SECTOR_16 ((uint32_t)0x00000010)
564#define OB_PCROP_SECTOR_17 ((uint32_t)0x00000020)
565#define OB_PCROP_SECTOR_18 ((uint32_t)0x00000040)
566#define OB_PCROP_SECTOR_19 ((uint32_t)0x00000080)
567#define OB_PCROP_SECTOR_20 ((uint32_t)0x00000100)
568#define OB_PCROP_SECTOR_21 ((uint32_t)0x00000200)
569#define OB_PCROP_SECTOR_22 ((uint32_t)0x00000400)
570#define OB_PCROP_SECTOR_23 ((uint32_t)0x00000800)
571#define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF)
576#if defined(STM32F401xC)
577#define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001)
578#define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002)
579#define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004)
580#define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008)
581#define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010)
582#define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020)
583#define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF)
588#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
589#define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001)
590#define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002)
591#define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004)
592#define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008)
593#define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010)
594#define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF)
599#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
600#define OB_PCROP_SECTOR_0 ((uint32_t)0x00000001)
601#define OB_PCROP_SECTOR_1 ((uint32_t)0x00000002)
602#define OB_PCROP_SECTOR_2 ((uint32_t)0x00000004)
603#define OB_PCROP_SECTOR_3 ((uint32_t)0x00000008)
604#define OB_PCROP_SECTOR_4 ((uint32_t)0x00000010)
605#define OB_PCROP_SECTOR_5 ((uint32_t)0x00000020)
606#define OB_PCROP_SECTOR_6 ((uint32_t)0x00000040)
607#define OB_PCROP_SECTOR_7 ((uint32_t)0x00000080)
608#define OB_PCROP_SECTOR_All ((uint32_t)0x00000FFF)
619#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
620 defined(STM32F469xx) || defined(STM32F479xx)
621#define OB_DUAL_BOOT_ENABLE ((uint8_t)0x10)
622#define OB_DUAL_BOOT_DISABLE ((uint8_t)0x00)
631#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
632 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
633 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
635#define OB_PCROP_DESELECTED ((uint8_t)0x00)
636#define OB_PCROP_SELECTED ((uint8_t)0x80)
658HAL_StatusTypeDef
HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
663#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
664 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
665 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
674#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
675 defined(STM32F469xx) || defined(STM32F479xx)
692#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
693#define FLASH_SECTOR_TOTAL 24
697#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
698#define FLASH_SECTOR_TOTAL 12
702#if defined(STM32F401xC)
703#define FLASH_SECTOR_TOTAL 6
707#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
708#define FLASH_SECTOR_TOTAL 5
712#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
713#define FLASH_SECTOR_TOTAL 8
719#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
720#define OPTCR1_BYTE2_ADDRESS ((uint32_t)0x40023C1A)
736#define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
737 ((VALUE) == FLASH_TYPEERASE_MASSERASE))
739#define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
740 ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
741 ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
742 ((RANGE) == FLASH_VOLTAGE_RANGE_4))
744#define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
745 ((VALUE) == OB_WRPSTATE_ENABLE))
747#define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP|OPTIONBYTE_RDP|OPTIONBYTE_USER|OPTIONBYTE_BOR)))
749#define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
750 ((LEVEL) == OB_RDP_LEVEL_1) ||\
751 ((LEVEL) == OB_RDP_LEVEL_2))
753#define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
755#define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
757#define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
759#define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
760 ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
762#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
763 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
764 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
766#define IS_PCROPSTATE(VALUE)(((VALUE) == OB_PCROP_STATE_DISABLE) || \
767 ((VALUE) == OB_PCROP_STATE_ENABLE))
771#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
772 defined(STM32F469xx) || defined(STM32F479xx)
773#define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP) || \
774 ((VALUE) == OPTIONBYTE_BOOTCONFIG))
777#if defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
778 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
779#define IS_OBEX(VALUE)(((VALUE) == OPTIONBYTE_PCROP))
782#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx) ||\
783 defined(STM32F469xx) || defined(STM32F479xx)
784#define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
785 ((LATENCY) == FLASH_LATENCY_1) || \
786 ((LATENCY) == FLASH_LATENCY_2) || \
787 ((LATENCY) == FLASH_LATENCY_3) || \
788 ((LATENCY) == FLASH_LATENCY_4) || \
789 ((LATENCY) == FLASH_LATENCY_5) || \
790 ((LATENCY) == FLASH_LATENCY_6) || \
791 ((LATENCY) == FLASH_LATENCY_7) || \
792 ((LATENCY) == FLASH_LATENCY_8) || \
793 ((LATENCY) == FLASH_LATENCY_9) || \
794 ((LATENCY) == FLASH_LATENCY_10) || \
795 ((LATENCY) == FLASH_LATENCY_11) || \
796 ((LATENCY) == FLASH_LATENCY_12) || \
797 ((LATENCY) == FLASH_LATENCY_13) || \
798 ((LATENCY) == FLASH_LATENCY_14) || \
799 ((LATENCY) == FLASH_LATENCY_15))
802#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
803 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
804 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
805#define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
806 ((LATENCY) == FLASH_LATENCY_1) || \
807 ((LATENCY) == FLASH_LATENCY_2) || \
808 ((LATENCY) == FLASH_LATENCY_3) || \
809 ((LATENCY) == FLASH_LATENCY_4) || \
810 ((LATENCY) == FLASH_LATENCY_5) || \
811 ((LATENCY) == FLASH_LATENCY_6) || \
812 ((LATENCY) == FLASH_LATENCY_7))
815#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
816#define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
817 ((BANK) == FLASH_BANK_2) || \
818 ((BANK) == FLASH_BANK_BOTH))
821#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) ||\
822 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
823 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx)
824#define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1))
828#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
829#define IS_FLASH_SECTOR(SECTOR) ( ((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
830 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
831 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
832 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
833 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
834 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
835 ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
836 ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
837 ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
838 ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
839 ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
840 ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
843#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
844#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
845 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
846 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
847 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
848 ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
849 ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11))
852#if defined(STM32F401xC)
853#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
854 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
855 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5))
858#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
859#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
860 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
861 ((SECTOR) == FLASH_SECTOR_4))
864#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
865#define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
866 ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
867 ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
868 ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
871#define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END))
872#define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
874#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
875#define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFF000000) == 0x00000000) && ((SECTOR) != 0x00000000))
878#if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx)
879#define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
882#if defined(STM32F401xC)
883#define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
886#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
887#define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
890#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
891#define IS_OB_WRP_SECTOR(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
894#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || defined(STM32F469xx) || defined(STM32F479xx)
895#define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
898#if defined(STM32F401xC)
899#define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
902#if defined(STM32F410Tx) || defined(STM32F410Cx) || defined(STM32F410Rx)
903#define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
906#if defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
907#define IS_OB_PCROP(SECTOR)((((SECTOR) & (uint32_t)0xFFFFF000) == 0x00000000) && ((SECTOR) != 0x00000000))
910#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
911 defined(STM32F469xx) || defined(STM32F479xx)
912#define IS_OB_BOOT(BOOT) (((BOOT) == OB_DUAL_BOOT_ENABLE) || ((BOOT) == OB_DUAL_BOOT_DISABLE))
915#if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
916 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F410Tx) || defined(STM32F410Cx) ||\
917 defined(STM32F410Rx) || defined(STM32F411xE) || defined(STM32F446xx) || defined(STM32F469xx) ||\
919#define IS_OB_PCROP_SELECT(PCROP) (((PCROP) == OB_PCROP_SELECTED) || ((PCROP) == OB_PCROP_DESELECTED))
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit)
Program option bytes.
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError)
Perform a mass erase or erase the specified FLASH memory sectors.
uint16_t HAL_FLASHEx_OB_GetBank2WRP(void)
Returns the FLASH Write Protection Option Bytes value for Bank 2.
void HAL_FLASHEx_AdvOBGetConfig(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit)
Get the OBEX byte configuration.
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit)
Get the Option byte configuration.
HAL_StatusTypeDef HAL_FLASHEx_OB_SelectPCROP(void)
Select the Protection Mode.
HAL_StatusTypeDef HAL_FLASHEx_OB_DeSelectPCROP(void)
Deselect the Protection Mode.
HAL_StatusTypeDef HAL_FLASHEx_AdvOBProgram(FLASH_AdvOBProgramInitTypeDef *pAdvOBInit)
Program option bytes.
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)
Perform a mass erase or erase the specified FLASH memory sectors with interrupt enabled.
void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange)
Erase the specified FLASH memory sector.
This file contains HAL common defines, enumeration, macros and structures definitions.
FLASH Advanced Option Bytes Program structure definition.
FLASH Option Bytes Program structure definition.