From 399742a3d408d7a806ad2cad031a76561d491079 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 7 May 2025 23:10:04 +0800 Subject: [PATCH] feature-out some battery testing code in hosted mode --- services/bao-console/src/main.rs | 33 +++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/services/bao-console/src/main.rs b/services/bao-console/src/main.rs index 5445cfd72..8185cf467 100644 --- a/services/bao-console/src/main.rs +++ b/services/bao-console/src/main.rs @@ -70,19 +70,26 @@ fn main() { log::set_max_level(log::LevelFilter::Debug); modals::tests::spawn_test(); } - use cramium_api::I2cApi; - let mut i2c = cram_hal_service::I2c::new(); - use cramium_hal::axp2101::*; - let measurements = [("VBAT", REG_VBAT_H), ("VBUS", REG_VBUS_H), ("VSYS", REG_VSYS_H)]; - let mut buf = [0u8, 0u8]; - loop { - tt.sleep_ms(2_000).ok(); - for (name, offset) in measurements { - i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap(); - let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32; - log::info!("{}: {:0.3}V", name, v as f32 / 1000.0); - i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap(); - log::info!("SOC: {}%", buf[0]); + #[cfg(not(feature = "hosted-baosec"))] + { + use cramium_api::I2cApi; + let mut i2c = cram_hal_service::I2c::new(); + use cramium_hal::axp2101::*; + let measurements = [("VBAT", REG_VBAT_H), ("VBUS", REG_VBUS_H), ("VSYS", REG_VSYS_H)]; + let mut buf = [0u8, 0u8]; + loop { + tt.sleep_ms(2_000).ok(); + for (name, offset) in measurements { + i2c.i2c_read(AXP2101_DEV, offset, &mut buf, false).unwrap(); + let v: u32 = (((buf[0] as u32) & 0x3F) << 8) | buf[1] as u32; + log::info!("{}: {:0.3}V", name, v as f32 / 1000.0); + i2c.i2c_read(AXP2101_DEV, REG_SOC, &mut buf[0..1], false).unwrap(); + log::info!("SOC: {}%", buf[0]); + } } } + #[cfg(feature = "hosted-baosec")] + loop { + tt.sleep_ms(2_000).ok(); + } }