The MCUXpresso SDK provides a peripheral driver for the Enhanced Serial Audio Interface (ESAI) module of MCUXpresso SDK devices.
ESAI driver includes functional APIs and transactional APIs.
Functional APIs are feature/property target low-level APIs. Functional APIs can be used for ESAI initialization/configuration/operation for optimization/customization purpose. Using the functional API requires the knowledge of the ESAI peripheral and how to organize functional APIs to meet the application requirements. All functional API use the peripheral base address as the first parameter. ESAI functional operation groups provide the functional API set.
Transactional APIs are transaction target high-level APIs. Transactional APIs can be used to enable the peripheral and in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are a critical requirement, see the transactional API implementation and write a custom code. All transactional APIs use the esai_handle_t as the first parameter. Initialize the handle by calling the ESAI_TransferTxCreateHandle() or ESAI_TransferRxCreateHandle() API.
Transactional APIs support asynchronous transfer. This means that the functions ESAI_TransferSendNonBlocking() and ESAI_TransferReceiveNonBlocking() set up the interrupt for data transfer. When the transfer completes, the upper layer is notified through a callback function with the kStatus_ESAI_TxIdle and kStatus_ESAI_RxIdle status.
Typical use case
ESAI Send/Receive using an interrupt method
esai_handle_t g_esaiTxHandle;
volatile bool txFinished;
volatile bool rxFinished;
const uint8_t sendData[] = [......];
void ESAI_UserCallback(esai_handle_t *handle, status_t status, void *userData)
{
userData = userData;
{
txFinished = true;
}
}
void main(void)
{
ESAI_TxGetDefaultConfig(&user_config);
ESAI_TxInit(ESAI0, &user_config);
ESAI_TransferTxSetTransferFormat(ESAI0, &g_esaiHandle, mclkSource, mclk);
sendXfer.
dataSize =
sizeof(sendData)/
sizeof(sendData[0]);
txFinished = false;
while (!txFinished)
{
}
}
ESAI Send/receive using a DMA method
esai_handle_t g_esaiHandle;
dma_handle_t g_esaiTxDmaHandle;
dma_handle_t g_esaiRxDmaHandle;
volatile bool txFinished;
uint8_t sendData[] = ...;
void ESAI_UserCallback(esai_handle_t *handle, status_t status, void *userData)
{
userData = userData;
{
txFinished = true;
}
}
void main(void)
{
ESAI_TxGetDefaultConfig(&user_config);
ESAI_TxInit(ESAI0, &user_config);
DMA_Init(DMA0);
DMA_CreateHandle(&g_esaiTxDmaHandle, DMA0, ESAI_TX_DMA_CHANNEL);
ESAI_TransferTxCreateHandleDMA(ESAI0, &g_esaiTxDmaHandle, ESAI_UserCallback, NULL);
sendXfer.
dataSize =
sizeof(sendData)/
sizeof(sendData[0]);
txFinished = false;
ESAI_TransferSendDMA(&g_esaiHandle, &sendXfer);
while (!txFinished)
{
}
}
|
typedef void(* | esai_transfer_callback_t )(ESAI_Type *base, esai_handle_t *handle, status_t status, void *userData) |
| ESAI transfer callback prototype.
|
|
|
enum | _esai_status_t {
kStatus_ESAI_TxBusy = MAKE_STATUS(kStatusGroup_ESAI, 0),
kStatus_ESAI_RxBusy = MAKE_STATUS(kStatusGroup_ESAI, 1),
kStatus_ESAI_TxError = MAKE_STATUS(kStatusGroup_ESAI, 2),
kStatus_ESAI_RxError = MAKE_STATUS(kStatusGroup_ESAI, 3),
kStatus_ESAI_QueueFull = MAKE_STATUS(kStatusGroup_ESAI, 4),
kStatus_ESAI_TxIdle = MAKE_STATUS(kStatusGroup_ESAI, 5),
kStatus_ESAI_RxIdle = MAKE_STATUS(kStatusGroup_ESAI, 6)
} |
| ESAI return status. More...
|
|
enum | esai_mode_t {
kESAI_NormalMode = 0x0U,
kESAI_NetworkMode
} |
| Define the ESAI bus type. More...
|
|
enum | esai_protocol_t {
kESAI_BusLeftJustified = 0x0U,
kESAI_BusRightJustified,
kESAI_BusI2S,
kESAI_BusPCMA,
kESAI_BusPCMB,
kESAI_BusTDM,
kESAI_BusCustomerNormal,
kESAI_BusCustomerNetwork
} |
| Define the ESAI bus type. More...
|
|
enum | esai_master_slave_t {
kESAI_Master = 0x0U,
kESAI_Slave = 0x1U
} |
| Master or slave mode. More...
|
|
enum | esai_sync_mode_t {
kESAI_ModeAsync = 0x0U,
kESAI_ModeSync
} |
| Synchronous or asynchronous mode. More...
|
|
enum | esai_hclk_source_t { ,
kESAI_rxHckSourceInternal = ESAI_ECR_ERI_MASK,
kESAI_rxHckSourceExternal = ESAI_ECR_ERO_MASK
} |
| Mater clock source. More...
|
|
enum | esai_clock_polarity_t {
kESAI_ClockActiveHigh = 0x0U,
kESAI_ClockActiveLow
} |
| Bit clock source. More...
|
|
enum | esai_shift_direction_t {
kESAI_ShifterMSB = 0x0,
kESAI_ShifterLSB = 0x1
} |
|
enum | esai_clock_direction_t {
kESAI_ClockInput = 0x0,
kESAI_ClockOutput = 0x1
} |
|
enum | _esai_interrupt_enable_t {
kESAI_LastSlotInterruptEnable,
kESAI_TransmitInterruptEnable = ESAI_TCR_TIE_MASK,
kESAI_EvenSlotDataInterruptEnable = ESAI_TCR_TEDIE_MASK,
kESAI_ExceptionInterruptEnable = ESAI_TCR_TEIE_MASK
} |
| The ESAI interrupt enable flag. More...
|
|
enum | _esai_flags {
kESAI_TransmitInitFlag = ESAI_ESR_TINIT_MASK,
kESAI_ReceiveFIFOFullFlag = ESAI_ESR_RFF_MASK,
kESAI_TransmitFIFOEmptyFlag = ESAI_ESR_TFE_MASK,
kESAI_TransmitLastSlotFlag = ESAI_ESR_TLS_MASK,
kESAI_TransmitDataExceptionFlag = ESAI_ESR_TDE_MASK,
kESAI_TransmitEvenDataFlag = ESAI_ESR_TED_MASK,
kESAI_TransmitDataFlag = ESAI_ESR_TD_MASK,
kESAI_ReceiveLastSlot = ESAI_ESR_RLS_MASK,
kESAI_ReceiveDataException = ESAI_ESR_RDE_MASK,
kESAI_ReceiveEvenData = ESAI_ESR_RED_MASK,
kESAI_ReceiveData = ESAI_ESR_RD_MASK
} |
| The ESAI status flag. More...
|
|
enum | _esai_sai_flags {
kESAI_TransmitOddRegEmpty = ESAI_SAISR_TODFE_MASK,
kESAI_TransmitEvenRegEmpty = ESAI_SAISR_TEDE_MASK,
kESAI_TransmitRegEmpty = ESAI_SAISR_TDE_MASK,
kESAI_TransmitUnderrunError = ESAI_SAISR_TUE_MASK,
kESAI_TransmitFrameSync = ESAI_SAISR_TFS_MASK,
kESAI_RecceiveOddRegFull = ESAI_SAISR_RODF_MASK,
kESAI_ReceiveEvenRegFull = ESAI_SAISR_RDF_MASK,
kESAI_RecceiveOverrunError = ESAI_SAISR_ROE_MASK,
kESAI_ReceiveFrameSync = ESAI_SAISR_RFS_MASK,
kESAI_SerialInputFlag2 = ESAI_SAISR_IF2_MASK,
kESAI_SerialInputFlag1 = ESAI_SAISR_IF1_MASK,
kESAI_SerialInputFlag0 = ESAI_SAISR_IF0_MASK
} |
| SAI interface port status flag. More...
|
|
enum | esai_sample_rate_t {
kESAI_SampleRate8KHz = 8000U,
kESAI_SampleRate11025Hz = 11025U,
kESAI_SampleRate12KHz = 12000U,
kESAI_SampleRate16KHz = 16000U,
kESAI_SampleRate22050Hz = 22050U,
kESAI_SampleRate24KHz = 24000U,
kESAI_SampleRate32KHz = 32000U,
kESAI_SampleRate44100Hz = 44100U,
kESAI_SampleRate48KHz = 48000U,
kESAI_SampleRate96KHz = 96000U
} |
| Audio sample rate. More...
|
|
enum | esai_word_width_t {
kESAI_WordWidth8bits = 8U,
kESAI_WordWidth16bits = 16U,
kESAI_WordWidth24bits = 24U,
kESAI_WordWidth32bits = 32U
} |
| Audio word width. More...
|
|
enum | esai_slot_format_t {
kESAI_SlotLen8WordLen8 = 0x0U,
kESAI_SlotLen12WordLen8 = 0x04U,
kESAI_SlotLen12WordLen12 = 0x01U,
kESAI_SlotLen16WordLen8 = 0x08U,
kESAI_SlotLen16WordLen12 = 0x05U,
kESAI_SlotLen16WordLen16 = 0x02U,
kESAI_SlotLen20WordLen8 = 0x0CU,
kESAI_SlotLen20WordLen12 = 0x09U,
kESAI_SlotLen20WordLen16 = 0x06U,
kESAI_SlotLen20WordLen20 = 0x03U,
kESAI_SlotLen24WordLen8 = 0x10U,
kESAI_SlotLen24WordLen12 = 0x0DU,
kESAI_SlotLen24WordLen16 = 0x0AU,
kESAI_SlotLen24WordLen20 = 0x07U,
kESAI_SlotLen24WordLen24 = 0x1EU,
kESAI_SlotLen32WordLen8 = 0x18U,
kESAI_SlotLen32WordLen12 = 0x15U,
kESAI_SlotLen32WordLen16 = 0x12U,
kESAI_SlotLen32WordLen20 = 0x0FU,
kESAI_SlotLen32WordLen24 = 0x1FU
} |
|
|
void | ESAI_TxSetFormat (ESAI_Type *base, esai_format_t *format, uint32_t hckClockHz, uint32_t hckSourceClockHz) |
| Configures the ESAI Tx audio format. More...
|
|
void | ESAI_RxSetFormat (ESAI_Type *base, esai_format_t *format, uint32_t hckClockHz, uint32_t hckSourceClockHz) |
| Configures the ESAI Rx audio format. More...
|
|
void | ESAI_WriteBlocking (ESAI_Type *base, uint32_t bitWidth, uint8_t *buffer, uint32_t size) |
| Sends data using a blocking method. More...
|
|
static void | ESAI_WriteData (ESAI_Type *base, uint32_t data) |
| Writes data into ESAI FIFO. More...
|
|
void | ESAI_ReadBlocking (ESAI_Type *base, uint32_t bitWidth, uint8_t *buffer, uint32_t size) |
| Receives data using a blocking method. More...
|
|
static uint32_t | ESAI_ReadData (ESAI_Type *base, uint32_t channel) |
| Reads data from ESAI FIFO. More...
|
|
|
void | ESAI_TransferTxCreateHandle (ESAI_Type *base, esai_handle_t *handle, esai_transfer_callback_t callback, void *userData) |
| Initializes the ESAI Tx handle. More...
|
|
void | ESAI_TransferRxCreateHandle (ESAI_Type *base, esai_handle_t *handle, esai_transfer_callback_t callback, void *userData) |
| Initializes the ESAI Rx handle. More...
|
|
status_t | ESAI_TransferTxSetFormat (ESAI_Type *base, esai_handle_t *handle, esai_format_t *format, uint32_t hckClockHz, uint32_t hckSourceClockHz) |
| Configures the ESAI Tx audio format. More...
|
|
status_t | ESAI_TransferRxSetFormat (ESAI_Type *base, esai_handle_t *handle, esai_format_t *format, uint32_t hckClockHz, uint32_t hckSourceClockHz) |
| Configures the ESAI Rx audio format. More...
|
|
status_t | ESAI_TransferSendNonBlocking (ESAI_Type *base, esai_handle_t *handle, esai_transfer_t *xfer) |
| Performs an interrupt non-blocking send transfer on ESAI. More...
|
|
status_t | ESAI_TransferReceiveNonBlocking (ESAI_Type *base, esai_handle_t *handle, esai_transfer_t *xfer) |
| Performs an interrupt non-blocking receive transfer on ESAI. More...
|
|
status_t | ESAI_TransferGetSendCount (ESAI_Type *base, esai_handle_t *handle, size_t *count) |
| Gets a set byte count. More...
|
|
status_t | ESAI_TransferGetReceiveCount (ESAI_Type *base, esai_handle_t *handle, size_t *count) |
| Gets a received byte count. More...
|
|
void | ESAI_TransferAbortSend (ESAI_Type *base, esai_handle_t *handle) |
| Aborts the current send. More...
|
|
void | ESAI_TransferAbortReceive (ESAI_Type *base, esai_handle_t *handle) |
| Aborts the the current IRQ receive. More...
|
|
void | ESAI_TransferTxHandleIRQ (ESAI_Type *base, esai_handle_t *handle) |
| Tx interrupt handler. More...
|
|
void | ESAI_TransferRxHandleIRQ (ESAI_Type *base, esai_handle_t *handle) |
| Tx interrupt handler. More...
|
|
struct esai_customer_protocol_t |
uint8_t* esai_transfer_t::data |
size_t esai_transfer_t::dataSize |
#define ESAI_XFER_QUEUE_SIZE (4) |
Enumerator |
---|
kStatus_ESAI_TxBusy |
ESAI Tx is busy.
|
kStatus_ESAI_RxBusy |
ESAI Rx is busy.
|
kStatus_ESAI_TxError |
ESAI Tx FIFO error.
|
kStatus_ESAI_RxError |
ESAI Rx FIFO error.
|
kStatus_ESAI_QueueFull |
ESAI transfer queue is full.
|
kStatus_ESAI_TxIdle |
ESAI Tx is idle.
|
kStatus_ESAI_RxIdle |
ESAI Rx is idle.
|
Enumerator |
---|
kESAI_NormalMode |
Use normal mode.
|
kESAI_NetworkMode |
Network mode.
|
Enumerator |
---|
kESAI_BusLeftJustified |
Uses left justified format.
|
kESAI_BusRightJustified |
Uses right justified format.
|
kESAI_BusI2S |
Uses I2S format.
|
kESAI_BusPCMA |
Uses I2S PCM A format.
|
kESAI_BusPCMB |
Uses I2S PCM B format.
|
kESAI_BusTDM |
Use TDM mode.
|
kESAI_BusCustomerNormal |
Customer defined normal mode.
|
kESAI_BusCustomerNetwork |
Customer defined network mode.
|
Enumerator |
---|
kESAI_Master |
Master mode.
|
kESAI_Slave |
Slave mode.
|
Enumerator |
---|
kESAI_ModeAsync |
Asynchronous mode.
|
kESAI_ModeSync |
Synchronous mode (with receiver or transmit)
|
Enumerator |
---|
kESAI_rxHckSourceInternal |
Rx HCK source is ESAI internal clock.
|
kESAI_rxHckSourceExternal |
Rx HCK source is external.
|
Enumerator |
---|
kESAI_ClockActiveHigh |
Clock active while high.
|
kESAI_ClockActiveLow |
Clock actie while low.
|
Enumerator |
---|
kESAI_ShifterMSB |
Data is shifted MSB first.
|
kESAI_ShifterLSB |
Data is shifted LSB first.
|
Enumerator |
---|
kESAI_ClockInput |
Clock direction is input.
|
kESAI_ClockOutput |
Clock direction is output.
|
Enumerator |
---|
kESAI_LastSlotInterruptEnable |
Enable interrupt at the beginning of last slot of frame in network mode.
|
kESAI_TransmitInterruptEnable |
Transmit/receive even slot data interrupt.
|
kESAI_EvenSlotDataInterruptEnable |
Transmit/receive even slot data interrupt.
|
kESAI_ExceptionInterruptEnable |
FIFO error flag.
|
Enumerator |
---|
kESAI_TransmitInitFlag |
Indicates transmit FIFO is writing the first word.
|
kESAI_ReceiveFIFOFullFlag |
Receive FIFO full flag.
|
kESAI_TransmitFIFOEmptyFlag |
Transmit FIFO empty.
|
kESAI_TransmitLastSlotFlag |
Transmit last slot.
|
kESAI_TransmitDataExceptionFlag |
Transmit data exception.
|
kESAI_TransmitEvenDataFlag |
Transmit even data.
|
kESAI_TransmitDataFlag |
Transmit data.
|
kESAI_ReceiveLastSlot |
Receive last slot.
|
kESAI_ReceiveDataException |
Receive data exception.
|
kESAI_ReceiveEvenData |
Receive even data.
|
kESAI_ReceiveData |
Receive data.
|
Enumerator |
---|
kESAI_TransmitOddRegEmpty |
Enabled transmitter register empty at odd slot.
|
kESAI_TransmitEvenRegEmpty |
Enabled transmitter register empty at even slot.
|
kESAI_TransmitRegEmpty |
All data in enabled transmitter regsiter send to shifter.
|
kESAI_TransmitUnderrunError |
Serial shifter empty and a transmit slot begins.
|
kESAI_TransmitFrameSync |
A transmit frame sync occurred in the current time slot.
|
kESAI_RecceiveOddRegFull |
Enabled receiver register full at odd slot.
|
kESAI_ReceiveEvenRegFull |
Enabled receiver register full at even slot.
|
kESAI_RecceiveOverrunError |
Receive data register overrun flag.
|
kESAI_ReceiveFrameSync |
Receive frame sync flag, indicate a frame sync occurs.
|
kESAI_SerialInputFlag2 |
Serial input flag 2.
|
kESAI_SerialInputFlag1 |
Serial in out flag 1.
|
kESAI_SerialInputFlag0 |
Serial input flag 0.
|
Enumerator |
---|
kESAI_SampleRate8KHz |
Sample rate 8000 Hz.
|
kESAI_SampleRate11025Hz |
Sample rate 11025 Hz.
|
kESAI_SampleRate12KHz |
Sample rate 12000 Hz.
|
kESAI_SampleRate16KHz |
Sample rate 16000 Hz.
|
kESAI_SampleRate22050Hz |
Sample rate 22050 Hz.
|
kESAI_SampleRate24KHz |
Sample rate 24000 Hz.
|
kESAI_SampleRate32KHz |
Sample rate 32000 Hz.
|
kESAI_SampleRate44100Hz |
Sample rate 44100 Hz.
|
kESAI_SampleRate48KHz |
Sample rate 48000 Hz.
|
kESAI_SampleRate96KHz |
Sample rate 96000 Hz.
|
Enumerator |
---|
kESAI_WordWidth8bits |
Audio data width 8 bits.
|
kESAI_WordWidth16bits |
Audio data width 16 bits.
|
kESAI_WordWidth24bits |
Audio data width 24 bits.
|
kESAI_WordWidth32bits |
Audio data width 32 bits.
|
Enumerator |
---|
kESAI_SlotLen8WordLen8 |
Slot length 8 bits, word length 8 bits.
|
kESAI_SlotLen12WordLen8 |
Slot length 12 bits, word length 8 bits.
|
kESAI_SlotLen12WordLen12 |
Slot length 12 bits, word length 12 bits.
|
kESAI_SlotLen16WordLen8 |
Slot length 16 bits, word length 8 bits.
|
kESAI_SlotLen16WordLen12 |
Slot length 16 bits, word length 12 bits.
|
kESAI_SlotLen16WordLen16 |
Slot length 16 bits, word length 16 bits.
|
kESAI_SlotLen20WordLen8 |
Slot length 20 bits, word length 8 bits.
|
kESAI_SlotLen20WordLen12 |
Slot length 20 bits, word length 12 bits.
|
kESAI_SlotLen20WordLen16 |
Slot length 20 bits, word length 16 bits.
|
kESAI_SlotLen20WordLen20 |
Slot length 20 bits, word length 20 bits.
|
kESAI_SlotLen24WordLen8 |
Slot length 24 bits, word length 8 bits.
|
kESAI_SlotLen24WordLen12 |
Slot length 24 bits, word length 12 bits.
|
kESAI_SlotLen24WordLen16 |
Slot length 24 bits, word length 16 bits.
|
kESAI_SlotLen24WordLen20 |
Slot length 24 bits, word length 20 bits.
|
kESAI_SlotLen24WordLen24 |
Slot length 24 bits, word length 24 bits.
|
kESAI_SlotLen32WordLen8 |
Slot length 32 bits, word length 8 bits.
|
kESAI_SlotLen32WordLen12 |
Slot length 32 bits, word length 12 bits.
|
kESAI_SlotLen32WordLen16 |
Slot length 32 bits, word length 16 bits.
|
kESAI_SlotLen32WordLen20 |
Slot length 32 bits, word length 20 bits.
|
kESAI_SlotLen32WordLen24 |
Slot length 32 bits, word length 24 bits.
|
Ungates the ESAI clock, resets the module, and configures ESAI with a configuration structure. The configuration structure can be custom filled or set with default values by ESAI_GetDefaultConfig().
- Note
- This API should be called at the beginning of the application to use the ESAI driver. Otherwise, accessing the ESAI module can cause a hard fault because the clock is not enabled.
- Parameters
-
base | ESAI base pointer |
config | ESAI configuration structure. |
This API initializes the configuration structure for use in ESAI_TxConfig(). The initialized structure can remain unchanged in ESAI_Init(), or it can be modified before calling ESAI_Init().
- Parameters
-
config | pointer to master configuration structure |
void ESAI_Deinit |
( |
ESAI_Type * |
base | ) |
|
This API gates the ESAI clock. The ESAI module can't operate unless ESAI_Init is called to enable the clock.
- Parameters
-
static void ESAI_Enable |
( |
ESAI_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
enable | True meanse enable, false means disable. |
static void ESAI_Reset |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
This API only resets the core logic, including the configuration registers, but not the ESAI FIFOs, users still needs to reset the ESAI fifo by calling ESAI_TxResetFIFO and ESAI_RxResetFIFO.
- Parameters
-
void ESAI_TxReset |
( |
ESAI_Type * |
base | ) |
|
This API only resets the core logic of tx and all tx sections.
- Parameters
-
void ESAI_RxReset |
( |
ESAI_Type * |
base | ) |
|
This API only resets the core logic of rx and all rx sections.
- Parameters
-
static void ESAI_TxResetFIFO |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
This function only resets the ESAI Tx FIFO.
- Parameters
-
static void ESAI_RxResetFIFO |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
This function only resets the ESAI Rx FIFO.
- Parameters
-
void ESAI_TxEnable |
( |
ESAI_Type * |
base, |
|
|
uint8_t |
sectionMap |
|
) |
| |
- Parameters
-
base | ESAI base pointer |
sectionMap | Which sections need to be enabled. 0 means all section disabled. This parameter can be a combination of each sections, every section N is 2^N in section map. |
void ESAI_RxEnable |
( |
ESAI_Type * |
base, |
|
|
uint8_t |
sectionMap |
|
) |
| |
- Parameters
-
base | ESAI base pointer |
sectionMap | Which sections need to be enabled. 0 means all section disabled. This parameter can be a combination of each sections, every section N is 2^N in section map. |
static void ESAI_TxEnableFIFO |
( |
ESAI_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
enable | True means enable ESAI Tx, false means disable. |
static void ESAI_RxEnableFIFO |
( |
ESAI_Type * |
base, |
|
|
bool |
enable |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
enable | True means enable ESAI Rx, false means disable. |
static void ESAI_TxSetSlotMask |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
slot |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
slot | Slot number need to be masked for Tx. |
static void EASI_RxSetSlotMask |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
slot |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
slot | Slot number need to be masked for Rx |
static uint32_t ESAI_GetStatusFlag |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- ESAI staus flag value. Use status flag to AND _esai_flags to get the related status.
static uint32_t ESAI_GetSAIStatusFlag |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- ESAI staus flag value. Use status flag to AND _esai_sai_flags to get the related status.
static uint32_t ESAI_GetTxFIFOStatus |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- ESAI Tx status flag value.
static uint32_t ESAI_GetRxFIFOStatus |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
- Parameters
-
- Returns
- ESAI Rx status flag value.
static void ESAI_TxEnableInterrupts |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
mask | interrupt source. The parameter can be a combination of elements in _esai_interrupt_enable_t. |
static void ESAI_RxEnableInterrupts |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
mask | interrupt source. The parameter can be a combination of elements in _esai_interrupt_enable_t. |
static void ESAI_TxDisableInterrupts |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
mask | interrupt source. The parameter can be a combination of elements in _esai_interrupt_enable_t. |
static void ESAI_RxDisableInterrupts |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
mask |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer |
mask | interrupt source. The parameter can be a combination of elements in _esai_interrupt_enable_t. |
static uint32_t ESAI_TxGetDataRegisterAddress |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
This API is used to provide a transfer address for ESAI DMA transfer configuration.
- Parameters
-
- Returns
- data register address.
static uint32_t ESAI_RxGetDataRegisterAddress |
( |
ESAI_Type * |
base | ) |
|
|
inlinestatic |
This API is used to provide a transfer address for ESAI DMA transfer configuration.
- Parameters
-
- Returns
- data register address.
void ESAI_TxSetFormat |
( |
ESAI_Type * |
base, |
|
|
esai_format_t * |
format, |
|
|
uint32_t |
hckClockHz, |
|
|
uint32_t |
hckSourceClockHz |
|
) |
| |
The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.
- Parameters
-
base | ESAI base pointer. |
format | Pointer to ESAI audio data format structure. |
hckClockHz | HCK clock frequency in Hz. |
hckSourceClockHz | HCK source clock frequency in Hz. |
void ESAI_RxSetFormat |
( |
ESAI_Type * |
base, |
|
|
esai_format_t * |
format, |
|
|
uint32_t |
hckClockHz, |
|
|
uint32_t |
hckSourceClockHz |
|
) |
| |
The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.
- Parameters
-
base | ESAI base pointer. |
format | Pointer to ESAI audio data format structure. |
hckClockHz | HCK clock frequency in Hz. |
hckSourceClockHz | HCK source clock frequency in Hz. |
void ESAI_WriteBlocking |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
bitWidth, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
size |
|
) |
| |
- Note
- This function blocks by polling until data is ready to be sent.
- Parameters
-
base | ESAI base pointer. |
bitWidth | How many bits in a audio word, usually 8/16/24 bits. |
buffer | Pointer to the data to be written. |
size | Bytes to be written. |
static void ESAI_WriteData |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
data |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer. |
data | Data needs to be written. |
void ESAI_ReadBlocking |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
bitWidth, |
|
|
uint8_t * |
buffer, |
|
|
uint32_t |
size |
|
) |
| |
- Note
- This function blocks by polling until data is ready to be sent.
- Parameters
-
base | ESAI base pointer. |
bitWidth | How many bits in a audio word, usually 8/16/24 bits. |
buffer | Pointer to the data to be read. |
size | Bytes to be read. |
static uint32_t ESAI_ReadData |
( |
ESAI_Type * |
base, |
|
|
uint32_t |
channel |
|
) |
| |
|
inlinestatic |
- Parameters
-
base | ESAI base pointer. |
channel | Data channel used. |
- Returns
- Data in ESAI FIFO.
void ESAI_TransferTxCreateHandle |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_transfer_callback_t |
callback, |
|
|
void * |
userData |
|
) |
| |
This function initializes the Tx handle for ESAI Tx transactional APIs. Call this function one time to get the handle initialized.
- Parameters
-
base | ESAI base pointer |
handle | ESAI handle pointer. |
callback | pointer to user callback function |
userData | user parameter passed to the callback function |
void ESAI_TransferRxCreateHandle |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_transfer_callback_t |
callback, |
|
|
void * |
userData |
|
) |
| |
This function initializes the Rx handle for ESAI Rx transactional APIs. Call this function one time to get the handle initialized.
- Parameters
-
base | ESAI base pointer. |
handle | ESAI handle pointer. |
callback | pointer to user callback function |
userData | user parameter passed to the callback function |
status_t ESAI_TransferTxSetFormat |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_format_t * |
format, |
|
|
uint32_t |
hckClockHz, |
|
|
uint32_t |
hckSourceClockHz |
|
) |
| |
The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.
- Parameters
-
base | ESAI base pointer. |
handle | ESAI handle pointer. |
format | Pointer to ESAI audio data format structure. |
hckClockHz | HCK clock frequency in Hz. |
hckSourceClockHz | HCK clock source frequency in Hz. |
- Returns
- Status of this function. Return value is one of status_t.
status_t ESAI_TransferRxSetFormat |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_format_t * |
format, |
|
|
uint32_t |
hckClockHz, |
|
|
uint32_t |
hckSourceClockHz |
|
) |
| |
The audio format can be changed at run-time. This function configures the sample rate and audio data format to be transferred.
- Parameters
-
base | ESAI base pointer. |
handle | ESAI handle pointer. |
format | Pointer to ESAI audio data format structure. |
hckClockHz | HCK clock frequency in Hz. |
hckSourceClockHz | HCK clock source frequency in Hz. |
- Returns
- Status of this function. Return value is one of status_t.
status_t ESAI_TransferSendNonBlocking |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_transfer_t * |
xfer |
|
) |
| |
- Note
- This API returns immediately after the transfer initiates. Call the ESAI_TxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_ESAI_Busy, the transfer is finished.
- Parameters
-
base | ESAI base pointer |
handle | pointer to esai_handle_t structure which stores the transfer state |
xfer | pointer to esai_transfer_t structure |
- Return values
-
kStatus_Success | Successfully started the data receive. |
kStatus_ESAI_TxBusy | Previous receive still not finished. |
kStatus_InvalidArgument | The input parameter is invalid. |
status_t ESAI_TransferReceiveNonBlocking |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
esai_transfer_t * |
xfer |
|
) |
| |
- Note
- This API returns immediately after the transfer initiates. Call the ESAI_RxGetTransferStatusIRQ to poll the transfer status and check whether the transfer is finished. If the return status is not kStatus_ESAI_Busy, the transfer is finished.
- Parameters
-
base | ESAI base pointer |
handle | pointer to esai_handle_t structure which stores the transfer state |
xfer | pointer to esai_transfer_t structure |
- Return values
-
kStatus_Success | Successfully started the data receive. |
kStatus_ESAI_RxBusy | Previous receive still not finished. |
kStatus_InvalidArgument | The input parameter is invalid. |
status_t ESAI_TransferGetSendCount |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
size_t * |
count |
|
) |
| |
- Parameters
-
base | ESAI base pointer. |
handle | pointer to esai_handle_t structure which stores the transfer state. |
count | Bytes count sent. |
- Return values
-
kStatus_Success | Succeed get the transfer count. |
kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress. |
status_t ESAI_TransferGetReceiveCount |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle, |
|
|
size_t * |
count |
|
) |
| |
- Parameters
-
base | ESAI base pointer. |
handle | pointer to esai_handle_t structure which stores the transfer state. |
count | Bytes count received. |
- Return values
-
kStatus_Success | Succeed get the transfer count. |
kStatus_NoTransferInProgress | There is not a non-blocking transaction currently in progress. |
void ESAI_TransferAbortSend |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle |
|
) |
| |
- Note
- This API can be called any time when an interrupt non-blocking transfer initiates to abort the transfer early.
- Parameters
-
base | ESAI base pointer. |
handle | pointer to esai_handle_t structure which stores the transfer state. |
void ESAI_TransferAbortReceive |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle |
|
) |
| |
- Note
- This API can be called any time when an interrupt non-blocking transfer initiates to abort the transfer early.
- Parameters
-
base | ESAI base pointer |
handle | pointer to esai_handle_t structure which stores the transfer state. |
void ESAI_TransferTxHandleIRQ |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ESAI base pointer. |
handle | pointer to esai_handle_t structure. |
void ESAI_TransferRxHandleIRQ |
( |
ESAI_Type * |
base, |
|
|
esai_handle_t * |
handle |
|
) |
| |
- Parameters
-
base | ESAI base pointer. |
handle | pointer to esai_handle_t structure. |