6.1.1 SPI_Config Command and its Response
The SPI_Config command (0x20) configures the SPI peripheral
with the specified clock speed, SPI mode, chip-select and its active state, and the
delays between chip-select assertion and the first data byte between the data bytes, and
between the last data byte and de-assertion of the chip-select.
This command is sent through Endpoint 0x06 (OUT). The response is read through Endpoint 0x86 (IN).
| Byte Index | Command | Description | |
|---|---|---|---|
| 0 | 0x20 | Command code | Configures the SPI module |
| 1 |
|
Speed: 12 MHz 6 MHz 3 MHz 1.5 MHz 750 kHz 375 kHz 187.5 kHz | SPI clock speed |
| 2 |
|
Mode: 0 1 2 3 | SPI mode |
| 3 |
|
CS-ActStat: CS0 active low CS0 active high CS1 active low CS1 aActive high CS2 active low CS2 active high CS3 active low CS3 active high | Chip-select and its assertion state |
| 4-5 |
|
Delay: 0 μs 10 μs 20 μs ... 1000 μs ... 5000 μs |
Delay between:
|
| Byte Index | Response | Description | |
|---|---|---|---|
| 0 | 0x20 | Return command code | Returns whether the SPI_Config command code was
accepted |
| 1 | 0x20 | Accepted - success | The command is accepted |
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 | |
0x6C | Rejected – wrong CS pin | The command is rejected because the selected chip-select pin is not configured as a CS function. Configure the corresponding I/O pin as a chip-select pin and resend the command. | |
