mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
absorb setup_pin trait into the cramium-hal service
This commit is contained in:
parent
c0ddf5f82a
commit
76e88ebc7d
2 changed files with 21 additions and 19 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
use core::sync::atomic::Ordering;
|
use core::sync::atomic::Ordering;
|
||||||
|
|
||||||
use cramium_hal::iox::{IoxDir, IoxDriveStrength, IoxEnable, IoxFunction, IoxPort, IoxValue};
|
use cramium_hal::iox::{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};
|
||||||
|
|
@ -18,23 +18,6 @@ impl IoxHal {
|
||||||
IoxHal { conn }
|
IoxHal { conn }
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn setup_io_pin(
|
|
||||||
&self,
|
|
||||||
port: IoxPort,
|
|
||||||
pin: u8,
|
|
||||||
direction: Option<IoxDir>,
|
|
||||||
function: Option<IoxFunction>,
|
|
||||||
schmitt_trigger: Option<IoxEnable>,
|
|
||||||
pullup: Option<IoxEnable>,
|
|
||||||
slow_slew: Option<IoxEnable>,
|
|
||||||
strength: Option<IoxDriveStrength>,
|
|
||||||
) {
|
|
||||||
let msg =
|
|
||||||
IoxConfigMessage { port, pin, direction, function, schmitt_trigger, pullup, slow_slew, strength };
|
|
||||||
let buf = xous_ipc::Buffer::into_buf(msg).unwrap();
|
|
||||||
buf.lend(self.conn, Opcode::ConfigureIox.to_u32().unwrap()).expect("Couldn't set up IO");
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_gpio_pin_value(&self, port: IoxPort, pin: u8, value: IoxValue) {
|
pub fn set_gpio_pin_value(&self, port: IoxPort, pin: u8, value: IoxValue) {
|
||||||
xous::send_message(
|
xous::send_message(
|
||||||
self.conn,
|
self.conn,
|
||||||
|
|
@ -138,6 +121,25 @@ impl IoxHal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl IoSetup for IoxHal {
|
||||||
|
fn setup_pin(
|
||||||
|
&self,
|
||||||
|
port: IoxPort,
|
||||||
|
pin: u8,
|
||||||
|
direction: Option<IoxDir>,
|
||||||
|
function: Option<IoxFunction>,
|
||||||
|
schmitt_trigger: Option<IoxEnable>,
|
||||||
|
pullup: Option<IoxEnable>,
|
||||||
|
slow_slew: Option<IoxEnable>,
|
||||||
|
strength: Option<IoxDriveStrength>,
|
||||||
|
) {
|
||||||
|
let msg =
|
||||||
|
IoxConfigMessage { port, pin, direction, function, schmitt_trigger, pullup, slow_slew, strength };
|
||||||
|
let buf = xous_ipc::Buffer::into_buf(msg).unwrap();
|
||||||
|
buf.lend(self.conn, Opcode::ConfigureIox.to_u32().unwrap()).expect("Couldn't set up IO");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ fn main() {
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.expect("couldn't claim the IOX hardware page");
|
.expect("couldn't claim the IOX hardware page");
|
||||||
let mut iox = iox::Iox::new(iox_page.as_mut_ptr() as *mut u32);
|
let iox = iox::Iox::new(iox_page.as_ptr() as *mut u32);
|
||||||
|
|
||||||
let udma_global_csr = xous::syscall::map_memory(
|
let udma_global_csr = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utralib::generated::HW_UDMA_CTRL_BASE),
|
xous::MemoryAddress::new(utralib::generated::HW_UDMA_CTRL_BASE),
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue