I2c

Struct I2c 

Source
pub struct I2c<I2C: Instance> { /* private fields */ }
Expand description

I2C peripheral operating in master mode

Implementations§

Source§

impl<I2C: Instance> I2c<I2C>

Source

pub fn blocking( self, start_timeout_us: u32, start_retries: u8, addr_timeout_us: u32, data_timeout_us: u32, clocks: &Clocks, ) -> BlockingI2c<I2C>

Generates a blocking I2C instance from a universal I2C object

Source

pub fn blocking_default(self, clocks: Clocks) -> BlockingI2c<I2C>

Source§

impl<I2C: Instance> I2c<I2C>

Source

pub fn new<const R: u8>( i2c: impl Into<Rmp<I2C, R>>, pins: (impl RInto<I2C::Scl, R>, impl RInto<I2C::Sda, R>), mode: impl Into<Mode>, rcc: &mut Rcc, ) -> Self

Creates a generic I2C object

Source§

impl<I2C: Instance> I2c<I2C>

Source

pub fn reset(&mut self)

Perform an I2C software reset

Source

pub fn release(self) -> (I2C, (I2C::Scl, I2C::Sda))

Releases the I2C peripheral and associated pins

Source

pub fn read( &mut self, addr: impl Into<Address>, buffer: &mut [u8], ) -> Result<(), Error>

Source

pub fn write( &mut self, addr: impl Into<Address>, bytes: &[u8], ) -> Result<(), Error>

Source

pub fn write_iter<B>( &mut self, addr: impl Into<Address>, bytes: B, ) -> Result<(), Error>
where B: IntoIterator<Item = u8>,

Source

pub fn write_read( &mut self, addr: impl Into<Address>, bytes: &[u8], buffer: &mut [u8], ) -> Result<(), Error>

Source

pub fn write_iter_read<B>( &mut self, addr: impl Into<Address>, bytes: B, buffer: &mut [u8], ) -> Result<(), Error>
where B: IntoIterator<Item = u8>,

Source

pub fn transaction<'a>( &mut self, addr: impl Into<Address>, ops: impl Iterator<Item = Operation<'a>>, ) -> Result<(), Error>

Source

pub fn transaction_slice( &mut self, addr: impl Into<Address>, ops_slice: &mut [Operation<'_>], ) -> Result<(), Error>

Trait Implementations§

Source§

impl<I2C: Instance> ErrorType for I2c<I2C>

Source§

type Error = Error

Error type
Source§

impl<I2C: Instance> I2c<u16> for I2c<I2C>

Source§

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

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

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

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

fn write_read( &mut self, addr: TenBitAddress, bytes: &[u8], buffer: &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§

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

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

impl<I2C: Instance> I2c for I2c<I2C>

Source§

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

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

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

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

fn write_read( &mut self, addr: SevenBitAddress, bytes: &[u8], buffer: &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§

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

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

impl<I2C: Instance> Transactional for I2c<I2C>

Source§

type Error = Error

Error type
Source§

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

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

impl<I2C: Instance> WriteIter for I2c<I2C>

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<I2C: Instance> WriteIterRead for I2c<I2C>

Source§

type Error = Error

Error type
Source§

fn write_iter_read<B>( &mut self, addr: 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<I2C: Instance> Read for I2c<I2C>

Source§

type Error = 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<I2C: Instance> Write for I2c<I2C>

Source§

type Error = Error

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<I2C: Instance> WriteRead for I2c<I2C>

Source§

type Error = Error

Error type
Source§

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

Auto Trait Implementations§

§

impl<I2C> Freeze for I2c<I2C>
where I2C: Freeze, <I2C as I2cCommon>::Scl: Freeze, <I2C as I2cCommon>::Sda: Freeze,

§

impl<I2C> RefUnwindSafe for I2c<I2C>
where I2C: RefUnwindSafe, <I2C as I2cCommon>::Scl: RefUnwindSafe, <I2C as I2cCommon>::Sda: RefUnwindSafe,

§

impl<I2C> Send for I2c<I2C>
where I2C: Send, <I2C as I2cCommon>::Scl: Send, <I2C as I2cCommon>::Sda: Send,

§

impl<I2C> Sync for I2c<I2C>
where I2C: Sync, <I2C as I2cCommon>::Scl: Sync, <I2C as I2cCommon>::Sda: Sync,

§

impl<I2C> Unpin for I2c<I2C>
where I2C: Unpin, <I2C as I2cCommon>::Scl: Unpin, <I2C as I2cCommon>::Sda: Unpin,

§

impl<I2C> UnwindSafe for I2c<I2C>
where I2C: UnwindSafe, <I2C as I2cCommon>::Scl: UnwindSafe, <I2C as I2cCommon>::Sda: UnwindSafe,

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, const R: u8> RFrom<T, R> for T

Source§

fn rfrom(value: T) -> T

Source§

impl<S, T, const R: u8> RInto<T, R> for S
where T: RFrom<S, R>,

Source§

fn rinto(self) -> T

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.