From edf52068461b7413fcf3cd6286c97ff9597b8382 Mon Sep 17 00:00:00 2001 From: bunnie Date: Thu, 18 Sep 2025 20:19:48 +0800 Subject: [PATCH] test code for shutdown/keep-on at the moment not working, will resume debug once new rev of board is back. --- services/bao-console/src/cmds/test.rs | 47 +++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/services/bao-console/src/cmds/test.rs b/services/bao-console/src/cmds/test.rs index 904af393a..a6777db01 100644 --- a/services/bao-console/src/cmds/test.rs +++ b/services/bao-console/src/cmds/test.rs @@ -57,7 +57,54 @@ impl<'a> ShellCmdApi<'a> for Test { } } } + "shutdown" => { + use cram_hal_service::I2c; + use cramium_api::*; + let iox = cramium_api::IoxHal::new(); + let mut i2c = I2c::new(); + iox.setup_pin( + IoxPort::PF, + 0, + Some(IoxDir::Output), + Some(IoxFunction::Gpio), + None, + Some(IoxEnable::Disable), + None, + Some(IoxDriveStrength::Drive8mA), + ); + iox.set_gpio_pin_value(IoxPort::PF, 0, IoxValue::Low); + log::info!( + "shutdown got {:x?}, {:x?}", + iox.get_gpio_pin_value(IoxPort::PF, 0), + iox.get_gpio_bank_value(IoxPort::PF) + ); + let axp2101 = cramium_hal::axp2101::Axp2101::new(&mut i2c).expect("couldn't get AXP2101"); + log::info!("sending shutdown to axp2101 pmic...in four seconds"); + let tt = ticktimer::Ticktimer::new().unwrap(); + tt.sleep_ms(4000).ok(); + axp2101.powerdown(&mut i2c).ok(); + iox.setup_pin( + IoxPort::PF, + 6, + Some(IoxDir::Output), + Some(IoxFunction::Gpio), + None, + Some(IoxEnable::Disable), + None, + Some(IoxDriveStrength::Drive8mA), + ); + iox.set_gpio_pin_value(IoxPort::PF, 6, IoxValue::Low); + log::info!("sent shutdown to axp2101"); + } + "keepon" => { + use cramium_api::*; + let iox = cramium_api::IoxHal::new(); + let (port, pin) = cramium_hal::board::setup_keep_on_pin(&iox); + iox.set_gpio_pin_value(port, pin, IoxValue::High); + let _ = cramium_hal::board::setup_kb_pins(&iox); + log::info!("keepon got {:x?}", iox.get_gpio_pin_value(IoxPort::PF, 0)); + } _ => { write!(ret, "{}", helpstring).unwrap(); }