mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
add pio bit setting to api
This commit is contained in:
parent
21fc147060
commit
514b27eb18
2 changed files with 25 additions and 0 deletions
|
|
@ -30,6 +30,8 @@ pub enum HalOpcode {
|
|||
SetGpioBank = 5,
|
||||
/// Return the value of a GPIO bank (blocking scalar)
|
||||
GetGpioBank = 6,
|
||||
/// Configure BIO
|
||||
ConfigureBio = 17,
|
||||
|
||||
/// Configure UDMA clocks & events
|
||||
// blocking scalar
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ pub trait IoSetup {
|
|||
slow_slew: Option<IoxEnable>,
|
||||
strength: Option<IoxDriveStrength>,
|
||||
);
|
||||
fn set_pio_bit_from_port_and_pin(&self, port: IoxPort, pin: u8) -> Option<u8>;
|
||||
}
|
||||
|
||||
/// Traits for accessing GPIOs after the port has been set up.
|
||||
|
|
@ -259,6 +260,28 @@ impl IoSetup for IoxHal {
|
|||
let buf = xous_ipc::Buffer::into_buf(msg).unwrap();
|
||||
buf.lend(self.conn, HalOpcode::ConfigureIox as u32).expect("Couldn't set up IO");
|
||||
}
|
||||
|
||||
fn set_pio_bit_from_port_and_pin(&self, port: IoxPort, pin: u8) -> Option<u8> {
|
||||
match xous::send_message(
|
||||
self.conn,
|
||||
xous::Message::new_blocking_scalar(
|
||||
HalOpcode::ConfigureBio.to_usize().unwrap(),
|
||||
port as usize,
|
||||
pin as usize,
|
||||
0,
|
||||
0,
|
||||
),
|
||||
) {
|
||||
Ok(xous::Result::Scalar2(code, ok)) => {
|
||||
if ok != 0 {
|
||||
Some(code as u8)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
_ => panic!("Internal error setting up BIO"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "std")]
|
||||
|
|
|
|||
Loading…
Reference in a new issue