Struct stm32f4xx_hal::i2c::I2c

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

I2C abstraction

Implementations§

source§

impl<I2C: Instance> I2c<I2C>

source

pub fn use_dma<TX_STREAM, const TX_CH: u8, RX_STREAM, const RX_CH: u8>( self, tx_stream: TX_STREAM, rx_stream: RX_STREAM ) -> I2CMasterDma<I2C, TxDMA<I2C, TX_STREAM, TX_CH>, RxDMA<I2C, RX_STREAM, RX_CH>>
where TX_STREAM: Stream, ChannelX<TX_CH>: Channel, Tx<I2C>: DMASet<TX_STREAM, TX_CH, MemoryToPeripheral>, RX_STREAM: Stream, ChannelX<RX_CH>: Channel, Rx<I2C>: DMASet<RX_STREAM, RX_CH, PeripheralToMemory>,

Converts blocking I2c to non-blocking I2CMasterDma that use tx_stream and rx_stream to send/receive data

source

pub fn use_dma_tx<TX_STREAM, const TX_CH: u8>( self, tx_stream: TX_STREAM ) -> I2CMasterDma<I2C, TxDMA<I2C, TX_STREAM, TX_CH>, NoDMA>
where TX_STREAM: Stream, ChannelX<TX_CH>: Channel, Tx<I2C>: DMASet<TX_STREAM, TX_CH, MemoryToPeripheral>,

Converts blocking I2c to non-blocking I2CMasterDma that use tx_stream to only send data

source

pub fn use_dma_rx<RX_STREAM, const RX_CH: u8>( self, rx_stream: RX_STREAM ) -> I2CMasterDma<I2C, NoDMA, RxDMA<I2C, RX_STREAM, RX_CH>>
where RX_STREAM: Stream, ChannelX<RX_CH>: Channel, Rx<I2C>: DMASet<RX_STREAM, RX_CH, PeripheralToMemory>,

Converts blocking I2c to non-blocking I2CMasterDma that use rx_stream to only receive data

source§

impl<I2C> I2c<I2C>
where I2C: Instance,

source

pub fn new( i2c: I2C, pins: (impl Into<I2C::Scl>, impl Into<I2C::Sda>), mode: impl Into<Mode>, clocks: &Clocks ) -> Self

source

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

source§

impl<I2C: Instance> I2c<I2C>

source

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

source

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

source

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

source

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

source

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

source

pub fn transaction<'a>( &mut self, addr: u8, ops: impl Iterator<Item = Operation<'a>> ) -> 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 I2c<I2C>

§

type Error = Error

Error type
source§

impl<I2C: Instance> I2c for I2c<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> Transactional for I2c<I2C>
where I2C: Instance,

§

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> WriteIter for I2c<I2C>
where I2C: Instance,

§

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> WriteIterRead for I2c<I2C>
where I2C: Instance,

§

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> Read for I2c<I2C>
where I2C: Instance,

§

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> Write for I2c<I2C>
where I2C: Instance,

§

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> WriteRead for I2c<I2C>
where I2C: Instance,

§

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> 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, U> TryFrom<U> for T
where U: Into<T>,

§

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

§

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.