Crate tlv320aic23

Crate tlv320aic23 

Source
Expand description

§TLV230AIC23B Driver

This is driver for the Texas Instruments TLV320AIC23B audio CODEC / amplifier.

Specifically, this driver is for setting the registers in the TLV230AIC23B over I²C - this driver does not handle the digital audio interface (I²S, or similar).

The TLV230AIC23B has the following inputs and outputs:

  • Stereo analog Line-level Input
  • Mono analog Microphone Input, with optional +20dB boost
  • Stereo analog Line-level Output
  • Stereo analog Amplified Headphone Output
  • Stereo digital Output
  • Stereo digital Input

The Codec object must cache the register contents because the TLV320AIC23B only has a write-only interface and you cannot read back any register contents.

§Example

You might setup the Codec like this:

let mut codec = tlv320aic23::Codec::new(tlv320aic23::BusAddress::CsLow);
if let Err(e) = codec.reset(&mut i2c) {
    // Codec didn't respond
}
codec.set_digital_interface_enabled(true);
codec.set_dac_selected(true);
codec.set_dac_mute(false);
codec.set_bypass(false);
codec.set_line_input_mute(true, tlv320aic23::Channel::Both);
codec.set_powered_on(tlv320aic23::Subsystem::AnalogDigitalConverter, true);
codec.set_powered_on(tlv320aic23::Subsystem::MicrophoneInput, true);
codec.set_powered_on(tlv320aic23::Subsystem::LineInput, true);
codec.set_headphone_output_volume(50, tlv320aic23::Channel::Both);
codec.set_sample_rate(
    tlv320aic23::CONFIG_USB_44K1,
    tlv320aic23::LrSwap::Disabled,
    tlv320aic23::LrPhase::RightOnHigh,
    tlv320aic23::Mode::Controller,
    tlv320aic23::InputBitLength::B16,
    tlv320aic23::DataFormat::I2s,
);
if let Err(e) = codec.sync(&mut i2c) {
    // Codec didn't respond
}

Structs§

Codec
Represents the state inside our TLV230AIC23B chip.
ConfigParams
Describes a specific configuration in terms of MCLK, ADC Sample Rate, and DAC Sample Rate

Enums§

AudioInput
Audio input devices available
BusAddress
The TLV230AIC23B has one of two I²C addresses, depending on whether the CS pin is pulled high or low.
Channel
Selects either only the left channel, only the right channel, or both channels together.
DataFormat
How the data is sent over the digital bus
InputBitLength
The size, in bits, of each sample
LrPhase
Control whether LRClk is active high or low
LrSwap
Swap the left and right DAC outputs
Mode
Whether the TLV230AIC23B generates or receives clock signals.
Sidetone
The level of sidetone that is added.
Subsystem
Represents parts of the TLV230AIC23B that we can turn on and off

Constants§

CONFIG_USB_8K
Configuration for USB Mode (12 MHz), ADC @ 8 kHz, DAC @ 8 kHz
CONFIG_USB_32K
Configuration for USB Mode (12 MHz), ADC @ 32 kHz, DAC @ 32 kHz
CONFIG_USB_44K1
Configuration for USB Mode (12 MHz), ADC @ 44.1 kHz, DAC @ 44.1 kHz
CONFIG_USB_48K
Configuration for USB Mode (12 MHz), ADC @ 48 kHz, DAC @ 48 kHz
CONFIG_USB_96K
Configuration for USB Mode (12 MHz), ADC @ 96 kHz, DAC @ 96 kHz