STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_flash_ex.h
Go to the documentation of this file.
1 
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_FLASH_EX_H
40 #define __STM32F7xx_HAL_FLASH_EX_H
41 
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45 
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f7xx_hal_def.h"
48 
57 /* Exported types ------------------------------------------------------------*/
65 typedef struct
66 {
67  uint32_t TypeErase;
70 #if defined (FLASH_OPTCR_nDBANK)
71  uint32_t Banks;
73 #endif /* FLASH_OPTCR_nDBANK */
74 
75  uint32_t Sector;
78  uint32_t NbSectors;
81  uint32_t VoltageRange;
85 
89 typedef struct
90 {
91  uint32_t OptionType;
94  uint32_t WRPState;
97  uint32_t WRPSector;
100  uint32_t RDPLevel;
103  uint32_t BORLevel;
106  uint32_t USERConfig;
110  uint32_t BootAddr0;
113  uint32_t BootAddr1;
117 
121 /* Exported constants --------------------------------------------------------*/
122 
130 #define FLASH_TYPEERASE_SECTORS ((uint32_t)0x00U)
131 #define FLASH_TYPEERASE_MASSERASE ((uint32_t)0x01U)
139 #define FLASH_VOLTAGE_RANGE_1 ((uint32_t)0x00U)
140 #define FLASH_VOLTAGE_RANGE_2 ((uint32_t)0x01U)
141 #define FLASH_VOLTAGE_RANGE_3 ((uint32_t)0x02U)
142 #define FLASH_VOLTAGE_RANGE_4 ((uint32_t)0x03U)
150 #define OB_WRPSTATE_DISABLE ((uint32_t)0x00U)
151 #define OB_WRPSTATE_ENABLE ((uint32_t)0x01U)
159 #define OPTIONBYTE_WRP ((uint32_t)0x01U)
160 #define OPTIONBYTE_RDP ((uint32_t)0x02U)
161 #define OPTIONBYTE_USER ((uint32_t)0x04U)
162 #define OPTIONBYTE_BOR ((uint32_t)0x08U)
163 #define OPTIONBYTE_BOOTADDR_0 ((uint32_t)0x10U)
164 #define OPTIONBYTE_BOOTADDR_1 ((uint32_t)0x20U)
172 #define OB_RDP_LEVEL_0 ((uint8_t)0xAAU)
173 #define OB_RDP_LEVEL_1 ((uint8_t)0x55U)
174 #define OB_RDP_LEVEL_2 ((uint8_t)0xCCU)
183 #define OB_WWDG_SW ((uint32_t)0x10U)
184 #define OB_WWDG_HW ((uint32_t)0x00U)
193 #define OB_IWDG_SW ((uint32_t)0x20U)
194 #define OB_IWDG_HW ((uint32_t)0x00U)
202 #define OB_STOP_NO_RST ((uint32_t)0x40U)
203 #define OB_STOP_RST ((uint32_t)0x00U)
211 #define OB_STDBY_NO_RST ((uint32_t)0x80U)
212 #define OB_STDBY_RST ((uint32_t)0x00U)
220 #define OB_IWDG_STOP_FREEZE ((uint32_t)0x00000000U)
221 #define OB_IWDG_STOP_ACTIVE ((uint32_t)0x80000000U)
229 #define OB_IWDG_STDBY_FREEZE ((uint32_t)0x00000000U)
230 #define OB_IWDG_STDBY_ACTIVE ((uint32_t)0x40000000U)
238 #define OB_BOR_LEVEL3 ((uint32_t)0x00U)
239 #define OB_BOR_LEVEL2 ((uint32_t)0x04U)
240 #define OB_BOR_LEVEL1 ((uint32_t)0x08U)
241 #define OB_BOR_OFF ((uint32_t)0x0CU)
246 #if defined (FLASH_OPTCR_nDBOOT)
247 
250 #define OB_DUAL_BOOT_DISABLE ((uint32_t)0x10000000U) /* !< Dual Boot disable. Boot according to boot address option */
251 #define OB_DUAL_BOOT_ENABLE ((uint32_t)0x00000000U) /* !< Dual Boot enable. Boot always from system memory if boot address in flash
252  (Dual bank Boot mode), or RAM if Boot address option in RAM */
253 
256 #endif /* FLASH_OPTCR_nDBOOT */
257 
258 #if defined (FLASH_OPTCR_nDBANK)
259 
262 #define OB_NDBANK_SINGLE_BANK ((uint32_t)0x20000000U)
263 #define OB_NDBANK_DUAL_BANK ((uint32_t)0x00000000U)
267 #endif /* FLASH_OPTCR_nDBANK */
268 
272 #define OB_BOOTADDR_ITCM_RAM ((uint32_t)0x0000U)
273 #define OB_BOOTADDR_SYSTEM ((uint32_t)0x0040U)
274 #define OB_BOOTADDR_ITCM_FLASH ((uint32_t)0x0080U)
275 #define OB_BOOTADDR_AXIM_FLASH ((uint32_t)0x2000U)
276 #define OB_BOOTADDR_DTCM_RAM ((uint32_t)0x8000U)
277 #define OB_BOOTADDR_SRAM1 ((uint32_t)0x8004U)
278 #define OB_BOOTADDR_SRAM2 ((uint32_t)0x8013U)
286 #define FLASH_LATENCY_0 FLASH_ACR_LATENCY_0WS
287 #define FLASH_LATENCY_1 FLASH_ACR_LATENCY_1WS
288 #define FLASH_LATENCY_2 FLASH_ACR_LATENCY_2WS
289 #define FLASH_LATENCY_3 FLASH_ACR_LATENCY_3WS
290 #define FLASH_LATENCY_4 FLASH_ACR_LATENCY_4WS
291 #define FLASH_LATENCY_5 FLASH_ACR_LATENCY_5WS
292 #define FLASH_LATENCY_6 FLASH_ACR_LATENCY_6WS
293 #define FLASH_LATENCY_7 FLASH_ACR_LATENCY_7WS
294 #define FLASH_LATENCY_8 FLASH_ACR_LATENCY_8WS
295 #define FLASH_LATENCY_9 FLASH_ACR_LATENCY_9WS
296 #define FLASH_LATENCY_10 FLASH_ACR_LATENCY_10WS
297 #define FLASH_LATENCY_11 FLASH_ACR_LATENCY_11WS
298 #define FLASH_LATENCY_12 FLASH_ACR_LATENCY_12WS
299 #define FLASH_LATENCY_13 FLASH_ACR_LATENCY_13WS
300 #define FLASH_LATENCY_14 FLASH_ACR_LATENCY_14WS
301 #define FLASH_LATENCY_15 FLASH_ACR_LATENCY_15WS
306 #if defined (FLASH_OPTCR_nDBANK)
307 
310 #define FLASH_BANK_1 ((uint32_t)0x01U)
311 #define FLASH_BANK_2 ((uint32_t)0x02U)
312 #define FLASH_BANK_BOTH ((uint32_t)(FLASH_BANK_1 | FLASH_BANK_2))
316 #endif /* FLASH_OPTCR_nDBANK */
317 
321 #if defined (FLASH_OPTCR_nDBANK)
322 #define FLASH_MER_BIT (FLASH_CR_MER1 | FLASH_CR_MER2)
323 #else
324 #define FLASH_MER_BIT (FLASH_CR_MER)
325 #endif /* FLASH_OPTCR_nDBANK */
326 
333 #if (FLASH_SECTOR_TOTAL == 24)
334 #define FLASH_SECTOR_8 ((uint32_t)8U)
335 #define FLASH_SECTOR_9 ((uint32_t)9U)
336 #define FLASH_SECTOR_10 ((uint32_t)10U)
337 #define FLASH_SECTOR_11 ((uint32_t)11U)
338 #define FLASH_SECTOR_12 ((uint32_t)12U)
339 #define FLASH_SECTOR_13 ((uint32_t)13U)
340 #define FLASH_SECTOR_14 ((uint32_t)14U)
341 #define FLASH_SECTOR_15 ((uint32_t)15U)
342 #define FLASH_SECTOR_16 ((uint32_t)16U)
343 #define FLASH_SECTOR_17 ((uint32_t)17U)
344 #define FLASH_SECTOR_18 ((uint32_t)18U)
345 #define FLASH_SECTOR_19 ((uint32_t)19U)
346 #define FLASH_SECTOR_20 ((uint32_t)20U)
347 #define FLASH_SECTOR_21 ((uint32_t)21U)
348 #define FLASH_SECTOR_22 ((uint32_t)22U)
349 #define FLASH_SECTOR_23 ((uint32_t)23U)
350 #endif /* FLASH_SECTOR_TOTAL == 24 */
351 
355 #if (FLASH_SECTOR_TOTAL == 24)
356 
365 /* Single Bank Sectors */
366 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U)
367 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U)
368 #define OB_WRP_SECTOR_2 ((uint32_t)0x00040000U)
369 #define OB_WRP_SECTOR_3 ((uint32_t)0x00080000U)
370 #define OB_WRP_SECTOR_4 ((uint32_t)0x00100000U)
371 #define OB_WRP_SECTOR_5 ((uint32_t)0x00200000U)
372 #define OB_WRP_SECTOR_6 ((uint32_t)0x00400000U)
373 #define OB_WRP_SECTOR_7 ((uint32_t)0x00800000U)
374 #define OB_WRP_SECTOR_8 ((uint32_t)0x01000000U)
375 #define OB_WRP_SECTOR_9 ((uint32_t)0x02000000U)
376 #define OB_WRP_SECTOR_10 ((uint32_t)0x04000000U)
377 #define OB_WRP_SECTOR_11 ((uint32_t)0x08000000U)
378 #define OB_WRP_SECTOR_All ((uint32_t)0x0FFF0000U)
380 /* Dual Bank Sectors */
381 #define OB_WRP_DB_SECTOR_0 ((uint32_t)0x00010000U)
382 #define OB_WRP_DB_SECTOR_1 ((uint32_t)0x00010000U)
383 #define OB_WRP_DB_SECTOR_2 ((uint32_t)0x00020000U)
384 #define OB_WRP_DB_SECTOR_3 ((uint32_t)0x00020000U)
385 #define OB_WRP_DB_SECTOR_4 ((uint32_t)0x00040000U)
386 #define OB_WRP_DB_SECTOR_5 ((uint32_t)0x00040000U)
387 #define OB_WRP_DB_SECTOR_6 ((uint32_t)0x00080000U)
388 #define OB_WRP_DB_SECTOR_7 ((uint32_t)0x00080000U)
389 #define OB_WRP_DB_SECTOR_8 ((uint32_t)0x00100000U)
390 #define OB_WRP_DB_SECTOR_9 ((uint32_t)0x00100000U)
391 #define OB_WRP_DB_SECTOR_10 ((uint32_t)0x00200000U)
392 #define OB_WRP_DB_SECTOR_11 ((uint32_t)0x00200000U)
393 #define OB_WRP_DB_SECTOR_12 ((uint32_t)0x00400000U)
394 #define OB_WRP_DB_SECTOR_13 ((uint32_t)0x00400000U)
395 #define OB_WRP_DB_SECTOR_14 ((uint32_t)0x00800000U)
396 #define OB_WRP_DB_SECTOR_15 ((uint32_t)0x00800000U)
397 #define OB_WRP_DB_SECTOR_16 ((uint32_t)0x01000000U)
398 #define OB_WRP_DB_SECTOR_17 ((uint32_t)0x01000000U)
399 #define OB_WRP_DB_SECTOR_18 ((uint32_t)0x02000000U)
400 #define OB_WRP_DB_SECTOR_19 ((uint32_t)0x02000000U)
401 #define OB_WRP_DB_SECTOR_20 ((uint32_t)0x04000000U)
402 #define OB_WRP_DB_SECTOR_21 ((uint32_t)0x04000000U)
403 #define OB_WRP_DB_SECTOR_22 ((uint32_t)0x08000000U)
404 #define OB_WRP_DB_SECTOR_23 ((uint32_t)0x08000000U)
405 #define OB_WRP_DB_SECTOR_All ((uint32_t)0x0FFF0000U)
409 #endif /* FLASH_SECTOR_TOTAL == 24 */
410 
411 #if (FLASH_SECTOR_TOTAL == 8)
412 
415 #define OB_WRP_SECTOR_0 ((uint32_t)0x00010000U)
416 #define OB_WRP_SECTOR_1 ((uint32_t)0x00020000U)
417 #define OB_WRP_SECTOR_2 ((uint32_t)0x00040000U)
418 #define OB_WRP_SECTOR_3 ((uint32_t)0x00080000U)
419 #define OB_WRP_SECTOR_4 ((uint32_t)0x00100000U)
420 #define OB_WRP_SECTOR_5 ((uint32_t)0x00200000U)
421 #define OB_WRP_SECTOR_6 ((uint32_t)0x00400000U)
422 #define OB_WRP_SECTOR_7 ((uint32_t)0x00800000U)
423 #define OB_WRP_SECTOR_All ((uint32_t)0x00FF0000U)
427 #endif /* FLASH_SECTOR_TOTAL == 8 */
428 
433 /* Exported macro ------------------------------------------------------------*/
443 #define __HAL_FLASH_CALC_BOOT_BASE_ADR(__ADDRESS__) ((__ADDRESS__) >> 14)
448 /* Exported functions --------------------------------------------------------*/
456 /* Extension Program operation functions *************************************/
457 HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError);
461 
469 /* Private types -------------------------------------------------------------*/
470 /* Private variables ---------------------------------------------------------*/
471 /* Private constants ---------------------------------------------------------*/
472 /* Private macros ------------------------------------------------------------*/
481 #define IS_FLASH_TYPEERASE(VALUE)(((VALUE) == FLASH_TYPEERASE_SECTORS) || \
482  ((VALUE) == FLASH_TYPEERASE_MASSERASE))
483 
484 #define IS_VOLTAGERANGE(RANGE)(((RANGE) == FLASH_VOLTAGE_RANGE_1) || \
485  ((RANGE) == FLASH_VOLTAGE_RANGE_2) || \
486  ((RANGE) == FLASH_VOLTAGE_RANGE_3) || \
487  ((RANGE) == FLASH_VOLTAGE_RANGE_4))
488 
489 #define IS_WRPSTATE(VALUE)(((VALUE) == OB_WRPSTATE_DISABLE) || \
490  ((VALUE) == OB_WRPSTATE_ENABLE))
491 
492 #define IS_OPTIONBYTE(VALUE)(((VALUE) <= (OPTIONBYTE_WRP | OPTIONBYTE_RDP | OPTIONBYTE_USER |\
493  OPTIONBYTE_BOR | OPTIONBYTE_BOOTADDR_0 | OPTIONBYTE_BOOTADDR_1)))
494 
495 #define IS_OB_BOOT_ADDRESS(ADDRESS) ((ADDRESS) <= 0x8013)
497 #define IS_OB_RDP_LEVEL(LEVEL) (((LEVEL) == OB_RDP_LEVEL_0) ||\
498  ((LEVEL) == OB_RDP_LEVEL_1) ||\
499  ((LEVEL) == OB_RDP_LEVEL_2))
500 
501 #define IS_OB_WWDG_SOURCE(SOURCE) (((SOURCE) == OB_WWDG_SW) || ((SOURCE) == OB_WWDG_HW))
503 #define IS_OB_IWDG_SOURCE(SOURCE) (((SOURCE) == OB_IWDG_SW) || ((SOURCE) == OB_IWDG_HW))
505 #define IS_OB_STOP_SOURCE(SOURCE) (((SOURCE) == OB_STOP_NO_RST) || ((SOURCE) == OB_STOP_RST))
507 #define IS_OB_STDBY_SOURCE(SOURCE) (((SOURCE) == OB_STDBY_NO_RST) || ((SOURCE) == OB_STDBY_RST))
509 #define IS_OB_IWDG_STOP_FREEZE(FREEZE) (((FREEZE) == OB_IWDG_STOP_FREEZE) || ((FREEZE) == OB_IWDG_STOP_ACTIVE))
511 #define IS_OB_IWDG_STDBY_FREEZE(FREEZE) (((FREEZE) == OB_IWDG_STDBY_FREEZE) || ((FREEZE) == OB_IWDG_STDBY_ACTIVE))
513 #define IS_OB_BOR_LEVEL(LEVEL) (((LEVEL) == OB_BOR_LEVEL1) || ((LEVEL) == OB_BOR_LEVEL2) ||\
514  ((LEVEL) == OB_BOR_LEVEL3) || ((LEVEL) == OB_BOR_OFF))
515 
516 #define IS_FLASH_LATENCY(LATENCY) (((LATENCY) == FLASH_LATENCY_0) || \
517  ((LATENCY) == FLASH_LATENCY_1) || \
518  ((LATENCY) == FLASH_LATENCY_2) || \
519  ((LATENCY) == FLASH_LATENCY_3) || \
520  ((LATENCY) == FLASH_LATENCY_4) || \
521  ((LATENCY) == FLASH_LATENCY_5) || \
522  ((LATENCY) == FLASH_LATENCY_6) || \
523  ((LATENCY) == FLASH_LATENCY_7) || \
524  ((LATENCY) == FLASH_LATENCY_8) || \
525  ((LATENCY) == FLASH_LATENCY_9) || \
526  ((LATENCY) == FLASH_LATENCY_10) || \
527  ((LATENCY) == FLASH_LATENCY_11) || \
528  ((LATENCY) == FLASH_LATENCY_12) || \
529  ((LATENCY) == FLASH_LATENCY_13) || \
530  ((LATENCY) == FLASH_LATENCY_14) || \
531  ((LATENCY) == FLASH_LATENCY_15))
532 
533 #define IS_FLASH_ADDRESS(ADDRESS) (((ADDRESS) >= FLASH_BASE) && ((ADDRESS) <= FLASH_END))
535 #define IS_FLASH_NBSECTORS(NBSECTORS) (((NBSECTORS) != 0U) && ((NBSECTORS) <= FLASH_SECTOR_TOTAL))
537 #if (FLASH_SECTOR_TOTAL == 8)
538 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
539  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
540  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
541  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7))
542 
543 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & (uint32_t)0xFF00FFFF) == 0x00000000U) && ((SECTOR) != 0x00000000U))
544 #endif /* FLASH_SECTOR_TOTAL == 8 */
545 
546 #if (FLASH_SECTOR_TOTAL == 24)
547 #define IS_FLASH_SECTOR(SECTOR) (((SECTOR) == FLASH_SECTOR_0) || ((SECTOR) == FLASH_SECTOR_1) ||\
548  ((SECTOR) == FLASH_SECTOR_2) || ((SECTOR) == FLASH_SECTOR_3) ||\
549  ((SECTOR) == FLASH_SECTOR_4) || ((SECTOR) == FLASH_SECTOR_5) ||\
550  ((SECTOR) == FLASH_SECTOR_6) || ((SECTOR) == FLASH_SECTOR_7) ||\
551  ((SECTOR) == FLASH_SECTOR_8) || ((SECTOR) == FLASH_SECTOR_9) ||\
552  ((SECTOR) == FLASH_SECTOR_10) || ((SECTOR) == FLASH_SECTOR_11) ||\
553  ((SECTOR) == FLASH_SECTOR_12) || ((SECTOR) == FLASH_SECTOR_13) ||\
554  ((SECTOR) == FLASH_SECTOR_14) || ((SECTOR) == FLASH_SECTOR_15) ||\
555  ((SECTOR) == FLASH_SECTOR_16) || ((SECTOR) == FLASH_SECTOR_17) ||\
556  ((SECTOR) == FLASH_SECTOR_18) || ((SECTOR) == FLASH_SECTOR_19) ||\
557  ((SECTOR) == FLASH_SECTOR_20) || ((SECTOR) == FLASH_SECTOR_21) ||\
558  ((SECTOR) == FLASH_SECTOR_22) || ((SECTOR) == FLASH_SECTOR_23))
559 
560 #define IS_OB_WRP_SECTOR(SECTOR) ((((SECTOR) & (uint32_t)0xF000FFFFU) == 0x00000000U) && ((SECTOR) != 0x00000000U))
561 #endif /* FLASH_SECTOR_TOTAL == 24 */
562 
563 #if defined (FLASH_OPTCR_nDBANK)
564 #define IS_OB_NDBANK(VALUE) (((VALUE) == OB_NDBANK_SINGLE_BANK) || \
565  ((VALUE) == OB_NDBANK_DUAL_BANK))
566 
567 #define IS_FLASH_BANK(BANK) (((BANK) == FLASH_BANK_1) || \
568  ((BANK) == FLASH_BANK_2) || \
569  ((BANK) == FLASH_BANK_BOTH))
570 #endif /* FLASH_OPTCR_nDBANK */
571 
572 #if defined (FLASH_OPTCR_nDBOOT)
573 #define IS_OB_NDBOOT(VALUE) (((VALUE) == OB_DUAL_BOOT_DISABLE) || \
574  ((VALUE) == OB_DUAL_BOOT_ENABLE))
575 #endif /* FLASH_OPTCR_nDBOOT */
576 
585 /* Private functions ---------------------------------------------------------*/
589 void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange);
602 #ifdef __cplusplus
603 }
604 #endif
605 
606 #endif /* __STM32F7xx_HAL_FLASH_EX_H */
607 
608 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void FLASH_Erase_Sector(uint32_t Sector, uint8_t VoltageRange)
FLASH Erase structure definition.
HAL_StatusTypeDef HAL_FLASHEx_Erase(FLASH_EraseInitTypeDef *pEraseInit, uint32_t *SectorError)
HAL_StatusTypeDef HAL_FLASHEx_Erase_IT(FLASH_EraseInitTypeDef *pEraseInit)
void HAL_FLASHEx_OBGetConfig(FLASH_OBProgramInitTypeDef *pOBInit)
HAL_StatusTypeDef HAL_FLASHEx_OBProgram(FLASH_OBProgramInitTypeDef *pOBInit)
This file contains HAL common defines, enumeration, macros and structures definitions.
FLASH Option Bytes Program structure definition.
HAL_StatusTypeDef
HAL Status structures definition.