rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
Functions
Collaboration diagram for FLASH Private Functions:

Functions

static void FLASH_MassErase (uint8_t VoltageRange, uint32_t Banks)
 Full erase of FLASH memory sectors.
 
void FLASH_FlushCaches (void)
 Flush the instruction and data caches.
 
static HAL_StatusTypeDef FLASH_OB_EnableWRP (uint32_t WRPSector, uint32_t Banks)
 Enable the write protection of the desired bank1 or bank 2 sectors.
 
static HAL_StatusTypeDef FLASH_OB_DisableWRP (uint32_t WRPSector, uint32_t Banks)
 Disable the write protection of the desired bank1 or bank 2 sectors.
 
static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig (uint8_t Level)
 Set the read protection level.
 
static HAL_StatusTypeDef FLASH_OB_UserConfig (uint8_t Iwdg, uint8_t Stop, uint8_t Stdby)
 Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

 
static HAL_StatusTypeDef FLASH_OB_BOR_LevelConfig (uint8_t Level)
 Set the BOR Level.
 
static uint8_t FLASH_OB_GetUser (void)
 Return the FLASH User Option Byte value.
 
static uint16_t FLASH_OB_GetWRP (void)
 Return the FLASH Write Protection Option Bytes value.
 
static uint8_t FLASH_OB_GetRDP (void)
 Returns the FLASH Read Protection level.
 
static uint8_t FLASH_OB_GetBOR (void)
 Returns the FLASH BOR level.
 
static HAL_StatusTypeDef FLASH_OB_EnablePCROP (uint32_t Sector)
 Enable the read/write protection (PCROP) of the desired sectors.
 
static HAL_StatusTypeDef FLASH_OB_DisablePCROP (uint32_t Sector)
 Disable the read/write protection (PCROP) of the desired sectors.
 
static HAL_StatusTypeDef FLASH_OB_EnablePCROP (uint32_t SectorBank1, uint32_t SectorBank2, uint32_t Banks)
 Enable the read/write protection (PCROP) of the desired sectors of Bank 1 and/or Bank 2.
 
static HAL_StatusTypeDef FLASH_OB_DisablePCROP (uint32_t SectorBank1, uint32_t SectorBank2, uint32_t Banks)
 Disable the read/write protection (PCROP) of the desired sectors of Bank 1 and/or Bank 2.
 
static HAL_StatusTypeDef FLASH_OB_BootConfig (uint8_t BootConfig)
 Configure the Dual Bank Boot.
 
HAL_StatusTypeDef FLASH_WaitForLastOperation (uint32_t Timeout)
 Wait for a FLASH operation to complete.
 
void FLASH_Erase_Sector (uint32_t Sector, uint8_t VoltageRange)
 Erase the specified FLASH memory sector.
 
static HAL_StatusTypeDef FLASH_OB_EnableWRP (uint32_t WRPSector)
 Enable the write protection of the desired bank1 or bank2 sectors.
 
static HAL_StatusTypeDef FLASH_OB_DisableWRP (uint32_t WRPSector)
 Disable the write protection of the desired bank1 or bank 2 sectors.
 
static HAL_StatusTypeDef FLASH_OB_BootAddressConfig (uint32_t BootOption, uint32_t Address)
 Configure Boot base address.
 
static uint32_t FLASH_OB_GetBootAddress (uint32_t BootOption)
 Configure Boot base address.
 
static HAL_StatusTypeDef FLASH_OB_UserConfig (uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, \ uint32_t Iwdgstdby, uint32_t NDBank, uint32_t NDBoot)
 Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

 
static void FLASH_MassErase (uint8_t VoltageRange)
 Full erase of FLASH memory sectors.
 
static HAL_StatusTypeDef FLASH_OB_UserConfig (uint32_t Wwdg, uint32_t Iwdg, uint32_t Stop, uint32_t Stdby, uint32_t Iwdgstop, uint32_t Iwdgstdby)
 Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

 
static HAL_StatusTypeDef FLASH_OB_PCROP_Config (uint32_t PCROPSector)
 Set the PCROP protection for sectors.
 
static HAL_StatusTypeDef FLASH_OB_PCROP_RDP_Config (uint32_t Pcrop_Rdp)
 Set the PCROP_RDP value.
 
static uint32_t FLASH_OB_GetPCROP (void)
 Return the FLASH PCROP Protection Option Bytes value.
 
static uint32_t FLASH_OB_GetPCROPRDP (void)
 Return the FLASH PCROP_RDP option byte value.
 
static void FLASH_MassErase (uint32_t VoltageRange, uint32_t Banks)
 Mass erase of FLASH memory.
 
static void FLASH_OB_GetWRP (uint32_t *WRPState, uint32_t *WRPSector, uint32_t Bank)
 Get the write protection of the given bank 1 or bank 2 sectors.
 
static void FLASH_OB_RDPConfig (uint32_t RDPLevel)
 Set the read protection level.
 
static void FLASH_OB_PCROPConfig (uint32_t PCROPConfig, uint32_t PCROPStartAddr, uint32_t PCROPEndAddr, uint32_t Banks)
 Configure the Proprietary code readout protection of the desired addresses.
 
static void FLASH_OB_GetPCROP (uint32_t *PCROPConfig, uint32_t *PCROPStartAddr, uint32_t *PCROPEndAddr, uint32_t Bank)
 Get the Proprietary code readout protection configuration on a given Bank.
 
static void FLASH_OB_BOR_LevelConfig (uint32_t Level)
 Set the BOR Level.
 
static void FLASH_OB_UserConfig (uint32_t UserType, uint32_t UserConfig)
 Program the FLASH User Option Byte.
 
static void FLASH_OB_BootAddConfig (uint32_t BootOption, uint32_t BootAddress0, uint32_t BootAddress1)
 Set Boot address.
 
static void FLASH_OB_GetBootAdd (uint32_t *BootAddress0, uint32_t *BootAddress1)
 Get Boot address.
 
static void FLASH_OB_SecureAreaConfig (uint32_t SecureAreaConfig, uint32_t SecureAreaStartAddr, uint32_t SecureAreaEndAddr, uint32_t Banks)
 Set secure area configuration.
 
static void FLASH_OB_GetSecureArea (uint32_t *SecureAreaConfig, uint32_t *SecureAreaStartAddr, uint32_t *SecureAreaEndAddr, uint32_t Bank)
 Get secure area configuration.
 
static void FLASH_CRC_AddSector (uint32_t Sector, uint32_t Bank)
 Add a CRC sector to the list of sectors on which the CRC will be calculated.
 
static void FLASH_CRC_SelectAddress (uint32_t CRCStartAddr, uint32_t CRCEndAddr, uint32_t Bank)
 Select CRC start and end memory addresses on which the CRC will be calculated.
 
static void FLASH_OB_CM4BootAddConfig (uint32_t BootOption, uint32_t BootAddress0, uint32_t BootAddress1)
 Set CM4 Boot address.
 
static void FLASH_OB_GetCM4BootAdd (uint32_t *BootAddress0, uint32_t *BootAddress1)
 Get CM4 Boot address.
 
static void FLASH_OB_OTP_LockConfig (uint32_t OTP_Block)
 Configure the OTP Block Lock.
 
static uint32_t FLASH_OB_OTP_GetLock (void)
 Get the OTP Block Lock.
 
static void FLASH_OB_SharedRAM_Config (uint32_t SharedRamConfig)
 Configure the TCM / AXI Shared RAM.
 
static uint32_t FLASH_OB_SharedRAM_GetConfig (void)
 Get the TCM / AXI Shared RAM configurtion.
 
static void FLASH_OB_CPUFreq_BoostConfig (uint32_t FreqBoost)
 Configure the CPU Frequency Boost.
 
static uint32_t FLASH_OB_CPUFreq_GetBoost (void)
 Get the CPU Frequency Boost state.
 
void FLASH_Erase_Sector (uint32_t Sector, uint32_t Banks, uint32_t VoltageRange)
 Erase the specified FLASH memory sector.
 

Detailed Description

Function Documentation

◆ FLASH_CRC_AddSector()

static void FLASH_CRC_AddSector ( uint32_t  Sector,
uint32_t  Bank 
)
static

Add a CRC sector to the list of sectors on which the CRC will be calculated.

Parameters
SectorSpecifies the CRC sector number
BankSpecifies the Bank
Return values
None

Definition at line 1719 of file stm32h7xx_hal_flash_ex.c.

1720{
1721 /* Check the parameters */
1722 assert_param(IS_FLASH_SECTOR(Sector));
1723
1724 if (Bank == FLASH_BANK_1)
1725 {
1726 /* Clear CRC sector */
1727 FLASH->CRCCR1 &= (~FLASH_CRCCR_CRC_SECT);
1728
1729 /* Select CRC Sector and activate ADD_SECT bit */
1730 FLASH->CRCCR1 |= Sector | FLASH_CRCCR_ADD_SECT;
1731 }
1732#if defined (DUAL_BANK)
1733 else
1734 {
1735 /* Clear CRC sector */
1736 FLASH->CRCCR2 &= (~FLASH_CRCCR_CRC_SECT);
1737
1738 /* Select CRC Sector and activate ADD_SECT bit */
1739 FLASH->CRCCR2 |= Sector | FLASH_CRCCR_ADD_SECT;
1740 }
1741#endif /* DUAL_BANK */
1742}

Referenced by HAL_FLASHEx_ComputeCRC().

Here is the caller graph for this function:

◆ FLASH_CRC_SelectAddress()

static void FLASH_CRC_SelectAddress ( uint32_t  CRCStartAddr,
uint32_t  CRCEndAddr,
uint32_t  Bank 
)
static

Select CRC start and end memory addresses on which the CRC will be calculated.

Parameters
CRCStartAddrSpecifies the CRC start address
CRCEndAddrSpecifies the CRC end address
BankSpecifies the Bank
Return values
None

Definition at line 1751 of file stm32h7xx_hal_flash_ex.c.

1752{
1753 if (Bank == FLASH_BANK_1)
1754 {
1755 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(CRCStartAddr));
1756 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(CRCEndAddr));
1757
1758 /* Write CRC Start and End addresses */
1759 FLASH->CRCSADD1 = CRCStartAddr;
1760 FLASH->CRCEADD1 = CRCEndAddr;
1761 }
1762#if defined (DUAL_BANK)
1763 else
1764 {
1765 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(CRCStartAddr));
1766 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(CRCEndAddr));
1767
1768 /* Write CRC Start and End addresses */
1769 FLASH->CRCSADD2 = CRCStartAddr;
1770 FLASH->CRCEADD2 = CRCEndAddr;
1771 }
1772#endif /* DUAL_BANK */
1773}

Referenced by HAL_FLASHEx_ComputeCRC().

Here is the caller graph for this function:

◆ FLASH_Erase_Sector() [1/2]

void FLASH_Erase_Sector ( uint32_t  Sector,
uint32_t  Banks,
uint32_t  VoltageRange 
)

Erase the specified FLASH memory sector.

Parameters
SectorFLASH sector to erase This parameter can be a value of FLASH Sectors
BanksBanks to be erased This parameter can be one of the following values:
  • FLASH_BANK_1: Bank1 to be erased
  • FLASH_BANK_2: Bank2 to be erased
  • FLASH_BANK_BOTH: Bank1 and Bank2 to be erased
VoltageRangeThe device program/erase parallelism. This parameter can be one of the following values:
  • FLASH_VOLTAGE_RANGE_1 : Flash program/erase by 8 bits
  • FLASH_VOLTAGE_RANGE_2 : Flash program/erase by 16 bits
  • FLASH_VOLTAGE_RANGE_3 : Flash program/erase by 32 bits
  • FLASH_VOLTAGE_RANGE_4 : Flash program/erase by 64 bits
Return values
None

Definition at line 933 of file stm32h7xx_hal_flash_ex.c.

