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

Macros

#define WM8978_I2C_SLAVE_ADDRESS1   (0x1A)
 
#define WM8978_I2C_SLAVE_ADDRESS2   (0x1A)
 

Functions

hpm_stat_t wm8979_init (wm8978_context_t *control)
 WM8979 initialize function. More...
 
hpm_stat_t wm8978_reset (wm8978_context_t *control)
 Write register to WM8978 using I2C. 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_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_ctrl_gpio1 (wm8978_context_t *control, bool value)
 Control the GPIO1 pin of WM8978 to output high or low. 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...
 

Variables

static volatile uint16_t wm8978_reg_val []
 

Macro Definition Documentation

◆ WM8978_I2C_SLAVE_ADDRESS1

#define WM8978_I2C_SLAVE_ADDRESS1   (0x1A)

◆ WM8978_I2C_SLAVE_ADDRESS2

#define WM8978_I2C_SLAVE_ADDRESS2   (0x1A)

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

Variable Documentation

◆ wm8978_reg_val

volatile uint16_t wm8978_reg_val[]
static
Initial value:
= {
0x000, 0x000, 0x000, 0x000, 0x050, 0x000, 0x140, 0x000,
0x000, 0x000, 0x000, 0x0FF, 0x0FF, 0x000, 0x100, 0x0FF,
0x0FF, 0x000, 0x12C, 0x02C, 0x02C, 0x02C, 0x02C, 0x000,
0x032, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000, 0x000,
0x038, 0x00B, 0x032, 0x000, 0x008, 0x00C, 0x093, 0x0E9,
0x000, 0x000, 0x000, 0x000, 0x003, 0x010, 0x010, 0x100,
0x100, 0x002, 0x001, 0x001, 0x039, 0x039, 0x039, 0x039,
}