Kinetis SDK v.1.3 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 transmit sync mode setting. More... | |
void | SAI_HAL_RxSetSyncMode (I2S_Type *base, sai_sync_mode_t sync_mode) |
SAI receive 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 transmit module. More... | |
static void | SAI_HAL_RxEnable (I2S_Type *base) |
Enables the SAI receive module. More... | |
static void | SAI_HAL_TxDisable (I2S_Type *base) |
Disables the transmit module. More... | |
static void | SAI_HAL_RxDisable (I2S_Type *base) |
Disables the receive module. More... | |
void | SAI_HAL_TxSetIntCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the transmit interrupt from different interrupt sources. More... | |
void | SAI_HAL_RxSetIntCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the receive interrupt from different interrupt sources. More... | |
void | SAI_HAL_TxSetDmaCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the transmit DMA request from different sources. More... | |
void | SAI_HAL_RxSetDmaCmd (I2S_Type *base, uint32_t source, bool enable) |
Enables the receive DMA request from different sources. More... | |
void | SAI_HAL_TxClearStateFlag (I2S_Type *base, uint32_t flag_mask) |
Clears the transmit state flags. More... | |
void | SAI_HAL_RxClearStateFlag (I2S_Type *base, uint32_t flag_mask) |
Clears the receive state flags. More... | |
void | SAI_HAL_TxSetReset (I2S_Type *base, uint32_t reset_mask) |
Resets the transmit module. More... | |
void | SAI_HAL_RxSetReset (I2S_Type *base, uint32_t reset_mask) |
Resets the receive module. More... | |
static void | SAI_HAL_TxSetDataChn (I2S_Type *base, uint8_t fifo_channel) |
Sets the transmit FIFO channel. More... | |
static void | SAI_HAL_RxSetDataChn (I2S_Type *base, uint8_t fifo_channel) |
Sets the receive FIFO channel. More... | |
void | SAI_HAL_TxSetRunModeCmd (I2S_Type *base, sai_run_mode_t run_mode, bool enable) |
Sets the running mode of the transmit. More... | |
void | SAI_HAL_RxSetRunModeCmd (I2S_Type *base, sai_run_mode_t run_mode, bool enable) |
Sets the running mode of the receive. 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 transmit. More... | |
void | SAI_HAL_RxInit (I2S_Type *base) |
Initializes the SAI receive. More... | |
void | SAI_HAL_TxSetProtocol (I2S_Type *base, sai_protocol_t protocol) |
Sets transmit protocol relevant settings. More... | |
void | SAI_HAL_RxSetProtocol (I2S_Type *base, sai_protocol_t protocol) |
Sets receive 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) |
Sets up the clock for the SAI transmit. More... | |
void | SAI_HAL_RxClockSetup (I2S_Type *base, sai_clock_setting_t *clk_config) |
Sets up the clock for the SAI receive. 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) |
Enables or disables the 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 transmit. More... | |
static void | SAI_HAL_RxSetBclkSrc (I2S_Type *base, sai_bclk_source_t source) |
Sets bit clock source of the receive. More... | |
static uint32_t | SAI_HAL_TxGetBclkSrc (I2S_Type *base) |
Gets the bit clock source of transmit. More... | |
static uint32_t | SAI_HAL_RxGetBclkSrc (I2S_Type *base) |
Gets bit clock source of the receive. More... | |
static void | SAI_HAL_TxSetBclkDiv (I2S_Type *base, uint32_t divider) |
Sets the transmit bit clock divider value. More... | |
static void | SAI_HAL_RxSetBclkDiv (I2S_Type *base, uint32_t divider) |
Sets the receive bit clock divider value. More... | |
static void | SAI_HAL_TxSetBclkInputCmd (I2S_Type *base, bool enable) |
Enables or disables the transmit bit clock input bit. More... | |
static void | SAI_HAL_RxSetBclkInputCmd (I2S_Type *base, bool enable) |
Enables or disables the receive bit clock input bit. More... | |
static void | SAI_HAL_TxSetSwapBclkCmd (I2S_Type *base, bool enable) |
Sets the transmit bit clock swap. More... | |
static void | SAI_HAL_RxSetSwapBclkCmd (I2S_Type *base, bool enable) |
Sets the receive bit clock swap. More... | |
Mono or stereo configuration | |
void | SAI_HAL_TxSetMonoStereo (I2S_Type *base, sai_mono_stereo_t mono_stereo) |
Sets the transmit audio channel number. More... | |
void | SAI_HAL_RxSetMonoStereo (I2S_Type *base, sai_mono_stereo_t mono_stereo) |
Sets the receive audio channel number. More... | |
Word configurations | |
void | SAI_HAL_TxSetWordWidth (I2S_Type *base, sai_protocol_t protocol, uint32_t bits) |
Sets the transmit word width. More... | |
void | SAI_HAL_RxSetWordWidth (I2S_Type *base, sai_protocol_t protocol, uint32_t bits) |
Sets the receive 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 destination/source address of the DMA transfer.
base | Register base address of SAI module. |
fifo_channel | FIFO channel selected. |
|
inlinestatic |
This function determines the destination/source address of the DMA transfer.
base | Register base address of SAI module. |
fifo_channel | FIFO channel selected. |
|
inlinestatic |
Enables the transmit. This function enables both the bit clock and the transfer channel.
base | Register base address of SAI module. |
|
inlinestatic |
Enables the receive. This function enables both the bit clock and the receive channel.
base | Register base address of SAI module. |
|
inlinestatic |
Disables the transmit. This function disables both the bit clock and the transfer channel.
base | Register base address of SAI module. |
|
inlinestatic |
Disables the receive. 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, and 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, and 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 clears the flags manually. It can clear word start, FIFO warning, FIFO error, and FIFO request flag.
base | Register base address of SAI module. |
flag_mask | 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, and FIFO request flag.
base | Register base address of SAI module. |
flag_mask | 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 reset: 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. |
reset_mask | SAI reset mask. |
void SAI_HAL_RxSetReset | ( | I2S_Type * | base, |
uint32_t | reset_mask | ||
) |
There are two kinds of reset: 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. |
reset_mask | SAI reset mask. |
|
inlinestatic |
A SAI base includes a transmit and an receive. 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 transmit and a receive. 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_mask | State flag type, it can be FIFO error, FIFO warning and so on. |
|
inlinestatic |
base | Register base address of SAI module. |
flag_mask | State flag type, it can be FIFO error, FIFO warning and so on. |
|
inlinestatic |
base | Register base address of SAI module. |
rx_channel | receive FIFO channel. |
data | Pointer to the address to be written in. |
|
inlinestatic |
base | Register base address of SAI module. |
tx_channel | transmit 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 | receive FIFO channel. |
rxBuff | receive data buffer. |
size | receive data size. |
void SAI_HAL_SendDataBlocking | ( | I2S_Type * | base, |
uint32_t | tx_channel, | ||
uint8_t * | txBuff, | ||
uint32_t | size | ||
) |
base | The SAI base. |
tx_channel | transmit FIFO channel. |
txBuff | transmit data buffer. |
size | transmit data size. |