934{
935 assert_param(IS_FLASH_SECTOR(Sector));
936 assert_param(IS_FLASH_BANK_EXCLUSIVE(Banks));
937#if defined (FLASH_CR_PSIZE)
938 assert_param(IS_VOLTAGERANGE(VoltageRange));
939#else
940 UNUSED(VoltageRange);
941#endif /* FLASH_CR_PSIZE */
942
943 if((Banks & FLASH_BANK_1) == FLASH_BANK_1)
944 {
945#if defined (FLASH_CR_PSIZE)
946 /* Reset Program/erase VoltageRange and Sector Number for Bank1 */
947 FLASH->CR1 &= ~(FLASH_CR_PSIZE | FLASH_CR_SNB);
948
949 FLASH->CR1 |= (FLASH_CR_SER | VoltageRange | (Sector << FLASH_CR_SNB_Pos) | FLASH_CR_START);
950#else
951 /* Reset Sector Number for Bank1 */
952 FLASH->CR1 &= ~(FLASH_CR_SNB);
953
954 FLASH->CR1 |= (FLASH_CR_SER | (Sector << FLASH_CR_SNB_Pos) | FLASH_CR_START);
955#endif /* FLASH_CR_PSIZE */
956 }
957
958#if defined (DUAL_BANK)
959 if((Banks & FLASH_BANK_2) == FLASH_BANK_2)
960 {
961#if defined (FLASH_CR_PSIZE)
962 /* Reset Program/erase VoltageRange and Sector Number for Bank2 */
963 FLASH->CR2 &= ~(FLASH_CR_PSIZE | FLASH_CR_SNB);
964
965 FLASH->CR2 |= (FLASH_CR_SER | VoltageRange | (Sector << FLASH_CR_SNB_Pos) | FLASH_CR_START);
966#else
967 /* Reset Sector Number for Bank2 */
968 FLASH->CR2 &= ~(FLASH_CR_SNB);
969
970 FLASH->CR2 |= (FLASH_CR_SER | (Sector << FLASH_CR_SNB_Pos) | FLASH_CR_START);
971#endif /* FLASH_CR_PSIZE */
972 }
973#endif /* DUAL_BANK */
974}
UNUSED(samplingTimeSeconds)
Here is the call graph for this function:

◆ FLASH_Erase_Sector() [2/2]

void FLASH_Erase_Sector ( uint32_t  Sector,
uint8_t  VoltageRange 
)

Erase the specified FLASH memory sector.

Parameters
SectorFLASH sector to erase The value of this parameter depend on device used within the same series
VoltageRangeThe device voltage range which defines the erase parallelism.
This parameter can be one of the following values:
  • FLASH_VOLTAGE_RANGE_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • FLASH_VOLTAGE_RANGE_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • FLASH_VOLTAGE_RANGE_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • FLASH_VOLTAGE_RANGE_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values
None

Definition at line 637 of file stm32f4xx_hal_flash_ex.c.

638{
639 uint32_t tmp_psize = 0;
640
641 /* Check the parameters */
642 assert_param(IS_FLASH_SECTOR(Sector));
643 assert_param(IS_VOLTAGERANGE(VoltageRange));
644
645 if(VoltageRange == FLASH_VOLTAGE_RANGE_1)
646 {
647 tmp_psize = FLASH_PSIZE_BYTE;
648 }
649 else if(VoltageRange == FLASH_VOLTAGE_RANGE_2)
650 {
651 tmp_psize = FLASH_PSIZE_HALF_WORD;
652 }
653 else if(VoltageRange == FLASH_VOLTAGE_RANGE_3)
654 {
655 tmp_psize = FLASH_PSIZE_WORD;
656 }
657 else
658 {
659 tmp_psize = FLASH_PSIZE_DOUBLE_WORD;
660 }
661
662 /* Need to add offset of 4 when sector higher than FLASH_SECTOR_11 */
663 if(Sector > FLASH_SECTOR_11)
664 {
665 Sector += 4;
666 }
667 /* If the previous operation is completed, proceed to erase the sector */
668 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
669 FLASH->CR |= tmp_psize;
670 CLEAR_BIT(FLASH->CR, FLASH_CR_SNB);
671 FLASH->CR |= FLASH_CR_SER | (Sector << POSITION_VAL(FLASH_CR_SNB));
672 FLASH->CR |= FLASH_CR_STRT;
673}

Referenced by HAL_FLASH_IRQHandler(), HAL_FLASHEx_Erase(), and HAL_FLASHEx_Erase_IT().

Here is the caller graph for this function:

◆ FLASH_FlushCaches()

void FLASH_FlushCaches ( void  )

Flush the instruction and data caches.

Return values
None

Definition at line 370 of file stm32f4xx_hal_flash_ex.c.

371{
372 /* Flush instruction cache */
373 if(READ_BIT(FLASH->ACR, FLASH_ACR_ICEN))
374 {
375 /* Disable instruction cache */
376 __HAL_FLASH_INSTRUCTION_CACHE_DISABLE();
377 /* Reset instruction cache */
378 __HAL_FLASH_INSTRUCTION_CACHE_RESET();
379 /* Enable instruction cache */
380 __HAL_FLASH_INSTRUCTION_CACHE_ENABLE();
381 }
382
383 /* Flush data cache */
384 if(READ_BIT(FLASH->ACR, FLASH_ACR_DCEN))
385 {
386 /* Disable data cache */
387 __HAL_FLASH_DATA_CACHE_DISABLE();
388 /* Reset data cache */
389 __HAL_FLASH_DATA_CACHE_RESET();
390 /* Enable data cache */
391 __HAL_FLASH_DATA_CACHE_ENABLE();
392 }
393}

Referenced by HAL_FLASH_IRQHandler(), and HAL_FLASHEx_Erase().

Here is the caller graph for this function:

◆ FLASH_MassErase() [1/3]

static void FLASH_MassErase ( uint32_t  VoltageRange,
uint32_t  Banks 
)
static

Mass erase of FLASH memory.

Parameters
VoltageRangeThe device program/erase parallelism. This parameter can be one of the following values:
  • FLASH_VOLTAGE_RANGE_1 : Flash program/erase by 8 bits
  • FLASH_VOLTAGE_RANGE_2 : Flash program/erase by 16 bits
  • FLASH_VOLTAGE_RANGE_3 : Flash program/erase by 32 bits
  • FLASH_VOLTAGE_RANGE_4 : Flash program/erase by 64 bits
BanksBanks to be erased This parameter can be one of the following values:
  • FLASH_BANK_1: Bank1 to be erased
  • FLASH_BANK_2: Bank2 to be erased
  • FLASH_BANK_BOTH: Bank1 and Bank2 to be erased
Return values
HALStatus

Definition at line 856 of file stm32h7xx_hal_flash_ex.c.

857{
858 /* Check the parameters */
859#if defined (FLASH_CR_PSIZE)
860 assert_param(IS_VOLTAGERANGE(VoltageRange));
861#else
862 UNUSED(VoltageRange);
863#endif /* FLASH_CR_PSIZE */
864 assert_param(IS_FLASH_BANK(Banks));
865
866#if defined (DUAL_BANK)
867 /* Flash Mass Erase */
868 if((Banks & FLASH_BANK_BOTH) == FLASH_BANK_BOTH)
869 {
870#if defined (FLASH_CR_PSIZE)
871 /* Reset Program/erase VoltageRange for Bank1 and Bank2 */
872 FLASH->CR1 &= (~FLASH_CR_PSIZE);
873 FLASH->CR2 &= (~FLASH_CR_PSIZE);
874
875 /* Set voltage range */
876 FLASH->CR1 |= VoltageRange;
877 FLASH->CR2 |= VoltageRange;
878#endif /* FLASH_CR_PSIZE */
879
880 /* Set Mass Erase Bit */
881 FLASH->OPTCR |= FLASH_OPTCR_MER;
882 }
883 else
884#endif /* DUAL_BANK */
885 {
886 /* Proceed to erase Flash Bank */
887 if((Banks & FLASH_BANK_1) == FLASH_BANK_1)
888 {
889#if defined (FLASH_CR_PSIZE)
890 /* Set Program/erase VoltageRange for Bank1 */
891 FLASH->CR1 &= (~FLASH_CR_PSIZE);
892 FLASH->CR1 |= VoltageRange;
893#endif /* FLASH_CR_PSIZE */
894
895 /* Erase Bank1 */
896 FLASH->CR1 |= (FLASH_CR_BER | FLASH_CR_START);
897 }
898
899#if defined (DUAL_BANK)
900 if((Banks & FLASH_BANK_2) == FLASH_BANK_2)
901 {
902#if defined (FLASH_CR_PSIZE)
903 /* Set Program/erase VoltageRange for Bank2 */
904 FLASH->CR2 &= (~FLASH_CR_PSIZE);
905 FLASH->CR2 |= VoltageRange;
906#endif /* FLASH_CR_PSIZE */
907
908 /* Erase Bank2 */
909 FLASH->CR2 |= (FLASH_CR_BER | FLASH_CR_START);
910 }
911#endif /* DUAL_BANK */
912 }
913}
Here is the call graph for this function:

◆ FLASH_MassErase() [2/3]

static void FLASH_MassErase ( uint8_t  VoltageRange)
static

Full erase of FLASH memory sectors.

Parameters
VoltageRangeThe device voltage range which defines the erase parallelism.
This parameter can be one of the following values:
  • VOLTAGE_RANGE_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • VOLTAGE_RANGE_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • VOLTAGE_RANGE_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • VOLTAGE_RANGE_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
Return values
HALStatus

Definition at line 665 of file stm32f7xx_hal_flash_ex.c.

666{
667 /* Check the parameters */
668 assert_param(IS_VOLTAGERANGE(VoltageRange));
669
670 /* if the previous operation is completed, proceed to erase all sectors */
671 FLASH->CR &= CR_PSIZE_MASK;
672 FLASH->CR |= FLASH_CR_MER;
673 FLASH->CR |= FLASH_CR_STRT | ((uint32_t)VoltageRange <<8);
674 /* Data synchronous Barrier (DSB) Just after the write operation
675 This will force the CPU to respect the sequence of instruction (no optimization).*/
676 __DSB();
677}

◆ FLASH_MassErase() [3/3]

static void FLASH_MassErase ( uint8_t  VoltageRange,
uint32_t  Banks 
)
static

Full erase of FLASH memory sectors.

Mass erase of FLASH memory.

Parameters
VoltageRangeThe device voltage range which defines the erase parallelism.
This parameter can be one of the following values:
  • FLASH_VOLTAGE_RANGE_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • FLASH_VOLTAGE_RANGE_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • FLASH_VOLTAGE_RANGE_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • FLASH_VOLTAGE_RANGE_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
BanksBanks to be erased This parameter can be one of the following values:
  • FLASH_BANK_1: Bank1 to be erased
  • FLASH_BANK_2: Bank2 to be erased
  • FLASH_BANK_BOTH: Bank1 and Bank2 to be erased
Return values
HALStatus
Parameters
VoltageRangeThe device voltage range which defines the erase parallelism.
This parameter can be one of the following values:
  • FLASH_VOLTAGE_RANGE_1: when the device voltage range is 1.8V to 2.1V, the operation will be done by byte (8-bit)
  • FLASH_VOLTAGE_RANGE_2: when the device voltage range is 2.1V to 2.7V, the operation will be done by half word (16-bit)
  • FLASH_VOLTAGE_RANGE_3: when the device voltage range is 2.7V to 3.6V, the operation will be done by word (32-bit)
  • FLASH_VOLTAGE_RANGE_4: when the device voltage range is 2.7V to 3.6V + External Vpp, the operation will be done by double word (64-bit)
BanksBanks to be erased This parameter can be one of the following values:
  • FLASH_BANK_1: Bank1 to be erased
Return values
None

Definition at line 591 of file stm32f4xx_hal_flash_ex.c.

592{
593 uint32_t tmp_psize = 0;
594
595 /* Check the parameters */
596 assert_param(IS_VOLTAGERANGE(VoltageRange));
597 assert_param(IS_FLASH_BANK(Banks));
598
599 /* if the previous operation is completed, proceed to erase all sectors */
600 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
601 FLASH->CR |= tmp_psize;
602 if(Banks == FLASH_BANK_BOTH)
603 {
604 /* bank1 & bank2 will be erased*/
605 FLASH->CR |= FLASH_MER_BIT;
606 }
607 else if(Banks == FLASH_BANK_1)
608 {
609 /*Only bank1 will be erased*/
610 FLASH->CR |= FLASH_CR_MER1;
611 }
612 else
613 {
614 /*Only bank2 will be erased*/
615 FLASH->CR |= FLASH_CR_MER2;
616 }
617 FLASH->CR |= FLASH_CR_STRT;
618}

Referenced by HAL_FLASHEx_Erase(), and HAL_FLASHEx_Erase_IT().

Here is the caller graph for this function:

◆ FLASH_OB_BootAddConfig()

static void FLASH_OB_BootAddConfig ( uint32_t  BootOption,
uint32_t  BootAddress0,
uint32_t  BootAddress1 
)
static

Set Boot address.

Parameters
BootOptionBoot address option byte to be programmed, This parameter must be a value of FLASHEx OB BOOT OPTION (OB_BOOT_ADD0, OB_BOOT_ADD1 or OB_BOOT_ADD_BOTH)
BootAddress0Specifies the Boot Address 0
BootAddress1Specifies the Boot Address 1
Return values
HALStatus

Definition at line 1522 of file stm32h7xx_hal_flash_ex.c.

