embassy-mcxa

Crates

git

Versions

mcx-a256

Flavors

I2c

Struct I2c 

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

I2C Target Driver.

Implementations§

Source§

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

Source

pub fn blocking_listen(&mut self) -> Result<Request, IOError>

Block waiting for new events

Source

pub fn blocking_respond_to_read(&mut self, buf: &[u8]) -> Result<usize, IOError>

Transmit the contents of buf to the I2C controller.

Returns either an Ok(usize) containing the number of bytes transmitted, or an Error.

Source

pub fn blocking_respond_to_write( &mut self, buf: &mut [u8], ) -> Result<usize, IOError>

Receive data from the I2C controller into buf.

Care is taken to guarantee that we receive at most buf.len() bytes. On success returns Ok(usize) containing the number of bytes received or an Error.

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 Target bus driver.

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

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 blocking instance of the I2C Target 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.

Source§

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

Source

pub async fn async_listen(&mut self) -> Result<Request, IOError>

Asynchronously wait for new events

Source

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

Asynchronously transmit the contents of buf to the I2C controller.

Returns either an Ok(usize) containing the number of bytes transmitted, or an Error.

Source

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

Asynchronously receive data from the I2C controller into buf.

Care is taken to guarantee that we receive at most buf.len() bytes. On success returns Ok(usize) containing the number of bytes received or an Error.

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

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.