|
arduino-audio-driver
|
Header only C++ driver for the TAS6422 2-channel Class-D amplifier. More...
#include <TAS6422DAC.h>
Public Types | |
| enum | Reg : uint8_t { MODE_CTRL_ADDR = 0x00 , MISC_CTRL_1_ADDR = 0x01 , MISC_CTRL_2_ADDR = 0x02 , SAP_CTRL_ADDR = 0x03 , CH_STATE_CTRL_ADDR = 0x04 , CH1_VOLUME_CTRL_ADDR = 0x05 , CH2_VOLUME_CTRL_ADDR = 0x06 , DC_LDG_CTRL_1_ADDR = 0x09 , DC_LDG_CTRL_2_ADDR = 0x0A , DC_LDG_REPORT_1_ADDR = 0x0C , DC_LDG_REPORT_3_ADDR = 0x0E , CH_FAULTS_ADDR = 0x10 , GLOBAL_FAULTS_1_ADDR = 0x11 , GLOBAL_FAULTS_2_ADDR = 0x12 , WARNINGS_ADDR = 0x13 , PIN_CTRL_ADDR = 0x14 , MISC_CTRL_3_ADDR = 0x21 , ILIMIT_STATUS_ADDR = 0x25 , MISC_CTRL_4_ADDR = 0x26 , MISC_CTRL_5_ADDR = 0x28 } |
Public Member Functions | |
| TAS6422DAC () | |
| uint8_t | address () |
| Provides the actual I2C address of the codec. | |
| bool | begin (uint32_t sample_rate, uint8_t bits) |
| Initialize the codec: soft reset, configure the I2S input format/sample rate and apply default output settings (overcurrent level, PWM frequency). The channels are muted (Hiz state is not used) until start() is called. | |
| bool | begin (uint32_t sample_rate, uint8_t bits, codec_mode_t mode, i2s_format_t fmt, bool is_master, uint8_t channels) override |
| Initializes the codec. | |
| bool | begin (uint32_t sample_rate=44100) |
| bool | clearFaults () |
| bool | configureDai (uint32_t sample_rate) |
| Configure the serial audio port: I2S input format and input sampling rate. | |
| bool | configureOutput () |
| Apply default output settings: overcurrent level = 1, PWM frequency = 10 fs (reduced from default to avoid component overtemperature). | |
| bool | getChannelFaults (uint8_t &value) |
| Read the channel faults register (over-current / DC detection) | |
| bool | getGlobalFaults1 (uint8_t &value) |
| Read the global faults 1 register (clock / supply voltage faults) | |
| bool | getGlobalFaults2 (uint8_t &value) |
| Read the global faults 2 register (thermal shutdown faults) | |
| virtual int | getInputVolume () |
| virtual int | getVolume () |
| Provides the output volume in % (0...100) that was set with setVolume() | |
| bool | getWarnings (uint8_t &value) |
| Read the warnings register (POR / over-temperature warnings) | |
| i2c_bus_handle_t | getWire () |
| Provides the actual I2C communication object. | |
| virtual bool | isInputVolumeSupported () |
| Returns true if the driver supports setting the input volume, false otherwise. By default we return false, but some drivers (e.g. WM8962) override this to return true. | |
| virtual bool | setActive (codec_mode_t mode) |
| void | setAddress (uint8_t addr) |
| Defines the I2C address of the codec. | |
| bool | setChannelState (TAS6422Channel channel, TAS6422ChannelState state) |
| Set the channel state (Play, Hiz, Mute or DcLoad) for the given channel(s) | |
| bool | setDevices (input_device_t input_device, output_device_t output_device) override |
| Stores the output device selection for use by configureOutput() | |
| virtual bool | setInputVolume (int volume) |
| virtual bool | setMute (bool mute) |
| bool | setMute (bool mute, TAS6422Channel channel=TAS6422Channel::All) |
| Mute / unmute the given channel(s) | |
| bool | setOutputVolume (int volume, TAS6422Channel channel=TAS6422Channel::All) |
| Set the output volume in 0.5dB steps. | |
| bool | setVolume (int volume) override |
| void | setWire (i2c_bus_handle_t w) |
| Defines the I2C communication object. | |
| bool | softReset () |
| Trigger a soft reset (sets the RESET bit in MODE_CTRL) | |
| bool | start (TAS6422Channel channel=TAS6422Channel::All) |
| Unmute (set to Play state) the given channel(s) | |
| bool | stop (TAS6422Channel channel=TAS6422Channel::All) |
| Mute the given channel(s) | |
Static Public Attributes | |
| static constexpr uint8_t | CH_STATE_CTRL_CH1_STATE_CTRL_MASK = (0x3u << 6) |
| static constexpr uint8_t | CH_STATE_CTRL_CH2_STATE_CTRL_MASK = (0x3u << 4) |
| static constexpr uint8_t | CH_VOLUME_CTRL_VOLUME_MASK = 0xFFu |
| static constexpr uint8_t | MISC_CTRL_1_GAIN_MASK = 0x3u |
| static constexpr uint8_t | MISC_CTRL_1_HPF_BYPASS = (1u << 7) |
| static constexpr uint8_t | MISC_CTRL_1_OC_CONTROL_MASK = (1u << 4) |
| static constexpr uint8_t | MISC_CTRL_1_OTW_CONTROL_MASK = (0x3u << 5) |
| static constexpr uint8_t | MISC_CTRL_1_VOLUME_RATE_MASK = (0x3u << 2) |
| static constexpr uint8_t | MISC_CTRL_2_OUTPUT_PHASE_MASK = 0x3u |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_10_FS = 1 |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_38_FS = 5 |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_44_FS = 6 |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_48_FS = 7 |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_8_FS = 0 |
| static constexpr uint8_t | MISC_CTRL_2_PWM_FREQUENCY_MASK = (0x7u << 4) |
| static constexpr uint8_t | MISC_CTRL_2_SDM_OSR = (1u << 2) |
| static constexpr uint8_t | MODE_CTRL_CH1_LO_MODE = (1u << 3) |
| static constexpr uint8_t | MODE_CTRL_CH2_LO_MODE = (1u << 2) |
| static constexpr uint8_t | MODE_CTRL_PBTL_CH12 = (1u << 4) |
| static constexpr uint8_t | MODE_CTRL_RESET = (1u << 7) |
| static constexpr int | OUTPUT_VOLUME_MAX = (24 * 2) |
| static constexpr int | OUTPUT_VOLUME_MIN = (-100 * 2) |
| static constexpr uint8_t | SAP_CTRL_INPUT_FORMAT_MASK = 0x7u |
| static constexpr uint8_t | SAP_CTRL_INPUT_SAMPLING_RATE_44_1_KHZ = 0 |
| static constexpr uint8_t | SAP_CTRL_INPUT_SAMPLING_RATE_48_KHZ = 1 |
| static constexpr uint8_t | SAP_CTRL_INPUT_SAMPLING_RATE_96_KHZ = 2 |
| static constexpr uint8_t | SAP_CTRL_INPUT_SAMPLING_RATE_MASK = (0x3u << 6) |
| static constexpr uint8_t | SAP_CTRL_TDM_SLOT_SELECT = (1u << 5) |
| static constexpr uint8_t | SAP_CTRL_TDM_SLOT_SELECT_2 = (1u << 3) |
| static constexpr uint8_t | SAP_CTRL_TDM_SLOT_SIZE = (1u << 4) |
Protected Member Functions | |
| bool | readReg (uint8_t reg, uint8_t &value) |
| Reads a single byte from an 8 bit register address. | |
| bool | readReg16 (uint8_t reg, uint16_t &value) |
| Reads a 16 bit (big endian) value from an 8 bit register address. | |
| bool | updateReg (uint8_t reg, uint8_t mask, uint8_t value) |
| Read-Modify-Write of a single byte register. | |
| bool | updateReg16 (uint8_t reg, uint16_t mask, uint16_t value) |
| Read-Modify-Write of a 16 bit (big endian) register. | |
| bool | writeReg (uint8_t reg, uint8_t value) |
| Writes a single byte to an 8 bit register address. | |
| bool | writeReg16 (uint8_t reg, uint16_t value) |
| Writes a 16 bit (big endian) value to an 8 bit register address. | |
Protected Attributes | |
| uint8_t | i2c_addr = 0 |
| int | input_volume_percent = 100 |
| Last input volume (in %) provided to setInputVolume() | |
| output_device_t | output_device = DAC_OUTPUT_ALL |
| Output device selection set via setDevices(), used by configureOutput() | |
| int | volume_percent = 100 |
| Last volume (in %) provided to setVolume() | |
| i2c_bus_handle_t | wire = nullptr |
Header only C++ driver for the TAS6422 2-channel Class-D amplifier.
Provides a soft reset, I2S/sample-rate configuration, per-channel mute/play state control and output volume control, ported from the corresponding Zephyr RTOS driver.
| enum Reg : uint8_t |
|
inline |
|
inlineinherited |
Provides the actual I2C address of the codec.
|
inline |
Initialize the codec: soft reset, configure the I2S input format/sample rate and apply default output settings (overcurrent level, PWM frequency). The channels are muted (Hiz state is not used) until start() is called.
Note: TAS6422 also has an optional hardware MUTE pin; if your board wires it, drive it externally (active = muted) in addition to the register based mute.
| sample_rate | I2S sample rate in Hz (44100, 48000 or 96000) Initializes the codec for I2S with the given sample rate (bits per sample is not configurable on this chip) |
|
inlineoverridevirtual |
Initializes the codec.
Implements ZephyrDriverCommon.
|
inline |
|
inline |
Read and clear the global/channel fault registers (writing 1 to MISC_CTRL_3 CLEAR_FAULT)
|
inline |
Configure the serial audio port: I2S input format and input sampling rate.
| sample_rate | 44100, 48000 or 96000 Hz |
|
inline |
Apply default output settings: overcurrent level = 1, PWM frequency = 10 fs (reduced from default to avoid component overtemperature).
This chip only drives speaker outputs (no headphone path), so it is only configured for DAC_OUTPUT_LINE2 (speaker) and DAC_OUTPUT_ALL. For DAC_OUTPUT_NONE / DAC_OUTPUT_LINE1 (headphone, not supported) all channels are kept muted.
|
inline |
Read the channel faults register (over-current / DC detection)
|
inline |
Read the global faults 1 register (clock / supply voltage faults)
|
inline |
Read the global faults 2 register (thermal shutdown faults)
|
inlinevirtualinherited |
Provides the input volume in % (0...100) that was set with setInputVolume()
|
inlinevirtualinherited |
Provides the output volume in % (0...100) that was set with setVolume()
|
inline |
Read the warnings register (POR / over-temperature warnings)
|
inlineinherited |
Provides the actual I2C communication object.
|
inlinevirtualinherited |
|
inlineprotectedinherited |
Reads a single byte from an 8 bit register address.
|
inlineprotectedinherited |
Reads a 16 bit (big endian) value from an 8 bit register address.
|
inlinevirtualinherited |
Activates/deactivates the playback and/or capture path at runtime (without reconfiguring the codec), based on codec_mode_t (CODEC_MODE_DECODE: playback active, CODEC_MODE_ENCODE: capture active). By default this just mutes/unmutes all outputs depending on CODEC_MODE_DECODE; chip specific subclasses that support muting the input path independently override this to also mute/unmute the capture path depending on CODEC_MODE_ENCODE.
|
inlineinherited |
Defines the I2C address of the codec.
|
inline |
Set the channel state (Play, Hiz, Mute or DcLoad) for the given channel(s)
|
inlineoverridevirtual |
Stores the output device selection for use by configureOutput()
Reimplemented from ZephyrDriverCommon.
|
inlinevirtualinherited |
|
inlinevirtualinherited |
Mutes/unmutes all outputs. Chip specific subclasses map this to their native mute functionality.
Reimplemented in AW88298, DA7212, MAX98091, PCM1681, TAS2563, TLV320AIC3110, TLV320DAC310x, WM8904, WM8962, and SF32LB.
|
inline |
Mute / unmute the given channel(s)
|
inline |
Set the output volume in 0.5dB steps.
| volume | signed volume in 0.5dB steps, range OUTPUT_VOLUME_MIN (-200, i.e. -100dB) .. OUTPUT_VOLUME_MAX (48, i.e. +24dB) |
|
inlineoverridevirtual |
Sets the output volume in % (0...100) for all channels, mapped to [OUTPUT_VOLUME_MIN..OUTPUT_VOLUME_MAX] (0.5dB steps)
Reimplemented from ZephyrDriverCommon.
|
inlineinherited |
Defines the I2C communication object.
|
inline |
Trigger a soft reset (sets the RESET bit in MODE_CTRL)
|
inline |
Unmute (set to Play state) the given channel(s)
|
inline |
Mute the given channel(s)
|
inlineprotectedinherited |
Read-Modify-Write of a single byte register.
|
inlineprotectedinherited |
Read-Modify-Write of a 16 bit (big endian) register.
|
inlineprotectedinherited |
Writes a single byte to an 8 bit register address.
|
inlineprotectedinherited |
Writes a 16 bit (big endian) value to an 8 bit register address.
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protectedinherited |
|
protectedinherited |
Last input volume (in %) provided to setInputVolume()
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protected |
Output device selection set via setDevices(), used by configureOutput()
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protectedinherited |
Last volume (in %) provided to setVolume()
|
protectedinherited |