|
arduino-audio-driver
|
Header only C++ driver for the PCM1681 8-channel audio DAC. More...
#include <PCM1681.h>
Public Types | |
| enum | Reg : uint8_t { REG_0 = 0x00 , AT1x_REG = 0x01 , AT2x_REG = 0x02 , AT3x_REG = 0x03 , AT4x_REG = 0x04 , AT5x_REG = 0x05 , AT6x_REG = 0x06 , MUTx_REG = 0x07 , DACx_REG = 0x08 , FMTx_REG = 0x09 , SRST_REG = 0x0A , REVx_REG = 0x0B , FLTx_REG = 0x0C , DAMS_REG = 0x0D , REG_14 = 0x0E , REG_15 = 0x0F , AT7x_REG = 0x10 , AT8x_REG = 0x11 , MUT_OR_REG = 0x12 , DAC_OR_REG = 0x13 } |
Public Member Functions | |
| PCM1681 () | |
| uint8_t | address () |
| Provides the actual I2C address of the codec. | |
| bool | applyProperties () |
| bool | begin (PCM1681Format format=PCM1681Format::I2S_16_24) |
| bool | begin (uint32_t sample_rate, uint8_t bits) |
| Initialize the codec: reset the local register shadow to the factory defaults, configure the DAI format and write everything to the device. | |
| 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 () |
| 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. | |
| virtual bool | setActive (codec_mode_t mode) |
| void | setAddress (uint8_t addr) |
| Defines the I2C address of the codec. | |
| bool | setAttenuationScale (PCM1681AttenuationScale scale, bool apply=true) |
| Configure the attenuation scale (fine 0.5dB / wide 1.0dB steps) | |
| bool | setDacEnabled (bool enable) |
| Enable or disable the DAC output of all channels. | |
| bool | setDacEnabled (uint8_t channel, bool enable, bool apply=true) |
| Enable or disable the DAC output of a single channel (used for start_output / stop_output). | |
| bool | setDeemphasisEnabled (bool enable, bool apply=true) |
| Enable or disable the digital de-emphasis filter. | |
| bool | setDeemphasisRate (PCM1681DeemphasisRate rate, bool apply=true) |
| Configure the digital de-emphasis filter sample rate. | |
| virtual bool | setDevices (input_device_t input_device, output_device_t output_device) |
| bool | setFilterRollOff (PCM1681FilterRollOff roll_off, bool apply=true) |
| Configure the digital filter roll-off characteristic. | |
| bool | setFormat (PCM1681Format format, bool apply=true) |
| Configure the digital audio interface format. | |
| virtual bool | setInputVolume (int volume) |
| bool | setMute (bool mute) override |
| Mute or unmute all 8 channels. | |
| bool | setMute (uint8_t channel, bool mute, bool apply=true) |
| Mute or unmute a single output channel. | |
| virtual bool | setVolume (int volume) |
| bool | setVolume (uint8_t channel, uint8_t volume, bool apply=true) |
| Set the volume (attenuation) of a single output channel. | |
| bool | setVolume (uint8_t volume) |
| Set the volume (attenuation) for all 8 channels (0..100) | |
| void | setWire (i2c_bus_handle_t w) |
| Defines the I2C communication object. | |
Static Public Attributes | |
| static constexpr int | N_CHANNELS = 8 |
| static constexpr int | N_REGISTERS = 20 |
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. | |
| void | updateBit (uint8_t reg, uint8_t pos, bool value) |
| 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. | |
Static Protected Member Functions | |
| static uint8_t | attenuationReg (uint8_t channel) |
| static bool | isAccessible (uint8_t reg) |
| static bool | isWriteable (uint8_t reg) |
Protected Attributes | |
| uint8_t | i2c_addr = 0 |
| int | input_volume_percent = 100 |
| Last input volume (in %) provided to setInputVolume() | |
| uint8_t | reg_map [N_REGISTERS] = {0} |
| int | volume_percent = 100 |
| Last volume (in %) provided to setVolume() | |
| i2c_bus_handle_t | wire = nullptr |
Header only C++ driver for the PCM1681 8-channel audio DAC.
Maintains a local shadow of the PCM1681 register map (matching the factory default values) and writes it out via I2C. Provides per-channel volume (attenuation) and mute control plus DAI format configuration, ported from the corresponding Zephyr RTOS driver.
| enum Reg : uint8_t |
|
inline |
|
inlineinherited |
Provides the actual I2C address of the codec.
|
inline |
Write the full local register shadow to the device (skips registers that are not writeable: REG_0, REG_14 and REG_15)
|
inlinestaticprotected |
|
inline |
|
inline |
Initialize the codec: reset the local register shadow to the factory defaults, configure the DAI format and write everything to the device.
| format | Digital audio interface format Initializes the codec for I2S (sample rate and word size are determined by the external I2S clock/format, not configurable here) |
|
inlineoverridevirtual |
Initializes the codec.
Implements ZephyrDriverCommon.
|
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()
|
inlineinherited |
Provides the actual I2C communication object.
|
inlinestaticprotected |
|
inlinevirtualinherited |
|
inlinestaticprotected |
|
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 |
Configure the attenuation scale (fine 0.5dB / wide 1.0dB steps)
|
inline |
Enable or disable the DAC output of all channels.
|
inline |
Enable or disable the DAC output of a single channel (used for start_output / stop_output).
| channel | channel number, 1..8 |
| enable | true to enable the DAC output |
| apply | write the change to the device immediately |
|
inline |
Enable or disable the digital de-emphasis filter.
|
inline |
Configure the digital de-emphasis filter sample rate.
|
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 digital filter roll-off characteristic.
|
inline |
Configure the digital audio interface format.
| format | Digital audio interface format |
| apply | write the change to the device immediately |
|
inlinevirtualinherited |
|
inlineoverridevirtual |
Mute or unmute all 8 channels.
Reimplemented from ZephyrDriverCommon.
|
inline |
Mute or unmute a single output channel.
| channel | channel number, 1..8 |
| mute | true to mute |
| apply | write the change to the device immediately |
|
inlinevirtualinherited |
Defines the output volume in % (0...100). Chip specific subclasses map this to their native volume range.
Reimplemented in AW88298, DA7212, MAX98091, SF32LB, TAS2563, TAS6422DAC, TLV320AIC3110, TLV320DAC310x, WM8904, and WM8962.
|
inline |
Set the volume (attenuation) of a single output channel.
| channel | channel number, 1..8 |
| volume | volume in percent, 0..100 |
| apply | write the change to the device immediately |
|
inline |
Set the volume (attenuation) for all 8 channels (0..100)
|
inlineinherited |
Defines the I2C communication object.
|
inlineprotected |
|
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.
|
protectedinherited |
|
protectedinherited |
Last input volume (in %) provided to setInputVolume()
|
staticconstexpr |
|
staticconstexpr |
|
protected |
|
protectedinherited |
Last volume (in %) provided to setVolume()
|
protectedinherited |