I have been working with SPI for a while but honestly never had to write code for a slave. The prediction bytes are confusing me, how does this work?
For example, I'm copping a well known PlayStation protocol. An example.
Command in this case is the master
Data is the slave.
The first thing I need to do is read what the master is sending so ill just send a FF to kick things off. Spi_read( 0xff);
So far so good. Now I need the next byte but I'm expected to know if I get a 42 or a 41 before I send my 79 or 41?
How does that work? There is no way for me to know if I'm going to get a 41 or a 42 so I can not send the 79 vs 41.
Correct me if I'm wrong here but SPI typically is bidirectional and you always send a byte when you read a byte. I get why the first byte is always a FF because we do not know what the master will send back. but if the master always sends a 1 as the first bute, I can not predict the next byte to send?
In working on the master, I never cared what the slave sent unless I needed to. So I just send my data 1,2,3,4... and read whatever I needed. With a slave it's more difficult because I need to listed to commands. These commands will get certain data based on the command. So this second byte being the command confused me as I need to send data before I know the command.