clean up warnings

This commit is contained in:
bunnie 2021-03-11 04:09:47 +08:00
parent 7db6f857dd
commit 0dbfa6a668
4 changed files with 31 additions and 27 deletions

View file

@ -83,7 +83,7 @@ pub struct I2cTransactionResolver {
}
impl rkyv::Resolve<I2cTransaction> for I2cTransactionResolver {
type Archived = ArchivedI2cTransaction;
fn resolve(self, pos: usize, value: &I2cTransaction) -> Self::Archived {
fn resolve(self, pos: usize, _value: &I2cTransaction) -> Self::Archived {
Self::Archived {
ptr: unsafe {
rkyv::RelPtr::new(pos + rkyv::offset_of!(ArchivedI2cTransaction, ptr), self.bytes_pos)

View file

@ -4,11 +4,10 @@
/// are calling these functions inside a different process.
pub mod api;
use api::*;
use xous::{send_message, Error, CID};
use xous::{send_message, CID};
pub fn allow_power_off(cid: CID, allow: bool) -> Result<(), xous::Error> {
send_message(cid, api::Opcode::PowerSelf(allow).into()).map(|_| ())
send_message(cid, api::Opcode::PowerSelf(!allow).into()).map(|_| ())
}
pub fn allow_ec_snoop(cid: CID, allow: bool) -> Result<(), xous::Error> {

View file

@ -8,14 +8,11 @@ use core::convert::TryFrom;
use log::{error, info};
use xous::CID;
#[cfg(target_os = "none")]
mod implementation {
use crate::api::*;
use log::{error, info};
use utralib::generated::*;
use ticktimer_server::*;
const STD_TIMEOUT: u32 = 100;
@ -242,8 +239,11 @@ mod implementation {
}
pub fn power_self(&mut self, power_on: bool) {
if power_on {
info!("LLIO: setting self-power state to on");
self.power_csr.rmwf(utra::power::POWER_SELF, 1);
} else {
info!("LLIO: setting self-power state to OFF");
self.power_csr.rmwf(utra::power::POWER_STATE, 0);
self.power_csr.rmwf(utra::power::POWER_SELF, 0);
}
}
@ -406,8 +406,8 @@ mod implementation {
fn xmain() -> ! {
let debug1 = false;
use crate::implementation::Llio;
use heapless::Vec;
use heapless::consts::*;
//use heapless::Vec;
//use heapless::consts::*;
log_server::init_wait().unwrap();
info!("LLIO: my PID is {}", xous::process::id());

View file

@ -16,25 +16,30 @@ impl<'a> ShellCmdApi<'a> for Sleep {
fn process(&mut self, _rest: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
use core::fmt::Write;
// TODO: check if power is plugged in first, we can't sleep when plugged in
if Ok(true) == gam::powerdown_request(env.gam) {
// allow EC to snoop, so that it can wake up the system
llio::allow_ec_snoop(env.llio, true).unwrap();
// allow the EC to power me down
llio::allow_power_off(env.llio, true).unwrap();
// now send the power off command
com::power_off_soc(env.com).unwrap();
log::info!("CMD: powering down now!");
// pause execution, nothing after this should be reachable
ticktimer_server::sleep_ms(env.ticktimer, 2000).unwrap(); // should power off within 2 seconds
log::info!("CMD: if you can read this, power down failed!");
}
let mut ret = String::<1024>::new();
write!(ret, "Powerdown request denied").unwrap();
Ok(Some(ret))
if ((llio::adc_vbus(env.llio).unwrap() as f64) * 0.005033) > 1.5 {
// if power is plugged in, deny powerdown request
write!(ret, "System can't sleep while charging. Unplug charging cable and try again.").unwrap();
Ok(Some(ret))
} else {
if Ok(true) == gam::powerdown_request(env.gam) {
ticktimer_server::sleep_ms(env.ticktimer, 500).unwrap(); // let the screen redraw
// allow EC to snoop, so that it can wake up the system
llio::allow_ec_snoop(env.llio, true).unwrap();
// allow the EC to power me down
llio::allow_power_off(env.llio, true).unwrap();
// now send the power off command
com::power_off_soc(env.com).unwrap();
log::info!("CMD: powering down now!");
// pause execution, nothing after this should be reachable
ticktimer_server::sleep_ms(env.ticktimer, 2000).unwrap(); // should power off within 2 seconds
log::info!("CMD: if you can read this, power down failed!");
}
write!(ret, "Powerdown request denied").unwrap();
Ok(Some(ret))
}
}