#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. | |
WM8904::WM8904 | ( | I2C & | module | ) |
uint8_t WM8904::GetMicGain | ( | AudioChSelect_t | channel | ) |
Get the microphone gain of the selected input channel.
channel | Input Channel to select. |
uint8_t WM8904::GetVolume | ( | AudioOutSelect_t | out, |
AudioChSelect_t | channel | ||
) |
Get the volume of the selected audio output and channel.
out | Audio Output to select. |
channel | Output Channel to select. |
void WM8904::Init | ( | const cfg_t & | cfg, |
const SSC_cfg_t & | ssc_cfg | ||
) |
Configures and initializes both the driver and the codec.
cfg | The driver configuration to use. |
ssc_cfg | The SSC driver configuration to use. |
void WM8904::Mute | ( | AudioOutSelect_t | out, |
AudioChSelect_t | channel, | ||
bool | mute | ||
) |
Mute or unmute the selected audio output and channel.
out | Audio Output to select. |
channel | Output Channel to select. |
mute | Whether the channel is to be muted. |
void WM8904::MuteMic | ( | AudioChSelect_t | channel, |
bool | mute | ||
) |
Mute or unmute the selected input channel.
channel | Input Channel to select. |
mute | Whether the channel is to be muted. |
uint16_t WM8904::ReadReg | ( | Reg::RegAddr_t | reg | ) |
int WM8904::ReadyReceiveBuffer | ( | void * | buffer, |
uint32_t | bufferLen, | ||
bool | waitIfNeeded | ||
) |
Hands off a buffer to be written to by the codec.
buffer | A pointer to the buffer to be written to. |
bufferLen | The length of the buffer to be written. (Must be multiples of 1, 2, or 4 bytes depending on word bit width) |
waitIfNeeded | Whether the driver should wait for space to receive or fail immediately upon exhausting the queue depth. |
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.
cmd | Command to execute |
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.
cmds | Commands to execute |
len | Number of commands to execute. |
void WM8904::SetMicGain | ( | WM8904::AudioChSelect_t | channel, |
uint8_t | gain | ||
) |
Set the microphone gain of the selected input channel.
channel | Input Channel to select. |
gain | Gain to set channel to. |
void WM8904::SetVolume | ( | WM8904::AudioOutSelect_t | out, |
WM8904::AudioChSelect_t | channel, | ||
uint8_t | volume | ||
) |
Set the volume of the selected audio output and channel.
out | Audio Output to select. |
channel | Output Channel to select. |
volume | Volume to set channel to. |
int WM8904::TransmitBuffer | ( | void * | buffer, |
uint32_t | bufferLen, | ||
bool | waitIfNeeded | ||
) |
Hands off a buffer to be transmitted to the codec.
buffer | A pointer to the buffer to be transmit. |
bufferLen | The length of the buffer to be transmit. (Must be multiples of 1, 2, or 4 bytes depending on word bit width) |
waitIfNeeded | Whether the driver should wait for space to transmit or fail immediately upon exhausting the queue depth. |
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.
cmd | Command to execute |
updateMask | A Positive bit mask of bits to update in the target register |
void WM8904::WriteReg | ( | Reg::RegAddr_t | reg, |
uint16_t | dat | ||
) |
Write a register on the WM8904.
reg | Register to write. |
dat | Data to write. |