pub struct I2cSlave<'d, Dm: DriverMode> { /* private fields */ }Expand description
I2C Slave driver
Implementations§
Source§impl<'d> I2cSlave<'d, Async>
impl<'d> I2cSlave<'d, Async>
Sourcepub fn into_blocking(self) -> I2cSlave<'d, Blocking>
pub fn into_blocking(self) -> I2cSlave<'d, Blocking>
Reconfigures the driver to operate in Blocking mode.
Source§impl<'d, Dm: DriverMode> I2cSlave<'d, Dm>
impl<'d, Dm: DriverMode> I2cSlave<'d, Dm>
Sourcepub fn with_sda(
self,
sda: impl PeripheralInput<'d> + PeripheralOutput<'d>,
) -> Self
pub fn with_sda( self, sda: impl PeripheralInput<'d> + PeripheralOutput<'d>, ) -> Self
Connects a pin to the I2C SDA signal.
Sourcepub fn with_scl(
self,
scl: impl PeripheralInput<'d> + PeripheralOutput<'d>,
) -> Self
pub fn with_scl( self, scl: impl PeripheralInput<'d> + PeripheralOutput<'d>, ) -> Self
Connects a pin to the I2C SCL signal.
Sourcepub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
pub fn apply_config(&mut self, config: &Config) -> Result<(), ConfigError>
Applies a new configuration.
Source§impl<'d, Dm: DriverMode> I2cSlave<'d, Dm>
impl<'d, Dm: DriverMode> I2cSlave<'d, Dm>
Sourcepub fn listen(&mut self, buffer: &mut [u8]) -> Result<Command, Error>
pub fn listen(&mut self, buffer: &mut [u8]) -> Result<Command, Error>
Listens for a request from the master.
If the master writes to the slave, this method reads data into the provided
buffer and returns Command::Write(len).
If the master is requesting a read, it returns Command::Read with the SCL line
stretched (held low).
Sourcepub fn respond_to_read(&mut self, buffer: &[u8]) -> Result<ReadStatus, Error>
pub fn respond_to_read(&mut self, buffer: &[u8]) -> Result<ReadStatus, Error>
Responds to a master read request.
Writes the contents of buffer to the TX FIFO, clears the clock stretch,
and waits for the transaction to complete.
Source§impl<'d> I2cSlave<'d, Async>
impl<'d> I2cSlave<'d, Async>
Sourcepub async fn listen_async(
&mut self,
buffer: &mut [u8],
) -> Result<Command, Error>
pub async fn listen_async( &mut self, buffer: &mut [u8], ) -> Result<Command, Error>
Listens for a request from the master asynchronously.
Sourcepub async fn respond_to_read_async(
&mut self,
buffer: &[u8],
) -> Result<ReadStatus, Error>
pub async fn respond_to_read_async( &mut self, buffer: &[u8], ) -> Result<ReadStatus, Error>
Responds to a master read request asynchronously.
Trait Implementations§
Auto Trait Implementations§
impl<'d, Dm> !UnwindSafe for I2cSlave<'d, Dm>
impl<'d, Dm> Freeze for I2cSlave<'d, Dm>where
PhantomData<Dm>: Freeze,
impl<'d, Dm> RefUnwindSafe for I2cSlave<'d, Dm>where
PhantomData<Dm>: RefUnwindSafe,
impl<'d, Dm> Send for I2cSlave<'d, Dm>where
PhantomData<Dm>: Send,
impl<'d, Dm> Sync for I2cSlave<'d, Dm>where
PhantomData<Dm>: Sync,
impl<'d, Dm> Unpin for I2cSlave<'d, Dm>where
PhantomData<Dm>: Unpin,
impl<'d, Dm> UnsafeUnpin for I2cSlave<'d, Dm>where
PhantomData<Dm>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more