mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
add IoGpio for xous environment
This commit is contained in:
parent
9527dcfbaf
commit
68828cf9ce
1 changed files with 26 additions and 1 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
|
|
||||||
use cramium_hal::iox::{IoSetup, IoxDir, IoxDriveStrength, IoxEnable, IoxFunction, IoxPort, IoxValue};
|
use cramium_hal::iox::{
|
||||||
|
IoGpio, IoSetup, IoxDir, IoxDriveStrength, IoxEnable, IoxFunction, IoxPort, IoxValue,
|
||||||
|
};
|
||||||
use num_traits::*;
|
use num_traits::*;
|
||||||
|
|
||||||
use crate::{Opcode, SERVER_NAME_CRAM_HAL, api::IoxConfigMessage};
|
use crate::{Opcode, SERVER_NAME_CRAM_HAL, api::IoxConfigMessage};
|
||||||
|
|
@ -140,6 +142,29 @@ impl IoSetup for IoxHal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IoGpio for IoxHal {
|
||||||
|
fn get_gpio_pin_value(&self, port: IoxPort, pin: u8) -> IoxValue { self.get_gpio_pin_value(port, pin) }
|
||||||
|
|
||||||
|
fn set_gpio_pin_dir(&self, port: IoxPort, pin: u8, dir: IoxDir) {
|
||||||
|
let msg = IoxConfigMessage {
|
||||||
|
port,
|
||||||
|
pin,
|
||||||
|
direction: Some(dir),
|
||||||
|
function: None,
|
||||||
|
schmitt_trigger: None,
|
||||||
|
pullup: None,
|
||||||
|
slow_slew: None,
|
||||||
|
strength: None,
|
||||||
|
};
|
||||||
|
let buf = xous_ipc::Buffer::into_buf(msg).unwrap();
|
||||||
|
buf.lend(self.conn, Opcode::ConfigureIox.to_u32().unwrap()).expect("Couldn't set up IO");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_gpio_pin_value(&self, port: IoxPort, pin: u8, value: IoxValue) {
|
||||||
|
self.set_gpio_pin_value(port, pin, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Drop for IoxHal {
|
impl Drop for IoxHal {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
// de-allocate myself. It's unsafe because we are responsible to make sure nobody else is using the
|
// de-allocate myself. It's unsafe because we are responsible to make sure nobody else is using the
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue