#i2c #amplifier #adafruit #audio #i2c-dev #tpa2016 #com-product-1712

i2c-tpa2016

i2c interface for a TPA2016 audio amplifier (https://www.adafruit.com/product/1712)

1 unstable release

Uses old Rust 2015

0.1.0 Jun 10, 2018

#6 in #i2c-dev

MIT license

9KB
130 lines

rust-i2c-tpa2016

Build status License crates.io Documentation

A rust crate for the communicating with the TPA2016 audio amplifier (https://www.adafruit.com/product/1712).

Synopsys

extern crate i2cdev;
extern crate i2c_tpa2016;

use i2cdev::linux::LinuxI2CDevice;

fn main() {
    let i2cdev = LinuxI2CDevice::new("/dev/i2c-1", 0x58).unwrap();
    let mut tpa2016 = i2c_tpa2016::I2CTPA2016::new(i2cdev).unwrap();

    tpa2016.set_gain(10).unwrap();
    println!("gain = {:?}", tpa2016.get_gain().unwrap());

    tpa2016.enable_channel(true, true).unwrap();

    tpa2016.set_agc_compression(0).unwrap();

    tpa2016.set_release_control(0).unwrap();
    tpa2016.set_attack_control(0).unwrap();
    tpa2016.set_hold_control(0).unwrap();

    tpa2016.set_limit_level_on().unwrap();
    tpa2016.set_limit_level(10).unwrap();

    tpa2016.set_limit_level_off().unwrap();

    tpa2016.set_agc_max_gain(12).unwrap();
}

Dependencies

~2–3.5MB
~61K SLoC