My AD5292 Digital pot takes a 16 bit command via SPI. First should be 6 bits for the command, and 10 bits for the data. It is a 1024 step pot, so it requires 10 bits for the data.
The SPI library sends 8 bits at a time. So I have to come up with some way to combine the command and the data into one value, then split that value into two parts to transfer one at a time.
So if the command bit is 001010 and the data bits are 1010101010 I need to combine them so that I get 0010101010101010, then break that up into 00101010 and 10101010.
The first value would be 42 in decimal. The second value would be 170.
So then I would use the SPI transfer function:
My problem is trying to come up with a way to combine and then split the result into two 8 bit commands.
I think I could build an array and then extract bits back out of it, but I'm not sure how to do that. I'm looking for ideas.