6.1 SPI Interface Commands and Their Responses

The MCP2222 supports SPI functionality through the vendor class, providing commands that allow the USB host to configure the SPI module, write data to an SPI client device, read data from an SPI client device, and perform full-duplex write-and-read transactions.

The following endpoints are used for SPI communication:
  • Endpoint 0x06 (OUT) — Used to send SPI commands and transmit SPI data
  • Endpoint 0x86 (IN) — Used to read SPI command responses and received SPI data
Table 6-1. Supported SPI Interface Commands
CommandDescription
SPI_Config

Configures the SPI module with:

1. A specified clock speed.

2. A specified SPI mode.

3. The specified chip-select set to idle state.

4. Transaction delays between:

  • Chip-select assertion and the first data byte
  • Two consecutive data bytes
  • The last data byte and chip-select deassertion
SPI_Write

Asserts the configured chip-select, applies the configured delay, writes “wDatLen” bytes of “vDatPac” to the SPI client device, and then de-asserts the chip-select after the configured delay

SPI_Read

Asserts the configured chip-select, applies the configured delay, reads “wDatLen” bytes of data from the SPI client device, and then de-asserts the chip-select after the configured delay

SPI_Exchange

Performs a full-duplex SPI transaction by writing wDatLen bytes from vDatPac while simultaneously reading wDatLen bytes from the SPI client device