Skip to content

Commit bbf76d5

Browse files
committed
ManufacturerAccess commands
Signed-off-by: Daniel Schaefer <[email protected]>
1 parent ee39a10 commit bbf76d5

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

framework_lib/src/battery.rs

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,29 @@ use crate::chromium_ec::i2c_passthrough::*;
1010
use crate::chromium_ec::{CrosEc, EcResult};
1111
use crate::os_specific;
1212

13+
#[repr(u8)]
14+
enum SmartBatReg {
15+
Mode = 0x03,
16+
Temp = 0x08,
17+
ManufactureDate = 0x1B,
18+
SerialNum = 0x1C,
19+
CycleCount = 0x17,
20+
DeviceName = 0x21,
21+
}
22+
23+
#[repr(u8)]
24+
/// ManufacturerAccess block
25+
/// Needs unseal
26+
enum ManufReg {
27+
SafetyAlert = 0x50,
28+
SafetyStatus = 0x51,
29+
PFAlert = 0x52,
30+
LifeTimeDataBlock1 = 0x60,
31+
LifeTimeDataBlock2 = 0x61,
32+
LifeTimeDataBlock3 = 0x62,
33+
}
1334

35+
// fn get_i16(ec: &CrosEC) ->
1436

1537
pub fn dump_data(ec: &CrosEc) -> EcResult<Option<Vec<u8>>> {
1638
// I2C Port on the EC
@@ -29,9 +51,29 @@ pub fn dump_data(ec: &CrosEc) -> EcResult<Option<Vec<u8>>> {
2951
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x17, 0x02)?;
3052
println!("Cycle Ct: {:?}", i2c_response.data);
3153
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x21, 0x08)?;
32-
// 0A 46 52 41
54+
// 0A 46 52 41 "FRAN...
3355
println!("Dev Name: {:X?}", i2c_response.data);
3456

57+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x4F, 0x02)?;
58+
println!("SOH: {:?}", i2c_response.data);
59+
60+
// Need to unseal for access
61+
// SE [US] [FA]
62+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x51, 0x02)?;
63+
println!("SafetyAlrt{:?}", i2c_response.data);
64+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x53, 0x02)?;
65+
println!("SafetySts:{:?}", i2c_response.data);
66+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x51, 0x02)?;
67+
println!("PFAlert: {:?}", i2c_response.data);
68+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x53, 0x02)?;
69+
println!("PFStatus: {:?}", i2c_response.data);
70+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x60, 0x02)?;
71+
println!("LifeTime1 {:?}", i2c_response.data);
72+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x61, 0x02)?;
73+
println!("LifeTime2 {:?}", i2c_response.data);
74+
let i2c_response = i2c_read(ec, i2c_port, i2c_addr >> 1, 0x61, 0x02)?;
75+
println!("LifeTime3 {:?}", i2c_response.data);
76+
3577
// i2c_write(ec, i2c_port, (i2c_addr + 2) >> 1, 0x70, &[0x00])?;
3678
// os_specific::sleep(50_000);
3779

0 commit comments

Comments
 (0)