Struct I2cProxy

Source
pub struct I2cProxy<'a, M> { /* private fields */ }
Expand description

Proxy type for I2C bus sharing.

The I2cProxy implements all (blocking) I2C traits so it can be passed to drivers instead of the bus instance. Internally, it holds reference to the bus via a mutex, ensuring that all accesses are strictly synchronized.

An I2cProxy is created by calling BusManager::acquire_i2c().

Trait Implementations§

Source§

impl<'a, M: BusMutex> Clone for I2cProxy<'a, M>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, M: Debug> Debug for I2cProxy<'a, M>

Source§

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

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

impl<'a, M: BusMutex> ErrorType for I2cProxy<'a, M>
where M::Bus: ErrorType,

Source§

type Error = <<M as BusMutex>::Bus as ErrorType>::Error

Error type
Source§

impl<'a, M: BusMutex> I2c for I2cProxy<'a, M>
where M::Bus: I2c,

Source§

fn read(&mut self, address: u8, buffer: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill buffer Read more
Source§

fn write(&mut self, address: u8, bytes: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address Read more
Source§

fn write_iter<B>(&mut self, address: u8, bytes: B) -> Result<(), Self::Error>
where B: IntoIterator<Item = u8>,

Writes bytes to slave with address address Read more
Source§

fn write_read( &mut self, address: u8, bytes: &[u8], buffer: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more
Source§

fn write_iter_read<B>( &mut self, address: u8, bytes: B, buffer: &mut [u8], ) -> Result<(), Self::Error>
where B: IntoIterator<Item = u8>,

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more
Source§

fn transaction<'b>( &mut self, address: u8, operations: &mut [Operation<'b>], ) -> Result<(), Self::Error>

Execute the provided operations on the I2C bus. Read more
Source§

fn transaction_iter<'b, O>( &mut self, address: u8, operations: O, ) -> Result<(), Self::Error>
where O: IntoIterator<Item = Operation<'b>>,

Execute the provided operations on the I2C bus (iterator version). Read more
Source§

impl<'a, M: BusMutex> WriteIter for I2cProxy<'a, M>
where M::Bus: WriteIter,

Source§

type Error = <<M as BusMutex>::Bus as WriteIter>::Error

Error type
Source§

fn write<B>(&mut self, address: u8, bytes: B) -> Result<(), Self::Error>
where B: IntoIterator<Item = u8>,

Writes bytes to slave with address address Read more
Source§

impl<'a, M: BusMutex> WriteIterRead for I2cProxy<'a, M>
where M::Bus: WriteIterRead,

Source§

type Error = <<M as BusMutex>::Bus as WriteIterRead>::Error

Error type
Source§

fn write_iter_read<B>( &mut self, address: u8, bytes: B, buffer: &mut [u8], ) -> Result<(), Self::Error>
where B: IntoIterator<Item = u8>,

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more
Source§

impl<'a, M: BusMutex> Read for I2cProxy<'a, M>
where M::Bus: Read,

Source§

type Error = <<M as BusMutex>::Bus as Read>::Error

Error type
Source§

fn read(&mut self, addr: u8, buffer: &mut [u8]) -> Result<(), Self::Error>

Reads enough bytes from slave with address to fill buffer Read more
Source§

impl<'a, M: BusMutex> Write for I2cProxy<'a, M>
where M::Bus: Write,

Source§

type Error = <<M as BusMutex>::Bus as Write>::Error

Error type
Source§

fn write(&mut self, addr: u8, buffer: &[u8]) -> Result<(), Self::Error>

Writes bytes to slave with address address Read more
Source§

impl<'a, M: BusMutex> WriteRead for I2cProxy<'a, M>
where M::Bus: WriteRead,

Source§

type Error = <<M as BusMutex>::Bus as WriteRead>::Error

Error type
Source§

fn write_read( &mut self, addr: u8, buffer_in: &[u8], buffer_out: &mut [u8], ) -> Result<(), Self::Error>

Writes bytes to slave with address address and then reads enough bytes to fill buffer in a single transaction Read more

Auto Trait Implementations§

§

impl<'a, M> Freeze for I2cProxy<'a, M>

§

impl<'a, M> RefUnwindSafe for I2cProxy<'a, M>
where M: RefUnwindSafe,

§

impl<'a, M> Send for I2cProxy<'a, M>
where M: Sync,

§

impl<'a, M> Sync for I2cProxy<'a, M>
where M: Sync,

§

impl<'a, M> Unpin for I2cProxy<'a, M>

§

impl<'a, M> UnwindSafe for I2cProxy<'a, M>
where M: RefUnwindSafe,

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.