Hello all,
I am using a Analog Devices chip set that is programmed using three wire SPI communication (the chip doesn't talk back to the arduino, only 1 way).
I am currently using a great library to communicate with the chip. I've worked by way though the code to try and come to an understanding of what is happening, but I had a few questions I couldn't resolve myself.
Regarding the function which transmits the data:
void ADF4351::writeDev(int n, Reg r)
332 {
333 byte txbyte ;
334 int i ;
335 digitalWrite(pinSS, LOW) ;
336 delayMicroseconds(10) ;
337 i=n ; // not used
338 for ( i = 3 ; i > -1 ; i--) {
339 txbyte = (byte) (r.whole >> (i * 8)) ;
340 SPI.transfer(txbyte) ;
341 }
342
343 digitalWrite(pinSS, HIGH) ;
344 delayMicroseconds(5) ;
345 digitalWrite(pinSS, LOW) ;
346 }
Can someone explain the syntax in line 339. The goal is to transfer over the 4 bytes of data MSB first, but I don't understand how the bitshift is doing that.
Also, the actual spi.transfer command is only operating with bytes. If I plan to write to a register that isn't a multiple of 8, how would I? I guess I could write two bytes with some leading zeros?
Thanks,
Sami
Also,