Flash Copier Function Documentation

 

Sys_Flash_Copy

void Sys_Flash_Copy(FLASH_Type * flash, uint32_t src_addr, uint32_t dest_addr, uint32_t length, uint32_t cpy_dest)

 

Copy data from the flash memory to a RAM memory instance.

 

Location: flash_copier.h:55

 

Parameters

Direction Name Description

in

flash

Pointer to the flash instance

in

src_addr

Source address in flash to copy data from

in

dest_addr

Destination address in RAM to copy data to

in

length

Number of words to copy

in

cpy_dest

Destination copier is CRC or memories; use COPY_TO_[CRC | MEM], and COPY_TO_[32 | 40]_BIT

 

Assumptions

src_addr points to an address in flash memory dest_addr points to an address in RAM memory The flash copy does not need to be complete before returning If CRC is selected as the destination, dest_addr is ignored and 32-bit copy mode is selected automatically.

 

Example Code for Sys_Flash_Copy

    // Copy a block of 256 bytes from flash to RAM.

    uint32_t srcAddr = (uint32_t)0x001D8000;

    uint32_t destAddr = (uint32_t)0x2000E000;

    Sys_Flash_Copy(FLASH, srcAddr, destAddr, 0x100, COPY_TO_MEM | COPY_TO_32BIT);

 

Sys_Flash_Compare

uint32_t Sys_Flash_Compare(FLASH_Type * flash, uint32_t cfg, uint32_t addr, uint32_t length, uint32_t value, uint32_t value_ecc)

 

Compare data in the flash to a pre-specified value.

 

Location: flash_copier.h:76

 

Parameters

Direction Name Description

in

flash

Pointer to the flash instance

in

cfg

Flash comparator configuration; use COMP_MODE_[CONSTANT | CHBK]_BYTE, COMP_ADDR_[DOWN | UP]_BYTE, and COMP_ADDR_STEP_*_BYTE

in

addr

Base address of the area to verify

in

length

Number of words to verify

in

value

Value that the words read from flash will be compared against

in

value_ecc

Value that the error-correction coding bits from the extended words read from flash will be compared against

 


Return


0 if comparison succeeded, 1 if the comparison failed.

 

Assumptions

addr points to an address in flash memory

 

Example Code for Sys_Flash_Compare

    // Verify that 256 bytes in flash are all 0xFFFFFFFF. 

    uint32_t srcAddr = (uint32_t)0x001D8000;

    Sys_Flash_Compare(FLASH, COMP_MODE_CONSTANT_BYTE |

                             COMP_ADDR_UP_BYTE       |

                             COMP_ADDR_STEP_1_BYTE,

                             srcAddr, 0x100, 0xFFFFFFFF, 0);

 

Sys_Flash_CalculateCRC

uint32_t Sys_Flash_CalculateCRC(FLASH_Type * flash, uint32_t addr, uint32_t length, uint32_t * crc)

 

Calculate CRC of words in flash using flash copier.

 

Location: flash_copier.h:91

 

Parameters

Direction Name Description

in

flash

Flash instance being used

in

addr

Address belonging to the flash instance

in

length

Total number of words used in CRC calculation

out

crc

CRC value calculated using CRC peripheral

 


Return


0 if calculation has succeeded, 1 if the calculation has failed.

 

NOTE: Flash copier and CRC register are modified

 

Example Code for Sys_Flash_CalculateCRC

    // Perform CRC of the 256 bytes in flash at srcAddr.

    uint32_t srcAddr = (uint32_t)0x001D8000;

    Sys_Flash_CalculateCRC(FLASH, COMP_MODE_CONSTANT_BYTE |

                             COMP_ADDR_UP_BYTE       |

                             COMP_ADDR_STEP_1_BYTE,

                             srcAddr, 0x100, 0xFFFFFFFF, 0);