1523{
1524 /* Check the parameters */
1525 assert_param(IS_OB_BOOT_ADD_OPTION(BootOption));
1526
1527 if((BootOption & OB_BOOT_ADD0) == OB_BOOT_ADD0)
1528 {
1529 /* Check the parameters */
1530 assert_param(IS_BOOT_ADDRESS(BootAddress0));
1531
1532 /* Configure CM7 BOOT ADD0 */
1533#if defined(DUAL_CORE)
1534 MODIFY_REG(FLASH->BOOT7_PRG, FLASH_BOOT7_BCM7_ADD0, (BootAddress0 >> 16));
1535#else /* Single Core*/
1536 MODIFY_REG(FLASH->BOOT_PRG, FLASH_BOOT_ADD0, (BootAddress0 >> 16));
1537#endif /* DUAL_CORE */
1538 }
1539
1540 if((BootOption & OB_BOOT_ADD1) == OB_BOOT_ADD1)
1541 {
1542 /* Check the parameters */
1543 assert_param(IS_BOOT_ADDRESS(BootAddress1));
1544
1545 /* Configure CM7 BOOT ADD1 */
1546#if defined(DUAL_CORE)
1547 MODIFY_REG(FLASH->BOOT7_PRG, FLASH_BOOT7_BCM7_ADD1, BootAddress1);
1548#else /* Single Core*/
1549 MODIFY_REG(FLASH->BOOT_PRG, FLASH_BOOT_ADD1, BootAddress1);
1550#endif /* DUAL_CORE */
1551 }
1552}

◆ FLASH_OB_BootAddressConfig()

static HAL_StatusTypeDef FLASH_OB_BootAddressConfig ( uint32_t  BootOption,
uint32_t  Address 
)
static

Configure Boot base address.

Parameters
BootOption: specifies Boot base address depending from Boot pin = 0 or pin = 1 This parameter can be one of the following values:
  • OPTIONBYTE_BOOTADDR_0 : Boot address based when Boot pin = 0
  • OPTIONBYTE_BOOTADDR_1 : Boot address based when Boot pin = 1
Addressspecifies Boot base address This parameter can be one of the following values:
  • OB_BOOTADDR_ITCM_RAM : Boot from ITCM RAM (0x00000000)
  • OB_BOOTADDR_SYSTEM : Boot from System memory bootloader (0x00100000)
  • OB_BOOTADDR_ITCM_FLASH : Boot from Flash on ITCM interface (0x00200000)
  • OB_BOOTADDR_AXIM_FLASH : Boot from Flash on AXIM interface (0x08000000)
  • OB_BOOTADDR_DTCM_RAM : Boot from DTCM RAM (0x20000000)
  • OB_BOOTADDR_SRAM1 : Boot from SRAM1 (0x20010000)
  • OB_BOOTADDR_SRAM2 : Boot from SRAM2 (0x2004C000)
Return values
HALStatus

Definition at line 958 of file stm32f7xx_hal_flash_ex.c.

959{
960 HAL_StatusTypeDef status = HAL_OK;
961
962 /* Check the parameters */
963 assert_param(IS_OB_BOOT_ADDRESS(Address));
964
965 /* Wait for last operation to be completed */
966 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
967
968 if(status == HAL_OK)
969 {
970 if(BootOption == OPTIONBYTE_BOOTADDR_0)
971 {
972 MODIFY_REG(FLASH->OPTCR1, FLASH_OPTCR1_BOOT_ADD0, Address);
973 }
974 else
975 {
976 MODIFY_REG(FLASH->OPTCR1, FLASH_OPTCR1_BOOT_ADD1, (Address << 16));
977 }
978 }
979
980 return status;
981}
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
Wait for a FLASH operation to complete.
Here is the call graph for this function:

◆ FLASH_OB_BootConfig()

static HAL_StatusTypeDef FLASH_OB_BootConfig ( uint8_t  BootConfig)
static

Configure the Dual Bank Boot.

Note
This function can be used only for STM32F42xxx/43xxx devices.
Parameters
BootConfigspecifies the Dual Bank Boot Option byte. This parameter can be one of the following values:
  • OB_Dual_BootEnabled: Dual Bank Boot Enable
  • OB_Dual_BootDisabled: Dual Bank Boot Disabled
Return values
None

Definition at line 829 of file stm32f4xx_hal_flash_ex.c.

830{
831 HAL_StatusTypeDef status = HAL_OK;
832
833 /* Check the parameters */
834 assert_param(IS_OB_BOOT(BootConfig));
835
836 /* Wait for last operation to be completed */
837 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
838
839 if(status == HAL_OK)
840 {
841 /* Set Dual Bank Boot */
842 *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS &= (~FLASH_OPTCR_BFB2);
843 *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= BootConfig;
844 }
845
846 return status;
847}
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
Wait for a FLASH operation to complete.

Referenced by HAL_FLASHEx_AdvOBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_BOR_LevelConfig() [1/2]

static void FLASH_OB_BOR_LevelConfig ( uint32_t  Level)
static

Set the BOR Level.

Parameters
Levelspecifies the Option Bytes BOR Reset Level. This parameter can be one of the following values:
  • OB_BOR_LEVEL0: Reset level threshold is set to 1.6V
  • OB_BOR_LEVEL1: Reset level threshold is set to 2.1V
  • OB_BOR_LEVEL2: Reset level threshold is set to 2.4V
  • OB_BOR_LEVEL3: Reset level threshold is set to 2.7V
Return values
None

Definition at line 1490 of file stm32h7xx_hal_flash_ex.c.

1491{
1492 assert_param(IS_OB_BOR_LEVEL(Level));
1493
1494 /* Configure BOR_LEV option byte */
1495 MODIFY_REG(FLASH->OPTSR_PRG, FLASH_OPTSR_BOR_LEV, Level);
1496}

◆ FLASH_OB_BOR_LevelConfig() [2/2]

static HAL_StatusTypeDef FLASH_OB_BOR_LevelConfig ( uint8_t  Level)
static

Set the BOR Level.

Parameters
Levelspecifies the Option Bytes BOR Reset Level. This parameter can be one of the following values:
  • OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V
  • OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V
  • OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V
  • OB_BOR_OFF: Supply voltage ranges from 1.62 to 2.1 V
Return values
HALStatus

Definition at line 1287 of file stm32f4xx_hal_flash_ex.c.

1288{
1289 /* Check the parameters */
1290 assert_param(IS_OB_BOR_LEVEL(Level));
1291
1292 /* Set the BOR Level */
1293 *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS &= (~FLASH_OPTCR_BOR_LEV);
1294 *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS |= Level;
1295
1296 return HAL_OK;
1297
1298}

Referenced by HAL_FLASHEx_OBProgram().

Here is the caller graph for this function:

◆ FLASH_OB_CM4BootAddConfig()

static void FLASH_OB_CM4BootAddConfig ( uint32_t  BootOption,
uint32_t  BootAddress0,
uint32_t  BootAddress1 
)
static

Set CM4 Boot address.

Parameters
BootOptionBoot address option byte to be programmed, This parameter must be a value of FLASHEx OB BOOT OPTION (OB_BOOT_ADD0, OB_BOOT_ADD1 or OB_BOOT_ADD_BOTH)
BootAddress0Specifies the CM4 Boot Address 0.
BootAddress1Specifies the CM4 Boot Address 1.
Return values
HALStatus

Definition at line 1588 of file stm32h7xx_hal_flash_ex.c.

1589{
1590 /* Check the parameters */
1591 assert_param(IS_OB_BOOT_ADD_OPTION(BootOption));
1592
1593 if((BootOption & OB_BOOT_ADD0) == OB_BOOT_ADD0)
1594 {
1595 /* Check the parameters */
1596 assert_param(IS_BOOT_ADDRESS(BootAddress0));
1597
1598 /* Configure CM4 BOOT ADD0 */
1599 MODIFY_REG(FLASH->BOOT4_PRG, FLASH_BOOT4_BCM4_ADD0, (BootAddress0 >> 16));
1600
1601 }
1602
1603 if((BootOption & OB_BOOT_ADD1) == OB_BOOT_ADD1)
1604 {
1605 /* Check the parameters */
1606 assert_param(IS_BOOT_ADDRESS(BootAddress1));
1607
1608 /* Configure CM4 BOOT ADD1 */
1609 MODIFY_REG(FLASH->BOOT4_PRG, FLASH_BOOT4_BCM4_ADD1, BootAddress1);
1610 }
1611}

◆ FLASH_OB_CPUFreq_BoostConfig()

static void FLASH_OB_CPUFreq_BoostConfig ( uint32_t  FreqBoost)
static

Configure the CPU Frequency Boost.

Parameters
FreqBoostspecifies the CPU Frequency Boost state. This parameter can be a value of FLASHEx OB CPUFREQ BOOST
Return values
None

Definition at line 1839 of file stm32h7xx_hal_flash_ex.c.

1840{
1841 /* Check the parameters */
1842 assert_param(IS_OB_USER_CPUFREQ_BOOST(FreqBoost));
1843
1844 /* Configure the CPU Frequency Boost in the option bytes register */
1845 MODIFY_REG(FLASH->OPTSR2_PRG, FLASH_OPTSR2_CPUFREQ_BOOST, FreqBoost);
1846}

◆ FLASH_OB_CPUFreq_GetBoost()

static uint32_t FLASH_OB_CPUFreq_GetBoost ( void  )
static

Get the CPU Frequency Boost state.

Return values
FreqBoostreturns the CPU Frequency Boost state. This return value can be a value of FLASHEx OB CPUFREQ BOOST

Definition at line 1853 of file stm32h7xx_hal_flash_ex.c.

1854{
1855 return (FLASH->OPTSR2_CUR & FLASH_OPTSR2_CPUFREQ_BOOST);;
1856}

◆ FLASH_OB_DisablePCROP() [1/2]

static HAL_StatusTypeDef FLASH_OB_DisablePCROP ( uint32_t  Sector)
static

Disable the read/write protection (PCROP) of the desired sectors.

Note
This function can be used only for STM32F401xx devices.
Parameters
Sectorspecifies the sector(s) to be read/write protected or unprotected. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector5
  • OB_PCROP_Sector_All
Return values
HALStatus

Definition at line 1186 of file stm32f4xx_hal_flash_ex.c.

1187{
1188 HAL_StatusTypeDef status = HAL_OK;
1189
1190 /* Check the parameters */
1191 assert_param(IS_OB_PCROP(Sector));
1192
1193 /* Wait for last operation to be completed */
1194 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1195
1196 if(status == HAL_OK)
1197 {
1198 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~Sector);
1199 }
1200
1201 return status;
1202
1203}

Referenced by HAL_FLASHEx_AdvOBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_DisablePCROP() [2/2]

static HAL_StatusTypeDef FLASH_OB_DisablePCROP ( uint32_t  SectorBank1,
uint32_t  SectorBank2,
uint32_t  Banks 
)
static

Disable the read/write protection (PCROP) of the desired sectors of Bank 1 and/or Bank 2.

Note
This function can be used only for STM32F42xxx/43xxx devices.
Parameters
SectorBank1specifies the sector(s) to be read/write protected or unprotected for bank1. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_SECTOR_0 and OB_PCROP_SECTOR_11
  • OB_PCROP_SECTOR__All
SectorBank2Specifies the sector(s) to be read/write protected or unprotected for bank2. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_SECTOR_12 and OB_PCROP_SECTOR_23
  • OB_PCROP_SECTOR__All
BanksDisable PCROP protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: WRP on all sectors of bank1
  • FLASH_BANK_2: WRP on all sectors of bank2
  • FLASH_BANK_BOTH: WRP on all sectors of bank1 & bank2
Return values
HALStatus

Definition at line 933 of file stm32f4xx_hal_flash_ex.c.

934{
935 HAL_StatusTypeDef status = HAL_OK;
936
937 /* Check the parameters */
938 assert_param(IS_FLASH_BANK(Banks));
939
940 /* Wait for last operation to be completed */
941 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
942
943 if(status == HAL_OK)
944 {
945 if((Banks == FLASH_BANK_1) || (Banks == FLASH_BANK_BOTH))
946 {
947 assert_param(IS_OB_PCROP(SectorBank1));
948 /*Write protection done on sectors of BANK1*/
949 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~SectorBank1);
950 }
951 else
952 {
953 /*Write protection done on sectors of BANK2*/
954 assert_param(IS_OB_PCROP(SectorBank2));
955 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~SectorBank2);
956 }
957
958 /*Write protection on all sector of BANK2*/
959 if(Banks == FLASH_BANK_BOTH)
960 {
961 assert_param(IS_OB_PCROP(SectorBank2));
962 /* Wait for last operation to be completed */
963 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
964
965 if(status == HAL_OK)
966 {
967 /*Write protection done on sectors of BANK2*/
968 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~SectorBank2);
969 }
970 }
971
972 }
973
974 return status;
975
976}
Here is the call graph for this function:

