1 unstable release
0.1.0 | Apr 26, 2022 |
---|
#17 in #gauge
9KB
112 lines
max1720x
An embedded-hal driver for the MAX1720x fuel gauge ICs
This driver is loosely based on Tock's MAX17205 driver but rewritten to use embedded-hal's I2C driver instead of the one built in to Tock's kernel. It does not take ownership of the I2C bus so works in conjunction with other I2C drivers.
Tested on a Raspberry Pi with a MAX17205 but should in theory work on any embedded-hal I2C device and with any of the MAX1720x family of ICs.
lib.rs
:
An embedded-hal driver for the Maxim MAX17205 fuel gauge.
Loosely based on https://github.com/tock/tock/blob/master/capsules/src/max17205.rs rewritten to use the embedded-hal I2C driver.
https://www.maximintegrated.com/en/products/power/battery-management/MAX17205.html
The MAX1720x/MAX1721x are ultra-low power stand-alone fuel gauge ICs that implement the Maxim ModelGauge™ m5 algorithm without requiring host interaction for configuration. This feature makes the MAX1720x/MAX1721x excellent pack-side fuel gauges. The MAX17201/MAX17211 monitor a single cell pack. The MAX17205/MAX17215 monitor and balance a 2S or 3S pack or monitor a multiple-series cell pack.
Usage
use rppal::i2c::I2c; fn main() { let mut i2c = I2c::new().unwrap(); let mut max17205 = MAX1720x::new(&mut i2c); let soc = max17205.state_of_charge(&mut i2c).unwrap(); let status = max17205.status(&mut i2c).unwrap(); let voltage = max17205.voltage(&mut i2c).unwrap(); let current = max17205.current(&mut i2c).unwrap(); println!("State of charge: {}%", soc); println!("Voltage: {}V", voltage); println!("Current: {}A", current); println!("Status: {:#?}", status); }
Dependencies
~71KB