Skip to main content

I2cStep

Enum I2cStep 

Source
pub enum I2cStep {
    Write {
        address: u8,
        bytes: Vec<u8>,
    },
    Read {
        address: u8,
        reply: Vec<u8>,
    },
    WriteRead {
        address: u8,
        bytes: Vec<u8>,
        reply: Vec<u8>,
    },
    Fault {
        address: u8,
        kind: ErrorKind,
    },
}
Expand description

One transfer a scripted I2C part expects, and what it answers.

Variants§

§

Write

The driver writes exactly bytes to address.

Fields

§address: u8

The 7-bit address the write must go to.

§bytes: Vec<u8>

The bytes the driver must send.

§

Read

The driver reads from address and receives reply, whose length is the length it must ask for.

Fields

§address: u8

The 7-bit address the read must come from.

§reply: Vec<u8>

The bytes the part answers with.

§

WriteRead

The driver writes bytes then reads reply.len() bytes from address in one transaction, the shape of a register read.

Fields

§address: u8

The 7-bit address of the part.

§bytes: Vec<u8>

The bytes the driver must send first, usually a register address.

§reply: Vec<u8>

The bytes the part answers with.

§

Fault

The part fails the next transfer to address with kind, the way a missing or busy part does.

Fields

§address: u8

The 7-bit address the failing transfer must go to.

§kind: ErrorKind

The failure the driver sees.

Implementations§

Source§

impl I2cStep

Source

pub fn write(address: u8, bytes: impl Into<Vec<u8>>) -> I2cStep

A write of exactly bytes to address.

§Arguments
  • address - the 7-bit address.
  • bytes - the bytes the driver must send.
§Returns

The step.

Source

pub fn read(address: u8, reply: impl Into<Vec<u8>>) -> I2cStep

A read from address answered with reply.

§Arguments
  • address - the 7-bit address.
  • reply - the bytes the part answers with; the driver must ask for exactly this many.
§Returns

The step.

Source

pub fn write_read( address: u8, bytes: impl Into<Vec<u8>>, reply: impl Into<Vec<u8>>, ) -> I2cStep

A write of bytes followed by a read answered with reply, in one transaction.

§Arguments
  • address - the 7-bit address.
  • bytes - the bytes the driver must send first.
  • reply - the bytes the part answers with.
§Returns

The step.

Source

pub fn fault(address: u8, kind: ErrorKind) -> I2cStep

A transfer to address that fails with kind.

§Arguments
  • address - the 7-bit address.
  • kind - the failure the driver sees.
§Returns

The step.

Trait Implementations§

Source§

impl Clone for I2cStep

Source§

fn clone(&self) -> I2cStep

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for I2cStep

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for I2cStep

Source§

impl PartialEq for I2cStep

Source§

fn eq(&self, other: &I2cStep) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for I2cStep

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.