NetBurner 3.1
WM8904 Class Reference

#include <wm8904.h>

Public Member Functions

 WM8904 (I2C &module)
 The constructor for the WM8904 context. More...
 
void Init (const cfg_t &cfg, const SSC_cfg_t &ssc_cfg)
 Configures and initializes both the driver and the codec. More...
 
void Shutdown ()
 Shuts down the WM8904 codec driver.
 
void WriteReg (Reg::RegAddr_t reg, uint16_t dat)
 Write a register on the WM8904. More...
 
uint16_t ReadReg (Reg::RegAddr_t reg)
 Read a register on the WM8904. More...
 
void SendCmd (Reg::cmd_t cmd)
 Execute codec Command. A command is: a register to write, a value to write, and a delay of time required for command execution. More...
 
void SendCmdList (Reg::cmd_t *cmds, uint32_t len)
 Execute an array of codec Commands. A command is: a register to write, a value to write, and a delay of time required for command execution. More...
 
void UpdateCmd (Reg::cmd_t cmd, uint16_t updateMask)
 Execute a codec Command to update a register. A command is: a register to write, a value to write, and a delay of time required for command execution. More...
 
void SetVolume (AudioOutSelect_t out, AudioChSelect_t channel, uint8_t volume)
 Set the volume of the selected audio output and channel. More...
 
uint8_t GetVolume (AudioOutSelect_t out, AudioChSelect_t channel)
 Get the volume of the selected audio output and channel. More...
 
void Mute (AudioOutSelect_t out, AudioChSelect_t channel, bool mute)
 Mute or unmute the selected audio output and channel. More...
 
void SetMicGain (AudioChSelect_t channel, uint8_t gain)
 Set the microphone gain of the selected input channel. More...
 
uint8_t GetMicGain (AudioChSelect_t channel)
 Get the microphone gain of the selected input channel. More...
 
void MuteMic (AudioChSelect_t channel, bool mute)
 Mute or unmute the selected input channel. More...
 
int TransmitBuffer (void *buffer, uint32_t bufferLen, bool waitIfNeeded)
 Hands off a buffer to be transmitted to the codec. More...
 
int ReadyReceiveBuffer (void *buffer, uint32_t bufferLen, bool waitIfNeeded)
 Hands off a buffer to be written to by the codec. More...
 
void RegisterTxBufferDoneCB (SSC_BufferDoneFn_t cb)
 Registers a callback for when a transmit buffer is finished.
 
void RegisterRxBufferDoneCB (SSC_BufferDoneFn_t cb)
 Registers a callback for when a receive buffer is finished.
 

Detailed Description

WM8904 is a driver for the WM8904 Audio Codec.

Constructor & Destructor Documentation

◆ WM8904()

WM8904::WM8904 ( I2C module)

The constructor for the WM8904 context.

Parameters
moduleA reference to the I2C module to be used for configuring the codec.

Member Function Documentation

◆ GetMicGain()

uint8_t WM8904::GetMicGain ( AudioChSelect_t  channel)

Get the microphone gain of the selected input channel.

Parameters
channelInput Channel to select.
Returns
Gain the channel is set to.

◆ GetVolume()

uint8_t WM8904::GetVolume ( AudioOutSelect_t  out,
AudioChSelect_t  channel 
)

Get the volume of the selected audio output and channel.

Parameters
outAudio Output to select.
channelOutput Channel to select.
Returns
Volume the channel is set to.

◆ Init()

void WM8904::Init ( const cfg_t &  cfg,
const SSC_cfg_t ssc_cfg 
)

Configures and initializes both the driver and the codec.

Parameters
cfgThe driver configuration to use.
ssc_cfgThe SSC driver configuration to use.

◆ Mute()

void WM8904::Mute ( AudioOutSelect_t  out,
AudioChSelect_t  channel,
bool  mute 
)

Mute or unmute the selected audio output and channel.

Parameters
outAudio Output to select.
channelOutput Channel to select.
muteWhether the channel is to be muted.

◆ MuteMic()

void WM8904::MuteMic ( AudioChSelect_t  channel,
bool  mute 
)

Mute or unmute the selected input channel.

Parameters
channelInput Channel to select.
muteWhether the channel is to be muted.

◆ ReadReg()

uint16_t WM8904::ReadReg ( Reg::RegAddr_t  reg)

Read a register on the WM8904.

Parameters
regRegister to write.
Returns
Data read.

◆ ReadyReceiveBuffer()

int WM8904::ReadyReceiveBuffer ( void *  buffer,
uint32_t  bufferLen,
bool  waitIfNeeded 
)

Hands off a buffer to be written to by the codec.

Parameters
bufferA pointer to the buffer to be written to.
bufferLenThe length of the buffer to be written. (Must be multiples of 1, 2, or 4 bytes depending on word bit width)
waitIfNeededWhether the driver should wait for space to receive or fail immediately upon exhausting the queue depth.
Returns
Negative on failure.

◆ SendCmd()

void WM8904::SendCmd ( Reg::cmd_t  cmd)

Execute codec Command. A command is: a register to write, a value to write, and a delay of time required for command execution.

Parameters
cmdCommand to execute

◆ SendCmdList()

void WM8904::SendCmdList ( Reg::cmd_t *  cmds,
uint32_t  len 
)

Execute an array of codec Commands. A command is: a register to write, a value to write, and a delay of time required for command execution.

Parameters
cmdsCommands to execute
lenNumber of commands to execute.

◆ SetMicGain()

void WM8904::SetMicGain ( WM8904::AudioChSelect_t  channel,
uint8_t  gain 
)

Set the microphone gain of the selected input channel.

Parameters
channelInput Channel to select.
gainGain to set channel to.

◆ SetVolume()

void WM8904::SetVolume ( WM8904::AudioOutSelect_t  out,
WM8904::AudioChSelect_t  channel,
uint8_t  volume 
)

Set the volume of the selected audio output and channel.

Parameters
outAudio Output to select.
channelOutput Channel to select.
volumeVolume to set channel to.

◆ TransmitBuffer()

int WM8904::TransmitBuffer ( void *  buffer,
uint32_t  bufferLen,
bool  waitIfNeeded 
)

Hands off a buffer to be transmitted to the codec.

Parameters
bufferA pointer to the buffer to be transmit.
bufferLenThe length of the buffer to be transmit. (Must be multiples of 1, 2, or 4 bytes depending on word bit width)
waitIfNeededWhether the driver should wait for space to transmit or fail immediately upon exhausting the queue depth.
Returns
Negative on failure.

◆ UpdateCmd()

void WM8904::UpdateCmd ( Reg::cmd_t  cmd,
uint16_t  updateMask 
)

Execute a codec Command to update a register. A command is: a register to write, a value to write, and a delay of time required for command execution.

Parameters
cmdCommand to execute
updateMaskA Positive bit mask of bits to update in the target register

◆ WriteReg()

void WM8904::WriteReg ( Reg::RegAddr_t  reg,
uint16_t  dat 
)

Write a register on the WM8904.

Parameters
regRegister to write.
datData to write.

The documentation for this class was generated from the following files: