Flash Library Reference Function Documentation

 

Flash_Initialize

FlashStatus_t Flash_Initialize(unsigned int num, FlashClockFrequency_t freq)

 

Location: flash.h:155

 

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). num Flash instance to be initialized freq Flash clock frequency in Hertz, only defined frequencies supported

See: FlashClockFrequency_t


Returns:
Flash API status code

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.

See: FlashClockFrequency_t


Returns:
Flash API status code

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.

 

Parameters

Direction Name Description

in

num

Flash instance to be initialized

in

freq

Flash clock frequency in Hertz, only defined frequencies supported

 

Flash_WriteWord

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

 

Location: flash.h:175

 

Write a word to a flash address.

 

This function writes a single word to flash. addr Address of the word to be written. word Data to be written to flash. enb_endurance Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of the data programmed.

Returns:
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.


Returns:
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.

 

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.

 

Flash_WriteBuffer

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

 

Location: flash.h:207

 

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. addr Address of first word location in flash. word_length Total number of words to be written to flash. words A 32-bit C pointer to the memory location of
the buffer to be written to flash.
enb_endurance Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of data programmed.

Returns:
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.


Returns:
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.

 

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.

 

Flash_WriteDouble

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

 

Location: flash.h:234

 

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.
A read-back verification is performed after write to ensure the write has been successful. addr Address of the word to be written in flash. 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.
enb_endurance Set to 0 for default flash endurance;
Set to 1 to enable two-stage programming for higher endurance of data programmed.

Returns:
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.


A read-back verification is performed after write to ensure the write has been successful.
Returns:
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.

 

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.

 

Flash_ReadWord

FlashStatus_t Flash_ReadWord(uint32_t addr, uint32_t * word)

 

Location: flash.h:251

 

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. addr Address in flash to be read. word 32-bit C pointer to the word read from flash.
Returns:
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.


Returns:
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.

 

Parameters

Direction Name Description

in

addr

Address in flash to be read.

out

word

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

 

Flash_ReadBuffer

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

 

Location: flash.h:272

 

Read contents of flash into a static memory buffer.

 

This function uses the flash copier to read contents of flash into a memory buffer. flash_addr Address of first word location in flash. dram_addr Address of first word location in static memory. word_length Total number of words to be read from flash.
Returns:
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.


Returns:
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.

 

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.

 

Flash_ReadDouble

FlashStatus_t Flash_ReadDouble(uint32_t addr, uint32_t * word)

 

Location: flash.h:297

 

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.

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

addr Address of the word to be read from flash. 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.

Returns:
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.


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


Returns:
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.

 

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.

 

Flash_EraseFlashBank

FlashStatus_t Flash_EraseFlashBank(uint32_t num)

 

Location: flash.h:315

 

Erase a single flash bank.

 

This function erases all code and data regions of a flash instance. num Flash instance not to be erased.
Returns:
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.


Returns:
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.

 

Parameters

Direction Name Description

in

num

Flash instance not to be erased.

 

Flash_EraseChip

FlashStatus_t Flash_EraseChip()

 

Location: flash.h:332

 

Erase all data and code flash.

 

This function erases all code and data regions of all flash instances.
Returns:
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.


Returns:
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)

 

Location: flash.h:348

 

Erase a sector flash.

 

This function erases a flash sector (512 words for code, 64 words for data). addr An address within the flash sector to be erased. enb_endurance Set to 0 for default flash endurance;
Set to 1 to enable two-stage erase iteration for higher endurance of flash.

Returns:
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.


Returns:
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.

 

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.

 

Flash_BlankCheck

FlashStatus_t Flash_BlankCheck(uint32_t addr, unsigned int word_length)

 

Location: flash.h:364

 

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). addr Address of the first word in flash to be verified. word_length Total number of words to be verified.
Returns:
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.


Returns:
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.

 

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.