Struct esp_ward::I2C

pub struct I2C<'d, T> { /* private fields */ }
Expand description

I2C peripheral container (I2C)

Implementations§

§

impl<'d, T> I2C<'d, T>
where T: Instance,

pub fn new<SDA, SCL>( i2c: impl Peripheral<P = T> + 'd, sda: impl Peripheral<P = SDA> + 'd, scl: impl Peripheral<P = SCL> + 'd, frequency: Rate<u32, 1, 1>, clocks: &Clocks<'_> ) -> I2C<'d, T>
where SDA: OutputPin + InputPin, SCL: OutputPin + InputPin,

Create a new I2C instance This will enable the peripheral but the peripheral won’t get automatically disabled when this gets dropped.

pub fn new_with_timeout<SDA, SCL>( i2c: impl Peripheral<P = T> + 'd, sda: impl Peripheral<P = SDA> + 'd, scl: impl Peripheral<P = SCL> + 'd, frequency: Rate<u32, 1, 1>, clocks: &Clocks<'_>, timeout: Option<u32> ) -> I2C<'d, T>
where SDA: OutputPin + InputPin, SCL: OutputPin + InputPin,

Create a new I2C instance with a custom timeout value. This will enable the peripheral but the peripheral won’t get automatically disabled when this gets dropped.

Trait Implementations§

§

impl<T> ErrorType for I2C<'_, T>

§

type Error = Error

Error type
§

impl<T> I2c for I2C<'_, T>
where T: Instance,

§

fn read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), <I2C<'_, T> as ErrorType>::Error>

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

fn write( &mut self, address: u8, bytes: &[u8] ) -> Result<(), <I2C<'_, T> as ErrorType>::Error>

Writes bytes to slave with address address. Read more
§

fn write_read( &mut self, address: u8, bytes: &[u8], buffer: &mut [u8] ) -> Result<(), <I2C<'_, T> as ErrorType>::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
§

fn transaction<'a>( &mut self, _address: u8, _operations: &mut [Operation<'a>] ) -> Result<(), <I2C<'_, T> as ErrorType>::Error>

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

impl<'d, T> I2c for I2C<'d, T>
where T: Instance,

§

async fn read( &mut self, address: u8, read: &mut [u8] ) -> Result<(), <I2C<'d, T> as ErrorType>::Error>

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

async fn write( &mut self, address: u8, write: &[u8] ) -> Result<(), <I2C<'d, T> as ErrorType>::Error>

Writes bytes to slave with address address. Read more
§

async fn write_read( &mut self, address: u8, write: &[u8], read: &mut [u8] ) -> Result<(), <I2C<'d, T> as ErrorType>::Error>

Writes bytes to slave with address address and then reads enough bytes to fill read in a single transaction. Read more
§

async fn transaction( &mut self, _address: u8, _operations: &mut [Operation<'_>] ) -> Result<(), <I2C<'d, T> as ErrorType>::Error>

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

impl<T> Read for I2C<'_, T>
where T: Instance,

§

type Error = Error

Error type
§

fn read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), <I2C<'_, T> as Read>::Error>

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

impl<T> Write for I2C<'_, T>
where T: Instance,

§

type Error = Error

Error type
§

fn write( &mut self, addr: u8, bytes: &[u8] ) -> Result<(), <I2C<'_, T> as Write>::Error>

Writes bytes to slave with address address Read more
§

impl<T> WriteRead for I2C<'_, T>
where T: Instance,

§

type Error = Error

Error type
§

fn write_read( &mut self, address: u8, bytes: &[u8], buffer: &mut [u8] ) -> Result<(), <I2C<'_, T> as WriteRead>::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, T> Freeze for I2C<'d, T>
where T: Freeze,

§

impl<'d, T> RefUnwindSafe for I2C<'d, T>
where T: RefUnwindSafe,

§

impl<'d, T> Send for I2C<'d, T>
where T: Send,

§

impl<'d, T> Sync for I2C<'d, T>
where T: Sync,

§

impl<'d, T> Unpin for I2C<'d, T>
where T: Unpin,

§

impl<'d, T> !UnwindSafe for I2C<'d, T>

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Az for T

source§

fn az<Dst>(self) -> Dst
where T: Cast<Dst>,

Casts the value.
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Src, Dst> CastFrom<Src> for Dst
where Src: Cast<Dst>,

source§

fn cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> CheckedAs for T

source§

fn checked_as<Dst>(self) -> Option<Dst>
where T: CheckedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> CheckedCastFrom<Src> for Dst
where Src: CheckedCast<Dst>,

source§

fn checked_cast_from(src: Src) -> Option<Dst>

Casts the value.
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

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> OverflowingAs for T

source§

fn overflowing_as<Dst>(self) -> (Dst, bool)
where T: OverflowingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> OverflowingCastFrom<Src> for Dst
where Src: OverflowingCast<Dst>,

source§

fn overflowing_cast_from(src: Src) -> (Dst, bool)

Casts the value.
source§

impl<T> SaturatingAs for T

source§

fn saturating_as<Dst>(self) -> Dst
where T: SaturatingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> SaturatingCastFrom<Src> for Dst
where Src: SaturatingCast<Dst>,

source§

fn saturating_cast_from(src: Src) -> Dst

Casts the value.
§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

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.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> UnwrappedAs for T

source§

fn unwrapped_as<Dst>(self) -> Dst
where T: UnwrappedCast<Dst>,

Casts the value.
source§

impl<Src, Dst> UnwrappedCastFrom<Src> for Dst
where Src: UnwrappedCast<Dst>,

source§

fn unwrapped_cast_from(src: Src) -> Dst

Casts the value.
source§

impl<T> WrappingAs for T

source§

fn wrapping_as<Dst>(self) -> Dst
where T: WrappingCast<Dst>,

Casts the value.
source§

impl<Src, Dst> WrappingCastFrom<Src> for Dst
where Src: WrappingCast<Dst>,

source§

fn wrapping_cast_from(src: Src) -> Dst

Casts the value.