|
arduino-audio-driver
|
Header only C++ driver for the TAS2563 mono Class-D smart amplifier. More...
#include <TAS2563.h>
Public Member Functions | |
| TAS2563 () | |
| uint8_t | address () |
| Provides the actual I2C address of the codec. | |
| bool | begin (TAS2563SampleRate rate=TAS2563SampleRate::Rate48kHz, uint8_t word_size=16, TAS2563Format format=TAS2563Format::I2S) |
| bool | begin (uint32_t sample_rate, uint8_t bits) |
| Initialize the codec: software reset, set TDM/I2S format and sample rate, set the default amplifier output level and put the amplifier into shutdown mode (call start() to enable the output). | |
| 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. | |
| virtual int | getInputVolume () |
| bool | getRevisionId (uint8_t &rev_id) |
| Read the chip revision / product ID register. | |
| virtual int | getVolume () |
| Provides the output volume in % (0...100) that was set with setVolume() | |
| 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. | |
| bool | selectBook (uint8_t book) |
| Set the active register book (only Book 0 is defined by this driver) | |
| bool | selectPage (uint8_t page) |
| Set the active register page (only Page 0 is defined by this driver) | |
| virtual bool | setActive (codec_mode_t mode) |
| void | setAddress (uint8_t addr) |
| Defines the I2C address of the codec. | |
| bool | setAmpLevel (uint8_t level) |
| Set the amplifier output level register value directly (see AMP_LEVEL_* constants) | |
| virtual bool | setDevices (input_device_t input_device, output_device_t output_device) |
| bool | setFormat (TAS2563SampleRate rate, uint8_t word_size=16, TAS2563Format format=TAS2563Format::I2S) |
| Configure the TDM/I2S digital audio interface: sample rate, word size and frame format. | |
| virtual bool | setInputVolume (int volume) |
| bool | setMute (bool mute) override |
| Mute / unmute the amplifier output (Mute power mode vs. Active) | |
| bool | setVolume (int volume) override |
| Set output volume in percent (0..100), mapped to the amplifier level range. | |
| void | setWire (i2c_bus_handle_t w) |
| Defines the I2C communication object. | |
| bool | softReset () |
| Software reset (TAS2563_SW_RESET register) | |
| bool | start () |
| Start the amplifier output (PWR_MODE = Active) | |
| bool | stop () |
| Stop the amplifier output (PWR_MODE = Shutdown) | |
Static Public Attributes | |
| static constexpr uint8_t | AMP_LEVEL_10_0DBV = 0x04 |
| static constexpr uint8_t | AMP_LEVEL_11_0DBV = 0x06 |
| static constexpr uint8_t | AMP_LEVEL_12_0DBV = 0x08 |
| static constexpr uint8_t | AMP_LEVEL_13_0DBV = 0x0A |
| static constexpr uint8_t | AMP_LEVEL_14_0DBV = 0x0C |
| static constexpr uint8_t | AMP_LEVEL_15_0DBV = 0x0E |
| static constexpr uint8_t | AMP_LEVEL_16_0DBV = 0x10 |
| static constexpr uint8_t | AMP_LEVEL_17_0DBV = 0x12 |
| static constexpr uint8_t | AMP_LEVEL_18_0DBV = 0x14 |
| static constexpr uint8_t | AMP_LEVEL_19_0DBV = 0x16 |
| static constexpr uint8_t | AMP_LEVEL_20_0DBV = 0x18 |
| static constexpr uint8_t | AMP_LEVEL_21_0DBV = 0x1A |
| static constexpr uint8_t | AMP_LEVEL_22_0DBV = 0x1C |
| static constexpr uint8_t | AMP_LEVEL_8_5DBV = 0x01 |
| static constexpr uint8_t | AMP_LEVEL_9_0DBV = 0x02 |
| static constexpr uint8_t | AMP_LEVEL_MASK = 0x3E |
| static constexpr uint8_t | AMP_LEVEL_SHIFT = 1 |
| static constexpr uint8_t | AUTO_RATE = 1U << 4 |
| static constexpr uint8_t | BOOST_EN = 1U << 5 |
| static constexpr uint8_t | BOOST_MODE_ALWAYS_OFF = 0x03 |
| static constexpr uint8_t | BOOST_MODE_ALWAYS_ON = 0x02 |
| static constexpr uint8_t | BOOST_MODE_CLASS_G = 0x01 |
| static constexpr uint8_t | BOOST_MODE_CLASS_H = 0x00 |
| static constexpr uint8_t | BOOST_MODE_MASK = 0xC0 |
| static constexpr uint8_t | CFG2_CONFIG_MASK = 0x3F |
| static constexpr uint8_t | CLASS_D_SYNC = 1U << 6 |
| static constexpr uint8_t | CLR_INT_LTCH = 1U << 2 |
| static constexpr uint8_t | DC_BLOCKER_DIS = 1U << 6 |
| static constexpr uint8_t | DEFAULT_BOOK = 0x00 |
| static constexpr uint8_t | DEFAULT_PAGE = 0x00 |
| static constexpr uint8_t | FRAME_START = 1U << 0 |
| static constexpr uint8_t | I2C_ADDR_DEFAULT = 0x4C |
| static constexpr uint8_t | I2C_ADDR_GLOBAL = 0x48 |
| static constexpr uint8_t | I2C_GLOBAL_EN = 1U << 1 |
| static constexpr uint8_t | INT_OI = 1U << 1 |
| static constexpr uint8_t | INT_OTE = 1U << 0 |
| static constexpr uint8_t | INT_TDMCKE = 1U << 2 |
| static constexpr uint8_t | IRQ_PIN_CFG_LATCHED = 0x01 |
| static constexpr uint8_t | IRQ_PIN_CFG_LIVE = 0x00 |
| static constexpr uint8_t | IRQ_PIN_CFG_MASK = 0x03 |
| static constexpr uint8_t | IRQ_POL = 1U << 7 |
| static constexpr uint8_t | ISNS_PD_MASK = 1U << 3 |
| static constexpr uint8_t | PWR_MODE_MASK = 0x03 |
| static constexpr uint8_t | RAMP_RATE = 1U << 5 |
| static constexpr uint8_t | RX_EDGE = 1U << 0 |
| static constexpr uint8_t | RX_JUSTIFY = 1U << 6 |
| static constexpr uint8_t | RX_OFFSET_MASK = 0x3E |
| static constexpr uint8_t | RX_OFFSET_SHIFT = 1 |
| static constexpr uint8_t | RX_SCFG_MASK = 0x30 |
| static constexpr uint8_t | RX_SCFG_MONO_I2C = 0x00 |
| static constexpr uint8_t | RX_SCFG_MONO_LEFT = 0x01 |
| static constexpr uint8_t | RX_SCFG_MONO_RIGHT = 0x02 |
| static constexpr uint8_t | RX_SCFG_SHIFT = 4 |
| static constexpr uint8_t | RX_SCFG_STEREO_DOWNMIX = 0x03 |
| static constexpr uint8_t | RX_SLEN_16BITS = 0x00 |
| static constexpr uint8_t | RX_SLEN_24BITS = 0x01 |
| static constexpr uint8_t | RX_SLEN_32BITS = 0x02 |
| static constexpr uint8_t | RX_SLEN_MASK = 0x03 |
| static constexpr uint8_t | RX_SLOT_LEFT_MASK = 0x0F |
| static constexpr uint8_t | RX_SLOT_RIGHT_MASK = 0xF0 |
| static constexpr uint8_t | RX_WLEN_16BITS = 0x00 |
| static constexpr uint8_t | RX_WLEN_20BITS = 0x01 |
| static constexpr uint8_t | RX_WLEN_24BITS = 0x02 |
| static constexpr uint8_t | RX_WLEN_32BITS = 0x03 |
| static constexpr uint8_t | RX_WLEN_MASK = 0x0C |
| static constexpr uint8_t | RX_WLEN_SHIFT = 2 |
| static constexpr uint8_t | SAMP_RATE_MASK = 0x0E |
| static constexpr uint8_t | SAMP_RATE_SHIFT = 1 |
| static constexpr uint8_t | SW_RESET_BIT = 1U << 0 |
| static constexpr uint8_t | TX_EDGE = 1U << 0 |
| static constexpr uint8_t | TX_FILL = 1U << 4 |
| static constexpr uint8_t | TX_KEEP_EN = 1U << 5 |
| static constexpr uint8_t | TX_OFFSET_MASK = 0x0E |
| static constexpr uint8_t | VSNS_PD_MASK = 1U << 2 |
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() | |
| int | volume_percent = 100 |
| Last volume (in %) provided to setVolume() | |
| i2c_bus_handle_t | wire = nullptr |
Header only C++ driver for the TAS2563 mono Class-D smart amplifier.
Provides software reset, TDM/I2S format configuration, amplifier output level (volume) and mute/shutdown control, ported from the corresponding Zephyr RTOS driver.
| enum Reg : uint8_t |
|
inline |
|
inlineinherited |
Provides the actual I2C address of the codec.
|
inline |
|
inline |
Initialize the codec: software reset, set TDM/I2S format and sample rate, set the default amplifier output level and put the amplifier into shutdown mode (call start() to enable the output).
| rate | I2S sample rate (one of TAS2563SampleRate) |
| word_size | I2S word size in bits (16, 20, 24, 32) |
| format | Digital audio interface format (I2S or left-justified) Initializes the codec for I2S with the given sample rate (in Hz, mapped to the nearest supported TAS2563SampleRate) and bits per sample |
|
inlineoverridevirtual |
Initializes the codec.
Implements ZephyrDriverCommon.
|
inlinevirtualinherited |
Provides the input volume in % (0...100) that was set with setInputVolume()
|
inline |
Read the chip revision / product ID register.
|
inlinevirtualinherited |
Provides the output volume in % (0...100) that was set with setVolume()
|
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.
|
inline |
Set the active register book (only Book 0 is defined by this driver)
|
inline |
Set the active register page (only Page 0 is defined by this driver)
|
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 amplifier output level register value directly (see AMP_LEVEL_* constants)
|
inlinevirtualinherited |
Selects the ADC input source / DAC output destination. By default this is a no-op; chip specific subclasses that support input/output routing override this to configure the corresponding registers.
Reimplemented in DA7212, MAX98091, TAS6422DAC, TLV320AIC3110, TLV320DAC310x, WM8904, and WM8962.
|
inline |
Configure the TDM/I2S digital audio interface: sample rate, word size and frame format.
|
inlinevirtualinherited |
|
inlineoverridevirtual |
Mute / unmute the amplifier output (Mute power mode vs. Active)
Reimplemented from ZephyrDriverCommon.
|
inlineoverridevirtual |
Set output volume in percent (0..100), mapped to the amplifier level range.
Reimplemented from ZephyrDriverCommon.
|
inlineinherited |
Defines the I2C communication object.
|
inline |
Software reset (TAS2563_SW_RESET register)
|
inline |
Start the amplifier output (PWR_MODE = Active)
|
inline |
Stop the amplifier output (PWR_MODE = Shutdown)
|
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 |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protectedinherited |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
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 |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
staticconstexpr |
|
protectedinherited |
Last volume (in %) provided to setVolume()
|
staticconstexpr |
|
protectedinherited |