Add necessary changes for PowerTools
This commit is contained in:
parent
1b9bbbd0d5
commit
c2383801ef
4 changed files with 31 additions and 19 deletions
|
@ -20,7 +20,7 @@ pub trait ControllerGet<S, RV = u8>: embedded_io::ErrorType {
|
|||
|
||||
/// Size of values to write and read from ports.
|
||||
/// System endianness is assumed.
|
||||
#[derive(Copy, Clone)]
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[repr(u8)]
|
||||
pub enum ValueSize {
|
||||
Byte = 1, // u8
|
||||
|
@ -35,6 +35,7 @@ const MAX_WAIT_CHECKS: u16 = 0x07ff;
|
|||
#[cfg(not(feature = "std"))]
|
||||
const MAX_WAIT_CHECKS: u16 = 0x7fff;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct EmbeddedController {
|
||||
data_address: u16,
|
||||
cmd_address: u16,
|
||||
|
@ -96,6 +97,14 @@ impl EmbeddedController {
|
|||
pub fn set_value_size(&mut self, size: ValueSize) {
|
||||
self.rw_size = size;
|
||||
}
|
||||
|
||||
pub fn data(&self) -> u16 {
|
||||
self.data_address
|
||||
}
|
||||
|
||||
pub fn cmd(&self) -> u16 {
|
||||
self.cmd_address
|
||||
}
|
||||
}
|
||||
|
||||
impl embedded_io::ErrorType for EmbeddedController {
|
||||
|
|
|
@ -5,9 +5,9 @@ mod ports_internal {
|
|||
pub(crate) fn outb(port: u16, val: u8) {
|
||||
//println!("outb port:{:#04x} value:{:#02x}", port, val);
|
||||
unsafe {
|
||||
std::arch::asm!("out dx, al", in("dx") port, in("al") val);
|
||||
//std::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//std::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
core::arch::asm!("out dx, al", in("dx") port, in("al") val);
|
||||
//core::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//core::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
}
|
||||
//println!("outb done");
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ mod ports_internal {
|
|||
pub(crate) fn outw(port: u16, val: u16) {
|
||||
//println!("outw port:{:#04x} value:{:#02x}", port, val);
|
||||
unsafe {
|
||||
std::arch::asm!("out dx, ax", in("dx") port, in("ax") val);
|
||||
//std::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//std::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
core::arch::asm!("out dx, ax", in("dx") port, in("ax") val);
|
||||
//core::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//core::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
}
|
||||
//println!("outw done");
|
||||
}
|
||||
|
@ -27,9 +27,9 @@ mod ports_internal {
|
|||
pub(crate) fn outl(port: u16, val: u32) {
|
||||
//println!("outl port:{:#04x} value:{:#02x}", port, val);
|
||||
unsafe {
|
||||
std::arch::asm!("out dx, eax", in("dx") port, in("eax") val);
|
||||
//std::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//std::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
core::arch::asm!("out dx, eax", in("dx") port, in("eax") val);
|
||||
//core::arch::asm!("outb %al, %dx", in("al") val, in("dx") port, options(att_syntax));
|
||||
//core::arch::asm!("out dx,al", in("al") val, in("dx") port);
|
||||
}
|
||||
//println!("outl done");
|
||||
}
|
||||
|
@ -39,9 +39,9 @@ mod ports_internal {
|
|||
let out: u8;
|
||||
//println!("inb port:{:#04x}", port);
|
||||
unsafe {
|
||||
std::arch::asm!("in al, dx", in("dx") port, lateout("al") out);
|
||||
//std::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//std::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
core::arch::asm!("in al, dx", in("dx") port, lateout("al") out);
|
||||
//core::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//core::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
}
|
||||
//println!("inb port:{:#04x} -> value:{:#02x}", port, out);
|
||||
out
|
||||
|
@ -52,9 +52,9 @@ mod ports_internal {
|
|||
let out: u16;
|
||||
//println!("inb port:{:#04x}", port);
|
||||
unsafe {
|
||||
std::arch::asm!("in ax, dx", in("dx") port, lateout("ax") out);
|
||||
//std::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//std::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
core::arch::asm!("in ax, dx", in("dx") port, lateout("ax") out);
|
||||
//core::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//core::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
}
|
||||
//println!("inb port:{:#04x} -> value:{:#02x}", port, out);
|
||||
out
|
||||
|
@ -65,9 +65,9 @@ mod ports_internal {
|
|||
let out: u32;
|
||||
//println!("inb port:{:#04x}", port);
|
||||
unsafe {
|
||||
std::arch::asm!("in eax, dx", in("dx") port, lateout("eax") out);
|
||||
//std::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//std::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
core::arch::asm!("in eax, dx", in("dx") port, lateout("eax") out);
|
||||
//core::arch::asm!("inb %dx, %al", in("dx") port, out("al") out, options(att_syntax));
|
||||
//core::arch::asm!("in al,dx", in("dx") port, out("al") out);
|
||||
}
|
||||
//println!("inb port:{:#04x} -> value:{:#02x}", port, out);
|
||||
out
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
mod addresses;
|
||||
pub use addresses::{Setting, Charge, ChargeMode, ControlBoard, BreathingColour, StaticColour};
|
||||
#[cfg(feature = "std")]
|
||||
pub mod raw_io;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct UnnamedPowerEC(super::EmbeddedController);
|
||||
|
||||
impl UnnamedPowerEC {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
//! Low-level hardware interfaces for Valve's Steam Deck
|
||||
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![warn(missing_docs)]
|
||||
|
||||
pub mod ec;
|
||||
|
|
Loading…
Reference in a new issue