![]() |
MCUXpresso SDK API Reference Manual
Rev 2.13.0
NXP Semiconductors
|
Data Structures | |
struct | hal_audio_dma_mux_config_t |
HAL Audio DMA mux user configuration. More... | |
struct | hal_audio_dma_channel_mux_config_t |
HAL Audio DMA channel mux user configuration. More... | |
struct | hal_audio_dma_extra_config_t |
HAL Audio DMA extra user configuration. More... | |
struct | hal_audio_dma_config_t |
HAL Audio DMA user configuration. More... | |
struct | hal_audio_ip_config_t |
HAL Audio IP specific feature configuration. More... | |
struct | hal_audio_config_t |
HAL Audio configuration structure. More... | |
struct | hal_audio_transfer_t |
HAL Audio transfer structure. More... | |
Macros | |
#define | HAL_AUDIO_HANDLE_SIZE (HAL_AUDIO_HANDLE_SIZE_TEMP) |
Definition of audio adapter handle size. More... | |
#define | HAL_AUDIO_HANDLE_DEFINE(name) uint32_t name[(HAL_AUDIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)] |
Defines the Audio handle. More... | |
Typedefs | |
typedef void * | hal_audio_handle_t |
HAL Audio transfer handle. More... | |
typedef void(* | hal_audio_transfer_callback_t )(hal_audio_handle_t handle, hal_audio_status_t completionStatus, void *callbackParam) |
HAL Audio completion callback function pointer type. More... | |
Initialization and de-initialization | |
hal_audio_status_t | HAL_AudioTxInit (hal_audio_handle_t handle, const hal_audio_config_t *config) |
Initializes the HAL Audio peripheral. More... | |
hal_audio_status_t | HAL_AudioRxInit (hal_audio_handle_t handle, const hal_audio_config_t *config) |
Initializes the HAL Audio peripheral. More... | |
hal_audio_status_t | HAL_AudioTxDeinit (hal_audio_handle_t handle) |
De-initializes the HAL Audio peripheral. More... | |
hal_audio_status_t | HAL_AudioRxDeinit (hal_audio_handle_t handle) |
De-initializes the HAL Audio peripheral. More... | |
struct hal_audio_dma_mux_config_t |
struct hal_audio_dma_channel_mux_config_t |
struct hal_audio_dma_extra_config_t |
struct hal_audio_dma_config_t |
Data Fields | |
uint8_t | instance |
DMA instance. | |
uint8_t | channel |
DMA channel. | |
hal_audio_dma_channel_priority_t | priority |
DMA channel priority. | |
bool | enablePreemption |
If true, a channel can be suspended by other channel with higher priority. More... | |
bool | enablePreemptAbility |
If true, a channel can suspend other channel with low priority Not all SOCs support this feature. More... | |
void * | dmaMuxConfig |
The pointer points to an entity defined by hal_audio_dma_mux_config_t. More... | |
void * | dmaChannelMuxConfig |
The pointer points to an entity defined by hal_audio_dma_channel_mux_config_t. More... | |
void * | dmaChannelConfig |
The pointer points to an entity defined by channel configuration structure that is defined in dma driver, such as edma_channel_config_t. More... | |
void * | dmaExtraConfig |
The pointer points to an entity defined by hal_audio_dma_extra_config_t. More... | |
bool hal_audio_dma_config_t::enablePreemption |
Not all SOCs support this feature. For example, EDMA, DMA4 supports this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the value should be set to false.
bool hal_audio_dma_config_t::enablePreemptAbility |
For example, EDMA, DMA4 supports this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the value should be set to false.
void* hal_audio_dma_config_t::dmaMuxConfig |
Not all SOCs support this feature. In general, when the macro FSL_FEATURE_SOC_DMAMUX_COUNT is defined as non-zero, the SOC supports this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the pointer should be set to NULL.
void* hal_audio_dma_config_t::dmaChannelMuxConfig |
Not all SOCs support this feature. In general, when the macro FSL_FEATURE_EDMA_HAS_CHANNEL_MUX is defined as non-zero, the SOC supports this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the pointer should be set to NULL.
void* hal_audio_dma_config_t::dmaChannelConfig |
Not all SOCs support this feature. In general, when the macro FSL_FEATURE_EDMA_HAS_CHANNEL_CONFIG is defined as non-zero, the SOC supports this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the pointer should be set to NULL.
void* hal_audio_dma_config_t::dmaExtraConfig |
Some DMA IPs have extra configurations, such as EDMA, DMA4. The structure is used for these extra configurations. Not all SOCs support this feature. For detailed information please refer to the SOC corresponding RM. If not supported, the pointer should be set to NULL.
struct hal_audio_ip_config_t |
struct hal_audio_config_t |
Data Fields | |
hal_audio_dma_config_t * | dmaConfig |
DMA configuration. | |
void * | ipConfig |
IP specific feature configuration. More... | |
uint32_t | srcClock_Hz |
Source clock. | |
uint32_t | sampleRate_Hz |
Sample rate. | |
uint16_t | frameLength |
Only flexcomm_i2s uses this field. More... | |
uint16_t | fifoWatermark |
FIFO watermark value. More... | |
hal_audio_master_slave_t | msaterSlave |
master or slave, configure where the bclk and frame sync come from. More... | |
hal_audio_bclk_polarity_t | bclkPolarity |
bclk polarity, data sample on rising edge or falling edge. More... | |
hal_audio_frame_sync_width_t | frameSyncWidth |
Only DSP mode uses this field. More... | |
hal_audio_frame_sync_polarity_t | frameSyncPolarity |
frame sync polarity, frame sync begin at rising or falling edge. More... | |
hal_audio_channel_t | lineChannels |
Configure the number of channel on the data line. More... | |
hal_audio_data_format_t | dataFormat |
data format on bus | |
uint8_t | bitWidth |
Bit Width. | |
uint8_t | instance |
Instance (0 - I2S0/SAI0, 1 - I2S1/SAI1, ...), for detailed information please refer to the SOC corresponding RM. More... | |
void* hal_audio_config_t::ipConfig |
The pointer points to an entity defined by hal_audio_ip_config_t. If there is no specific feature configuration, it should be set to NULL.
uint16_t hal_audio_config_t::frameLength |
In most cases, frameLength is equal to bitWidth times lineChannels. In some cases, frameLength needs to be set to other value. For example, when the number of bit clock on the bus between two neighboring WS value is greater than bitWidth times lineChannels, frameLength needs to be set to the value that is equal to the number of bit clock between two neighboring WS signal. SAI does not use this field because frameLength can be determined internally by bitWidth and lineChannels.
uint16_t hal_audio_config_t::fifoWatermark |
Generally, the value is set to half the number of FIFO(F). Note that the receive(R) or transmit length(T) is related to fifoWatermark(W) and bitWidth(B). The relationship between them is: R = N * W * B, T = N * (F - W) * B (N is integer). On some SOCs, the W and (F - W) is constant 1 and setting the W does not take effect. In that case the fifoWatermark does not need to be set. If the value set by application is greater than the number of FIFO, a maximum value will be used. For example, if the number of FIFO is 32 on a SOC but the watermark is set to 64 by application, the real value that is written to register will be 31.
hal_audio_master_slave_t hal_audio_config_t::msaterSlave |
hal_audio_bclk_polarity_t hal_audio_config_t::bclkPolarity |
hal_audio_frame_sync_width_t hal_audio_config_t::frameSyncWidth |
For other data format, this field does not need to be set and the frameSyncWidth is determined internally that depends on different mode. For example, for I2S classic mode, frameSyncWidth is equal to bitWidth.
hal_audio_frame_sync_polarity_t hal_audio_config_t::frameSyncPolarity |
This field is not used now and reserved for future use. The frameSyncPolarity is set internally that depends on different mode. For example, for I2S classic mode, frameSyncWidth is equal to kHAL_AudioBeginAtFallingEdge.
hal_audio_channel_t hal_audio_config_t::lineChannels |
uint8_t hal_audio_config_t::instance |
Invalid instance value will cause initialization failure.
struct hal_audio_transfer_t |
#define HAL_AUDIO_HANDLE_SIZE (HAL_AUDIO_HANDLE_SIZE_TEMP) |
#define HAL_AUDIO_HANDLE_DEFINE | ( | name | ) | uint32_t name[(HAL_AUDIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)] |
This macro is used to define a 4 byte aligned Audio handle. Then use "(hal_audio_handle_t)name" to get the Audio handle.
The macro should be global and could be optional. You could also define Audio handle by yourself.
This is an example,
name | The name string of the Audio transfer handle. |
typedef void* hal_audio_handle_t |
typedef void(* hal_audio_transfer_callback_t)(hal_audio_handle_t handle, hal_audio_status_t completionStatus, void *callbackParam) |
This callback is used only for the non-blocking Audio transfer API. Specify the callback you wish to use in the call to HAL_AudioTxInstallCallback() or HAL_AudioRxInstallCallback().
handle | audio transfer handle pointer, this should be a static variable. |
completionStatus | Either kStatus_HAL_AudioIdle or an error code describing how the transfer completed. |
callbackParam | Arbitrary pointer-sized value passed from the application. |
enum hal_audio_status_t |
enum hal_audio_channel_t |
hal_audio_status_t HAL_AudioTxInit | ( | hal_audio_handle_t | handle, |
const hal_audio_config_t * | config | ||
) |
Example below shows how to use this API to configure the audio peripheral. For SAI,
For I2S,
handle | Pointer to point to a memory space of size HAL_AUDIO_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: HAL_AUDIO_HANDLE_DEFINE(handle); or uint32_t handle[((HAL_AUDIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]; |
config | A pointer to the audio configuration structure |
kStatus_HAL_AudioSuccess | audio initialization succeed |
hal_audio_status_t HAL_AudioRxInit | ( | hal_audio_handle_t | handle, |
const hal_audio_config_t * | config | ||
) |
Example below shows how to use this API to configure the audio peripheral. For SAI,
For I2S,
handle | Pointer to point to a memory space of size HAL_AUDIO_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: HAL_AUDIO_HANDLE_DEFINE(handle); or uint32_t handle[((HAL_AUDIO_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))]; |
config | A pointer to the audio configuration structure |
kStatus_HAL_AudioSuccess | audio initialization succeed |
hal_audio_status_t HAL_AudioTxDeinit | ( | hal_audio_handle_t | handle | ) |
Call this API to gate the HAL Audio clock. The HAL Audio module can't work unless the HAL_AudioTxInit is called.
handle | audio handle pointer, this should be a static variable. |
kStatus_HAL_AudioSuccess | audio de-initialization succeed |
hal_audio_status_t HAL_AudioRxDeinit | ( | hal_audio_handle_t | handle | ) |
Call this API to gate the HAL Audio clock. The HAL Audio module can't work unless the HAL_AudioRxInit is called.
handle | audio handle pointer, this should be a static variable. |
kStatus_HAL_AudioSuccess | audio de-initialization succeed |
hal_audio_status_t HAL_AudioTxInstallCallback | ( | hal_audio_handle_t | handle, |
hal_audio_transfer_callback_t | callback, | ||
void * | callbackParam | ||
) |
This function is used to install the callback and callback parameter for audio module. When any status of the audio changed, the driver will notify the upper layer by the installed callback function. And the status is also passed as status parameter when the callback is called.
handle | audio handle pointer, this should be a static variable. |
callback | pointer to user callback function. |
callbackParam | user parameter passed to the callback function. |
kStatus_HAL_AudioSuccess | audio tx transfer handle created |
hal_audio_status_t HAL_AudioRxInstallCallback | ( | hal_audio_handle_t | handle, |
hal_audio_transfer_callback_t | callback, | ||
void * | callbackParam | ||
) |
This function is used to install the callback and callback parameter for audio module. When any status of the audio changed, the driver will notify the upper layer by the installed callback function. And the status is also passed as status parameter when the callback is called.
handle | audio handle pointer, this should be a static variable. |
callback | pointer to user callback function. |
callbackParam | user parameter passed to the callback function. |
kStatus_HAL_AudioSuccess | audio rx transfer handle created |
hal_audio_status_t HAL_AudioTransferSendNonBlocking | ( | hal_audio_handle_t | handle, |
hal_audio_transfer_t * | xfer | ||
) |
handle | audio handle pointer, this should be a static variable. |
xfer | pointer to hal_audio_transfer_t structure. |
kStatus_HAL_AudioSuccess | Successfully start the data transmission. |
kStatus_HAL_AudioBusy | Previous transmission still not finished. |
kStatus_HAL_AudioError | An error occurred. |
hal_audio_status_t HAL_AudioTransferReceiveNonBlocking | ( | hal_audio_handle_t | handle, |
hal_audio_transfer_t * | xfer | ||
) |
handle | audio handle pointer, this should be a static variable. |
xfer | pointer to hal_audio_transfer_t structure. |
kStatus_HAL_AudioSuccess | Successfully start the data transmission. |
kStatus_HAL_AudioBusy | Previous transmission still not finished. |
kStatus_HAL_AudioError | An error occurred. |
hal_audio_status_t HAL_AudioTransferAbortSend | ( | hal_audio_handle_t | handle | ) |
handle | audio handle pointer, this should be a static variable. |
kStatus_HAL_AudioSuccess | Successfully abort the transfer. |
hal_audio_status_t HAL_AudioTransferAbortReceive | ( | hal_audio_handle_t | handle | ) |
handle | audio handle pointer, this should be a static variable. |
kStatus_HAL_AudioSuccess | Successfully abort the transfer. |
hal_audio_status_t HAL_AudioTransferGetSendCount | ( | hal_audio_handle_t | handle, |
size_t * | count | ||
) |
handle | audio handle pointer, this should be a static variable. |
count | Number of bytes sent so far by the non-blocking transaction. |
kStatus_HAL_AudioSuccess | Successfully return the count. |
kStatus_HAL_AudioIdle | Previous transmission has been finished. |
kStatus_HAL_AudioError | An error occurred. |
hal_audio_status_t HAL_AudioTransferGetReceiveCount | ( | hal_audio_handle_t | handle, |
size_t * | count | ||
) |
handle | audio handle pointer, this should be a static variable. |
count | Number of bytes received so far by the non-blocking transaction. |
kStatus_HAL_AudioSuccess | Successfully return the count. |
kStatus_HAL_AudioIdle | Previous transmission has been finished. |
kStatus_HAL_AudioError | An error occurred. |