arduino-audio-driver
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
ZephyrDriverCommon Class Referenceabstract

Common parent class for codec drivers that have been ported from the Zephyr RTOS audio driver implementations (drivers/audio). More...

#include <ZephyrDriverCommon.h>

Inheritance diagram for ZephyrDriverCommon:
AW88298 DA7212 MAX98091 PCM1681 SF32LB TAS2563 TAS6422DAC TLV320AIC3110 TLV320DAC310x WM8904 WM8962

Public Member Functions

uint8_t address ()
 Provides the actual I2C address of the codec.
 
virtual bool begin (uint32_t sample_rate, uint8_t bits, codec_mode_t mode, i2s_format_t fmt, bool is_master, uint8_t channels)=0
 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.
 
virtual bool setDevices (input_device_t input_device, output_device_t output_device)
 
virtual bool setInputVolume (int volume)
 
virtual bool setMute (bool mute)
 
virtual bool setVolume (int volume)
 
void setWire (i2c_bus_handle_t w)
 Defines the I2C communication object.
 

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
 

Detailed Description

Common parent class for codec drivers that have been ported from the Zephyr RTOS audio driver implementations (drivers/audio).

It provides the basic I2C register access helpers (8 bit and 16 bit register values addressed via an 8 bit register address) that are used by most of these drivers. Chip specific classes can add additional register access methods (e.g. for paged/book based register maps) by using the protected wire and i2c_addr members directly.

Member Function Documentation

◆ address()

uint8_t address ( )
inline

Provides the actual I2C address of the codec.

◆ begin()

virtual bool begin ( uint32_t  sample_rate,
uint8_t  bits,
codec_mode_t  mode,
i2s_format_t  fmt,
bool  is_master,
uint8_t  channels 
)
pure virtual

Initializes the codec.

Implemented in AW88298, DA7212, MAX98091, PCM1681, TAS2563, TAS6422DAC, TLV320AIC3110, TLV320DAC310x, WM8904, and WM8962.

◆ getInputVolume()

virtual int getInputVolume ( )
inlinevirtual

Provides the input volume in % (0...100) that was set with setInputVolume()

◆ getVolume()

virtual int getVolume ( )
inlinevirtual

Provides the output volume in % (0...100) that was set with setVolume()

◆ getWire()

i2c_bus_handle_t getWire ( )
inline

Provides the actual I2C communication object.

◆ isInputVolumeSupported()

virtual bool isInputVolumeSupported ( )
inlinevirtual

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.

Reimplemented in DA7212, WM8904, and WM8962.

◆ readReg()

bool readReg ( uint8_t  reg,
uint8_t &  value 
)
inlineprotected

Reads a single byte from an 8 bit register address.

◆ readReg16()

bool readReg16 ( uint8_t  reg,
uint16_t &  value 
)
inlineprotected

Reads a 16 bit (big endian) value from an 8 bit register address.

◆ setActive()

virtual bool setActive ( codec_mode_t  mode)
inlinevirtual

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.

Reimplemented in DA7212, WM8904, and WM8962.

◆ setAddress()

void setAddress ( uint8_t  addr)
inline

Defines the I2C address of the codec.

◆ setDevices()

virtual bool setDevices ( input_device_t  input_device,
output_device_t  output_device 
)
inlinevirtual

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.

◆ setInputVolume()

virtual bool setInputVolume ( int  volume)
inlinevirtual

Defines the input volume in % (0...100). Chip specific subclasses map this to their native input volume range.

Reimplemented in DA7212, WM8904, and WM8962.

◆ setMute()

virtual bool setMute ( bool  mute)
inlinevirtual

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.

◆ setVolume()

virtual bool setVolume ( int  volume)
inlinevirtual

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.

◆ setWire()

void setWire ( i2c_bus_handle_t  w)
inline

Defines the I2C communication object.

◆ updateReg()

bool updateReg ( uint8_t  reg,
uint8_t  mask,
uint8_t  value 
)
inlineprotected

Read-Modify-Write of a single byte register.

◆ updateReg16()

bool updateReg16 ( uint8_t  reg,
uint16_t  mask,
uint16_t  value 
)
inlineprotected

Read-Modify-Write of a 16 bit (big endian) register.

◆ writeReg()

bool writeReg ( uint8_t  reg,
uint8_t  value 
)
inlineprotected

Writes a single byte to an 8 bit register address.

◆ writeReg16()

bool writeReg16 ( uint8_t  reg,
uint16_t  value 
)
inlineprotected

Writes a 16 bit (big endian) value to an 8 bit register address.

Member Data Documentation

◆ i2c_addr

uint8_t i2c_addr = 0
protected

◆ input_volume_percent

int input_volume_percent = 100
protected

Last input volume (in %) provided to setInputVolume()

◆ volume_percent

int volume_percent = 100
protected

Last volume (in %) provided to setVolume()

◆ wire

i2c_bus_handle_t wire = nullptr
protected

The documentation for this class was generated from the following file: