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

Modules

 Programming operation functions
 Programming operation functions.
 
 Peripheral Control functions
 management functions
 
 Peripheral State and Errors functions
 Peripheral Errors functions.
 

Functions

HAL_StatusTypeDef FLASH_WaitForLastOperation (uint32_t Timeout)
 Wait for a FLASH operation to complete.
 
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.
 

Detailed Description

Function Documentation

◆ 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 767 of file stm32f7xx_hal_flash.c.

768{
769 /* Check the parameters */
770 assert_param(IS_FLASH_ADDRESS(Address));
771
772 /* If the previous operation is completed, proceed to program the new data */
773 FLASH->CR &= CR_PSIZE_MASK;
774 FLASH->CR |= FLASH_PSIZE_BYTE;
775 FLASH->CR |= FLASH_CR_PG;
776
777 *(__IO uint8_t*)Address = Data;
778
779 /* Data synchronous Barrier (DSB) Just after the write operation
780 This will force the CPU to respect the sequence of instruction (no optimization).*/
781 __DSB();
782}

◆ 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 678 of file stm32f7xx_hal_flash.c.

679{
680 /* Check the parameters */
681 assert_param(IS_FLASH_ADDRESS(Address));
682
683 /* If the previous operation is completed, proceed to program the new data */
684 FLASH->CR &= CR_PSIZE_MASK;
685 FLASH->CR |= FLASH_PSIZE_DOUBLE_WORD;
686 FLASH->CR |= FLASH_CR_PG;
687
688 *(__IO uint64_t*)Address = Data;
689
690 /* Data synchronous Barrier (DSB) Just after the write operation
691 This will force the CPU to respect the sequence of instruction (no optimization).*/
692 __DSB();
693}

◆ 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 737 of file stm32f7xx_hal_flash.c.

738{
739 /* Check the parameters */
740 assert_param(IS_FLASH_ADDRESS(Address));
741
742 /* If the previous operation is completed, proceed to program the new data */
743 FLASH->CR &= CR_PSIZE_MASK;
744 FLASH->CR |= FLASH_PSIZE_HALF_WORD;
745 FLASH->CR |= FLASH_CR_PG;
746
747 *(__IO uint16_t*)Address = Data;
748
749 /* Data synchronous Barrier (DSB) Just after the write operation
750 This will force the CPU to respect the sequence of instruction (no optimization).*/
751 __DSB();
752
753}

◆ 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 708 of file stm32f7xx_hal_flash.c.

709{
710 /* Check the parameters */
711 assert_param(IS_FLASH_ADDRESS(Address));
712
713 /* If the previous operation is completed, proceed to program the new data */
714 FLASH->CR &= CR_PSIZE_MASK;
715 FLASH->CR |= FLASH_PSIZE_WORD;
716 FLASH->CR |= FLASH_CR_PG;
717
718 *(__IO uint32_t*)Address = Data;
719
720 /* Data synchronous Barrier (DSB) Just after the write operation
721 This will force the CPU to respect the sequence of instruction (no optimization).*/
722 __DSB();
723}

◆ FLASH_SetErrorCode()

static void FLASH_SetErrorCode ( void  )
static

Set the specific FLASH error flag.

Return values
None

Definition at line 788 of file stm32f7xx_hal_flash.c.

789{
790 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPERR) != RESET)
791 {
792 pFlash.ErrorCode |= HAL_FLASH_ERROR_OPERATION;
793 }
794
795 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) != RESET)
796 {
797 pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
798 }
799
800 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR) != RESET)
801 {
802 pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA;
803 }
804
805 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGPERR) != RESET)
806 {
807 pFlash.ErrorCode |= HAL_FLASH_ERROR_PGP;
808 }
809
810 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ERSERR) != RESET)
811 {
812 pFlash.ErrorCode |= HAL_FLASH_ERROR_ERS;
813 }
814
815#if defined (FLASH_OPTCR2_PCROP)
816 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) != RESET)
817 {
818 pFlash.ErrorCode |= HAL_FLASH_ERROR_RD;
819 }
820#endif /* FLASH_OPTCR2_PCROP */
821
822 /* Clear error programming flags */
823 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_ALL_ERRORS);
824}
FLASH_ProcessTypeDef pFlash

Referenced by FLASH_WaitForLastOperation().

Here is the caller graph for this function:

◆ FLASH_WaitForLastOperation()

HAL_StatusTypeDef FLASH_WaitForLastOperation ( uint32_t  Timeout)

Wait for a FLASH operation to complete.

Parameters
Timeoutmaximum flash operationtimeout
Return values
HALStatus

Definition at line 618 of file stm32f7xx_hal_flash.c.

619{
620 (void)Timeout;
621 //uint32_t tickstart = 0;
622
623 /* Clear Error Code */
624 pFlash.ErrorCode = HAL_FLASH_ERROR_NONE;
625
626 /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
627 Even if the FLASH operation fails, the BUSY flag will be reset and an error
628 flag will be set */
629 /* Get tick */
630 // todo: implement rusEfi own timeout
631 //tickstart = HAL_GetTick();
632
633 while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) != RESET)
634 {
635 /*
636 // todo: implement rusEfi own timeout
637 if(Timeout != HAL_MAX_DELAY)
638 {
639 if((Timeout == 0)||((HAL_GetTick() - tickstart ) > Timeout))
640 {
641 return HAL_TIMEOUT;
642 }
643 }
644 */
645 }
646
647 if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_ALL_ERRORS) != RESET)
648 {
649 /*Save the error code*/
651 return HAL_ERROR;
652 }
653
654 /* Check FLASH End of Operation flag */
655 if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP) != RESET)
656 {
657 /* Clear FLASH End of Operation pending bit */
658 __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
659 }
660
661 /* If there is an error flag set */
662 return HAL_OK;
663
664}
static void FLASH_SetErrorCode(void)
Set the specific FLASH error flag.

Referenced by FLASH_OB_BootConfig(), FLASH_OB_DisablePCROP(), FLASH_OB_DisablePCROP(), FLASH_OB_DisableWRP(), FLASH_OB_EnablePCROP(), FLASH_OB_EnablePCROP(), FLASH_OB_EnableWRP(), FLASH_OB_RDP_LevelConfig(), FLASH_OB_UserConfig(), and HAL_FLASHEx_Erase().

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