Macros | Typedefs | Enumerations | Functions | Variables
fsl_sai.c File Reference
#include "fsl_sai.h"
Include dependency graph for fsl_sai.c:

Go to the source code of this file.

Macros

#define FSL_COMPONENT_ID   "platform.drivers.sai"
 
#define IS_SAI_FLAG_SET(reg, flag)   (((reg) & ((uint32_t)flag)) != 0UL)
 check flag avalibility More...
 

Typedefs

typedef void(* sai_rx_isr_t) (I2S_Type *base, sai_handle_t *saiHandle)
 Typedef for sai rx interrupt handler. More...
 
typedef void(* sai_tx_isr_t) (I2S_Type *base, sai_handle_t *saiHandle)
 Typedef for sai tx interrupt handler. More...
 

Enumerations

enum  { kSAI_Busy = 0x0U, kSAI_Idle, kSAI_Error }
 _sai_transfer_state sai transfer state. More...
 

Functions

void SAI_Deinit (I2S_Type *base)
 De-initializes the SAI peripheral. More...
 
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. More...
 
static void SAI_GetCommonConfig (sai_transceiver_t *config, sai_word_width_t bitWidth, sai_mono_stereo_t mode, uint32_t saiChannelMask)
 Get classic I2S mode configurations. More...
 
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. More...
 
static uint32_t SAI_GetInstance (I2S_Type *base)
 Get the instance number for SAI. More...
 
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. More...
 
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. More...
 
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. More...
 
void SAI_Init (I2S_Type *base)
 Initializes the SAI peripheral. More...
 
void SAI_ReadBlocking (I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Receives data using a blocking method. More...
 
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. More...
 
static void SAI_ReadNonBlocking (I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
 Receive a piece of data in non-blocking way. More...
 
void SAI_RxEnable (I2S_Type *base, bool enable)
 Enables/disables the SAI Rx. More...
 
void SAI_RxGetDefaultConfig (sai_config_t *config)
 Sets the SAI Rx configuration structure to default values. More...
 
static bool SAI_RxGetEnabledInterruptStatus (I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
 sai get rx enabled interrupt status. More...
 
void SAI_RxInit (I2S_Type *base, const sai_config_t *config)
 Initializes the SAI Rx peripheral. More...
 
void SAI_RxReset (I2S_Type *base)
 Resets the SAI Rx. More...
 
void SAI_RxSetBitclockConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
 Receiver Bit clock configurations. More...
 
void SAI_RxSetBitClockPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Rx data order. More...
 
void SAI_RxSetBitClockRate (I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
 Receiver bit clock rate configurations. More...
 
void SAI_RxSetChannelFIFOMask (I2S_Type *base, uint8_t mask)
 Set the Rx channel FIFO enable mask. More...
 
void SAI_RxSetConfig (I2S_Type *base, sai_transceiver_t *config)
 SAI receiver configurations. More...
 
void SAI_RxSetDataOrder (I2S_Type *base, sai_data_order_t order)
 Set the Rx data order. More...
 
void SAI_RxSetFormat (I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Rx audio format. More...
 
void SAI_RxSetFrameSyncConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
 SAI receiver Frame sync configurations. More...
 
void SAI_RxSetFrameSyncPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Rx data order. More...
 
void SAI_RxSetSerialDataConfig (I2S_Type *base, sai_serial_data_t *config)
 SAI receiver Serial data configurations. More...
 
void SAI_RxSoftwareReset (I2S_Type *base, sai_reset_type_t type)
 Do software reset or FIFO reset . More...
 
void SAI_TransferAbortReceive (I2S_Type *base, sai_handle_t *handle)
 Aborts the current IRQ receive. More...
 
void SAI_TransferAbortSend (I2S_Type *base, sai_handle_t *handle)
 Aborts the current send. More...
 
status_t SAI_TransferGetReceiveCount (I2S_Type *base, sai_handle_t *handle, size_t *count)
 Gets a received byte count. More...
 
status_t SAI_TransferGetSendCount (I2S_Type *base, sai_handle_t *handle, size_t *count)
 Gets a set byte count. More...
 
status_t SAI_TransferReceiveNonBlocking (I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
 Performs an interrupt non-blocking receive transfer on SAI. More...
 
void SAI_TransferRxCreateHandle (I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
 Initializes the SAI Rx handle. More...
 
void SAI_TransferRxHandleIRQ (I2S_Type *base, sai_handle_t *handle)
 Tx interrupt handler. More...
 
void SAI_TransferRxSetConfig (I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
 SAI receiver transfer configurations. More...
 
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. More...
 
status_t SAI_TransferSendNonBlocking (I2S_Type *base, sai_handle_t *handle, sai_transfer_t *xfer)
 Performs an interrupt non-blocking send transfer on SAI. More...
 
void SAI_TransferTerminateReceive (I2S_Type *base, sai_handle_t *handle)
 Terminate all SAI receive. More...
 
void SAI_TransferTerminateSend (I2S_Type *base, sai_handle_t *handle)
 Terminate all SAI send. More...
 
void SAI_TransferTxCreateHandle (I2S_Type *base, sai_handle_t *handle, sai_transfer_callback_t callback, void *userData)
 Initializes the SAI Tx handle. More...
 
void SAI_TransferTxHandleIRQ (I2S_Type *base, sai_handle_t *handle)
 Tx interrupt handler. More...
 
void SAI_TransferTxSetConfig (I2S_Type *base, sai_handle_t *handle, sai_transceiver_t *config)
 SAI transmitter transfer configurations. More...
 
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. More...
 
void SAI_TxEnable (I2S_Type *base, bool enable)
 Enables/disables the SAI Tx. More...
 
void SAI_TxGetDefaultConfig (sai_config_t *config)
 Sets the SAI Tx configuration structure to default values. More...
 
static bool SAI_TxGetEnabledInterruptStatus (I2S_Type *base, uint32_t enableFlag, uint32_t statusFlag)
 sai get tx enabled interrupt status. More...
 
void SAI_TxInit (I2S_Type *base, const sai_config_t *config)
 Initializes the SAI Tx peripheral. More...
 
void SAI_TxReset (I2S_Type *base)
 Resets the SAI Tx. More...
 
void SAI_TxSetBitclockConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_bit_clock_t *config)
 Transmitter Bit clock configurations. More...
 
void SAI_TxSetBitClockPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Tx data order. More...
 
void SAI_TxSetBitClockRate (I2S_Type *base, uint32_t sourceClockHz, uint32_t sampleRate, uint32_t bitWidth, uint32_t channelNumbers)
 Transmitter bit clock rate configurations. More...
 
void SAI_TxSetChannelFIFOMask (I2S_Type *base, uint8_t mask)
 Set the Tx channel FIFO enable mask. More...
 
void SAI_TxSetConfig (I2S_Type *base, sai_transceiver_t *config)
 SAI transmitter configurations. More...
 
void SAI_TxSetDataOrder (I2S_Type *base, sai_data_order_t order)
 Set the Tx data order. More...
 
void SAI_TxSetFormat (I2S_Type *base, sai_transfer_format_t *format, uint32_t mclkSourceClockHz, uint32_t bclkSourceClockHz)
 Configures the SAI Tx audio format. More...
 
void SAI_TxSetFrameSyncConfig (I2S_Type *base, sai_master_slave_t masterSlave, sai_frame_sync_t *config)
 SAI transmitter Frame sync configurations. More...
 
void SAI_TxSetFrameSyncPolarity (I2S_Type *base, sai_clock_polarity_t polarity)
 Set the Tx data order. More...
 
void SAI_TxSetSerialDataConfig (I2S_Type *base, sai_serial_data_t *config)
 SAI transmitter Serial data configurations. More...
 
void SAI_TxSoftwareReset (I2S_Type *base, sai_reset_type_t type)
 Do software reset or FIFO reset . More...
 
void SAI_WriteBlocking (I2S_Type *base, uint32_t channel, uint32_t bitWidth, uint8_t *buffer, uint32_t size)
 Sends data using a blocking method. More...
 
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. More...
 
static void SAI_WriteNonBlocking (I2S_Type *base, uint32_t channel, uint32_t channelMask, uint32_t endChannel, uint8_t bitWidth, uint8_t *buffer, uint32_t size)
 sends a piece of data in non-blocking way. More...
 

Variables

static I2S_Type *const s_saiBases [] = I2S_BASE_PTRS
 
static const clock_ip_name_t s_saiClock [] = SAI_CLOCKS
 
static sai_handle_ts_saiHandle [ARRAY_SIZE(s_saiBases)][2]
 SAI handle pointer. More...
 
static const IRQn_Type s_saiRxIRQ [] = I2S_RX_IRQS
 
static sai_rx_isr_t s_saiRxIsr
 Pointer to tx IRQ handler for each instance. More...
 
static const IRQn_Type s_saiTxIRQ [] = I2S_TX_IRQS
 
static sai_tx_isr_t s_saiTxIsr
 Pointer to tx IRQ handler for each instance. More...
 

Macro Definition Documentation

◆ FSL_COMPONENT_ID

#define FSL_COMPONENT_ID   "platform.drivers.sai"

Definition at line 13 of file fsl_sai.c.

◆ IS_SAI_FLAG_SET

#define IS_SAI_FLAG_SET (   reg,
  flag 
)    (((reg) & ((uint32_t)flag)) != 0UL)

check flag avalibility

Definition at line 34 of file fsl_sai.c.

Typedef Documentation

◆ sai_rx_isr_t

typedef void(* sai_rx_isr_t) (I2S_Type *base, sai_handle_t *saiHandle)

Typedef for sai rx interrupt handler.

Definition at line 31 of file fsl_sai.c.

◆ sai_tx_isr_t

typedef void(* sai_tx_isr_t) (I2S_Type *base, sai_handle_t *saiHandle)

Typedef for sai tx interrupt handler.

Definition at line 28 of file fsl_sai.c.

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

_sai_transfer_state sai transfer state.

Enumerator
kSAI_Busy 

SAI is busy

kSAI_Idle 

Transfer is done.

kSAI_Error 

Transfer error occurred.

Definition at line 20 of file fsl_sai.c.

Function Documentation

◆ SAI_GetCommonConfig()

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

Get classic I2S mode configurations.

Parameters
configtransceiver configurations
bitWidthaudio data bitWidth.
modeaudio data channel
saiChannelMaskchannel mask value to enable

Definition at line 340 of file fsl_sai.c.

◆ SAI_GetInstance()

static uint32_t SAI_GetInstance ( I2S_Type base)
static

Get the instance number for SAI.

Parameters
baseSAI base pointer.

Definition at line 259 of file fsl_sai.c.

◆ SAI_ReadNonBlocking()

static void SAI_ReadNonBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  channelMask,
uint32_t  endChannel,
uint8_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)
static

Receive a piece of data in non-blocking way.

Parameters
baseSAI base pointer
channelstart channel number.
channelMaskenabled channels mask.
endChannelend channel numbers.
bitWidthHow many bits in a audio word, usually 8/16/24/32 bits.
bufferPointer to the data to be read.
sizeBytes to be read.

Definition at line 310 of file fsl_sai.c.

◆ SAI_RxGetEnabledInterruptStatus()

static bool SAI_RxGetEnabledInterruptStatus ( I2S_Type base,
uint32_t  enableFlag,
uint32_t  statusFlag 
)
static

sai get rx enabled interrupt status.

Parameters
baseSAI base pointer.
enableFlagenable flag to check.
statusFlagstatus flag to check.

Definition at line 165 of file fsl_sai.c.

◆ SAI_TxGetEnabledInterruptStatus()

static bool SAI_TxGetEnabledInterruptStatus ( I2S_Type base,
uint32_t  enableFlag,
uint32_t  statusFlag 
)
static

sai get tx enabled interrupt status.

Set the master clock divider.

Parameters
baseSAI base pointer.
enableFlagenable flag to check.
statusFlagstatus flag to check.

This API will compute the master clock divider according to master clock frequency and master clock source clock source frequency.

Parameters
baseSAI base pointer.
mclk_HzMater clock frequency in Hz.
mclkSrcClock_HzMaster clock source frequency in Hz.

Definition at line 172 of file fsl_sai.c.

◆ SAI_WriteNonBlocking()

static void SAI_WriteNonBlocking ( I2S_Type base,
uint32_t  channel,
uint32_t  channelMask,
uint32_t  endChannel,
uint8_t  bitWidth,
uint8_t *  buffer,
uint32_t  size 
)
static

sends a piece of data in non-blocking way.

Parameters
baseSAI base pointer
channelstart channel number.
channelMaskenabled channels mask.
endChannelend channel numbers.
bitWidthHow many bits in a audio word, usually 8/16/24/32 bits.
bufferPointer to the data to be written.
sizeBytes to be written.

Definition at line 277 of file fsl_sai.c.

Variable Documentation

◆ s_saiBases

I2S_Type* const s_saiBases[] = I2S_BASE_PTRS
static

Definition at line 147 of file fsl_sai.c.

◆ s_saiClock

const clock_ip_name_t s_saiClock[] = SAI_CLOCKS
static

Definition at line 155 of file fsl_sai.c.

◆ s_saiHandle

sai_handle_t* s_saiHandle[ARRAY_SIZE(s_saiBases)][2]
static

SAI handle pointer.

Definition at line 149 of file fsl_sai.c.

◆ s_saiRxIRQ

const IRQn_Type s_saiRxIRQ[] = I2S_RX_IRQS
static

Definition at line 152 of file fsl_sai.c.

◆ s_saiRxIsr

sai_rx_isr_t s_saiRxIsr
static

Pointer to tx IRQ handler for each instance.

Definition at line 160 of file fsl_sai.c.

◆ s_saiTxIRQ

const IRQn_Type s_saiTxIRQ[] = I2S_TX_IRQS
static

Definition at line 151 of file fsl_sai.c.

◆ s_saiTxIsr

sai_tx_isr_t s_saiTxIsr
static

Pointer to tx IRQ handler for each instance.

Definition at line 158 of file fsl_sai.c.



picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:57