◆ FLASH_OB_DisableWRP() [1/2]

static HAL_StatusTypeDef FLASH_OB_DisableWRP ( uint32_t  WRPSector)
static

Disable the write protection of the desired bank1 or bank 2 sectors.

Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Parameters
WRPSectorspecifies the sector(s) to be write protected. This parameter can be one of the following values:
  • WRPSector: A value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_7 (for STM32F74xxx/STM32F75xxx devices) or a value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_11 (in Single Bank mode for STM32F76xxx/STM32F77xxx devices) or a value between OB_WRP_DB_SECTOR_0 and OB_WRP_DB_SECTOR_23 (in Dual Bank mode for STM32F76xxx/STM32F77xxx devices)
  • OB_WRP_Sector_All
Return values
HALStatus

Definition at line 868 of file stm32f7xx_hal_flash_ex.c.

869{
870 HAL_StatusTypeDef status = HAL_OK;
871
872 /* Check the parameters */
873 assert_param(IS_OB_WRP_SECTOR(WRPSector));
874
875 /* Wait for last operation to be completed */
876 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
877
878 if(status == HAL_OK)
879 {
880 /* Write protection disabled on sectors */
881 FLASH->OPTCR |= (WRPSector);
882 }
883
884 return status;
885}
Here is the call graph for this function:

◆ FLASH_OB_DisableWRP() [2/2]

static void FLASH_OB_DisableWRP ( uint32_t  WRPSector,
uint32_t  Banks 
)
static

Disable the write protection of the desired bank1 or bank 2 sectors.

Disable the write protection of the desired bank 1 sectors.

Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
Parameters
WRPSectorspecifies the sector(s) to be write protected. This parameter can be one of the following values:
  • WRPSector: A value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_23
  • OB_WRP_Sector_All
Note
BANK2 starts from OB_WRP_SECTOR_12
Parameters
BanksDisable write protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: Bank1 to be erased
  • FLASH_BANK_2: Bank2 to be erased
  • FLASH_BANK_BOTH: Bank1 and Bank2 to be erased
Return values
HALStatus
Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
Parameters
WRPSectorspecifies the sector(s) to be write protected. The value of this parameter depend on device used within the same series
BanksEnable write protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: WRP on all sectors of bank1
Return values
HALStatus
Parameters
WRPSectorspecifies the sector(s) to disable write protection. This parameter can be one of the following values:
  • WRPSector: A combination of FLASH_OB_WRP_SECTOR_0 to FLASH_OB_WRP_SECTOR_7 or FLASH_OB_WRP_SECTOR_All
Banksthe specific bank to apply WRP sectors This parameter can be one of the following values:
  • FLASH_BANK_1: disable WRP on specified bank1 sectors
  • FLASH_BANK_2: disable WRP on specified bank2 sectors
  • FLASH_BANK_BOTH: disable WRP on both bank1 and bank2 specified sectors
Return values
HALFLASH State

Definition at line 768 of file stm32f4xx_hal_flash_ex.c.

769{
770 HAL_StatusTypeDef status = HAL_OK;
771
772 /* Check the parameters */
773 assert_param(IS_OB_WRP_SECTOR(WRPSector));
774 assert_param(IS_FLASH_BANK(Banks));
775
776 /* Wait for last operation to be completed */
777 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
778
779 if(status == HAL_OK)
780 {
781 if(((WRPSector == OB_WRP_SECTOR_All) && ((Banks == FLASH_BANK_1) || (Banks == FLASH_BANK_BOTH))) ||
782 (WRPSector < OB_WRP_SECTOR_12))
783 {
784 if(WRPSector == OB_WRP_SECTOR_All)
785 {
786 /*Write protection on all sector of BANK1*/
787 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)(WRPSector>>12);
788 }
789 else
790 {
791 /*Write protection done on sectors of BANK1*/
792 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)WRPSector;
793 }
794 }
795 else
796 {
797 /*Write protection done on sectors of BANK2*/
798 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)(WRPSector>>12);
799 }
800
801 /*Write protection on all sector of BANK2*/
802 if((WRPSector == OB_WRP_SECTOR_All) && (Banks == FLASH_BANK_BOTH))
803 {
804 /* Wait for last operation to be completed */
805 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
806
807 if(status == HAL_OK)
808 {
809 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)(WRPSector>>12);
810 }
811 }
812
813 }
814
815 return status;
816}

Referenced by HAL_FLASHEx_OBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_EnablePCROP() [1/2]

static HAL_StatusTypeDef FLASH_OB_EnablePCROP ( uint32_t  Sector)
static

Enable the read/write protection (PCROP) of the desired sectors.

Note
This function can be used only for STM32F401xx devices.
Parameters
Sectorspecifies the sector(s) to be read/write protected or unprotected. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_Sector0 and OB_PCROP_Sector5
  • OB_PCROP_Sector_All
Return values
HALStatus

Definition at line 1158 of file stm32f4xx_hal_flash_ex.c.

1159{
1160 HAL_StatusTypeDef status = HAL_OK;
1161
1162 /* Check the parameters */
1163 assert_param(IS_OB_PCROP(Sector));
1164
1165 /* Wait for last operation to be completed */
1166 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1167
1168 if(status == HAL_OK)
1169 {
1170 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)Sector;
1171 }
1172
1173 return status;
1174}

Referenced by HAL_FLASHEx_AdvOBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_EnablePCROP() [2/2]

static HAL_StatusTypeDef FLASH_OB_EnablePCROP ( uint32_t  SectorBank1,
uint32_t  SectorBank2,
uint32_t  Banks 
)
static

Enable the read/write protection (PCROP) of the desired sectors of Bank 1 and/or Bank 2.

Note
This function can be used only for STM32F42xxx/43xxx devices.
Parameters
SectorBank1Specifies the sector(s) to be read/write protected or unprotected for bank1. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_SECTOR_0 and OB_PCROP_SECTOR_11
  • OB_PCROP_SECTOR__All
SectorBank2Specifies the sector(s) to be read/write protected or unprotected for bank2. This parameter can be one of the following values:
  • OB_PCROP: A value between OB_PCROP_SECTOR_12 and OB_PCROP_SECTOR_23
  • OB_PCROP_SECTOR__All
BanksEnable PCROP protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: WRP on all sectors of bank1
  • FLASH_BANK_2: WRP on all sectors of bank2
  • FLASH_BANK_BOTH: WRP on all sectors of bank1 & bank2
Return values
HALStatus

Definition at line 869 of file stm32f4xx_hal_flash_ex.c.

870{
871 HAL_StatusTypeDef status = HAL_OK;
872
873 assert_param(IS_FLASH_BANK(Banks));
874
875 /* Wait for last operation to be completed */
876 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
877
878 if(status == HAL_OK)
879 {
880 if((Banks == FLASH_BANK_1) || (Banks == FLASH_BANK_BOTH))
881 {
882 assert_param(IS_OB_PCROP(SectorBank1));
883 /*Write protection done on sectors of BANK1*/
884 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS |= (uint16_t)SectorBank1;
885 }
886 else
887 {
888 assert_param(IS_OB_PCROP(SectorBank2));
889 /*Write protection done on sectors of BANK2*/
890 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)SectorBank2;
891 }
892
893 /*Write protection on all sector of BANK2*/
894 if(Banks == FLASH_BANK_BOTH)
895 {
896 assert_param(IS_OB_PCROP(SectorBank2));
897 /* Wait for last operation to be completed */
898 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
899
900 if(status == HAL_OK)
901 {
902 /*Write protection done on sectors of BANK2*/
903 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS |= (uint16_t)SectorBank2;
904 }
905 }
906
907 }
908
909 return status;
910}
Here is the call graph for this function:

◆ FLASH_OB_EnableWRP() [1/2]

static HAL_StatusTypeDef FLASH_OB_EnableWRP ( uint32_t  WRPSector)
static

Enable the write protection of the desired bank1 or bank2 sectors.

Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM7
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Parameters
WRPSectorspecifies the sector(s) to be write protected. This parameter can be one of the following values:
  • WRPSector: A value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_7 (for STM32F74xxx/STM32F75xxx devices) or a value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_11 (in Single Bank mode for STM32F76xxx/STM32F77xxx devices) or a value between OB_WRP_DB_SECTOR_0 and OB_WRP_DB_SECTOR_23 (in Dual Bank mode for STM32F76xxx/STM32F77xxx devices)
  • OB_WRP_SECTOR_All
Return values
HALFLASH State

Definition at line 832 of file stm32f7xx_hal_flash_ex.c.

833{
834 HAL_StatusTypeDef status = HAL_OK;
835
836 /* Check the parameters */
837 assert_param(IS_OB_WRP_SECTOR(WRPSector));
838
839 /* Wait for last operation to be completed */
840 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
841
842 if(status == HAL_OK)
843 {
844 /*Write protection enabled on sectors */
845 FLASH->OPTCR &= (~WRPSector);
846 }
847
848 return status;
849}
Here is the call graph for this function:

◆ FLASH_OB_EnableWRP() [2/2]

static void FLASH_OB_EnableWRP ( uint32_t  WRPSector,
uint32_t  Banks 
)
static

Enable the write protection of the desired bank1 or bank 2 sectors.

Enable the write protection of the desired bank 1 sectors.

Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
Parameters
WRPSectorspecifies the sector(s) to be write protected. This parameter can be one of the following values:
  • WRPSector: A value between OB_WRP_SECTOR_0 and OB_WRP_SECTOR_23
  • OB_WRP_SECTOR_All
Note
BANK2 starts from OB_WRP_SECTOR_12
Parameters
BanksEnable write protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: WRP on all sectors of bank1
  • FLASH_BANK_2: WRP on all sectors of bank2
  • FLASH_BANK_BOTH: WRP on all sectors of bank1 & bank2
Return values
HALFLASH State
Note
When the memory read protection level is selected (RDP level = 1), it is not possible to program or erase the flash sector i if CortexM4
debug features are connected or boot code is executed in RAM, even if nWRPi = 1
Active value of nWRPi bits is inverted when PCROP mode is active (SPRMOD =1).
Parameters
WRPSectorspecifies the sector(s) to be write protected. The value of this parameter depend on device used within the same series
BanksEnable write protection on all the sectors for the specific bank This parameter can be one of the following values:
  • FLASH_BANK_1: WRP on all sectors of bank1
Return values
HALStatus
Parameters
WRPSectorspecifies the sector(s) to be write protected. This parameter can be one of the following values:
  • WRPSector: A combination of OB_WRP_SECTOR_0 to OB_WRP_SECTOR_7 or OB_WRP_SECTOR_All
Banksthe specific bank to apply WRP sectors This parameter can be one of the following values:
  • FLASH_BANK_1: enable WRP on specified bank1 sectors
  • FLASH_BANK_2: enable WRP on specified bank2 sectors
  • FLASH_BANK_BOTH: enable WRP on both bank1 and bank2 specified sectors
Return values
HALFLASH State

Definition at line 697 of file stm32f4xx_hal_flash_ex.c.

698{
699 HAL_StatusTypeDef status = HAL_OK;
700
701 /* Check the parameters */
702 assert_param(IS_OB_WRP_SECTOR(WRPSector));
703 assert_param(IS_FLASH_BANK(Banks));
704
705 /* Wait for last operation to be completed */
706 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
707
708 if(status == HAL_OK)
709 {
710 if(((WRPSector == OB_WRP_SECTOR_All) && ((Banks == FLASH_BANK_1) || (Banks == FLASH_BANK_BOTH))) ||
711 (WRPSector < OB_WRP_SECTOR_12))
712 {
713 if(WRPSector == OB_WRP_SECTOR_All)
714 {
715 /*Write protection on all sector of BANK1*/
716 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~(WRPSector>>12));
717 }
718 else
719 {
720 /*Write protection done on sectors of BANK1*/
721 *(__IO uint16_t*)OPTCR_BYTE2_ADDRESS &= (~WRPSector);
722 }
723 }
724 else
725 {
726 /*Write protection done on sectors of BANK2*/
727 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~(WRPSector>>12));
728 }
729
730 /*Write protection on all sector of BANK2*/
731 if((WRPSector == OB_WRP_SECTOR_All) && (Banks == FLASH_BANK_BOTH))
732 {
733 /* Wait for last operation to be completed */
734 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
735
736 if(status == HAL_OK)
737 {
738 *(__IO uint16_t*)OPTCR1_BYTE2_ADDRESS &= (~(WRPSector>>12));
739 }
740 }
741
742 }
743 return status;
744}

Referenced by HAL_FLASHEx_OBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_GetBootAdd()

static void FLASH_OB_GetBootAdd ( uint32_t *  BootAddress0,
uint32_t *  BootAddress1 
)
static

