Flash Library Reference Function Documentation

 

Flash_Initialize

FlashStatus_t Flash_Initialize(unsigned int num, FlashClockFrequency_t freq)

 

Initialize clock and access to flash.

 

This function powers-up and enables access to a flash region. It also applies the correct delay settings based on the specified flash clock frequency (freq).

 

Location: flash.h:85

 

Parameters

Direction Name Description

in

num

Flash instance to be initialized

in

freq

Flash clock frequency in Hertz, only defined frequencies supported

 


Return


Flash API status code

 

See: FlashClockFrequency_t

See: FlashStatus_t

NOTE: System clock frequency should not be changed while the flash is being erased or programmed.
An accurate system clock frequency of 1 MHz or higher is required for proper flash operation. If using the RC oscillator, care must be taken as the trimmed frequency for this oscillator has a high temperature dependency.

 

Flash_WriteWord

FlashStatus_t Flash_WriteWord(uint32_t addr, uint32_t word, bool enb_endurance)

 

Write a word to a flash address.

 

This function writes a single word to flash.

 

Location: flash.h:105

 

Parameters

Direction Name Description

in

addr

Address of the word to be written.

in

word

Data to be written to flash.

in

enb_endurance

Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of the data programmed.

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: addr must be word aligned.
Contents of flash must be erased prior to performing a write.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_WriteBuffer

FlashStatus_t Flash_WriteBuffer(uint32_t addr, uint32_t word_length, const uint32_t * words, bool enb_endurance)

 

Write contents of a static memory buffer to flash.

 

This function writes the contents of a static memory buffer to flash. A read-back verification is performed after write to ensure the write has been successful.

 

Location: flash.h:137

 

Parameters

Direction Name Description

in

addr

Address of first word location in flash.

in

word_length

Total number of words to be written to flash.

in

words

A 32-bit C pointer to the memory location of
the buffer to be written to flash.

in

enb_endurance

Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of data programmed.

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: addr must be word aligned.
Contents of flash must be erased prior to performing a write.
Interrupts are disabled during critical sections, to ensure proper flash operation.
Applications must ensure that the function completes and that the return value is FLASH_ERR_NONE to consider the two-stage programming to be complete.
Source address of data being read and destination address being written, can not be part the same flash instance.
CRC peripheral registers are modified during execution, and restored before returning. The CRC must not be used by the application while writing the buffer to flash.

 

Flash_WriteDouble

FlashStatus_t Flash_WriteDouble(uint32_t addr, const uint32_t * word, bool enb_endurance)

 

Write a 38-bit word to flash.

 

This function temporarily disables automatic flash ECC generation, allowing the user to write 38-bits to a single word address in flash.

 

Location: flash.h:164

 

Parameters

Direction Name Description

in

addr

Address of the word to be written in flash.

in

word

32-bit C pointer to the word and ECC data to be written to flash:

  • word[0] contains the data to be written to flash
  • word[1] [5:0] contains the 6-bit data to be written as the ECC value.

in

enb_endurance

Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of data programmed.

 


Return


Flash API status code

 


A read-back verification is performed after write to ensure the write has been successful.

See: FlashStatus_t

NOTE: addr must be word aligned.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_ReadWord

FlashStatus_t Flash_ReadWord(uint32_t addr, uint32_t * word)

 

Read a 32-bit word from flash.

 

This function reads a 32-bit word from flash. If ECC is enabled (default), hardware will log/generate interrupt on ECC errors.

 

Location: flash.h:181

 

Parameters

Direction Name Description

in

addr

Address in flash to be read.

out

word

32-bit C pointer to the word read from flash.

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: addr must be word aligned.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_ReadBuffer

FlashStatus_t Flash_ReadBuffer(uint32_t flash_addr, uint32_t dram_addr, unsigned int word_length)

 

Read contents of flash into a static memory buffer.

 

This function uses the flash copier to read contents of flash into a memory buffer.

 

Location: flash.h:202

 

Parameters

Direction Name Description

in

flash_addr

Address of first word location in flash.

in

dram_addr

Address of first word location in static memory.

in

word_length

Total number of words to be read from flash.

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: flash_addr and dram_addr must be word aligned.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.
This function fails if the DMA or CryptoCell continuously blocks memory accesses by the flash copier by accessing memory on every cycle.

 

Flash_ReadDouble

FlashStatus_t Flash_ReadDouble(uint32_t addr, uint32_t * word)

 

Read a 38-bit word from flash.

 

This function temporarily disables automatic flash ECC generation, allowing the user to read all 38 bits from a single word address in flash.

 

Location: flash.h:227

 

Parameters

Direction Name Description

in

addr

Address of the word to be read from flash.

out

word

32-bit C pointer to the word and ECC data read from flash:

  • word[0] contains the data to word read from flash.
  • word[1] [5:0] contains the 6-bit data ECC value read.

 


Return


Flash API status code

 


NOTE: ECC checks are not performed on the 32-bit data word or 6-bit ECC value.

See: FlashStatus_t

NOTE: addr must be word aligned.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_EraseFlashBank

FlashStatus_t Flash_EraseFlashBank(uint32_t num)

 

Erase a single flash bank.

 

This function erases all code and data regions of a flash instance.

 

Location: flash.h:245

 

Parameters

Direction Name Description

in

num

Flash instance not to be erased.

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: A blank check is not performed to ensure that the flash has been successfully erased. Flash_BlankCheck can be used by an application to verify if the erase has been successful.
NVR regions are not erased. Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_EraseChip

FlashStatus_t Flash_EraseChip()

 

Erase all data and code flash.

 

This function erases all code and data regions of all flash instances.

 

Location: flash.h:262

 


Return


Flash API status code

 

See: FlashStatus_t

NOTE: A blank check is not performed to ensure that the flash has been successfully erased. Flash_BlankCheck can be used by an application to verify if the erase has been successful.
NVR regions are not erased.
Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_EraseSector

FlashStatus_t Flash_EraseSector(uint32_t addr, bool enb_endurance)

 

Erase a sector flash.

 

This function erases a flash sector (512 words for code, 64 words for data).

 

Location: flash.h:278

 

Parameters

Direction Name Description

in

addr

An address within the flash sector to be erased.

in

enb_endurance

Set to 0 for default flash endurance;
Set to 1 to enable two-stage erase iteration for higher endurance of flash.

 


Return


Flash API status code. See FlashStatus_t

 

NOTE: Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.

 

Flash_BlankCheck

FlashStatus_t Flash_BlankCheck(uint32_t addr, unsigned int word_length)

 

Check if flash region is blank.

 

This function uses the flash copier in comparator mode to verify if the flash contents are empty (i.e containing the erase value 0xFFFFFFFF).

 

Location: flash.h:294

 

Parameters

Direction Name Description

in

addr

Address of the first word in flash to be verified.

in

word_length

Total number of words to be verified.

 


Return


Flash API status code FlashStatus_t

 

NOTE: Interrupts are not disabled; operation is undefined if the calling application modifies the values of flash registers before returning from this function call.
addr must be word aligned.