![]() |
MCUXpresso SDK API Reference Manual
Rev 2.16.000
NXP Semiconductors
|
The wm8904 driver provides a codec control interface.
Data Structures | |
struct | _wm8904_fll_config |
wm8904 fll configuration More... | |
struct | _wm8904_audio_format |
Audio format configuration. More... | |
struct | _wm8904_config |
Configuration structure of WM8904. More... | |
struct | _wm8904_handle |
wm8904 codec handler More... | |
Macros | |
#define | WM8904_I2C_HANDLER_SIZE (CODEC_I2C_MASTER_HANDLER_SIZE) |
wm8904 handle size | |
#define | WM8904_DEBUG_REGISTER 0 |
wm8904 debug macro | |
#define | WM8904_RESET (0x00) |
WM8904 register map. | |
#define | WM8904_I2C_ADDRESS (0x1A) |
WM8904 I2C address. More... | |
#define | WM8904_I2C_BITRATE (400000U) |
WM8904 I2C bit rate. More... | |
#define | WM8904_MAP_HEADPHONE_LINEOUT_MAX_VOLUME 0x3FU |
WM8904 maximum volume. | |
Typedefs | |
typedef enum _wm8904_module | wm8904_module_t |
wm8904 module value | |
typedef enum _wm8904_timeslot | wm8904_timeslot_t |
WM8904 time slot. More... | |
typedef enum _wm8904_protocol | wm8904_protocol_t |
The audio data transfer protocol. More... | |
typedef enum _wm8904_fs_ratio | wm8904_fs_ratio_t |
The SYSCLK / fs ratio. More... | |
typedef enum _wm8904_sample_rate | wm8904_sample_rate_t |
Sample rate. More... | |
typedef enum _wm8904_bit_width | wm8904_bit_width_t |
Bit width. More... | |
typedef enum _wm8904_sys_clk_source | wm8904_sys_clk_source_t |
wm8904 system clock source | |
typedef enum _wm8904_fll_clk_source | wm8904_fll_clk_source_t |
wm8904 fll clock source | |
typedef struct _wm8904_fll_config | wm8904_fll_config_t |
wm8904 fll configuration | |
typedef struct _wm8904_audio_format | wm8904_audio_format_t |
Audio format configuration. More... | |
typedef struct _wm8904_config | wm8904_config_t |
Configuration structure of WM8904. More... | |
typedef struct _wm8904_handle | wm8904_handle_t |
wm8904 codec handler | |
Functions | |
status_t | WM8904_WriteRegister (wm8904_handle_t *handle, uint8_t reg, uint16_t value) |
WM8904 write register. More... | |
status_t | WM8904_ReadRegister (wm8904_handle_t *handle, uint8_t reg, uint16_t *value) |
WM8904 write register. More... | |
status_t | WM8904_ModifyRegister (wm8904_handle_t *handle, uint8_t reg, uint16_t mask, uint16_t value) |
WM8904 modify register. More... | |
status_t | WM8904_Init (wm8904_handle_t *handle, wm8904_config_t *wm8904Config) |
Initializes WM8904. More... | |
status_t | WM8904_Deinit (wm8904_handle_t *handle) |
Deinitializes the WM8904 codec. More... | |
void | WM8904_GetDefaultConfig (wm8904_config_t *config) |
Fills the configuration structure with default values. More... | |
status_t | WM8904_SetMasterSlave (wm8904_handle_t *handle, bool master) |
Sets WM8904 as master or slave. More... | |
status_t | WM8904_SetMasterClock (wm8904_handle_t *handle, uint32_t sysclk, uint32_t sampleRate, uint32_t bitWidth) |
Sets WM8904 master clock configuration. More... | |
status_t | WM8904_SetFLLConfig (wm8904_handle_t *handle, wm8904_fll_config_t *config) |
WM8904 set PLL configuration This function will enable the GPIO1 FLL clock output function, so user can see the generated fll output clock frequency from WM8904 GPIO1. More... | |
status_t | WM8904_SetProtocol (wm8904_handle_t *handle, wm8904_protocol_t protocol) |
Sets the audio data transfer protocol. More... | |
status_t | WM8904_SetAudioFormat (wm8904_handle_t *handle, uint32_t sysclk, uint32_t sampleRate, uint32_t bitWidth) |
Sets the audio data format. More... | |
status_t | WM8904_CheckAudioFormat (wm8904_handle_t *handle, wm8904_audio_format_t *format, uint32_t mclkFreq) |
check and update the audio data format. More... | |
status_t | WM8904_SetVolume (wm8904_handle_t *handle, uint16_t volumeLeft, uint16_t volumeRight) |
Sets the module output volume. More... | |
status_t | WM8904_SetMute (wm8904_handle_t *handle, bool muteLeft, bool muteRight) |
Sets the headphone output mute. More... | |
status_t | WM8904_SelectLRCPolarity (wm8904_handle_t *handle, uint32_t polarity) |
Select LRC polarity. More... | |
status_t | WM8904_EnableDACTDMMode (wm8904_handle_t *handle, wm8904_timeslot_t timeSlot) |
Enable WM8904 DAC time slot. More... | |
status_t | WM8904_EnableADCTDMMode (wm8904_handle_t *handle, wm8904_timeslot_t timeSlot) |
Enable WM8904 ADC time slot. More... | |
status_t | WM8904_SetModulePower (wm8904_handle_t *handle, wm8904_module_t module, bool isEnabled) |
SET the module output power. More... | |
status_t | WM8904_SetDACVolume (wm8904_handle_t *handle, uint8_t volume) |
SET the DAC module volume. More... | |
status_t | WM8904_SetChannelVolume (wm8904_handle_t *handle, uint32_t channel, uint32_t volume) |
Sets the channel output volume. More... | |
status_t | WM8904_SetRecord (wm8904_handle_t *handle, uint32_t recordSource) |
SET the WM8904 record source. More... | |
status_t | WM8904_SetRecordChannel (wm8904_handle_t *handle, uint32_t leftRecordChannel, uint32_t rightRecordChannel) |
SET the WM8904 record source. More... | |
status_t | WM8904_SetPlay (wm8904_handle_t *handle, uint32_t playSource) |
SET the WM8904 play source. More... | |
status_t | WM8904_SetChannelMute (wm8904_handle_t *handle, uint32_t channel, bool isMute) |
Sets the channel mute. More... | |
Driver version | |
#define | FSL_WM8904_DRIVER_VERSION (MAKE_VERSION(2, 5, 1)) |
WM8904 driver version 2.5.1. More... | |
struct _wm8904_fll_config |
Data Fields | |
wm8904_fll_clk_source_t | source |
fll reference clock source | |
uint32_t | refClock_HZ |
fll reference clock frequency | |
uint32_t | outputClock_HZ |
fll output clock frequency | |
struct _wm8904_audio_format |
Data Fields | |
wm8904_fs_ratio_t | fsRatio |
SYSCLK / fs ratio. | |
wm8904_sample_rate_t | sampleRate |
Sample rate. | |
wm8904_bit_width_t | bitWidth |
Bit width. | |
struct _wm8904_config |
Data Fields | |
bool | master |
Master or slave. | |
wm8904_sys_clk_source_t | sysClkSource |
system clock source | |
wm8904_fll_config_t * | fll |
fll configuration | |
wm8904_protocol_t | protocol |
Audio transfer protocol. | |
wm8904_audio_format_t | format |
Audio format. | |
uint32_t | mclk_HZ |
MCLK frequency value. | |
uint16_t | recordSource |
record source | |
uint16_t | recordChannelLeft |
record channel | |
uint16_t | recordChannelRight |
record channel | |
uint16_t | playSource |
play source | |
uint8_t | slaveAddress |
code device slave address | |
codec_i2c_config_t | i2cConfig |
i2c bus configuration | |
struct _wm8904_handle |
Data Fields | |
wm8904_config_t * | config |
wm8904 config pointer | |
uint8_t | i2cHandle [WM8904_I2C_HANDLER_SIZE] |
i2c handle | |
#define FSL_WM8904_DRIVER_VERSION (MAKE_VERSION(2, 5, 1)) |
#define WM8904_I2C_ADDRESS (0x1A) |
#define WM8904_I2C_BITRATE (400000U) |
typedef enum _wm8904_timeslot wm8904_timeslot_t |
typedef enum _wm8904_protocol wm8904_protocol_t |
typedef enum _wm8904_fs_ratio wm8904_fs_ratio_t |
typedef enum _wm8904_sample_rate wm8904_sample_rate_t |
typedef enum _wm8904_bit_width wm8904_bit_width_t |
typedef struct _wm8904_audio_format wm8904_audio_format_t |
typedef struct _wm8904_config wm8904_config_t |
anonymous enum |
enum _wm8904_module |
enum _wm8904_timeslot |
enum _wm8904_protocol |
enum _wm8904_fs_ratio |
enum _wm8904_sample_rate |
enum _wm8904_bit_width |
anonymous enum |
anonymous enum |
anonymous enum |
status_t WM8904_WriteRegister | ( | wm8904_handle_t * | handle, |
uint8_t | reg, | ||
uint16_t | value | ||
) |
handle | WM8904 handle structure. |
reg | register address. |
value | value to write. |
status_t WM8904_ReadRegister | ( | wm8904_handle_t * | handle, |
uint8_t | reg, | ||
uint16_t * | value | ||
) |
handle | WM8904 handle structure. |
reg | register address. |
value | value to read. |
status_t WM8904_ModifyRegister | ( | wm8904_handle_t * | handle, |
uint8_t | reg, | ||
uint16_t | mask, | ||
uint16_t | value | ||
) |
handle | WM8904 handle structure. |
reg | register address. |
mask | register bits mask. |
value | value to write. |
status_t WM8904_Init | ( | wm8904_handle_t * | handle, |
wm8904_config_t * | wm8904Config | ||
) |
handle | WM8904 handle structure. |
wm8904Config | WM8904 configuration structure. |
status_t WM8904_Deinit | ( | wm8904_handle_t * | handle | ) |
This function resets WM8904.
handle | WM8904 handle structure. |
void WM8904_GetDefaultConfig | ( | wm8904_config_t * | config | ) |
The default values are:
master = false; protocol = kWM8904_ProtocolI2S; format.fsRatio = kWM8904_FsRatio64X; format.sampleRate = kWM8904_SampleRate48kHz; format.bitWidth = kWM8904_BitWidth16;
config | default configurations of wm8904. |
status_t WM8904_SetMasterSlave | ( | wm8904_handle_t * | handle, |
bool | master | ||
) |
handle | WM8904 handle structure. |
master | true for master, false for slave. |
status_t WM8904_SetMasterClock | ( | wm8904_handle_t * | handle, |
uint32_t | sysclk, | ||
uint32_t | sampleRate, | ||
uint32_t | bitWidth | ||
) |
User should pay attention to the sysclk parameter ,When using external MCLK as system clock source, the value should be frequency of MCLK, when using FLL as system clock source, the value should be frequency of the output of FLL.
handle | WM8904 handle structure. |
sysclk | system clock source frequency. |
sampleRate | sample rate |
bitWidth | bit width |
status_t WM8904_SetFLLConfig | ( | wm8904_handle_t * | handle, |
wm8904_fll_config_t * | config | ||
) |
handle | wm8904 handler pointer. |
config | FLL configuration pointer. |
status_t WM8904_SetProtocol | ( | wm8904_handle_t * | handle, |
wm8904_protocol_t | protocol | ||
) |
handle | WM8904 handle structure. |
protocol | Audio transfer protocol. |
status_t WM8904_SetAudioFormat | ( | wm8904_handle_t * | handle, |
uint32_t | sysclk, | ||
uint32_t | sampleRate, | ||
uint32_t | bitWidth | ||
) |
User should pay attention to the sysclk parameter ,When using external MCLK as system clock source, the value should be frequency of MCLK, when using FLL as system clock source, the value should be frequency of the output of FLL.
handle | WM8904 handle structure. |
sysclk | system clock source frequency. |
sampleRate | Sample rate frequency in Hz. |
bitWidth | Audio data bit width. |
status_t WM8904_CheckAudioFormat | ( | wm8904_handle_t * | handle, |
wm8904_audio_format_t * | format, | ||
uint32_t | mclkFreq | ||
) |
This api is used check the fsRatio setting based on the mclk and sample rate, if fsRatio setting is not correct, it will correct it according to mclk and sample rate.
handle | WM8904 handle structure. |
format | audio data format |
mclkFreq | mclk frequency |
status_t WM8904_SetVolume | ( | wm8904_handle_t * | handle, |
uint16_t | volumeLeft, | ||
uint16_t | volumeRight | ||
) |
The parameter should be from 0 to 63. The resulting volume will be. 0 for -57DB, 63 for 6DB.
handle | WM8904 handle structure. |
volumeLeft | left channel volume. |
volumeRight | right channel volume. |
status_t WM8904_SetMute | ( | wm8904_handle_t * | handle, |
bool | muteLeft, | ||
bool | muteRight | ||
) |
handle | WM8904 handle structure. |
muteLeft | true to mute left channel, false to unmute. |
muteRight | true to mute right channel, false to unmute. |
status_t WM8904_SelectLRCPolarity | ( | wm8904_handle_t * | handle, |
uint32_t | polarity | ||
) |
handle | WM8904 handle structure. |
polarity | LRC clock polarity. |
status_t WM8904_EnableDACTDMMode | ( | wm8904_handle_t * | handle, |
wm8904_timeslot_t | timeSlot | ||
) |
handle | WM8904 handle structure. |
timeSlot | timeslot number. |
status_t WM8904_EnableADCTDMMode | ( | wm8904_handle_t * | handle, |
wm8904_timeslot_t | timeSlot | ||
) |
handle | WM8904 handle structure. |
timeSlot | timeslot number. |
status_t WM8904_SetModulePower | ( | wm8904_handle_t * | handle, |
wm8904_module_t | module, | ||
bool | isEnabled | ||
) |
handle | WM8904 handle structure. |
module | wm8904 module. |
isEnabled | true is power on, false is power down. |
status_t WM8904_SetDACVolume | ( | wm8904_handle_t * | handle, |
uint8_t | volume | ||
) |
handle | WM8904 handle structure. |
volume | volume to be configured. |
status_t WM8904_SetChannelVolume | ( | wm8904_handle_t * | handle, |
uint32_t | channel, | ||
uint32_t | volume | ||
) |
The parameter should be from 0 to 63. The resulting volume will be. 0 for -57dB, 63 for 6DB.
handle | codec handle structure. |
channel | codec channel. |
volume | volume value from 0 -63. |
status_t WM8904_SetRecord | ( | wm8904_handle_t * | handle, |
uint32_t | recordSource | ||
) |
handle | WM8904 handle structure. |
recordSource | record source , can be a value of kCODEC_ModuleRecordSourceDifferentialLine, kCODEC_ModuleRecordSourceDifferentialMic, kCODEC_ModuleRecordSourceSingleEndMic, kCODEC_ModuleRecordSourceDigitalMic. |
status_t WM8904_SetRecordChannel | ( | wm8904_handle_t * | handle, |
uint32_t | leftRecordChannel, | ||
uint32_t | rightRecordChannel | ||
) |
handle | WM8904 handle structure. |
leftRecordChannel | channel number of left record channel when using differential source, channel number of single end left channel when using single end source, channel number of digital mic when using digital mic source. |
rightRecordChannel | channel number of right record channel when using differential source, channel number of single end right channel when using single end source. |
status_t WM8904_SetPlay | ( | wm8904_handle_t * | handle, |
uint32_t | playSource | ||
) |
handle | WM8904 handle structure. |
playSource | play source , can be a value of kCODEC_ModuleHeadphoneSourcePGA, kCODEC_ModuleHeadphoneSourceDAC, kCODEC_ModuleLineoutSourcePGA, kCODEC_ModuleLineoutSourceDAC. |
status_t WM8904_SetChannelMute | ( | wm8904_handle_t * | handle, |
uint32_t | channel, | ||
bool | isMute | ||
) |
handle | codec handle structure. |
channel | codec module name. |
isMute | true is mute, false unmute. |