pub trait I2cTargetCallbacks:
Send
+ Sync
+ 'static {
// Provided methods
fn write_requested(&self) -> Result<()> { ... }
fn write_received(&self, val: u8) -> Result<()> { ... }
fn read_requested(&self) -> Result<u8> { ... }
fn read_processed(&self) -> Result<u8> { ... }
fn stop(&self) -> Result<()> { ... }
}Expand description
Trait for I2C target callbacks.
Implement this on a type that holds your shared state. All methods receive
&self and are called from ISR context, so interior mutability must use
ISR-safe mechanisms such as SpinMutex or
atomics.
The implementing type must be Send + Sync because it is shared
between ISR callbacks and regular threads.
Provided Methods§
Sourcefn write_requested(&self) -> Result<()>
fn write_requested(&self) -> Result<()>
Called when the controller initiates a write to this target.
Sourcefn write_received(&self, val: u8) -> Result<()>
fn write_received(&self, val: u8) -> Result<()>
Called for each byte received from the controller.
Sourcefn read_requested(&self) -> Result<u8>
fn read_requested(&self) -> Result<u8>
Called when the controller initiates a read from this target.
Returns the first byte to send to the controller.
Sourcefn read_processed(&self) -> Result<u8>
fn read_processed(&self) -> Result<u8>
Called after the controller reads a byte, requesting the next.
Returns the next byte to send to the controller.