I am designing my own serial communication for a hardware circuit that takes 16 bits of data serially. (Think Aircore Gauges)
Outputs I need: CLOCK, CHIPSELECT, DATA (this requirement negates using any of the built-in serial libraries)
CLOCK and CHIPSELECT are easy-shmeazy. DATA, not so much (Yet)
I have an Integer I need to send to this device.
Let's use an INT of 20. (or 0b0000000000010100)
I have a loop that executes 16 times, I need to Bitwise AND to build my DATA stream:
My LOOP uses an interim INT value that increments from 1 thru 16, then back to 1 when it is finished.
My question is: How can I test each individual bit in the INT I want to send to see if it's a 1 or 0 and then set my DATA line accordingly?
on CLK 1: DATA = 0 on CLK 2: DATA = 0 on CLK 3: DATA = 1 on CLK 4: DATA = 0 on CLK 5: DATA = 1 on CLK 6: DATA = 0