![]() |
Kinetis SDK v.1.2 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
#include <string.h>
#include <stdbool.h>
#include <assert.h>
#include "fsl_device_registers.h"
Data Structures | |
struct | sai_clock_setting_t |
SAI clock configuration structure. More... | |
Functions | |
void | SAI_HAL_TxSetSyncMode (I2S_Type *base, sai_sync_mode_t sync_mode) |
SAI Tx sync mode setting. More... | |
void | SAI_HAL_RxSetSyncMode (I2S_Type *base, sai_sync_mode_t sync_mode) |
SAI Rx sync mode setting. More... | |
static uint32_t | SAI_HAL_TxGetFifoAddr (I2S_Type *base, uint32_t fifo_channel) |
Gets the TDR register address. More... | |
static uint32_t | SAI_HAL_RxGetFifoAddr (I2S_Type *base, uint32_t fifo_channel) |
Gets the RDR register address. More... | |
static void | SAI_HAL_TxEnable (I2S_Type *base) |
Enables the SAI Tx module. More... | |
static void | SAI_HAL_RxEnable (I2S_Type *base) |
Enables the SAI Rx module. More... | |
static void | SAI_HAL_TxDisable (I2S_Type *base) |
Disables the Tx module. More... | |
static void | SAI_HAL_RxDisable (I2S_Type *base) |
Disables the Rx module. More... | |
void | SAI_HAL_TxSetIntCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the Tx interrupt from different interrupt sources. More... | |
void | SAI_HAL_RxSetIntCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the Rx interrupt from different interrupt sources. More... | |
void | SAI_HAL_TxSetDmaCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the Tx DMA request from different sources. More... | |
void | SAI_HAL_RxSetDmaCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the Rx DMA request from different sources. More... | |
void | SAI_HAL_TxClearStateFlag (I2S_Type *base, uint32_t flag_mask) |
Clears the Tx state flags. More... | |
void | SAI_HAL_RxClearStateFlag (I2S_Type *base, uint32_t flag_mask) |
Clears the Rx state flags. More... | |
void | SAI_HAL_TxSetReset (I2S_Type *base, uint32_t reset_mask) |
Resets the Tx module. More... | |
void | SAI_HAL_RxSetReset (I2S_Type *base, uint32_t reset_mask) |
Resets the Rx module. More... | |
static void | SAI_HAL_TxSetDataChn (I2S_Type *base, uint8_t fifo_channel) |
Sets the Tx FIFO channel. More... | |
static void | SAI_HAL_RxSetDataChn (I2S_Type *base, uint8_t fifo_channel) |
Sets the Rx FIFO channel. More... | |
void | SAI_HAL_TxSetRunModeCmd (I2S_Type *base, sai_run_mode_t run_mode, bool enable) |
Sets the running mode of the Tx. More... | |
void | SAI_HAL_RxSetRunModeCmd (I2S_Type *base, sai_run_mode_t run_mode, bool enable) |
Sets the running mode of the Rx. More... | |
static uint32_t | SAI_HAL_TxGetStateFlag (I2S_Type *base, uint32_t flag_mask) |
Gets the state of the flags in the TCSR. More... | |
static uint32_t | SAI_HAL_RxGetStateFlag (I2S_Type *base, uint32_t flag_mask) |
Gets the state of the flags in the RCSR. More... | |
static uint32_t | SAI_HAL_ReceiveData (I2S_Type *base, uint32_t rx_channel) |
Receives the data from the FIFO. More... | |
static void | SAI_HAL_SendData (I2S_Type *base, uint32_t tx_channel, uint32_t data) |
Transmits data to the FIFO. More... | |
void | SAI_HAL_ReceiveDataBlocking (I2S_Type *base, uint32_t rx_channel, uint8_t *rxBuff, uint32_t size) |
Uses blocking to receive data. More... | |
void | SAI_HAL_SendDataBlocking (I2S_Type *base, uint32_t tx_channel, uint8_t *txBuff, uint32_t size) |
Uses blocking to send data. More... | |
Module control | |
void | SAI_HAL_TxInit (I2S_Type *base) |
Initializes the SAI Tx. More... | |
void | SAI_HAL_RxInit (I2S_Type *base) |
Initializes the SAI Rx. More... | |
void | SAI_HAL_TxSetProtocol (I2S_Type *base, sai_protocol_t protocol) |
Sets Tx protocol relevant settings. More... | |
void | SAI_HAL_RxSetProtocol (I2S_Type *base, sai_protocol_t protocol) |
Sets Rx protocol relevant settings. More... | |
void | SAI_HAL_TxSetMasterSlave (I2S_Type *base, sai_master_slave_t master_slave_mode) |
Sets master or slave mode. More... | |
void | SAI_HAL_RxSetMasterSlave (I2S_Type *base, sai_master_slave_t master_slave_mode) |
Sets master or slave mode. More... | |
Overall Clock configuration | |
void | SAI_HAL_TxClockSetup (I2S_Type *base, sai_clock_setting_t *clk_config) |
Setup clock for SAI Tx. More... | |
void | SAI_HAL_RxClockSetup (I2S_Type *base, sai_clock_setting_t *clk_config) |
Setup clock for SAI Rx. More... | |
Master clock configuration | |
static void | SAI_HAL_SetMclkSrc (I2S_Type *base, sai_mclk_source_t source) |
Sets the master clock source. More... | |
static uint32_t | SAI_HAL_GetMclkSrc (I2S_Type *base) |
Gets the master clock source. More... | |
static void | SAI_HAL_SetMclkDividerCmd (I2S_Type *base, bool enable) |
Enable or disable MCLK internal. More... | |
Bit clock configuration | |
static void | SAI_HAL_TxSetBclkSrc (I2S_Type *base, sai_bclk_source_t source) |
Sets the bit clock source of Tx. More... | |
static void | SAI_HAL_RxSetBclkSrc (I2S_Type *base, sai_bclk_source_t source) |
Sets bit clock source of the Rx. More... | |
static uint32_t | SAI_HAL_TxGetBclkSrc (I2S_Type *base) |
Gets the bit clock source of Tx. More... | |
static uint32_t | SAI_HAL_RxGetBclkSrc (I2S_Type *base) |
Gets bit clock source of the Rx. More... | |
static void | SAI_HAL_TxSetBclkDiv (I2S_Type *base, uint32_t divider) |
Sets the Tx bit clock divider value. More... | |
static void | SAI_HAL_RxSetBclkDiv (I2S_Type *base, uint32_t divider) |
Sets the Rx bit clock divider value. More... | |
static void | SAI_HAL_TxSetBclkInputCmd (I2S_Type *base, bool enable) |
Enables or disables the Tx bit clock input bit. More... | |
static void | SAI_HAL_RxSetBclkInputCmd (I2S_Type *base, bool enable) |
Enables or disables the Rx bit clock input bit. More... | |
static void | SAI_HAL_TxSetSwapBclkCmd (I2S_Type *base, bool enable) |
Sets the Tx bit clock swap. More... | |
static void | SAI_HAL_RxSetSwapBclkCmd (I2S_Type *base, bool enable) |
Sets the Rx bit clock swap. More... | |
Mono or stereo configuration | |
void | SAI_HAL_TxSetMonoStereo (I2S_Type *base, sai_mono_stereo_t mono_stereo) |
Set Tx audio channel number. More... | |
void | SAI_HAL_RxSetMonoStereo (I2S_Type *base, sai_mono_stereo_t mono_stereo) |
Set Rx audio channel number. More... | |
Word configurations | |
void | SAI_HAL_TxSetWordWidth (I2S_Type *base, sai_protocol_t protocol, uint32_t bits) |
Set Tx word width. More... | |
void | SAI_HAL_RxSetWordWidth (I2S_Type *base, sai_protocol_t protocol, uint32_t bits) |
Set Rx word width. More... | |
void SAI_HAL_TxSetSyncMode | ( | I2S_Type * | base, |
sai_sync_mode_t | sync_mode | ||
) |
The mode can be asynchronous mode, synchronous, or synchronous with another SAI device. When configured for a synchronous mode of operation, the receiver must be configured for the asynchronous operation.
base | Register base address of SAI module. |
sync_mode | Synchronous mode or Asynchronous mode. |
void SAI_HAL_RxSetSyncMode | ( | I2S_Type * | base, |
sai_sync_mode_t | sync_mode | ||
) |
The mode can be asynchronous mode, synchronous, or synchronous with another SAI device. When configured for a synchronous mode of operation, the receiver must be configured for the asynchronous operation.
base | Register base address of SAI module. |
sync_mode | Synchronous mode or Asynchronous mode. |
|
inlinestatic |
This function determines the dest/src address of the DMA transfer.
base | Register base address of SAI module. |
fifo_channel | FIFO channel selected. |
|
inlinestatic |
This function determines the dest/src address of the DMA transfer.
base | Register base address of SAI module. |
fifo_channel | FIFO channel selected. |
|
inlinestatic |
Enables the Tx. This function enables both the bit clock and the transfer channel.
base | Register base address of SAI module. |
|
inlinestatic |
Enables the Rx. This function enables both the bit clock and the receive channel.
base | Register base address of SAI module. |
|
inlinestatic |
Disables the Tx. This function disables both the bit clock and the transfer channel.
base | Register base address of SAI module. |
|
inlinestatic |
Disables the Rx. This function disables both the bit clock and the receive channel.
base | Register base address of SAI module. |
void SAI_HAL_TxSetIntCmd | ( | I2S_Type * | base, |
uint32_t | source, | ||
bool | enable | ||
) |
The interrupt source can be : Word start flag, Sync error flag, FIFO error flag, FIFO warning flag, FIFO request flag. This function sets which flag causes an interrupt request.
base | Register base address of SAI module. |
source | SAI interrupt request source. |
enable | Enable or disable. |
void SAI_HAL_RxSetIntCmd | ( | I2S_Type * | base, |
uint32_t | source, | ||
bool | enable | ||
) |
The interrupt source can be : Word start flag, Sync error flag, FIFO error flag, FIFO warning flag, FIFO request flag. This function sets which flag causes an interrupt request.
base | Register base address of SAI module. |
source | SAI interrupt request source. |
enable | Enable or disable. |
void SAI_HAL_TxSetDmaCmd | ( | I2S_Type * | base, |
uint32_t | source, | ||
bool | enable | ||
) |
The DMA sources can be: FIFO warning and FIFO request. This function enables the DMA request from different DMA request sources.
base | Register base address of SAI module. |
source | SAI DMA request source. |
enable | Enable or disable. |
void SAI_HAL_RxSetDmaCmd | ( | I2S_Type * | base, |
uint32_t | source, | ||
bool | enable | ||
) |
The DMA sources can be: FIFO warning and FIFO request. This function enables the DMA request from different DMA request sources.
base | Register base address of SAI module. |
source | SAI DMA request source. |
enable | Enable or disable. |
void SAI_HAL_TxClearStateFlag | ( | I2S_Type * | base, |
uint32_t | flag_mask | ||
) |
The function is used to clear the flags manually. It can clear word start, FIFO warning, FIFO error, FIFO request flag.
base | Register base address of SAI module. |
flag | SAI state flag type. The flag can be word start, sync error, FIFO error/warning. |
void SAI_HAL_RxClearStateFlag | ( | I2S_Type * | base, |
uint32_t | flag_mask | ||
) |
The function is used to clear the flags manually. It can clear word start, FIFO warning, FIFO error, FIFO request flag.
base | Register base address of SAI module. |
flag | SAI state flag type. The flag can be word start, sync error, FIFO error/warning. |
void SAI_HAL_TxSetReset | ( | I2S_Type * | base, |
uint32_t | reset_mask | ||
) |
There are two kinds of resets: Software reset and FIFO reset. Software reset: resets all transmitter internal logic, including the bit clock generation, status flags and FIFO pointers. It does not reset the configuration registers. FIFO reset: synchronizes the FIFO write pointer to the same value as the FIFO read pointer. This empties the FIFO contents and is to be used after the Transmit FIFO Error Flag is set, and before the FIFO is re-initialized and the Error Flag is cleared.
base | Register base address of SAI module. |
type | SAI reset type. |
void SAI_HAL_RxSetReset | ( | I2S_Type * | base, |
uint32_t | reset_mask | ||
) |
There are two kinds of resets: Software reset and FIFO reset. Software reset: resets all transmitter internal logic, including the bit clock generation, status flags and FIFO pointers. It does not reset the configuration registers. FIFO reset: synchronizes the FIFO write pointer to the same value as the FIFO read pointer. This empties the FIFO contents and is to be used after the Transmit FIFO Error Flag is set, and before the FIFO is re-initialized and the Error Flag is cleared.
base | Register base address of SAI module. |
type | SAI reset type. |
|
inlinestatic |
A SAI base includes a Tx and an Rx. Each has several channels according to different platforms. A channel means a path for the audio data input/output.
base | Register base address of SAI module. |
fifo_channel | FIFO channel number. |
|
inlinestatic |
A SAI base includes a Tx and a Rx. Each has several channels according to different platforms. A channel means a path for the audio data input/output.
base | Register base address of SAI module. |
fifo_channel | FIFO channel number. |
void SAI_HAL_TxSetRunModeCmd | ( | I2S_Type * | base, |
sai_run_mode_t | run_mode, | ||
bool | enable | ||
) |
There is a debug mode, stop mode, and a normal mode.
This function can set the working mode of the SAI base. Stop mode is always used in low power cases, and the debug mode disables the SAI after the current transmit/receive is completed.
base | Register base address of SAI module. |
run_mode | SAI running mode. |
enable | Enable or disable a mode. |
void SAI_HAL_RxSetRunModeCmd | ( | I2S_Type * | base, |
sai_run_mode_t | run_mode, | ||
bool | enable | ||
) |
There is a debug mode, stop mode, and a normal mode.
This function can set the working mode of the SAI base. Stop mode is always used in low power cases, and the debug mode disables the SAI after the current transmit/receive is completed.
base | Register base address of SAI module. |
run_mode | SAI running mode. |
enable | Enable or disable a mode. |
|
inlinestatic |
base | Register base address of SAI module. |
flag | State flag type, it can be FIFO error, FIFO warning and so on. |
|
inlinestatic |
base | Register base address of SAI module. |
flag | State flag type, it can be FIFO error, FIFO warning and so on. |
|
inlinestatic |
base | Register base address of SAI module. |
rx_channel | Rx FIFO channel. |
data | Pointer to the address to be written in. |
|
inlinestatic |
base | Register base address of SAI module. |
tx_channel | Tx FIFO channel. |
data | Data value which needs to be written into FIFO. |
void SAI_HAL_ReceiveDataBlocking | ( | I2S_Type * | base, |
uint32_t | rx_channel, | ||
uint8_t * | rxBuff, | ||
uint32_t | size | ||
) |
base | The SAI base. |
rx_channel | Rx FIFO channel. |
void SAI_HAL_SendDataBlocking | ( | I2S_Type * | base, |
uint32_t | tx_channel, | ||
uint8_t * | txBuff, | ||
uint32_t | size | ||
) |
base | The SAI base. |
tx_channel | Tx FIFO channel. |
data | Data value which needs to be written into FIFO. |