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

Overview

Data Structures

struct  wm8962_audio_format_t
 wm8962 audio format More...
 
struct  wm8962_fll_clk_config_t
 wm8962 master system clock configuration More...
 
struct  wm8962_route_config_t
 WM8962 data route configurations. More...
 
struct  wm8962_config_t
 Initialize structure of WM8962. More...
 
struct  wm8962_handle_t
 wm8962 codec handler More...
 

Macros

#define WM8962_I2C_HANDLER_SIZE   CODEC_I2C_MASTER_HANDLER_SIZE
 wm8962 handle size
 
#define WM8962_LINVOL   0x0U
 Define the register address of WM8962. More...
 
#define WM8962_CACHEREGNUM   56U
 Cache register number.
 
#define WM8962_CLOCK2_BCLK_DIV_MASK   0xFU
 WM8962 CLOCK2 bits.
 
#define WM8962_IFACE0_FORMAT_MASK   0x13U
 WM8962_IFACE0 FORMAT bits.
 
#define WM8962_IFACE0_WL_MASK   0x0CU
 WM8962_IFACE0 WL bits.
 
#define WM8962_IFACE1_LRP_MASK   0x10U
 WM8962_IFACE1 LRP bit.
 
#define WM8962_IFACE1_DLRSWAP_MASK   0x20U
 WM8962_IFACE1 DLRSWAP bit.
 
#define WM8962_IFACE1_MS_MASK   0x40U
 WM8962_IFACE1 MS bit.
 
#define WM8962_IFACE1_BCLKINV_MASK   0x80U
 WM8962_IFACE1 BCLKINV bit.
 
#define WM8962_IFACE1_ALRSWAP_MASK   0x100U
 WM8962_IFACE1 ALRSWAP bit.
 
#define WM8962_POWER1_VREF_MASK   0x40U
 WM8962_POWER1.
 
#define WM8962_POWER2_DACL_MASK   0x100U
 WM8962_POWER2.
 
#define WM8962_I2C_ADDR   (0x34 >> 1U)
 WM8962 I2C address. More...
 
#define WM8962_I2C_BAUDRATE   (100000U)
 WM8962 I2C baudrate.
 
#define WM8962_ADC_MAX_VOLUME_vALUE   0xFFU
 WM8962 maximum volume value.
 

Enumerations

enum  {
  kWM8962_InputMixerSourceInput2 = 4U,
  kWM8962_InputMixerSourceInput3 = 2U,
  kWM8962_InputMixerSourceInputPGA = 1U
}
 wm8962 input mixer source. More...
 
enum  {
  kWM8962_OutputMixerDisabled = 0U,
  kWM8962_OutputMixerSourceInput4Right = 1U,
  kWM8962_OutputMixerSourceInput4Left = 2U,
  kWM8962_OutputMixerSourceRightInputMixer = 4U,
  kWM8962_OutputMixerSourceLeftInputMixer = 8U,
  kWM8962_OutputMixerSourceRightDAC = 0x10U,
  kWM8962_OutputMixerSourceLeftDAC = 0x20U
}
 wm8962 output mixer source. More...
 
enum  wm8962_module_t {
  kWM8962_ModuleADC = 0,
  kWM8962_ModuleDAC = 1,
  kWM8962_ModuleMICB = 4,
  kWM8962_ModuleMIC = 5,
  kWM8962_ModuleLineIn = 6,
  kWM8962_ModuleHeadphone = 7,
  kWM8962_ModuleSpeaker = 8,
  kWM8962_ModuleHeaphoneMixer = 9,
  kWM8962_ModuleSpeakerMixer = 10
}
 Modules in WM8962 board. More...
 
enum  {
  kWM8962_HeadphoneLeft = 1,
  kWM8962_HeadphoneRight = 2,
  kWM8962_SpeakerLeft = 4,
  kWM8962_SpeakerRight = 8
}
 wm8962 play channel More...
 
enum  wm8962_protocol_t {
  kWM8962_BusPCMA = 4,
  kWM8962_BusPCMB = 3,
  kWM8962_BusI2S = 2,
  kWM8962_BusLeftJustified = 1,
  kWM8962_BusRightJustified = 0
}
 The audio data transfer protocol choice. More...
 
enum  wm8962_input_pga_source_t {
  kWM8962_InputPGASourceInput1 = 8,
  kWM8962_InputPGASourceInput2 = 4,
  kWM8962_InputPGASourceInput3 = 2,
  kWM8962_InputPGASourceInput4 = 1
}
 wm8962 input source More...
 
enum  wm8962_output_pga_source_t {
  kWM8962_OutputPGASourceMixer = 0,
  kWM8962_OutputPGASourceDAC = 1
}
 wm8962 input source More...
 
enum  {
  kWM8962_AudioSampleRate8KHz = 8000U,
  kWM8962_AudioSampleRate11025Hz = 11025U,
  kWM8962_AudioSampleRate12KHz = 12000U,
  kWM8962_AudioSampleRate16KHz = 16000U,
  kWM8962_AudioSampleRate22050Hz = 22050U,
  kWM8962_AudioSampleRate24KHz = 24000U,
  kWM8962_AudioSampleRate32KHz = 32000U,
  kWM8962_AudioSampleRate44100Hz = 44100U,
  kWM8962_AudioSampleRate48KHz = 48000U,
  kWM8962_AudioSampleRate88200Hz = 88200U,
  kWM8962_AudioSampleRate96KHz = 96000U
}
 audio sample rate definition More...
 
enum  {
  kWM8962_AudioBitWidth16bit = 16U,
  kWM8962_AudioBitWidth20bit = 20U,
  kWM8962_AudioBitWidth24bit = 24U,
  kWM8962_AudioBitWidth32bit = 32U
}
 audio bit width More...
 
enum  wm8962_fllclk_source_t {
  kWM8962_FLLClkSourceMCLK = 0U,
  kWM8962_FLLClkSourceBCLK = 1U
}
 wm8962 fll clock source More...
 
enum  wm8962_sysclk_source_t {
  kWM8962_SysClkSourceMclk = 0U,
  kWM8962_SysClkSourceFLL = 1U
}
 wm8962 sysclk source More...
 

Functions

status_t WM8962_Init (wm8962_handle_t *handle, const wm8962_config_t *config)
 WM8962 initialize function. More...
 
status_t WM8962_Deinit (wm8962_handle_t *handle)
 Deinit the WM8962 codec. More...
 
status_t WM8962_SetDataRoute (wm8962_handle_t *handle, const wm8962_route_config_t *route)
 Set audio data route in WM8962. More...
 
status_t WM8962_SetProtocol (wm8962_handle_t *handle, wm8962_protocol_t protocol)
 Set the audio transfer protocol. More...
 
status_t WM8962_SetModuleVolume (wm8962_handle_t *handle, wm8962_module_t module, uint32_t volume)
 Set the volume of different modules in WM8962. More...
 
uint32_t WM8962_GetModuleVolume (wm8962_handle_t *handle, wm8962_module_t module)
 Get the volume of different modules in WM8962. More...
 
status_t WM8962_SetModuleMute (wm8962_handle_t *handle, wm8962_module_t module, bool isEnabled)
 Mute modules in WM8962. More...
 
status_t WM8962_SetModulePower (wm8962_handle_t *handle, wm8962_module_t module, bool isEnabled)
 Enable/disable expected devices. More...
 
status_t WM8962_ConfigDataFormat (wm8962_handle_t *handle, uint32_t sysclk, uint32_t sample_rate, uint32_t bits)
 Configure the data format of audio data. More...
 
status_t WM8962_WriteReg (wm8962_handle_t *handle, uint16_t reg, uint16_t val)
 Write register to WM8962 using I2C. More...
 
status_t WM8962_ReadReg (wm8962_handle_t *handle, uint16_t reg, uint16_t *val)
 Read register from WM8962 using I2C. More...
 
status_t WM8962_ModifyReg (wm8962_handle_t *handle, uint16_t reg, uint16_t mask, uint16_t val)
 Modify some bits in the register using I2C. More...
 

Driver version

#define FSL_WM8962_DRIVER_VERSION   (MAKE_VERSION(2, 2, 0))
 CLOCK driver version 2.1.3.
 

Data Structure Documentation

struct wm8962_audio_format_t

Data Fields

uint32_t mclk_HZ
 master clock frequency
 
uint32_t sampleRate
 sample rate
 
uint32_t bitWidth
 bit width
 
struct wm8962_fll_clk_config_t

Data Fields

wm8962_fllclk_source_t fllClockSource
 fll clock source
 
uint32_t fllReferenceClockFreq
 external input frequency
 
uint32_t fllOutputFreq
 FLL output frequency value.
 
struct wm8962_route_config_t

Data Fields

bool enableLoopBack
 enable loopback: ADC->DAC directly
 
wm8962_input_pga_source_t leftInputPGASource
 Left input source for WM8962.
 
uint32_t leftInputMixerSource
 left input MIXER source, combination value of wm8962_input_mixer_source_t
 
wm8962_input_pga_source_t rightInputPGASource
 right input PGA source
 
uint32_t rightInputMixerSource
 right input MIXER source, combination value of wm8962_input_mixer_source_t
 
uint32_t leftSpeakerMixerSource
 speaker left MIXER source, combination value of wm8962_output_mixer_source_t
 
wm8962_output_pga_source_t leftSpeakerPGASource
 speaker left PGA source
 
uint32_t rightSpeakerMixerSource
 speaker right MIXER source, combination value of wm8962_output_mixer_source_t
 
wm8962_output_pga_source_t rightSpeakerPGASource
 speaker left PGA source
 
uint32_t leftHeadphoneMixerSource
 headphone left MIXER source, combination value of wm8962_output_mixer_source_t
 
wm8962_output_pga_source_t leftHeadphonePGASource
 speaker left PGA source
 
uint32_t rightHeadphoneMixerSource
 headphone left MIXER source, combination value of wm8962_output_mixer_source_t
 
wm8962_output_pga_source_t rightHeadphonePGASource
 speaker left PGA source
 
struct wm8962_config_t

Data Fields

wm8962_route_config_t route
 Audio data route. More...
 
wm8962_protocol_t bus
 Audio transfer protocol.
 
wm8962_audio_format_t format
 Audio format.
 
bool masterSlave
 Master or slave. More...
 
wm8962_sysclk_source_t sysclkSource
 sysclk source
 
wm8962_fll_clk_config_t fllClock
 FLL clock configurations, shall be configured when masterSlave is true.
 
uint8_t slaveAddress
 wm8962 device address
 
codec_i2c_config_t i2cConfig
 i2c configuration
 

Field Documentation

wm8962_route_config_t wm8962_config_t::route
bool wm8962_config_t::masterSlave

true: master mode, false: slave mode

struct wm8962_handle_t

Data Fields

const wm8962_config_tconfig
 wm8904 config pointer
 
uint16_t volume [DEBUG_WM8962_MODULE_NUM]
 Audio volume value.
 
uint8_t i2cHandle [WM8962_I2C_HANDLER_SIZE]
 i2c handle
 

Macro Definition Documentation

#define WM8962_LINVOL   0x0U
#define WM8962_I2C_ADDR   (0x34 >> 1U)

Enumeration Type Documentation

anonymous enum

Enumerator
kWM8962_InputMixerSourceInput2 

input mixer source input 2

kWM8962_InputMixerSourceInput3 

input mixer source input 3

kWM8962_InputMixerSourceInputPGA 

input mixer source input PGA

anonymous enum

Enumerator
kWM8962_OutputMixerDisabled 

output mixer disabled

kWM8962_OutputMixerSourceInput4Right 

output mixer source input 4 left

kWM8962_OutputMixerSourceInput4Left 

output mixer source input 4 right

kWM8962_OutputMixerSourceRightInputMixer 

output mixer source left input mixer

kWM8962_OutputMixerSourceLeftInputMixer 

output mixer source right input mixer

kWM8962_OutputMixerSourceRightDAC 

output mixer source left DAC

kWM8962_OutputMixerSourceLeftDAC 

output mixer source Right DAC

Enumerator
kWM8962_ModuleADC 

ADC module in WM8962.

kWM8962_ModuleDAC 

DAC module in WM8962.

kWM8962_ModuleMICB 

Mic bias.

kWM8962_ModuleMIC 

Input Mic.

kWM8962_ModuleLineIn 

Analog in PGA.

kWM8962_ModuleHeadphone 

Line out module.

kWM8962_ModuleSpeaker 

Speaker module.

kWM8962_ModuleHeaphoneMixer 

Output mixer.

kWM8962_ModuleSpeakerMixer 

Output mixer.

anonymous enum

Enumerator
kWM8962_HeadphoneLeft 

wm8962 headphone left channel

kWM8962_HeadphoneRight 

wm8962 headphone right channel

kWM8962_SpeakerLeft 

wm8962 speaker left channel

kWM8962_SpeakerRight 

wm8962 speaker right channel

WM8962 only supports I2S format and PCM format.

Enumerator
kWM8962_BusPCMA 

PCMA mode.

kWM8962_BusPCMB 

PCMB mode.

kWM8962_BusI2S 

I2S type.

kWM8962_BusLeftJustified 

Left justified mode.

kWM8962_BusRightJustified 

Right justified mode.

Enumerator
kWM8962_InputPGASourceInput1 

Input PGA source input1.

kWM8962_InputPGASourceInput2 

Input PGA source input2.

kWM8962_InputPGASourceInput3 

Input PGA source input3.

kWM8962_InputPGASourceInput4 

Input PGA source input4.

Enumerator
kWM8962_OutputPGASourceMixer 

Output PGA source mixer.

kWM8962_OutputPGASourceDAC 

Output PGA source DAC.

anonymous enum

Enumerator
kWM8962_AudioSampleRate8KHz 

Sample rate 8000 Hz.

kWM8962_AudioSampleRate11025Hz 

Sample rate 11025 Hz.

kWM8962_AudioSampleRate12KHz 

Sample rate 12000 Hz.

kWM8962_AudioSampleRate16KHz 

Sample rate 16000 Hz.

kWM8962_AudioSampleRate22050Hz 

Sample rate 22050 Hz.

kWM8962_AudioSampleRate24KHz 

Sample rate 24000 Hz.

kWM8962_AudioSampleRate32KHz 

Sample rate 32000 Hz.

kWM8962_AudioSampleRate44100Hz 

Sample rate 44100 Hz.

kWM8962_AudioSampleRate48KHz 

Sample rate 48000 Hz.

kWM8962_AudioSampleRate88200Hz 

Sample rate 88200 Hz.

kWM8962_AudioSampleRate96KHz 

Sample rate 96000 Hz.

anonymous enum

Enumerator
kWM8962_AudioBitWidth16bit 

audio bit width 16

kWM8962_AudioBitWidth20bit 

audio bit width 20

kWM8962_AudioBitWidth24bit 

audio bit width 24

kWM8962_AudioBitWidth32bit 

audio bit width 32

Enumerator
kWM8962_FLLClkSourceMCLK 

FLL clock source from MCLK.

kWM8962_FLLClkSourceBCLK 

FLL clock source from BCLK.

Enumerator
kWM8962_SysClkSourceMclk 

sysclk source from external MCLK

kWM8962_SysClkSourceFLL 

sysclk source from internal FLL

Function Documentation

status_t WM8962_Init ( wm8962_handle_t handle,
const wm8962_config_t config 
)

The second parameter is NULL to WM8962 in this version. If users want to change the settings, they have to use wm8962_write_reg() or wm8962_modify_reg() to set the register value of WM8962. Note: If the codec_config is NULL, it would initialize WM8962 using default settings. The default setting: codec_config->route = kWM8962_RoutePlaybackandRecord codec_config->bus = kWM8962_BusI2S codec_config->master = slave

Parameters
handleWM8962 handle structure.
configWM8962 configuration structure.
status_t WM8962_Deinit ( wm8962_handle_t handle)

This function close all modules in WM8962 to save power.

Parameters
handleWM8962 handle structure pointer.
status_t WM8962_SetDataRoute ( wm8962_handle_t handle,
const wm8962_route_config_t route 
)

This function would set the data route according to route. The route cannot be combined, as all route would enable different modules. Note: If a new route is set, the previous route would not work.

Parameters
handleWM8962 handle structure.
routeAudio data route in WM8962.
status_t WM8962_SetProtocol ( wm8962_handle_t handle,
wm8962_protocol_t  protocol 
)

WM8960 only supports I2S, left justified, right justified, PCM A, PCM B format.

Parameters
handleWM8960 handle structure.
protocolAudio data transfer protocol.
status_t WM8962_SetModuleVolume ( wm8962_handle_t handle,
wm8962_module_t  module,
uint32_t  volume 
)

This function would set the volume of WM8962 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.

Module:kWM8962_ModuleADC, volume range value: 0 is mute, 1-255 is -97db to 30db Module:kWM8962_ModuleDAC, volume range value: 0 is mute, 1-255 is -127db to 0db Module:kWM8962_ModuleHP, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db Module:kWM8962_ModuleLineIn, volume range value: 0 - 0x3F is -17.25db to 30db Module:kWM8962_ModuleSpeaker, volume range value: 0 - 2F is mute, 0x30 - 0x7F is -73db to 6db

Parameters
handleWM8962 handle structure.
moduleModule to set volume, it can be ADC, DAC, Headphone and so on.
volumeVolume value need to be set.
uint32_t WM8962_GetModuleVolume ( wm8962_handle_t handle,
wm8962_module_t  module 
)

This function gets the volume of WM8962 modules. Uses need to appoint the module. The function assume that left channel and right channel has the same volume.

Parameters
handleWM8962 handle structure.
moduleModule to set volume, it can be ADC, DAC, Headphone and so on.
Returns
Volume value of the module.
status_t WM8962_SetModuleMute ( wm8962_handle_t handle,
wm8962_module_t  module,
bool  isEnabled 
)
Parameters
handleWM8962 handle structure.
moduleModules need to be mute.
isEnabledMute or unmute, 1 represent mute.
status_t WM8962_SetModulePower ( wm8962_handle_t handle,
wm8962_module_t  module,
bool  isEnabled 
)
Parameters
handleWM8962 handle structure.
moduleModule expected to enable.
isEnabledEnable or disable moudles.
status_t WM8962_ConfigDataFormat ( wm8962_handle_t handle,
uint32_t  sysclk,
uint32_t  sample_rate,
uint32_t  bits 
)

This function would configure the registers about the sample rate, bit depths.

Parameters
handleWM8962 handle structure pointer.
sysclksystem clock of the codec which can be generated by MCLK or PLL output.
sample_rateSample rate of audio file running in WM8962. WM8962 now supports 8k, 11.025k, 12k, 16k, 22.05k, 24k, 32k, 44.1k, 48k and 96k sample rate.
bitsBit depth of audio file (WM8962 only supports 16bit, 20bit, 24bit and 32 bit in HW).
status_t WM8962_WriteReg ( wm8962_handle_t handle,
uint16_t  reg,
uint16_t  val 
)
Parameters
handleWM8962 handle structure.
regThe register address in WM8962.
valValue needs to write into the register.
status_t WM8962_ReadReg ( wm8962_handle_t handle,
uint16_t  reg,
uint16_t *  val 
)
Parameters
handleWM8962 handle structure.
regThe register address in WM8962.
valValue written to.
status_t WM8962_ModifyReg ( wm8962_handle_t handle,
uint16_t  reg,
uint16_t  mask,
uint16_t  val 
)
Parameters
handleWM8962 handle structure.
regThe register address in WM8962.
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.