RTEMS 6.1-rc6
Loading...
Searching...
No Matches
Data Structures
SAI Driver

Data Structures

struct  _sai_config
 SAI user configuration structure. More...
 
struct  _sai_transfer_format
 sai transfer format More...
 
struct  _sai_bit_clock
 sai bit clock configurations More...
 
struct  _sai_frame_sync
 sai frame sync configurations More...
 
struct  _sai_serial_data
 sai serial data configurations More...
 
struct  _sai_transceiver
 sai transceiver configurations More...
 
struct  _sai_transfer
 SAI transfer structure. More...
 
struct  _sai_handle
 SAI handle structure. More...
 

Driver version

enum  {
  kStatus_SAI_TxBusy = MAKE_STATUS(kStatusGroup_SAI, 0) , kStatus_SAI_RxBusy = MAKE_STATUS(kStatusGroup_SAI, 1) , kStatus_SAI_TxError = MAKE_STATUS(kStatusGroup_SAI, 2) , kStatus_SAI_RxError = MAKE_STATUS(kStatusGroup_SAI, 3) ,
  kStatus_SAI_QueueFull = MAKE_STATUS(kStatusGroup_SAI, 4) , kStatus_SAI_TxIdle = MAKE_STATUS(kStatusGroup_SAI, 5) , kStatus_SAI_RxIdle = MAKE_STATUS(kStatusGroup_SAI, 6)
}
 _sai_status_t, SAI return status. More...
 
enum  {
  kSAI_Channel0Mask = 1 << 0U , kSAI_Channel1Mask = 1 << 1U , kSAI_Channel2Mask = 1 << 2U , kSAI_Channel3Mask = 1 << 3U ,
  kSAI_Channel4Mask = 1 << 4U , kSAI_Channel5Mask = 1 << 5U , kSAI_Channel6Mask = 1 << 6U , kSAI_Channel7Mask = 1 << 7U
}
 _sai_channel_mask,.sai channel mask value, actual channel numbers is depend soc specific More...
 
enum  _sai_protocol {
  kSAI_BusLeftJustified = 0x0U , kSAI_BusRightJustified , kSAI_BusI2S , kSAI_BusPCMA ,
  kSAI_BusPCMB
}
 Define the SAI bus type. More...
 
enum  _sai_master_slave { kSAI_Master = 0x0U , kSAI_Slave = 0x1U , kSAI_Bclk_Master_FrameSync_Slave = 0x2U , kSAI_Bclk_Slave_FrameSync_Master = 0x3U }
 Master or slave mode. More...
 
enum  _sai_mono_stereo { kSAI_Stereo = 0x0U , kSAI_MonoRight , kSAI_MonoLeft }
 Mono or stereo audio format. More...
 
enum  _sai_data_order { kSAI_DataLSB = 0x0U , kSAI_DataMSB }
 SAI data order, MSB or LSB. More...
 
enum  _sai_clock_polarity { kSAI_PolarityActiveHigh = 0x0U , kSAI_PolarityActiveLow = 0x1U , kSAI_SampleOnFallingEdge = 0x0U , kSAI_SampleOnRisingEdge = 0x1U }
 SAI clock polarity, active high or low. More...
 
enum  _sai_sync_mode { kSAI_ModeAsync = 0x0U , kSAI_ModeSync }
 Synchronous or asynchronous mode. More...
 
enum  _sai_mclk_source { kSAI_MclkSourceSysclk = 0x0U , kSAI_MclkSourceSelect1 , kSAI_MclkSourceSelect2 , kSAI_MclkSourceSelect3 }
 Mater clock source. More...
 
enum  _sai_bclk_source {
  kSAI_BclkSourceBusclk = 0x0U , kSAI_BclkSourceMclkOption1 = 0x1U , kSAI_BclkSourceMclkOption2 = 0x2U , kSAI_BclkSourceMclkOption3 = 0x3U ,
  kSAI_BclkSourceMclkDiv = 0x1U , kSAI_BclkSourceOtherSai0 = 0x2U , kSAI_BclkSourceOtherSai1 = 0x3U
}
 Bit clock source. More...
 
enum  { kSAI_WordStartInterruptEnable , kSAI_SyncErrorInterruptEnable = I2S_TCSR_SEIE_MASK , kSAI_FIFOWarningInterruptEnable = I2S_TCSR_FWIE_MASK , kSAI_FIFOErrorInterruptEnable = I2S_TCSR_FEIE_MASK }
 _sai_interrupt_enable_t, The SAI interrupt enable flag More...
 
enum  { kSAI_FIFOWarningDMAEnable = I2S_TCSR_FWDE_MASK }
 _sai_dma_enable_t, The DMA request sources More...
 
enum  { kSAI_WordStartFlag = I2S_TCSR_WSF_MASK , kSAI_SyncErrorFlag = I2S_TCSR_SEF_MASK , kSAI_FIFOErrorFlag = I2S_TCSR_FEF_MASK , kSAI_FIFOWarningFlag = I2S_TCSR_FWF_MASK }
 _sai_flags, The SAI status flag More...
 
enum  _sai_reset_type { kSAI_ResetTypeSoftware = I2S_TCSR_SR_MASK , kSAI_ResetTypeFIFO = I2S_TCSR_FR_MASK , kSAI_ResetAll = I2S_TCSR_SR_MASK | I2S_TCSR_FR_MASK }
 The reset type. More...
 
enum  _sai_sample_rate {
  kSAI_SampleRate8KHz = 8000U , kSAI_SampleRate11025Hz = 11025U , kSAI_SampleRate12KHz = 12000U , kSAI_SampleRate16KHz = 16000U ,
  kSAI_SampleRate22050Hz = 22050U , kSAI_SampleRate24KHz = 24000U , kSAI_SampleRate32KHz = 32000U , kSAI_SampleRate44100Hz = 44100U ,
  kSAI_SampleRate48KHz = 48000U , kSAI_SampleRate96KHz = 96000U , kSAI_SampleRate192KHz = 192000U , kSAI_SampleRate384KHz = 384000U
}
 Audio sample rate. More...
 
enum  _sai_word_width { kSAI_WordWidth8bits = 8U , kSAI_WordWidth16bits = 16U , kSAI_WordWidth24bits = 24U , kSAI_WordWidth32bits = 32U }
 Audio word width. More...
 
enum  _sai_transceiver_type { kSAI_Transmitter = 0U , kSAI_Receiver = 1U }
 sai transceiver type More...
 
enum  _sai_frame_sync_len { kSAI_FrameSyncLenOneBitClk = 0U , kSAI_FrameSyncLenPerWordWidth = 1U }
 sai frame sync len More...
 
typedef enum _sai_protocol sai_protocol_t
 Define the SAI bus type.
 
typedef enum _sai_master_slave sai_master_slave_t
 Master or slave mode.
 
typedef enum _sai_mono_stereo sai_mono_stereo_t
 Mono or stereo audio format.
 
typedef enum _sai_data_order sai_data_order_t
 SAI data order, MSB or LSB.
 
typedef enum _sai_clock_polarity sai_clock_polarity_t
 SAI clock polarity, active high or low.
 
typedef enum _sai_sync_mode sai_sync_mode_t
 Synchronous or asynchronous mode.
 
typedef enum _sai_mclk_source sai_mclk_source_t
 Mater clock source.
 
typedef enum _sai_bclk_source sai_bclk_source_t
 Bit clock source.
 
typedef enum _sai_reset_type sai_reset_type_t
 The reset type.
 
typedef struct _sai_config sai_config_t
 SAI user configuration structure.
 
typedef enum _sai_sample_rate sai_sample_rate_t
 Audio sample rate.
 
typedef enum _sai_word_width sai_word_width_t
 Audio word width.
 
typedef enum _sai_transceiver_type sai_transceiver_type_t
 sai transceiver type
 
typedef enum _sai_frame_sync_len sai_frame_sync_len_t
 sai frame sync len
 
typedef struct _sai_transfer_format sai_transfer_format_t
 sai transfer format
 
typedef struct _sai_bit_clock sai_bit_clock_t
 sai bit clock configurations
 
typedef struct _sai_frame_sync sai_frame_sync_t
 sai frame sync configurations
 
typedef struct _sai_serial_data sai_serial_data_t
 sai serial data configurations
 
typedef struct _sai_transceiver sai_transceiver_t
 sai transceiver configurations
 
typedef struct _sai_transfer sai_transfer_t
 SAI transfer structure.
 
typedef struct _sai_handle sai_handle_t
 
typedef void(* sai_transfer_callback_t) (I2S_Type *base, sai_handle_t *handle, status_t status, void *userData)
 SAI transfer callback prototype.
 
#define FSL_SAI_DRIVER_VERSION   (MAKE_VERSION(2, 3, 8))
 
#define SAI_XFER_QUEUE_SIZE   (4U)
 SAI transfer queue size, user can refine it according to use case.
 
#define FSL_SAI_HAS_FIFO_EXTEND_FEATURE   0
 sai fifo feature
 

Initialization and deinitialization

void SAI_TxInit (I2S_Type *base, const sai_config_t *config)
 Initializes the SAI Tx peripheral.
 
void SAI_RxInit (I2S_Type *base, const sai_config_t *config)
 Initializes the SAI Rx peripheral.
 
void SAI_TxGetDefaultConfig (sai_config_t *config)
 Sets the SAI Tx configuration structure to default values.
 
void SAI_RxGetDefaultConfig (sai_config_t *config)
 Sets the SAI Rx configuration structure to default values.
 
void SAI_Init (I2S_Type *base)
 Initializes the SAI peripheral.
 
void SAI_Deinit (I2S_Type *base)
 De-initializes the SAI peripheral.
 
void SAI_TxReset (I2S_Type *base)
 Resets the SAI Tx.
 
void SAI_RxReset (I2S_Type *base)
 Resets the SAI Rx.
 
void SAI_TxEnable (I2S_Type *base, bool enable)
 Enables/disables the SAI Tx.
 
void SAI_RxEnable (I2S_Type *base, bool enable)
 Enables/disables the SAI Rx.
 
