pub struct I2C<'d, T> { /* private fields */ }
Expand description
I2C peripheral container (I2C)
Implementations§
§impl<'d, T> I2C<'d, T>where
T: Instance,
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>
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>
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>
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>
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> I2c for I2C<'_, T>where
T: Instance,
impl<T> I2c for I2C<'_, T>where
T: Instance,
§fn read(
&mut self,
address: u8,
buffer: &mut [u8]
) -> Result<(), <I2C<'_, T> as ErrorType>::Error>
fn read( &mut self, address: u8, buffer: &mut [u8] ) -> Result<(), <I2C<'_, T> as ErrorType>::Error>
§fn write(
&mut self,
address: u8,
bytes: &[u8]
) -> Result<(), <I2C<'_, T> as ErrorType>::Error>
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>
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>
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,
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>
async fn read( &mut self, address: u8, read: &mut [u8] ) -> Result<(), <I2C<'d, T> as ErrorType>::Error>
§async fn write(
&mut self,
address: u8,
write: &[u8]
) -> Result<(), <I2C<'d, T> as ErrorType>::Error>
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>
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>
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
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 Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
§impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
impl<T, U> TryFrom<U> for Twhere
U: Into<T>,
§impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
impl<T, U> TryInto<U> for Twhere
U: TryFrom<T>,
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.