pub struct I2cTarget<'d, M: Mode> { /* private fields */ }Expand description
I2C Target driver.
Implementations§
Source§impl<'d> I2cTarget<'d, Async>
impl<'d> I2cTarget<'d, Async>
Sourcepub fn new<T: Instance>(
peri: Peri<'d, T>,
scl: Peri<'d, impl SclPin<T>>,
sda: Peri<'d, impl SdaPin<T>>,
_irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd,
config: Config,
target_config: Config,
) -> Result<Self, ConfigError>
pub fn new<T: Instance>( peri: Peri<'d, T>, scl: Peri<'d, impl SclPin<T>>, sda: Peri<'d, impl SdaPin<T>>, _irq: impl Binding<T::Interrupt, InterruptHandler<T>> + 'd, config: Config, target_config: Config, ) -> Result<Self, ConfigError>
Create a new asynchronous I2C target driver using interrupts
The config reuses the i2c controller config to setup the clock while target_config
configures i2c target specific parameters.
Sourcepub fn reset(&mut self) -> Result<(), ConfigError>
pub fn reset(&mut self) -> Result<(), ConfigError>
Reset the i2c peripheral. If you cancel a respond_to_read, you may stall the bus. You can recover the bus by calling this function, but doing so will almost certainly cause an i/o error in the controller.
Source§impl<'d> I2cTarget<'d, Blocking>
impl<'d> I2cTarget<'d, Blocking>
Sourcepub fn new_blocking<T: Instance>(
peri: Peri<'d, T>,
scl: Peri<'d, impl SclPin<T>>,
sda: Peri<'d, impl SdaPin<T>>,
config: Config,
target_config: Config,
) -> Result<Self, ConfigError>
pub fn new_blocking<T: Instance>( peri: Peri<'d, T>, scl: Peri<'d, impl SclPin<T>>, sda: Peri<'d, impl SdaPin<T>>, config: Config, target_config: Config, ) -> Result<Self, ConfigError>
Create a new blocking I2C target driver.
The config reuses the i2c controller config to setup the clock while target_config
configures i2c target specific parameters.
Sourcepub fn reset(&mut self) -> Result<(), ConfigError>
pub fn reset(&mut self) -> Result<(), ConfigError>
Reset the i2c peripheral. If you cancel a respond_to_read, you may stall the bus. You can recover the bus by calling this function, but doing so will almost certainly cause an i/o error in the controller.
Source§impl<'d, M: Mode> I2cTarget<'d, M>
impl<'d, M: Mode> I2cTarget<'d, M>
Sourcepub fn flush_tx_fifo(&mut self)
pub fn flush_tx_fifo(&mut self)
Blocking function to empty the tx fifo
This function can be used to empty the transmit FIFO if data remains after handling a ‘read’ command (LeftoverBytes).
Source§impl<'d> I2cTarget<'d, Async>
impl<'d> I2cTarget<'d, Async>
Sourcepub async fn listen(&mut self, buffer: &mut [u8]) -> Result<Command, Error>
pub async fn listen(&mut self, buffer: &mut [u8]) -> Result<Command, Error>
Wait asynchronously for commands from an I2C controller.
buffer is provided in case controller does a ‘write’, ‘write read’, or ‘general call’ and is unused for ‘read’.
Sourcepub async fn respond_to_read(
&mut self,
buffer: &[u8],
) -> Result<ReadStatus, Error>
pub async fn respond_to_read( &mut self, buffer: &[u8], ) -> Result<ReadStatus, Error>
Respond to an I2C controller ‘read’ command, asynchronously.
Sourcepub async fn respond_till_stop(&mut self, fill: u8) -> Result<(), Error>
pub async fn respond_till_stop(&mut self, fill: u8) -> Result<(), Error>
Respond to reads with the fill byte until the controller stops asking
Sourcepub async fn respond_and_fill(
&mut self,
buffer: &[u8],
fill: u8,
) -> Result<ReadStatus, Error>
pub async fn respond_and_fill( &mut self, buffer: &[u8], fill: u8, ) -> Result<ReadStatus, Error>
Respond to a controller read, then fill any remaining read bytes with fill
Trait Implementations§
Source§impl<'d> SetConfig for I2cTarget<'d, Async>
impl<'d> SetConfig for I2cTarget<'d, Async>
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config fails.Source§fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
fn set_config(&mut self, config: &Self::Config) -> Result<(), Self::ConfigError>
Source§impl<'d> SetConfig for I2cTarget<'d, Blocking>
impl<'d> SetConfig for I2cTarget<'d, Blocking>
Source§type ConfigError = ConfigError
type ConfigError = ConfigError
set_config fails.