Get Boot address.

Parameters
BootAddress0Specifies the Boot Address 0.
BootAddress1Specifies the Boot Address 1.
Return values
HALStatus

Definition at line 1560 of file stm32h7xx_hal_flash_ex.c.

1561{
1562 uint32_t regvalue;
1563
1564#if defined(DUAL_CORE)
1565 regvalue = FLASH->BOOT7_CUR;
1566
1567 (*BootAddress0) = (regvalue & FLASH_BOOT7_BCM7_ADD0) << 16;
1568 (*BootAddress1) = (regvalue & FLASH_BOOT7_BCM7_ADD1);
1569#else /* Single Core */
1570 regvalue = FLASH->BOOT_CUR;
1571
1572 (*BootAddress0) = (regvalue & FLASH_BOOT_ADD0) << 16;
1573 (*BootAddress1) = (regvalue & FLASH_BOOT_ADD1);
1574#endif /* DUAL_CORE */
1575}

◆ FLASH_OB_GetBootAddress()

static uint32_t FLASH_OB_GetBootAddress ( uint32_t  BootOption)
static

Configure Boot base address.

Parameters
BootOption: specifies Boot base address depending from Boot pin = 0 or pin = 1 This parameter can be one of the following values:
  • OPTIONBYTE_BOOTADDR_0 : Boot address based when Boot pin = 0
  • OPTIONBYTE_BOOTADDR_1 : Boot address based when Boot pin = 1
Return values
uint32_tBoot Base Address:
  • OB_BOOTADDR_ITCM_RAM : Boot from ITCM RAM (0x00000000)
  • OB_BOOTADDR_SYSTEM : Boot from System memory bootloader (0x00100000)
  • OB_BOOTADDR_ITCM_FLASH : Boot from Flash on ITCM interface (0x00200000)
  • OB_BOOTADDR_AXIM_FLASH : Boot from Flash on AXIM interface (0x08000000)
  • OB_BOOTADDR_DTCM_RAM : Boot from DTCM RAM (0x20000000)
  • OB_BOOTADDR_SRAM1 : Boot from SRAM1 (0x20010000)
  • OB_BOOTADDR_SRAM2 : Boot from SRAM2 (0x2004C000)

Definition at line 1042 of file stm32f7xx_hal_flash_ex.c.

1043{
1044 uint32_t Address = 0;
1045
1046 /* Return the Boot base Address */
1047 if(BootOption == OPTIONBYTE_BOOTADDR_0)
1048 {
1049 Address = FLASH->OPTCR1 & FLASH_OPTCR1_BOOT_ADD0;
1050 }
1051 else
1052 {
1053 Address = ((FLASH->OPTCR1 & FLASH_OPTCR1_BOOT_ADD1) >> 16);
1054 }
1055
1056 return Address;
1057}

◆ FLASH_OB_GetBOR()

static uint32_t FLASH_OB_GetBOR ( void  )
static

Returns the FLASH BOR level.

Get the BOR Level.

Return values
uint8_tThe FLASH BOR level:
  • OB_BOR_LEVEL3: Supply voltage ranges from 2.7 to 3.6 V
  • OB_BOR_LEVEL2: Supply voltage ranges from 2.4 to 2.7 V
  • OB_BOR_LEVEL1: Supply voltage ranges from 2.1 to 2.4 V
  • OB_BOR_OFF : Supply voltage ranges from 1.62 to 2.1 V
TheOption Bytes BOR Reset Level. This parameter can be one of the following values:
  • OB_BOR_LEVEL0: Reset level threshold is set to 1.6V
  • OB_BOR_LEVEL1: Reset level threshold is set to 2.1V
  • OB_BOR_LEVEL2: Reset level threshold is set to 2.4V
  • OB_BOR_LEVEL3: Reset level threshold is set to 2.7V

Definition at line 1357 of file stm32f4xx_hal_flash_ex.c.

1358{
1359 /* Return the FLASH BOR level */
1360 return (uint8_t)(*(__IO uint8_t *)(OPTCR_BYTE0_ADDRESS) & (uint8_t)0x0C);
1361}

Referenced by HAL_FLASHEx_OBGetConfig().

Here is the caller graph for this function:

◆ FLASH_OB_GetCM4BootAdd()

static void FLASH_OB_GetCM4BootAdd ( uint32_t *  BootAddress0,
uint32_t *  BootAddress1 
)
static

Get CM4 Boot address.

Parameters
BootAddress0Specifies the CM4 Boot Address 0.
BootAddress1Specifies the CM4 Boot Address 1.
Return values
HALStatus

Definition at line 1619 of file stm32h7xx_hal_flash_ex.c.

1620{
1621 uint32_t regvalue;
1622
1623 regvalue = FLASH->BOOT4_CUR;
1624
1625 (*BootAddress0) = (regvalue & FLASH_BOOT4_BCM4_ADD0) << 16;
1626 (*BootAddress1) = (regvalue & FLASH_BOOT4_BCM4_ADD1);
1627}

◆ FLASH_OB_GetPCROP() [1/2]

static void FLASH_OB_GetPCROP ( uint32_t *  PCROPConfig,
uint32_t *  PCROPStartAddr,
uint32_t *  PCROPEndAddr,
uint32_t  Bank 
)
static

Get the Proprietary code readout protection configuration on a given Bank.

Parameters
PCROPConfigindicates if the PCROP area for the given Bank shall be erased or not when RDP level decreased from Level 1 to Level 0 or after a bank erase with protection removal
PCROPStartAddrgives the start address of the Proprietary code readout protection of the bank
PCROPEndAddrgives the end address of the Proprietary code readout protection of the bank
Bankthe specific bank to apply PCROP protection This parameter can be exclusively one of the following values:
  • FLASH_BANK_1: PCROP on specified bank1 area
  • FLASH_BANK_2: PCROP on specified bank2 area
  • FLASH_BANK_BOTH: is not allowed here
Return values
None

Definition at line 1454 of file stm32h7xx_hal_flash_ex.c.

1455{
1456 uint32_t regvalue = 0;
1457 uint32_t bankBase = 0;
1458
1459 if(Bank == FLASH_BANK_1)
1460 {
1461 regvalue = FLASH->PRAR_CUR1;
1462 bankBase = FLASH_BANK1_BASE;
1463 }
1464
1465#if defined (DUAL_BANK)
1466 if(Bank == FLASH_BANK_2)
1467 {
1468 regvalue = FLASH->PRAR_CUR2;
1469 bankBase = FLASH_BANK2_BASE;
1470 }
1471#endif /* DUAL_BANK */
1472
1473 (*PCROPConfig) = (regvalue & FLASH_PRAR_DMEP);
1474
1475 (*PCROPStartAddr) = ((regvalue & FLASH_PRAR_PROT_AREA_START) << 8) + bankBase;
1476 (*PCROPEndAddr) = (regvalue & FLASH_PRAR_PROT_AREA_END) >> FLASH_PRAR_PROT_AREA_END_Pos;
1477 (*PCROPEndAddr) = ((*PCROPEndAddr) << 8) + bankBase;
1478}

◆ FLASH_OB_GetPCROP() [2/2]

static uint32_t FLASH_OB_GetPCROP ( void  )
static

Return the FLASH PCROP Protection Option Bytes value.

Return values
uint32_tFLASH PCROP Protection Option Bytes value

Definition at line 1115 of file stm32f7xx_hal_flash_ex.c.

1116{
1117 /* Return the FLASH write protection Register value */
1118 return ((uint32_t)(FLASH->OPTCR2 & FLASH_OPTCR2_PCROP));
1119}

◆ FLASH_OB_GetPCROPRDP()

static uint32_t FLASH_OB_GetPCROPRDP ( void  )
static

Return the FLASH PCROP_RDP option byte value.

Return values
uint32_tFLASH PCROP_RDP option byte value

Definition at line 1125 of file stm32f7xx_hal_flash_ex.c.

1126{
1127 /* Return the FLASH write protection Register value */
1128 return ((uint32_t)(FLASH->OPTCR2 & FLASH_OPTCR2_PCROP_RDP));
1129}

◆ FLASH_OB_GetRDP()

static uint32_t FLASH_OB_GetRDP ( void  )
static

Returns the FLASH Read Protection level.

Get the read protection level.

Return values
FLASHReadOut Protection Status: This parameter can be one of the following values:
  • OB_RDP_LEVEL_0: No protection
  • OB_RDP_LEVEL_1: Read protection of the memory
  • OB_RDP_LEVEL_2: Full chip protection
RDPLevelspecifies the read protection level. This return value can be one of the following values:
  • OB_RDP_LEVEL_0: No protection
  • OB_RDP_LEVEL_1: Read protection of the memory
  • OB_RDP_LEVEL_2: Full chip protection

Definition at line 1329 of file stm32f4xx_hal_flash_ex.c.

1330{
1331 uint8_t readstatus = OB_RDP_LEVEL_0;
1332
1333 if (*(__IO uint8_t*)(OPTCR_BYTE1_ADDRESS) == (uint8_t)OB_RDP_LEVEL_2)
1334 {
1335 readstatus = OB_RDP_LEVEL_2;
1336 }
1337 else if (*(__IO uint8_t*)(OPTCR_BYTE1_ADDRESS) == (uint8_t)OB_RDP_LEVEL_1)
1338 {
1339 readstatus = OB_RDP_LEVEL_1;
1340 }
1341 else
1342 {
1343 readstatus = OB_RDP_LEVEL_0;
1344 }
1345
1346 return readstatus;
1347}

Referenced by HAL_FLASHEx_OBGetConfig().

Here is the caller graph for this function:

◆ FLASH_OB_GetSecureArea()

static void FLASH_OB_GetSecureArea ( uint32_t *  SecureAreaConfig,
uint32_t *  SecureAreaStartAddr,
uint32_t *  SecureAreaEndAddr,
uint32_t  Bank 
)
static

Get secure area configuration.

Parameters
SecureAreaConfigindicates if the secure area will be deleted or not when RDP level decreased from Level 1 to Level 0 or during a mass erase.
SecureAreaStartAddrgives the secure area start address
SecureAreaEndAddrgives the secure area end address
BankSpecifies the Bank
Return values
None

Definition at line 1686 of file stm32h7xx_hal_flash_ex.c.

1687{
1688 uint32_t regvalue = 0;
1689 uint32_t bankBase = 0;
1690
1691 /* Check Bank parameter value */
1692 if(Bank == FLASH_BANK_1)
1693 {
1694 regvalue = FLASH->SCAR_CUR1;
1695 bankBase = FLASH_BANK1_BASE;
1696 }
1697
1698#if defined (DUAL_BANK)
1699 if(Bank == FLASH_BANK_2)
1700 {
1701 regvalue = FLASH->SCAR_CUR2;
1702 bankBase = FLASH_BANK2_BASE;
1703 }
1704#endif /* DUAL_BANK */
1705
1706 /* Get the secure area settings */
1707 (*SecureAreaConfig) = (regvalue & FLASH_SCAR_DMES);
1708 (*SecureAreaStartAddr) = ((regvalue & FLASH_SCAR_SEC_AREA_START) << 8) + bankBase;
1709 (*SecureAreaEndAddr) = (regvalue & FLASH_SCAR_SEC_AREA_END) >> FLASH_SCAR_SEC_AREA_END_Pos;
1710 (*SecureAreaEndAddr) = ((*SecureAreaEndAddr) << 8) + bankBase;
1711}

◆ FLASH_OB_GetUser()

static uint32_t FLASH_OB_GetUser ( void  )
static

Return the FLASH User Option Byte value.

Return values
uint8_tFLASH User Option Bytes values: IWDG_SW(Bit0), RST_STOP(Bit1) and RST_STDBY(Bit2).
TheFLASH User Option Bytes values IWDG1_SW(Bit4), IWDG2_SW(Bit 5), nRST_STOP_D1(Bit 6), nRST_STDY_D1(Bit 7), FZ_IWDG_STOP(Bit 17), FZ_IWDG_SDBY(Bit 18), ST_RAM_SIZE(Bit[19:20]), SECURITY(Bit 21), BCM4(Bit 22), BCM7(Bit 23), nRST_STOP_D2(Bit 24), nRST_STDY_D2(Bit 25), IO_HSLV (Bit 29) and SWAP_BANK_OPT(Bit 31).

Return the FLASH User Option Byte value.

Return values
TheFLASH User Option Bytes values IWDG_SW(Bit4), nRST_STOP_D1(Bit 6), nRST_STDY_D1(Bit 7), FZ_IWDG_STOP(Bit 17), FZ_IWDG_SDBY(Bit 18), ST_RAM_SIZE(Bit[19:20]), SECURITY(Bit 21), IO_HSLV (Bit 29) and SWAP_BANK_OPT(Bit 31).

