1 unstable release
0.1.0 | Sep 16, 2023 |
---|
#1709 in Hardware support
27KB
411 lines
TLV320AIC23 CODEC driver
This is driver for the Texas Instruments TLV320AIC23B audio CODEC / amplifier.
Changelog
Unreleased Changes
- First version
Licence
Copyright (c) The Neotron Developers, 2023
Licensed under either MIT or Apache-2.0 at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you shall be licensed as above, without any additional terms or conditions.
lib.rs
:
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
}
Dependencies
~220KB