I2cTargetCallbacks

Trait I2cTargetCallbacks 

Source
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§

Source

fn write_requested(&self) -> Result<()>

Called when the controller initiates a write to this target.

Source

fn write_received(&self, val: u8) -> Result<()>

Called for each byte received from the controller.

Source

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.

Source

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.

Source

fn stop(&self) -> Result<()>

Called when a STOP condition is detected.

Implementors§