Definition at line 1305 of file stm32f4xx_hal_flash_ex.c.

1306{
1307 /* Return the User Option Byte */
1308 return ((uint8_t)(FLASH->OPTCR & 0xE0));
1309}

Referenced by HAL_FLASHEx_OBGetConfig().

Here is the caller graph for this function:

◆ FLASH_OB_GetWRP() [1/2]

static void FLASH_OB_GetWRP ( uint32_t *  WRPState,
uint32_t *  WRPSector,
uint32_t  Bank 
)
static

Get the write protection of the given bank 1 or bank 2 sectors.

Parameters
WRPStategives the write protection state on the given bank. This parameter can be one of the following values:
  • WRPState: OB_WRPSTATE_DISABLE or OB_WRPSTATE_ENABLE
WRPSectorgives the write protected sector(s) on the given bank . This parameter can be one of the following values:
  • WRPSector: A combination of FLASH_OB_WRP_SECTOR_0 to FLASH_OB_WRP_SECTOR_7 or FLASH_OB_WRP_SECTOR_All
Bankthe specific bank to apply WRP sectors This parameter can be exclusively one of the following values:
  • FLASH_BANK_1: Get bank1 WRP sectors
  • FLASH_BANK_2: Get bank2 WRP sectors
  • FLASH_BANK_BOTH: note allowed in this functions
Return values
HALFLASH State

Definition at line 1064 of file stm32h7xx_hal_flash_ex.c.

1065{
1066 uint32_t regvalue = 0U;
1067
1068 if(Bank == FLASH_BANK_1)
1069 {
1070 regvalue = FLASH->WPSN_CUR1;
1071 }
1072
1073#if defined (DUAL_BANK)
1074 if(Bank == FLASH_BANK_2)
1075 {
1076 regvalue = FLASH->WPSN_CUR2;
1077 }
1078#endif /* DUAL_BANK */
1079
1080 (*WRPSector) = (~regvalue) & FLASH_WPSN_WRPSN;
1081
1082 if(*WRPSector == 0U)
1083 {
1084 (*WRPState) = OB_WRPSTATE_DISABLE;
1085 }
1086 else
1087 {
1088 (*WRPState) = OB_WRPSTATE_ENABLE;
1089 }
1090}

◆ FLASH_OB_GetWRP() [2/2]

static uint16_t FLASH_OB_GetWRP ( void  )
static

Return the FLASH Write Protection Option Bytes value.

Return values
uint16_tFLASH Write Protection Option Bytes value

Definition at line 1315 of file stm32f4xx_hal_flash_ex.c.

1316{
1317 /* Return the FLASH write protection Register value */
1318 return (*(__IO uint16_t *)(OPTCR_BYTE2_ADDRESS));
1319}

Referenced by HAL_FLASHEx_OBGetConfig().

Here is the caller graph for this function:

◆ FLASH_OB_OTP_GetLock()

static uint32_t FLASH_OB_OTP_GetLock ( void  )
static

Get the OTP Block Lock.

Return values
OTP_Blockspecifies the OTP Block to lock. This return value can be a value of FLASH OTP blocks

Definition at line 1799 of file stm32h7xx_hal_flash_ex.c.

1800{
1801 return (FLASH->OTPBL_CUR);
1802}

◆ FLASH_OB_OTP_LockConfig()

static void FLASH_OB_OTP_LockConfig ( uint32_t  OTP_Block)
static

Configure the OTP Block Lock.

Parameters
OTP_Blockspecifies the OTP Block to lock. This parameter can be a value of FLASH OTP blocks
Return values
None

Definition at line 1785 of file stm32h7xx_hal_flash_ex.c.

1786{
1787 /* Check the parameters */
1788 assert_param(IS_OTP_BLOCK(OTP_Block));
1789
1790 /* Configure the OTP Block lock in the option bytes register */
1791 FLASH->OTPBL_PRG |= (OTP_Block & FLASH_OTPBL_LOCKBL);
1792}

◆ FLASH_OB_PCROP_Config()

static HAL_StatusTypeDef FLASH_OB_PCROP_Config ( uint32_t  PCROPSector)
static

Set the PCROP protection for sectors.

Parameters
PCROPSectorspecifies the sector(s) to be PCROP protected. This parameter can be one of the following values:
  • OB_PCROP_SECTOR_x: A value between OB_PCROP_SECTOR_0 and OB_PCROP_SECTOR_7
  • OB_PCROP_SECTOR_ALL
Return values
HALStatus

Definition at line 1069 of file stm32f7xx_hal_flash_ex.c.

1070{
1071 HAL_StatusTypeDef status = HAL_OK;
1072
1073 /* Check the parameters */
1074 assert_param(IS_OB_PCROP_SECTOR(PCROPSector));
1075
1076 /* Wait for last operation to be completed */
1077 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1078
1079 if(status == HAL_OK)
1080 {
1081 MODIFY_REG(FLASH->OPTCR2, FLASH_OPTCR2_PCROP, PCROPSector);
1082 }
1083
1084 return status;
1085}
Here is the call graph for this function:

◆ FLASH_OB_PCROP_RDP_Config()

static HAL_StatusTypeDef FLASH_OB_PCROP_RDP_Config ( uint32_t  Pcrop_Rdp)
static

Set the PCROP_RDP value.

Parameters
Pcrop_Rdpspecifies the PCROP_RDP bit value.
Return values
HALStatus

Definition at line 1093 of file stm32f7xx_hal_flash_ex.c.

1094{
1095 HAL_StatusTypeDef status = HAL_OK;
1096
1097 /* Check the parameters */
1098 assert_param(IS_OB_PCROP_RDP_VALUE(Pcrop_Rdp));
1099
1100 /* Wait for last operation to be completed */
1101 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1102
1103 if(status == HAL_OK)
1104 {
1105 MODIFY_REG(FLASH->OPTCR2, FLASH_OPTCR2_PCROP_RDP, Pcrop_Rdp);
1106 }
1107
1108 return status;
1109}
Here is the call graph for this function:

◆ FLASH_OB_PCROPConfig()

static void FLASH_OB_PCROPConfig ( uint32_t  PCROPConfig,
uint32_t  PCROPStartAddr,
uint32_t  PCROPEndAddr,
uint32_t  Banks 
)
static

Configure the Proprietary code readout protection of the desired addresses.

Note
To configure the PCROP options, the option lock bit OPTLOCK must be cleared with the call of the HAL_FLASH_OB_Unlock() function.
To validate the PCROP options, the option bytes must be reloaded through the call of the HAL_FLASH_OB_Launch() function.
Parameters
PCROPConfigspecifies if the PCROP area for the given Bank shall be erased or not when RDP level decreased from Level 1 to Level 0, or after a bank erase with protection removal This parameter must be a value of
  • FLASHEx_OB_PCROP_RDP enumeration
PCROPStartAddrspecifies the start address of the Proprietary code readout protection This parameter can be an address between begin and end of the bank
PCROPEndAddrspecifies the end address of the Proprietary code readout protection This parameter can be an address between PCROPStartAddr and end of the bank
Banksthe specific bank to apply PCROP protection This parameter can be one of the following values:
  • FLASH_BANK_1: PCROP on specified bank1 area
  • FLASH_BANK_2: PCROP on specified bank2 area
  • FLASH_BANK_BOTH: PCROP on specified bank1 and bank2 area (same config will be applied on both banks)
Return values
None

Definition at line 1405 of file stm32h7xx_hal_flash_ex.c.

1406{
1407 /* Check the parameters */
1408 assert_param(IS_FLASH_BANK(Banks));
1409 assert_param(IS_OB_PCROP_RDP(PCROPConfig));
1410
1411 if((Banks & FLASH_BANK_1) == FLASH_BANK_1)
1412 {
1413 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(PCROPStartAddr));
1414 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(PCROPEndAddr));
1415
1416 /* Configure the Proprietary code readout protection */
1417 FLASH->PRAR_PRG1 = ((PCROPStartAddr - FLASH_BANK1_BASE) >> 8) | \
1418 (((PCROPEndAddr - FLASH_BANK1_BASE) >> 8) << FLASH_PRAR_PROT_AREA_END_Pos) | \
1419 PCROPConfig;
1420 }
1421
1422#if defined (DUAL_BANK)
1423 if((Banks & FLASH_BANK_2) == FLASH_BANK_2)
1424 {
1425 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(PCROPStartAddr));
1426 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(PCROPEndAddr));
1427
1428 /* Configure the Proprietary code readout protection */
1429 FLASH->PRAR_PRG2 = ((PCROPStartAddr - FLASH_BANK2_BASE) >> 8) | \
1430 (((PCROPEndAddr - FLASH_BANK2_BASE) >> 8) << FLASH_PRAR_PROT_AREA_END_Pos) | \
1431 PCROPConfig;
1432 }
1433#endif /* DUAL_BANK */
1434}

◆ FLASH_OB_RDP_LevelConfig()

static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig ( uint8_t  Level)
static

Set the read protection level.

Parameters
Levelspecifies the read protection level. This parameter can be one of the following values:
  • OB_RDP_LEVEL_0: No protection
  • OB_RDP_LEVEL_1: Read protection of the memory
  • OB_RDP_LEVEL_2: Full chip protection
Note
WARNING: When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0
Return values
HALStatus

Definition at line 1218 of file stm32f4xx_hal_flash_ex.c.

1219{
1220 HAL_StatusTypeDef status = HAL_OK;
1221
1222 /* Check the parameters */
1223 assert_param(IS_OB_RDP_LEVEL(Level));
1224
1225 /* Wait for last operation to be completed */
1226 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1227
1228 if(status == HAL_OK)
1229 {
1230 *(__IO uint8_t*)OPTCR_BYTE1_ADDRESS = Level;
1231 }
1232
1233 return status;
1234}

Referenced by HAL_FLASHEx_OBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_OB_RDPConfig()

static void FLASH_OB_RDPConfig ( uint32_t  RDPLevel)
static

Set the read protection level.

Note
To configure the RDP level, the option lock bit OPTLOCK must be cleared with the call of the HAL_FLASH_OB_Unlock() function.
To validate the RDP level, the option bytes must be reloaded through the call of the HAL_FLASH_OB_Launch() function.
!!! Warning : When enabling OB_RDP level 2 it's no more possible to go back to level 1 or 0 !!!
Parameters
RDPLevelspecifies the read protection level. This parameter can be one of the following values:
  • OB_RDP_LEVEL_0: No protection
  • OB_RDP_LEVEL_1: Read protection of the memory
  • OB_RDP_LEVEL_2: Full chip protection
Return values
HALstatus

Definition at line 1110 of file stm32h7xx_hal_flash_ex.c.

1111{
1112 /* Check the parameters */
1113 assert_param(IS_OB_RDP_LEVEL(RDPLevel));
1114
1115 /* Configure the RDP level in the option bytes register */
1116 MODIFY_REG(FLASH->OPTSR_PRG, FLASH_OPTSR_RDP, RDPLevel);
1117}

◆ FLASH_OB_SecureAreaConfig()

static void FLASH_OB_SecureAreaConfig ( uint32_t  SecureAreaConfig,
uint32_t  SecureAreaStartAddr,
uint32_t  SecureAreaEndAddr,
uint32_t  Banks 
)
static

Set secure area configuration.

Parameters
SecureAreaConfigspecify if the secure area will be deleted or not when RDP level decreased from Level 1 to Level 0 or during a mass erase.
SecureAreaStartAddrSpecifies the secure area start address
SecureAreaEndAddrSpecifies the secure area end address
Banksthe specific bank to apply Security protection This parameter can be one of the following values:
  • FLASH_BANK_1: Secure area on specified bank1 area
  • FLASH_BANK_2: Secure area on specified bank2 area
  • FLASH_BANK_BOTH: Secure area on specified bank1 and bank2 area (same config will be applied on both banks)
Return values
None

Definition at line 1644 of file stm32h7xx_hal_flash_ex.c.

1645{
1646 /* Check the parameters */
1647 assert_param(IS_FLASH_BANK(Banks));
1648 assert_param(IS_OB_SECURE_RDP(SecureAreaConfig));
1649
1650 if((Banks & FLASH_BANK_1) == FLASH_BANK_1)
1651 {
1652 /* Check the parameters */
1653 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(SecureAreaStartAddr));
1654 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK1(SecureAreaEndAddr));
1655
1656 /* Configure the secure area */
1657 FLASH->SCAR_PRG1 = ((SecureAreaStartAddr - FLASH_BANK1_BASE) >> 8) | \
1658 (((SecureAreaEndAddr - FLASH_BANK1_BASE) >> 8) << FLASH_SCAR_SEC_AREA_END_Pos) | \
1659 (SecureAreaConfig & FLASH_SCAR_DMES);
1660 }
1661
1662#if defined (DUAL_BANK)
1663 if((Banks & FLASH_BANK_2) == FLASH_BANK_2)
1664 {
1665 /* Check the parameters */
1666 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(SecureAreaStartAddr));
1667 assert_param(IS_FLASH_PROGRAM_ADDRESS_BANK2(SecureAreaEndAddr));
1668
1669 /* Configure the secure area */
1670 FLASH->SCAR_PRG2 = ((SecureAreaStartAddr - FLASH_BANK2_BASE) >> 8) | \
1671 (((SecureAreaEndAddr - FLASH_BANK2_BASE) >> 8) << FLASH_SCAR_SEC_AREA_END_Pos) | \
1672 (SecureAreaConfig & FLASH_SCAR_DMES);
1673 }
1674#endif /* DUAL_BANK */
1675}

◆ FLASH_OB_SharedRAM_Config()

static void FLASH_OB_SharedRAM_Config ( uint32_t  SharedRamConfig)
static

Configure the TCM / AXI Shared RAM.

Parameters
SharedRamConfigspecifies the Shared RAM configuration. This parameter can be a value of FLASHEx OB TCM AXI SHARED
Return values
None

Definition at line 1812 of file stm32h7xx_hal_flash_ex.c.

1813{
1814 /* Check the parameters */
1815 assert_param(IS_OB_USER_TCM_AXI_SHARED(SharedRamConfig));
1816
1817 /* Configure the TCM / AXI Shared RAM in the option bytes register */
1818 MODIFY_REG(FLASH->OPTSR2_PRG, FLASH_OPTSR2_TCM_AXI_SHARED, SharedRamConfig);
1819}

◆ FLASH_OB_SharedRAM_GetConfig()

static uint32_t FLASH_OB_SharedRAM_GetConfig ( void  )
static

Get the TCM / AXI Shared RAM configurtion.

Return values
SharedRamConfigreturns the TCM / AXI Shared RAM configuration. This return value can be a value of FLASHEx OB TCM AXI SHARED

Definition at line 1826 of file stm32h7xx_hal_flash_ex.c.

1827{
1828 return (FLASH->OPTSR2_CUR & FLASH_OPTSR2_TCM_AXI_SHARED);;
1829}

◆ FLASH_OB_UserConfig() [1/4]

static void FLASH_OB_UserConfig ( uint32_t  UserType,
uint32_t  UserConfig 
)
static

Program the FLASH User Option Byte.

Note
To configure the user option bytes, the option lock bit OPTLOCK must be cleared with the call of the HAL_FLASH_OB_Unlock() function.
To validate the user option bytes, the option bytes must be reloaded through the call of the HAL_FLASH_OB_Launch() function.
Parameters
UserTypeThe FLASH User Option Bytes to be modified : a combination of FLASHEx OB USER Type
UserConfigThe FLASH User Option Bytes values: IWDG1_SW(Bit4), IWDG2_SW(Bit 5), nRST_STOP_D1(Bit 6), nRST_STDY_D1(Bit 7), FZ_IWDG_STOP(Bit 17), FZ_IWDG_SDBY(Bit 18), ST_RAM_SIZE(Bit[19:20]), SECURITY(Bit 21), BCM4(Bit 22), BCM7(Bit 23), nRST_STOP_D2(Bit 24), nRST_STDY_D2(Bit 25), IO_HSLV (Bit 29) and SWAP_BANK_OPT(Bit 31).
Return values
HALstatus

Program the FLASH User Option Byte.

Note
To configure the user option bytes, the option lock bit OPTLOCK must be cleared with the call of the HAL_FLASH_OB_Unlock() function.
To validate the user option bytes, the option bytes must be reloaded through the call of the HAL_FLASH_OB_Launch() function.
Parameters
UserTypeThe FLASH User Option Bytes to be modified : a combination of
  • FLASHEx_OB_USER_Type
UserConfigThe FLASH User Option Bytes values: IWDG_SW(Bit4), nRST_STOP_D1(Bit 6), nRST_STDY_D1(Bit 7), FZ_IWDG_STOP(Bit 17), FZ_IWDG_SDBY(Bit 18), ST_RAM_SIZE(Bit[19:20]), SECURITY(Bit 21), IO_HSLV (Bit 29) and SWAP_BANK_OPT(Bit 31).
Return values
HALstatus

Definition at line 1183 of file stm32h7xx_hal_flash_ex.c.

1184{
1185 uint32_t optr_reg_val = 0;
1186 uint32_t optr_reg_mask = 0;
1187
1188 /* Check the parameters */
1189 assert_param(IS_OB_USER_TYPE(UserType));
1190
1191 if((UserType & OB_USER_IWDG1_SW) != 0U)
1192 {
1193 /* IWDG_HW option byte should be modified */
1194 assert_param(IS_OB_IWDG1_SOURCE(UserConfig & FLASH_OPTSR_IWDG1_SW));
1195
1196 /* Set value and mask for IWDG_HW option byte */
1197 optr_reg_val |= (UserConfig & FLASH_OPTSR_IWDG1_SW);
1198 optr_reg_mask |= FLASH_OPTSR_IWDG1_SW;
1199 }
1200#if defined(DUAL_CORE)
1201 if((UserType & OB_USER_IWDG2_SW) != 0U)
1202 {
1203 /* IWDG2_SW option byte should be modified */
1204 assert_param(IS_OB_IWDG2_SOURCE(UserConfig & FLASH_OPTSR_IWDG2_SW));
1205
1206 /* Set value and mask for IWDG2_SW option byte */
1207 optr_reg_val |= (UserConfig & FLASH_OPTSR_IWDG2_SW);
1208 optr_reg_mask |= FLASH_OPTSR_IWDG2_SW;
1209 }
1210#endif /*DUAL_CORE*/
1211 if((UserType & OB_USER_NRST_STOP_D1) != 0U)
1212 {
1213 /* NRST_STOP option byte should be modified */
1214 assert_param(IS_OB_STOP_D1_RESET(UserConfig & FLASH_OPTSR_NRST_STOP_D1));
1215
1216 /* Set value and mask for NRST_STOP option byte */
1217 optr_reg_val |= (UserConfig & FLASH_OPTSR_NRST_STOP_D1);
1218 optr_reg_mask |= FLASH_OPTSR_NRST_STOP_D1;
1219 }
1220
1221 if((UserType & OB_USER_NRST_STDBY_D1) != 0U)
1222 {
1223 /* NRST_STDBY option byte should be modified */
1224 assert_param(IS_OB_STDBY_D1_RESET(UserConfig & FLASH_OPTSR_NRST_STBY_D1));
1225
1226 /* Set value and mask for NRST_STDBY option byte */
1227 optr_reg_val |= (UserConfig & FLASH_OPTSR_NRST_STBY_D1);
1228 optr_reg_mask |= FLASH_OPTSR_NRST_STBY_D1;
1229 }
1230
1231 if((UserType & OB_USER_IWDG_STOP) != 0U)
1232 {
1233 /* IWDG_STOP option byte should be modified */
1234 assert_param(IS_OB_USER_IWDG_STOP(UserConfig & FLASH_OPTSR_FZ_IWDG_STOP));
1235
1236 /* Set value and mask for IWDG_STOP option byte */
1237 optr_reg_val |= (UserConfig & FLASH_OPTSR_FZ_IWDG_STOP);
1238 optr_reg_mask |= FLASH_OPTSR_FZ_IWDG_STOP;
1239 }
1240
1241 if((UserType & OB_USER_IWDG_STDBY) != 0U)
1242 {
1243 /* IWDG_STDBY option byte should be modified */
1244 assert_param(IS_OB_USER_IWDG_STDBY(UserConfig & FLASH_OPTSR_FZ_IWDG_SDBY));
1245
1246 /* Set value and mask for IWDG_STDBY option byte */
1247 optr_reg_val |= (UserConfig & FLASH_OPTSR_FZ_IWDG_SDBY);
1248 optr_reg_mask |= FLASH_OPTSR_FZ_IWDG_SDBY;
1249 }
1250
1251 if((UserType & OB_USER_ST_RAM_SIZE) != 0U)
1252 {
1253 /* ST_RAM_SIZE option byte should be modified */
1254 assert_param(IS_OB_USER_ST_RAM_SIZE(UserConfig & FLASH_OPTSR_ST_RAM_SIZE));
1255
1256 /* Set value and mask for ST_RAM_SIZE option byte */
1257 optr_reg_val |= (UserConfig & FLASH_OPTSR_ST_RAM_SIZE);
1258 optr_reg_mask |= FLASH_OPTSR_ST_RAM_SIZE;
1259 }
1260
1261 if((UserType & OB_USER_SECURITY) != 0U)
1262 {
1263 /* SECURITY option byte should be modified */
1264 assert_param(IS_OB_USER_SECURITY(UserConfig & FLASH_OPTSR_SECURITY));
1265
1266 /* Set value and mask for SECURITY option byte */
1267 optr_reg_val |= (UserConfig & FLASH_OPTSR_SECURITY);
1268 optr_reg_mask |= FLASH_OPTSR_SECURITY;
1269 }
1270
1271#if defined(DUAL_CORE)
1272 if((UserType & OB_USER_BCM4) != 0U)
1273 {
1274 /* BCM4 option byte should be modified */
1275 assert_param(IS_OB_USER_BCM4(UserConfig & FLASH_OPTSR_BCM4));
1276
1277 /* Set value and mask for BCM4 option byte */
1278 optr_reg_val |= (UserConfig & FLASH_OPTSR_BCM4);
1279 optr_reg_mask |= FLASH_OPTSR_BCM4;
1280 }
1281
1282 if((UserType & OB_USER_BCM7) != 0U)
1283 {
1284 /* BCM7 option byte should be modified */
1285 assert_param(IS_OB_USER_BCM7(UserConfig & FLASH_OPTSR_BCM7));
1286
1287 /* Set value and mask for BCM7 option byte */
1288 optr_reg_val |= (UserConfig & FLASH_OPTSR_BCM7);
1289 optr_reg_mask |= FLASH_OPTSR_BCM7;
1290 }
1291#endif /* DUAL_CORE */
1292
1293#if defined (FLASH_OPTSR_NRST_STOP_D2)
1294 if((UserType & OB_USER_NRST_STOP_D2) != 0U)
1295 {
1296 /* NRST_STOP option byte should be modified */
1297 assert_param(IS_OB_STOP_D2_RESET(UserConfig & FLASH_OPTSR_NRST_STOP_D2));
1298
1299 /* Set value and mask for NRST_STOP option byte */
1300 optr_reg_val |= (UserConfig & FLASH_OPTSR_NRST_STOP_D2);
1301 optr_reg_mask |= FLASH_OPTSR_NRST_STOP_D2;
1302 }
1303
1304 if((UserType & OB_USER_NRST_STDBY_D2) != 0U)
1305 {
1306 /* NRST_STDBY option byte should be modified */
1307 assert_param(IS_OB_STDBY_D2_RESET(UserConfig & FLASH_OPTSR_NRST_STBY_D2));
1308
1309 /* Set value and mask for NRST_STDBY option byte */
1310 optr_reg_val |= (UserConfig & FLASH_OPTSR_NRST_STBY_D2);
1311 optr_reg_mask |= FLASH_OPTSR_NRST_STBY_D2;
1312 }
1313#endif /* FLASH_OPTSR_NRST_STOP_D2 */
1314
1315#if defined (DUAL_BANK)
1316 if((UserType & OB_USER_SWAP_BANK) != 0U)
1317 {
1318 /* SWAP_BANK_OPT option byte should be modified */
1319 assert_param(IS_OB_USER_SWAP_BANK(UserConfig & FLASH_OPTSR_SWAP_BANK_OPT));
1320
1321 /* Set value and mask for SWAP_BANK_OPT option byte */
1322 optr_reg_val |= (UserConfig & FLASH_OPTSR_SWAP_BANK_OPT);
1323 optr_reg_mask |= FLASH_OPTSR_SWAP_BANK_OPT;
1324 }
1325#endif /* DUAL_BANK */
1326
1327 if((UserType & OB_USER_IOHSLV) != 0U)
1328 {
1329 /* IOHSLV_OPT option byte should be modified */
1330 assert_param(IS_OB_USER_IOHSLV(UserConfig & FLASH_OPTSR_IO_HSLV));
1331
1332 /* Set value and mask for IOHSLV_OPT option byte */
1333 optr_reg_val |= (UserConfig & FLASH_OPTSR_IO_HSLV);
1334 optr_reg_mask |= FLASH_OPTSR_IO_HSLV;
1335 }
1336
1337#if defined (FLASH_OPTSR_VDDMMC_HSLV)
1338 if((UserType & OB_USER_VDDMMC_HSLV) != 0U)
1339 {
1340 /* VDDMMC_HSLV option byte should be modified */
1341 assert_param(IS_OB_USER_VDDMMC_HSLV(UserConfig & FLASH_OPTSR_VDDMMC_HSLV));
1342
1343 /* Set value and mask for VDDMMC_HSLV option byte */
1344 optr_reg_val |= (UserConfig & FLASH_OPTSR_VDDMMC_HSLV);
1345 optr_reg_mask |= FLASH_OPTSR_VDDMMC_HSLV;
1346 }
1347#endif /* FLASH_OPTSR_VDDMMC_HSLV */
1348
1349 /* Configure the option bytes register */
1350 MODIFY_REG(FLASH->OPTSR_PRG, optr_reg_mask, optr_reg_val);
1351}

◆ FLASH_OB_UserConfig() [2/4]

static HAL_StatusTypeDef FLASH_OB_UserConfig ( uint32_t  Wwdg,
uint32_t  Iwdg,
uint32_t  Stop,
uint32_t  Stdby,
uint32_t  Iwdgstop,
\ uint32_t  Iwdgstdby,
uint32_t  NDBank,
uint32_t  NDBoot 
)
static

Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

Parameters
WwdgSelects the IWDG mode This parameter can be one of the following values:
  • OB_WWDG_SW: Software WWDG selected
  • OB_WWDG_HW: Hardware WWDG selected
IwdgSelects the WWDG mode This parameter can be one of the following values:
  • OB_IWDG_SW: Software IWDG selected
  • OB_IWDG_HW: Hardware IWDG selected
StopReset event when entering STOP mode. This parameter can be one of the following values:
  • OB_STOP_NO_RST: No reset generated when entering in STOP
  • OB_STOP_RST: Reset generated when entering in STOP
StdbyReset event when entering Standby mode. This parameter can be one of the following values:
  • OB_STDBY_NO_RST: No reset generated when entering in STANDBY
  • OB_STDBY_RST: Reset generated when entering in STANDBY
IwdgstopIndependent watchdog counter freeze in Stop mode. This parameter can be one of the following values:
  • OB_IWDG_STOP_FREEZE: Freeze IWDG counter in STOP
  • OB_IWDG_STOP_ACTIVE: IWDG counter active in STOP
IwdgstdbyIndependent watchdog counter freeze in standby mode. This parameter can be one of the following values:
  • OB_IWDG_STDBY_FREEZE: Freeze IWDG counter in STANDBY
  • OB_IWDG_STDBY_ACTIVE: IWDG counter active in STANDBY
NDBankFlash Single Bank mode enabled. This parameter can be one of the following values:
  • OB_NDBANK_SINGLE_BANK: enable 256 bits mode (Flash is a single bank)
  • OB_NDBANK_DUAL_BANK: disable 256 bits mode (Flash is a dual bank in 128 bits mode)
NDBootFlash Dual boot mode disable. This parameter can be one of the following values:
  • OB_DUAL_BOOT_DISABLE: Disable Dual Boot
  • OB_DUAL_BOOT_ENABLE: Enable Dual Boot
Return values
HALStatus

Definition at line 602 of file stm32f7xx_hal_flash_ex.c.

604{
605 uint32_t useroptionmask = 0x00;
606 uint32_t useroptionvalue = 0x00;
607
608 HAL_StatusTypeDef status = HAL_OK;
609
610 /* Check the parameters */
611 assert_param(IS_OB_WWDG_SOURCE(Wwdg));
612 assert_param(IS_OB_IWDG_SOURCE(Iwdg));
613 assert_param(IS_OB_STOP_SOURCE(Stop));
614 assert_param(IS_OB_STDBY_SOURCE(Stdby));
615 assert_param(IS_OB_IWDG_STOP_FREEZE(Iwdgstop));
616 assert_param(IS_OB_IWDG_STDBY_FREEZE(Iwdgstdby));
617 assert_param(IS_OB_NDBANK(NDBank));
618 assert_param(IS_OB_NDBOOT(NDBoot));
619
620 /* Wait for last operation to be completed */
621 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
622
623 if(status == HAL_OK)
624 {
625 useroptionmask = (FLASH_OPTCR_WWDG_SW | FLASH_OPTCR_IWDG_SW | FLASH_OPTCR_nRST_STOP | \
626 FLASH_OPTCR_nRST_STDBY | FLASH_OPTCR_IWDG_STOP | FLASH_OPTCR_IWDG_STDBY | \
627 FLASH_OPTCR_nDBOOT | FLASH_OPTCR_nDBANK);
628
629 useroptionvalue = (Iwdg | Wwdg | Stop | Stdby | Iwdgstop | Iwdgstdby | NDBoot | NDBank);
630
631 /* Update User Option Byte */
632 MODIFY_REG(FLASH->OPTCR, useroptionmask, useroptionvalue);
633 }
634
635 return status;
636}
Here is the call graph for this function:

◆ FLASH_OB_UserConfig() [3/4]

static HAL_StatusTypeDef FLASH_OB_UserConfig ( uint32_t  Wwdg,
uint32_t  Iwdg,
uint32_t  Stop,
uint32_t  Stdby,
uint32_t  Iwdgstop,
uint32_t  Iwdgstdby 
)
static

Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

Parameters
WwdgSelects the IWDG mode This parameter can be one of the following values:
  • OB_WWDG_SW: Software WWDG selected
  • OB_WWDG_HW: Hardware WWDG selected
IwdgSelects the WWDG mode This parameter can be one of the following values:
  • OB_IWDG_SW: Software IWDG selected
  • OB_IWDG_HW: Hardware IWDG selected
StopReset event when entering STOP mode. This parameter can be one of the following values:
  • OB_STOP_NO_RST: No reset generated when entering in STOP
  • OB_STOP_RST: Reset generated when entering in STOP
StdbyReset event when entering Standby mode. This parameter can be one of the following values:
  • OB_STDBY_NO_RST: No reset generated when entering in STANDBY
  • OB_STDBY_RST: Reset generated when entering in STANDBY
IwdgstopIndependent watchdog counter freeze in Stop mode. This parameter can be one of the following values:
  • OB_IWDG_STOP_FREEZE: Freeze IWDG counter in STOP
  • OB_IWDG_STOP_ACTIVE: IWDG counter active in STOP
IwdgstdbyIndependent watchdog counter freeze in standby mode. This parameter can be one of the following values:
  • OB_IWDG_STDBY_FREEZE: Freeze IWDG counter in STANDBY
  • OB_IWDG_STDBY_ACTIVE: IWDG counter active in STANDBY
Return values
HALStatus

Definition at line 771 of file stm32f7xx_hal_flash_ex.c.

772{
773 uint32_t useroptionmask = 0x00;
774 uint32_t useroptionvalue = 0x00;
775
776 HAL_StatusTypeDef status = HAL_OK;
777
778 /* Check the parameters */
779 assert_param(IS_OB_WWDG_SOURCE(Wwdg));
780 assert_param(IS_OB_IWDG_SOURCE(Iwdg));
781 assert_param(IS_OB_STOP_SOURCE(Stop));
782 assert_param(IS_OB_STDBY_SOURCE(Stdby));
783 assert_param(IS_OB_IWDG_STOP_FREEZE(Iwdgstop));
784 assert_param(IS_OB_IWDG_STDBY_FREEZE(Iwdgstdby));
785
786 /* Wait for last operation to be completed */
787 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
788
789 if(status == HAL_OK)
790 {
791 useroptionmask = (FLASH_OPTCR_WWDG_SW | FLASH_OPTCR_IWDG_SW | FLASH_OPTCR_nRST_STOP | \
792 FLASH_OPTCR_nRST_STDBY | FLASH_OPTCR_IWDG_STOP | FLASH_OPTCR_IWDG_STDBY);
793
794 useroptionvalue = (Iwdg | Wwdg | Stop | Stdby | Iwdgstop | Iwdgstdby);
795
796 /* Update User Option Byte */
797 MODIFY_REG(FLASH->OPTCR, useroptionmask, useroptionvalue);
798 }
799
800 return status;
801
802}
Here is the call graph for this function:

◆ FLASH_OB_UserConfig() [4/4]

static HAL_StatusTypeDef FLASH_OB_UserConfig ( uint8_t  Iwdg,
uint8_t  Stop,
uint8_t  Stdby 
)
static

Program the FLASH User Option Byte: IWDG_SW / RST_STOP / RST_STDBY.

Parameters
IwdgSelects the IWDG mode This parameter can be one of the following values:
  • OB_IWDG_SW: Software IWDG selected
  • OB_IWDG_HW: Hardware IWDG selected
StopReset event when entering STOP mode. This parameter can be one of the following values:
  • OB_STOP_NO_RST: No reset generated when entering in STOP
  • OB_STOP_RST: Reset generated when entering in STOP
StdbyReset event when entering Standby mode. This parameter can be one of the following values:
  • OB_STDBY_NO_RST: No reset generated when entering in STANDBY
  • OB_STDBY_RST: Reset generated when entering in STANDBY
Return values
HALStatus

Definition at line 1252 of file stm32f4xx_hal_flash_ex.c.

1253{
1254 uint8_t optiontmp = 0xFF;
1255 HAL_StatusTypeDef status = HAL_OK;
1256
1257 /* Check the parameters */
1258 assert_param(IS_OB_IWDG_SOURCE(Iwdg));
1259 assert_param(IS_OB_STOP_SOURCE(Stop));
1260 assert_param(IS_OB_STDBY_SOURCE(Stdby));
1261
1262 /* Wait for last operation to be completed */
1263 status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
1264
1265 if(status == HAL_OK)
1266 {
1267 /* Mask OPTLOCK, OPTSTRT, BOR_LEV and BFB2 bits */
1268 optiontmp = (uint8_t)((*(__IO uint8_t *)OPTCR_BYTE0_ADDRESS) & (uint8_t)0x1F);
1269
1270 /* Update User Option Byte */
1271 *(__IO uint8_t *)OPTCR_BYTE0_ADDRESS = Iwdg | (uint8_t)(Stdby | (uint8_t)(Stop | ((uint8_t)optiontmp)));
1272 }
1273
1274 return status;
1275}

Referenced by HAL_FLASHEx_OBProgram().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FLASH_WaitForLastOperation()

HAL_StatusTypeDef FLASH_WaitForLastOperation ( uint32_t  Timeout)
extern

Wait for a FLASH operation to complete.

Parameters
Timeoutmaximum flash operationtimeout
Return values
HALStatus

Definition at line 569 of file stm32f4xx_hal_flash.c.

570{
571 (void)Timeout;
572
573 /* Clear Error Code */
574 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
575
576 /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
577 Even if the FLASH operation fails, the BUSY flag will be reset and an error
578 flag will be set */
579 /* Get tick */
580 // todo: implement rusEfi own timeout
581 // uint32_t tickstart = HAL_GetTick();
582
583 while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET)
584 {
585 /*
586 // todo: implement rusEfi own timeout
587 if(Timeout != HAL_MAX_DELAY)
588 {
589 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
590 {
591 return HAL_TIMEOUT;
592 }
593 }
594 */
595 }
596
597 /* Check FLASH End of Operation flag */
598 if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
599 {
600 /* Clear FLASH End of Operation pending bit */
601 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
602 }
603
604 if(__HAL_FLASH_GET_FLAG((FLASH_FLAG_OPERR | FLASH_FLAG_WRPERR | FLASH_FLAG_PGAERR | \
605 FLASH_FLAG_PGPERR | FLASH_FLAG_PGSERR | FLASH_FLAG_RDERR)) != RESET)
606 {
607 /*Save the error code*/
609 return HAL_ERROR;
610 }
611
612 /* If there is no error flag set */
613 return HAL_OK;
614
615}
static void FLASH_SetErrorCode(void)
Set the specific FLASH error flag.
FLASH_ProcessTypeDef pFlash

Referenced by FLASH_OB_BootAddressConfig(), FLASH_OB_BootConfig(), FLASH_OB_DisablePCROP(), FLASH_OB_DisablePCROP(), FLASH_OB_DisableWRP(), FLASH_OB_DisableWRP(), FLASH_OB_EnablePCROP(), FLASH_OB_EnablePCROP(), FLASH_OB_EnableWRP(), FLASH_OB_EnableWRP(), FLASH_OB_PCROP_Config(), FLASH_OB_PCROP_RDP_Config(), FLASH_OB_RDP_LevelConfig(), FLASH_OB_RDP_LevelConfig(), FLASH_OB_UserConfig(), FLASH_OB_UserConfig(), FLASH_OB_UserConfig(), HAL_FLASH_OB_Launch(), HAL_FLASH_Program(), and HAL_FLASHEx_Erase().

Here is the call graph for this function:
Here is the caller graph for this function: