| Kinetis SDK v.2.0 API Reference Manual Rev. 0 Freescale Semiconductor, Inc.

- Main Page
- Related Pages
- API Reference

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Modules | Files | Data Structures | Macros | Typedefs | Enumerations
FlexIO I2S Driver
FlexIO: FlexIO Driver

## Overview

The KSDK provides a peripheral driver for I2S function using Flexible I/O module of Kinetis devices.

# Overview

The FlexIO I2S driver includes functional APIs and transactional APIs.

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

Transactional APIs are transaction target high level APIs. The transactional APIs can be used to enable the peripheral and also in the application if the code size and performance of transactional APIs can satisfy requirements. If the code size and performance are critical requirements, see the transactional API implementation and write custom code. All transactional APIs use the the sai_handle_t as the first parameter. Initialize the handle by calling the FlexIO_I2S_TransferTxCreateHandle() or FlexIO_I2S_TransferRxCreateHandle() API.

Transactional APIs support asynchronous transfer. This means that the functions FLEXIO_I2S_TransferSendNonBlocking() and FLEXIO_I2S_TransferReceiveNonBlocking() set up an interrupt for data transfer. When the transfer completes, the upper layer is notified through a callback function with the kStatus_FLEXIO_I2S_TxIdle and kStatus_FLEXIO_I2S_RxIdle status.

# Typical use case

## FlexIO I2S send/receive using an interrupt method

sai_handle_t g_saiTxHandle;
sai_config_t user_config;
sai_transfer_t sendXfer;
volatile bool txFinished;
volatile bool rxFinished;
const uint8_t sendData[] = [......];
void FLEXIO_I2S_UserCallback(sai_handle_t *handle, status_t status, void *userData)
{
userData = userData;
if (kStatus_FLEXIO_I2S_TxIdle == status)
{
txFinished = true;
}
}
void main(void)
{
//...
FLEXIO_I2S_TxGetDefaultConfig(&user_config);
FLEXIO_I2S_TxInit(FLEXIO I2S0, &user_config);
FLEXIO_I2S_TransferTxCreateHandle(FLEXIO I2S0, &g_saiHandle, FLEXIO_I2S_UserCallback, NULL);
//Configures the SAI format.
FLEXIO_I2S_TransferTxSetTransferFormat(FLEXIO I2S0, &g_saiHandle, mclkSource, mclk);
// Prepares to send.
sendXfer.data = sendData
sendXfer.dataSize = sizeof(sendData)/sizeof(sendData[0]);
txFinished = false;
// Sends out.
FLEXIO_I2S_TransferSendNonBlocking(FLEXIO I2S0, &g_saiHandle, &sendXfer);
// Waiting to send is finished.
while (!txFinished)
{
}
// ...
}

## FLEXIO_I2S send/receive using a DMA method

sai_handle_t g_saiHandle;
dma_handle_t g_saiTxDmaHandle;
dma_handle_t g_saiRxDmaHandle;
sai_config_t user_config;
sai_transfer_t sendXfer;
volatile bool txFinished;
uint8_t sendData[] = ...;
void FLEXIO_I2S_UserCallback(sai_handle_t *handle, status_t status, void *userData)
{
userData = userData;
if (kStatus_FLEXIO_I2S_TxIdle == status)
{
txFinished = true;
}
}
void main(void)
{
//...
FLEXIO_I2S_TxGetDefaultConfig(&user_config);
FLEXIO_I2S_TxInit(FLEXIO I2S0, &user_config);
// Sets up the DMA.
DMAMUX_Init(DMAMUX0);
DMAMUX_SetSource(DMAMUX0, FLEXIO_I2S_TX_DMA_CHANNEL, FLEXIO_I2S_TX_DMA_REQUEST);
DMAMUX_EnableChannel(DMAMUX0, FLEXIO_I2S_TX_DMA_CHANNEL);
DMA_Init(DMA0);
/* Creates the DMA handle.
DMA_TransferTxCreateHandle(&g_saiTxDmaHandle, DMA0, FLEXIO_I2S_TX_DMA_CHANNEL);
FLEXIO_I2S_TransferTxCreateHandleDMA(FLEXIO I2S0, &g_saiTxDmaHandle, FLEXIO_I2S_UserCallback, NULL);
// Prepares to send.
sendXfer.data = sendData
sendXfer.dataSize = sizeof(sendData)/sizeof(sendData[0]);
txFinished = false;
// Sends out.
FLEXIO_I2S_TransferSendDMA(&g_saiHandle, &sendXfer);
// Waiting to send is finished.
while (!txFinished)
{
}
// ...
}

## Modules
| FlexIO DMA I2S Driver
| FlexIO eDMA I2S Driver

## Files
file | fsl_flexio_i2s.h

## Data Structures
struct | FLEXIO_I2S_Type
| Define FlexIO I2S access structure typedef. More...
struct | flexio_i2s_config_t
| FlexIO I2S configure structure. More...
struct | flexio_i2s_format_t
| FlexIO I2S audio format, FlexIO I2S only support the same format in Tx and Rx. More...
struct | flexio_i2s_transfer_t
| Define FlexIO I2S transfer structure. More...
struct | flexio_i2s_handle_t
| Define FlexIO I2S handle structure. More...

## Macros
#define | FLEXIO_I2S_XFER_QUEUE_SIZE (4)
| FlexIO I2S transfer queue size, user can refine it according to use case. More...

## Typedefs
typedef void(* | flexio_i2s_callback_t )(FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, status_t status, void *userData)
| FlexIO I2S xfer callback prototype.

## Enumerations
enum | _flexio_i2s_status { kStatus_FLEXIO_I2S_Idle = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 0), kStatus_FLEXIO_I2S_TxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 1), kStatus_FLEXIO_I2S_RxBusy = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 2), kStatus_FLEXIO_I2S_Error = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 3), kStatus_FLEXIO_I2S_QueueFull = MAKE_STATUS(kStatusGroup_FLEXIO_I2S, 4) }
| FlexIO I2S transfer status. More...
enum | flexio_i2s_master_slave_t { kFLEXIO_I2S_Master = 0x0U, kFLEXIO_I2S_Slave = 0x1U }
| Master or slave mode. More...
enum | _flexio_i2s_interrupt_enable { kFLEXIO_I2S_TxDataRegEmptyInterruptEnable = 0x1U, kFLEXIO_I2S_RxDataRegFullInterruptEnable = 0x2U }
| Define FlexIO FlexIO I2S interrupt mask. More...
enum | _flexio_i2s_status_flags { kFLEXIO_I2S_TxDataRegEmptyFlag = 0x1U, kFLEXIO_I2S_RxDataRegFullFlag = 0x2U }
| Define FlexIO FlexIO I2S status mask. More...
enum | flexio_i2s_sample_rate_t { kFLEXIO_I2S_SampleRate8KHz = 8000U, kFLEXIO_I2S_SampleRate11025Hz = 11025U, kFLEXIO_I2S_SampleRate12KHz = 12000U, kFLEXIO_I2S_SampleRate16KHz = 16000U, kFLEXIO_I2S_SampleRate22050Hz = 22050U, kFLEXIO_I2S_SampleRate24KHz = 24000U, kFLEXIO_I2S_SampleRate32KHz = 32000U, kFLEXIO_I2S_SampleRate44100Hz = 44100U, kFLEXIO_I2S_SampleRate48KHz = 48000U, kFLEXIO_I2S_SampleRate96KHz = 96000U }
| Audio sample rate. More...
enum | flexio_i2s_word_width_t { kFLEXIO_I2S_WordWidth8bits = 8U, kFLEXIO_I2S_WordWidth16bits = 16U, kFLEXIO_I2S_WordWidth24bits = 24U, kFLEXIO_I2S_WordWidth32bits = 32U }
| Audio word width. More...

## Driver version
#define | FSL_FLEXIO_I2S_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))
| FlexIO I2S driver version 2.1.0. More...

## Initialization and deinitialization
void | FLEXIO_I2S_Init (FLEXIO_I2S_Type *base, const flexio_i2s_config_t *config)
| Initializes the FlexIO I2S. More...
void | FLEXIO_I2S_GetDefaultConfig (flexio_i2s_config_t *config)
| Sets the FlexIO I2S configuration structure to default values. More...
void | FLEXIO_I2S_Deinit (FLEXIO_I2S_Type *base)
| De-initializes the FlexIO I2S. More...
static void | FLEXIO_I2S_Enable (FLEXIO_I2S_Type *base, bool enable)
| Enables/disables the FlexIO I2S module operation. More...

## Status
uint32_t | FLEXIO_I2S_GetStatusFlags (FLEXIO_I2S_Type *base)
| Gets the FlexIO I2S status flags. More...

## Interrupts
void | FLEXIO_I2S_EnableInterrupts (FLEXIO_I2S_Type *base, uint32_t mask)
| Enables the FlexIO I2S interrupt. More...
void | FLEXIO_I2S_DisableInterrupts (FLEXIO_I2S_Type *base, uint32_t mask)
| Disables the FlexIO I2S interrupt. More...

## DMA Control
static void | FLEXIO_I2S_TxEnableDMA (FLEXIO_I2S_Type *base, bool enable)
| Enables/disables the FlexIO I2S Tx DMA requests. More...
static void | FLEXIO_I2S_RxEnableDMA (FLEXIO_I2S_Type *base, bool enable)
| Enables/disables the FlexIO I2S Rx DMA requests. More...
static uint32_t | FLEXIO_I2S_TxGetDataRegisterAddress (FLEXIO_I2S_Type *base)
| Gets the FlexIO I2S send data register address. More...
static uint32_t | FLEXIO_I2S_RxGetDataRegisterAddress (FLEXIO_I2S_Type *base)
| Gets the FlexIO I2S receive data register address. More...

## Bus Operations
void | FLEXIO_I2S_MasterSetFormat (FLEXIO_I2S_Type *base, flexio_i2s_format_t *format, uint32_t srcClock_Hz)
| Configures the FlexIO I2S audio format in master mode. More...
void | FLEXIO_I2S_SlaveSetFormat (FLEXIO_I2S_Type *base, flexio_i2s_format_t *format)
| Configures the FlexIO I2S audio format in slave mode. More...
void | FLEXIO_I2S_WriteBlocking (FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *txData, size_t size)
| Sends a piece of data using a blocking method. More...
static void | FLEXIO_I2S_WriteData (FLEXIO_I2S_Type *base, uint8_t bitWidth, uint32_t data)
| Writes a data into data register. More...
void | FLEXIO_I2S_ReadBlocking (FLEXIO_I2S_Type *base, uint8_t bitWidth, uint8_t *rxData, size_t size)
| Receives a piece of data using a blocking method. More...
static uint32_t | FLEXIO_I2S_ReadData (FLEXIO_I2S_Type *base)
| Reads a data from the data register. More...

## Transactional
void | FLEXIO_I2S_TransferTxCreateHandle (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_callback_t callback, void *userData)
| Initializes the FlexIO I2S handle. More...
void | FLEXIO_I2S_TransferSetFormat (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_format_t *format, uint32_t srcClock_Hz)
| Configures the FlexIO I2S audio format. More...
void | FLEXIO_I2S_TransferRxCreateHandle (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_callback_t callback, void *userData)
| Initializes the FlexIO I2S receive handle. More...
status_t | FLEXIO_I2S_TransferSendNonBlocking (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_transfer_t *xfer)
| Performs an interrupt non-blocking send transfer on FlexIO I2S. More...
status_t | FLEXIO_I2S_TransferReceiveNonBlocking (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, flexio_i2s_transfer_t *xfer)
| Performs an interrupt non-blocking receive transfer on FlexIO I2S. More...
void | FLEXIO_I2S_TransferAbortSend (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
| Aborts the current send. More...
void | FLEXIO_I2S_TransferAbortReceive (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle)
| Aborts the current receive. More...
status_t | FLEXIO_I2S_TransferGetSendCount (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count)
| Gets the remaining bytes to be sent. More...
status_t | FLEXIO_I2S_TransferGetReceiveCount (FLEXIO_I2S_Type *base, flexio_i2s_handle_t *handle, size_t *count)
| Gets the remaining bytes to be received. More...
void | FLEXIO_I2S_TransferTxHandleIRQ (void *i2sBase, void *i2sHandle)
| Tx interrupt handler. More...
void | FLEXIO_I2S_TransferRxHandleIRQ (void *i2sBase, void *i2sHandle)
| Rx interrupt handler. More...

## Data Structure Documentation

struct FLEXIO_I2S_Type

### Data Fields
FLEXIO_Type * | flexioBase
| FlexIO base pointer.
uint8_t | txPinIndex
| Tx data pin index in FlexIO pins.
uint8_t | rxPinIndex
| Rx data pin index.
uint8_t | bclkPinIndex
| Bit clock pin index.
uint8_t | fsPinIndex
| Frame sync pin index.
uint8_t | txShifterIndex
| Tx data shifter index.
uint8_t | rxShifterIndex
| Rx data shifter index.
uint8_t | bclkTimerIndex
| Bit clock timer index.
uint8_t | fsTimerIndex
| Frame sync timer index.

struct flexio_i2s_config_t

### Data Fields
bool | enableI2S
| Enable FlexIO I2S.
flexio_i2s_master_slave_t | masterSlave
| Master or slave.

struct flexio_i2s_format_t

### Data Fields
uint8_t | bitWidth
| Bit width of audio data, always 8/16/24/32 bits.
uint32_t | sampleRate_Hz
| Sample rate of the audio data.

struct flexio_i2s_transfer_t

### Data Fields
uint8_t * | data
| Data buffer start pointer.
size_t | dataSize
| Bytes to be transferred. More...

#### Field Documentation

size_t flexio_i2s_transfer_t::dataSize

struct _flexio_i2s_handle

### Data Fields
uint32_t | state
| Internal state.
flexio_i2s_callback_t | callback
| Callback function called at transfer event.
void * | userData
| Callback parameter passed to callback function.
uint8_t | bitWidth
| Bit width for transfer, 8/16/24/32bits.
flexio_i2s_transfer_t | queue [FLEXIO_I2S_XFER_QUEUE_SIZE]
| Transfer queue storing queued transfer.
size_t | transferSize [FLEXIO_I2S_XFER_QUEUE_SIZE]
| Data bytes need to transfer.
volatile uint8_t | queueUser
| Index for user to queue transfer.
volatile uint8_t | queueDriver
| Index for driver to get the transfer data and size.

## Macro Definition Documentation

#define FSL_FLEXIO_I2S_DRIVER_VERSION (MAKE_VERSION(2, 1, 0))

#define FLEXIO_I2S_XFER_QUEUE_SIZE (4)

## Enumeration Type Documentation

enum _flexio_i2s_status

Enumerator
kStatus_FLEXIO_I2S_Idle | FlexIO I2S is in idle state.
kStatus_FLEXIO_I2S_TxBusy | FlexIO I2S Tx is busy.
kStatus_FLEXIO_I2S_RxBusy | FlexIO I2S Tx is busy.
kStatus_FLEXIO_I2S_Error | FlexIO I2S error occurred.
kStatus_FLEXIO_I2S_QueueFull | FlexIO I2S transfer queue is full.

enum flexio_i2s_master_slave_t

Enumerator
kFLEXIO_I2S_Master | Master mode.
kFLEXIO_I2S_Slave | Slave mode.

enum _flexio_i2s_interrupt_enable

Enumerator
kFLEXIO_I2S_TxDataRegEmptyInterruptEnable | Transmit buffer empty interrupt enable.
kFLEXIO_I2S_RxDataRegFullInterruptEnable | Receive buffer full interrupt enable.

enum _flexio_i2s_status_flags

Enumerator
kFLEXIO_I2S_TxDataRegEmptyFlag | Transmit buffer empty flag.
kFLEXIO_I2S_RxDataRegFullFlag | Receive buffer full flag.

enum flexio_i2s_sample_rate_t

Enumerator
kFLEXIO_I2S_SampleRate8KHz | Sample rate 8000Hz.
kFLEXIO_I2S_SampleRate11025Hz | Sample rate 11025Hz.
kFLEXIO_I2S_SampleRate12KHz | Sample rate 12000Hz.
kFLEXIO_I2S_SampleRate16KHz | Sample rate 16000Hz.
kFLEXIO_I2S_SampleRate22050Hz | Sample rate 22050Hz.
kFLEXIO_I2S_SampleRate24KHz | Sample rate 24000Hz.
kFLEXIO_I2S_SampleRate32KHz | Sample rate 32000Hz.
kFLEXIO_I2S_SampleRate44100Hz | Sample rate 44100Hz.
kFLEXIO_I2S_SampleRate48KHz | Sample rate 48000Hz.
kFLEXIO_I2S_SampleRate96KHz | Sample rate 96000Hz.

enum flexio_i2s_word_width_t

Enumerator
kFLEXIO_I2S_WordWidth8bits | Audio data width 8 bits.
kFLEXIO_I2S_WordWidth16bits | Audio data width 16 bits.
kFLEXIO_I2S_WordWidth24bits | Audio data width 24 bits.
kFLEXIO_I2S_WordWidth32bits | Audio data width 32 bits.

## Function Documentation

void FLEXIO_I2S_Init | ( | FLEXIO_I2S_Type * | base,
|  | const flexio_i2s_config_t * | config
| ) |  |

This API configures FlexIO pins and shifter to I2S and configure FlexIO I2S with configuration structure. The configuration structure can be filled by the user, or be set with default values by FLEXIO_I2S_GetDefaultConfig().

Note
  This API should be called at the beginning of the application to use the FlexIO I2S driver, or any access to the FlexIO I2S module could cause hard fault because clock is not enabled.

Parameters

  base | FlexIO I2S base pointer
  config | FlexIO I2S configure structure.

void FLEXIO_I2S_GetDefaultConfig | ( | flexio_i2s_config_t * | config | ) |

The purpose of this API is to get the configuration structure initialized for use in FLEXIO_I2S_Init(). User may use the initialized structure unchanged in FLEXIO_I2S_Init(), or modify some fields of the structure before calling FLEXIO_I2S_Init().

Parameters

  config | pointer to master configuration structure

void FLEXIO_I2S_Deinit | ( | FLEXIO_I2S_Type * | base | ) |

Calling this API gates the FlexIO i2s clock. After calling this API, call the FLEXO_I2S_Init to use the FlexIO I2S module.

Parameters

  base | FlexIO I2S base pointer

static void FLEXIO_I2S_Enable | ( | FLEXIO_I2S_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | pointer to FLEXIO_I2S_Type
  enable | True to enable, false to disable.

uint32_t FLEXIO_I2S_GetStatusFlags | ( | FLEXIO_I2S_Type * | base | ) |

Parameters

  base | pointer to FLEXIO_I2S_Type structure

Returns
  Status flag, which are ORed by the enumerators in the _flexio_i2s_status_flags.

void FLEXIO_I2S_EnableInterrupts | ( | FLEXIO_I2S_Type * | base,
|  | uint32_t | mask
| ) |  |

This function enables the FlexIO UART interrupt.

Parameters

  base | pointer to FLEXIO_I2S_Type structure
  mask | interrupt source

void FLEXIO_I2S_DisableInterrupts | ( | FLEXIO_I2S_Type * | base,
|  | uint32_t | mask
| ) |  |

This function enables the FlexIO UART interrupt.

Parameters

  base | pointer to FLEXIO_I2S_Type structure
  mask | interrupt source

static void FLEXIO_I2S_TxEnableDMA | ( | FLEXIO_I2S_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | FlexIO I2S base pointer
  enable | True means enable DMA, false means disable DMA.

static void FLEXIO_I2S_RxEnableDMA | ( | FLEXIO_I2S_Type * | base,
|  | bool | enable
| ) |  |
| inline static

Parameters

  base | FlexIO I2S base pointer
  enable | True means enable DMA, false means disable DMA.

static uint32_t FLEXIO_I2S_TxGetDataRegisterAddress | ( | FLEXIO_I2S_Type * | base | ) |
| inline static

This function returns the I2S data register address, mainly used by DMA/eDMA.

Parameters

  base | pointer to FLEXIO_I2S_Type structure

Returns
  FlexIO i2s send data register address.

static uint32_t FLEXIO_I2S_RxGetDataRegisterAddress | ( | FLEXIO_I2S_Type * | base | ) |
| inline static

This function returns the I2S data register address, mainly used by DMA/eDMA.

Parameters

  base | pointer to FLEXIO_I2S_Type structure

Returns
  FlexIO i2s receive data register address.

void FLEXIO_I2S_MasterSetFormat | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_format_t * | format,
|  | uint32_t | srcClock_Hz
| ) |  |

Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data format to be transferred.

Parameters

  base | pointer to FLEXIO_I2S_Type structure
  format | Pointer to FlexIO I2S audio data format structure.
  srcClock_Hz | I2S master clock source frequency in Hz.

void FLEXIO_I2S_SlaveSetFormat | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_format_t * | format
| ) |  |

Audio format can be changed in run-time of FlexIO I2S. This function configures the sample rate and audio data format to be transferred.

Parameters

  base | pointer to FLEXIO_I2S_Type structure
  format | Pointer to FlexIO I2S audio data format structure.

void FLEXIO_I2S_WriteBlocking | ( | FLEXIO_I2S_Type * | base,
|  | uint8_t | bitWidth,
|  | uint8_t * | txData,
|  | size_t | size
| ) |  |

Note
  This function blocks via polling until data is ready to be sent.

Parameters

  base | FlexIO I2S base pointer.
  bitWidth | How many bits in a audio word, usually 8/16/24/32 bits.
  txData | Pointer to the data to be written.
  size | Bytes to be written.

static void FLEXIO_I2S_WriteData | ( | FLEXIO_I2S_Type * | base,
|  | uint8_t | bitWidth,
|  | uint32_t | data
| ) |  |
| inline static

Parameters

  base | FlexIO I2S base pointer.
  bitWidth | How many bits in a audio word, usually 8/16/24/32 bits.
  data | Data to be written.

void FLEXIO_I2S_ReadBlocking | ( | FLEXIO_I2S_Type * | base,
|  | uint8_t | bitWidth,
|  | uint8_t * | rxData,
|  | size_t | size
| ) |  |

Note
  This function blocks via polling until data is ready to be sent.

Parameters

  base | FlexIO I2S base pointer
  bitWidth | How many bits in a audio word, usually 8/16/24/32 bits.
  rxData | Pointer to the data to be read.
  size | Bytes to be read.

static uint32_t FLEXIO_I2S_ReadData | ( | FLEXIO_I2S_Type * | base | ) |
| inline static

Parameters

  base | FlexIO I2S base pointer

Returns
  Data read from data register.

void FLEXIO_I2S_TransferTxCreateHandle | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | flexio_i2s_callback_t | callback,
|  | void * | userData
| ) |  |

This function initializes the FlexIO I2S handle which can be used for other FlexIO I2S transactional APIs. Call this API once to get the initialized handle.

Parameters

  base | pointer to FLEXIO_I2S_Type structure
  handle | pointer to flexio_i2s_handle_t structure to store the transfer state.
  callback | FlexIO I2S callback function, which is called while finished a block.
  userData | User parameter for the FlexIO I2S callback.

void FLEXIO_I2S_TransferSetFormat | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | flexio_i2s_format_t * | format,
|  | uint32_t | srcClock_Hz
| ) |  |

Audio format can be changed in run-time of FlexIO i2s. This function configures the sample rate and audio data format to be transferred.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | FlexIO I2S handle pointer.
  format | Pointer to audio data format structure.
  srcClock_Hz | FlexIO I2S bit clock source frequency in Hz. This parameter should be 0 while in slave mode.

void FLEXIO_I2S_TransferRxCreateHandle | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | flexio_i2s_callback_t | callback,
|  | void * | userData
| ) |  |

This function initializes the FlexIO I2S handle which can be used for other FlexIO I2S transactional APIs. Usually, user only need to call this API once to get the initialized handle.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure to store the transfer state.
  callback | FlexIO I2S callback function, which is called while finished a block.
  userData | User parameter for the FlexIO I2S callback.

status_t FLEXIO_I2S_TransferSendNonBlocking | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | flexio_i2s_transfer_t * | xfer
| ) |  |

Note
  Calling the API returns immediately after transfer initiates. Call FLEXIO_I2S_GetRemainingBytes to poll the transfer status and check whether the transfer is finished. If the return status is 0, the transfer is finished.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state
  xfer | pointer to flexio_i2s_transfer_t structure

Return values

  kStatus_Success | Successfully start the data transmission.
  kStatus_FLEXIO_I2S_TxBusy | Previous transmission still not finished, data not all written to TX register yet.
  kStatus_InvalidArgument | The input parameter is invalid.

status_t FLEXIO_I2S_TransferReceiveNonBlocking | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | flexio_i2s_transfer_t * | xfer
| ) |  |

Note
  The API returns immediately after transfer initiates. Call FLEXIO_I2S_GetRemainingBytes to poll the transfer status to check whether the transfer is finished. If the return status is 0, the transfer is finished.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state
  xfer | pointer to flexio_i2s_transfer_t structure

Return values

  kStatus_Success | Successfully start the data receive.
  kStatus_FLEXIO_I2S_RxBusy | Previous receive still not finished.
  kStatus_InvalidArgument | The input parameter is invalid.

void FLEXIO_I2S_TransferAbortSend | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle
| ) |  |

Note
  This API can be called at any time when interrupt non-blocking transfer initiates to abort the transfer in a early time.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state

void FLEXIO_I2S_TransferAbortReceive | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle
| ) |  |

Note
  This API can be called at any time when interrupt non-blocking transfer initiates to abort the transfer in a early time.

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state

status_t FLEXIO_I2S_TransferGetSendCount | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | size_t * | count
| ) |  |

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state
  count | Bytes sent.

Return values

  kStatus_Success | Succeed get the transfer count.
  kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress.

status_t FLEXIO_I2S_TransferGetReceiveCount | ( | FLEXIO_I2S_Type * | base,
|  | flexio_i2s_handle_t * | handle,
|  | size_t * | count
| ) |  |

Parameters

  base | pointer to FLEXIO_I2S_Type structure.
  handle | pointer to flexio_i2s_handle_t structure which stores the transfer state

Returns
  count Bytes received.

Return values

  kStatus_Success | Succeed get the transfer count.
  kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress.

void FLEXIO_I2S_TransferTxHandleIRQ | ( | void * | i2sBase,
|  | void * | i2sHandle
| ) |  |

Parameters

  i2sBase | pointer to FLEXIO_I2S_Type structure.
  i2sHandle | pointer to flexio_i2s_handle_t structure

void FLEXIO_I2S_TransferRxHandleIRQ | ( | void * | i2sBase,
|  | void * | i2sHandle
| ) |  |

Parameters

  i2sBase | pointer to FLEXIO_I2S_Type structure.
  i2sHandle | pointer to flexio_i2s_handle_t structure