Macros | Enumerations | Functions
FlashWFF3.h File Reference
#include <stdint.h>
#include <string.h>
#include <ti/devices/DeviceFamily.h>
#include <DeviceFamily_constructPath(driverlib/xip.h)>
#include <DeviceFamily_constructPath(driverlib/ospi.h)>
#include <DeviceFamily_constructPath(driverlib/debug.h)>
Include dependency graph for FlashWFF3.h:

Go to the source code of this file.

Macros

#define FLASH_STATUS_SUCCESS   0x00000000
 
#define FLASH_TIMEOUT_REACHED_ERROR   (-1300)
 
#define PSRAM_XIP_OFFSET   (0x100)
 
#define DEVICE_SWITCH_ERROR   (-1)
 
#define FLASH_WR_BOUND_SIZE_IN_BYTES   64U
 
#define FLASH_RD_BOUND_SIZE_IN_BYTES   256U
 
#define __IF__(x)   (x)
 
#define __THEN__(x)   ? (x)
 
#define __ELSE__(x)   : (x)
 
#define __ELSE_IF__(x)   : (x)
 
#define OSPI_IDLE_XSPI_COUNTER_BEFORE_TIMEOUT   100
 
#define BITMASK_x_0(x)
 
#define BITMASK_x_y(x, y)
 
#define FLASH_STIG_CONFIG_ENTER   0
 
#define FLASH_STIG_CONFIG_EXIT   1
 
#define FLASH_STIG_CONFIG_PRE_READ   2
 
#define FLASH_STIG_CONFIG_EXECUTE_READ   3
 
#define FLASH_STIG_CONFIG_POST_READ   4
 
#define FLASH_STIG_CONFIG_PRE_WRITE   5
 
#define FLASH_STIG_CONFIG_EXECUTE_WRITE   6
 
#define FLASH_STIG_CONFIG_POST_WRITE   7
 
#define FLASH_STIG_CONFIG_PRE_ERASE   8
 
#define FLASH_STIG_CONFIG_EXECUTE_ERASE   9
 
#define FLASH_STIG_CONFIG_POST_ERASE   10
 

Enumerations

enum  FlashOtfdeStateSet { FLASH_OTFDE_DISABLE = 0, FLASH_OTFDE_ENABLE = 1 }
 
enum  FlashUdmaJobStatus { FLASH_UDMA_JOB_DONE = 0, FLASH_UDMA_JOB_ERROR = 1 }
 
enum  FlashStigStatus { FLASH_STIG_DONE = 0, FLASH_STIG_TIMEOUT = 1, FLASH_STIG_ERROR = 2 }
 

Functions

void FlashRead (uint32_t *readFromAddr, uint32_t *writeToAddr, uint32_t length)
 Read from external memory. More...
 
FlashStigStatus FlashReadSTIG (uint32_t readStartAddr, uint32_t *writeToAddr, uint8_t DeviceNum)
 Read from external memory using STIG command. More...
 
FlashStigStatus FlashExecuteReadSTIGCommand (uint32_t srcReadAddr, uint32_t *writeToAddr)
 Execute read of one word from Flash based on STIG write command. More...
 
void FlashWrite (uint32_t *readFromAddr, uint32_t *writeToAddr, uint32_t length)
 Write to external memory. More...
 
FlashStigStatus FlashWriteSTIG (uint32_t *readFromAddr, uint32_t *writeToAddr, uint8_t DeviceNum)
 Write to external memory using STIG command. More...
 
FlashStigStatus FlashExecuteWriteSTIGCommand (uint32_t srcWriteData, uint32_t srcWriteAddrPhy)
 Execute write to Flash based on STIG write command. More...
 
void FlashSetOTFDE (uint8_t setState)
 Enable/Disable the OTFDE. More...
 
uint32_t FlashExecutePolling (void)
 read flash status register until WIP (write in process) indication is free. More...
 
FlashStigStatus FlashExecuteEraseSTIGCommand (uint32_t EraseAddr_en, uint32_t srcEraseAddr)
 Execute erase Flash based on STIG command. More...
 
FlashStigStatus FlashSectorErase (uint32_t eraseStartAddr, uint8_t DeviceNum)
 Execute erase Flash based on STIG command. More...
 
void FlashSetTickPeriod (uint32_t TickPeriod)
 Store the ClockP period internally. More...
 
uint32_t FlashIsXspiIdle ()
 xSPI (accessible) idle check before STIG execution. More...
 

Macro Definition Documentation

§ FLASH_STATUS_SUCCESS

#define FLASH_STATUS_SUCCESS   0x00000000

Function completed successfully

§ FLASH_TIMEOUT_REACHED_ERROR

#define FLASH_TIMEOUT_REACHED_ERROR   (-1300)

timeout status error

§ PSRAM_XIP_OFFSET

#define PSRAM_XIP_OFFSET   (0x100)

Offset for PSRAM XIP Configuration

§ DEVICE_SWITCH_ERROR

#define DEVICE_SWITCH_ERROR   (-1)

