I2S PAL

Detailed Description

Data Structures

struct  i2s_user_config_t
 I2S user configuration structure. More...
 

Enumerations

enum  i2s_transfer_type_t { I2S_USING_INTERRUPT = 0U, I2S_USING_DMA = 1U }
 Defines the transfer type. More...
 
enum  i2s_mode_t { I2S_MASTER = 0U, I2S_SLAVE = 1U }
 Master or slave. More...
 

Functions

status_t I2S_Init (const i2s_instance_t *instance, const i2s_user_config_t *config)
 Initializes the I2S module. More...
 
status_t I2S_Deinit (const i2s_instance_t *instance)
 De-initializes the I2S module. More...
 
status_t I2S_GetBaudRate (const i2s_instance_t *instance, uint32_t *configuredBaudRate)
 Returns the i2s baud rate. More...
 
status_t I2S_SetTxBuffer (const i2s_instance_t *instance, const uint8_t *txBuff, uint32_t txSize)
 Keep sending. More...
 
status_t I2S_SetRxBuffer (const i2s_instance_t *instance, uint8_t *rxBuff, uint32_t rxSize)
 Keep receiving. More...
 
status_t I2S_SendDataBlocking (const i2s_instance_t *instance, const uint8_t *txBuff, uint32_t txSize, uint32_t timeout)
 Perform a blocking I2S transmission. More...
 
status_t I2S_SendData (const i2s_instance_t *instance, const uint8_t *txBuff, uint32_t txSize)
 Perform a non-blocking I2S transmission. More...
 
status_t I2S_GetStatus (const i2s_instance_t *instance, uint32_t *countRemaining)
 Get the status of the current I2S transfer. More...
 
status_t I2S_ReceiveDataBlocking (const i2s_instance_t *instance, uint8_t *rxBuff, uint32_t rxSize, uint32_t timeout)
 Perform a blocking I2S reception. More...
 
status_t I2S_ReceiveData (const i2s_instance_t *instance, uint8_t *rxBuff, uint32_t rxSize)
 Perform a non-blocking I2S reception. More...
 
status_t I2S_Abort (const i2s_instance_t *instance)
 Terminates a non-blocking transfer early. More...
 

Enumeration Type Documentation

enum i2s_mode_t

Master or slave.

Implements : i2s_mode_t_Class

Enumerator
I2S_MASTER 

Generate bit clock and word select signal

I2S_SLAVE 

Receive bit clock and word select signal

Definition at line 51 of file i2s_pal.h.

Defines the transfer type.

Implements : i2s_transfer_type_t_Class

Enumerator
I2S_USING_INTERRUPT 

Driver uses interrupts for data transfers

I2S_USING_DMA 

Driver uses DMA for data transfers

Definition at line 40 of file i2s_pal.h.

Function Documentation

status_t I2S_Abort ( const i2s_instance_t instance)

Terminates a non-blocking transfer early.

Parameters
instanceInstance number

Definition at line 673 of file i2s_pal.c.

status_t I2S_Deinit ( const i2s_instance_t instance)

De-initializes the I2S module.

This function de-initializes the I2S module.

Parameters
[in]instanceInstance number

Definition at line 432 of file i2s_pal.c.

status_t I2S_GetBaudRate ( const i2s_instance_t instance,
uint32_t *  configuredBaudRate 
)

Returns the i2s baud rate.

This function returns the i2s configured baud rate, only call this when instance is configured as master.

Parameters
instanceInstance number.
[out]configuredBaudRateconfigured baud rate.
Returns
STATUS_SUCCESS

Definition at line 473 of file i2s_pal.c.

status_t I2S_GetStatus ( const i2s_instance_t instance,
uint32_t *  countRemaining 
)

Get the status of the current I2S transfer.

Parameters
instanceInstance number
countRemainingPointer to value that is populated with the number of words that have been sent in the active transfer
Returns
The transmit status.
Return values
STATUS_SUCCESSThe transmit has completed successfully.
STATUS_BUSYThe transmit is still in progress. will be filled with the number of words that have been transferred so far.
STATUS_I2S_ABORTEDThe transmit was aborted.
STATUS_TIMEOUTA timeout was reached.
STATUS_ERRORAn error occurred.

Definition at line 728 of file i2s_pal.c.

status_t I2S_Init ( const i2s_instance_t instance,
const i2s_user_config_t config 
)

Initializes the I2S module.

This function initializes and enables the requested I2S module. Note that when use I2S over SAI, tx and rx line are separated with SAI0, with other SAI instance tx and rx share one line.

Parameters
[in]instanceInstance number
[in]configThe configuration structure

Definition at line 269 of file i2s_pal.c.

status_t I2S_ReceiveData ( const i2s_instance_t instance,
uint8_t *  rxBuff,
uint32_t  rxSize 
)

Perform a non-blocking I2S reception.

This function receives a block of data and returns immediately. The rest of the transmission is handled by the interrupt service routine (if the driver is initialized in interrupt mode).

Parameters
[in]instanceInstance number
[in]rxBuffpointer to the data to be transferred
[in]rxSizelength in words of the data to be transferred

Definition at line 837 of file i2s_pal.c.

status_t I2S_ReceiveDataBlocking ( const i2s_instance_t instance,
uint8_t *  rxBuff,
uint32_t  rxSize,
uint32_t  timeout 
)

Perform a blocking I2S reception.

This function receives a block of data and only returns when the transmission is complete.

Parameters
[in]instanceInstance number
rxBuffpointer to the receive buffer
rxSizelength in words of the data to be received
timeouttimeout for the transfer in milliseconds
Returns
Error, success or timed out status

Definition at line 787 of file i2s_pal.c.

status_t I2S_SendData ( const i2s_instance_t instance,
const uint8_t *  txBuff,
uint32_t  txSize 
)

Perform a non-blocking I2S transmission.

This function sends a block of data and returns immediately. The rest of the transmission is handled by the interrupt service routine (if the driver is initialized in interrupt mode).

Parameters
[in]instanceInstance number
[in]txBuffpointer to the data to be transferred
[in]txSizelength in words of the data to be transferred

Definition at line 628 of file i2s_pal.c.

status_t I2S_SendDataBlocking ( const i2s_instance_t instance,
const uint8_t *  txBuff,
uint32_t  txSize,
uint32_t  timeout 
)

Perform a blocking I2S transmission.

This function sends a block of data and only returns when the transmission is complete.

Parameters
[in]instanceInstance number
[in]txBuffpointer to the data to be transferred
[in]txSizelength in words of the data to be transferred
[in]timeouttimeout value in milliseconds
Returns
Error, success or timed out status

Definition at line 505 of file i2s_pal.c.

status_t I2S_SetRxBuffer ( const i2s_instance_t instance,
uint8_t *  rxBuff,
uint32_t  rxSize 
)

Keep receiving.

This function must be called in callback function when RX_FULl event is reported to ensure rx operation working continuously.

Parameters
[in]instanceInstance number
[in]rxBuffpointer to the data to be transferred
[in]rxSizelength in words of the data to be transferred

Definition at line 551 of file i2s_pal.c.

status_t I2S_SetTxBuffer ( const i2s_instance_t instance,
const uint8_t *  txBuff,
uint32_t  txSize 
)

Keep sending.

This function must be called in callback function when TX_EMPTY event is reported to ensure tx operation working continuously.

Parameters
[in]instanceInstance number
[in]txBuffpointer to the data to be transferred
[in]txSizelength in words of the data to be transferred

Definition at line 590 of file i2s_pal.c.