MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
FLEXSPI: Flexible Serial Peripheral Interface Driver

Overview

The MCUXpresso SDK provides a peripheral driver for the Flexible Serial Peripheral Interface (FLEXSPI) module of MCUXpresso SDK/i.MX devices.

FLEXSPI driver includes functional APIs and interrupt/EDMA non-blocking transactional APIs.

Functional APIs are feature/property target low level APIs. Functional APIs can be used for FLEXSPI initialization/configuration/operation for optimization/customization purpose. Using the functional API requires the knowledge of the FLEXSPI peripheral and how to organize functional APIs to meet the application requirements. All functional API use the peripheral base address as the first parameter. FLEXSPI functional operation groups provide the functional API set.

Transactional APIs are transaction target high level APIs. Transactional APIs can be used to enable the peripheral and in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are a critical requirement, see the transactional API implementation and write a custom code. All transactional APIs use the flexspi_handle_t/flexspi_edma_handle_t as the second parameter. Initialize the handle for interrupt non-blocking transfer by calling the FLEXSPI_TransferCreateHandle API. Initialize the handle for interrupt non-blocking transfer by calling the FLEXSPI_TransferCreateHandleEDMA API.

Transactional APIs support asynchronous transfer. This means that the functions FLEXSPI_TransferNonBlocking() and FLEXSPI_TransferEDMA() set up data transfer. When the transfer completes, the upper layer is notified through a callback function with the kStatus_FLEXSPI_Idle status.

Modules

 FLEXSPI eDMA Driver
 

Data Structures

struct  flexspi_config_t
 FLEXSPI configuration structure. More...
 
struct  flexspi_device_config_t
 External device configuration items. More...
 
struct  flexspi_transfer_t
 Transfer structure for FLEXSPI. More...
 
struct  flexspi_handle_t
 Transfer handle structure for FLEXSPI. More...
 

Macros

#define FLEXSPI_LUT_SEQ(cmd0, pad0, op0, cmd1, pad1, op1)
 Formula to form FLEXSPI instructions in LUT table. More...
 

Typedefs

typedef void(* flexspi_transfer_callback_t )(FLEXSPI_Type *base, flexspi_handle_t *handle, status_t status, void *userData)
 FLEXSPI transfer callback function. More...
 

Enumerations

enum  _flexspi_status {
  kStatus_FLEXSPI_Busy = MAKE_STATUS(kStatusGroup_FLEXSPI, 0),
  kStatus_FLEXSPI_SequenceExecutionTimeout = MAKE_STATUS(kStatusGroup_FLEXSPI, 1),
  kStatus_FLEXSPI_IpCommandSequenceError = MAKE_STATUS(kStatusGroup_FLEXSPI, 2),
  kStatus_FLEXSPI_IpCommandGrantTimeout = MAKE_STATUS(kStatusGroup_FLEXSPI, 3)
}
 Status structure of FLEXSPI. More...
 
enum  _flexspi_command {
  kFLEXSPI_Command_STOP = 0x00U,
  kFLEXSPI_Command_SDR = 0x01U,
  kFLEXSPI_Command_RADDR_SDR = 0x02U,
  kFLEXSPI_Command_CADDR_SDR = 0x03U,
  kFLEXSPI_Command_MODE1_SDR = 0x04U,
  kFLEXSPI_Command_MODE2_SDR = 0x05U,
  kFLEXSPI_Command_MODE4_SDR = 0x06U,
  kFLEXSPI_Command_MODE8_SDR = 0x07U,
  kFLEXSPI_Command_WRITE_SDR = 0x08U,
  kFLEXSPI_Command_READ_SDR = 0x09U,
  kFLEXSPI_Command_LEARN_SDR = 0x0AU,
  kFLEXSPI_Command_DATSZ_SDR = 0x0BU,
  kFLEXSPI_Command_DUMMY_SDR = 0x0CU,
  kFLEXSPI_Command_DUMMY_RWDS_SDR = 0x0DU,
  kFLEXSPI_Command_DDR = 0x21U,
  kFLEXSPI_Command_RADDR_DDR = 0x22U,
  kFLEXSPI_Command_CADDR_DDR = 0x23U,
  kFLEXSPI_Command_MODE1_DDR = 0x24U,
  kFLEXSPI_Command_MODE2_DDR = 0x25U,
  kFLEXSPI_Command_MODE4_DDR = 0x26U,
  kFLEXSPI_Command_MODE8_DDR = 0x27U,
  kFLEXSPI_Command_WRITE_DDR = 0x28U,
  kFLEXSPI_Command_READ_DDR = 0x29U,
  kFLEXSPI_Command_LEARN_DDR = 0x2AU,
  kFLEXSPI_Command_DATSZ_DDR = 0x2BU,
  kFLEXSPI_Command_DUMMY_DDR = 0x2CU,
  kFLEXSPI_Command_DUMMY_RWDS_DDR = 0x2DU,
  kFLEXSPI_Command_JUMP_ON_CS = 0x1FU
}
 CMD definition of FLEXSPI, use to form LUT instruction. More...
 
enum  _flexspi_pad {
  kFLEXSPI_1PAD = 0x00U,
  kFLEXSPI_2PAD = 0x01U,
  kFLEXSPI_4PAD = 0x02U,
  kFLEXSPI_8PAD = 0x03U
}
 pad definition of FLEXSPI, use to form LUT instruction. More...
 
enum  flexspi_flags_t {
  kFLEXSPI_SequenceExecutionTimeoutFlag = FLEXSPI_INTEN_SEQTIMEOUTEN_MASK,
  kFLEXSPI_AhbBusTimeoutFlag = FLEXSPI_INTEN_AHBBUSTIMEOUTEN_MASK,
  kFLEXSPI_SckStoppedBecauseTxEmptyFlag,
  kFLEXSPI_SckStoppedBecauseRxFullFlag,
  kFLEXSPI_IpTxFifoWatermarkEmpltyFlag = FLEXSPI_INTEN_IPTXWEEN_MASK,
  kFLEXSPI_IpRxFifoWatermarkAvailableFlag = FLEXSPI_INTEN_IPRXWAEN_MASK,
  kFLEXSPI_AhbCommandSequenceErrorFlag,
  kFLEXSPI_IpCommandSequenceErrorFlag = FLEXSPI_INTEN_IPCMDERREN_MASK,
  kFLEXSPI_AhbCommandGrantTimeoutFlag,
  kFLEXSPI_IpCommandGrantTimeoutFlag,
  kFLEXSPI_IpCommandExcutionDoneFlag,
  kFLEXSPI_AllInterruptFlags = 0xFFFU
}
 FLEXSPI interrupt status flags. More...
 
enum  flexspi_read_sample_clock_t {
  kFLEXSPI_ReadSampleClkLoopbackInternally = 0x0U,
  kFLEXSPI_ReadSampleClkLoopbackFromDqsPad = 0x1U,
  kFLEXSPI_ReadSampleClkLoopbackFromSckPad = 0x2U,
  kFLEXSPI_ReadSampleClkExternalInputFromDqsPad = 0x3U
}
 FLEXSPI sample clock source selection for Flash Reading. More...
 
enum  flexspi_cs_interval_cycle_unit_t {
  kFLEXSPI_CsIntervalUnit1SckCycle = 0x0U,
  kFLEXSPI_CsIntervalUnit256SckCycle = 0x1U
}
 FLEXSPI interval unit for flash device select. More...
 
enum  flexspi_ahb_write_wait_unit_t {
  kFLEXSPI_AhbWriteWaitUnit2AhbCycle = 0x0U,
  kFLEXSPI_AhbWriteWaitUnit8AhbCycle = 0x1U,
  kFLEXSPI_AhbWriteWaitUnit32AhbCycle = 0x2U,
  kFLEXSPI_AhbWriteWaitUnit128AhbCycle = 0x3U,
  kFLEXSPI_AhbWriteWaitUnit512AhbCycle = 0x4U,
  kFLEXSPI_AhbWriteWaitUnit2048AhbCycle = 0x5U,
  kFLEXSPI_AhbWriteWaitUnit8192AhbCycle = 0x6U,
  kFLEXSPI_AhbWriteWaitUnit32768AhbCycle = 0x7U
}
 FLEXSPI AHB wait interval unit for writting. More...
 
enum  flexspi_ip_error_code_t {
  kFLEXSPI_IpCmdErrorNoError = 0x0U,
  kFLEXSPI_IpCmdErrorJumpOnCsInIpCmd = 0x2U,
  kFLEXSPI_IpCmdErrorUnknownOpCode = 0x3U,
  kFLEXSPI_IpCmdErrorSdrDummyInDdrSequence = 0x4U,
  kFLEXSPI_IpCmdErrorDdrDummyInSdrSequence = 0x5U,
  kFLEXSPI_IpCmdErrorInvalidAddress = 0x6U,
  kFLEXSPI_IpCmdErrorSequenceExecutionTimeout = 0xEU,
  kFLEXSPI_IpCmdErrorFlashBoundaryAcrosss = 0xFU
}
 Error Code when IP command Error detected. More...
 
enum  flexspi_ahb_error_code_t {
  kFLEXSPI_AhbCmdErrorNoError = 0x0U,
  kFLEXSPI_AhbCmdErrorJumpOnCsInWriteCmd = 0x2U,
  kFLEXSPI_AhbCmdErrorUnknownOpCode = 0x3U,
  kFLEXSPI_AhbCmdErrorSdrDummyInDdrSequence = 0x4U,
  kFLEXSPI_AhbCmdErrorDdrDummyInSdrSequence = 0x5U,
  kFLEXSPI_AhbCmdSequenceExecutionTimeout = 0x6U
}
 Error Code when AHB command Error detected. More...
 
enum  flexspi_port_t {
  kFLEXSPI_PortA1 = 0x0U,
  kFLEXSPI_PortA2 = 0x1U,
  kFLEXSPI_PortB1 = 0x2U,
  kFLEXSPI_PortB2 = 0x3U
}
 FLEXSPI operation port select. More...
 
enum  flexspi_arb_command_source_t
 Trigger source of current command sequence granted by arbitrator. More...
 
enum  flexspi_command_type_t {
  kFLEXSPI_Command,
  kFLEXSPI_Config
}
 

Driver version

#define FSL_FLEXSPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
 FLEXSPI driver version 2.0.1. More...
 

Initialization and deinitialization

void FLEXSPI_Init (FLEXSPI_Type *base, const flexspi_config_t *config)
 Initializes the FLEXSPI module and internal state. More...
 
void FLEXSPI_GetDefaultConfig (flexspi_config_t *config)
 Gets default settings for FLEXSPI. More...
 
void FLEXSPI_Deinit (FLEXSPI_Type *base)
 Deinitializes the FLEXSPI module. More...
 
void FLEXSPI_SetFlashConfig (FLEXSPI_Type *base, flexspi_device_config_t *config, flexspi_port_t port)
 Configures the connected device parameter. More...
 
static void FLEXSPI_SoftwareReset (FLEXSPI_Type *base)
 Software reset for the FLEXSPI logic. More...
 
static void FLEXSPI_Enable (FLEXSPI_Type *base, bool enable)
 Enables or disables the FLEXSPI module. More...
 

Interrupts

static void FLEXSPI_EnableInterrupts (FLEXSPI_Type *base, uint32_t mask)
 Enables the FLEXSPI interrupts. More...
 
static void FLEXSPI_DisableInterrupts (FLEXSPI_Type *base, uint32_t mask)
 Disable the FLEXSPI interrupts. More...
 

DMA control

static void FLEXSPI_EnableTxDMA (FLEXSPI_Type *base, bool enable)
 Enables or disables FLEXSPI IP Tx FIFO DMA requests. More...
 
static void FLEXSPI_EnableRxDMA (FLEXSPI_Type *base, bool enable)
 Enables or disables FLEXSPI IP Rx FIFO DMA requests. More...
 
static uint32_t FLEXSPI_GetTxFifoAddress (FLEXSPI_Type *base)
 Gets FLEXSPI IP tx fifo address for DMA transfer. More...
 
static uint32_t FLEXSPI_GetRxFifoAddress (FLEXSPI_Type *base)
 Gets FLEXSPI IP rx fifo address for DMA transfer. More...
 

FIFO control

static void FLEXSPI_ResetFifos (FLEXSPI_Type *base, bool txFifo, bool rxFifo)
 Clears the FLEXSPI IP FIFO logic. More...
 
static void FLEXSPI_GetFifoCounts (FLEXSPI_Type *base, size_t *txCount, size_t *rxCount)
 Gets the valid data entries in the FLEXSPI FIFOs. More...
 

Status

static uint32_t FLEXSPI_GetInterruptStatusFlags (FLEXSPI_Type *base)
 Get the FLEXSPI interrupt status flags. More...
 
static void FLEXSPI_ClearInterruptStatusFlags (FLEXSPI_Type *base, uint32_t mask)
 Get the FLEXSPI interrupt status flags. More...
 
static flexspi_arb_command_source_t FLEXSPI_GetArbitratorCommandSource (FLEXSPI_Type *base)
 Gets the trigger source of current command sequence granted by arbitrator. More...
 
static flexspi_ip_error_code_t FLEXSPI_GetIPCommandErrorCode (FLEXSPI_Type *base, uint8_t *index)
 Gets the error code when IP command error detected. More...
 
static flexspi_ahb_error_code_t FLEXSPI_GetAHBCommandErrorCode (FLEXSPI_Type *base, uint8_t *index)
 Gets the error code when AHB command error detected. More...
 
static bool FLEXSPI_GetBusIdleStatus (FLEXSPI_Type *base)
 Returns whether the bus is idle. More...
 

Bus Operations

static void FLEXSPI_EnableIPParallelMode (FLEXSPI_Type *base, bool enable)
 Enables/disables the FLEXSPI IP command parallel mode. More...
 
static void FLEXSPI_EnableAHBParallelMode (FLEXSPI_Type *base, bool enable)
 Enables/disables the FLEXSPI AHB command parallel mode. More...
 
void FLEXSPI_UpdateLUT (FLEXSPI_Type *base, uint32_t index, const uint32_t *cmd, uint32_t count)
 Updates the LUT table. More...
 
static void FLEXSPI_WriteData (FLEXSPI_Type *base, uint32_t data, uint8_t fifoIndex)
 Writes data into FIFO. More...
 
static uint32_t FLEXSPI_ReadData (FLEXSPI_Type *base, uint8_t fifoIndex)
 Receives data from data FIFO. More...
 
status_t FLEXSPI_WriteBlocking (FLEXSPI_Type *base, uint32_t *buffer, size_t size)
 Sends a buffer of data bytes using blocking method. More...
 
status_t FLEXSPI_ReadBlocking (FLEXSPI_Type *base, uint32_t *buffer, size_t size)
 Receives a buffer of data bytes using a blocking method. More...
 
status_t FLEXSPI_TransferBlocking (FLEXSPI_Type *base, flexspi_transfer_t *xfer)
 Execute command to transfer a buffer data bytes using a blocking method. More...
 

Transactional

void FLEXSPI_TransferCreateHandle (FLEXSPI_Type *base, flexspi_handle_t *handle, flexspi_transfer_callback_t callback, void *userData)
 Initializes the FLEXSPI handle which is used in transactional functions. More...
 
status_t FLEXSPI_TransferNonBlocking (FLEXSPI_Type *base, flexspi_handle_t *handle, flexspi_transfer_t *xfer)
 Performs a interrupt non-blocking transfer on the FLEXSPI bus. More...
 
status_t FLEXSPI_TransferGetCount (FLEXSPI_Type *base, flexspi_handle_t *handle, size_t *count)
 Gets the master transfer status during a interrupt non-blocking transfer. More...
 
void FLEXSPI_TransferAbort (FLEXSPI_Type *base, flexspi_handle_t *handle)
 Aborts an interrupt non-blocking transfer early. More...
 
void FLEXSPI_TransferHandleIRQ (FLEXSPI_Type *base, flexspi_handle_t *handle)
 Master interrupt handler. More...
 

Data Structure Documentation

struct flexspi_config_t

Data Fields

flexspi_read_sample_clock_t rxSampleClock
 Sample Clock source selection for Flash Reading. More...
 
bool enableSckFreeRunning
 Enable/disable SCK output free-running. More...
 
bool enableCombination
 
 Enable/disable combining PORT A and B Data Pins

(SIOA[3:0] and SIOB[3:0]) to support Flash Octal mode. More...

 
bool enableDoze
 Enable/disable doze mode support. More...
 
bool enableHalfSpeedAccess
 
Enable/disable divide by 2 of the clock for half

speed commands. More...

 
bool enableSckBDiffOpt
 
Enable/disable SCKB pad use as SCKA differential clock

output, when enable, Port B flash access is not available. More...

 
bool enableSameConfigForAll
 
Enable/disable same configuration for all connected devices

when enabled, same configuration in FLASHA1CRx is applied to all. More...

 
uint16_t seqTimeoutCycle
 
 Timeout wait cycle for command sequence execution,

timeout after ahbGrantTimeoutCyle*1024 serial root clock cycles. More...

 
uint8_t ipGrantTimeoutCycle
 
Timeout wait cycle for IP command grant, timeout after

ipGrantTimeoutCycle*1024 AHB clock cycles. More...

 
uint8_t txWatermark
 FLEXSPI IP transmit watermark value. More...
 
uint8_t rxWatermark
 FLEXSPI receive watermark value. More...
 
bool enableAHBWriteIpTxFifo
 Enable AHB bus write access to IP TX FIFO. More...
 
bool enableAHBWriteIpRxFifo
 Enable AHB bus write access to IP RX FIFO. More...
 
uint8_t ahbGrantTimeoutCycle
 
Timeout wait cycle for AHB command grant,

timeout after ahbGrantTimeoutCyle*1024 AHB clock cycles. More...

 
uint16_t ahbBusTimeoutCycle
 
 Timeout wait cycle for AHB read/write access,

timeout after ahbBusTimeoutCycle*1024 AHB clock cycles. More...

 
uint8_t resumeWaitCycle
 
Wait cycle for idle state before suspended command sequence

resume, timeout after ahbBusTimeoutCycle AHB clock cycles. More...

 
flexspi_ahbBuffer_config_t buffer [FSL_FEATURE_FLEXSPI_AHB_BUFFER_COUNT]
 AHB buffer size. More...
 
bool enableClearAHBBufferOpt
 
Enable/disable automatically clean AHB RX Buffer and TX Buffer

when FLEXSPI returns STOP mode ACK. More...

 
bool enableAHBPrefetch
 
Enable/disable AHB read prefetch feature, when enabled, FLEXSPI

will fetch more data than current AHB burst. More...

 
bool enableAHBBufferable
 
Enable/disable AHB bufferable write access support, when enabled,

FLEXSPI return before waiting for command excution finished. More...

 
bool enableAHBCachable
 Enable AHB bus cachable read access support. More...
 

Field Documentation

flexspi_read_sample_clock_t flexspi_config_t::rxSampleClock
bool flexspi_config_t::enableSckFreeRunning
bool flexspi_config_t::enableCombination
bool flexspi_config_t::enableDoze
bool flexspi_config_t::enableHalfSpeedAccess
bool flexspi_config_t::enableSckBDiffOpt
bool flexspi_config_t::enableSameConfigForAll
uint16_t flexspi_config_t::seqTimeoutCycle
uint8_t flexspi_config_t::ipGrantTimeoutCycle
uint8_t flexspi_config_t::txWatermark
uint8_t flexspi_config_t::rxWatermark
bool flexspi_config_t::enableAHBWriteIpTxFifo
bool flexspi_config_t::enableAHBWriteIpRxFifo
uint8_t flexspi_config_t::ahbGrantTimeoutCycle
uint16_t flexspi_config_t::ahbBusTimeoutCycle
uint8_t flexspi_config_t::resumeWaitCycle
flexspi_ahbBuffer_config_t flexspi_config_t::buffer[FSL_FEATURE_FLEXSPI_AHB_BUFFER_COUNT]
bool flexspi_config_t::enableClearAHBBufferOpt
bool flexspi_config_t::enableAHBPrefetch
bool flexspi_config_t::enableAHBBufferable
bool flexspi_config_t::enableAHBCachable
struct flexspi_device_config_t

Data Fields

uint32_t flexspiRootClk
 FLEXSPI serial root clock. More...
 
bool isSck2Enabled
 FLEXSPI use SCK2. More...
 
uint32_t flashSize
 Flash size in KByte. More...
 
flexspi_cs_interval_cycle_unit_t CSIntervalUnit
 CS interval unit, 1 or 256 cycle. More...
 
uint16_t CSInterval
 
CS line assert interval, mutiply CS interval unit to

get the CS line assert interval cycles. More...

 
uint8_t CSHoldTime
 CS line hold time. More...
 
uint8_t CSSetupTime
 CS line setup time. More...
 
uint8_t dataValidTime
 Data valid time for external device. More...
 
uint8_t columnspace
 Column space size. More...
 
bool enableWordAddress
 If enable word address. More...
 
uint8_t AWRSeqIndex
 Sequence ID for AHB write command. More...
 
uint8_t AWRSeqNumber
 Sequence number for AHB write command. More...
 
uint8_t ARDSeqIndex
 Sequence ID for AHB read command. More...
 
uint8_t ARDSeqNumber
 Sequence number for AHB read command. More...
 
flexspi_ahb_write_wait_unit_t AHBWriteWaitUnit
 AHB write wait unit. More...
 
uint16_t AHBWriteWaitInterval
 
AHB write wait interval, mutiply AHB write interval

unit to get the AHB write wait cycles. More...

 
bool enableWriteMask
 
Enable/Disable FLEXSPI drive DQS pin as write mask

when writing to external device. More...

 

Field Documentation

uint32_t flexspi_device_config_t::flexspiRootClk
bool flexspi_device_config_t::isSck2Enabled
uint32_t flexspi_device_config_t::flashSize
flexspi_cs_interval_cycle_unit_t flexspi_device_config_t::CSIntervalUnit
uint16_t flexspi_device_config_t::CSInterval
uint8_t flexspi_device_config_t::CSHoldTime
uint8_t flexspi_device_config_t::CSSetupTime
uint8_t flexspi_device_config_t::dataValidTime
uint8_t flexspi_device_config_t::columnspace
bool flexspi_device_config_t::enableWordAddress
uint8_t flexspi_device_config_t::AWRSeqIndex
uint8_t flexspi_device_config_t::AWRSeqNumber
uint8_t flexspi_device_config_t::ARDSeqIndex
uint8_t flexspi_device_config_t::ARDSeqNumber
flexspi_ahb_write_wait_unit_t flexspi_device_config_t::AHBWriteWaitUnit
uint16_t flexspi_device_config_t::AHBWriteWaitInterval
bool flexspi_device_config_t::enableWriteMask
struct flexspi_transfer_t

Data Fields

uint32_t deviceAddress
 Operation device address. More...
 
flexspi_port_t port
 Operation port. More...
 
flexspi_command_type_t cmdType
 Execution command type. More...
 
uint8_t seqIndex
 Sequence ID for command. More...
 
uint8_t SeqNumber
 Sequence number for command. More...
 
uint32_t * data
 Data buffer. More...
 
size_t dataSize
 Data size in bytes. More...
 

Field Documentation

uint32_t flexspi_transfer_t::deviceAddress
flexspi_port_t flexspi_transfer_t::port
flexspi_command_type_t flexspi_transfer_t::cmdType
uint8_t flexspi_transfer_t::seqIndex
uint8_t flexspi_transfer_t::SeqNumber
uint32_t* flexspi_transfer_t::data
size_t flexspi_transfer_t::dataSize
struct _flexspi_handle

Data Fields

uint32_t state
 Internal state for FLEXSPI transfer.
 
uint32_t * data
 Data buffer. More...
 
size_t dataSize
 Remaining Data size in bytes. More...
 
size_t transferTotalSize
 Total Data size in bytes. More...
 
flexspi_transfer_callback_t completionCallback
 Callback for users while transfer finish or error occurred.
 
void * userData
 FLEXSPI callback function parameter. More...
 

Field Documentation

uint32_t* flexspi_handle_t::data
size_t flexspi_handle_t::dataSize
size_t flexspi_handle_t::transferTotalSize
void* flexspi_handle_t::userData

Macro Definition Documentation

#define FSL_FLEXSPI_DRIVER_VERSION   (MAKE_VERSION(2, 0, 1))
#define FLEXSPI_LUT_SEQ (   cmd0,
  pad0,
  op0,
  cmd1,
  pad1,
  op1 
)
Value:
(FLEXSPI_LUT_OPERAND0(op0) | FLEXSPI_LUT_NUM_PADS0(pad0) | FLEXSPI_LUT_OPCODE0(cmd0) | FLEXSPI_LUT_OPERAND1(op1) | \
FLEXSPI_LUT_NUM_PADS1(pad1) | FLEXSPI_LUT_OPCODE1(cmd1))

Typedef Documentation

typedef void(* flexspi_transfer_callback_t)(FLEXSPI_Type *base, flexspi_handle_t *handle, status_t status, void *userData)

Enumeration Type Documentation

Enumerator
kStatus_FLEXSPI_Busy 

FLEXSPI is busy.

kStatus_FLEXSPI_SequenceExecutionTimeout 

Sequence execution timeout error occurred during FLEXSPI transfer.

kStatus_FLEXSPI_IpCommandSequenceError 

IP command Sequence execution timeout error occurred during FLEXSPI transfer.

kStatus_FLEXSPI_IpCommandGrantTimeout 

IP command grant timeout error occurred during FLEXSPI transfer.

Enumerator
kFLEXSPI_Command_STOP 

Stop execution, deassert CS.

kFLEXSPI_Command_SDR 

Transmit Command code to Flash, using SDR mode.

kFLEXSPI_Command_RADDR_SDR 

Transmit Row Address to Flash, using SDR mode.

kFLEXSPI_Command_CADDR_SDR 

Transmit Column Address to Flash, using SDR mode.

kFLEXSPI_Command_MODE1_SDR 

Transmit 1-bit Mode bits to Flash, using SDR mode.

kFLEXSPI_Command_MODE2_SDR 

Transmit 2-bit Mode bits to Flash, using SDR mode.

kFLEXSPI_Command_MODE4_SDR 

Transmit 4-bit Mode bits to Flash, using SDR mode.

kFLEXSPI_Command_MODE8_SDR 

Transmit 8-bit Mode bits to Flash, using SDR mode.

kFLEXSPI_Command_WRITE_SDR 

Transmit Programming Data to Flash, using SDR mode.

kFLEXSPI_Command_READ_SDR 

Receive Read Data from Flash, using SDR mode.

kFLEXSPI_Command_LEARN_SDR 

Receive Read Data or Preamble bit from Flash, SDR mode.

kFLEXSPI_Command_DATSZ_SDR 

Transmit Read/Program Data size (byte) to Flash, SDR mode.

kFLEXSPI_Command_DUMMY_SDR 

Leave data lines undriven by FlexSPI controller.

kFLEXSPI_Command_DUMMY_RWDS_SDR 

Leave data lines undriven by FlexSPI controller, dummy cycles decided by RWDS.

kFLEXSPI_Command_DDR 

Transmit Command code to Flash, using DDR mode.

kFLEXSPI_Command_RADDR_DDR 

Transmit Row Address to Flash, using DDR mode.

kFLEXSPI_Command_CADDR_DDR 

Transmit Column Address to Flash, using DDR mode.

kFLEXSPI_Command_MODE1_DDR 

Transmit 1-bit Mode bits to Flash, using DDR mode.

kFLEXSPI_Command_MODE2_DDR 

Transmit 2-bit Mode bits to Flash, using DDR mode.

kFLEXSPI_Command_MODE4_DDR 

Transmit 4-bit Mode bits to Flash, using DDR mode.

kFLEXSPI_Command_MODE8_DDR 

Transmit 8-bit Mode bits to Flash, using DDR mode.

kFLEXSPI_Command_WRITE_DDR 

Transmit Programming Data to Flash, using DDR mode.

kFLEXSPI_Command_READ_DDR 

Receive Read Data from Flash, using DDR mode.

kFLEXSPI_Command_LEARN_DDR 

Receive Read Data or Preamble bit from Flash, DDR mode.

kFLEXSPI_Command_DATSZ_DDR 

Transmit Read/Program Data size (byte) to Flash, DDR mode.

kFLEXSPI_Command_DUMMY_DDR 

Leave data lines undriven by FlexSPI controller.

kFLEXSPI_Command_DUMMY_RWDS_DDR 

Leave data lines undriven by FlexSPI controller, dummy cycles decided by RWDS.

kFLEXSPI_Command_JUMP_ON_CS 

Stop execution, deassert CS and save operand[7:0] as the instruction start pointer for next sequence.

Enumerator
kFLEXSPI_1PAD 

Transmit command/address and transmit/receive data only through DATA0/DATA1.

kFLEXSPI_2PAD 

Transmit command/address and transmit/receive data only through DATA[1:0].

kFLEXSPI_4PAD 

Transmit command/address and transmit/receive data only through DATA[3:0].

kFLEXSPI_8PAD 

Transmit command/address and transmit/receive data only through DATA[7:0].

Enumerator
kFLEXSPI_SequenceExecutionTimeoutFlag 

Sequence execution timeout.

kFLEXSPI_AhbBusTimeoutFlag 

AHB Bus timeout.

kFLEXSPI_SckStoppedBecauseTxEmptyFlag 

SCK is stopped during command sequence because Async TX FIFO empty.

kFLEXSPI_SckStoppedBecauseRxFullFlag 

SCK is stopped during command sequence because Async RX FIFO full.

kFLEXSPI_IpTxFifoWatermarkEmpltyFlag 

IP TX FIFO WaterMark empty.

kFLEXSPI_IpRxFifoWatermarkAvailableFlag 

IP RX FIFO WaterMark available.

kFLEXSPI_AhbCommandSequenceErrorFlag 

AHB triggered Command Sequences Error.

kFLEXSPI_IpCommandSequenceErrorFlag 

IP triggered Command Sequences Error.

kFLEXSPI_AhbCommandGrantTimeoutFlag 

AHB triggered Command Sequences Grant Timeout.

kFLEXSPI_IpCommandGrantTimeoutFlag 

IP triggered Command Sequences Grant Timeout.

kFLEXSPI_IpCommandExcutionDoneFlag 

IP triggered Command Sequences Execution finished.

kFLEXSPI_AllInterruptFlags 

All flags.

Enumerator
kFLEXSPI_ReadSampleClkLoopbackInternally 

Dummy Read strobe generated by FlexSPI Controller and loopback internally.

kFLEXSPI_ReadSampleClkLoopbackFromDqsPad 

Dummy Read strobe generated by FlexSPI Controller and loopback from DQS pad.

kFLEXSPI_ReadSampleClkLoopbackFromSckPad 

SCK output clock and loopback from SCK pad.

kFLEXSPI_ReadSampleClkExternalInputFromDqsPad 

Flash provided Read strobe and input from DQS pad.

Enumerator
kFLEXSPI_CsIntervalUnit1SckCycle 

Chip selection interval: CSINTERVAL * 1 serial clock cycle.

kFLEXSPI_CsIntervalUnit256SckCycle 

Chip selection interval: CSINTERVAL * 256 serial clock cycle.

Enumerator
kFLEXSPI_AhbWriteWaitUnit2AhbCycle 

AWRWAIT unit is 2 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit8AhbCycle 

AWRWAIT unit is 8 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit32AhbCycle 

AWRWAIT unit is 32 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit128AhbCycle 

AWRWAIT unit is 128 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit512AhbCycle 

AWRWAIT unit is 512 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit2048AhbCycle 

AWRWAIT unit is 2048 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit8192AhbCycle 

AWRWAIT unit is 8192 ahb clock cycle.

kFLEXSPI_AhbWriteWaitUnit32768AhbCycle 

AWRWAIT unit is 32768 ahb clock cycle.

Enumerator
kFLEXSPI_IpCmdErrorNoError 

No error.

kFLEXSPI_IpCmdErrorJumpOnCsInIpCmd 

IP command with JMP_ON_CS instruction used.

kFLEXSPI_IpCmdErrorUnknownOpCode 

Unknown instruction opcode in the sequence.

kFLEXSPI_IpCmdErrorSdrDummyInDdrSequence 

Instruction DUMMY_SDR/DUMMY_RWDS_SDR used in DDR sequence.

kFLEXSPI_IpCmdErrorDdrDummyInSdrSequence 

Instruction DUMMY_DDR/DUMMY_RWDS_DDR used in SDR sequence.

kFLEXSPI_IpCmdErrorInvalidAddress 

Flash access start address exceed the whole flash address range (A1/A2/B1/B2).

kFLEXSPI_IpCmdErrorSequenceExecutionTimeout 

Sequence execution timeout.

kFLEXSPI_IpCmdErrorFlashBoundaryAcrosss 

Flash boundary crossed.

Enumerator
kFLEXSPI_AhbCmdErrorNoError 

No error.

kFLEXSPI_AhbCmdErrorJumpOnCsInWriteCmd 

AHB Write command with JMP_ON_CS instruction used in the sequence.

kFLEXSPI_AhbCmdErrorUnknownOpCode 

Unknown instruction opcode in the sequence.

kFLEXSPI_AhbCmdErrorSdrDummyInDdrSequence 

Instruction DUMMY_SDR/DUMMY_RWDS_SDR used in DDR sequence.

kFLEXSPI_AhbCmdErrorDdrDummyInSdrSequence 

Instruction DUMMY_DDR/DUMMY_RWDS_DDR used in SDR sequence.

kFLEXSPI_AhbCmdSequenceExecutionTimeout 

Sequence execution timeout.

Enumerator
kFLEXSPI_PortA1 

Access flash on A1 port.

kFLEXSPI_PortA2 

Access flash on A2 port.

kFLEXSPI_PortB1 

Access flash on B1 port.

kFLEXSPI_PortB2 

Access flash on B2 port.

Enumerator
kFLEXSPI_Command 

FlexSPI operation: Only command, both TX and Rx buffer are ignored.

kFLEXSPI_Config 

FlexSPI operation: Configure device mode, the TX fifo size is fixed in LUT.

Function Documentation

void FLEXSPI_Init ( FLEXSPI_Type *  base,
const flexspi_config_t config 
)

This function enables the clock for FLEXSPI and also configures the FLEXSPI with the input configure parameters. Users should call this function before any FLEXSPI operations.

Parameters
baseFLEXSPI peripheral base address.
configFLEXSPI configure structure.
void FLEXSPI_GetDefaultConfig ( flexspi_config_t config)
Parameters
configFLEXSPI configuration structure.
void FLEXSPI_Deinit ( FLEXSPI_Type *  base)

Clears the FLEXSPI state and FLEXSPI module registers.

Parameters
baseFLEXSPI peripheral base address.
void FLEXSPI_SetFlashConfig ( FLEXSPI_Type *  base,
flexspi_device_config_t config,
flexspi_port_t  port 
)

This function configures the connected device relevant parameters, such as the size, command, and so on. The flash configuration value cannot have a default value. The user needs to configure it according to the connected device.

Parameters
baseFLEXSPI peripheral base address.
configFlash configuration parameters.
portFLEXSPI Operation port.
static void FLEXSPI_SoftwareReset ( FLEXSPI_Type *  base)
inlinestatic

This function sets the software reset flags for both AHB and buffer domain and resets both AHB buffer and also IP FIFOs.

Parameters
baseFLEXSPI peripheral base address.
static void FLEXSPI_Enable ( FLEXSPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
enableTrue means enable FLEXSPI, false means disable.
static void FLEXSPI_EnableInterrupts ( FLEXSPI_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
maskFLEXSPI interrupt source.
static void FLEXSPI_DisableInterrupts ( FLEXSPI_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
maskFLEXSPI interrupt source.
static void FLEXSPI_EnableTxDMA ( FLEXSPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
enableEnable flag for transmit DMA request. Pass true for enable, false for disable.
static void FLEXSPI_EnableRxDMA ( FLEXSPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
enableEnable flag for receive DMA request. Pass true for enable, false for disable.
static uint32_t FLEXSPI_GetTxFifoAddress ( FLEXSPI_Type *  base)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
Return values
Thetx fifo address.
static uint32_t FLEXSPI_GetRxFifoAddress ( FLEXSPI_Type *  base)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
Return values
Therx fifo address.
static void FLEXSPI_ResetFifos ( FLEXSPI_Type *  base,
bool  txFifo,
bool  rxFifo 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
txFifoPass true to reset TX FIFO.
rxFifoPass true to reset RX FIFO.
static void FLEXSPI_GetFifoCounts ( FLEXSPI_Type *  base,
size_t *  txCount,
size_t *  rxCount 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
[out]txCountPointer through which the current number of bytes in the transmit FIFO is returned. Pass NULL if this value is not required.
[out]rxCountPointer through which the current number of bytes in the receive FIFO is returned. Pass NULL if this value is not required.
static uint32_t FLEXSPI_GetInterruptStatusFlags ( FLEXSPI_Type *  base)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
Return values
interruptstatus flag, use status flag to AND flexspi_flags_t could get the related status.
static void FLEXSPI_ClearInterruptStatusFlags ( FLEXSPI_Type *  base,
uint32_t  mask 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
interruptstatus flag.
static flexspi_arb_command_source_t FLEXSPI_GetArbitratorCommandSource ( FLEXSPI_Type *  base)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
Return values
triggersource of current command sequence.
static flexspi_ip_error_code_t FLEXSPI_GetIPCommandErrorCode ( FLEXSPI_Type *  base,
uint8_t *  index 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
indexPointer to a uint8_t type variable to receive the sequence index when error detected.
Return values
errorcode when IP command error detected.
static flexspi_ahb_error_code_t FLEXSPI_GetAHBCommandErrorCode ( FLEXSPI_Type *  base,
uint8_t *  index 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
indexPointer to a uint8_t type variable to receive the sequence index when error detected.
Return values
errorcode when AHB command error detected.
static bool FLEXSPI_GetBusIdleStatus ( FLEXSPI_Type *  base)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
Return values
trueBus is idle.
falseBus is busy.
static void FLEXSPI_EnableIPParallelMode ( FLEXSPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
enableTrue means enable parallel mode, false means disable parallel mode.
static void FLEXSPI_EnableAHBParallelMode ( FLEXSPI_Type *  base,
bool  enable 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address.
enableTrue means enable parallel mode, false means disable parallel mode.
void FLEXSPI_UpdateLUT ( FLEXSPI_Type *  base,
uint32_t  index,
const uint32_t *  cmd,
uint32_t  count 
)
Parameters
baseFLEXSPI peripheral base address.
indexFrom which index start to update. It could be any index of the LUT table, which also allows user to update command content inside a command. Each command consists of up to 8 instructions and occupy 4*32-bit memory.
cmdCommand sequence array.
countNumber of sequences.
static void FLEXSPI_WriteData ( FLEXSPI_Type *  base,
uint32_t  data,
uint8_t  fifoIndex 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address
dataThe data bytes to send
fifoIndexDestination fifo index.
static uint32_t FLEXSPI_ReadData ( FLEXSPI_Type *  base,
uint8_t  fifoIndex 
)
inlinestatic
Parameters
baseFLEXSPI peripheral base address
fifoIndexSource fifo index.
Returns
The data in the FIFO.
status_t FLEXSPI_WriteBlocking ( FLEXSPI_Type *  base,
uint32_t *  buffer,
size_t  size 
)
Note
This function blocks via polling until all bytes have been sent.
Parameters
baseFLEXSPI peripheral base address
bufferThe data bytes to send
sizeThe number of data bytes to send
Return values
kStatus_Successwrite success without error
kStatus_FLEXSPI_SequenceExecutionTimeoutsequence execution timeout
kStatus_FLEXSPI_IpCommandSequenceErrorIP command sequencen error detected
kStatus_FLEXSPI_IpCommandGrantTimeoutIP command grant timeout detected
status_t FLEXSPI_ReadBlocking ( FLEXSPI_Type *  base,
uint32_t *  buffer,
size_t  size 
)
Note
This function blocks via polling until all bytes have been sent.
Parameters
baseFLEXSPI peripheral base address
bufferThe data bytes to send
sizeThe number of data bytes to receive
Return values
kStatus_Successread success without error
kStatus_FLEXSPI_SequenceExecutionTimeoutsequence execution timeout
kStatus_FLEXSPI_IpCommandSequenceErrorIP command sequencen error detected
kStatus_FLEXSPI_IpCommandGrantTimeoutIP command grant timeout detected
status_t FLEXSPI_TransferBlocking ( FLEXSPI_Type *  base,
flexspi_transfer_t xfer 
)
Parameters
baseFLEXSPI peripheral base address
xferpointer to the transfer structure.
Return values
kStatus_Successcommand transfer success without error
kStatus_FLEXSPI_SequenceExecutionTimeoutsequence execution timeout
kStatus_FLEXSPI_IpCommandSequenceErrorIP command sequencen error detected
kStatus_FLEXSPI_IpCommandGrantTimeoutIP command grant timeout detected
void FLEXSPI_TransferCreateHandle ( FLEXSPI_Type *  base,
flexspi_handle_t *  handle,
flexspi_transfer_callback_t  callback,
void *  userData 
)
Parameters
baseFLEXSPI peripheral base address.
handlepointer to flexspi_handle_t structure to store the transfer state.
callbackpointer to user callback function.
userDatauser parameter passed to the callback function.
status_t FLEXSPI_TransferNonBlocking ( FLEXSPI_Type *  base,
flexspi_handle_t *  handle,
flexspi_transfer_t xfer 
)
Note
Calling the API returns immediately after transfer initiates. The user needs to call FLEXSPI_GetTransferCount to poll the transfer status to check whether the transfer is finished. If the return status is not kStatus_FLEXSPI_Busy, the transfer is finished. For FLEXSPI_Read, the dataSize should be multiple of rx watermark levle, or FLEXSPI could not read data properly.
Parameters
baseFLEXSPI peripheral base address.
handlepointer to flexspi_handle_t structure which stores the transfer state.
xferpointer to flexspi_transfer_t structure.
Return values
kStatus_SuccessSuccessfully start the data transmission.
kStatus_FLEXSPI_BusyPrevious transmission still not finished.
status_t FLEXSPI_TransferGetCount ( FLEXSPI_Type *  base,
flexspi_handle_t *  handle,
size_t *  count 
)
Parameters
baseFLEXSPI peripheral base address.
handlepointer to flexspi_handle_t structure which stores the transfer state.
countNumber of bytes transferred so far by the non-blocking transaction.
Return values
kStatus_InvalidArgumentcount is Invalid.
kStatus_SuccessSuccessfully return the count.
void FLEXSPI_TransferAbort ( FLEXSPI_Type *  base,
flexspi_handle_t *  handle 
)
Note
This API can be called at any time when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
baseFLEXSPI peripheral base address.
handlepointer to flexspi_handle_t structure which stores the transfer state
void FLEXSPI_TransferHandleIRQ ( FLEXSPI_Type *  base,
flexspi_handle_t *  handle 
)
Parameters
baseFLEXSPI peripheral base address.
handlepointer to flexspi_handle_t structure.