mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
Modify I2C API to accommodate Nack responses specifically
This commit is contained in:
parent
76a45ff47d
commit
73a1714772
2 changed files with 6 additions and 3 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
pub trait I2cApi {
|
pub trait I2cApi {
|
||||||
fn i2c_write(&mut self, dev: u8, adr: u8, data: &[u8]) -> Result<usize, xous::Error>;
|
fn i2c_write(&mut self, dev: u8, adr: u8, data: &[u8]) -> Result<I2cResult, xous::Error>;
|
||||||
|
|
||||||
/// initiate an i2c read. The read buffer is passed during the await.
|
/// initiate an i2c read. The read buffer is passed during the await.
|
||||||
fn i2c_read(
|
fn i2c_read(
|
||||||
|
|
@ -8,7 +8,7 @@ pub trait I2cApi {
|
||||||
adr: u8,
|
adr: u8,
|
||||||
buf: &mut [u8],
|
buf: &mut [u8],
|
||||||
repeated_start: bool,
|
repeated_start: bool,
|
||||||
) -> Result<usize, xous::Error>;
|
) -> Result<I2cResult, xous::Error>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||||
|
|
@ -20,7 +20,7 @@ pub enum I2cTransactionType {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||||
#[derive(Debug)]
|
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||||
pub enum I2cResult {
|
pub enum I2cResult {
|
||||||
/// For the outbound message holder
|
/// For the outbound message holder
|
||||||
Pending,
|
Pending,
|
||||||
|
|
@ -28,6 +28,8 @@ pub enum I2cResult {
|
||||||
Ack(usize),
|
Ack(usize),
|
||||||
/// An error occurred.
|
/// An error occurred.
|
||||||
Nack,
|
Nack,
|
||||||
|
/// An unhandled error has occurred.
|
||||||
|
InternalError,
|
||||||
}
|
}
|
||||||
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
#[cfg_attr(feature = "derive-rkyv", derive(rkyv::Archive, rkyv::Serialize, rkyv::Deserialize))]
|
||||||
#[cfg(feature = "std")]
|
#[cfg(feature = "std")]
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,7 @@ pub enum EventChannel {
|
||||||
#[derive(Debug, Copy, Clone, num_derive::FromPrimitive)]
|
#[derive(Debug, Copy, Clone, num_derive::FromPrimitive)]
|
||||||
pub enum IrqBank {
|
pub enum IrqBank {
|
||||||
I2c,
|
I2c,
|
||||||
|
I2cErr,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Use a trait that will allow us to share code between both `std` and `no-std` implementations
|
/// Use a trait that will allow us to share code between both `std` and `no-std` implementations
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue