Function esp_idf_svc::sys::i2c_master_transmit_receive
source ยท pub unsafe extern "C" fn i2c_master_transmit_receive(
i2c_dev: *mut i2c_master_dev_t,
write_buffer: *const u8,
write_size: usize,
read_buffer: *mut u8,
read_size: usize,
xfer_timeout_ms: i32,
) -> i32
Expand description
@brief Perform a write-read transaction on the I2C bus. The transaction will be undergoing until it finishes or it reaches the timeout provided.
@note If a callback was registered with i2c_master_register_event_callbacks
, the transaction will be asynchronous, and thus, this function will return directly, without blocking.
You will get finish information from callback. Besides, data buffer should always be completely prepared when callback is registered, otherwise, the data will get corrupt.
@param[in] i2c_dev I2C master device handle that created by i2c_master_bus_add_device
.
@param[in] write_buffer Data bytes to send on the I2C bus.
@param[in] write_size Size, in bytes, of the write buffer.
@param[out] read_buffer Data bytes received from i2c bus.
@param[in] read_size Size, in bytes, of the read buffer.
@param[in] xfer_timeout_ms Wait timeout, in ms. Note: -1 means wait forever.
@return
- ESP_OK: I2C master transmit-receive success
- ESP_ERR_INVALID_ARG: I2C master transmit parameter invalid.
- ESP_ERR_TIMEOUT: Operation timeout(larger than xfer_timeout_ms) because the bus is busy or hardware crash.