Synopsis
typedef struct {
unsigned address;
const unsigned char *tx;
size_t txlen;
unsigned char *rx;
size_t rxlen;
} CTL_I2C_REQUEST_t;
Description
CTL_I2C_REQUEST_t is an I/O request block for an I2C transaction.
Clients are not required to use this request block directly from
the I2C API, but I2C drivers are required to implement I/O
requests according to the block's members:
-
Write-Read request: If both tx and rx are non-null,
the I/O request first writes the slave address and data specified
by tx and txlen to the bus, issues a repeated start, and
reads rxlen bytes from the bus into rx, and finally issues a
stop.
-
Write request: If tx is non-null and rx is null, the
I/O request writes the slave address and data specified by
tx and txlen to the bus, and then issues a stop.
-
Read request: If tx is null and rx is non-null, the
I/O request writes the slave address to the bus, reads
rxlen bytes from the bus to rx, and issues a stop.
Structure
-
address
- 8-bit address for the I/O request. The low order bit is
undefined when passed to the low-level I2C driver, and the
I2C driver must correctly set or reset the R/W bit according
to the request phase.
-
tx
- A pointer to the data to write to the bus after the slave
address is transmitted. If tx is zero, the driver must
skip the write part of the I/O request.
-
txlen
- The number of bytes to transfer as payload in the write part
of the I/O request.
-
rx
- A pointer to the data to read from the bus after the slave
address is transmitted. If rx is zero, the driver must
skip the read part of the I/O request.
-
rxlen
- The number of bytes to transfer as payload in the read part
of the I/O request.