MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
tfa9xxx Driver

Overview

The tfa9xxx driver provide codec control interface.

Modules

 tfa9xxx adapter
 

Data Structures

struct  tfa9xxx_audio_format_t
 tfa9xxx audio format More...
 
struct  tfa9xxx_config_t
 Initialize structure of TFA9XXX. More...
 
struct  tfa9xxx_handle_t
 tfa9xxx codec handler Application should allocate a buffer with TFA9XXX_HANDLE_SIZE for handle definition, such as uint8_t tfa9xxxHandleBuffer[TFA9XXX_HANDLE_SIZE]; tfa9xxx_handle_t *tfa9xxxHandle = tfa9xxxHandleBuffer; More...
 

Macros

#define TFA9XXX_I2C_HANDLER_SIZE   (CODEC_I2C_MASTER_HANDLER_SIZE)
 tfa9xxx handle size
 
#define TFA9XXX_I2C_BAUDRATE   (400000U)
 TFA9XXX_ I2C baudrate.
 

Enumerations

enum  tfa9xxx_protocol_t { kTFA9XXX_BusI2S = 0 }
 The audio data transfer protocol choice. More...
 
enum  _tfa9xxx_sample_rate { kTFA9XXX_AudioSampleRate48KHz = 48000U }
 audio sample rate definition, more sample rates can be supported in the future More...
 
enum  _tfa9xxx_audio_bit_width { kTFA9XXX_AudioBitWidth16bit = 16U }
 audio bit width, more bit width can be supported in the future More...
 
enum  _tfa98xxx_play_channel {
  kTFA9XXX_PlayChannelLeft0 = 1U,
  kTFA9XXX_PlayChannelRight0 = 2U
}
 play channel More...
 

Functions

status_t TFA9XXX_Init (tfa9xxx_handle_t *handle, tfa9xxx_config_t *tfa9xxxConfig)
 Initialize the TFA, put the TFA to operating state, allocate memory side. More...
 
status_t TFA9XXX_Deinit (tfa9xxx_handle_t *handle)
 Deinitialize the TFA, put the TFA to powerdown state. More...
 
status_t TFA9XXX_SetMute (tfa9xxx_handle_t *handle, bool isMute)
 Mute/Unmute the TFA. More...
 
status_t TFA9XXX_ConfigDataFormat (tfa9xxx_handle_t *handle, uint32_t mclk, uint32_t sampleRate, uint32_t bitWidth)
 Configure the TFA based on I2S format. More...
 
status_t TFA9XXX_SetVolume (tfa9xxx_handle_t *handle, uint32_t volume)
 Set the volume level. More...
 
status_t TFA9XXX_SetPlayChannel (tfa9xxx_handle_t *handle, uint32_t playChannel)
 Set the audio channel for a speaker. More...
 
status_t TFA9XXX_Start (tfa9xxx_handle_t *handle)
 Start the TFA. More...
 
status_t TFA9XXX_Stop (tfa9xxx_handle_t *handle)
 Stop the TFA. More...
 
status_t TFA9XXX_Reset (tfa9xxx_handle_t *handle)
 Reset the TFA. More...
 
status_t TFA9XXX_CheckCalibrationStatus (tfa9xxx_handle_t *handle, bool *isTFACalibrated)
 check if TFA is calibrated. More...
 
status_t TFA9XXX_CalibrateSpeakerBoost (tfa9xxx_handle_t *handle)
 Start Speakerboost Calibration. More...
 
status_t TFA9XXX_HardcodeCalibrationValue (tfa9xxx_handle_t *handle)
 Hardcode calibration value for DSP usage instead of triggering calibration. More...
 
status_t TFA9XXX_GetStatus (tfa9xxx_handle_t *handle)
 Get the status of a running TFA. More...
 
status_t TFA9XXX_ConvertErrorCode (int32_t rc)
 Convert the return check value from TFA driver to predefined error code. More...
 

Driver version

#define FSL_TFA9XXX_DRIVER_VERSION   (MAKE_VERSION(8, 1, 2))
 TFA9XXX driver version 8.1.2. More...
 

Data Structure Documentation

struct tfa9xxx_audio_format_t

Data Fields

enum _tfa9xxx_sample_rate sampleRate
 sample rate
 
enum _tfa9xxx_audio_bit_width bitWidth
 bit width
 
struct tfa9xxx_config_t

Data Fields

tfa9xxx_protocol_t protocol
 Audio transfer protocol.
 
tfa9xxx_audio_format_t format
 Audio format.
 
uint8_t slaveAddress
 tfa9xxx device address
 
codec_i2c_config_t i2cConfig
 i2c configuration
 
uint8_t * tfaContainer
 tfa container array
 
uint8_t deviceIndex
 tfa device index, starting from 0, up to TFA9XXX_DEV_NUM - 1
 
struct tfa9xxx_handle_t

Data Fields

tfa9xxx_config_tconfig
 tfa9xxx config pointer
 
uint8_t i2cHandle [TFA9XXX_I2C_HANDLER_SIZE]
 i2c handle
 

Macro Definition Documentation

#define FSL_TFA9XXX_DRIVER_VERSION   (MAKE_VERSION(8, 1, 2))

Enumeration Type Documentation

TFA9XXX only supports I2S format.

Enumerator
kTFA9XXX_BusI2S 

I2S type.

Enumerator
kTFA9XXX_AudioSampleRate48KHz 

Sample rate 48000 Hz.

Enumerator
kTFA9XXX_AudioBitWidth16bit 

audio bit width 16

Enumerator
kTFA9XXX_PlayChannelLeft0 

codec play channel left 0

kTFA9XXX_PlayChannelRight0 

codec play channel right 0

Function Documentation

status_t TFA9XXX_Init ( tfa9xxx_handle_t handle,
tfa9xxx_config_t tfa9xxxConfig 
)
Parameters
handleTFA9XXX handle structure.
tfa9xxxConfigTFA9XXX configuration structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_Deinit ( tfa9xxx_handle_t handle)
Parameters
handleTFA9XXX handle structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_SetMute ( tfa9xxx_handle_t handle,
bool  isMute 
)

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleTFA9XXX handle structure.
isMutetrue is mute, false is unmute..
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_ConfigDataFormat ( tfa9xxx_handle_t handle,
uint32_t  mclk,
uint32_t  sampleRate,
uint32_t  bitWidth 
)

Assuming TFA_Init() is already called by calling CODEC_Init(), the TFA will be in operating state. So before calling TFA_SetFormat(), the TFA needs to be in powerdown state by calling TFA_Stop().

Parameters
handleTFA9XXX handle structure.
mclkThe mclk.
sampleRateThe sample rate.
bitWidthThe bit width.
Returns
Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_SetVolume ( tfa9xxx_handle_t handle,
uint32_t  volume 
)

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleTFA9XXX handle structure.
volumevolume volume value, support 0 ~ 100, 0 is mute, 100 is the maximum volume value.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_SetPlayChannel ( tfa9xxx_handle_t handle,
uint32_t  playChannel 
)

By default, I2S channel is configured by the .tfaContainer in tfa9xxx_config_t. So you don't need to call this function. However, if required, calling this function allows overwriting I2S channel selection. This can be useful when the tuning is done, and you simply want to change the I2S channel.

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleTFA9XXX handle structure.
playChannel_codec_play_channel play channel, available values are kCODEC_PlayChannelSpeakerLeft, kCODEC_PlayChannelSpeakerRight, kCODEC_PlayChannelSpeakerLeft | kCODEC_PlayChannelSpeakerRight.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_Start ( tfa9xxx_handle_t handle)

Start device will initialize if the device is in cold state if already warm then only clocks will be started.

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA codec handle.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_Stop ( tfa9xxx_handle_t handle)

Stop will put the TFA in powerdown/standby mode, the next time TFA start will be a warm start.

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA9XXX handle structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_Reset ( tfa9xxx_handle_t handle)

Reset will put the in powerdown/standby mode, the next time TFA start will be a cold start.

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA9XXX handle structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_CheckCalibrationStatus ( tfa9xxx_handle_t handle,
bool *  isTFACalibrated 
)

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA9XXX handle structure.
isTFACalibratedThis value stores if TFA is calibrated.
Returns
status_t Returns kStatus_Success if operation is successfully, otherwise returns error code..
status_t TFA9XXX_CalibrateSpeakerBoost ( tfa9xxx_handle_t handle)

The calibration will measure speaker impedance, and calculate the speaker impedance at 25 degree. This value will be used to estimate the real-time temperature.

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA codec handle.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_HardcodeCalibrationValue ( tfa9xxx_handle_t handle)

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleTFA9XXX handle structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_GetStatus ( tfa9xxx_handle_t handle)

This function has dependency on internal structure, it has to be called after TFA9XXX_CreatePlatform();

Parameters
handleThe TFA9XXX handle structure.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.
status_t TFA9XXX_ConvertErrorCode ( int32_t  rc)
Parameters
rcReturn check value from TFA driver.
Returns
status_t Returns kStatus_Success if success, otherwise returns error code.