Gammon Forum : Electronics : Microprocessors : SPI - Serial Peripheral Interface - for Arduino
Brilliant, cheers. So, reading the text under heading "sending & receiving data", because the appropriate data is sent back is sent back at the same time as the data going out, let's check I understand this right.
SPI.transfer (4) would send the value of 4, of course - and writing an a = SPI.transfer(4) would capture the data returned as a result of sending a value of 4 out over SPI?
a = SPI.transfer (4);
// a is now 1
b = SPI.transfer (3);
// b is now 2
If I send my data as two binary bytes, as below for example, the data I then capture back using the above method, does that come back and save as a binary byte? I've added two entries in to my code to declare bytes to save the contents of the registers.
byte ident_reg_contents = B00000000;
byte diag_reg_contents = B00000000;
SPI.transfer(B01111000);
diag_reg_contents = SPI.transfer(B00000000);
If it doesn't, give up
That somewhat defeats the point of learning to interface with the SPI bus....