test code for shutdown/keep-on

at the moment not working, will resume debug once new rev of board
is back.
This commit is contained in:
bunnie 2025-09-18 20:19:48 +08:00
parent d02268e24c
commit edf5206846

View file

@ -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();
}