RTEMS 6.1-rc1
Data Structures | Enumerator | Variables
Flexio_spi

Data Structures

struct  _flexio_spi_type
 Define FlexIO SPI access structure typedef. More...
 
struct  _flexio_spi_master_config
 Define FlexIO SPI master configuration structure. More...
 
struct  _flexio_spi_slave_config
 Define FlexIO SPI slave configuration structure. More...
 
struct  _flexio_spi_transfer
 Define FlexIO SPI transfer structure. More...
 
struct  _flexio_spi_master_handle
 Define FlexIO SPI handle structure. More...
 

Variables

FLEXIO_Type_flexio_spi_type::flexioBase
 
uint8_t _flexio_spi_type::SDOPinIndex
 
uint8_t _flexio_spi_type::SDIPinIndex
 
uint8_t _flexio_spi_type::SCKPinIndex
 
uint8_t _flexio_spi_type::CSnPinIndex
 
uint8_t _flexio_spi_type::shifterIndex [2]
 
uint8_t _flexio_spi_type::timerIndex [2]
 
bool _flexio_spi_master_config::enableMaster
 
bool _flexio_spi_master_config::enableInDoze
 
bool _flexio_spi_master_config::enableInDebug
 
bool _flexio_spi_master_config::enableFastAccess
 
uint32_t _flexio_spi_master_config::baudRate_Bps
 
flexio_spi_clock_phase_t _flexio_spi_master_config::phase
 
flexio_spi_data_bitcount_mode_t _flexio_spi_master_config::dataMode
 
bool _flexio_spi_slave_config::enableSlave
 
bool _flexio_spi_slave_config::enableInDoze
 
bool _flexio_spi_slave_config::enableInDebug
 
bool _flexio_spi_slave_config::enableFastAccess
 
flexio_spi_clock_phase_t _flexio_spi_slave_config::phase
 
flexio_spi_data_bitcount_mode_t _flexio_spi_slave_config::dataMode
 
uint8_t * _flexio_spi_transfer::txData
 
uint8_t * _flexio_spi_transfer::rxData
 
size_t _flexio_spi_transfer::dataSize
 
uint8_t _flexio_spi_transfer::flags
 
uint8_t * _flexio_spi_master_handle::txData
 
uint8_t * _flexio_spi_master_handle::rxData
 
size_t _flexio_spi_master_handle::transferSize
 
volatile size_t _flexio_spi_master_handle::txRemainingBytes
 
volatile size_t _flexio_spi_master_handle::rxRemainingBytes
 
volatile uint32_t _flexio_spi_master_handle::state
 
uint8_t _flexio_spi_master_handle::bytePerFrame
 
flexio_spi_shift_direction_t _flexio_spi_master_handle::direction
 
flexio_spi_master_transfer_callback_t _flexio_spi_master_handle::callback
 
void * _flexio_spi_master_handle::userData
 

Driver version

enum  { kStatus_FLEXIO_SPI_Busy = MAKE_STATUS(kStatusGroup_FLEXIO_SPI, 1) , kStatus_FLEXIO_SPI_Idle = MAKE_STATUS(kStatusGroup_FLEXIO_SPI, 2) , kStatus_FLEXIO_SPI_Error = MAKE_STATUS(kStatusGroup_FLEXIO_SPI, 3) , kStatus_FLEXIO_SPI_Timeout }
 Error codes for the FlexIO SPI driver. More...
 
enum  _flexio_spi_clock_phase { kFLEXIO_SPI_ClockPhaseFirstEdge = 0x0U , kFLEXIO_SPI_ClockPhaseSecondEdge = 0x1U }
 FlexIO SPI clock phase configuration. More...
 
enum  _flexio_spi_shift_direction { kFLEXIO_SPI_MsbFirst = 0 , kFLEXIO_SPI_LsbFirst = 1 }
 FlexIO SPI data shifter direction options. More...
 
enum  _flexio_spi_data_bitcount_mode { kFLEXIO_SPI_8BitMode = 0x08U , kFLEXIO_SPI_16BitMode = 0x10U , kFLEXIO_SPI_32BitMode = 0x20U }
 FlexIO SPI data length mode options. More...
 
enum  _flexio_spi_interrupt_enable { kFLEXIO_SPI_TxEmptyInterruptEnable = 0x1U , kFLEXIO_SPI_RxFullInterruptEnable = 0x2U }
 Define FlexIO SPI interrupt mask. More...
 
enum  _flexio_spi_status_flags { kFLEXIO_SPI_TxBufferEmptyFlag = 0x1U , kFLEXIO_SPI_RxBufferFullFlag = 0x2U }
 Define FlexIO SPI status mask. More...
 
enum  _flexio_spi_dma_enable { kFLEXIO_SPI_TxDmaEnable = 0x1U , kFLEXIO_SPI_RxDmaEnable = 0x2U , kFLEXIO_SPI_DmaAllEnable = 0x3U }
 Define FlexIO SPI DMA mask. More...
 
enum  _flexio_spi_transfer_flags {
  kFLEXIO_SPI_8bitMsb = 0x0U , kFLEXIO_SPI_8bitLsb = 0x1U , kFLEXIO_SPI_16bitMsb = 0x2U , kFLEXIO_SPI_16bitLsb = 0x3U ,
  kFLEXIO_SPI_32bitMsb = 0x4U , kFLEXIO_SPI_32bitLsb = 0x5U , kFLEXIO_SPI_csContinuous = 0x8U
}
 Define FlexIO SPI transfer flags. More...
 
typedef enum _flexio_spi_clock_phase flexio_spi_clock_phase_t
 FlexIO SPI clock phase configuration.
 
typedef enum _flexio_spi_shift_direction flexio_spi_shift_direction_t
 FlexIO SPI data shifter direction options.
 
typedef enum _flexio_spi_data_bitcount_mode flexio_spi_data_bitcount_mode_t
 FlexIO SPI data length mode options.
 
typedef struct _flexio_spi_type FLEXIO_SPI_Type
 Define FlexIO SPI access structure typedef.
 
typedef struct _flexio_spi_master_config flexio_spi_master_config_t
 Define FlexIO SPI master configuration structure.
 
typedef struct _flexio_spi_slave_config flexio_spi_slave_config_t
 Define FlexIO SPI slave configuration structure.
 
typedef struct _flexio_spi_transfer flexio_spi_transfer_t
 Define FlexIO SPI transfer structure.
 
typedef struct _flexio_spi_master_handle flexio_spi_master_handle_t
 typedef for flexio_spi_master_handle_t in advance.
 
typedef flexio_spi_master_handle_t flexio_spi_slave_handle_t
 Slave handle is the same with master handle.
 
typedef void(* flexio_spi_master_transfer_callback_t) (FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, status_t status, void *userData)
 FlexIO SPI master callback for finished transmit.
 
typedef void(* flexio_spi_slave_transfer_callback_t) (FLEXIO_SPI_Type *base, flexio_spi_slave_handle_t *handle, status_t status, void *userData)
 FlexIO SPI slave callback for finished transmit.
 
#define FSL_FLEXIO_SPI_DRIVER_VERSION   (MAKE_VERSION(2, 3, 0))
 FlexIO SPI driver version.
 
#define FLEXIO_SPI_DUMMYDATA   (0xFFFFFFFFU)
 FlexIO SPI dummy transfer data, the data is sent while txData is NULL.
 
#define SPI_RETRY_TIMES   0U /* Define to zero means keep waiting until the flag is assert/deassert. */
 Retry times for waiting flag.
 
#define FLEXIO_SPI_XFER_DATA_FORMAT(flag)   ((flag) & (0x7U))
 Get the transfer data format of width and bit order.
 

FlexIO SPI Configuration

void FLEXIO_SPI_MasterInit (FLEXIO_SPI_Type *base, flexio_spi_master_config_t *masterConfig, uint32_t srcClock_Hz)
 Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI master hardware, and configures the FlexIO SPI with FlexIO SPI master configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_MasterGetDefaultConfig(). More...
 
void FLEXIO_SPI_MasterDeinit (FLEXIO_SPI_Type *base)
 Resets the FlexIO SPI timer and shifter config. More...
 
void FLEXIO_SPI_MasterGetDefaultConfig (flexio_spi_master_config_t *masterConfig)
 Gets the default configuration to configure the FlexIO SPI master. The configuration can be used directly by calling the FLEXIO_SPI_MasterConfigure(). Example: More...
 
void FLEXIO_SPI_SlaveInit (FLEXIO_SPI_Type *base, flexio_spi_slave_config_t *slaveConfig)
 Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI slave hardware configuration, and configures the FlexIO SPI with FlexIO SPI slave configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_SlaveGetDefaultConfig(). More...
 
void FLEXIO_SPI_SlaveDeinit (FLEXIO_SPI_Type *base)
 Gates the FlexIO clock. More...
 
void FLEXIO_SPI_SlaveGetDefaultConfig (flexio_spi_slave_config_t *slaveConfig)
 Gets the default configuration to configure the FlexIO SPI slave. The configuration can be used directly for calling the FLEXIO_SPI_SlaveConfigure(). Example: More...
 

Status

uint32_t FLEXIO_SPI_GetStatusFlags (FLEXIO_SPI_Type *base)
 Gets FlexIO SPI status flags. More...
 
void FLEXIO_SPI_ClearStatusFlags (FLEXIO_SPI_Type *base, uint32_t mask)
 Clears FlexIO SPI status flags. More...
 

Interrupts

void FLEXIO_SPI_EnableInterrupts (FLEXIO_SPI_Type *base, uint32_t mask)
 Enables the FlexIO SPI interrupt. More...
 
void FLEXIO_SPI_DisableInterrupts (FLEXIO_SPI_Type *base, uint32_t mask)
 Disables the FlexIO SPI interrupt. More...
 

DMA Control

void FLEXIO_SPI_EnableDMA (FLEXIO_SPI_Type *base, uint32_t mask, bool enable)
 Enables/disables the FlexIO SPI transmit DMA. This function enables/disables the FlexIO SPI Tx DMA, which means that asserting the kFLEXIO_SPI_TxEmptyFlag does/doesn't trigger the DMA request. More...
 

Bus Operations

void FLEXIO_SPI_MasterSetBaudRate (FLEXIO_SPI_Type *base, uint32_t baudRate_Bps, uint32_t srcClockHz)
 Sets baud rate for the FlexIO SPI transfer, which is only used for the master. More...
 
status_t FLEXIO_SPI_WriteBlocking (FLEXIO_SPI_Type *base, flexio_spi_shift_direction_t direction, const uint8_t *buffer, size_t size)
 Sends a buffer of data bytes. More...
 
status_t FLEXIO_SPI_ReadBlocking (FLEXIO_SPI_Type *base, flexio_spi_shift_direction_t direction, uint8_t *buffer, size_t size)
 Receives a buffer of bytes. More...
 
status_t FLEXIO_SPI_MasterTransferBlocking (FLEXIO_SPI_Type *base, flexio_spi_transfer_t *xfer)
 Receives a buffer of bytes. More...
 
void FLEXIO_SPI_FlushShifters (FLEXIO_SPI_Type *base)
 Flush tx/rx shifters. More...
 

Transactional

status_t FLEXIO_SPI_MasterTransferCreateHandle (FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_master_transfer_callback_t callback, void *userData)
 Initializes the FlexIO SPI Master handle, which is used in transactional functions. More...
 
status_t FLEXIO_SPI_MasterTransferNonBlocking (FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, flexio_spi_transfer_t *xfer)
 Master transfer data using IRQ. More...
 
void FLEXIO_SPI_MasterTransferAbort (FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle)
 Aborts the master data transfer, which used IRQ. More...
 
status_t FLEXIO_SPI_MasterTransferGetCount (FLEXIO_SPI_Type *base, flexio_spi_master_handle_t *handle, size_t *count)
 Gets the data transfer status which used IRQ. More...
 
void FLEXIO_SPI_MasterTransferHandleIRQ (void *spiType, void *spiHandle)
 FlexIO SPI master IRQ handler function. More...
 
status_t FLEXIO_SPI_SlaveTransferCreateHandle (FLEXIO_SPI_Type *base, flexio_spi_slave_handle_t *handle, flexio_spi_slave_transfer_callback_t callback, void *userData)
 Initializes the FlexIO SPI Slave handle, which is used in transactional functions. More...
 
status_t FLEXIO_SPI_SlaveTransferNonBlocking (FLEXIO_SPI_Type *base, flexio_spi_slave_handle_t *handle, flexio_spi_transfer_t *xfer)
 Slave transfer data using IRQ. More...
 
void FLEXIO_SPI_SlaveTransferHandleIRQ (void *spiType, void *spiHandle)
 FlexIO SPI slave IRQ handler function. More...
 

Detailed Description

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Error codes for the FlexIO SPI driver.

Enumerator
kStatus_FLEXIO_SPI_Busy 

FlexIO SPI is busy.

kStatus_FLEXIO_SPI_Idle 

SPI is idle

kStatus_FLEXIO_SPI_Error 

FlexIO SPI error.

kStatus_FLEXIO_SPI_Timeout 

FlexIO SPI timeout polling status flags.

◆ _flexio_spi_clock_phase

FlexIO SPI clock phase configuration.

Enumerator
kFLEXIO_SPI_ClockPhaseFirstEdge 

First edge on SPSCK occurs at the middle of the first cycle of a data transfer.

kFLEXIO_SPI_ClockPhaseSecondEdge 

First edge on SPSCK occurs at the start of the first cycle of a data transfer.

◆ _flexio_spi_data_bitcount_mode

FlexIO SPI data length mode options.

Enumerator
kFLEXIO_SPI_8BitMode 

8-bit data transmission mode.

kFLEXIO_SPI_16BitMode 

16-bit data transmission mode.

kFLEXIO_SPI_32BitMode 

32-bit data transmission mode.

◆ _flexio_spi_dma_enable

Define FlexIO SPI DMA mask.

Enumerator
kFLEXIO_SPI_TxDmaEnable 

Tx DMA request source

kFLEXIO_SPI_RxDmaEnable 

Rx DMA request source

kFLEXIO_SPI_DmaAllEnable 

All DMA request source

◆ _flexio_spi_interrupt_enable

Define FlexIO SPI interrupt mask.

Enumerator
kFLEXIO_SPI_TxEmptyInterruptEnable 

Transmit buffer empty interrupt enable.

kFLEXIO_SPI_RxFullInterruptEnable 

Receive buffer full interrupt enable.

◆ _flexio_spi_shift_direction

FlexIO SPI data shifter direction options.

Enumerator
kFLEXIO_SPI_MsbFirst 

Data transfers start with most significant bit.

kFLEXIO_SPI_LsbFirst 

Data transfers start with least significant bit.

◆ _flexio_spi_status_flags

Define FlexIO SPI status mask.

Enumerator
kFLEXIO_SPI_TxBufferEmptyFlag 

Transmit buffer empty flag.

kFLEXIO_SPI_RxBufferFullFlag 

Receive buffer full flag.

◆ _flexio_spi_transfer_flags

Define FlexIO SPI transfer flags.

Note
Use kFLEXIO_SPI_csContinuous and one of the other flags to OR together to form the transfer flag.
Enumerator
kFLEXIO_SPI_8bitMsb 

FlexIO SPI 8-bit MSB first

kFLEXIO_SPI_8bitLsb 

FlexIO SPI 8-bit LSB first

kFLEXIO_SPI_16bitMsb 

FlexIO SPI 16-bit MSB first

kFLEXIO_SPI_16bitLsb 

FlexIO SPI 16-bit LSB first

kFLEXIO_SPI_32bitMsb 

FlexIO SPI 32-bit MSB first

kFLEXIO_SPI_32bitLsb 

FlexIO SPI 32-bit LSB first

kFLEXIO_SPI_csContinuous 

Enable the CS signal continuous mode

Function Documentation

◆ FLEXIO_SPI_ClearStatusFlags()

void FLEXIO_SPI_ClearStatusFlags ( FLEXIO_SPI_Type base,
uint32_t  mask 
)

Clears FlexIO SPI status flags.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
maskstatus flag The parameter can be any combination of the following values:
  • kFLEXIO_SPI_TxEmptyFlag
  • kFLEXIO_SPI_RxEmptyFlag
brief Clears FlexIO SPI status flags.

param base Pointer to the FLEXIO_SPI_Type structure. param mask status flag The parameter can be any combination of the following values: arg kFLEXIO_SPI_TxEmptyFlag arg kFLEXIO_SPI_RxEmptyFlag

◆ FLEXIO_SPI_DisableInterrupts()

void FLEXIO_SPI_DisableInterrupts ( FLEXIO_SPI_Type base,
uint32_t  mask 
)

Disables the FlexIO SPI interrupt.

This function disables the FlexIO SPI interrupt.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
maskinterrupt source The parameter can be any combination of the following values:
  • kFLEXIO_SPI_RxFullInterruptEnable
  • kFLEXIO_SPI_TxEmptyInterruptEnable
brief Disables the FlexIO SPI interrupt.

This function disables the FlexIO SPI interrupt.

param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable

◆ FLEXIO_SPI_EnableDMA()

void FLEXIO_SPI_EnableDMA ( FLEXIO_SPI_Type base,
uint32_t  mask,
bool  enable 
)

Enables/disables the FlexIO SPI transmit DMA. This function enables/disables the FlexIO SPI Tx DMA, which means that asserting the kFLEXIO_SPI_TxEmptyFlag does/doesn't trigger the DMA request.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
maskSPI DMA source.
enableTrue means enable DMA, false means disable DMA.

brief Enables/disables the FlexIO SPI transmit DMA. This function enables/disables the FlexIO SPI Tx DMA, which means that asserting the kFLEXIO_SPI_TxEmptyFlag does/doesn't trigger the DMA request.

param base Pointer to the FLEXIO_SPI_Type structure. param mask SPI DMA source. param enable True means enable DMA, false means disable DMA.

◆ FLEXIO_SPI_EnableInterrupts()

void FLEXIO_SPI_EnableInterrupts ( FLEXIO_SPI_Type base,
uint32_t  mask 
)

Enables the FlexIO SPI interrupt.

This function enables the FlexIO SPI interrupt.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
maskinterrupt source. The parameter can be any combination of the following values:
  • kFLEXIO_SPI_RxFullInterruptEnable
  • kFLEXIO_SPI_TxEmptyInterruptEnable
brief Enables the FlexIO SPI interrupt.

This function enables the FlexIO SPI interrupt.

param base Pointer to the FLEXIO_SPI_Type structure. param mask interrupt source. The parameter can be any combination of the following values: arg kFLEXIO_SPI_RxFullInterruptEnable arg kFLEXIO_SPI_TxEmptyInterruptEnable

◆ FLEXIO_SPI_FlushShifters()

void FLEXIO_SPI_FlushShifters ( FLEXIO_SPI_Type base)

Flush tx/rx shifters.

Parameters
basePointer to the FLEXIO_SPI_Type structure.

brief Flush tx/rx shifters.

param base Pointer to the FLEXIO_SPI_Type structure.

◆ FLEXIO_SPI_GetStatusFlags()

uint32_t FLEXIO_SPI_GetStatusFlags ( FLEXIO_SPI_Type base)

Gets FlexIO SPI status flags.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
Returns
status flag; Use the status flag to AND the following flag mask and get the status.
  • kFLEXIO_SPI_TxEmptyFlag
  • kFLEXIO_SPI_RxEmptyFlag
brief Gets FlexIO SPI status flags.

param base Pointer to the FLEXIO_SPI_Type structure. return status flag; Use the status flag to AND the following flag mask and get the status. arg kFLEXIO_SPI_TxEmptyFlag arg kFLEXIO_SPI_RxEmptyFlag

◆ FLEXIO_SPI_MasterDeinit()

void FLEXIO_SPI_MasterDeinit ( FLEXIO_SPI_Type base)

Resets the FlexIO SPI timer and shifter config.

Parameters
basePointer to the FLEXIO_SPI_Type.

brief Resets the FlexIO SPI timer and shifter config.

param base Pointer to the FLEXIO_SPI_Type.

◆ FLEXIO_SPI_MasterGetDefaultConfig()

void FLEXIO_SPI_MasterGetDefaultConfig ( flexio_spi_master_config_t masterConfig)

Gets the default configuration to configure the FlexIO SPI master. The configuration can be used directly by calling the FLEXIO_SPI_MasterConfigure(). Example:

void FLEXIO_SPI_MasterGetDefaultConfig(flexio_spi_master_config_t *masterConfig)
Gets the default configuration to configure the FlexIO SPI master. The configuration can be used dire...
Definition: fsl_flexio_spi.c:374
Define FlexIO SPI master configuration structure.
Definition: fsl_flexio_spi.h:127
Parameters
masterConfigPointer to the flexio_spi_master_config_t structure.

brief Gets the default configuration to configure the FlexIO SPI master. The configuration can be used directly by calling the FLEXIO_SPI_MasterConfigure(). Example: code flexio_spi_master_config_t masterConfig; FLEXIO_SPI_MasterGetDefaultConfig(&masterConfig); endcode param masterConfig Pointer to the flexio_spi_master_config_t structure.

◆ FLEXIO_SPI_MasterInit()

void FLEXIO_SPI_MasterInit ( FLEXIO_SPI_Type base,
flexio_spi_master_config_t masterConfig,
uint32_t  srcClock_Hz 
)

Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI master hardware, and configures the FlexIO SPI with FlexIO SPI master configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_MasterGetDefaultConfig().

Note
1.FlexIO SPI master only support CPOL = 0, which means clock inactive low. 2.For FlexIO SPI master, the input valid time is 1.5 clock cycles, for slave the output valid time is 2.5 clock cycles. So if FlexIO SPI master communicates with other spi IPs, the maximum baud rate is FlexIO clock frequency divided by 2*2=4. If FlexIO SPI master communicates with FlexIO SPI slave, the maximum baud rate is FlexIO clock frequency divided by (1.5+2.5)*2=8.

Example

FLEXIO_SPI_Type spiDev = {
.flexioBase = FLEXIO,
.SDOPinIndex = 0,
.SDIPinIndex = 1,
.SCKPinIndex = 2,
.CSnPinIndex = 3,
.shifterIndex = {0,1},
.timerIndex = {0,1}
};
.enableMaster = true,
.enableInDoze = false,
.enableInDebug = true,
.enableFastAccess = false,
.baudRate_Bps = 500000,
.direction = kFLEXIO_SPI_MsbFirst,
};
FLEXIO_SPI_MasterInit(&spiDev, &config, srcClock_Hz);
FLEXIO_Type * flexioBase
Definition: fsl_flexio_spi.h:115
void FLEXIO_SPI_MasterInit(FLEXIO_SPI_Type *base, flexio_spi_master_config_t *masterConfig, uint32_t srcClock_Hz)
Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI master hardware,...
Definition: fsl_flexio_spi.c:223
@ kFLEXIO_SPI_ClockPhaseFirstEdge
Definition: fsl_flexio_spi.h:56
@ kFLEXIO_SPI_MsbFirst
Definition: fsl_flexio_spi.h:65
@ kFLEXIO_SPI_8BitMode
Definition: fsl_flexio_spi.h:72
Define FlexIO SPI access structure typedef.
Definition: fsl_flexio_spi.h:114
Definition: deflate.c:114
Parameters
basePointer to the FLEXIO_SPI_Type structure.
masterConfigPointer to the flexio_spi_master_config_t structure.
srcClock_HzFlexIO source clock in Hz.

brief Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI master hardware, and configures the FlexIO SPI with FlexIO SPI master configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_MasterGetDefaultConfig().

note 1.FlexIO SPI master only support CPOL = 0, which means clock inactive low. 2.For FlexIO SPI master, the input valid time is 1.5 clock cycles, for slave the output valid time is 2.5 clock cycles. So if FlexIO SPI master communicates with other spi IPs, the maximum baud rate is FlexIO clock frequency divided by 2*2=4. If FlexIO SPI master communicates with FlexIO SPI slave, the maximum baud rate is FlexIO clock frequency divided by (1.5+2.5)*2=8.

Example code FLEXIO_SPI_Type spiDev = { .flexioBase = FLEXIO, .SDOPinIndex = 0, .SDIPinIndex = 1, .SCKPinIndex = 2, .CSnPinIndex = 3, .shifterIndex = {0,1}, .timerIndex = {0,1} }; flexio_spi_master_config_t config = { .enableMaster = true, .enableInDoze = false, .enableInDebug = true, .enableFastAccess = false, .baudRate_Bps = 500000, .phase = kFLEXIO_SPI_ClockPhaseFirstEdge, .direction = kFLEXIO_SPI_MsbFirst, .dataMode = kFLEXIO_SPI_8BitMode }; FLEXIO_SPI_MasterInit(&spiDev, &config, srcClock_Hz); endcode

param base Pointer to the FLEXIO_SPI_Type structure. param masterConfig Pointer to the flexio_spi_master_config_t structure. param srcClock_Hz FlexIO source clock in Hz.

◆ FLEXIO_SPI_MasterSetBaudRate()

void FLEXIO_SPI_MasterSetBaudRate ( FLEXIO_SPI_Type base,
uint32_t  baudRate_Bps,
uint32_t  srcClockHz 
)

Sets baud rate for the FlexIO SPI transfer, which is only used for the master.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
baudRate_BpsBaud Rate needed in Hz.
srcClockHzSPI source clock frequency in Hz.

brief Sets baud rate for the FlexIO SPI transfer, which is only used for the master.

param base Pointer to the FLEXIO_SPI_Type structure. param baudRate_Bps Baud Rate needed in Hz. param srcClockHz SPI source clock frequency in Hz.

◆ FLEXIO_SPI_MasterTransferAbort()

void FLEXIO_SPI_MasterTransferAbort ( FLEXIO_SPI_Type base,
flexio_spi_master_handle_t handle 
)

Aborts the master data transfer, which used IRQ.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
handlePointer to the flexio_spi_master_handle_t structure to store the transfer state.

brief Aborts the master data transfer, which used IRQ.

param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state.

◆ FLEXIO_SPI_MasterTransferBlocking()

status_t FLEXIO_SPI_MasterTransferBlocking ( FLEXIO_SPI_Type base,
flexio_spi_transfer_t xfer 
)

Receives a buffer of bytes.

Note
This function blocks via polling until all bytes have been received.
Parameters
basepointer to FLEXIO_SPI_Type structure
xferFlexIO SPI transfer structure, see flexio_spi_transfer_t.
Return values
kStatus_SuccessSuccessfully create the handle.
kStatus_FLEXIO_SPI_TimeoutThe transfer timed out and was aborted.

brief Receives a buffer of bytes.

note This function blocks via polling until all bytes have been received.

param base pointer to FLEXIO_SPI_Type structure param xfer FlexIO SPI transfer structure, see flexio_spi_transfer_t. retval kStatus_Success Successfully create the handle. retval kStatus_FLEXIO_SPI_Timeout The transfer timed out and was aborted.

◆ FLEXIO_SPI_MasterTransferCreateHandle()

status_t FLEXIO_SPI_MasterTransferCreateHandle ( FLEXIO_SPI_Type base,
flexio_spi_master_handle_t handle,
flexio_spi_master_transfer_callback_t  callback,
void *  userData 
)

Initializes the FlexIO SPI Master handle, which is used in transactional functions.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
handlePointer to the flexio_spi_master_handle_t structure to store the transfer state.
callbackThe callback function.
userDataThe parameter of the callback function.
Return values
kStatus_SuccessSuccessfully create the handle.
kStatus_OutOfRangeThe FlexIO type/handle/ISR table out of range.

brief Initializes the FlexIO SPI Master handle, which is used in transactional functions.

param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range.

◆ FLEXIO_SPI_MasterTransferGetCount()

status_t FLEXIO_SPI_MasterTransferGetCount ( FLEXIO_SPI_Type base,
flexio_spi_master_handle_t handle,
size_t *  count 
)

Gets the data transfer status which used IRQ.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
handlePointer to the flexio_spi_master_handle_t structure to store 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.

brief Gets the data transfer status which used IRQ.

param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param count Number of bytes transferred so far by the non-blocking transaction. retval kStatus_InvalidArgument count is Invalid. retval kStatus_Success Successfully return the count.

◆ FLEXIO_SPI_MasterTransferHandleIRQ()

void FLEXIO_SPI_MasterTransferHandleIRQ ( void *  spiType,
void *  spiHandle 
)

FlexIO SPI master IRQ handler function.

Parameters
spiTypePointer to the FLEXIO_SPI_Type structure.
spiHandlePointer to the flexio_spi_master_handle_t structure to store the transfer state.

brief FlexIO SPI master IRQ handler function.

param spiType Pointer to the FLEXIO_SPI_Type structure. param spiHandle Pointer to the flexio_spi_master_handle_t structure to store the transfer state.

◆ FLEXIO_SPI_MasterTransferNonBlocking()

status_t FLEXIO_SPI_MasterTransferNonBlocking ( FLEXIO_SPI_Type base,
flexio_spi_master_handle_t handle,
flexio_spi_transfer_t xfer 
)

Master transfer data using IRQ.

This function sends data using IRQ. This is a non-blocking function, which returns right away. When all data is sent out/received, the callback function is called.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
handlePointer to the flexio_spi_master_handle_t structure to store the transfer state.
xferFlexIO SPI transfer structure. See flexio_spi_transfer_t.
Return values
kStatus_SuccessSuccessfully start a transfer.
kStatus_InvalidArgumentInput argument is invalid.
kStatus_FLEXIO_SPI_BusySPI is not idle, is running another transfer.

brief Master transfer data using IRQ.

This function sends data using IRQ. This is a non-blocking function, which returns right away. When all data is sent out/received, the callback function is called.

param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_master_handle_t structure to store the transfer state. param xfer FlexIO SPI transfer structure. See flexio_spi_transfer_t. retval kStatus_Success Successfully start a transfer. retval kStatus_InvalidArgument Input argument is invalid. retval kStatus_FLEXIO_SPI_Busy SPI is not idle, is running another transfer.

◆ FLEXIO_SPI_ReadBlocking()

status_t FLEXIO_SPI_ReadBlocking ( FLEXIO_SPI_Type base,
flexio_spi_shift_direction_t  direction,
uint8_t *  buffer,
size_t  size 
)

Receives a buffer of bytes.

Note
This function blocks using the polling method until all bytes have been received.
Parameters
basePointer to the FLEXIO_SPI_Type structure.
directionShift direction of MSB first or LSB first.
bufferThe buffer to store the received bytes.
sizeThe number of data bytes to be received.
directionShift direction of MSB first or LSB first.
Return values
kStatus_SuccessSuccessfully create the handle.
kStatus_FLEXIO_SPI_TimeoutThe transfer timed out and was aborted.

brief Receives a buffer of bytes.

note This function blocks using the polling method until all bytes have been received.

param base Pointer to the FLEXIO_SPI_Type structure. param direction Shift direction of MSB first or LSB first. param buffer The buffer to store the received bytes. param size The number of data bytes to be received. param direction Shift direction of MSB first or LSB first. retval kStatus_Success Successfully create the handle. retval kStatus_FLEXIO_SPI_Timeout The transfer timed out and was aborted.

◆ FLEXIO_SPI_SlaveDeinit()

void FLEXIO_SPI_SlaveDeinit ( FLEXIO_SPI_Type base)

Gates the FlexIO clock.

Parameters
basePointer to the FLEXIO_SPI_Type.

brief Gates the FlexIO clock.

param base Pointer to the FLEXIO_SPI_Type.

◆ FLEXIO_SPI_SlaveGetDefaultConfig()

void FLEXIO_SPI_SlaveGetDefaultConfig ( flexio_spi_slave_config_t slaveConfig)

Gets the default configuration to configure the FlexIO SPI slave. The configuration can be used directly for calling the FLEXIO_SPI_SlaveConfigure(). Example:

void FLEXIO_SPI_SlaveGetDefaultConfig(flexio_spi_slave_config_t *slaveConfig)
Gets the default configuration to configure the FlexIO SPI slave. The configuration can be used direc...
Definition: fsl_flexio_spi.c:550
Define FlexIO SPI slave configuration structure.
Definition: fsl_flexio_spi.h:141
Parameters
slaveConfigPointer to the flexio_spi_slave_config_t structure.

brief Gets the default configuration to configure the FlexIO SPI slave. The configuration can be used directly for calling the FLEXIO_SPI_SlaveConfigure(). Example: code flexio_spi_slave_config_t slaveConfig; FLEXIO_SPI_SlaveGetDefaultConfig(&slaveConfig); endcode param slaveConfig Pointer to the flexio_spi_slave_config_t structure.

◆ FLEXIO_SPI_SlaveInit()

void FLEXIO_SPI_SlaveInit ( FLEXIO_SPI_Type base,
flexio_spi_slave_config_t slaveConfig 
)

Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI slave hardware configuration, and configures the FlexIO SPI with FlexIO SPI slave configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_SlaveGetDefaultConfig().

Note
1.Only one timer is needed in the FlexIO SPI slave. As a result, the second timer index is ignored. 2.FlexIO SPI slave only support CPOL = 0, which means clock inactive low. 3.For FlexIO SPI master, the input valid time is 1.5 clock cycles, for slave the output valid time is 2.5 clock cycles. So if FlexIO SPI slave communicates with other spi IPs, the maximum baud rate is FlexIO clock frequency divided by 3*2=6. If FlexIO SPI slave communicates with FlexIO SPI master, the maximum baud rate is FlexIO clock frequency divided by (1.5+2.5)*2=8. Example
FLEXIO_SPI_Type spiDev = {
.flexioBase = FLEXIO,
.SDOPinIndex = 0,
.SDIPinIndex = 1,
.SCKPinIndex = 2,
.CSnPinIndex = 3,
.shifterIndex = {0,1},
.timerIndex = {0}
};
.enableSlave = true,
.enableInDoze = false,
.enableInDebug = true,
.enableFastAccess = false,
.direction = kFLEXIO_SPI_MsbFirst,
};
void FLEXIO_SPI_SlaveInit(FLEXIO_SPI_Type *base, flexio_spi_slave_config_t *slaveConfig)
Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI slave hardware configur...
Definition: fsl_flexio_spi.c:430
Parameters
basePointer to the FLEXIO_SPI_Type structure.
slaveConfigPointer to the flexio_spi_slave_config_t structure.

brief Ungates the FlexIO clock, resets the FlexIO module, configures the FlexIO SPI slave hardware configuration, and configures the FlexIO SPI with FlexIO SPI slave configuration. The configuration structure can be filled by the user, or be set with default values by the FLEXIO_SPI_SlaveGetDefaultConfig().

note 1.Only one timer is needed in the FlexIO SPI slave. As a result, the second timer index is ignored. 2.FlexIO SPI slave only support CPOL = 0, which means clock inactive low. 3.For FlexIO SPI master, the input valid time is 1.5 clock cycles, for slave the output valid time is 2.5 clock cycles. So if FlexIO SPI slave communicates with other spi IPs, the maximum baud rate is FlexIO clock frequency divided by 3*2=6. If FlexIO SPI slave communicates with FlexIO SPI master, the maximum baud rate is FlexIO clock frequency divided by (1.5+2.5)*2=8. Example code FLEXIO_SPI_Type spiDev = { .flexioBase = FLEXIO, .SDOPinIndex = 0, .SDIPinIndex = 1, .SCKPinIndex = 2, .CSnPinIndex = 3, .shifterIndex = {0,1}, .timerIndex = {0} }; flexio_spi_slave_config_t config = { .enableSlave = true, .enableInDoze = false, .enableInDebug = true, .enableFastAccess = false, .phase = kFLEXIO_SPI_ClockPhaseFirstEdge, .direction = kFLEXIO_SPI_MsbFirst, .dataMode = kFLEXIO_SPI_8BitMode }; FLEXIO_SPI_SlaveInit(&spiDev, &config); endcode param base Pointer to the FLEXIO_SPI_Type structure. param slaveConfig Pointer to the flexio_spi_slave_config_t structure.

◆ FLEXIO_SPI_SlaveTransferCreateHandle()

status_t FLEXIO_SPI_SlaveTransferCreateHandle ( FLEXIO_SPI_Type base,
flexio_spi_slave_handle_t handle,
flexio_spi_slave_transfer_callback_t  callback,
void *  userData 
)

Initializes the FlexIO SPI Slave handle, which is used in transactional functions.

Parameters
basePointer to the FLEXIO_SPI_Type structure.
handlePointer to the flexio_spi_slave_handle_t structure to store the transfer state.
callbackThe callback function.
userDataThe parameter of the callback function.
Return values
kStatus_SuccessSuccessfully create the handle.
kStatus_OutOfRangeThe FlexIO type/handle/ISR table out of range.

brief Initializes the FlexIO SPI Slave handle, which is used in transactional functions.

param base Pointer to the FLEXIO_SPI_Type structure. param handle Pointer to the flexio_spi_slave_handle_t structure to store the transfer state. param callback The callback function. param userData The parameter of the callback function. retval kStatus_Success Successfully create the handle. retval kStatus_OutOfRange The FlexIO type/handle/ISR table out of range.

◆ FLEXIO_SPI_SlaveTransferHandleIRQ()

void FLEXIO_SPI_SlaveTransferHandleIRQ ( void *  spiType,
void *  spiHandle 
)

FlexIO SPI slave IRQ handler function.

Parameters
spiTypePointer to the FLEXIO_SPI_Type structure.
spiHandlePointer to the flexio_spi_slave_handle_t structure to store the transfer state.

brief FlexIO SPI slave IRQ handler function.

param spiType Pointer to the FLEXIO_SPI_Type structure. param spiHandle Pointer to the flexio_spi_slave_handle_t structure to store the transfer state.

◆ FLEXIO_SPI_SlaveTransferNonBlocking()

status_t FLEXIO_SPI_SlaveTransferNonBlocking ( FLEXIO_SPI_Type base,
flexio_spi_slave_handle_t handle,
flexio_spi_transfer_t xfer 
)

Slave transfer data using IRQ.

This function sends data using IRQ. This is a non-blocking function, which returns right away. When all data is sent out/received, the callback function is called.

Parameters
handlePointer to the flexio_spi_slave_handle_t structure to store the transfer state.
basePointer to the FLEXIO_SPI_Type structure.
xferFlexIO SPI transfer structure. See flexio_spi_transfer_t.
Return values
kStatus_SuccessSuccessfully start a transfer.
kStatus_InvalidArgumentInput argument is invalid.
kStatus_FLEXIO_SPI_BusySPI is not idle; it is running another transfer.

brief Slave transfer data using IRQ.

This function sends data using IRQ. This is a non-blocking function, which returns right away. When all data is sent out/received, the callback function is called. param handle Pointer to the flexio_spi_slave_handle_t structure to store the transfer state.

param base Pointer to the FLEXIO_SPI_Type structure. param xfer FlexIO SPI transfer structure. See flexio_spi_transfer_t. retval kStatus_Success Successfully start a transfer. retval kStatus_InvalidArgument Input argument is invalid. retval kStatus_FLEXIO_SPI_Busy SPI is not idle; it is running another transfer.

◆ FLEXIO_SPI_WriteBlocking()

status_t FLEXIO_SPI_WriteBlocking ( FLEXIO_SPI_Type base,
flexio_spi_shift_direction_t  direction,
const uint8_t *  buffer,
size_t  size 
)

Sends a buffer of data bytes.

Note
This function blocks using the polling method until all bytes have been sent.
Parameters
basePointer to the FLEXIO_SPI_Type structure.
directionShift direction of MSB first or LSB first.
bufferThe data bytes to send.
sizeThe number of data bytes to send.
Return values
kStatus_SuccessSuccessfully create the handle.
kStatus_FLEXIO_SPI_TimeoutThe transfer timed out and was aborted.

brief Sends a buffer of data bytes.

note This function blocks using the polling method until all bytes have been sent.

param base Pointer to the FLEXIO_SPI_Type structure. param direction Shift direction of MSB first or LSB first. param buffer The data bytes to send. param size The number of data bytes to send. retval kStatus_Success Successfully create the handle. retval kStatus_FLEXIO_SPI_Timeout The transfer timed out and was aborted.

Variable Documentation

◆ baudRate_Bps

uint32_t _flexio_spi_master_config::baudRate_Bps

Baud rate in Bps.

◆ bytePerFrame

uint8_t _flexio_spi_master_handle::bytePerFrame

SPI mode, 2bytes or 1byte in a frame

◆ callback

flexio_spi_master_transfer_callback_t _flexio_spi_master_handle::callback

FlexIO SPI callback.

◆ CSnPinIndex

uint8_t _flexio_spi_type::CSnPinIndex

Pin select for enable.

◆ dataMode [1/2]

flexio_spi_data_bitcount_mode_t _flexio_spi_master_config::dataMode

8bit or 16bit mode.

◆ dataMode [2/2]

flexio_spi_data_bitcount_mode_t _flexio_spi_slave_config::dataMode

8bit or 16bit mode.

◆ dataSize

size_t _flexio_spi_transfer::dataSize

Transfer bytes.

◆ direction

flexio_spi_shift_direction_t _flexio_spi_master_handle::direction

Shift direction.

◆ enableFastAccess [1/2]

bool _flexio_spi_master_config::enableFastAccess

Enable/disable fast access to FlexIO registers, fast access requires the FlexIO clock to be at least twice the frequency of the bus clock.

◆ enableFastAccess [2/2]

bool _flexio_spi_slave_config::enableFastAccess

Enable/disable fast access to FlexIO registers, fast access requires the FlexIO clock to be at least twice the frequency of the bus clock.

◆ enableInDebug [1/2]

bool _flexio_spi_master_config::enableInDebug

Enable/disable FlexIO operation in debug mode.

◆ enableInDebug [2/2]

bool _flexio_spi_slave_config::enableInDebug

Enable/disable FlexIO operation in debug mode.

◆ enableInDoze [1/2]

bool _flexio_spi_master_config::enableInDoze

Enable/disable FlexIO operation in doze mode.

◆ enableInDoze [2/2]

bool _flexio_spi_slave_config::enableInDoze

Enable/disable FlexIO operation in doze mode.

◆ enableMaster

bool _flexio_spi_master_config::enableMaster

Enable/disable FlexIO SPI master after configuration.

◆ enableSlave

bool _flexio_spi_slave_config::enableSlave

Enable/disable FlexIO SPI slave after configuration.

◆ flags

uint8_t _flexio_spi_transfer::flags

FlexIO SPI control flag, MSB first or LSB first.

◆ flexioBase

FLEXIO_Type* _flexio_spi_type::flexioBase

FlexIO base pointer.

◆ phase [1/2]

flexio_spi_clock_phase_t _flexio_spi_master_config::phase

Clock phase.

◆ phase [2/2]

flexio_spi_clock_phase_t _flexio_spi_slave_config::phase

Clock phase.

◆ rxData [1/2]

uint8_t* _flexio_spi_transfer::rxData

Receive buffer.

◆ rxData [2/2]

uint8_t* _flexio_spi_master_handle::rxData

Receive buffer.

◆ rxRemainingBytes

volatile size_t _flexio_spi_master_handle::rxRemainingBytes

Receive data remaining in bytes.

◆ SCKPinIndex

uint8_t _flexio_spi_type::SCKPinIndex

Pin select for clock.

◆ SDIPinIndex

uint8_t _flexio_spi_type::SDIPinIndex

Pin select for data input.

◆ SDOPinIndex

uint8_t _flexio_spi_type::SDOPinIndex

Pin select for data output. To set SDO pin in Hi-Z state, user needs to mux the pin as GPIO input and disable all pull up/down in application.

◆ shifterIndex

uint8_t _flexio_spi_type::shifterIndex[2]

Shifter index used in FlexIO SPI.

◆ state

volatile uint32_t _flexio_spi_master_handle::state

FlexIO SPI internal state.

◆ timerIndex

uint8_t _flexio_spi_type::timerIndex[2]

Timer index used in FlexIO SPI.

◆ transferSize

size_t _flexio_spi_master_handle::transferSize

Total bytes to be transferred.

◆ txData [1/2]

uint8_t* _flexio_spi_transfer::txData

Send buffer.

◆ txData [2/2]

uint8_t* _flexio_spi_master_handle::txData

Transfer buffer.

◆ txRemainingBytes

volatile size_t _flexio_spi_master_handle::txRemainingBytes

Send data remaining in bytes.

◆ userData

void* _flexio_spi_master_handle::userData

Callback parameter.