rusEFI
The most advanced open source ECU
Modules | Functions
Collaboration diagram for FLASHEx Exported Functions:

Modules

 Extended IO operation functions
 Extended IO operation functions.
 

Functions

void FLASH_Erase_Sector (uint32_t Sector, uint8_t VoltageRange)
 Erase the specified FLASH memory sector. More...
 
static void FLASH_MassErase (uint8_t VoltageRange, uint32_t Banks)
 Full erase of FLASH memory sectors. More...
 
static uint32_t FLASH_OB_GetWRP (void)
 Return the FLASH Write Protection Option Bytes value. More...
 
static uint32_t FLASH_OB_GetUser (void)
 Return the FLASH User Option Byte value. More...
 
static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig (uint8_t Level)
 Set the read protection level. More...
 
static HAL_StatusTypeDef FLASH_OB_BOR_LevelConfig (uint8_t Level)
 Set the BOR Level. More...
 
static uint8_t FLASH_OB_GetRDP (void)
 Returns the FLASH Read Protection level. More...
 
static uint32_t FLASH_OB_GetBOR (void)
 Returns the FLASH BOR level. More...
 
static HAL_StatusTypeDef FLASH_OB_EnableWRP (uint32_t WRPSector, uint32_t Banks)
 Enable the write protection of the desired bank1 or bank 2 sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_DisableWRP (uint32_t WRPSector, uint32_t Banks)
 Disable the write protection of the desired bank1 or bank 2 sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_BootConfig (uint8_t BootConfig)
 Configure the Dual Bank Boot. More...
 
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. More...
 
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. More...
 
static HAL_StatusTypeDef FLASH_OB_EnablePCROP (uint32_t Sector)
 Enable the read/write protection (PCROP) of the desired sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_DisablePCROP (uint32_t Sector)
 Disable the read/write protection (PCROP) of the desired sectors. More...
 
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.
More...
 
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.
More...
 
static void FLASH_MassErase (uint8_t VoltageRange)
 Full erase of FLASH memory sectors. More...
 
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.
More...
 
static HAL_StatusTypeDef FLASH_OB_EnableWRP (uint32_t WRPSector)
 Enable the write protection of the desired bank1 or bank2 sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_DisableWRP (uint32_t WRPSector)
 Disable the write protection of the desired bank1 or bank 2 sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_BootAddressConfig (uint32_t BootOption, uint32_t Address)
 Configure Boot base address. More...
 
static uint32_t FLASH_OB_GetBootAddress (uint32_t BootOption)
 Configure Boot base address. More...
 
static HAL_StatusTypeDef FLASH_OB_PCROP_Config (uint32_t PCROPSector)
 Set the PCROP protection for sectors. More...
 
static HAL_StatusTypeDef FLASH_OB_PCROP_RDP_Config (uint32_t Pcrop_Rdp)
 Set the PCROP_RDP value. More...
 
static uint32_t FLASH_OB_GetPCROP (void)
 Return the FLASH PCROP Protection Option Bytes value. More...
 
static uint32_t FLASH_OB_GetPCROPRDP (void)
 Return the FLASH PCROP_RDP option byte value. More...
 

Detailed Description

Function Documentation

◆ FLASH_Erase_Sector()

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_MassErase() [1/2]

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() [2/2]

static void FLASH_MassErase ( uint8_t  VoltageRange,
uint32_t  Banks 
)
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)
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 466 of file stm32f7xx_hal_flash_ex.c.

467 {
468  /* Check the parameters */
469  assert_param(IS_VOLTAGERANGE(VoltageRange));
470  assert_param(IS_FLASH_BANK(Banks));
471 
472  /* if the previous operation is completed, proceed to erase all sectors */
473  FLASH->CR &= CR_PSIZE_MASK;
474  if(Banks == FLASH_BANK_BOTH)
475  {
476  /* bank1 & bank2 will be erased*/
477  FLASH->CR |= FLASH_MER_BIT;
478  }
479  else if(Banks == FLASH_BANK_2)
480  {
481  /*Only bank2 will be erased*/
482  FLASH->CR |= FLASH_CR_MER2;
483  }
484  else
485  {
486  /*Only bank1 will be erased*/
487  FLASH->CR |= FLASH_CR_MER1;
488  }
489  FLASH->CR |= FLASH_CR_STRT | ((uint32_t)VoltageRange <<8);
490  /* Data synchronous Barrier (DSB) Just after the write operation
491  This will force the CPU to respect the sequence of instruction (no optimization).*/
492  __DSB();
493 }

◆ 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()

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 927 of file stm32f7xx_hal_flash_ex.c.

928 {
929  /* Check the parameters */
930  assert_param(IS_OB_BOR_LEVEL(Level));
931 
932  /* Set the BOR Level */
933  MODIFY_REG(FLASH->OPTCR, FLASH_OPTCR_BOR_LEV, Level);
934 
935  return HAL_OK;
936 
937 }

◆ 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 HAL_StatusTypeDef 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

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 HAL_StatusTypeDef 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

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_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.

Return values
uint32_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

Definition at line 1019 of file stm32f7xx_hal_flash_ex.c.

1020 {
1021  /* Return the FLASH BOR level */
1022  return ((uint32_t)(FLASH->OPTCR & 0x0C));
1023 }

◆ FLASH_OB_GetPCROP()

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 uint8_t FLASH_OB_GetRDP ( void  )
static

Returns the FLASH Read Protection level.

Return values
FlagStatusFLASH ReadOut 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

Definition at line 991 of file stm32f7xx_hal_flash_ex.c.

992 {
993  uint8_t readstatus = OB_RDP_LEVEL_0;
994 
995  if ((*(__IO uint8_t*)(OPTCR_BYTE1_ADDRESS)) == OB_RDP_LEVEL_0)
996  {
997  readstatus = OB_RDP_LEVEL_0;
998  }
999  else if ((*(__IO uint8_t*)(OPTCR_BYTE1_ADDRESS)) == OB_RDP_LEVEL_2)
1000  {
1001  readstatus = OB_RDP_LEVEL_2;
1002  }
1003  else
1004  {
1005  readstatus = OB_RDP_LEVEL_1;
1006  }
1007 
1008  return readstatus;
1009 }

◆ FLASH_OB_GetUser()

static uint32_t FLASH_OB_GetUser ( void  )
static

Return the FLASH User Option Byte value.

Return values
uint32_tFLASH User Option Bytes values: WWDG_SW(Bit4), IWDG_SW(Bit5), nRST_STOP(Bit6), nRST_STDBY(Bit7), nDBOOT(Bit28), nDBANK(Bit29), IWDG_STDBY(Bit30) and IWDG_STOP(Bit31).
uint32_tFLASH User Option Bytes values: WWDG_SW(Bit4), IWDG_SW(Bit5), nRST_STOP(Bit6), nRST_STDBY(Bit7), IWDG_STDBY(Bit30) and IWDG_STOP(Bit31).

Definition at line 643 of file stm32f7xx_hal_flash_ex.c.

644 {
645  /* Return the User Option Byte */
646  return ((uint32_t)(FLASH->OPTCR & 0xF00000F0U));
647 }

◆ FLASH_OB_GetWRP()

static uint32_t FLASH_OB_GetWRP ( void  )
static

Return the FLASH Write Protection Option Bytes value.

Return values
uint32_tFLASH Write Protection Option Bytes value

Definition at line 559 of file stm32f7xx_hal_flash_ex.c.

560 {
561  /* Return the FLASH write protection Register value */
562  return ((uint32_t)(FLASH->OPTCR & 0x0FFF0000));
563 }

◆ 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_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 899 of file stm32f7xx_hal_flash_ex.c.

900 {
901  HAL_StatusTypeDef status = HAL_OK;
902 
903  /* Check the parameters */
904  assert_param(IS_OB_RDP_LEVEL(Level));
905 
906  /* Wait for last operation to be completed */
907  status = FLASH_WaitForLastOperation((uint32_t)FLASH_TIMEOUT_VALUE);
908 
909  if(status == HAL_OK)
910  {
911  *(__IO uint8_t*)OPTCR_BYTE1_ADDRESS = Level;
912  }
913 
914  return status;
915 }
Here is the call graph for this function:

◆ FLASH_OB_UserConfig() [1/3]

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() [2/3]

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() [3/3]

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: