# _embedded_hal_blocking_i2c_WriteRead in k210_hal::prelude - Rust
Blocking write + read
Keywords: rust, rustlang, rust-lang, _embedded_hal_blocking_i2c_WriteRead

# Trait k210_hal::prelude::_embedded_hal_blocking_i2c_WriteRead

source · [−]

    pub trait _embedded_hal_blocking_i2c_WriteRead {
        type Error;
        fn try_write_read(
            &mut self,
            address: u8,
            bytes: &[u8],
            buffer: &mut [u8]
        ) -> Result<(), Self::Error>;
    }

Expand description

Blocking write + read

## Associated Types

source

#### type Error

Error type

## Required methods

source

#### fn try_write_read(
&mut self,
address: u8,
bytes: &[ u8 ],
buffer: &mut [ u8 ]
) -> Result<(), Self::Error>

Sends bytes to slave with address `addr` and then reads enough bytes to fill `buffer` in a single transaction

##### I2C Events (contract)

    Master: ST SAD+W     O0     O1     ... OM     SR SAD+R        MAK    MAK ...    NMAK SP
    Slave:           SAK    SAK    SAK ...    SAK          SAK I0     I1     ... IN

Where

- `ST` = start condition
- `SAD+W` = slave address followed by bit 0 to indicate writing
- `SAK` = slave acknowledge
- `Oi` = ith outgoing byte of data
- `SR` = repeated start condition
- `SAD+R` = slave address followed by bit 1 to indicate reading
- `Ii` = ith incoming byte of data
- `MAK` = master acknowledge
- `NMAK` = master no acknowledge
- `SP` = stop condition

## Implementors