void SAI_TxSetBitClockRate (I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
 Transmitter bit clock rate configurations.
 
void SAI_RxSetBitClockRate (I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
 Receiver bit clock rate configurations.
 
void SAI_TxSetBitclockConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
 Transmitter Bit clock configurations.
 
void SAI_RxSetBitclockConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
 Receiver Bit clock configurations.
 
void SAI_TxSetFrameSyncConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
 SAI transmitter Frame sync configurations.
 
void SAI_RxSetFrameSyncConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
 SAI receiver Frame sync configurations.
 
void SAI_TxSetSerialDataConfig (I2S_Type *base, sai_serial_data_t *config)
 SAI transmitter Serial data configurations.
 
void SAI_RxSetSerialDataConfig (I2S_Type *base, sai_serial_data_t *config)
 SAI receiver Serial data configurations.
 
void SAI_TxSetConfig (I2S_Type *base, sai_transceiver_t *config)
 SAI transmitter configurations.
 
void SAI_RxSetConfig (I2S_Type *base, sai_transceiver_t *config)
 SAI receiver configurations.
 
void SAI_GetClassicI2SConfig (sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
 Get classic I2S mode configurations.
 
void SAI_GetLeftJustifiedConfig (sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
 Get left justified mode configurations.
 
void SAI_GetRightJustifiedConfig (sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
 Get right justified mode configurations.
 
void SAI_GetTDMConfig (sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, uint32_t dataWordNum, uint32_t saiChannelMask)
 Get TDM mode configurations.
 
void SAI_GetDSPConfig (sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
 Get DSP mode configurations.
 

Status

void SAI_TxSoftwareReset (I2S_Type *base, sai_reset_type_t resetType)
 Do software reset or FIFO reset .
 
void SAI_RxSoftwareReset (I2S_Type *base, sai_reset_type_t resetType)
 Do software reset or FIFO reset .
 
void SAI_TxSetChannelFIFOMask (I2S_Type *base, uint8_t mask)
 Set the Tx channel FIFO enable mask.
 
void SAI_RxSetChannelFIFOMask (I2S_Type *base, uint8_t mask)
 Set the Rx channel FIFO enable mask.
 
void SAI_TxSetDataOrder (I2S_Type *base, sai_data_order_t order)
 Set the Tx data order.
 
void SAI_RxSetDataOrder (I2S_Type *base, sai_data_order_t order)
 Set the Rx data order.
 
void SAI_TxSetBitClockPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Tx data order.
 
void SAI_RxSetBitClockPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Rx data order.
 
void SAI_TxSetFrameSyncPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Tx data order.
 
void SAI_RxSetFrameSyncPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Rx data order.
 

Bus Operations

void SAI_TxSetFormat (I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Tx audio format.
 
void SAI_RxSetFormat (I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Rx audio format.
 
void SAI_WriteBlocking (I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Sends data using a blocking method.
 
void SAI_WriteMultiChannelBlocking (I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Sends data to multi channel using a blocking method.
 
void SAI_ReadBlocking (I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Receives data using a blocking method.
 
void SAI_ReadMultiChannelBlocking (I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Receives multi channel data using a blocking method.
 

Transactional

void SAI_TransferTxCreateHandle (I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
 Initializes the SAI Tx handle.
 
void SAI_TransferRxCreateHandle (I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
 Initializes the SAI Rx handle.
 
void SAI_TransferTxSetConfig (I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
 SAI transmitter transfer configurations.
 
void SAI_TransferRxSetConfig (I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
 SAI receiver transfer configurations.
 
status_t SAI_TransferTxSetFormat (I2S_Type *base, sai_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Tx audio format.
 
status_t SAI_TransferRxSetFormat (I2S_Type *base, sai_handle_t *handle, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Rx audio format.
 
status_t SAI_TransferSendNonBlocking (I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
 Performs an interrupt non-blocking send transfer on SAI.
 
status_t SAI_TransferReceiveNonBlocking (I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
 Performs an interrupt non-blocking receive transfer on SAI.
 
status_t SAI_TransferGetSendCount (I2S_Type *base, sai_handle_t *handle, size_t *count)
 Gets a set byte count.
 
status_t SAI_TransferGetReceiveCount (I2S_Type *base, sai_handle_t *handle, size_t *count)
 Gets a received byte count.
 
void SAI_TransferAbortSend (I2S_Type *base, sai_handle_t *handle)
 Aborts the current send.
 
void SAI_TransferAbortReceive (I2S_Type *base, sai_handle_t *handle)
 Aborts the current IRQ receive.
 
void SAI_TransferTerminateSend (I2S_Type *base, sai_handle_t *handle)
 Terminate all SAI send.
 
void SAI_TransferTerminateReceive (I2S_Type *base, sai_handle_t *handle)
 Terminate all SAI receive.
 
void SAI_TransferTxHandleIRQ (I2S_Type *base, sai_handle_t *handle)
 Tx interrupt handler.
 
void SAI_TransferRxHandleIRQ (I2S_Type *base, sai_handle_t *handle)
 Tx interrupt handler.
 

Detailed Description

Macro Definition Documentation

◆ FSL_SAI_DRIVER_VERSION

#define FSL_SAI_DRIVER_VERSION   (MAKE_VERSION(2, 3, 8))

Version 2.3.8

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

_sai_status_t, SAI return status.

Enumerator
kStatus_SAI_TxBusy 

SAI Tx is busy.

kStatus_SAI_RxBusy 

SAI Rx is busy.

kStatus_SAI_TxError 

SAI Tx FIFO error.

kStatus_SAI_RxError 

SAI Rx FIFO error.

kStatus_SAI_QueueFull 

SAI transfer queue is full.

kStatus_SAI_TxIdle 

SAI Tx is idle

kStatus_SAI_RxIdle 

SAI Rx is idle

◆ anonymous enum

anonymous enum

_sai_channel_mask,.sai channel mask value, actual channel numbers is depend soc specific

Enumerator
kSAI_Channel0Mask 

channel 0 mask value

kSAI_Channel1Mask 

channel 1 mask value

kSAI_Channel2Mask 

channel 2 mask value

kSAI_Channel3Mask 

channel 3 mask value

kSAI_Channel4Mask 

channel 4 mask value

kSAI_Channel5Mask 

channel 5 mask value

kSAI_Channel6Mask 

channel 6 mask value

kSAI_Channel7Mask 

channel 7 mask value

◆ anonymous enum

anonymous enum

_sai_interrupt_enable_t, The SAI interrupt enable flag

Enumerator
kSAI_WordStartInterruptEnable 

Word start flag, means the first word in a frame detected

kSAI_SyncErrorInterruptEnable 

Sync error flag, means the sync error is detected

kSAI_FIFOWarningInterruptEnable 

FIFO warning flag, means the FIFO is empty

kSAI_FIFOErrorInterruptEnable 

FIFO error flag

◆ anonymous enum

anonymous enum

_sai_dma_enable_t, The DMA request sources

Enumerator
kSAI_FIFOWarningDMAEnable 

FIFO warning caused by the DMA request

◆ anonymous enum

anonymous enum

_sai_flags, The SAI status flag

Enumerator
kSAI_WordStartFlag 

Word start flag, means the first word in a frame detected

kSAI_SyncErrorFlag 

Sync error flag, means the sync error is detected

kSAI_FIFOErrorFlag 

FIFO error flag

kSAI_FIFOWarningFlag 

FIFO warning flag

◆ _sai_bclk_source

Bit clock source.

Enumerator
kSAI_BclkSourceBusclk 

Bit clock using bus clock

kSAI_BclkSourceMclkOption1 

Bit clock MCLK option 1

kSAI_BclkSourceMclkOption2 

Bit clock MCLK option2

kSAI_BclkSourceMclkOption3 

Bit clock MCLK option3

kSAI_BclkSourceMclkDiv 

Bit clock using master clock divider

kSAI_BclkSourceOtherSai0 

Bit clock from other SAI device

kSAI_BclkSourceOtherSai1 

Bit clock from other SAI device

◆ _sai_clock_polarity

SAI clock polarity, active high or low.

Enumerator
kSAI_PolarityActiveHigh 

Drive outputs on rising edge

kSAI_PolarityActiveLow 

Drive outputs on falling edge

kSAI_SampleOnFallingEdge 

Sample inputs on falling edge

kSAI_SampleOnRisingEdge 

Sample inputs on rising edge

◆ _sai_data_order

SAI data order, MSB or LSB.

Enumerator
kSAI_DataLSB 

LSB bit transferred first

kSAI_DataMSB 

MSB bit transferred first

◆ _sai_frame_sync_len

sai frame sync len

Enumerator
kSAI_FrameSyncLenOneBitClk 

1 bit clock frame sync len for DSP mode

kSAI_FrameSyncLenPerWordWidth 

Frame sync length decided by word width

◆ _sai_master_slave

Master or slave mode.

Enumerator
kSAI_Master 

Master mode include bclk and frame sync

kSAI_Slave 

Slave mode include bclk and frame sync

kSAI_Bclk_Master_FrameSync_Slave 

bclk in master mode, frame sync in slave mode

kSAI_Bclk_Slave_FrameSync_Master 

bclk in slave mode, frame sync in master mode

◆ _sai_mclk_source

Mater clock source.

Enumerator
kSAI_MclkSourceSysclk 

Master clock from the system clock

kSAI_MclkSourceSelect1 

Master clock from source 1

kSAI_MclkSourceSelect2 

Master clock from source 2

kSAI_MclkSourceSelect3 

Master clock from source 3

◆ _sai_mono_stereo

Mono or stereo audio format.

Enumerator
kSAI_Stereo 

Stereo sound.

kSAI_MonoRight 

Only Right channel have sound.

kSAI_MonoLeft 

Only left channel have sound.

◆ _sai_protocol

Define the SAI bus type.

Enumerator
kSAI_BusLeftJustified 

Uses left justified format.

kSAI_BusRightJustified 

Uses right justified format.

kSAI_BusI2S 

Uses I2S format.

kSAI_BusPCMA 

Uses I2S PCM A format.

kSAI_BusPCMB 

Uses I2S PCM B format.

◆ _sai_reset_type

The reset type.

Enumerator
kSAI_ResetTypeSoftware 

Software reset, reset the logic state

kSAI_ResetTypeFIFO 

FIFO reset, reset the FIFO read and write pointer

kSAI_ResetAll 

All reset.

◆ _sai_sample_rate

Audio sample rate.

Enumerator
kSAI_SampleRate8KHz 

Sample rate 8000 Hz

kSAI_SampleRate11025Hz 

Sample rate 11025 Hz

kSAI_SampleRate12KHz 

Sample rate 12000 Hz

kSAI_SampleRate16KHz 

Sample rate 16000 Hz

kSAI_SampleRate22050Hz 

Sample rate 22050 Hz

kSAI_SampleRate24KHz 

Sample rate 24000 Hz

kSAI_SampleRate32KHz 

Sample rate 32000 Hz

kSAI_SampleRate44100Hz 

Sample rate 44100 Hz

kSAI_SampleRate48KHz 

Sample rate 48000 Hz

kSAI_SampleRate96KHz 

Sample rate 96000 Hz

kSAI_SampleRate192KHz 

Sample rate 192000 Hz

kSAI_SampleRate384KHz 

Sample rate 384000 Hz

◆ _sai_sync_mode

Synchronous or asynchronous mode.

Enumerator
kSAI_ModeAsync 

Asynchronous mode

kSAI_ModeSync 

Synchronous mode (with receiver or transmit)

◆ _sai_transceiver_type

sai transceiver type

Enumerator
kSAI_Transmitter 

sai transmitter

kSAI_Receiver 

sai receiver

◆ _sai_word_width

Audio word width.

Enumerator
kSAI_WordWidth8bits 

Audio data width 8 bits

kSAI_WordWidth16bits 

Audio data width 16 bits

kSAI_WordWidth24bits 

Audio data width 24 bits

kSAI_WordWidth32bits 

Audio data width 32 bits

Function Documentation

◆ SAI_Deinit()

void SAI_Deinit ( I2S_Type base)

De-initializes the SAI peripheral.

This API gates the SAI clock. The SAI module can't operate unless SAI_TxInit or SAI_RxInit is called to enable the clock.

Parameters
baseSAI base pointer.

brief De-initializes the SAI peripheral.

This API gates the SAI clock. The SAI module can't operate unless SAI_TxInit or SAI_RxInit is called to enable the clock.

param base SAI base pointer

◆ SAI_GetClassicI2SConfig()

void SAI_GetClassicI2SConfig ( sai_transceiver_t config,
sai_word_width_t  bitWidth,
sai_mono_stereo_t  mode,
uint32_t  saiChannelMask 
)

Get classic I2S mode configurations.

Parameters
configtransceiver configurations.
bitWidthaudio data bitWidth.
modeaudio data channel.
saiChannelMaskmask value of the channel to be enable.

brief Get classic I2S mode configurations.

param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable.

◆ SAI_GetDSPConfig()

void SAI_GetDSPConfig ( sai_transceiver_t config,
sai_frame_sync_len_t  frameSyncWidth,
sai_word_width_t  bitWidth,
sai_mono_stereo_t  mode,
uint32_t  saiChannelMask 
)

Get DSP mode configurations.

Note
DSP mode is also called PCM mode which support MODE A and MODE B, DSP/PCM MODE A configuration flow. RX is similiar but uses SAI_RxSetConfig instead of SAI_TxSetConfig:
config->frameSync.frameSyncEarly = true;
void SAI_TxSetConfig(I2S_Type *base, sai_transceiver_t *config)
SAI transmitter configurations.
Definition: fsl_sai.c:1428
void SAI_GetDSPConfig(sai_transceiver_t *config, sai_frame_sync_len_t frameSyncWidth, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
Get DSP mode configurations.
Definition: fsl_sai.c:1773
@ kSAI_Stereo
Definition: fsl_sai.h:75
@ kSAI_FrameSyncLenOneBitClk
Definition: fsl_sai.h:265
Definition: deflate.c:114

DSP/PCM MODE B configuration flow for TX. RX is similiar but uses SAI_RxSetConfig instead of SAI_TxSetConfig:

Parameters
configtransceiver configurations.
frameSyncWidthlength of frame sync.
bitWidthaudio data bitWidth.
modeaudio data channel.
saiChannelMaskmask value of the channel to enable.

brief Get DSP mode configurations.

note DSP mode is also called PCM mode which support MODE A and MODE B, DSP/PCM MODE A configuration flow. RX is similiar but uses SAI_RxSetConfig instead of SAI_TxSetConfig: code SAI_GetDSPConfig(config, kSAI_FrameSyncLenOneBitClk, bitWidth, kSAI_Stereo, channelMask) config->frameSync.frameSyncEarly = true; SAI_TxSetConfig(base, config) endcode

DSP/PCM MODE B configuration flow for TX. RX is similiar but uses SAI_RxSetConfig instead of SAI_TxSetConfig: code SAI_GetDSPConfig(config, kSAI_FrameSyncLenOneBitClk, bitWidth, kSAI_Stereo, channelMask) SAI_TxSetConfig(base, config) endcode

param config transceiver configurations. param frameSyncWidth length of frame sync. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask mask value of the channel to enable.

◆ SAI_GetLeftJustifiedConfig()

void SAI_GetLeftJustifiedConfig ( sai_transceiver_t config,
sai_word_width_t  bitWidth,
sai_mono_stereo_t  mode,
uint32_t  saiChannelMask 
)

Get left justified mode configurations.

Parameters
configtransceiver configurations.
bitWidthaudio data bitWidth.
modeaudio data channel.
saiChannelMaskmask value of the channel to be enable.

brief Get left justified mode configurations.

param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable.

◆ SAI_GetRightJustifiedConfig()

void SAI_GetRightJustifiedConfig ( sai_transceiver_t config,
sai_word_width_t  bitWidth,
sai_mono_stereo_t  mode,
uint32_t  saiChannelMask 
)

Get right justified mode configurations.

Parameters
configtransceiver configurations.
bitWidthaudio data bitWidth.
modeaudio data channel.
saiChannelMaskmask value of the channel to be enable.

brief Get right justified mode configurations.

param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable.

◆ SAI_GetTDMConfig()

void SAI_GetTDMConfig ( sai_transceiver_t config,
sai_frame_sync_len_t  frameSyncWidth,
sai_word_width_t  bitWidth,
uint32_t  dataWordNum,
uint32_t  saiChannelMask 
)

Get TDM mode configurations.

Parameters
configtransceiver configurations.
frameSyncWidthlength of frame sync.
bitWidthaudio data word width.
dataWordNumword number in one frame.
saiChannelMaskmask value of the channel to be enable.

brief Get TDM mode configurations.

param config transceiver configurations. param bitWidth audio data bitWidth. param mode audio data channel. param saiChannelMask channel mask value to enable.

◆ SAI_Init()

void SAI_Init ( I2S_Type base)

Initializes the SAI peripheral.

This API gates the SAI clock. The SAI module can't operate unless SAI_Init is called to enable the clock.

Parameters
baseSAI base pointer.

brief Initializes the SAI peripheral.

This API gates the SAI clock. The SAI module can't operate unless SAI_Init is called to enable the clock.

param base SAI base pointer

◆ SAI_ReadBlocking()

void SAI_ReadBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)

Receives data using a blocking method.

Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSAI base pointer.
channelData channel used.
bitWidthHow many bits in an audio word; usually 8/16/24/32 bits.
bufferPointer to the data to be read.
sizeBytes to be read.

brief Receives data using a blocking method.

note This function blocks by polling until data is ready to be sent.

param base SAI base pointer. param channel Data channel used. param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. param buffer Pointer to the data to be read. param size Bytes to be read.

◆ SAI_ReadMultiChannelBlocking()

void SAI_ReadMultiChannelBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  channelMask,
uint32_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)

Receives multi channel data using a blocking method.

Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSAI base pointer.
channelData channel used.
channelMaskchannel mask.
bitWidthHow many bits in an audio word; usually 8/16/24/32 bits.
bufferPointer to the data to be read.
sizeBytes to be read.

brief Receives multi channel data using a blocking method.

note This function blocks by polling until data is ready to be sent.

param base SAI base pointer. param channel Data channel used. param channelMask channel mask. param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. param buffer Pointer to the data to be read. param size Bytes to be read.

◆ SAI_RxEnable()

void SAI_RxEnable ( I2S_Type base,
bool  enable 
)

Enables/disables the SAI Rx.

Parameters
baseSAI base pointer.
enableTrue means enable SAI Rx, false means disable.

brief Enables/disables the SAI Rx.

param base SAI base pointer param enable True means enable SAI Rx, false means disable.

◆ SAI_RxGetDefaultConfig()

void SAI_RxGetDefaultConfig ( sai_config_t config)

Sets the SAI Rx configuration structure to default values.

Deprecated:
Do not use this function. It has been superceded by SAI_GetClassicI2SConfig, SAI_GetLeftJustifiedConfig , SAI_GetRightJustifiedConfig, SAI_GetDSPConfig, SAI_GetTDMConfig

This API initializes the configuration structure for use in SAI_RxConfig(). The initialized structure can remain unchanged in SAI_RxConfig() or it can be modified before calling SAI_RxConfig(). This is an example.

void SAI_RxGetDefaultConfig(sai_config_t *config)
Sets the SAI Rx configuration structure to default values.
Definition: fsl_sai.c:731
SAI user configuration structure.
Definition: fsl_sai.h:189
Parameters
configpointer to master configuration structure

brief Sets the SAI Rx configuration structure to default values.

deprecated Do not use this function. It has been superceded by SAI_GetClassicI2SConfig,SAI_GetLeftJustifiedConfig,SAI_GetRightJustifiedConfig,SAI_GetDSPConfig,SAI_GetTDMConfig

This API initializes the configuration structure for use in SAI_RxConfig(). The initialized structure can remain unchanged in SAI_RxConfig() or it can be modified before calling SAI_RxConfig(). This is an example. code sai_config_t config; SAI_RxGetDefaultConfig(&config); endcode

param config pointer to master configuration structure

◆ SAI_RxInit()

void SAI_RxInit ( I2S_Type base,
const sai_config_t config 
)

Initializes the SAI Rx peripheral.

Deprecated:
Do not use this function. It has been superceded by SAI_Init

Ungates the SAI clock, resets the module, and configures the SAI Rx with a configuration structure. The configuration structure can be custom filled or set with default values by SAI_RxGetDefaultConfig().

Note
This API should be called at the beginning of the application to use the SAI driver. Otherwise, accessing the SAI module can cause a hard fault because the clock is not enabled.
Parameters
baseSAI base pointer
configSAI configuration structure.

brief Initializes the SAI Rx peripheral.

deprecated Do not use this function. It has been superceded by SAI_Init

Ungates the SAI clock, resets the module, and configures the SAI Rx with a configuration structure. The configuration structure can be custom filled or set with default values by SAI_RxGetDefaultConfig().

note This API should be called at the beginning of the application to use the SAI driver. Otherwise, accessing the SAI module can cause a hard fault because the clock is not enabled.

param base SAI base pointer param config SAI configuration structure.

◆ SAI_RxReset()

void SAI_RxReset ( I2S_Type base)

Resets the SAI Rx.

This function enables the software reset and FIFO reset of SAI Rx. After reset, clear the reset bit.

Parameters
baseSAI base pointer

brief Resets the SAI Rx.

This function enables the software reset and FIFO reset of SAI Rx. After reset, clear the reset bit.

param base SAI base pointer

◆ SAI_RxSetBitclockConfig()

void SAI_RxSetBitclockConfig ( I2S_Type base,
sai_master_slave_t  masterSlave,
sai_bit_clock_t config 
)

Receiver Bit clock configurations.

Parameters
baseSAI base pointer.
masterSlavemaster or slave.
configbit clock other configurations, can be NULL in slave mode.

brief Receiver Bit clock configurations.

param base SAI base pointer. param masterSlave master or slave. param config bit clock other configurations, can be NULL in slave mode.

◆ SAI_RxSetBitClockPolarity()

void SAI_RxSetBitClockPolarity ( I2S_Type base,
sai_clock_polarity_t  polarity 
)

Set the Rx data order.

Parameters
baseSAI base pointer
polarity

brief Set the Rx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_RxSetBitClockRate()

void SAI_RxSetBitClockRate ( I2S_Type base,
uint32_t  sourceClockHz,
uint32_t  sampleRate,
uint32_t  bitWidth,
uint32_t  channelNumbers 
)

Receiver bit clock rate configurations.

Parameters
baseSAI base pointer.
sourceClockHzBit clock source frequency.
sampleRateAudio data sample rate.
bitWidthAudio data bitWidth.
channelNumbersAudio channel numbers.

brief Receiver bit clock rate configurations.

param base SAI base pointer. param sourceClockHz, bit clock source frequency. param sampleRate audio data sample rate. param bitWidth, audio data bitWidth. param channelNumbers, audio channel numbers.

◆ SAI_RxSetChannelFIFOMask()

void SAI_RxSetChannelFIFOMask ( I2S_Type base,
uint8_t  mask 
)

Set the Rx channel FIFO enable mask.

Parameters
baseSAI base pointer
maskChannel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled.

brief Set the Rx channel FIFO enable mask.

param base SAI base pointer param mask Channel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled.

◆ SAI_RxSetConfig()

void SAI_RxSetConfig ( I2S_Type base,
sai_transceiver_t config 
)

SAI receiver configurations.

Parameters
baseSAI base pointer.
configreceiver configurations.

brief SAI receiver configurations.

param base SAI base pointer. param config transmitter configurations.

◆ SAI_RxSetDataOrder()

void SAI_RxSetDataOrder ( I2S_Type base,
sai_data_order_t  order 
)

Set the Rx data order.

Parameters
baseSAI base pointer
orderData order MSB or LSB

brief Set the Rx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_RxSetFormat()

void SAI_RxSetFormat ( I2S_Type base,
sai_transfer_format_t format,
uint32_t  mclkSourceClockHz,
uint32_t  bclkSourceClockHz 
)

Configures the SAI Rx audio format.

Deprecated:
Do not use this function. It has been superceded by SAI_RxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

Parameters
baseSAI base pointer.
formatPointer to the SAI audio data format structure.
mclkSourceClockHzSAI master clock source frequency in Hz.
bclkSourceClockHzSAI bit clock source frequency in Hz. If the bit clock source is a master clock, this value should equal the masterClockHz.

brief Configures the SAI Rx audio format.

deprecated Do not use this function. It has been superceded by SAI_RxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

param base SAI base pointer. param format Pointer to the SAI audio data format structure. param mclkSourceClockHz SAI master clock source frequency in Hz. param bclkSourceClockHz SAI bit clock source frequency in Hz. If the bit clock source is a master clock, this value should equal the masterClockHz.

◆ SAI_RxSetFrameSyncConfig()

void SAI_RxSetFrameSyncConfig ( I2S_Type base,
sai_master_slave_t  masterSlave,
sai_frame_sync_t config 
)

SAI receiver Frame sync configurations.

Parameters
baseSAI base pointer.
masterSlavemaster or slave.
configframe sync configurations, can be NULL in slave mode.

brief SAI receiver Frame sync configurations.

param base SAI base pointer. param masterSlave master or slave. param config frame sync configurations, can be NULL in slave mode.

◆ SAI_RxSetFrameSyncPolarity()

void SAI_RxSetFrameSyncPolarity ( I2S_Type base,
sai_clock_polarity_t  polarity 
)

Set the Rx data order.

Parameters
baseSAI base pointer
polarity

brief Set the Rx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_RxSetSerialDataConfig()

void SAI_RxSetSerialDataConfig ( I2S_Type base,
sai_serial_data_t config 
)

SAI receiver Serial data configurations.

Parameters
baseSAI base pointer.
configserial data configurations.
Parameters
baseSAI base pointer.
configserial data configurations.

◆ SAI_RxSoftwareReset()

void SAI_RxSoftwareReset ( I2S_Type base,
sai_reset_type_t  resetType 
)

Do software reset or FIFO reset .

FIFO reset means clear all the data in the FIFO, and make the FIFO pointer both to 0. Software reset means clear the Rx internal logic, including the bit clock, frame count etc. But software reset will not clear any configuration registers like RCR1~RCR5. This function will also clear all the error flags such as FIFO error, sync error etc.

Parameters
baseSAI base pointer
resetTypeReset type, FIFO reset or software reset

brief Do software reset or FIFO reset .

FIFO reset means clear all the data in the FIFO, and make the FIFO pointer both to 0. Software reset means clear the Rx internal logic, including the bit clock, frame count etc. But software reset will not clear any configuration registers like RCR1~RCR5. This function will also clear all the error flags such as FIFO error, sync error etc.

param base SAI base pointer param resetType Reset type, FIFO reset or software reset

◆ SAI_TransferAbortReceive()

void SAI_TransferAbortReceive ( I2S_Type base,
sai_handle_t handle 
)

Aborts the current IRQ receive.

Note
This API can be called when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
baseSAI base pointer
handlePointer to the sai_handle_t structure which stores the transfer state.

brief Aborts the current IRQ receive.

note This API can be called when an interrupt non-blocking transfer initiates to abort the transfer early.

param base SAI base pointer param handle Pointer to the sai_handle_t structure which stores the transfer state.

◆ SAI_TransferAbortSend()

void SAI_TransferAbortSend ( I2S_Type base,
sai_handle_t handle 
)

Aborts the current send.

Note
This API can be called any time when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure which stores the transfer state.

brief Aborts the current send.

note This API can be called any time when an interrupt non-blocking transfer initiates to abort the transfer early.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state.

◆ SAI_TransferGetReceiveCount()

status_t SAI_TransferGetReceiveCount ( I2S_Type base,
sai_handle_t handle,
size_t *  count 
)

Gets a received byte count.

Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure which stores the transfer state.
countBytes count received.
Return values
kStatus_SuccessSucceed get the transfer count.
kStatus_NoTransferInProgressThere is not a non-blocking transaction currently in progress.

brief Gets a received byte count.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state. param count Bytes count received. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.

◆ SAI_TransferGetSendCount()

status_t SAI_TransferGetSendCount ( I2S_Type base,
sai_handle_t handle,
size_t *  count 
)

Gets a set byte count.

Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure which stores the transfer state.
countBytes count sent.
Return values
kStatus_SuccessSucceed get the transfer count.
kStatus_NoTransferInProgressThere is not a non-blocking transaction currently in progress.

brief Gets a set byte count.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state. param count Bytes count sent. retval kStatus_Success Succeed get the transfer count. retval kStatus_NoTransferInProgress There is not a non-blocking transaction currently in progress.

◆ SAI_TransferReceiveNonBlocking()

status_t SAI_TransferReceiveNonBlocking ( I2S_Type base,
sai_handle_t handle,
sai_transfer_t xfer 
)

Performs an interrupt non-blocking receive transfer on SAI.

Note
This API returns immediately after the transfer initiates. Call the SAI_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer is finished.
Parameters
baseSAI base pointer
handlePointer to the sai_handle_t structure which stores the transfer state.
xferPointer to the sai_transfer_t structure.
Return values
kStatus_SuccessSuccessfully started the data receive.
kStatus_SAI_RxBusyPrevious receive still not finished.
kStatus_InvalidArgumentThe input parameter is invalid.

brief Performs an interrupt non-blocking receive transfer on SAI.

note This API returns immediately after the transfer initiates. Call the SAI_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer is finished.

param base SAI base pointer param handle Pointer to the sai_handle_t structure which stores the transfer state. param xfer Pointer to the sai_transfer_t structure. retval kStatus_Success Successfully started the data receive. retval kStatus_SAI_RxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid.

◆ SAI_TransferRxCreateHandle()

void SAI_TransferRxCreateHandle ( I2S_Type base,
sai_handle_t handle,
sai_transfer_callback_t  callback,
void *  userData 
)

Initializes the SAI Rx handle.

This function initializes the Rx handle for the SAI Rx transactional APIs. Call this function once to get the handle initialized.

Parameters
baseSAI base pointer.
handleSAI handle pointer.
callbackPointer to the user callback function.
userDataUser parameter passed to the callback function.

brief Initializes the SAI Rx handle.

This function initializes the Rx handle for the SAI Rx transactional APIs. Call this function once to get the handle initialized.

param base SAI base pointer. param handle SAI handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function.

◆ SAI_TransferRxHandleIRQ()

void SAI_TransferRxHandleIRQ ( I2S_Type base,
sai_handle_t handle 
)

Tx interrupt handler.

Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure.

brief Tx interrupt handler.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure.

◆ SAI_TransferRxSetConfig()

void SAI_TransferRxSetConfig ( I2S_Type base,
sai_handle_t handle,
sai_transceiver_t config 
)

SAI receiver transfer configurations.

This function initializes the Rx, include bit clock, frame sync, master clock, serial data and fifo configurations.

Parameters
baseSAI base pointer.
handleSAI handle pointer.
configreceiver configurations.

brief SAI receiver transfer configurations.

This function initializes the TX, include bit clock, frame sync, master clock, serial data and fifo configurations.

param base SAI base pointer. param handle SAI handle pointer. param config tranmitter configurations.

◆ SAI_TransferRxSetFormat()

status_t SAI_TransferRxSetFormat ( I2S_Type base,
sai_handle_t handle,
sai_transfer_format_t format,
uint32_t  mclkSourceClockHz,
uint32_t  bclkSourceClockHz 
)

Configures the SAI Rx audio format.

Deprecated:
Do not use this function. It has been superceded by SAI_TransferRxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

Parameters
baseSAI base pointer.
handleSAI handle pointer.
formatPointer to the SAI audio data format structure.
mclkSourceClockHzSAI master clock source frequency in Hz.
bclkSourceClockHzSAI bit clock source frequency in Hz. If a bit clock source is a master clock, this value should equal the masterClockHz in format.
Returns
Status of this function. Return value is one of status_t.

brief Configures the SAI Rx audio format.

deprecated Do not use this function. It has been superceded by SAI_TransferRxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

param base SAI base pointer. param handle SAI handle pointer. param format Pointer to the SAI audio data format structure. param mclkSourceClockHz SAI master clock source frequency in Hz. param bclkSourceClockHz SAI bit clock source frequency in Hz. If a bit clock source is a master clock, this value should equal the masterClockHz in format. return Status of this function. Return value is one of status_t.

◆ SAI_TransferSendNonBlocking()

status_t SAI_TransferSendNonBlocking ( I2S_Type base,
sai_handle_t handle,
sai_transfer_t xfer 
)

Performs an interrupt non-blocking send transfer on SAI.

Note
This API returns immediately after the transfer initiates. Call the SAI_TxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer is finished.
Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure which stores the transfer state.
xferPointer to the sai_transfer_t structure.
Return values
kStatus_SuccessSuccessfully started the data receive.
kStatus_SAI_TxBusyPrevious receive still not finished.
kStatus_InvalidArgumentThe input parameter is invalid.

brief Performs an interrupt non-blocking send transfer on SAI.

note This API returns immediately after the transfer initiates. Call the SAI_TxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_SAI_Busy, the transfer is finished.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure which stores the transfer state. param xfer Pointer to the sai_transfer_t structure. retval kStatus_Success Successfully started the data receive. retval kStatus_SAI_TxBusy Previous receive still not finished. retval kStatus_InvalidArgument The input parameter is invalid.

◆ SAI_TransferTerminateReceive()

void SAI_TransferTerminateReceive ( I2S_Type base,
sai_handle_t handle 
)

Terminate all SAI receive.

This function will clear all transfer slots buffered in the sai queue. If users only want to abort the current transfer slot, please call SAI_TransferAbortReceive.

Parameters
baseSAI base pointer.
handleSAI eDMA handle pointer.

brief Terminate all SAI receive.

This function will clear all transfer slots buffered in the sai queue. If users only want to abort the current transfer slot, please call SAI_TransferAbortReceive.

param base SAI base pointer. param handle SAI eDMA handle pointer.

◆ SAI_TransferTerminateSend()

void SAI_TransferTerminateSend ( I2S_Type base,
sai_handle_t handle 
)

Terminate all SAI send.

This function will clear all transfer slots buffered in the sai queue. If users only want to abort the current transfer slot, please call SAI_TransferAbortSend.

Parameters
baseSAI base pointer.
handleSAI eDMA handle pointer.

brief Terminate all SAI send.

This function will clear all transfer slots buffered in the sai queue. If users only want to abort the current transfer slot, please call SAI_TransferAbortSend.

param base SAI base pointer. param handle SAI eDMA handle pointer.

◆ SAI_TransferTxCreateHandle()

void SAI_TransferTxCreateHandle ( I2S_Type base,
sai_handle_t handle,
sai_transfer_callback_t  callback,
void *  userData 
)

Initializes the SAI Tx handle.

This function initializes the Tx handle for the SAI Tx transactional APIs. Call this function once to get the handle initialized.

Parameters
baseSAI base pointer
handleSAI handle pointer.
callbackPointer to the user callback function.
userDataUser parameter passed to the callback function

brief Initializes the SAI Tx handle.

This function initializes the Tx handle for the SAI Tx transactional APIs. Call this function once to get the handle initialized.

param base SAI base pointer param handle SAI handle pointer. param callback Pointer to the user callback function. param userData User parameter passed to the callback function

◆ SAI_TransferTxHandleIRQ()

void SAI_TransferTxHandleIRQ ( I2S_Type base,
sai_handle_t handle 
)

Tx interrupt handler.

Parameters
baseSAI base pointer.
handlePointer to the sai_handle_t structure.

brief Tx interrupt handler.

param base SAI base pointer. param handle Pointer to the sai_handle_t structure.

◆ SAI_TransferTxSetConfig()

void SAI_TransferTxSetConfig ( I2S_Type base,
sai_handle_t handle,
sai_transceiver_t config 
)

SAI transmitter transfer configurations.

This function initializes the Tx, include bit clock, frame sync, master clock, serial data and fifo configurations.

Parameters
baseSAI base pointer.
handleSAI handle pointer.
configtranmitter configurations.

brief SAI transmitter transfer configurations.

This function initializes the TX, include bit clock, frame sync, master clock, serial data and fifo configurations.

param base SAI base pointer. param handle SAI handle pointer. param config tranmitter configurations.

◆ SAI_TransferTxSetFormat()

status_t SAI_TransferTxSetFormat ( I2S_Type base,
sai_handle_t handle,
sai_transfer_format_t format,
uint32_t  mclkSourceClockHz,
uint32_t  bclkSourceClockHz 
)

Configures the SAI Tx audio format.

Deprecated:
Do not use this function. It has been superceded by SAI_TransferTxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

Parameters
baseSAI base pointer.
handleSAI handle pointer.
formatPointer to the SAI audio data format structure.
mclkSourceClockHzSAI master clock source frequency in Hz.
bclkSourceClockHzSAI bit clock source frequency in Hz. If a bit clock source is a master clock, this value should equal the masterClockHz in format.
Returns
Status of this function. Return value is the status_t.

brief Configures the SAI Tx audio format.

deprecated Do not use this function. It has been superceded by SAI_TransferTxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

param base SAI base pointer. param handle SAI handle pointer. param format Pointer to the SAI audio data format structure. param mclkSourceClockHz SAI master clock source frequency in Hz. param bclkSourceClockHz SAI bit clock source frequency in Hz. If a bit clock source is a master clock, this value should equal the masterClockHz in format. return Status of this function. Return value is the status_t.

◆ SAI_TxEnable()

void SAI_TxEnable ( I2S_Type base,
bool  enable 
)

Enables/disables the SAI Tx.

Parameters
baseSAI base pointer.
enableTrue means enable SAI Tx, false means disable.

brief Enables/disables the SAI Tx.

param base SAI base pointer param enable True means enable SAI Tx, false means disable.

◆ SAI_TxGetDefaultConfig()

void SAI_TxGetDefaultConfig ( sai_config_t config)

Sets the SAI Tx configuration structure to default values.

Deprecated:
Do not use this function. It has been superceded by SAI_GetClassicI2SConfig, SAI_GetLeftJustifiedConfig , SAI_GetRightJustifiedConfig, SAI_GetDSPConfig, SAI_GetTDMConfig

This API initializes the configuration structure for use in SAI_TxConfig(). The initialized structure can remain unchanged in SAI_TxConfig(), or it can be modified before calling SAI_TxConfig(). This is an example.

void SAI_TxGetDefaultConfig(sai_config_t *config)
Sets the SAI Tx configuration structure to default values.
Definition: fsl_sai.c:697
Parameters
configpointer to master configuration structure

brief Sets the SAI Tx configuration structure to default values.

deprecated Do not use this function. It has been superceded by SAI_GetClassicI2SConfig, SAI_GetLeftJustifiedConfig,SAI_GetRightJustifiedConfig, SAI_GetDSPConfig,SAI_GetTDMConfig

This API initializes the configuration structure for use in SAI_TxConfig(). The initialized structure can remain unchanged in SAI_TxConfig(), or it can be modified before calling SAI_TxConfig(). This is an example. code sai_config_t config; SAI_TxGetDefaultConfig(&config); endcode

param config pointer to master configuration structure

◆ SAI_TxInit()

void SAI_TxInit ( I2S_Type base,
const sai_config_t config 
)

Initializes the SAI Tx peripheral.

Deprecated:
Do not use this function. It has been superceded by SAI_Init

Ungates the SAI clock, resets the module, and configures SAI Tx with a configuration structure. The configuration structure can be custom filled or set with default values by SAI_TxGetDefaultConfig().

Note
This API should be called at the beginning of the application to use the SAI driver. Otherwise, accessing the SAIM module can cause a hard fault because the clock is not enabled.
Parameters
baseSAI base pointer
configSAI configuration structure.

brief Initializes the SAI Tx peripheral.

deprecated Do not use this function. It has been superceded by SAI_Init

Ungates the SAI clock, resets the module, and configures SAI Tx with a configuration structure. The configuration structure can be custom filled or set with default values by SAI_TxGetDefaultConfig().

note This API should be called at the beginning of the application to use the SAI driver. Otherwise, accessing the SAIM module can cause a hard fault because the clock is not enabled.

param base SAI base pointer param config SAI configuration structure.

◆ SAI_TxReset()

void SAI_TxReset ( I2S_Type base)

Resets the SAI Tx.

This function enables the software reset and FIFO reset of SAI Tx. After reset, clear the reset bit.

Parameters
baseSAI base pointer

brief Resets the SAI Tx.

This function enables the software reset and FIFO reset of SAI Tx. After reset, clear the reset bit.

param base SAI base pointer

◆ SAI_TxSetBitclockConfig()

void SAI_TxSetBitclockConfig ( I2S_Type base,
sai_master_slave_t  masterSlave,
sai_bit_clock_t config 
)

Transmitter Bit clock configurations.

Parameters
baseSAI base pointer.
masterSlavemaster or slave.
configbit clock other configurations, can be NULL in slave mode.

brief Transmitter Bit clock configurations.

param base SAI base pointer. param masterSlave master or slave. param config bit clock other configurations, can be NULL in slave mode.

◆ SAI_TxSetBitClockPolarity()

void SAI_TxSetBitClockPolarity ( I2S_Type base,
sai_clock_polarity_t  polarity 
)

Set the Tx data order.

Parameters
baseSAI base pointer
polarity

brief Set the Tx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_TxSetBitClockRate()

void SAI_TxSetBitClockRate ( I2S_Type base,
uint32_t  sourceClockHz,
uint32_t  sampleRate,
uint32_t  bitWidth,
uint32_t  channelNumbers 
)

Transmitter bit clock rate configurations.

Parameters
baseSAI base pointer.
sourceClockHzBit clock source frequency.
sampleRateAudio data sample rate.
bitWidthAudio data bitWidth.
channelNumbersAudio channel numbers.

brief Transmitter bit clock rate configurations.

param base SAI base pointer. param sourceClockHz, bit clock source frequency. param sampleRate audio data sample rate. param bitWidth, audio data bitWidth. param channelNumbers, audio channel numbers.

◆ SAI_TxSetChannelFIFOMask()

void SAI_TxSetChannelFIFOMask ( I2S_Type base,
uint8_t  mask 
)

Set the Tx channel FIFO enable mask.

Parameters
baseSAI base pointer
maskChannel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled.

brief Set the Tx channel FIFO enable mask.

param base SAI base pointer param mask Channel enable mask, 0 means all channel FIFO disabled, 1 means channel 0 enabled, 3 means both channel 0 and channel 1 enabled.

◆ SAI_TxSetConfig()

void SAI_TxSetConfig ( I2S_Type base,
sai_transceiver_t config 
)

SAI transmitter configurations.

Parameters
baseSAI base pointer.
configtransmitter configurations.

brief SAI transmitter configurations.

param base SAI base pointer. param config transmitter configurations.

◆ SAI_TxSetDataOrder()

void SAI_TxSetDataOrder ( I2S_Type base,
sai_data_order_t  order 
)

Set the Tx data order.

Parameters
baseSAI base pointer
orderData order MSB or LSB

brief Set the Tx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_TxSetFormat()

void SAI_TxSetFormat ( I2S_Type base,
sai_transfer_format_t format,
uint32_t  mclkSourceClockHz,
uint32_t  bclkSourceClockHz 
)

Configures the SAI Tx audio format.

Deprecated:
Do not use this function. It has been superceded by SAI_TxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

Parameters
baseSAI base pointer.
formatPointer to the SAI audio data format structure.
mclkSourceClockHzSAI master clock source frequency in Hz.
bclkSourceClockHzSAI bit clock source frequency in Hz. If the bit clock source is a master clock, this value should equal the masterClockHz.

brief Configures the SAI Tx audio format.

deprecated Do not use this function. It has been superceded by SAI_TxSetConfig

The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.

param base SAI base pointer. param format Pointer to the SAI audio data format structure. param mclkSourceClockHz SAI master clock source frequency in Hz. param bclkSourceClockHz SAI bit clock source frequency in Hz. If the bit clock source is a master clock, this value should equal the masterClockHz.

◆ SAI_TxSetFrameSyncConfig()

void SAI_TxSetFrameSyncConfig ( I2S_Type base,
sai_master_slave_t  masterSlave,
sai_frame_sync_t config 
)

SAI transmitter Frame sync configurations.

Parameters
baseSAI base pointer.
masterSlavemaster or slave.
configframe sync configurations, can be NULL in slave mode.

brief SAI transmitter Frame sync configurations.

param base SAI base pointer. param masterSlave master or slave. param config frame sync configurations, can be NULL in slave mode.

◆ SAI_TxSetFrameSyncPolarity()

void SAI_TxSetFrameSyncPolarity ( I2S_Type base,
sai_clock_polarity_t  polarity 
)

Set the Tx data order.

Parameters
baseSAI base pointer
polarity

brief Set the Tx data order.

param base SAI base pointer param order Data order MSB or LSB

◆ SAI_TxSetSerialDataConfig()

void SAI_TxSetSerialDataConfig ( I2S_Type base,
sai_serial_data_t config 
)

SAI transmitter Serial data configurations.

Parameters
baseSAI base pointer.
configserial data configurations.

brief SAI transmitter Serial data configurations.

param base SAI base pointer. param config serial data configurations.

◆ SAI_TxSoftwareReset()

void SAI_TxSoftwareReset ( I2S_Type base,
sai_reset_type_t  resetType 
)

Do software reset or FIFO reset .

FIFO reset means clear all the data in the FIFO, and make the FIFO pointer both to 0. Software reset means clear the Tx internal logic, including the bit clock, frame count etc. But software reset will not clear any configuration registers like TCR1~TCR5. This function will also clear all the error flags such as FIFO error, sync error etc.

Parameters
baseSAI base pointer
tresetTypeReset type, FIFO reset or software reset

brief Do software reset or FIFO reset .

FIFO reset means clear all the data in the FIFO, and make the FIFO pointer both to 0. Software reset means clear the Tx internal logic, including the bit clock, frame count etc. But software reset will not clear any configuration registers like TCR1~TCR5. This function will also clear all the error flags such as FIFO error, sync error etc.

param base SAI base pointer param resetType Reset type, FIFO reset or software reset

◆ SAI_WriteBlocking()

void SAI_WriteBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)

Sends data using a blocking method.

Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSAI base pointer.
channelData channel used.
bitWidthHow many bits in an audio word; usually 8/16/24/32 bits.
bufferPointer to the data to be written.
sizeBytes to be written.

brief Sends data using a blocking method.

note This function blocks by polling until data is ready to be sent.

param base SAI base pointer. param channel Data channel used. param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. param buffer Pointer to the data to be written. param size Bytes to be written.

◆ SAI_WriteMultiChannelBlocking()

void SAI_WriteMultiChannelBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  channelMask,
uint32_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)

Sends data to multi channel using a blocking method.

Note
This function blocks by polling until data is ready to be sent.
Parameters
baseSAI base pointer.
channelData channel used.
channelMaskchannel mask.
bitWidthHow many bits in an audio word; usually 8/16/24/32 bits.
bufferPointer to the data to be written.
sizeBytes to be written.

brief Sends data to multi channel using a blocking method.

note This function blocks by polling until data is ready to be sent.

param base SAI base pointer. param channel Data channel used. param channelMask channel mask. param bitWidth How many bits in an audio word; usually 8/16/24/32 bits. param buffer Pointer to the data to be written. param size Bytes to be written.