API Reference

relic_tlv320aic3204

CircuitPython driver library for the TLV320AIC3204 audio codec

  • Author(s): Cooper Dalrymple

Implementation Notes

Software and Dependencies:

relic_tlv320aic3204.AUDIO_INTERFACE_DSP = 1

DSP format. Use with TLV320AIC3204.audio_interface.

relic_tlv320aic3204.AUDIO_INTERFACE_I2S = 0

I2S format. Use with TLV320AIC3204.audio_interface.

relic_tlv320aic3204.AUDIO_INTERFACE_LJF = 3

Left justified format. Use with TLV320AIC3204.audio_interface.

relic_tlv320aic3204.AUDIO_INTERFACE_RJF = 2

Right justified format. Use with TLV320AIC3204.audio_interface.

relic_tlv320aic3204.DAC_PATH_DISABLED = 0

DAC data path off.

relic_tlv320aic3204.DAC_PATH_MIXED = 3

Mixed DAC data path (L+R).

relic_tlv320aic3204.DAC_PATH_NORMAL = 1

Normal DAC data path (L->L or R->R).

relic_tlv320aic3204.DAC_PATH_SWAPPED = 2

Swapped DAC data path (R->L or L->R).

relic_tlv320aic3204.IMPEDANCE_10K = 1

Connect an input using 10k resistance. Use with TLV320AIC3204.connect_input.

relic_tlv320aic3204.IMPEDANCE_20K = 1

Connect an input using 20k resistance. Use with TLV320AIC3204.connect_input.

relic_tlv320aic3204.IMPEDANCE_40K = 1

Connect an input using 40k resistance. Use with TLV320AIC3204.connect_input.

relic_tlv320aic3204.INPUT_1 = 0

Use for routing either IN1L or IN1R to the MICPGA input with TLV320AIC3204.connect_input.

relic_tlv320aic3204.INPUT_2 = 1

Use for routing either IN2L or IN2R to the MICPGA input with TLV320AIC3204.connect_input.

relic_tlv320aic3204.INPUT_3 = 2

Use for routing either IN3L or IN3R to the MICPGA input with TLV320AIC3204.connect_input.

relic_tlv320aic3204.MICBIAS_MODE_1V25 = 0

MICBIAS output voltage of 1.25V (when common mode is 0.9V). Use with TLV320AIC3204.micbias_mode.

relic_tlv320aic3204.MICBIAS_MODE_1V7 = 1

MICBIAS output voltage of 1.7V (when common mode is 0.9V). Use with TLV320AIC3204.micbias_mode.

relic_tlv320aic3204.MICBIAS_MODE_2V5 = 2

MICBIAS output voltage of 2.5V (when common mode is 0.9V). Use with TLV320AIC3204.micbias_mode.

relic_tlv320aic3204.MICBIAS_MODE_SOURCE = 3

MICBIAS output voltage is sourced from power supply as dictated by TLV320AIC3204.micbias_source. Use with TLV320AIC3204.micbias_mode.

relic_tlv320aic3204.SOURCE_AVDD = 0

Voltage is generated from AVDD. Use with TLV320AIC3204.micbias_source.

relic_tlv320aic3204.SOURCE_LDOIN = 1

Voltage is generated from LDOIN. Use with TLV320AIC3204.micbias_source.

class relic_tlv320aic3204.TLV320AIC3204(i2c: busio.I2C, mclk: microcontroller.Pin = None, rst: microcontroller.Pin = None, address: int = _DEFAULT_I2C_ADDR)

Driver for the TI TLV320AIC3204 Stereo Codec with Line Inputs, Mic Inputs, Line Outputs and Headphone Amplifier.

Initialize the TLV320AIC3204. The I2S bus will default to a sample rate of 44.1 kHz and bit depth of 16 bits. Power will be configured according to Figure 21 of the datasheet with 3.3V power to LDOIN for high performance operation.

Parameters:
  • i2c – The I2C bus the device is connected to.

  • mclk – The main clock pin. If provided, it will be driven at 15 MHz to improve audio quality, especially at lower sample rates.

  • rst – The reset pin. If provided, calling TLV320AIC3204.reset will perform a hardware reset rather than a software reset for more dependable operation.

  • address – The I2C device address (default is 0x18).

property adc_enabled: bool

The power state of both channels of the ADC. Also depends on TLV320AIC3204.dac_enabled. Both must be set as True to use ADC.

Default:

False

adc_loopback: bool

If set as True, I2S ADC output is routed to DAC input.

Default:

False

property adc_muted: bool

The muted state of both channels of the ADC.

Default:

True

adc_processing_block: int

The signal processing block of the ADC from 1 to 18. See Table 2 in the datasheet for details.

Default:

1 (PRB_R1)

property adc_volume: float

The digital volume in dB of the ADC. Range is -12 dB to 20 dB in 0.5 dB increments.

Default:

0.0 dB

audio_interface: int

The audio interface type. See AUDIO_INTERFACE_* constants for valid settings.

Default:

AUDIO_INTERFACE_I2S.

property bit_depth: int

The number of bits per sample. The values of 16, 20, 24, and 32 are possible, but only 16 is supported by audiobusio.I2SOut.

Default:

16

connect_input(input: int, impedance: int = IMPEDANCE_10K) None

Connect an input source to both channels of the input amplifier. Only supports unbalanced operation.

Parameters:
  • input – The desired input source. See INPUT_* constants for valid settings.

  • impedance – The amount of resistance to use when connecting to the input amplifier. See IMPEDANCE_* for valid settings. Defaults to IMPEDANCE_10K.

connect_left_input(input: int, impedance: int = IMPEDANCE_10K, balanced: bool = False) None

Connect an input source to the left channel of the input amplifier.

Parameters:
  • input – The desired input source. See INPUT_* constants for valid settings.

  • impedance – The amount of resistance to use when connecting to the input amplifier. See IMPEDANCE_* for valid settings. Defaults to IMPEDANCE_10K.

  • balanced – Whether or not to use both channels of an input source to drive the input amplifier for balanced operation. Only supported with INPUT_2 and INPUT_3. Defaults to False.

connect_right_input(input: int, impedance: int = IMPEDANCE_10K, balanced: bool = False) None

Connect an input source to the right channel of the input amplifier.

Parameters:
  • input – The desired input source. See INPUT_* constants for valid settings.

  • impedance – The amount of resistance to use when connecting to the input amplifier. See IMPEDANCE_* for valid settings. Defaults to IMPEDANCE_10K.

  • balanced – Whether or not to use both channels of an input source to drive the input amplifier for balanced operation. Only supported with INPUT_1 and INPUT_3. Defaults to False.

property dac_enabled: bool

The power state of both channels of the DAC. Must be enabled to use either the DAC or ADC.

Default:

False

dac_loopback: bool

If set as True, I2S DAC input is routed to ADC output.

Default:

False

property dac_muted: bool

The muted state of both channels of the DAC.

Default:

True

property dac_path: int

The DAC path of both channels. See DAC_PATH_* constants for relevant configurations.

Default:

DAC_PATH_NORMAL

dac_processing_block: int

The signal processing block of the DAC from 1 to 25. See Table 3 in the datasheet for details.

Default:

1 (PRB_P1)

property dac_to_headphone_output: bool

Whether or not to route the output of the DAC to the headphone amplifier.

Default:

False

property dac_to_line_output: bool

Whether or not to route the output of the DAC to the line level output driver.

Default:

False

property dac_volume: float

The digital volume in dB of the DAC. Range is -63.5 dB to 24 dB.

Default:

0.0 dB

property headphone_output_enabled: bool

Whether or not the both channels of the headphone amplifier are powered.

Default:

False

property headphone_output_gain: int

The amount of gain in decibels of both channels of the headphone amplifier from -6 dB to 29 dB.

Default:

0 dB

property headphone_output_muted: bool

Whether or not both channels of the headphone amplifier are muted.

Default:

True

property input1_to_headphone_output: bool

Whether or not to route the output of the direct passthrough of input 1 (IN1_L and IN1_R) to the headphone amplifier. See TLV320AIC3204.input1_to_headphone_output_volume to control the volume of this passthrough.

Default:

False

property input1_to_headphone_output_volume: float

The volume of the direct passthrough of input 1 (IN1_L and IN1_R) to the headphone amplifier in decibels from -72.3 dB to 0.0 dB. Set is as a value below -72.3 dB to mute the output See TLV320AIC3204.input1_to_headphone_output to enable this passthrough.

Default:

0.0 dB

property input_gain: float

The amount of gain in decibels of the input amplifier from 0.0 dB to 47.5 dB in 0.5 dB increments.

Default:

0.0 dB

property input_passthrough_enabled: bool

Whether or not both channels of the input passthrough are powered.

Default:

False

property input_passthrough_volume: float

The volume of both channels of the input passthrough from -30.1 dB to 0.0 dB. If set to a value below -30.1 dB, the passthrough will be muted.

Default:

0.0 dB

property input_to_headphone_output: bool

Whether or not to route the output of the input passthrough to the headphone amplifier. See TLV320AIC3204.input_passthrough_enabled and TLV320AIC3204.input_passthrough_volume to control the passthrough mixer.

Default:

False

property input_to_line_output: bool

Whether or not to route the output of the input passthrough to the line level output driver. See TLV320AIC3204.input_passthrough_enabled and TLV320AIC3204.input_passthrough_volume to control the passthrough mixer.

Default:

False

left_adc_enabled: bool

The power state of the left channel of the ADC. Also depends on TLV320AIC3204.left_dac_enabled. Both must be set as True to use ADC.

Default:

False

left_adc_muted: bool

The muted state of the left channel of the ADC.

Default:

True

property left_adc_volume: float

The digital volume in dB of the left channel of the ADC. Range is -12 dB to 20 dB in 0.5 dB increments.

Default:

0.0 dB

left_dac_enabled: bool

The power state of the left channel of the DAC. Must be enabled to use either the left channel of the DAC or ADC.

Default:

False

left_dac_muted: bool

The muted state of the left channel of the DAC.

Default:

True

left_dac_path: int

The DAC path of the left channel. See DAC_PATH_* constants for relevant configurations.

Default:

DAC_PATH_NORMAL

left_dac_to_left_headphone_output: bool

Whether or not to route the output of the left channel of the DAC to the left channel of the headphone amplifier.

Default:

False

left_dac_to_left_line_output: bool

Whether or not to route the output of the left channel of the DAC to the left channel of the line level output driver.

Default:

False

property left_dac_volume: float

The digital volume in dB of the left channel of the DAC. Range is -63.5 dB to 24 dB.

Default:

0.0 dB

left_headphone_output_enabled: bool

Whether or not the left channel of the headphone amplifier is powered.

Default:

False

left_headphone_output_gain: int

The amount of gain in decibels of the left channel of the headphone amplifier from -6 dB to 29 dB.

Default:

0 dB

left_headphone_output_muted: bool

Whether or not the left channel of the headphone amplifier is muted.

Default:

True

left_input1_to_left_headphone_output: bool

Whether or not to route the output of the direct passthrough of the left channel of input 1 (IN1_L) to the left channel of the headphone amplifier. See TLV320AIC3204.left_input1_to_left_headphone_output_volume to control the volume of this passthrough.

Default:

False

left_input1_to_left_headphone_output_volume: float

The volume of the direct passthrough of the left channel of input 1 (IN1_L) to the left channel of the headphone amplifier in decibels from -72.3 dB to 0.0 dB. Set is as a value below -72.3 dB to mute the output See TLV320AIC3204.left_input1_to_left_headphone_output to enable this passthrough.

Default:

0.0 dB

property left_input_gain: float

The amount of gain in decibels of the left channel of the input amplifier from 0.0 dB to 47.5 dB in 0.5 dB increments.

Default:

0.0 dB

left_input_passthrough_enabled: bool

Whether or not the left channel of the input passthrough is powered.

Default:

False

left_input_passthrough_volume: float

The volume of the left channel of the input passthrough from -30.1 dB to 0.0 dB. If set to a value below -30.1 dB, the passthrough will be muted.

Default:

0.0 dB

left_input_to_left_headphone_output: bool

Whether or not to route the output of the left channel of the input passthrough to the left channel of the headphone amplifier. See TLV320AIC3204.left_input_passthrough_enabled and TLV320AIC3204.left_input_passthrough_volume to control the passthrough mixer.

Default:

False

left_input_to_left_line_output: bool

Whether or not to route the output of the left channel of the input passthrough to the left channel of the line level output driver. See TLV320AIC3204.left_input_passthrough_enabled and TLV320AIC3204.left_input_passthrough_volume to control the passthrough mixer.

Default:

False

left_line_output_enabled: bool

Whether or not the left channel of the line level output driver is powered.

Default:

False

left_line_output_gain: int

The amount of gain in decibels of the left channel of the line level output driver from -6 dB to 29 dB.

Default:

0 dB

left_line_output_muted: bool

Whether or not the left channel of the line level output driver is muted.

Default:

True

property line_output_enabled: bool

Whether or not both channels of the line level output driver are powered.

Default:

False

property line_output_gain: int

The amount of gain in decibels of the line level output driver from -6 dB to 29 dB.

Default:

0 dB

property line_output_muted: bool

Whether or not the line level output driver is muted.

Default:

True

micbias_enabled: bool

The power state of the MICBIAS output.

Default:

False

micbias_mode: int

The output voltage configuration of MICBIAS. See MICBIAS_MODE_* constants for valid settings.

Default:

MICBIAS_MODE_1V25

micbias_source: bool

The voltage source of MICBIAS when TLV320AIC3204.micbias_mode is set as MICBIAS_MODE_SOURCE. See SOURCE_* constants for valid settings.

Default:

SOURCE_AVDD

reset() None

Perform a full reset of the device configuration registers. If a reset pin was provided, a hardware reset will be performed rather than a software reset.

right_adc_enabled: bool

The power state of the right channel of the ADC. Also depends on TLV320AIC3204.right_dac_enabled. Both must be set as True to use ADC.

Default:

False

right_adc_muted: bool

The muted state of the right channel of the ADC.

Default:

True

property right_adc_volume: float

The digital volume in dB of the right channel of the ADC. Range is -12 dB to 20 dB in 0.5 dB increments.

Default:

0.0 dB

right_dac_enabled: bool

The power state of the left channel of the DAC. Must be enabled to use either the left channel of the DAC or ADC.

Default:

False

right_dac_muted: bool

The muted state of the right channel of the DAC.

Default:

True

right_dac_path: int

The DAC path of the right channel. See DAC_PATH_* constants for relevant configurations.

Default:

DAC_PATH_NORMAL

right_dac_to_right_headphone_output: bool

Whether or not to route the output of the right channel of the DAC to the right channel of the headphone amplifier.

Default:

False

right_dac_to_right_line_output: bool

Whether or not to route the output of the right channel of the DAC to the right channel of the line level output driver.

Default:

False

property right_dac_volume: float

The digital volume in dB of the right channel of the DAC. Range is -63.5 dB to 24 dB.

Default:

0.0 dB

right_headphone_output_enabled: bool

Whether or not the right channel of the headphone amplifier is powered.

Default:

False

right_headphone_output_gain: int

The amount of gain in decibels of the right channel of the headphone amplifier from -6 dB to 29 dB.

Default:

0 dB

right_headphone_output_muted: bool

Whether or not the right channel of the headphone amplifier is muted.

Default:

True

right_input1_to_right_headphone_output: bool

Whether or not to route the output of the direct passthrough of the right channel of input 1 (IN1_R) to the right channel of the headphone amplifier. See TLV320AIC3204.right_input1_to_left_headphone_output_volume to control the volume of this passthrough.

Default:

False

right_input1_to_right_headphone_output_volume: float

The volume of the direct passthrough of the right channel of input 1 (IN1_R) to the right channel of the headphone amplifier in decibels from -72.3 dB to 0.0 dB. Set is as a value below -72.3 dB to mute the output See TLV320AIC3204.right_input1_to_right_headphone_output to enable this passthrough.

Default:

0.0 dB

property right_input_gain: float

The amount of gain in decibels of the right channel of the input amplifier from 0.0 dB to 47.5 dB in 0.5 dB increments.

Default:

0.0 dB

right_input_passthrough_enabled: bool

Whether or not the right channel of the input passthrough is powered.

Default:

False

right_input_passthrough_volume: float

The volume of the right channel of the input passthrough from -30.1 dB to 0.0 dB. If set to a value below -30.1 dB, the passthrough will be muted.

Default:

0.0 dB

right_input_to_right_headphone_output: bool

Whether or not to route the output of the right channel of the input passthrough to the right channel of the headphone amplifier. See TLV320AIC3204.right_input_passthrough_enabled and TLV320AIC3204.right_input_passthrough_volume to control the passthrough mixer.

Default:

False

right_input_to_right_line_output: bool

Whether or not to route the output of the right channel of the input passthrough to the right channel of the line level output driver. See TLV320AIC3204.right_input_passthrough_enabled and TLV320AIC3204.right_input_passthrough_volume to control the passthrough mixer.

Default:

False

right_line_output_enabled: bool

Whether or not the right channel of the line level output driver is powered.

Default:

False

right_line_output_gain: int

The amount of gain in decibels of the right channel of the line level output driver from -6 dB to 29 dB.

Default:

0 dB

right_line_output_muted: bool

Whether or not the right channel of the line level output driver is muted.

Default:

True