From 993836cb4e8dc3f420f0923896d39654d0f1386a Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 5 Mar 2025 22:43:33 +0800 Subject: [PATCH] some test code for battery fet disconnect / leakage measurements put into the commit log just in case i need to refer to it again in the future... --- loader/src/platform/cramium/cramium.rs | 37 +++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/loader/src/platform/cramium/cramium.rs b/loader/src/platform/cramium/cramium.rs index d311709da..7591168bc 100644 --- a/loader/src/platform/cramium/cramium.rs +++ b/loader/src/platform/cramium/cramium.rs @@ -334,7 +334,42 @@ pub fn early_init() -> u32 { pmic.set_ldo(&mut i2c, Some(2.5), cramium_hal::axp2101::WhichLdo::Aldo2).unwrap(); pmic.set_dcdc(&mut i2c, Some((1.2, false)), cramium_hal::axp2101::WhichDcDc::Dcdc4).unwrap(); - crate::println!("AXP2101 configure: {:?}", pmic); + + // This debug print creates a lot of extra code... + // crate::println!("AXP2101 configure: {:?}", pmic); + + // test battery power off + /* + crate::println!("poweroff"); + pmic.set_ldo(&mut i2c, None, cramium_hal::axp2101::WhichLdo::Aldo3).unwrap(); + crate::println!("poweroff done"); + */ + + // try to get the BATTFET disengaged on AXP2101 + // the lowest current we can get is 3mA... + /* + let mut buf = [0u8, 0u8]; + crate::println!("debug"); + i2c.i2c_read(0x34, 0u8, &mut buf, false).unwrap(); + crate::println!("0|1 bef: {:x?}", buf); + + buf[0] = 0; + buf[1] = 0; + // force batfet off + i2c.i2c_write(0x34, 0x12u8, &buf[..1]).unwrap(); + crate::println!("delay"); + i2c.i2c_read(0x34, 0u8, &mut buf, false).unwrap(); + crate::println!("0|1 aft: {:x?}", buf); + + crate::println!("enable power off"); + buf[0] = 0x2; + i2c.i2c_write(0x34, 0x22u8, &buf[..1]).unwrap(); + + crate::println!("poweroff"); + buf[0] = 0x1; + i2c.i2c_write(0x34, 0x10u8, &buf[..1]).unwrap(); + crate::println!("poweroff done"); + */ // Make this true to have the system shut down by disconnecting its own battery while on battery // power Note this does nothing if you have USB power plugged in.