pub struct I2cSlave<'d, Dm: DriverMode> { /* private fields */ }Expand description
I2C Slave driver
Implementations§
Source§impl<'d> I2cSlave<'d, Blocking>
impl<'d> I2cSlave<'d, Blocking>
Sourcepub fn new(i2c: impl Instance + 'd, config: Config) -> Result<Self, ConfigError>
pub fn new(i2c: impl Instance + 'd, config: Config) -> Result<Self, ConfigError>
Create a new I2C slave instance.
Sourcepub fn into_async(self) -> I2cSlave<'d, Async>
pub fn into_async(self) -> I2cSlave<'d, Async>
Reconfigures the driver to operate in Async mode.
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
Connect 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
Connect 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§
Source§impl<'d, Dm: Debug + DriverMode> Debug for I2cSlave<'d, Dm>
Available on crate feature unstable only.
impl<'d, Dm: Debug + DriverMode> Debug for I2cSlave<'d, Dm>
unstable only.