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

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

Enums

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

Constants

  • Configuration for USB Mode (12 MHz), ADC @ 8 kHz, DAC @ 8 kHz
  • Configuration for USB Mode (12 MHz), ADC @ 32 kHz, DAC @ 32 kHz
  • Configuration for USB Mode (12 MHz), ADC @ 44.1 kHz, DAC @ 44.1 kHz
  • Configuration for USB Mode (12 MHz), ADC @ 48 kHz, DAC @ 48 kHz
  • Configuration for USB Mode (12 MHz), ADC @ 96 kHz, DAC @ 96 kHz