Struct esp32_hal::i2c::I2C

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

I2C peripheral container (I2C)

Implementations§

source§

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

source

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.

source

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§

source§

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

§

type Error = Error

Error type
source§

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

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

§

type Error = Error

Error type
source§

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

Writes bytes to slave with address address Read more
source§

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

§

type Error = Error

Error type
source§

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

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.