MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
Files | |
file | fsl_i2s.h |
Data Structures | |
struct | i2s_config_t |
I2S configuration structure. More... | |
struct | i2s_transfer_t |
Buffer to transfer from or receive audio data into. More... | |
struct | i2s_handle_t |
Members not to be accessed / modified outside of the driver. More... | |
Macros | |
#define | I2S_NUM_BUFFERS (4) |
Number of buffers . More... | |
Typedefs | |
typedef void(* | i2s_transfer_callback_t )(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData) |
Callback function invoked from transactional API on completion of a single buffer transfer. More... | |
Enumerations | |
enum | _i2s_status { kStatus_I2S_BufferComplete, kStatus_I2S_Done = MAKE_STATUS(kStatusGroup_I2S, 1), kStatus_I2S_Busy } |
I2S status codes. More... | |
enum | i2s_flags_t { kI2S_TxErrorFlag = I2S_FIFOINTENSET_TXERR_MASK, kI2S_TxLevelFlag = I2S_FIFOINTENSET_TXLVL_MASK, kI2S_RxErrorFlag = I2S_FIFOINTENSET_RXERR_MASK, kI2S_RxLevelFlag = I2S_FIFOINTENSET_RXLVL_MASK } |
I2S flags. More... | |
enum | i2s_master_slave_t { kI2S_MasterSlaveNormalSlave = 0x0, kI2S_MasterSlaveWsSyncMaster = 0x1, kI2S_MasterSlaveExtSckMaster = 0x2, kI2S_MasterSlaveNormalMaster = 0x3 } |
Master / slave mode. More... | |
enum | i2s_mode_t { kI2S_ModeI2sClassic = 0x0, kI2S_ModeDspWs50 = 0x1, kI2S_ModeDspWsShort = 0x2, kI2S_ModeDspWsLong = 0x3 } |
I2S mode. More... | |
enum | _i2s_secondary_channel { kI2S_SecondaryChannel1 = 0U, kI2S_SecondaryChannel2 = 1U, kI2S_SecondaryChannel3 = 2U } |
I2S secondary channel. More... | |
Driver version | |
#define | FSL_I2S_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
I2S driver version 2.1.0. More... | |
Initialization and deinitialization | |
void | I2S_TxInit (I2S_Type *base, const i2s_config_t *config) |
Initializes the FLEXCOMM peripheral for I2S transmit functionality. More... | |
void | I2S_RxInit (I2S_Type *base, const i2s_config_t *config) |
Initializes the FLEXCOMM peripheral for I2S receive functionality. More... | |
void | I2S_TxGetDefaultConfig (i2s_config_t *config) |
Sets the I2S Tx configuration structure to default values. More... | |
void | I2S_RxGetDefaultConfig (i2s_config_t *config) |
Sets the I2S Rx configuration structure to default values. More... | |
void | I2S_Deinit (I2S_Type *base) |
De-initializes the I2S peripheral. More... | |
Non-blocking API | |
void | I2S_TxTransferCreateHandle (I2S_Type *base, i2s_handle_t *handle, i2s_transfer_callback_t callback, void *userData) |
Initializes handle for transfer of audio data. More... | |
status_t | I2S_TxTransferNonBlocking (I2S_Type *base, i2s_handle_t *handle, i2s_transfer_t transfer) |
Begins or queue sending of the given data. More... | |
void | I2S_TxTransferAbort (I2S_Type *base, i2s_handle_t *handle) |
Aborts sending of data. More... | |
void | I2S_RxTransferCreateHandle (I2S_Type *base, i2s_handle_t *handle, i2s_transfer_callback_t callback, void *userData) |
Initializes handle for reception of audio data. More... | |
status_t | I2S_RxTransferNonBlocking (I2S_Type *base, i2s_handle_t *handle, i2s_transfer_t transfer) |
Begins or queue reception of data into given buffer. More... | |
void | I2S_RxTransferAbort (I2S_Type *base, i2s_handle_t *handle) |
Aborts receiving of data. More... | |
status_t | I2S_TransferGetCount (I2S_Type *base, i2s_handle_t *handle, size_t *count) |
Returns number of bytes transferred so far. More... | |
status_t | I2S_TransferGetErrorCount (I2S_Type *base, i2s_handle_t *handle, size_t *count) |
Returns number of buffer underruns or overruns. More... | |
Enable / disable | |
static void | I2S_Enable (I2S_Type *base) |
Enables I2S operation. More... | |
static void | I2S_Disable (I2S_Type *base) |
Disables I2S operation. More... | |
Interrupts | |
static void | I2S_EnableInterrupts (I2S_Type *base, uint32_t interruptMask) |
Enables I2S FIFO interrupts. More... | |
static void | I2S_DisableInterrupts (I2S_Type *base, uint32_t interruptMask) |
Disables I2S FIFO interrupts. More... | |
static uint32_t | I2S_GetEnabledInterrupts (I2S_Type *base) |
Returns the set of currently enabled I2S FIFO interrupts. More... | |
void | I2S_TxHandleIRQ (I2S_Type *base, i2s_handle_t *handle) |
Invoked from interrupt handler when transmit FIFO level decreases. More... | |
void | I2S_RxHandleIRQ (I2S_Type *base, i2s_handle_t *handle) |
Invoked from interrupt handler when receive FIFO level decreases. More... | |
struct i2s_config_t |
Data Fields | |
i2s_master_slave_t | masterSlave |
Master / slave configuration. | |
i2s_mode_t | mode |
I2S mode. | |
bool | rightLow |
Right channel data in low portion of FIFO. | |
bool | leftJust |
Left justify data in FIFO. | |
bool | sckPol |
SCK polarity. | |
bool | wsPol |
WS polarity. | |
uint16_t | divider |
Flexcomm function clock divider (1 - 4096) | |
bool | oneChannel |
true mono, false stereo | |
uint8_t | dataLength |
Data length (4 - 32) | |
uint16_t | frameLength |
Frame width (4 - 512) | |
uint16_t | position |
Data position in the frame. | |
uint8_t | watermark |
FIFO trigger level. | |
bool | txEmptyZero |
Transmit zero when buffer becomes empty or last item. | |
bool | pack48 |
Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) | |
struct i2s_transfer_t |
struct _i2s_handle |
Transactional state of the intialized transfer or receive I2S operation.
Data Fields | |
uint32_t | state |
State of transfer. | |
i2s_transfer_callback_t | completionCallback |
Callback function pointer. | |
void * | userData |
Application data passed to callback. | |
bool | oneChannel |
true mono, false stereo | |
uint8_t | dataLength |
Data length (4 - 32) | |
bool | pack48 |
Packing format for 48-bit data (false - 24 bit values, true - alternating 32-bit and 16-bit values) | |
bool | useFifo48H |
When dataLength 17-24: true use FIFOWR48H, false use FIFOWR. | |
volatile i2s_transfer_t | i2sQueue [I2S_NUM_BUFFERS] |
Transfer queue storing transfer buffers. | |
volatile uint8_t | queueUser |
Queue index where user's next transfer will be stored. | |
volatile uint8_t | queueDriver |
Queue index of buffer actually used by the driver. | |
volatile uint32_t | errorCount |
Number of buffer underruns/overruns. | |
volatile uint32_t | transferCount |
Number of bytes transferred. | |
volatile uint8_t | watermark |
FIFO trigger level. | |
#define FSL_I2S_DRIVER_VERSION (MAKE_VERSION(2, 1, 0)) |
#define I2S_NUM_BUFFERS (4) |
typedef void(* i2s_transfer_callback_t)(I2S_Type *base, i2s_handle_t *handle, status_t completionStatus, void *userData) |
base | I2S base pointer. |
handle | pointer to I2S transaction. |
completionStatus | status of the transaction. |
userData | optional pointer to user arguments data. |
enum _i2s_status |
enum i2s_flags_t |
enum i2s_master_slave_t |
enum i2s_mode_t |
void I2S_TxInit | ( | I2S_Type * | base, |
const i2s_config_t * | config | ||
) |
Ungates the FLEXCOMM clock and configures the module for I2S transmission using a configuration structure. The configuration structure can be custom filled or set with default values by I2S_TxGetDefaultConfig().
base | I2S base pointer. |
config | pointer to I2S configuration structure. |
void I2S_RxInit | ( | I2S_Type * | base, |
const i2s_config_t * | config | ||
) |
Ungates the FLEXCOMM clock and configures the module for I2S receive using a configuration structure. The configuration structure can be custom filled or set with default values by I2S_RxGetDefaultConfig().
base | I2S base pointer. |
config | pointer to I2S configuration structure. |
void I2S_TxGetDefaultConfig | ( | i2s_config_t * | config | ) |
This API initializes the configuration structure for use in I2S_TxInit(). The initialized structure can remain unchanged in I2S_TxInit(), or it can be modified before calling I2S_TxInit(). Example:
Default values:
config | pointer to I2S configuration structure. |
void I2S_RxGetDefaultConfig | ( | i2s_config_t * | config | ) |
This API initializes the configuration structure for use in I2S_RxInit(). The initialized structure can remain unchanged in I2S_RxInit(), or it can be modified before calling I2S_RxInit(). Example:
Default values:
config | pointer to I2S configuration structure. |
void I2S_Deinit | ( | I2S_Type * | base | ) |
This API gates the FLEXCOMM clock. The I2S module can't operate unless I2S_TxInit or I2S_RxInit is called to enable the clock.
base | I2S base pointer. |
void I2S_TxTransferCreateHandle | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
i2s_transfer_callback_t | callback, | ||
void * | userData | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
callback | function to be called back when transfer is done or fails. |
userData | pointer to data passed to callback. |
status_t I2S_TxTransferNonBlocking | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
i2s_transfer_t | transfer | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
transfer | data buffer. |
kStatus_Success | |
kStatus_I2S_Busy | if all queue slots are occupied with unsent buffers. |
void I2S_TxTransferAbort | ( | I2S_Type * | base, |
i2s_handle_t * | handle | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
void I2S_RxTransferCreateHandle | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
i2s_transfer_callback_t | callback, | ||
void * | userData | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
callback | function to be called back when transfer is done or fails. |
userData | pointer to data passed to callback. |
status_t I2S_RxTransferNonBlocking | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
i2s_transfer_t | transfer | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
transfer | data buffer. |
kStatus_Success | |
kStatus_I2S_Busy | if all queue slots are occupied with buffers which are not full. |
void I2S_RxTransferAbort | ( | I2S_Type * | base, |
i2s_handle_t * | handle | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
status_t I2S_TransferGetCount | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
size_t * | count | ||
) |
base | I2S base pointer. | |
handle | pointer to handle structure. | |
[out] | count | number of bytes transferred so far by the non-blocking transaction. |
kStatus_Success | |
kStatus_NoTransferInProgress | there is no non-blocking transaction currently in progress. |
status_t I2S_TransferGetErrorCount | ( | I2S_Type * | base, |
i2s_handle_t * | handle, | ||
size_t * | count | ||
) |
base | I2S base pointer. | |
handle | pointer to handle structure. | |
[out] | count | number of transmit errors encountered so far by the non-blocking transaction. |
kStatus_Success | |
kStatus_NoTransferInProgress | there is no non-blocking transaction currently in progress. |
|
inlinestatic |
base | I2S base pointer. |
|
inlinestatic |
base | I2S base pointer. |
|
inlinestatic |
base | I2S base pointer. |
interruptMask | bit mask of interrupts to enable. See i2s_flags_t for the set of constants that should be OR'd together to form the bit mask. |
|
inlinestatic |
base | I2S base pointer. |
interruptMask | bit mask of interrupts to enable. See i2s_flags_t for the set of constants that should be OR'd together to form the bit mask. |
|
inlinestatic |
base | I2S base pointer. |
void I2S_TxHandleIRQ | ( | I2S_Type * | base, |
i2s_handle_t * | handle | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |
void I2S_RxHandleIRQ | ( | I2S_Type * | base, |
i2s_handle_t * | handle | ||
) |
base | I2S base pointer. |
handle | pointer to handle structure. |