Arduino WM8060 Audio Codec
Functions
WM8960 Audio Codec

Transmit Audio. More...

Functions

void mtb_wm8960_set_write_retry_count (uint32_t count)
 Defines the number of times we retry to update a register value via I2C. This might help if you have an instable I2C connection. By default we set it to 1 which will cause the initialization to fail when the register update fails. More...
 
bool mtb_wm8960_init (uint8_t features)
 Initialize the I2C communication with the audio codec, reset the codec and apply default configuration based on the feature(s) requested. More...
 
void mtb_wm8960_free ()
 Frees up any resources allocated by the driver as part of mtb_wm8960_init().
 
bool mtb_wm8960_adjust_input_volume (uint8_t volume)
 This function updates the volume of both the left and right channels of the microphone input. More...
 
bool mtb_wm8960_adjust_heaphone_output_volume (uint8_t volume)
 This function updates the volume of both the left and right channels of the headphone output. More...
 
bool mtb_wm8960_adjust_speaker_output_volume (uint8_t volume)
 This function updates the volume of both the left and right channels of the speaker output. More...
 
bool mtb_wm8960_set_output_volume (uint8_t volume)
 This function updates the volume of both the left and right channels of the speaker and headphones. More...
 
bool mtb_wm8960_activate (void)
 This function powers up the modules the required for the features enabled using mtb_wm8960_init. This function is called in conjunction with mtb_wm8960_deactivate. More...
 
bool mtb_wm8960_deactivate (void)
 This function powers down the modules the required for the features enabled using mtb_wm8960_init. More...
 
bool mtb_wm8960_configure_clocking (uint32_t mclk_hz, bool enable_pll, mtb_wm8960_adc_dac_sample_rate_t sample_rate, mtb_wm8960_word_length_t word_length, mtb_wm8960_mode_t mode)
 This function configures the master clock and the digital interface for the audio codec. More...
 
bool mtb_wm8960_dump ()
 This function dumps the actual register values. More...
 

Detailed Description

Transmit Audio.

Function Documentation

◆ mtb_wm8960_activate()

bool mtb_wm8960_activate ( void  )

This function powers up the modules the required for the features enabled using mtb_wm8960_init. This function is called in conjunction with mtb_wm8960_deactivate.

Note
This function only updates the power management registers (R25[0x19], R26[0x1A], R47[0x2F]) to enable the modules required for the enabled features.
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_adjust_heaphone_output_volume()

bool mtb_wm8960_adjust_heaphone_output_volume ( uint8_t  volume)

This function updates the volume of both the left and right channels of the headphone output.

Parameters
[in]volume- Steps of 1dB, where: Minimum volume: -73dB (0x30) Maximum volume: +6dB (0x7F) Mute: (0x00~0x2F)
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_adjust_input_volume()

bool mtb_wm8960_adjust_input_volume ( uint8_t  volume)

This function updates the volume of both the left and right channels of the microphone input.

Parameters
[in]volume- Steps of 0.75dB, where: Minimum volume: -17.25dB (0x00) Maximum volume: +30dB (0x3F)
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_adjust_speaker_output_volume()

bool mtb_wm8960_adjust_speaker_output_volume ( uint8_t  volume)

This function updates the volume of both the left and right channels of the speaker output.

Parameters
[in]volume- Steps of 1dB, where: Minimum volume: -73dB (0x30) Maximum volume: +6dB (0x7F) Mute: (0x00~0x2F)
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_configure_clocking()

bool mtb_wm8960_configure_clocking ( uint32_t  mclk_hz,
bool  enable_pll,
mtb_wm8960_adc_dac_sample_rate_t  sample_rate,
mtb_wm8960_word_length_t  word_length,
mtb_wm8960_mode_t  mode 
)

This function configures the master clock and the digital interface for the audio codec.

Parameters
[in]mclk_hzThe master clock (MCLK) frequency
[in]enable_pllSet true to enable PLL and false to disable PLL
[in]sample_rateSample rate for the ADC and DAC
[in]word_lengthWord length
[in]modeMode the audio codec to operate as.
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_deactivate()

bool mtb_wm8960_deactivate ( void  )

This function powers down the modules the required for the features enabled using mtb_wm8960_init.

Note
This function only updates the power management registers (R25[0x19], R26[0x1A], R47[0x2F]) to disable the modules required for the enabled features.
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_dump()

bool mtb_wm8960_dump ( )

This function dumps the actual register values.

Parameters
[in]regThe audio codec register to update
[in]maskThe mask used to clear bits in the register
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_init()

bool mtb_wm8960_init ( uint8_t  features)

Initialize the I2C communication with the audio codec, reset the codec and apply default configuration based on the feature(s) requested.

If either WM8960_FEATURE_MICROPHONE or WM8960_FEATURE_HEADPHONE is requested, the following operations will be performed, For either feature features,

  • Set VMID=50K and Enable VREF

For WM8960_FEATURE_MICROPHONE,

  • Enable AINL, AINR, ADCL and ADCR
  • Enable left (LMIC) and right channel (RMIC) input PGA
  • LINPUT1 to PGA (LMN1), Connect left input PGA to left input boost (LMIC2B), Left PGA Boost = 0dB
  • RINPUT1 to PGA (RMN1), Connect right input PGA to right input boost (RMIC2B), Right PGA Boost = 0dB
  • Unmute left input PGA (LINMUTE), Left Input PGA Vol = 0dB, Volume Update
  • Unmute right input PGA (RINMUTE), Right Input PGA Vol = 0dB, Volume Update
  • Left ADC Vol = 0dB, Volume Update
  • Right ADC Vol = 0dB, Volume Update

For WM8960_FEATURE_HEADPHONE,

  • Enable DACL, DACR, LOUT1 and ROUT1
  • Enable left output mixer (LOMIX) and right output mixer (ROMIX)
  • Left DAC to left output mixer enabled (LD2LO), 0dB
  • Right DAC to right output mixer enabled (RD2RO), 0dB
  • LOUT1 Vol = 0dB, volume update enabled
  • ROUT1 Vol = 0dB, volume update enabled
  • Unmute DAC digital soft mute
Parameters
[in]featuresFeatures to enabled during initialization. See mtb_wm8960_features_t
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_set_output_volume()

bool mtb_wm8960_set_output_volume ( uint8_t  volume)

This function updates the volume of both the left and right channels of the speaker and headphones.

Parameters
[in]volume- Steps of 1dB, where: Minimum volume: -73dB (0x30) Maximum volume: +6dB (0x7F) Mute: (0x00~0x2F)
Returns
true if properly initialized, else an error indicating what went wrong.

◆ mtb_wm8960_set_write_retry_count()

void mtb_wm8960_set_write_retry_count ( uint32_t  count)

Defines the number of times we retry to update a register value via I2C. This might help if you have an instable I2C connection. By default we set it to 1 which will cause the initialization to fail when the register update fails.

Parameters
count;0: retry endlessly until success; any number > 0 = number of retries