HPM SDK
HPMicro Software Development Kit
hpm_wm8978.h File Reference
#include "hpm_i2c_drv.h"
#include "hpm_wm8978_regs.h"

Go to the source code of this file.

Data Structures

struct  wm8978_context_t
 

Typedefs

typedef enum wm8978_audio_interface wm8978_audio_interface_t
 
typedef enum wm8978_word_length wm8978_word_length_t
 
typedef enum wm8978_out_channel wm8978_out_channel_t
 
typedef enum input_channel_flag input_channel_flags_t
 
typedef enum output_channel_flag output_channel_flag_t
 

Enumerations

enum  wm8978_audio_interface { wm8978_right_justified = 0 , wm8978_left_justified , wm8978_philips_i2s , wm8978_pcm_mode }
 
enum  wm8978_word_length { wm8978_16bits_length = 0 , wm8978_20bits_length , wm8978_24bits_length , wm8978_32bits_length }
 
enum  wm8978_out_channel { wm8978_out1_channel = 0 , wm8978_out2_channel = 1 }
 
enum  input_channel_flag {
  input_off = 0x00 , mic_left_on = 0x01 , mic_right_on = 0x02 , line_on = 0x04 ,
  aux_on = 0x08 , dac_on = 0x10 , adc_on = 0x20
}
 
enum  output_channel_flag {
  output_off = 0x00 , earphone_left_on = 0x01 , earphone_right_on = 0x02 , spk_on = 0x04 ,
  out_3_4_on = 0x08
}
 

Functions

hpm_stat_t wm8979_init (wm8978_context_t *control)
 WM8979 initialize function. More...
 
hpm_stat_t wm8978_set_out_volume (wm8978_context_t *control, wm8978_out_channel_t channel, uint8_t volume)
 WM8979 set out volume function. More...
 
hpm_stat_t wm8978_get_out_volume (wm8978_context_t *control, wm8978_out_channel_t channel, uint8_t *volume)
 WM8979 read out volume function. More...
 
hpm_stat_t wm8978_set_out_mute (wm8978_context_t *control, wm8978_out_channel_t channel, bool mute)
 WM8979 set out mute. More...
 
hpm_stat_t wm8978_set_mic_gain (wm8978_context_t *control, uint8_t gain)
 WM8979 set gain of mic. More...
 
hpm_stat_t wm8978_set_line_gain (wm8978_context_t *control, uint8_t gain)
 WM8979 set the gain of the Line input channel. More...
 
hpm_stat_t wm8978_power_down (wm8978_context_t *control)
 WM8979 enter power down mode. More...
 
hpm_stat_t wm8978_ctrl_gpio1 (wm8978_context_t *control, bool value)
 Control the GPIO1 pin of WM8978 to output high or low. More...
 
hpm_stat_t wm8978_cfg_audio_interface (wm8978_context_t *control, wm8978_audio_interface_t standard, wm8978_word_length_t word_len)
 Configuring the audio interface of WM8978. More...
 
hpm_stat_t wm8978_cfg_audio_channel (wm8978_context_t *control, uint8_t in_flags, uint8_t out_flags)
 Configure wm8978 audio channel. More...
 
hpm_stat_t wm8978_notch_filter (wm8978_context_t *control, uint16_t nfa0, uint16_t nfa1)
 setting the Notch Filter for WM8978 More...
 
hpm_stat_t wm8978_reset (wm8978_context_t *control)
 Write register to WM8978 using I2C. More...
 
hpm_stat_t wm8978_write_reg (wm8978_context_t *control, uint8_t reg, uint16_t val)
 Write register to WM8978 using I2C. More...
 
hpm_stat_t wm8978_read_reg (wm8978_context_t *control, uint8_t reg, uint16_t *val)
 Read register from WM8978 using I2C. More...
 
hpm_stat_t wm8978_modify_reg (wm8978_context_t *control, uint8_t reg, uint16_t mask, uint16_t val)
 Modify some bits in the register using I2C. More...
 

Typedef Documentation

◆ input_channel_flags_t

◆ output_channel_flag_t

◆ wm8978_audio_interface_t

◆ wm8978_out_channel_t

◆ wm8978_word_length_t

Enumeration Type Documentation

◆ input_channel_flag

Enumerator
input_off 
mic_left_on 
mic_right_on 
line_on 
aux_on 
dac_on 
adc_on 

◆ output_channel_flag

Enumerator
output_off 
earphone_left_on 
earphone_right_on 
spk_on 
out_3_4_on 

◆ wm8978_audio_interface

Enumerator
wm8978_right_justified 
wm8978_left_justified 
wm8978_philips_i2s 
wm8978_pcm_mode 

◆ wm8978_out_channel

Enumerator
wm8978_out1_channel 
wm8978_out2_channel 

◆ wm8978_word_length

Enumerator
wm8978_16bits_length 
wm8978_20bits_length 
wm8978_24bits_length 
wm8978_32bits_length 

Function Documentation

◆ wm8978_cfg_audio_channel()

hpm_stat_t wm8978_cfg_audio_channel ( wm8978_context_t control,
uint8_t  in_flags,
uint8_t  out_flags 
)

Configure wm8978 audio channel.

Parameters
[in]controlWM8979 control structure.
[in]in_flagsFlags for the input channel
[in]out_flagsFlags for the output channel
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_cfg_audio_interface()

hpm_stat_t wm8978_cfg_audio_interface ( wm8978_context_t control,
wm8978_audio_interface_t  standard,
wm8978_word_length_t  word_len 
)

Configuring the audio interface of WM8978.

Parameters
[in]controlWM8979 control structure.
[in]standardwm8978_audio_interface_t structure
[in]word_lenwm8978_word_length_t structure
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_ctrl_gpio1()

hpm_stat_t wm8978_ctrl_gpio1 ( wm8978_context_t control,
bool  value 
)

Control the GPIO1 pin of WM8978 to output high or low.

Parameters
[in]controlWM8979 control structure.
[in]valueoutput high or low. if true, it's high
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_get_out_volume()

hpm_stat_t wm8978_get_out_volume ( wm8978_context_t control,
wm8978_out_channel_t  channel,
uint8_t *  volume 
)

WM8979 read out volume function.

Parameters
[in]controlWM8979 control structure.
[in]channelout channel
[out]volumevolume points value
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_modify_reg()

hpm_stat_t wm8978_modify_reg ( wm8978_context_t control,
uint8_t  reg,
uint16_t  mask,
uint16_t  val 
)

Modify some bits in the register using I2C.

Parameters
[in]controlWM8978 control structure.
[in]regThe register address in WM8978.
[in]maskThe mask code for the bits want to write. The bit you want to write should be 0.
[in]valValue needs to write into the register.
Return values
hpm_stat_tstatus_success if modify reg without any error

◆ wm8978_notch_filter()

hpm_stat_t wm8978_notch_filter ( wm8978_context_t control,
uint16_t  nfa0,
uint16_t  nfa1 
)

setting the Notch Filter for WM8978

Note
used to suppress positive feedback of microphone sound waves to avoid howling
Parameters
[in]controlWM8979 control structure.
[in]nfa0Notch Filter0 value
[in]nfa1Notch Filter1 value
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_power_down()

hpm_stat_t wm8978_power_down ( wm8978_context_t control)

WM8979 enter power down mode.

Parameters
[in]controlWM8979 control structure.
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_read_reg()

hpm_stat_t wm8978_read_reg ( wm8978_context_t control,
uint8_t  reg,
uint16_t *  val 
)

Read register from WM8978 using I2C.

Parameters
[in]regThe register address in WM8978.
[in]regThe register address in WM8978.
[out]valValue point read to.
Return values
hpm_stat_tstatus_success if read reg without any error

◆ wm8978_reset()

hpm_stat_t wm8978_reset ( wm8978_context_t control)

Write register to WM8978 using I2C.

Parameters
[in]controlWM8978 control structure.
Return values
hpm_stat_tstatus_success if reset without any error

◆ wm8978_set_line_gain()

hpm_stat_t wm8978_set_line_gain ( wm8978_context_t control,
uint8_t  gain 
)

WM8979 set the gain of the Line input channel.

Parameters
[in]controlWM8979 control structure.
[in]gainvolume value, range: 0 ~ 7
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_set_mic_gain()

hpm_stat_t wm8978_set_mic_gain ( wm8978_context_t control,
uint8_t  gain 
)

WM8979 set gain of mic.

Parameters
[in]controlWM8979 control structure.
[in]gaingain value, range: 0 ~ 63
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_set_out_mute()

hpm_stat_t wm8978_set_out_mute ( wm8978_context_t control,
wm8978_out_channel_t  channel,
bool  mute 
)

WM8979 set out mute.

Parameters
[in]controlWM8979 control structure.
[in]channelout channel
[in]muteif mute is set to true
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_set_out_volume()

hpm_stat_t wm8978_set_out_volume ( wm8978_context_t control,
wm8978_out_channel_t  channel,
uint8_t  volume 
)

WM8979 set out volume function.

Parameters
[in]controlWM8979 control structure.
[in]channelout channel
[in]volumevolume value
Return values
hpm_stat_tstatus_success if set without any error

◆ wm8978_write_reg()

hpm_stat_t wm8978_write_reg ( wm8978_context_t control,
uint8_t  reg,
uint16_t  val 
)

Write register to WM8978 using I2C.

Parameters
[in]controlWM8978 control structure.
[in]regThe register address in WM8978.
[in]valValue needs to write into the register.
Return values
hpm_stat_tstatus_success if write reg without any error

◆ wm8979_init()

hpm_stat_t wm8979_init ( wm8978_context_t control)

WM8979 initialize function.

Parameters
[in]controlWM8979 control structure.
Return values
hpm_stat_tstatus_success if init without any error