§ FLASH_WR_BOUND_SIZE_IN_BYTES

#define FLASH_WR_BOUND_SIZE_IN_BYTES   64U

< UDMA Data movement boundary for write command (page program) Internal memory to External memory UDMA Data movement boundary for read command External memory to Internal memory

§ FLASH_RD_BOUND_SIZE_IN_BYTES

#define FLASH_RD_BOUND_SIZE_IN_BYTES   256U

§ __IF__

#define __IF__ (   x)    (x)

§ __THEN__

#define __THEN__ (   x)    ? (x)

§ __ELSE__

#define __ELSE__ (   x)    : (x)

§ __ELSE_IF__

#define __ELSE_IF__ (   x)    : (x)

§ OSPI_IDLE_XSPI_COUNTER_BEFORE_TIMEOUT

#define OSPI_IDLE_XSPI_COUNTER_BEFORE_TIMEOUT   100

§ BITMASK_x_0

#define BITMASK_x_0 (   x)
Value:
(__IF__((x) == 31) /* For x==31, we immediately return 0xFFFFFFFF */ \
__THEN__(0xFFFFFFFF) /* For other x, we return 2^(x+1) - 1. */ \
__ELSE__((1 << ((x) + 1)) - 1))
#define __IF__(x)
Definition: FlashWFF3.h:73

BITMASK_x_0() returns a bit mask of "1" from Bits[x:0]

E.g., for x=5

BITMASK_x_0(5) = ........111111 Bits[5:0] = "111111" BITMASK_x_0(0) = .............1 Bits[0:0] = "000001"

§ BITMASK_x_y

#define BITMASK_x_y (   x,
 
)
Value:
(__IF__((y) == 0) /* For y==0, we return Bits[x:0] */ \
__THEN__(BITMASK_x_0(x)) /* For y> 0, we return Bits[x:0] - Bits[y-1:0] */ \
__ELSE__(BITMASK_x_0(x) - BITMASK_x_0((y)-1)))
#define BITMASK_x_0(x)
Definition: FlashWFF3.h:88
#define __IF__(x)
Definition: FlashWFF3.h:73

BITMASK_x_y() returns a bit mask of "1" from Bits[x:y] (naturally, x >= y should be enforces by the caller!!)

E.g., for x=5, y=2

BITMASK_x_y(5,5) = ......1..... Bits[5:5] = "100000" BITMASK_x_y(5,2) = ......1111.. Bits[5:0] = "111100" BITMASK_x_0(5,1) = ......11111. Bits[5:1] = "111110" BITMASK_x_0(5,0) = ......111111 Bits[5:0] = "111111"

§ FLASH_STIG_CONFIG_ENTER

#define FLASH_STIG_CONFIG_ENTER   0

§ FLASH_STIG_CONFIG_EXIT

#define FLASH_STIG_CONFIG_EXIT   1

§ FLASH_STIG_CONFIG_PRE_READ

#define FLASH_STIG_CONFIG_PRE_READ   2

§ FLASH_STIG_CONFIG_EXECUTE_READ

#define FLASH_STIG_CONFIG_EXECUTE_READ   3

§ FLASH_STIG_CONFIG_POST_READ

#define FLASH_STIG_CONFIG_POST_READ   4

§ FLASH_STIG_CONFIG_PRE_WRITE

#define FLASH_STIG_CONFIG_PRE_WRITE   5

§ FLASH_STIG_CONFIG_EXECUTE_WRITE

#define FLASH_STIG_CONFIG_EXECUTE_WRITE   6

§ FLASH_STIG_CONFIG_POST_WRITE

#define FLASH_STIG_CONFIG_POST_WRITE   7

§ FLASH_STIG_CONFIG_PRE_ERASE

#define FLASH_STIG_CONFIG_PRE_ERASE   8

§ FLASH_STIG_CONFIG_EXECUTE_ERASE

#define FLASH_STIG_CONFIG_EXECUTE_ERASE   9

§ FLASH_STIG_CONFIG_POST_ERASE

#define FLASH_STIG_CONFIG_POST_ERASE   10

Enumeration Type Documentation

§ FlashOtfdeStateSet

Enumerator
FLASH_OTFDE_DISABLE 

Bit configuration to disable OTFDE control over XSPI

FLASH_OTFDE_ENABLE 

Bit configuration to enable OTFDE control over XSPI

§ FlashUdmaJobStatus

Enumerator
FLASH_UDMA_JOB_DONE 

UDMA job completed successfully

FLASH_UDMA_JOB_ERROR 

UDMA job did not completed successfully

§ FlashStigStatus

Enumerator
FLASH_STIG_DONE 

STIG command completed successfully

FLASH_STIG_TIMEOUT 

STIG command completed with timeout

FLASH_STIG_ERROR 

STIG command did not completed successfully

Function Documentation

§ FlashRead()

void FlashRead ( uint32_t *  readFromAddr,
uint32_t *  writeToAddr,
uint32_t  length 
)

Read from external memory.

