API Reference
relic_tlv320aic3204
CircuitPython driver library for the TLV320AIC3204 audio codec
Author(s): Cooper Dalrymple
Implementation Notes
Software and Dependencies:
Adafruit CircuitPython firmware for the supported boards: https://circuitpython.org/downloads
Adafruit’s Bus Device library: https://github.com/adafruit/Adafruit_CircuitPython_BusDevice
Adafruit’s Register library: https://github.com/adafruit/Adafruit_CircuitPython_Register
- 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 withTLV320AIC3204.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.resetwill 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 asTrueto use ADC.- Default:
- 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:
- 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_2andINPUT_3. Defaults toFalse.
- 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_1andINPUT_3. Defaults toFalse.
- property dac_enabled: bool
The power state of both channels of the DAC. Must be enabled to use either the DAC or ADC.
- Default:
- property dac_path: int
The DAC path of both channels. See DAC_PATH_* constants for relevant configurations.
- Default:
- 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:
- property dac_to_line_output: bool
Whether or not to route the output of the DAC to the line level output driver.
- Default:
- 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:
- 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:
- 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_volumeto control the volume of this passthrough.- Default:
- 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_outputto 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:
- 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_enabledandTLV320AIC3204.input_passthrough_volumeto control the passthrough mixer.- Default:
- 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_enabledandTLV320AIC3204.input_passthrough_volumeto control the passthrough mixer.- Default:
- 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 asTrueto use ADC.- Default:
- 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:
- left_dac_path: int
The DAC path of the left channel. See DAC_PATH_* constants for relevant configurations.
- Default:
- 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:
- 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:
- 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:
- 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:
- 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_volumeto control the volume of this passthrough.- Default:
- 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_outputto 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:
- 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_enabledandTLV320AIC3204.left_input_passthrough_volumeto control the passthrough mixer.- Default:
- 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_enabledandTLV320AIC3204.left_input_passthrough_volumeto control the passthrough mixer.- Default:
- left_line_output_enabled: bool
Whether or not the left channel of the line level output driver is powered.
- Default:
- 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:
- property line_output_enabled: bool
Whether or not both channels of the line level output driver are powered.
- Default:
- 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
- micbias_mode: int
The output voltage configuration of MICBIAS. See MICBIAS_MODE_* constants for valid settings.
- Default:
- micbias_source: bool
The voltage source of MICBIAS when
TLV320AIC3204.micbias_modeis set asMICBIAS_MODE_SOURCE. See SOURCE_* constants for valid settings.- Default:
- 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 asTrueto use ADC.- Default:
- 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:
- right_dac_path: int
The DAC path of the right channel. See DAC_PATH_* constants for relevant configurations.
- Default:
- 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:
- 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:
- 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:
- 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:
- 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_volumeto control the volume of this passthrough.- Default:
- 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_outputto 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:
- 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_enabledandTLV320AIC3204.right_input_passthrough_volumeto control the passthrough mixer.- Default:
- 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_enabledandTLV320AIC3204.right_input_passthrough_volumeto control the passthrough mixer.- Default:
- right_line_output_enabled: bool
Whether or not the right channel of the line level output driver is powered.
- Default: