|
arduino-audio-driver
|
Header-only driver class for the WM8731 codec chip. More...
#include <WM8731.h>
Public Types | |
| enum | ActiveControl : uint16_t { Active = 1 << 0 } |
| Bit flags for the Active Control register. More... | |
| enum | AnaloguePath : uint16_t { MicBoost = 1 << 0 , MuteMic = 1 << 1 , InputSelectMic = 1 << 2 , Bypass = 1 << 3 , DacSelect = 1 << 4 , SideTone = 1 << 5 , SideToneAttenuationMask = 0x3 << 6 } |
| Bit flags for the Analogue Audio Path Control register. More... | |
| enum | DigitalPath : uint16_t { AdcHighPassDisable = 1 << 0 , DeEmphasisDisable = 0x0 << 1 , DeEmphasis32k = 0x1 << 1 , DeEmphasis44_1k = 0x2 << 1 , DeEmphasis48k = 0x3 << 1 , DacSoftMute = 1 << 3 , HighPassOnReset = 1 << 4 } |
| Bit flags for the Digital Audio Path Control register. More... | |
| enum | Format : uint16_t { FormatRightJustified = 0x0 , FormatLeftJustified = 0x1 , FormatI2S = 0x2 , FormatDsp = 0x3 , FormatMask = 0x3 , WordLength16Bit = 0x0 << 2 , WordLength20Bit = 0x1 << 2 , WordLength24Bit = 0x2 << 2 , WordLength32Bit = 0x3 << 2 , WordLengthMask = 0x3 << 2 , LrSwapPolarity = 1 << 4 , LrSwap = 1 << 5 , MasterMode = 1 << 6 , BitClockInvert = 1 << 7 } |
| Bit flags / values for the Digital Audio Interface Format register. More... | |
| enum | HeadphoneOut : uint16_t { HeadphoneVolMask = 0x7F , HeadphoneZeroCross = 1 << 7 , HeadphoneBoth = 1 << 8 } |
| Bit flags for the Left/Right Headphone Out registers. More... | |
| enum | LineIn : uint16_t { LineInVolMask = 0x1F , LineInMute = 1 << 7 , LineInBoth = 1 << 8 } |
| Bit flags for the Left/Right Line In registers. More... | |
| enum | PowerDown : uint16_t { LineInPowerDown = 1 << 0 , MicPowerDown = 1 << 1 , AdcPowerDown = 1 << 2 , DacPowerDown = 1 << 3 , OutputPowerDown = 1 << 4 , OscillatorPowerDown = 1 << 5 , ClockOutPowerDown = 1 << 6 , PowerOff = 1 << 7 } |
| Bit flags for the Power Down Control register. More... | |
| enum class | Reg : uint8_t { LeftLineIn = 0x00 , RightLineIn = 0x01 , LeftHeadphoneOut = 0x02 , RightHeadphoneOut = 0x03 , AnaloguePath = 0x04 , DigitalPath = 0x05 , PowerDown = 0x06 , Format = 0x07 , SamplingControl = 0x08 , Active = 0x09 , Reset = 0x0F } |
| WM8731 register addresses. More... | |
| enum | SamplingControl : uint16_t { UsbMode = 1 << 0 , BaseOversamplingRate = 1 << 1 , SampleRateMask = 0xF << 2 , ClkInDiv2 = 1 << 6 , ClkOutDiv2 = 1 << 7 } |
| Bit flags for the Sampling Control register. More... | |
Public Member Functions | |
| WM8731 ()=default | |
| error_t | configI2S (codec_mode_t mode, I2SDefinition *iface) |
| Configure the digital audio interface format and sample rate. | |
| error_t | ctrlStateActive (codec_mode_t mode, bool ctrl_state_active) |
| Activate or standby the codec. | |
| error_t | deinit (void) |
| Deinitialize the WM8731 codec chip. | |
| error_t | getVoiceVolume (int *volume) |
| Get the headphone / line output volume (0~100) | |
| error_t | init (codec_config_t *cfg) |
| Initialize the WM8731 codec chip. | |
| error_t | reset () |
| Reset all registers to their default values. | |
| error_t | resume (void) |
| Restores the power configuration that was active before standby. | |
| error_t | setActive (bool active) |
| Activates / deactivates the digital audio interface. | |
| void | setAddress (int addr) |
| Defines the I2C device address. | |
| error_t | setVoiceMute (bool enable) |
| Mute / unmute the DAC output. | |
| error_t | setVoiceVolume (int volume) |
| Set the headphone / line output volume. | |
| void | setWire (i2c_bus_handle_t handle) |
| Defines the I2C bus instance to be used. | |
| error_t | standby (void) |
| Powers down all sections (standby) | |
| error_t | writeReg (Reg reg_addr, uint16_t value) |
| Write a value to a WM8731 register. | |
Protected Member Functions | |
| uint16_t | getSamplingControl (samplerate_t rate) |
| Determine the SamplingControl register value for the requested sample rate. | |
| error_t | updatePower (input_device_t input_device, output_device_t output_device) |
| Powers up the input/output sections that are actually used. | |
Protected Attributes | |
| uint16_t | active_control = 0 |
| uint16_t | analogue_path = 0 |
| uint16_t | digital_path = 0 |
| int | i2c_addr = WM8731_ADDR |
| i2c_bus_handle_t | i2c_handle = nullptr |
| bool | initialized = false |
| uint16_t | power_down = 0 |
| int | voice_volume = 70 |
Header-only driver class for the WM8731 codec chip.
| enum ActiveControl : uint16_t |
| enum AnaloguePath : uint16_t |
| enum DigitalPath : uint16_t |
| enum Format : uint16_t |
| enum HeadphoneOut : uint16_t |
| enum LineIn : uint16_t |
| enum PowerDown : uint16_t |
|
strong |
WM8731 register addresses.
| Enumerator | |
|---|---|
| LeftLineIn | |
| RightLineIn | |
| LeftHeadphoneOut | |
| RightHeadphoneOut | |
| AnaloguePath | |
| DigitalPath | |
| PowerDown | |
| Format | |
| SamplingControl | |
| Active | |
| Reset | |
| enum SamplingControl : uint16_t |
|
default |
|
inline |
Configure the digital audio interface format and sample rate.
|
inline |
Activate or standby the codec.
|
inlineprotected |
Determine the SamplingControl register value for the requested sample rate.
|
inline |
Get the headphone / line output volume (0~100)
|
inline |
Initialize the WM8731 codec chip.
|
inline |
Reset all registers to their default values.
|
inline |
Restores the power configuration that was active before standby.
|
inline |
Activates / deactivates the digital audio interface.
|
inline |
Defines the I2C device address.
|
inline |
Mute / unmute the DAC output.
|
inline |
Set the headphone / line output volume.
| volume | voice volume (0~100) |
|
inline |
Defines the I2C bus instance to be used.
|
inline |
Powers down all sections (standby)
|
inlineprotected |
Powers up the input/output sections that are actually used.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |