Crate ltc681x

Source
Expand description

§Generic client for LTC681X battery stack monitors

Supports all devices of LTC681X family: LTC6813, LTC6812, LTC6811 and LTC6810.

Currently the following features are implemented:

§Example

For all details see monitor module.

use ltc681x::example::ExampleSPIDevice;
use ltc681x::ltc6813::{CellSelection, Channel, GPIOSelection, LTC6813};
use ltc681x::monitor::{ADCMode, LTC681X, LTC681XClient, PollClient};

let spi_bus = ExampleSPIDevice::default();

// LTC6813 device
let mut client: LTC681X<_, _, LTC6813, 1> = LTC681X::ltc6813(spi_bus);

// Starts conversion for cell group 1
client.start_conv_cells(ADCMode::Normal, CellSelection::Group1, true);

// Wait until ADC conversion is finished or poll the status
// (s. 'Conversion time' and 'Polling' section(s) of monitor module)

// Returns the value of cell group A. In case of LTC613: cell 1, 7 and 13
let voltages = client.read_voltages(CellSelection::Group1).unwrap();
assert_eq!(Channel::Cell1, voltages[0][0].channel);
assert_eq!(24979, voltages[0][0].voltage);

Re-exports§

pub use heapless;

Modules§

config
Device configuration
example
SPI bus mock for doc examples
ltc6810
Device-specific types for LTC6810
ltc6811
Device-specific types for LTC6811
ltc6812
Device-specific types for LTC6812
ltc6813
Device-specific types for LTC6813
monitor
Generic client for LTX681X device family
spi
SPI device implementation for SDO line polling