Go to the documentation of this file.
10 #define _FSL_WM8904_H_
25 #define FSL_WM8904_DRIVER_VERSION (MAKE_VERSION(2, 4, 1))
29 #ifndef WM8904_I2C_HANDLER_SIZE
30 #define WM8904_I2C_HANDLER_SIZE (CODEC_I2C_MASTER_HANDLER_SIZE)
33 #ifndef WM8904_DEBUG_REGISTER
34 #define WM8904_DEBUG_REGISTER 0
38 #define WM8904_RESET (0x00)
39 #define WM8904_ANALOG_ADC_0 (0x0A)
40 #define WM8904_POWER_MGMT_0 (0x0C)
41 #define WM8904_POWER_MGMT_2 (0x0E)
42 #define WM8904_POWER_MGMT_3 (0x0F)
43 #define WM8904_POWER_MGMT_6 (0x12)
44 #define WM8904_CLK_RATES_0 (0x14)
45 #define WM8904_CLK_RATES_1 (0x15)
46 #define WM8904_CLK_RATES_2 (0x16)
47 #define WM8904_AUDIO_IF_0 (0x18)
48 #define WM8904_AUDIO_IF_1 (0x19)
49 #define WM8904_AUDIO_IF_2 (0x1A)
50 #define WM8904_AUDIO_IF_3 (0x1B)
51 #define WM8904_DAC_DIG_1 (0x21)
52 #define WM8904_DAC_DIG_0 (0x27)
53 #define WM8904_ANALOG_LEFT_IN_0 (0x2C)
54 #define WM8904_ANALOG_RIGHT_IN_0 (0x2D)
55 #define WM8904_ANALOG_LEFT_IN_1 (0x2E)
56 #define WM8904_ANALOG_RIGHT_IN_1 (0x2F)
57 #define WM8904_ANALOG_OUT1_LEFT (0x39)
58 #define WM8904_ANALOG_OUT1_RIGHT (0x3A)
59 #define WM8904_ANALOG_OUT12_ZC (0x3D)
60 #define WM8904_DC_SERVO_0 (0x43)
61 #define WM8904_ANALOG_HP_0 (0x5A)
62 #define WM8904_CHRG_PUMP_0 (0x62)
63 #define WM8904_CLS_W_0 (0x68)
64 #define WM8904_WRT_SEQUENCER_0 (0x6C)
65 #define WM8904_WRT_SEQUENCER_3 (0x6F)
66 #define WM8904_WRT_SEQUENCER_4 (0x70)
67 #define WM8904_DAC_DIGITAL_VOLUME_LEFT (0x1E)
68 #define WM8904_DAC_DIGITAL_VOLUME_RIGHT (0x1F)
69 #define WM8904_ADC_DIGITAL_VOLUME_LEFT (0x24)
70 #define WM8904_ADC_DIGITAL_VOLUME_RIGHT (0x25)
71 #define WM8904_ANALOG_OUT2_LEFT (0x3B)
72 #define WM8904_ANALOG_OUT2_RIGHT (0x3C)
73 #define WM8904_GPIO_CONTROL_4 (0x7C)
75 #define WM8904_FLL_CONTROL_1 (0x74)
76 #define WM8904_FLL_CONTROL_2 (0x75)
77 #define WM8904_FLL_CONTROL_3 (0x76)
78 #define WM8904_FLL_CONTROL_4 (0x77)
79 #define WM8904_FLL_CONTROL_5 (0x78)
81 #define WM8904_GPIO_CONTROL_1 (0x79)
82 #define WM8904_GPIO_CONTROL_2 (0x7A)
83 #define WM8904_GPIO_CONTROL_3 (0x7B)
84 #define WM8904_GPIO_CONTROL_4 (0x7C)
86 #define WM8904_FLL_NCO_TEST_0 (0xF7U)
87 #define WM8904_FLL_NCO_TEST_1 (0xF8U)
90 #define WM8904_I2C_ADDRESS (0x1A)
93 #define WM8904_I2C_BITRATE (400000U)
272 #if defined(__cplusplus)
465 #if WM8904_DEBUG_REGISTER
548 #if defined(__cplusplus)
status_t WM8904_CheckAudioFormat(wm8904_handle_t *handle, wm8904_audio_format_t *format, uint32_t mclkFreq)
check and update the audio data format. This api is used check the fsRatio setting based on the mclk ...
_wm8904_lrc_polarity
WM8904 lrc polarity.
@ kWM8904_RecordSourceDigitalMic
status_t WM8904_SetChannelVolume(wm8904_handle_t *handle, uint32_t channel, uint32_t volume)
Sets the channel output volume.
@ kWM8904_SampleRate16kHz
_wm8904_sys_clk_source
wm8904 system clock source
codec_i2c_config_t i2cConfig
_wm8904_record_channel
wm8904 record channel
enum _wm8904_bit_width wm8904_bit_width_t
Bit width.
@ kWM8904_ModuleHeadphone
@ kWM8904_RecordChannelLeft3
@ kWM8904_SampleRate12kHz
_wm8904_timeslot
WM8904 time slot.
Configuration structure of WM8904.
struct _wm8904_audio_format wm8904_audio_format_t
Audio format configuration.
@ kWM8904_ProtocolLeftJustified
status_t WM8904_SetModulePower(wm8904_handle_t *handle, wm8904_module_t module, bool isEnabled)
wm8904_bit_width_t bitWidth
_wm8904_fs_ratio
The SYSCLK / fs ratio.
status_t WM8904_SeMasterClock(wm8904_handle_t *handle, uint32_t sysclk, uint32_t sampleRate, uint32_t bitWidth)
Sets WM8904 master clock configuration.
uint16_t recordChannelLeft
CODEC I2C configurations structure.
wm8904_protocol_t protocol
wm8904_fs_ratio_t fsRatio
enum _wm8904_protocol wm8904_protocol_t
The audio data transfer protocol.
enum _wm8904_sys_clk_source wm8904_sys_clk_source_t
wm8904 system clock source
@ kWM8904_LRCPolarityNormal
status_t WM8904_Deinit(wm8904_handle_t *handle)
Deinitializes the WM8904 codec.
_wm8904_record_source
wm8904 record source
@ kWM8904_RecordChannelDifferentialPositive1
@ kWM8904_FLLClkSourceMCLK
@ kWM8904_RecordSourceDifferentialMic
status_t WM8904_SetPlay(wm8904_handle_t *handle, uint32_t playSource)
SET the WM8904 play source.
@ kWM8904_ProtocolRightJustified
@ kWM8904_SysClkSourceFLL
status_t WM8904_WriteRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t value)
WM8904 write register.
@ kWM8904_RecordChannelDifferentialNegative3
@ kWM8904_LRCPolarityInverted
wm8904_fll_clk_source_t source
_wm8904_fll_clk_source
wm8904 fll clock source
@ kWM8904_RecordChannelDifferentialPositive3
@ kWM8904_RecordChannelLeft2
enum _wm8904_fs_ratio wm8904_fs_ratio_t
The SYSCLK / fs ratio.
@ kWM8904_RecordChannelRight3
status_t WM8904_ModifyRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t mask, uint16_t value)
WM8904 modify register.
#define WM8904_I2C_HANDLER_SIZE
wm8904 handle size
status_t WM8904_Init(wm8904_handle_t *handle, wm8904_config_t *wm8904_config)
Initializes WM8904.
status_t WM8904_SetRecordChannel(wm8904_handle_t *handle, uint32_t leftRecordChannel, uint32_t rightRecordChannel)
SET the WM8904 record source.
@ kWM8904_RecordChannelLeft1
enum _wm8904_fll_clk_source wm8904_fll_clk_source_t
wm8904 fll clock source
status_t WM8904_SetProtocol(wm8904_handle_t *handle, wm8904_protocol_t protocol)
Sets the audio data transfer protocol.
enum _wm8904_sample_rate wm8904_sample_rate_t
Sample rate.
@ kWM8904_RecordSourceLineInput
uint16_t recordChannelRight
status_t WM8904_SetMute(wm8904_handle_t *handle, bool muteLeft, bool muteRight)
Sets the headphone output mute.
status_t WM8904_ReadRegister(wm8904_handle_t *handle, uint8_t reg, uint16_t *value)
WM8904 write register.
struct _wm8904_handle wm8904_handle_t
wm8904 codec handler
wm8904_fll_config_t * fll
@ kWM8904_SampleRate24kHz
status_t WM8904_EnableADCTDMMode(wm8904_handle_t *handle, wm8904_timeslot_t timeSlot)
Enable WM8904 ADC time slot.
@ kWM8904_RecordChannelDifferentialNegative1
_wm8904_sample_rate
Sample rate.
wm8904_audio_format_t format
enum _wm8904_module wm8904_module_t
wm8904 module value
@ kWM8904_RecordChannelRight1
enum _wm8904_timeslot wm8904_timeslot_t
WM8904 time slot.
@ kWM8904_SampleRate32kHz
wm8904_sample_rate_t sampleRate
uint8_t i2cHandle[WM8904_I2C_HANDLER_SIZE]
@ kWM8904_RecordChannelDifferentialPositive2
wm8904_sys_clk_source_t sysClkSource
_wm8904_play_source
wm8904 play source
@ kWM8904_RecordChannelDifferentialNegative2
_wm8904_status
WM8904 status return codes.
void WM8904_GetDefaultConfig(wm8904_config_t *config)
Fills the configuration structure with default values.
struct _wm8904_config wm8904_config_t
Configuration structure of WM8904.
@ kWM8904_SysClkSourceMCLK
_wm8904_protocol
The audio data transfer protocol.
status_t WM8904_SelectLRCPolarity(wm8904_handle_t *handle, uint32_t polarity)
Select LRC polarity.
status_t WM8904_SetRecord(wm8904_handle_t *handle, uint32_t recordSource)
SET the WM8904 record source.
static sai_transceiver_t config
status_t WM8904_SetVolume(wm8904_handle_t *handle, uint16_t volumeLeft, uint16_t volumeRight)
Sets the module output volume.
status_t WM8904_SetAudioFormat(wm8904_handle_t *handle, uint32_t sysclk, uint32_t sampleRate, uint32_t bitWidth)
Sets the audio data format.
_wm8904_play_channel
wm8904 play channel
status_t WM8904_EnableDACTDMMode(wm8904_handle_t *handle, wm8904_timeslot_t timeSlot)
Enable WM8904 DAC time slot.
@ kWM8904_SampleRate48kHz
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,...
status_t WM8904_SetMasterSlave(wm8904_handle_t *handle, bool master)
Sets WM8904 as master or slave.
struct _wm8904_fll_config wm8904_fll_config_t
wm8904 fll configuration
_wm8904_bit_width
Bit width.
int32_t status_t
Type used for all status and error return values.
@ kWM8904_RecordChannelRight2
@ kWM8904_RecordSourceDifferentialLine
_wm8904_module
wm8904 module value
status_t WM8904_SetChannelMute(wm8904_handle_t *handle, uint32_t channel, bool isMute)
Sets the channel mute.