5.1.3 I2C_Read Command and its Response
The I2C_Read command (0x48) initiates an I2C read
transaction. The command reads wRdDtLen bytes of data from the
I2C client device addressed by bAddress.
This command is sent through Endpoint 0x03 (OUT) and the response is read through Endpoint 0x83 (IN).
Depending on the requested read length, multiple response packets may be returned. The first response may contain up to 60 data bytes and subsequent response packets may contain up to 62 data bytes each.
| SI. No. | Byte Index | Command | Description | |
|---|---|---|---|---|
| 1 | 0 | 0x48 | Command code | Initiates the I2C read transaction |
| 2 | 1 | bAddress | I2C client address | 7-bit I2C client address |
| 3 | 2 | L(wRdDtLen) | Read data length (lower byte) | Number of data bytes; maximum length 65535 bytes |
| 4 | 3 | H(wRdDtLen) | Read data length (upper byte) | |
| 5 | Wait for the first response from the MCP2222 to determine whether the command is accepted | |||
| 6 | If accepted, continue reading until the required number of bytes are read or until a failure occurs. | |||
| Byte Index | First Response | Description | |
|---|---|---|---|
| 0 | 0x48 | Return command code | Returns whether the I2C_Read command was
accepted. |
| 1 |
|
Accepted – initiated Rejected – wrong parameters Rejected – I2C is busy |
The command is accepted and the read transaction is initiated. The command is rejected because the parameters are invalid. The command is rejected because the I2C module is busy. |
| Byte Index | Second Response | Description | |
|---|---|---|---|
| 0 | 0x48 | Return command code | The I2C read is continued. |
| 1 | 0x21 | Read is continued | |
0x80 | Failure - address NACK | An address NACK was received. Verify the I2C client address. | |
0x88 | Failure - clock-stretch timeout | A clock-stretch timeout occurred. Recover the bus and retry, if required. | |
0x8C | Failure - arbitration lost | Bus arbitration was lost; another I2C host may be using the bus. | |
0x90 | Failure - an I2C bus error occurred | A bus error occurred. | |
| 2 | L(wRdDtLen) | Data length (lower byte) | Number of data bytes to be read (maximum 65,535 bytes). |
| 3 | H(wRdDtLen) | Data length (higher byte) | |
| 4 | b0(vDatPac) | First data byte | The first 60 data bytes are read |
| 5 | b1(vDatPac) | Second data byte | |
| … | ... | ... | |
| 63 | b59(vDatPac) | The 60th data byte | |
| Byte Index | Subsequent Responses | Description | |
|---|---|---|---|
| 0 | 0x48 | Return command code | The I2C_Read is continued |
| 1 | 0x21 | Read is continued | |
0x88 | Failure - clock-stretch timeout | A clock-stretch timeout occurred. Recover the bus and retry, if required. | |
0x8C | Failure - arbitration lost | Bus arbitration was lost | |
0x90 | Failure - an I2C bus error occurred | A bus error occurred | |
| 2 | b60(vDatPac) | The 61st data byte | The next 62 data bytes are read |
| … | … | ... | |
| 63 | b121(vDatPac) | The 122nd data byte | |
| Repeat the subsequent response sequence until all requested bytes have been received or an error occurs. | |||
