DLPU057A March 2018 – April 2022
All the commands are sent as packets. Only the Master can initiate a packet transaction. A command packet consists of START_CHARACTER, 2 byte header (command byte, Length), variable data payload and a checksum byte. These are explained in the subsections below.
The SPI Packet structure sent by the Master is shown in Figure 1-3.
Byte 0 | Byte 1 | Byte 2 | Byte 3 | … | Byte n+2 | Byte n+3 |
START CHARACTER | Command Byte | Length(n) | Data[1] | … | Data[n] | Checksum |
In Figure 1-3, n stands for number of bytes of Data for the command being transmitted. For example, a backlight command (see Section 3.2.1) will have the following structure:
Byte 1 | Byte 2 | Byte 3 | Byte 4 | Byte 5 |
Command Byte = 00 | n = 2 | Data[1] = FF | Data[2] = FF | Checksum = 00 |
The slave will keep sending dummy bytes (0xFF) back to the master for each byte of the command packet. Once the command packet is completely received, the slave prepares a response byte after validating the checksum and the length byte. To receive the response byte, the master should keep sending dummy bytes to the slave till it receives a non-0xFF byte from slave. The first non-0xFF byte from slave will be the response byte.
For a read command the read data follows the response byte and has the structure shown in Figure 1-6, where,
k – This is the time (in bytes) needed by the slave to respond to the master’s request.
m – The number of data bytes returned by the slave. This is also called length and is transmitted as byte k+1.
The number of bytes from k transmitted by slave can vary from minimum of 1 byte (response byte only – in case of write commands, failed read commands) up to 258 (255 data bytes + Response + Length + Checksum) depending on the read command (unless master aborts the command).
Byte k-2 | Byte k-1 | Byte k | Byte k+1 | Byte k+2 | … | Byte k+m+1 | Byte k+m+2 |
0xFF | 0xFF | Response Byte | Length(m) | Data[1] | … | Data[m] | Checksum |
As an example, the slave response to a backlight read command (see Section 3.2.3) is given below:
Byte k | Byte k+1 | Byte k+2 | Byte k+3 | Byte k+4 |
Response Byte = 01 | m = 2 | Data[0] = FF | Data[1] = FF | Checksum = 01 |