BlockingI2c

Struct BlockingI2c 

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

embedded-hal compatible blocking I2C implementation

NOTE: Before using blocking I2C, you need to enable the DWT cycle counter using the DWT::enable_cycle_counter method.

Implementations§

Source§

impl<I2C: Instance> BlockingI2c<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, start_timeout_us: u32, start_retries: u8, addr_timeout_us: u32, data_timeout_us: u32, ) -> Self

Creates a blocking I2C1 object on pins PB6 and PB7 or PB8 and PB9 using the embedded-hal BlockingI2c trait.

Source§

impl<I2C: Instance> BlockingI2c<I2C>

Source

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

Source

pub fn reset(&mut self)

Source

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

Source

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

Source

pub fn transaction_slice( &mut self, _addr: u8, _ops_slice: &mut [Operation<'_>], ) -> Result<(), Error>

Trait Implementations§

Source§

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

Source§

type Error = Error

Error type
Source§

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

Source§

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

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

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

Writes bytes to slave with address address. Read more
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 read in a single transaction. Read more
Source§

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

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

impl<I2C: Instance> Transactional for BlockingI2c<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> Read for BlockingI2c<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 BlockingI2c<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 BlockingI2c<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 BlockingI2c<I2C>
where I2C: Freeze, <I2C as I2cCommon>::Scl: Freeze, <I2C as I2cCommon>::Sda: Freeze,

§

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

§

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

§

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

§

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

§

impl<I2C> UnwindSafe for BlockingI2c<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.