mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
clean up warnings
This commit is contained in:
parent
7db6f857dd
commit
0dbfa6a668
4 changed files with 31 additions and 27 deletions
|
|
@ -83,7 +83,7 @@ pub struct I2cTransactionResolver {
|
||||||
}
|
}
|
||||||
impl rkyv::Resolve<I2cTransaction> for I2cTransactionResolver {
|
impl rkyv::Resolve<I2cTransaction> for I2cTransactionResolver {
|
||||||
type Archived = ArchivedI2cTransaction;
|
type Archived = ArchivedI2cTransaction;
|
||||||
fn resolve(self, pos: usize, value: &I2cTransaction) -> Self::Archived {
|
fn resolve(self, pos: usize, _value: &I2cTransaction) -> Self::Archived {
|
||||||
Self::Archived {
|
Self::Archived {
|
||||||
ptr: unsafe {
|
ptr: unsafe {
|
||||||
rkyv::RelPtr::new(pos + rkyv::offset_of!(ArchivedI2cTransaction, ptr), self.bytes_pos)
|
rkyv::RelPtr::new(pos + rkyv::offset_of!(ArchivedI2cTransaction, ptr), self.bytes_pos)
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,10 @@
|
||||||
/// are calling these functions inside a different process.
|
/// are calling these functions inside a different process.
|
||||||
pub mod api;
|
pub mod api;
|
||||||
|
|
||||||
use api::*;
|
use xous::{send_message, CID};
|
||||||
use xous::{send_message, Error, CID};
|
|
||||||
|
|
||||||
pub fn allow_power_off(cid: CID, allow: bool) -> Result<(), xous::Error> {
|
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> {
|
pub fn allow_ec_snoop(cid: CID, allow: bool) -> Result<(), xous::Error> {
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,11 @@ use core::convert::TryFrom;
|
||||||
|
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
|
|
||||||
use xous::CID;
|
|
||||||
|
|
||||||
#[cfg(target_os = "none")]
|
#[cfg(target_os = "none")]
|
||||||
mod implementation {
|
mod implementation {
|
||||||
use crate::api::*;
|
use crate::api::*;
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use utralib::generated::*;
|
use utralib::generated::*;
|
||||||
use ticktimer_server::*;
|
|
||||||
|
|
||||||
const STD_TIMEOUT: u32 = 100;
|
const STD_TIMEOUT: u32 = 100;
|
||||||
|
|
||||||
|
|
@ -242,8 +239,11 @@ mod implementation {
|
||||||
}
|
}
|
||||||
pub fn power_self(&mut self, power_on: bool) {
|
pub fn power_self(&mut self, power_on: bool) {
|
||||||
if power_on {
|
if power_on {
|
||||||
|
info!("LLIO: setting self-power state to on");
|
||||||
self.power_csr.rmwf(utra::power::POWER_SELF, 1);
|
self.power_csr.rmwf(utra::power::POWER_SELF, 1);
|
||||||
} else {
|
} 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);
|
self.power_csr.rmwf(utra::power::POWER_SELF, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -406,8 +406,8 @@ mod implementation {
|
||||||
fn xmain() -> ! {
|
fn xmain() -> ! {
|
||||||
let debug1 = false;
|
let debug1 = false;
|
||||||
use crate::implementation::Llio;
|
use crate::implementation::Llio;
|
||||||
use heapless::Vec;
|
//use heapless::Vec;
|
||||||
use heapless::consts::*;
|
//use heapless::consts::*;
|
||||||
|
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
info!("LLIO: my PID is {}", xous::process::id());
|
info!("LLIO: my PID is {}", xous::process::id());
|
||||||
|
|
|
||||||
|
|
@ -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> {
|
fn process(&mut self, _rest: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||||
use core::fmt::Write;
|
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();
|
let mut ret = String::<1024>::new();
|
||||||
write!(ret, "Powerdown request denied").unwrap();
|
if ((llio::adc_vbus(env.llio).unwrap() as f64) * 0.005033) > 1.5 {
|
||||||
Ok(Some(ret))
|
// 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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue