embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

I2c

Struct I2c 

Source
pub struct I2c<'d, M: Mode> { /* private fields */ }
Expand description

I2C Controller Driver.

Implementations§

Source§

impl<'d> I2c<'d, Blocking>

Source

pub fn new_blocking<T: Instance>( peri: Peri<'d, T>, scl: Peri<'d, impl SclPin<T>>, sda: Peri<'d, impl SdaPin<T>>, config: Config, ) -> Result<Self, SetupError>

Create a new blocking instance of the I2C Controller bus driver.

Any external pin will be placed into Disabled state upon Drop.

Source§

impl<'d, M: Mode> I2c<'d, M>

Source

pub fn blocking_read( &mut self, address: u8, read: &mut [u8], ) -> Result<(), IOError>

Read from address into buffer blocking caller until done.

Source

pub fn blocking_write( &mut self, address: u8, write: &[u8], ) -> Result<(), IOError>

Write to address from buffer blocking caller until done.

Source

pub fn blocking_write_read( &mut self, address: u8, write: &[u8], read: &mut [u8], ) -> Result<(), IOError>

Write to address from bytes and read from address into buffer blocking caller until done.

Source§

impl<'d, M: AsyncMode> I2c<'d, M>
where Self: AsyncEngine,

Source

pub fn async_read<'a>( &'a mut self, address: u8, read: &'a mut [u8], ) -> impl Future<Output = Result<(), IOError>> + 'a

Read from address into buffer asynchronously.

Source

pub fn async_write<'a>( &'a mut self, address: u8, write: &'a [u8], ) -> impl Future<Output = Result<(), IOError>> + 'a

Source

pub fn async_write_read<'a>( &'a mut self, address: u8, write: &'a [u8], read: &'a mut [u8], ) -> impl Future<Output = Result<(), IOError>> + 'a

Write to address from bytes and read from address into buffer asynchronously.

Source§

impl<'d> I2c<'d, Async>

Source

pub fn new_async<T: Instance>( peri: Peri<'d, T>, scl: Peri<'d, impl SclPin<T>>, sda: Peri<'d, impl SdaPin<T>>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, ) -> Result<Self, SetupError>

Create a new async instance of the I2C Controller bus driver.

Any external pin will be placed into Disabled state upon Drop.

Source§

impl<'d> I2c<'d, Dma<'d>>

Source

pub fn new_async_with_dma<T: Instance>( peri: Peri<'d, T>, scl: Peri<'d, impl SclPin<T>>, sda: Peri<'d, impl SdaPin<T>>, tx_dma: Peri<'d, impl TxDma<T>>, rx_dma: Peri<'d, impl RxDma<T>>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, ) -> Result<Self, SetupError>

Create a new async instance of the I2C Controller bus driver with DMA support.

Any external pin will be placed into Disabled state upon Drop, additionally, the DMA channel is disabled.

Trait Implementations§

Source§

impl<'d, M: Mode> Drop for I2c<'d, M>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

impl<'d, M: Mode> ErrorType for I2c<'d, M>

Source§

type Error = IOError

Error type
Source§

impl<'d, M: Mode> I2c for I2c<'d, M>

Source§

fn transaction( &mut self, address: u8, 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<'d, M: AsyncMode> I2c for I2c<'d, M>
where I2c<'d, M>: AsyncEngine,

Source§

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

Execute the provided operations on the I2C bus as a single transaction. Read more
Source§

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

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

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

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

async 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<'d, M: Mode> SetConfig for I2c<'d, M>

Source§

type Config = Config

The configuration type used by this driver.
Source§

type ConfigError = SetupError

The error type that can occur if set_config fails.
Source§

fn set_config(&mut self, config: &Self::Config) -> Result<(), SetupError>

Set the configuration of the driver.
Source§

impl<'d, M: Mode> Transactional for I2c<'d, M>

Source§

type Error = IOError

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<'d, M: Mode> Read for I2c<'d, M>

Source§

type Error = IOError

Error type
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§

impl<'d, M: Mode> Write for I2c<'d, M>

Source§

type Error = IOError

Error type
Source§

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

Writes bytes to slave with address address Read more
Source§

impl<'d, M: Mode> WriteRead for I2c<'d, M>

Source§

type Error = IOError

Error type
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

Auto Trait Implementations§

§

impl<'d, M> Freeze for I2c<'d, M>
where M: Freeze,

§

impl<'d, M> !RefUnwindSafe for I2c<'d, M>

§

impl<'d, M> Send for I2c<'d, M>
where M: Send,

§

impl<'d, M> Sync for I2c<'d, M>
where M: Sync,

§

impl<'d, M> Unpin for I2c<'d, M>
where M: Unpin,

§

impl<'d, M> !UnwindSafe for I2c<'d, M>

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

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.