I2C

Struct I2C 

Source
pub struct I2C<'pio, P, SMI, SDA, SCL>
where P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,
{ /* private fields */ }
Expand description

Instance of I2C Controller.

Implementations§

Source§

impl<P, SMI, SDA, SCL> I2C<'_, P, SMI, SDA, SCL>
where P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source

pub fn write_iter<B, A>(&mut self, address: A, bytes: B) -> Result<(), Error>
where A: ValidAddressMode, B: IntoIterator<Item = u8> + Clone,

Source

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

Source

pub fn transaction_iter<'a, A, O>( &mut self, address: A, operations: O, ) -> Result<(), Error>
where A: ValidAddressMode, O: IntoIterator<Item = Operation<'a>>,

Source§

impl<'pio, P, SMI, SDA, SCL> I2C<'pio, P, SMI, SDA, SCL>
where P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source

pub fn new( pio: &'pio mut PIO<P>, sda: SDA, scl: SCL, sm: UninitStateMachine<(P, SMI)>, bus_freq: HertzU32, clock_freq: HertzU32, ) -> Self
where SDA: AnyPin<Function = FunctionNull>, SDA::Id: ValidFunction<P::PinFunction>, SCL: AnyPin<Function = FunctionNull>, SCL::Id: ValidFunction<P::PinFunction>,

Creates a new instance of this driver.

Note: the PIO must have been reset before using this driver.

Source§

impl<P, SMI, SDA, SCL> I2C<'_, P, SMI, SDA, SCL>
where P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SDA::Id: ValidFunction<SDA::Function>, SCL: AnyPin, SCL::Id: ValidFunction<SCL::Function>,

Source

pub fn free(self) -> ((SDA::Type, SCL::Type), UninitStateMachine<(P, SMI)>)

Frees the state machine and pins.

Trait Implementations§

Source§

impl<P, SMI, SDA, SCL> ErrorType for I2C<'_, P, SMI, SDA, SCL>
where P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

impl<A, P, SMI, SDA, SCL> I2c<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

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

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

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

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

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

Writes bytes to slave with address address. Read more
Source§

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

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

impl<A, P, SMI, SDA, SCL> Transactional<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

fn exec( &mut self, address: A, operations: &mut [Operation<'_>], ) -> Result<(), Self::Error>

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

impl<A, P, SMI, SDA, SCL> TransactionalIter<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

fn exec_iter<'a, O>( &mut self, address: A, operations: O, ) -> Result<(), Self::Error>
where O: IntoIterator<Item = Operation<'a>>,

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

impl<A, P, SMI, SDA, SCL> WriteIter<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<A, P, SMI, SDA, SCL> WriteIterRead<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

fn write_iter_read<B>( &mut self, address: A, 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, P, SMI, SDA, SCL> Read<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

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

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

impl<A, P, SMI, SDA, SCL> Write<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<A, P, SMI, SDA, SCL> WriteRead<A> for I2C<'_, P, SMI, SDA, SCL>
where A: ValidAddressMode, P: PIOExt, SMI: StateMachineIndex, SDA: AnyPin, SCL: AnyPin,

Source§

type Error = Error

Error type
Source§

fn write_read( &mut self, address: A, 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

Auto Trait Implementations§

§

impl<'pio, P, SMI, SDA, SCL> Freeze for I2C<'pio, P, SMI, SDA, SCL>
where <SDA as AnyPin>::Id: Freeze, <P as PIOExt>::PinFunction: Freeze, <SCL as AnyPin>::Id: Freeze,

§

impl<'pio, P, SMI, SDA, SCL> !RefUnwindSafe for I2C<'pio, P, SMI, SDA, SCL>

§

impl<'pio, P, SMI, SDA, SCL> Send for I2C<'pio, P, SMI, SDA, SCL>
where <SDA as AnyPin>::Id: Send, <P as PIOExt>::PinFunction: Send, <SCL as AnyPin>::Id: Send,

§

impl<'pio, P, SMI, SDA, SCL> !Sync for I2C<'pio, P, SMI, SDA, SCL>

§

impl<'pio, P, SMI, SDA, SCL> Unpin for I2C<'pio, P, SMI, SDA, SCL>
where <SDA as AnyPin>::Id: Unpin, <P as PIOExt>::PinFunction: Unpin, <SCL as AnyPin>::Id: Unpin, P: Unpin, SMI: Unpin,

§

impl<'pio, P, SMI, SDA, SCL> !UnwindSafe for I2C<'pio, P, SMI, SDA, SCL>

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<Choices> CoproductSubsetter<CNil, HNil> for Choices

Source§

type Remainder = Choices

Source§

fn subset( self, ) -> Result<CNil, <Choices as CoproductSubsetter<CNil, HNil>>::Remainder>

Extract a subset of the possible types in a coproduct (or get the remaining possibilities) 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T, U, I> LiftInto<U, I> for T
where U: LiftFrom<T, I>,

Source§

fn lift_into(self) -> U

Performs the indexed conversion.
Source§

impl<Source> Sculptor<HNil, HNil> for Source

Source§

type Remainder = Source

Source§

fn sculpt(self) -> (HNil, <Source as Sculptor<HNil, HNil>>::Remainder)

Consumes the current HList and returns an HList with the requested shape. 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.