Crates.io | ltc681x |
lib.rs | ltc681x |
version | 0.5.0 |
source | src |
created_at | 2022-05-03 11:17:20.59274 |
updated_at | 2024-02-08 13:00:28.737278 |
description | Client LTC681X battery monitoring family |
homepage | |
repository | https://github.com/pegasus-aero/rt-LTC681X |
max_upload_size | |
id | 579667 |
size | 228,172 |
Abstraction for LTC681X family. Supports all devices of LTC681X family: LTC6813, LTC6812, LTC6811 and LTC6810.
Currently, the following features are implemented:
For all details see monitor module.
use ltc681x::example::{ExampleCSPin, ExampleSPIBus};
use ltc681x::ltc6813::{CellSelection, Channel, GPIOSelection, LTC6813};
use ltc681x::monitor::{ADCMode, LTC681X, LTC681XClient, PollClient};
let spi_bus = ExampleSPIBus::default();
let cs_pin = ExampleCSPin{};
// LTC6813 device
let mut client: LTC681X<_, _, _, LTC6813, 1> = LTC681X::ltc6813(spi_bus, cs_pin)
.enable_sdo_polling();
// Starts conversion for cell group 1
client.start_conv_cells(ADCMode::Normal, CellSelection::Group1, true);
// Poll ADC status
while !client.adc_ready().unwrap() {
// Conversion is not done yet
}
// 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);
:warning: The crate is still incomplete, but is under active development.
:warning: The crate has only been tested for the LTC6813 variant. Although the protocol of the LTC681X family is essentially the same, inconsistencies are still conceivable for some variants. Practical tests + feedback with other variants are therefore welcome.
Any form of support is greatly appreciated. Feel free to create issues and PRs. See DEVELOPMENT for more details.
Licensed under either of
Each contributor agrees that his/her contribution covers both licenses.