| Online Development Notebook > Index > ODN > Raw Device Programming > 15 - SPIMasterCmd |
Command #15 - SPIMasterCmd
Description:
This command is used to communicate with a slave SPI device. Zero to six bytes can be transferred in a single command. For each byte sent to a SPI slave device, a byte is returned. The returned bytes are in the response to the command
Command Format:
| Byte Number | Description |
| 0 | 15h: SPIMasterCmd |
| 1 | Number of Bytes (0-6) |
| 2 | Byte Data |
| 3 | Byte Data |
| 4 | Byte Data |
| 5 | Byte Data |
| 6 | Byte Data |
| 7 | Byte Data |
Command Format Details:
Byte 0 contains the command. Byte 1 contains the number of bytes to send. The number of bytes can 0 to 6. Byte 2 through byte 7 are the transmitted bytes.
Response Format:
| Byte Number | Description |
| 0 | 15h: SPIMasterCmd |
| 1 | Number of Bytes (0-6) |
| 2 | Byte Data |
| 3 | Byte Data |
| 4 | Byte Data |
| 5 | Byte Data |
| 6 | Byte Data |
| 7 | Byte Data |
Response Format Details:
Byte 0 contains the command. Byte 1 contains the number of bytes received (sent). Byte 0 through byte 7 contain the received data.
Example Usage:
When the InitSPICmd command sets the SPI subsystem to be a master, only the SPI lines SCK, MISO, and MOSI are configured. A SPI device needs to be addressed with a slave select signal. Any remaining line of the U401 can be set to be an output that controls the slave device SS input.
The slave must be selected prior to issuing the SPIMasterCmd command and deselected afterward.
Issuing 15-01-55-00-00-00-00-00 will shift a single byte (55h) out the SPI port.
| Hardware: U401 USB Interface U421 USB Interface |
| Programming: USBm DLL Programming Download Files |
| Application Notes: U4x1 Application Notes Misc Applications and Information FAQ |