This function call to #XIPStartUDMATransaction() in order to execute copy transaction from external memory to internal memory.

Parameters
[in]readFromAddris a pointer to the external memory source data.
[in]writeToAddris a pointer to the internal memory destination data.
[in]lengthis the number of bytes to transfer.
Note
Tested with flash only (did not test with PSRAM)

§ FlashReadSTIG()

FlashStigStatus FlashReadSTIG ( uint32_t  readStartAddr,
uint32_t *  writeToAddr,
uint8_t  DeviceNum 
)

Read from external memory using STIG command.

This function call to FlashExecuteReadSTIGCommand() in order to Execute read Flash based on STIG command.

Parameters
[in]readFromAddris a pointer to the external memory source data.
[in]writeToAddris a pointer to the internal memory destination data.
[in]DeviceNumDevice identifier (XMEM_FLASH or XMEM_PSRAM).
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG erase command failed.

§ FlashExecuteReadSTIGCommand()

FlashStigStatus FlashExecuteReadSTIGCommand ( uint32_t  srcReadAddr,
uint32_t *  writeToAddr 
)

Execute read of one word from Flash based on STIG write command.

Parameters
[in]srcReadAddris the data to read from external memory.
[in]writeToAddris a pointer to the internal memory destination data.
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG command failed.

§ FlashWrite()

void FlashWrite ( uint32_t *  readFromAddr,
uint32_t *  writeToAddr,
uint32_t  length 
)

Write to external memory.

This function call to #XIPStartUDMATransaction() in order to execute copy transaction from internal memory to external memory.

Parameters
[in]readFromAddris a pointer to the internal memory source data.
[in]writeToAddris a pointer to the external memory destination data.
[in]lengthis the number of bytes to transfer. Maximum configurable job size - 1 Mega byte (256K Words).
Note
Tested with flash only (did not test with PSRAM)

§ FlashWriteSTIG()

FlashStigStatus FlashWriteSTIG ( uint32_t *  readFromAddr,
uint32_t *  writeToAddr,
uint8_t  DeviceNum 
)

Write to external memory using STIG command.

This function call to FlashExecuteWriteSTIGCommand() in order to Execute write Flash based on STIG command.

Parameters
[in]readFromAddris a pointer to the internal memory source data.
[in]writeToAddris a pointer to the external memory destination data.
[in]DeviceNumDevice identifier (XMEM_FLASH or XMEM_PSRAM).
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG erase command failed.
Note
Tested with flash only (did not test with PSRAM)

§ FlashExecuteWriteSTIGCommand()

FlashStigStatus FlashExecuteWriteSTIGCommand ( uint32_t  srcWriteData,
uint32_t  srcWriteAddrPhy 
)

Execute write to Flash based on STIG write command.

Parameters
[in]srcWriteAddrPhyis the address of the external memory destination data.
[in]srcWriteDatais the data to write to external memory.
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG command failed.

§ FlashSetOTFDE()

void FlashSetOTFDE ( uint8_t  setState)

Enable/Disable the OTFDE.

Parameters
[in]setStateis the required state to configure FlashOtfdeStateSet.

§ FlashExecutePolling()

uint32_t FlashExecutePolling ( void  )

read flash status register until WIP (write in process) indication is free.

This function can be called by nay function that execute on going process such as FlashSectorErase(), FlashReadSTIG(), FlashWriteSTIG().

If transaction will not complete before timeout reatched

Returns
status transaction complete: FLASH_STATUS_SUCCESS - Trasaction successfuly completed. FLASH_TIMEOUT_REACHED_ERROR - Timeout, transaction failed.

§ FlashExecuteEraseSTIGCommand()

FlashStigStatus FlashExecuteEraseSTIGCommand ( uint32_t  EraseAddr_en,
uint32_t  srcEraseAddr 
)

Execute erase Flash based on STIG command.

Parameters
[in]EraseAddr_enset in case the STIG command needs to use #srcEraseAddr.
[in]srcEraseAddrfrom where to start the flash erase.
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG command failed.

§ FlashSectorErase()

FlashStigStatus FlashSectorErase ( uint32_t  eraseStartAddr,
uint8_t  DeviceNum 
)

Execute erase Flash based on STIG command.

Parameters
[in]eraseStartAddrfrom where to start the sector erase.
[in]DeviceNumDevice identifier (XMEM_FLASH or XMEM_PSRAM).
Returns
FlashStigStatus of STIG execution command: FLASH_STIG_DONE - STIG command done. FLASH_STIG_TIMEOUT - STIG command not completed, finish with timeout. FLASH_STIG_ERROR - STIG command failed.

§ FlashSetTickPeriod()

void FlashSetTickPeriod ( uint32_t  TickPeriod)

Store the ClockP period internally.

Parameters
TickPeriodPeriodic interval in ClockP ticks

§ FlashIsXspiIdle()

uint32_t FlashIsXspiIdle ( )

xSPI (accessible) idle check before STIG execution.

© Copyright 1995-2026, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale