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

Overview

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   0x01U
 Define the register address of CS42888. More...
 
#define CS42888_AOUT_MAX_VOLUME_VALUE   0xFFU
 CS42888 volume setting range.
 
#define CS42888_CACHEREGNUM   28U
 Cache register number.
 
#define CS42888_I2C_ADDR   0x48U
 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  {
  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, 2))
 cs42888 driver version 2.1.2. More...
 

Data Structure Documentation

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
 

Field Documentation

cs42888_func_mode cs42888_config_t::ADCMode
cs42888_func_mode cs42888_config_t::DACMode
struct cs42888_handle_t

Data Fields

cs42888_config_tconfig
 cs42888 config pointer
 
uint8_t i2cHandle [CS42888_I2C_HANDLER_SIZE]
 i2c handle pointer
 

Macro Definition Documentation

#define FSL_CS42888_DRIVER_VERSION   (MAKE_VERSION(2, 1, 2))
#define CS42888_ID   0x01U
#define CS42888_I2C_ADDR   0x48U

Enumeration Type Documentation

Enumerator
kCS42888_ModeMasterSSM 

master single speed mode

kCS42888_ModeMasterDSM 

master dual speed mode

kCS42888_ModeMasterQSM 

master quad speed mode

kCS42888_ModeSlave 

master single speed mode

Enumerator
kCS42888_ModuleDACPair1 

DAC pair1 (AOUT1 and AOUT2) module in CS42888.

kCS42888_ModuleDACPair2 

DAC pair2 (AOUT3 and AOUT4) module in CS42888.

kCS42888_ModuleDACPair3 

DAC pair3 (AOUT5 and AOUT6) module in CS42888.

kCS42888_ModuleDACPair4 

DAC pair4 (AOUT7 and AOUT8) module in CS42888.

kCS42888_ModuleADCPair1 

ADC pair1 (AIN1 and AIN2) module in CS42888.

kCS42888_ModuleADCPair2 

ADC pair2 (AIN3 and AIN4) module in CS42888.

Enumerator
kCS42888_BusLeftJustified 

Left justified format, up to 24 bits.

kCS42888_BusI2S 

I2S format, up to 24 bits.

kCS42888_BusRightJustified 

Right justified, can support 16bits and 24 bits.

kCS42888_BusOL1 

One-Line #1 mode.

kCS42888_BusOL2 

One-Line #2 mode.

kCS42888_BusTDM 

TDM mode.

anonymous enum

Enumerator
kCS42888_AOUT1 

aout1

kCS42888_AOUT2 

aout2

kCS42888_AOUT3 

aout3

kCS42888_AOUT4 

aout4

kCS42888_AOUT5 

aout5

kCS42888_AOUT6 

aout6

kCS42888_AOUT7 

aout7

kCS42888_AOUT8 

aout8

Function Documentation

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

Parameters
handleCS42888 handle structure.
configCS42888 configuration structure.
status_t CS42888_Deinit ( cs42888_handle_t handle)

This function close all modules in CS42888 to save power.

Parameters
handleCS42888 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.

Parameters
handleCS42888 handle structure.
protocolAudio data transfer protocol.
bitWidthbit width
void CS42888_SetFuncMode ( cs42888_handle_t handle,
cs42888_func_mode  mode 
)
Deprecated:
api, Do not use it anymore. It has been superceded by CS42888_SelectFunctionalMode.
Parameters
handleCS42888 handle structure.
modedifferenht working mode of CS42888.
status_t CS42888_SelectFunctionalMode ( cs42888_handle_t handle,
cs42888_func_mode  adcMode,
cs42888_func_mode  dacMode 
)
Parameters
handleCS42888 handle structure.
adcModedifferenht working mode of CS42888.
dacModedifferenht 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.

Parameters
handleCS42888 handle structure.
channelAOUT channel, it shall be 1~8.
volumeVolume 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.

Parameters
handleCS42888 handle structure.
channelAIN channel, it shall be 1~4.
volumeVolume 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.

Parameters
handleCS42888 handle structure.
channelAOUT 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.

Parameters
handleCS42888 handle structure.
channelAIN channel, it shall be 1~4.
status_t CS42888_SetMute ( cs42888_handle_t handle,
uint8_t  channelMask 
)
Parameters
handleCS42888 handle structure.
channelMaskChannel 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 
)
Parameters
handleCS42888 handle structure.
channelreference _cs42888_play_channel.
isMutetrue is mute, falase is unmute.
status_t CS42888_SetModule ( cs42888_handle_t handle,
cs42888_module_t  module,
bool  isEnabled 
)
Parameters
handleCS42888 handle structure.
moduleModule expected to enable.
isEnabledEnable 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.

Parameters
handleCS42888 handle structure pointer.
mclkMaster clock frequency of I2S.
sample_rateSample 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.
bitsBit 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 
)
Parameters
handleCS42888 handle structure.
regThe register address in CS42888.
valValue needs to write into the register.
status_t CS42888_ReadReg ( cs42888_handle_t handle,
uint8_t  reg,
uint8_t *  val 
)
Parameters
handleCS42888 handle structure.
regThe register address in CS42888.
valValue written to.
status_t CS42888_ModifyReg ( cs42888_handle_t handle,
uint8_t  reg,
uint8_t  mask,
uint8_t  val 
)
Parameters
handleCS42888 handle structure.
regThe register address in CS42888.
maskThe mask code for the bits want to write. The bit you want to write should be 0.
valValue needs to write into the register.