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.

Table 6-7. SPI_Read - Command
Byte IndexCommandDescription
00x28Command codeInitiates the SPI read transaction
10xAFCommand code extension byte
2L(wDatLen)Data length (lower byte)Number of data bytes. Maximum length: 65535 bytes.
3H(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
Table 6-8. SPI_Read - First Response
Byte IndexResponseDescription
00x28Return command codeReturns whether the SPI_Read command was accepted
10x22Accepted – initiatedThe command is accepted, and an SPI read is initiated
0x60Rejected – wrong parametersThe command is rejected because the parameters are invalid
0x64Rejected – SPI is busyThe command is rejected because the SPI module is busy
Table 6-9. SPI_Read - Second Response
Byte IndexResponseDescription
00x28Return command codeThe SPI read is continued
1

0x21

Read continued
2L(wDatLen)Data length (lower byte)Number of data bytes to be read (maximum 65,535 bytes)
3H(wDatLen)Data length (higher byte)
4b0(vDatPac)First data byteThe first 60 bytes are read
5b1(vDatPac)Second data byte
.........
63b59(vDatPac)The 60th data byte
Table 6-10. SPI_Read - Subsequent Response
Byte IndexResponse (Endpoint 0x86)Description
00x28Return command codeThe SPI read is continued
1

0x21

Read continued
2b60(vDatPac)The 61st Data ByteThe next 62 data bytes are read
.........
63b121(vDatPac)The 122nd Data Byte
Repeat the subsequent response sequence until all requested bytes have been received.