Crate ltc2497

source ·
Expand description

A platform agnostic Rust driver for the LTC2497 ADC, based on the embedded-hal traits. Device can be used with embedded HAL directly or with RPPAL (Raspberry Pi Peripheral Access Library) with “hal” feature.

Usage

Import this crate and one of embedded HAL implementation (e.g. linux-embedded-hal or rppal). Then instantiate the device.

use std::error::Error;
use ltc2497::LTC2497;
use ltc2497::{AddressPinState::Low, Channel};
use rppal::hal::Delay;
use rppal::i2c::I2c;

let i2c = I2c::new()?;

let mut adc = LTC2497::new_from_pins(i2c, Low, Low, Low, 5.0, 0.0, Delay);

for ch in 0..=15 {
    match adc.read_channel(Channel::from(ch)) {
        Ok(v) => println!("Channel {ch}: {v}V"),
        Err(e) => println!("error {e:?} at channel {ch}"),
    };
}

Ok(())

Also you can instantiate device with address directly. For example, if you configured pins to set device address 0x20:

let mut adc = LTC2497::new(i2c, 0x20, 5.0, 0.0, Delay);

Structs

Enums

  • Address pins haven’t any pull-ups/pull-downs and are tri-state by nature. So address is configured by these states.
  • LTC2497 provides a possibility to make differential measurements between two adjacent channels. You can get voltage between channel 0 and channel 1, between channel 2 and channel 3, but you can’t measure voltage between channel 1 and channel 2 or between channel 4 and channel 8, because they belongs to different pairs. Also you can make single-ended measurements (between any channel and GND).