|
| 1 | +// https://www.ti.com/lit/ug/sluua43a/sluua43a.pdf?ts=1763375446472 |
| 2 | +// driver/battery/smart.c |
| 3 | +// include/battery_smart.h |
| 4 | +use alloc::vec::Vec; |
| 5 | +use num_traits::FromPrimitive; |
| 6 | + |
| 7 | +use crate::chromium_ec::command::EcRequestRaw; |
| 8 | +use crate::chromium_ec::commands::{EcRequestGetGpuPcie, GpuVendor}; |
| 9 | +use crate::chromium_ec::i2c_passthrough::*; |
| 10 | +use crate::chromium_ec::{CrosEc, EcResult}; |
| 11 | +use crate::os_specific; |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +pub fn dump_data(ec: &CrosEc) -> EcResult<Option<Vec<u8>>> { |
| 16 | + // I2C Port on the EC |
| 17 | + let i2c_port = 3; |
| 18 | + // 8-bit I2C address of the battery |
| 19 | + // EC passthrough needs 7-bit, so shift one over before sending to EC |
| 20 | + let i2c_addr = 0x0b << 1; |
| 21 | + |
| 22 | + // Check mode |
| 23 | + let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x03, 0x01)?; |
| 24 | + println!("Mode: {:?}", i2c_response.data); |
| 25 | + let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x1c, 0x02)?; |
| 26 | + println!("Serial: {:X?}", i2c_response.data); |
| 27 | + let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x08, 0x02)?; |
| 28 | + println!("Temp: {:X?}", i2c_response.data); |
| 29 | + let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x17, 0x02)?; |
| 30 | + println!("Cycle Ct: {:?}", i2c_response.data); |
| 31 | + let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x21, 0x08)?; |
| 32 | + // 0A 46 52 41 |
| 33 | + println!("Dev Name: {:X?}", i2c_response.data); |
| 34 | + |
| 35 | + // i2c_write(ec, i2c_port, (i2c_addr + 2) >> 1, 0x70, &[0x00])?; |
| 36 | + // os_specific::sleep(50_000); |
| 37 | + |
| 38 | + Ok(Some(i2c_response.data)) |
| 39 | +} |
0 commit comments