i2cdev::mock

Struct MockI2CDevice

Source
pub struct MockI2CDevice {
    pub regmap: I2CRegisterMap,
}
Expand description

Mock I2C device exposing a register map

Fields§

§regmap: I2CRegisterMap

I2C register map

Implementations§

Source§

impl MockI2CDevice

Source

pub fn new() -> MockI2CDevice

Create a new mock I2C device

Trait Implementations§

Source§

impl Default for MockI2CDevice

Source§

fn default() -> MockI2CDevice

Returns the “default value” for a type. Read more
Source§

impl I2CDevice for MockI2CDevice

Source§

type Error = Error

Error type
Source§

fn read(&mut self, data: &mut [u8]) -> I2CResult<()>

Read data from the device to fill the provided slice
Source§

fn write(&mut self, data: &[u8]) -> I2CResult<()>

Write the provided buffer to the device
Source§

fn smbus_write_quick(&mut self, _bit: bool) -> I2CResult<()>

This sends a single bit to the device, at the place of the Rd/Wr bit
Source§

fn smbus_read_block_data(&mut self, _register: u8) -> I2CResult<Vec<u8>>

Read a block of up to 32 bytes from a device Read more
Source§

fn smbus_write_block_data( &mut self, _register: u8, _values: &[u8], ) -> I2CResult<()>

Write a block of up to 32 bytes to a device Read more
Source§

fn smbus_process_block( &mut self, _register: u8, _values: &[u8], ) -> I2CResult<Vec<u8>>

Select a register, send 1 to 31 bytes of data to it, and reads 1 to 31 bytes of data from it.
Source§

fn smbus_read_i2c_block_data( &mut self, _register: u8, _len: u8, ) -> I2CResult<Vec<u8>>

Read a block of up to 32 bytes from a device Read more
Source§

fn smbus_write_i2c_block_data( &mut self, _register: u8, _values: &[u8], ) -> I2CResult<()>

Write a block of up to 32 bytes from a device Read more
Source§

fn smbus_read_byte(&mut self) -> Result<u8, Self::Error>

Read a single byte from a device, without specifying a device register Read more
Source§

fn smbus_write_byte(&mut self, value: u8) -> Result<(), Self::Error>

Write a single byte to a device, without specifying a device register Read more
Source§

fn smbus_read_byte_data(&mut self, register: u8) -> Result<u8, Self::Error>

Read a single byte from a device, from a designated register Read more
Source§

fn smbus_write_byte_data( &mut self, register: u8, value: u8, ) -> Result<(), Self::Error>

Write a single byte to a specific register on a device Read more
Source§

fn smbus_read_word_data(&mut self, register: u8) -> Result<u16, Self::Error>

Read 2 bytes from a given register on a device (lsb first)
Source§

fn smbus_write_word_data( &mut self, register: u8, value: u16, ) -> Result<(), Self::Error>

Write 2 bytes to a given register on a device (lsb first)
Source§

fn smbus_process_word( &mut self, register: u8, value: u16, ) -> Result<u16, Self::Error>

Select a register, send 16 bits of data to it, and read 16 bits of data
Source§

impl<'a> I2CTransfer<'a> for MockI2CDevice

Source§

fn transfer( &mut self, messages: &'a mut [Self::Message], ) -> Result<u32, Self::Error>

Issue the provided sequence of I2C transactions

Source§

type Error = Error

I2C transfer error type
Source§

type Message = MockI2CMessage<'a>

I2C transfer message type

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> 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, 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.