6.1.3 SPI_Read Command and its Response
The SPI_Read command (0x28) initiates an SPI read transaction.
The command reads wDatLen bytes of data from the SPI client device
selected by the active SPI configuration.
This command is sent through Endpoint 0x06 (OUT). The response is read through Endpoint 0x86 (IN).
If the read data length exceeds the payload capacity of a single USB packet, multiple packets are used. The first packet contains up to 60 data bytes, and each additional continuation packet contains up to 62 data bytes.
Depending on the requested read length, multiple response packets may be returned. The first data response may contain up to 60 bytes, and subsequent response packets may contain up to 62 bytes each.
| Byte Index | Command | Description | |
|---|---|---|---|
| 0 | 0x28 | Command code | Initiates the SPI read transaction |
| 1 | 0xAF | Command code extension byte | |
| 2 | L(wDatLen) | Data length (lower byte) | Number of data bytes. Maximum length: 65535 bytes. |
| 3 | H(wDatLen) | Data length (upper byte) | |
| Wait for the first response from the MCP2222 to determine whether the command is accepted | |||
| If accepted, continue reading until the required number of bytes are read | |||
| Byte Index | Response | Description | |
|---|---|---|---|
| 0 | 0x28 | Return command code | Returns whether the SPI_Read command was
accepted |
| 1 | 0x22 | Accepted – initiated | The command is accepted, and an SPI read is initiated |
0x60 | Rejected – wrong parameters | The command is rejected because the parameters are invalid | |
0x64 | Rejected – SPI is busy | The command is rejected because the SPI module is busy | |
| Byte Index | Response | Description | |
|---|---|---|---|
| 0 | 0x28 | Return command code | The SPI read is continued |
| 1 |
| Read continued | |
| 2 | L(wDatLen) | Data length (lower byte) | Number of data bytes to be read (maximum 65,535 bytes) |
| 3 | H(wDatLen) | Data length (higher byte) | |
| 4 | b0(vDatPac) | First data byte | The first 60 bytes are read |
| 5 | b1(vDatPac) | Second data byte | |
| ... | ... | ... | |
| 63 | b59(vDatPac) | The 60th data byte | |
| Byte Index | Response (Endpoint 0x86) | Description | |
|---|---|---|---|
| 0 | 0x28 | Return command code | The SPI read is continued |
| 1 |
| Read continued | |
| 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. | |||
