rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
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.
 
static void FLASH_MassErase (uint8_t VoltageRange, uint32_t Banks)
 Full erase of FLASH memory sectors.
 
static uint32_t FLASH_OB_GetWRP (void)
 Return the FLASH Write Protection Option Bytes value.
 
static uint32_t FLASH_OB_GetUser (void)
 Return the FLASH User Option Byte value.
 
static HAL_StatusTypeDef FLASH_OB_RDP_LevelConfig (uint8_t Level)
 Set the read protection level.
 
static HAL_StatusTypeDef FLASH_OB_BOR_LevelConfig (uint8_t Level)
 Set the BOR Level.
 
static uint8_t FLASH_OB_GetRDP (void)
 Returns the FLASH Read Protection level.
 
static uint32_t FLASH_OB_GetBOR (void)
 Returns the FLASH BOR level.
 

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

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:
  • 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
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 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_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_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
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

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

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).
uint8_tFLASH User Option Bytes values: IWDG_SW(Bit0), RST_STOP(Bit1) and RST_STDBY(Bit2).

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
uint16_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_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}
HAL_StatusTypeDef FLASH_WaitForLastOperation(uint32_t Timeout)
Wait for a FLASH operation to complete.
Here is the call graph for this function: