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

Functions

static void FLASH_Program_DoubleWord (uint32_t Address, uint64_t Data)
 Program a double word (64-bit) at a specified address.
 
static void FLASH_Program_Word (uint32_t Address, uint32_t Data)
 Program word (32-bit) at a specified address.
 
static void FLASH_Program_HalfWord (uint32_t Address, uint16_t Data)
 Program a half-word (16-bit) at a specified address.
 
static void FLASH_Program_Byte (uint32_t Address, uint8_t Data)
 Program byte (8-bit) at a specified address.
 
static void FLASH_SetErrorCode (void)
 Set the specific FLASH error flag.
 
void FLASH_FlushCaches (void)
 Flush the instruction and data caches.
 
HAL_StatusTypeDef FLASH_WaitForLastOperation (uint32_t Timeout)
 Wait for a FLASH operation to complete.
 
HAL_StatusTypeDef FLASH_WaitForLastOperation (uint32_t Timeout, uint32_t Bank)
 Wait for a FLASH operation to complete.
 
HAL_StatusTypeDef FLASH_OB_WaitForLastOperation (uint32_t Timeout)
 Wait for a FLASH Option Bytes change operation to complete.
 
HAL_StatusTypeDef FLASH_CRC_WaitForLastOperation (uint32_t Timeout, uint32_t Bank)
 Wait for a FLASH CRC computation to complete.
 

Detailed Description

Function Documentation

◆ FLASH_CRC_WaitForLastOperation()

HAL_StatusTypeDef FLASH_CRC_WaitForLastOperation ( uint32_t  Timeout,
uint32_t  Bank 
)

Wait for a FLASH CRC computation to complete.

Parameters
Timeoutmaximum flash operation timeout
Bankflash FLASH_BANK_1 or FLASH_BANK_2
Return values
HAL_StatusTypeDefHAL Status

Definition at line 1111 of file stm32h7xx_hal_flash.c.

1112{
1113 uint32_t bsyflag;
1114 (void)Timeout;
1115 //uint32_t tickstart = HAL_GetTick();
1116
1117 assert_param(IS_FLASH_BANK_EXCLUSIVE(Bank));
1118
1119 /* Select bsyflag depending on Bank */
1120 if(Bank == FLASH_BANK_1)
1121 {
1122 bsyflag = FLASH_FLAG_CRC_BUSY_BANK1;
1123 }
1124 else
1125 {
1126 bsyflag = FLASH_FLAG_CRC_BUSY_BANK2;
1127 }
1128
1129 /* Wait for the FLASH CRC computation to complete by polling on CRC_BUSY flag to be reset */
1130 while(__HAL_FLASH_GET_FLAG(bsyflag))
1131 {
1132 // TODO: rusefi own timeout
1133 // if(Timeout != HAL_MAX_DELAY)
1134 // {
1135 // if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1136 // {
1137 // return HAL_TIMEOUT;
1138 // }
1139 // }
1140 }
1141
1142 /* Check FLASH CRC read error flag */
1143 if(Bank == FLASH_BANK_1)
1144 {
1145 if (__HAL_FLASH_GET_FLAG_BANK1(FLASH_FLAG_CRCRDERR_BANK1))
1146 {
1147 /* Save the error code */
1148 pFlash.ErrorCode |= HAL_FLASH_ERROR_CRCRD_BANK1;
1149
1150 /* Clear FLASH CRC read error pending bit */
1151 __HAL_FLASH_CLEAR_FLAG_BANK1(FLASH_FLAG_CRCRDERR_BANK1);
1152
1153 return HAL_ERROR;
1154 }
1155 }
1156#if defined (DUAL_BANK)
1157 else
1158 {
1159 if (__HAL_FLASH_GET_FLAG_BANK2(FLASH_FLAG_CRCRDERR_BANK2))
1160 {
1161 /* Save the error code */
1162 pFlash.ErrorCode |= HAL_FLASH_ERROR_CRCRD_BANK2;
1163
1164 /* Clear FLASH CRC read error pending bit */
1165 __HAL_FLASH_CLEAR_FLAG_BANK2(FLASH_FLAG_CRCRDERR_BANK2);
1166
1167 return HAL_ERROR;
1168 }
1169 }
1170#endif /* DUAL_BANK */
1171
1172 /* If there is no error flag set */
1173 return HAL_OK;
1174}
FLASH_ProcessTypeDef pFlash

Referenced by HAL_FLASHEx_ComputeCRC().

Here is the caller graph for this function:

◆ FLASH_FlushCaches()

void FLASH_FlushCaches ( void  )
extern

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

HAL_StatusTypeDef FLASH_OB_WaitForLastOperation ( uint32_t  Timeout)

Wait for a FLASH Option Bytes change operation to complete.

Parameters
Timeoutmaximum flash operation timeout
Return values
HAL_StatusTypeDefHAL Status

Definition at line 1070 of file stm32h7xx_hal_flash.c.

1071{
1072 (void)Timeout;
1073 /* Get timeout */
1074 //uint32_t tickstart = HAL_GetTick();
1075
1076 /* Wait for the FLASH Option Bytes change operation to complete by polling on OPT_BUSY flag to be reset */
1077 while(READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_OPT_BUSY) != 0U)
1078 {
1079 // TODO: rusefi own timeout
1080 /*if(Timeout != HAL_MAX_DELAY)
1081 {
1082 if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1083 {
1084 return HAL_TIMEOUT;
1085 }
1086 }*/
1087 }
1088
1089 /* Check option byte change error */
1090 if(READ_BIT(FLASH->OPTSR_CUR, FLASH_OPTSR_OPTCHANGEERR) != 0U)
1091 {
1092 /* Save the error code */
1093 pFlash.ErrorCode |= HAL_FLASH_ERROR_OB_CHANGE;
1094
1095 /* Clear the OB error flag */
1096 FLASH->OPTCCR |= FLASH_OPTCCR_CLR_OPTCHANGEERR;
1097
1098 return HAL_ERROR;
1099 }
1100
1101 /* If there is no error flag set */
1102 return HAL_OK;
1103}

Referenced by HAL_FLASHEx_ComputeCRC().

Here is the caller graph for this function:

◆ FLASH_Program_Byte()

static void FLASH_Program_Byte ( uint32_t  Address,
uint8_t  Data 
)
static

Program byte (8-bit) at a specified address.

Note
This function must be used when the device voltage range is from 2.7V to 3.6V.
If an erase and a program operations are requested simultaneously,
the erase operation is performed before the program one.
Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Return values
None

Definition at line 705 of file stm32f4xx_hal_flash.c.

706{
707 /* Check the parameters */
708 assert_param(IS_FLASH_ADDRESS(Address));
709
710 /* If the previous operation is completed, proceed to program the new data */
711 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
712 FLASH->CR |= FLASH_PSIZE_BYTE;
713 FLASH->CR |= FLASH_CR_PG;
714
715 *(__IO uint8_t*)Address = Data;
716}

Referenced by HAL_FLASH_Program(), and HAL_FLASH_Program_IT().

Here is the caller graph for this function:

◆ FLASH_Program_DoubleWord()

static void FLASH_Program_DoubleWord ( uint32_t  Address,
uint64_t  Data 
)
static

Program a double word (64-bit) at a specified address.

Note
This function must be used when the device voltage range is from 2.7V to 3.6V and an External Vpp is present.
If an erase and a program operations are requested simultaneously,
the erase operation is performed before the program one.
Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Return values
None

Definition at line 629 of file stm32f4xx_hal_flash.c.

630{
631 /* Check the parameters */
632 assert_param(IS_FLASH_ADDRESS(Address));
633
634 /* If the previous operation is completed, proceed to program the new data */
635 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
636 FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD;
637 FLASH->CR |= FLASH_CR_PG;
638
639 *(__IO uint64_t*)Address = Data;
640}

Referenced by HAL_FLASH_Program(), and HAL_FLASH_Program_IT().

Here is the caller graph for this function:

◆ FLASH_Program_HalfWord()

static void FLASH_Program_HalfWord ( uint32_t  Address,
uint16_t  Data 
)
static

Program a half-word (16-bit) at a specified address.

Note
This function must be used when the device voltage range is from 2.7V to 3.6V.
If an erase and a program operations are requested simultaneously,
the erase operation is performed before the program one.
Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Return values
None

Definition at line 680 of file stm32f4xx_hal_flash.c.

681{
682 /* Check the parameters */
683 assert_param(IS_FLASH_ADDRESS(Address));
684
685 /* If the previous operation is completed, proceed to program the new data */
686 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
687 FLASH->CR |= FLASH_PSIZE_HALF_WORD;
688 FLASH->CR |= FLASH_CR_PG;
689
690 *(__IO uint16_t*)Address = Data;
691}

Referenced by HAL_FLASH_Program(), and HAL_FLASH_Program_IT().

Here is the caller graph for this function:

◆ FLASH_Program_Word()

static void FLASH_Program_Word ( uint32_t  Address,
uint32_t  Data 
)
static

Program word (32-bit) at a specified address.

Note
This function must be used when the device voltage range is from 2.7V to 3.6V.
If an erase and a program operations are requested simultaneously,
the erase operation is performed before the program one.
Parameters
Addressspecifies the address to be programmed.
Dataspecifies the data to be programmed.
Return values
None

Definition at line 655 of file stm32f4xx_hal_flash.c.

656{
657 /* Check the parameters */
658 assert_param(IS_FLASH_ADDRESS(Address));
659
660 /* If the previous operation is completed, proceed to program the new data */
661 CLEAR_BIT(FLASH->CR, FLASH_CR_PSIZE);
662 FLASH->CR |= FLASH_PSIZE_WORD;
663 FLASH->CR |= FLASH_CR_PG;
664
665 *(__IO uint32_t*)Address = Data;
666}

Referenced by HAL_FLASH_Program(), and HAL_FLASH_Program_IT().

Here is the caller graph for this function:

◆ FLASH_SetErrorCode()

static void FLASH_SetErrorCode ( void  )
static

Set the specific FLASH error flag.

Return values
None

Definition at line 722 of file stm32f4xx_hal_flash.c.

723{
724 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET)
725 {
726 pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
727
728 /* Clear FLASH write protection error pending bit */
729 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_WRPERR);
730 }
731
732 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET)
733 {
734 pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA;
735
736 /* Clear FLASH Programming alignment error pending bit */
737 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGAERR);
738 }
739
740 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR) != RESET)
741 {
742 pFlash.ErrorCode |= HAL_FLASH_ERROR_PGP;
743
744 /* Clear FLASH Programming parallelism error pending bit */
745 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGPERR);
746 }
747
748 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGSERR) != RESET)
749 {
750 pFlash.ErrorCode |= HAL_FLASH_ERROR_PGS;
751
752 /* Clear FLASH Programming sequence error pending bit */
753 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_PGSERR);
754 }
755
756 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) != RESET)
757 {
758 pFlash.ErrorCode |= HAL_FLASH_ERROR_RD;
759
760 /* Clear FLASH Proprietary readout protection error pending bit */
761 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_RDERR);
762 }
763
764 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR) != RESET)
765 {
766 pFlash.ErrorCode |= HAL_FLASH_ERROR_OPERATION;
767
768 /* Clear FLASH Operation error pending bit */
769 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_OPERR);
770 }
771}
FLASH_ProcessTypeDef pFlash

Referenced by FLASH_WaitForLastOperation(), and HAL_FLASH_IRQHandler().

Here is the caller graph for this function:

◆ FLASH_WaitForLastOperation() [1/2]

HAL_StatusTypeDef FLASH_WaitForLastOperation ( uint32_t  Timeout)

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.

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

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

◆ FLASH_WaitForLastOperation() [2/2]

HAL_StatusTypeDef FLASH_WaitForLastOperation ( uint32_t  Timeout,
uint32_t  Bank 
)

Wait for a FLASH operation to complete.

Parameters
Timeoutmaximum flash operation timeout
Bankflash FLASH_BANK_1 or FLASH_BANK_2
Return values
HAL_StatusTypeDefHAL Status

Definition at line 993 of file stm32h7xx_hal_flash.c.

994{
995 (void)Timeout;
996
997 /* Wait for the FLASH operation to complete by polling on QW flag to be reset.
998 Even if the FLASH operation fails, the QW flag will be reset and an error
999 flag will be set */
1000
1001 uint32_t bsyflag = FLASH_FLAG_QW_BANK1;
1002 uint32_t errorflag = FLASH->SR1 & FLASH_FLAG_ALL_ERRORS_BANK1;
1003 //uint32_t tickstart = HAL_GetTick();
1004
1005 assert_param(IS_FLASH_BANK_EXCLUSIVE(Bank));
1006
1007#if defined (DUAL_BANK)
1008
1009 if (Bank == FLASH_BANK_2)
1010 {
1011 /* Get Error Flags */
1012 errorflag = (FLASH->SR2 & FLASH_FLAG_ALL_ERRORS_BANK2) | 0x80000000U;
1013 /* Select bsyflag depending on Bank */
1014 bsyflag = FLASH_FLAG_QW_BANK2;
1015 }
1016#endif /* DUAL_BANK */
1017
1018 while(__HAL_FLASH_GET_FLAG(bsyflag))
1019 {
1020 if(Timeout != HAL_MAX_DELAY)
1021 {
1022 // todo: implement rusEfi own timeout
1023 // if(((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
1024 // {
1025 // return HAL_TIMEOUT;
1026 // }
1027 }
1028 }
1029
1030 /* In case of error reported in Flash SR1 or SR2 register */
1031 if((errorflag & 0x7FFFFFFFU) != 0U)
1032 {
1033 /*Save the error code*/
1034 pFlash.ErrorCode |= errorflag;
1035
1036 /* Clear error programming flags */
1037 __HAL_FLASH_CLEAR_FLAG(errorflag);
1038
1039 return HAL_ERROR;
1040 }
1041
1042 /* Check FLASH End of Operation flag */
1043 if(Bank == FLASH_BANK_1)
1044 {
1045 if (__HAL_FLASH_GET_FLAG_BANK1(FLASH_FLAG_EOP_BANK1))
1046 {
1047 /* Clear FLASH End of Operation pending bit */
1048 __HAL_FLASH_CLEAR_FLAG_BANK1(FLASH_FLAG_EOP_BANK1);
1049 }
1050 }
1051#if defined (DUAL_BANK)
1052 else
1053 {
1054 if (__HAL_FLASH_GET_FLAG_BANK2(FLASH_FLAG_EOP_BANK2))
1055 {
1056 /* Clear FLASH End of Operation pending bit */
1057 __HAL_FLASH_CLEAR_FLAG_BANK2(FLASH_FLAG_EOP_BANK2);
1058 }
1059 }
1060#endif /* DUAL_BANK */
1061
1062 return HAL_OK;
1063}

Referenced by HAL_FLASH_Program(), and HAL_FLASH_Program_IT().

Here is the caller graph for this function: