Expand description
§Device configuration
Instead of directly writing do configuration registers, the client offers a generic abstraction.
§Example
For full details s. Configuration struct.
use ltc681x::config::{Cell, Configuration};
use ltc681x::example::{ExampleCSPin, ExampleSPIBus};
use ltc681x::ltc6813::LTC6813;
use ltc681x::monitor::{LTC681X, LTC681XClient};
// Single LTC6813 device
let spi_bus = ExampleSPIBus::default();
let cs_pin = ExampleCSPin{};
let mut client: LTC681X<_, _, _, LTC6813, 1> = LTC681X::ltc6813(spi_bus, cs_pin);
let mut config = Configuration::default();
// Set over-voltage limit to 4.25 V
config.set_ov_comp_voltage(4_250_000).unwrap();
// Sets under-voltage limit to 3.0 V
config.set_uv_comp_voltage(3_000_000).unwrap();
// Turn on discharge switch for cell 6 and 9
config.discharge_cell(Cell::Cell6);
config.discharge_cell(Cell::Cell9);
client.write_configuration([config]).unwrap();
§Multiple devices in daisy-chain
Writing to multiple devices in daisy-chain is supported, by providing an array item per device:
// 3 devices in daisy chain
let mut client: LTC681X<_, _, _, LTC6813, 3> = LTC681X::ltc6813(spi_bus, cs_pin);
let mut config = [
Configuration::default(),
Configuration::default(),
Configuration::default()
];
config[0].set_ov_comp_voltage(4_100_000);
config[1].set_ov_comp_voltage(4_200_000);
config[2].set_ov_comp_voltage(4_300_000);
client.write_configuration(config).unwrap();
Structs§
- Abstracted configuration of configuration register(s)
- Given voltage is out-of-range for fitting in 12 bit integer
Enums§
- Cell indexes of the LTC681X device. Depending on the device type, not all cells may be available. Configuring a cell that is not physically available has no effect.
- Digital Redundancy Path Selection
- Timeout duration for discharge timer
- GPIO pins of LTC681X device. Depending on the device type, not all pins may be available. Configuring a pin that is not physically available has no effect.