expression

Read an I2C register with a combined transaction

A common register read writes a register selector and then reads bytes using a repeated START between directions. The device datasheet determines whether this protocol is supported. The embedded-hal transaction contract manages bus framing. The example is a symbolic trace only, not a real transaction. Expected host stdout (not executed): START + write address register selector repeated START + read address read byte STOP Common mistake: Assuming two independent write and read calls are always equivalent to a combined transaction.

Formal Syntax & Structure

rust syntaxrust
i2c.write_read(address, &[register], &mut data)

Working Example

Example Snippetrust
fn main() {    let trace = ["START + write address", "register selector", "repeated START + read address", "read byte", "STOP"];    for event in trace { println!("{event}"); }}
Rust Reference