MCUXpresso SDK API Reference Manual
Rev. 0
NXP Semiconductors
|
The cs42888 driver provide codec control interface.
Modules | |
cs42888 adapter | |
Data Structures | |
struct | cs42888_audio_format_t |
cs42888 audio format More... | |
struct | cs42888_config_t |
Initialize structure of CS42888. More... | |
struct | cs42888_handle_t |
cs42888 handler More... | |
Macros | |
#define | CS42888_I2C_HANDLER_SIZE CODEC_I2C_MASTER_HANDLER_SIZE |
CS42888 handle size. | |
#define | CS42888_ID 0x01 |
Define the register address of CS42888. More... | |
#define | CS42888_CACHEREGNUM 28 |
Cache register number. | |
#define | CS42888_I2C_ADDR 0x48 |
CS42888 I2C address. More... | |
#define | CS42888_I2C_BITRATE (100000U) |
CS42888 I2C baudrate. | |
Typedefs | |
typedef void(* | cs42888_reset )(bool state) |
cs42888 reset function pointer | |
Enumerations | |
enum | cs42888_func_mode { kCS42888_ModeMasterSSM = 0x0, kCS42888_ModeMasterDSM = 0x1, kCS42888_ModeMasterQSM = 0x2, kCS42888_ModeSlave = 0x3 } |
CS42888 support modes. More... | |
enum | cs42888_module_t { kCS42888_ModuleDACPair1 = 0x2, kCS42888_ModuleDACPair2 = 0x4, kCS42888_ModuleDACPair3 = 0x8, kCS42888_ModuleDACPair4 = 0x10, kCS42888_ModuleADCPair1 = 0x20, kCS42888_ModuleADCPair2 = 0x40 } |
Modules in CS42888 board. More... | |
enum | cs42888_bus_t { kCS42888_BusLeftJustified = 0x0, kCS42888_BusI2S = 0x1, kCS42888_BusRightJustified = 0x2, kCS42888_BusOL1 = 0x4, kCS42888_BusOL2 = 0x5, kCS42888_BusTDM = 0x6 } |
CS42888 supported audio bus type. More... | |
enum | _cs42888_play_channel { kCS42888_AOUT1 = 1U, kCS42888_AOUT2 = 2U, kCS42888_AOUT3 = 3U, kCS42888_AOUT4 = 4U, kCS42888_AOUT5 = 5U, kCS42888_AOUT6 = 6U, kCS42888_AOUT7 = 7U, kCS42888_AOUT8 = 8U } |
CS428888 play channel. More... | |
Functions | |
status_t | CS42888_Init (cs42888_handle_t *handle, cs42888_config_t *config) |
CS42888 initialize function. More... | |
status_t | CS42888_Deinit (cs42888_handle_t *handle) |
Deinit the CS42888 codec. More... | |
status_t | CS42888_SetProtocol (cs42888_handle_t *handle, cs42888_bus_t protocol, uint32_t bitWidth) |
Set the audio transfer protocol. More... | |
void | CS42888_SetFuncMode (cs42888_handle_t *handle, cs42888_func_mode mode) |
Set CS42888 to differernt working mode. More... | |
status_t | CS42888_SelectFunctionalMode (cs42888_handle_t *handle, cs42888_func_mode adcMode, cs42888_func_mode dacMode) |
Set CS42888 to differernt functional mode. More... | |
status_t | CS42888_SetAOUTVolume (cs42888_handle_t *handle, uint8_t channel, uint8_t volume) |
Set the volume of different modules in CS42888. More... | |
status_t | CS42888_SetAINVolume (cs42888_handle_t *handle, uint8_t channel, uint8_t volume) |
Set the volume of different modules in CS42888. More... | |
uint8_t | CS42888_GetAOUTVolume (cs42888_handle_t *handle, uint8_t channel) |
Get the volume of different AOUT channel in CS42888. More... | |
uint8_t | CS42888_GetAINVolume (cs42888_handle_t *handle, uint8_t channel) |
Get the volume of different AIN channel in CS42888. More... | |
status_t | CS42888_SetMute (cs42888_handle_t *handle, uint8_t channelMask) |
Mute modules in CS42888. More... | |
status_t | CS42888_SetChannelMute (cs42888_handle_t *handle, uint8_t channel, bool isMute) |
Mute channel modules in CS42888. More... | |
status_t | CS42888_SetModule (cs42888_handle_t *handle, cs42888_module_t module, bool isEnabled) |
Enable/disable expected devices. More... | |
status_t | CS42888_ConfigDataFormat (cs42888_handle_t *handle, uint32_t mclk, uint32_t sample_rate, uint32_t bits) |
Configure the data format of audio data. More... | |
status_t | CS42888_WriteReg (cs42888_handle_t *handle, uint8_t reg, uint8_t val) |
Write register to CS42888 using I2C. More... | |
status_t | CS42888_ReadReg (cs42888_handle_t *handle, uint8_t reg, uint8_t *val) |
Read register from CS42888 using I2C. More... | |
status_t | CS42888_ModifyReg (cs42888_handle_t *handle, uint8_t reg, uint8_t mask, uint8_t val) |
Modify some bits in the register using I2C. More... | |
Driver version | |
#define | FSL_CS42888_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) |
cs42888 driver version 2.1.1. More... | |
struct cs42888_audio_format_t |
Data Fields | |
uint32_t | mclk_HZ |
master clock frequency | |
uint32_t | sampleRate |
sample rate | |
uint32_t | bitWidth |
bit width | |
struct cs42888_config_t |
Data Fields | |
cs42888_bus_t | bus |
Audio transfer protocol. | |
cs42888_audio_format_t | format |
cs42888 audio format | |
cs42888_func_mode | ADCMode |
CS42888 ADC function mode. More... | |
cs42888_func_mode | DACMode |
CS42888 DAC function mode. More... | |
bool | master |
true is master, false is slave | |
codec_i2c_config_t | i2cConfig |
i2c bus configuration | |
uint8_t | slaveAddress |
slave address | |
cs42888_reset | reset |
reset function pointer | |
cs42888_func_mode cs42888_config_t::ADCMode |
cs42888_func_mode cs42888_config_t::DACMode |
struct cs42888_handle_t |
Data Fields | |
cs42888_config_t * | config |
cs42888 config pointer | |
uint8_t | i2cHandle [CS42888_I2C_HANDLER_SIZE] |
i2c handle pointer | |
#define FSL_CS42888_DRIVER_VERSION (MAKE_VERSION(2, 1, 1)) |
#define CS42888_ID 0x01 |
#define CS42888_I2C_ADDR 0x48 |
enum cs42888_func_mode |
enum cs42888_module_t |
enum cs42888_bus_t |
status_t CS42888_Init | ( | cs42888_handle_t * | handle, |
cs42888_config_t * | config | ||
) |
The second parameter is NULL to CS42888 in this version. If users want to change the settings, they have to use cs42888_write_reg() or cs42888_modify_reg() to set the register value of CS42888. Note: If the codec_config is NULL, it would initialize CS42888 using default settings. The default setting: codec_config->bus = kCS42888_BusI2S codec_config->ADCmode = kCS42888_ModeSlave codec_config->DACmode = kCS42888_ModeSlave
handle | CS42888 handle structure. |
config | CS42888 configuration structure. |
status_t CS42888_Deinit | ( | cs42888_handle_t * | handle | ) |
This function close all modules in CS42888 to save power.
handle | CS42888 handle structure pointer. |
status_t CS42888_SetProtocol | ( | cs42888_handle_t * | handle, |
cs42888_bus_t | protocol, | ||
uint32_t | bitWidth | ||
) |
CS42888 only supports I2S, left justified, right justified, PCM A, PCM B format.
handle | CS42888 handle structure. |
protocol | Audio data transfer protocol. |
bitWidth | bit width |
void CS42888_SetFuncMode | ( | cs42888_handle_t * | handle, |
cs42888_func_mode | mode | ||
) |
handle | CS42888 handle structure. |
mode | differenht working mode of CS42888. |
status_t CS42888_SelectFunctionalMode | ( | cs42888_handle_t * | handle, |
cs42888_func_mode | adcMode, | ||
cs42888_func_mode | dacMode | ||
) |
handle | CS42888 handle structure. |
adcMode | differenht working mode of CS42888. |
dacMode | differenht working mode of CS42888. |
status_t CS42888_SetAOUTVolume | ( | cs42888_handle_t * | handle, |
uint8_t | channel, | ||
uint8_t | volume | ||
) |
This function would set the volume of CS42888 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.
handle | CS42888 handle structure. |
channel | AOUT channel, it shall be 1~8. |
volume | Volume value need to be set. |
status_t CS42888_SetAINVolume | ( | cs42888_handle_t * | handle, |
uint8_t | channel, | ||
uint8_t | volume | ||
) |
This function would set the volume of CS42888 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.
handle | CS42888 handle structure. |
channel | AIN channel, it shall be 1~4. |
volume | Volume value need to be set. |
uint8_t CS42888_GetAOUTVolume | ( | cs42888_handle_t * | handle, |
uint8_t | channel | ||
) |
This function gets the volume of CS42888 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.
handle | CS42888 handle structure. |
channel | AOUT channel, it shall be 1~8. |
uint8_t CS42888_GetAINVolume | ( | cs42888_handle_t * | handle, |
uint8_t | channel | ||
) |
This function gets the volume of CS42888 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.
handle | CS42888 handle structure. |
channel | AIN channel, it shall be 1~4. |
status_t CS42888_SetMute | ( | cs42888_handle_t * | handle, |
uint8_t | channelMask | ||
) |
handle | CS42888 handle structure. |
channelMask | Channel mask for mute. Mute channel 0, it shall be 0x1, while mute channel 0 and 1, it shall be 0x3. Mute all channel, it shall be 0xFF. Each bit represent one channel, 1 means mute, 0 means unmute. |
status_t CS42888_SetChannelMute | ( | cs42888_handle_t * | handle, |
uint8_t | channel, | ||
bool | isMute | ||
) |
handle | CS42888 handle structure. |
channel | reference _cs42888_play_channel. |
isMute | true is mute, falase is unmute. |
status_t CS42888_SetModule | ( | cs42888_handle_t * | handle, |
cs42888_module_t | module, | ||
bool | isEnabled | ||
) |
handle | CS42888 handle structure. |
module | Module expected to enable. |
isEnabled | Enable or disable moudles. |
status_t CS42888_ConfigDataFormat | ( | cs42888_handle_t * | handle, |
uint32_t | mclk, | ||
uint32_t | sample_rate, | ||
uint32_t | bits | ||
) |
This function would configure the registers about the sample rate, bit depths.
handle | CS42888 handle structure pointer. |
mclk | Master clock frequency of I2S. |
sample_rate | Sample rate of audio file running in CS42888. CS42888 now supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate. |
bits | Bit depth of audio file (CS42888 only supports 16bit, 20bit, 24bit and 32 bit in HW). |
status_t CS42888_WriteReg | ( | cs42888_handle_t * | handle, |
uint8_t | reg, | ||
uint8_t | val | ||
) |
handle | CS42888 handle structure. |
reg | The register address in CS42888. |
val | Value needs to write into the register. |
status_t CS42888_ReadReg | ( | cs42888_handle_t * | handle, |
uint8_t | reg, | ||
uint8_t * | val | ||
) |
handle | CS42888 handle structure. |
reg | The register address in CS42888. |
val | Value written to. |
status_t CS42888_ModifyReg | ( | cs42888_handle_t * | handle, |
uint8_t | reg, | ||
uint8_t | mask, | ||
uint8_t | val | ||
) |
handle | CS42888 handle structure. |
reg | The register address in CS42888. |
mask | The mask code for the bits want to write. The bit you want to write should be 0. |
val | Value needs to write into the register. |