I have been trying to convert the shiftin program from Arduino to eclipse Java using the core processing library but I cannot seem to figure out what this BYTES_VAL_T represents. The original code comes from Playground arduino and is used for shifting in data towards the serial. Please see the code below:
#define BYTES_VAL_T unsigned int
int ploadPin = 7; // Connects to Parallel load pin the 165
int clockEnablePin = 4; // Connects to Clock Enable pin the 165
int dataPin = 3; // Connects to the Q7 pin the 165
int clockPin = 6; // Connects to the Clock pin the 165
BYTES_VAL_T pinValues;
BYTES_VAL_T oldPinValues;
/* This function is essentially a "shift-in" routine reading the
* serial Data from the shift register chips and representing
* the state of those pins in an unsigned integer (or long).
*/
BYTES_VAL_T read_shift_regs()
{
long bitVal;
BYTES_VAL_T bytesVal = 0;
/* Trigger a parallel Load to latch the state of the data lines,
*/
digitalWrite(clockEnablePin, HIGH);
digitalWrite(ploadPin, LOW);
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(ploadPin, HIGH);
digitalWrite(clockEnablePin, LOW);
/* Loop to read each bit value from the serial out line
* of the SN74HC165N.
*/
for(int i = 0; i < DATA_WIDTH; i++)
{
bitVal = digitalRead(dataPin);
/* Set the corresponding bit in bytesVal.
*/
bytesVal |= (bitVal << ((DATA_WIDTH-1) - i));
/* Pulse the Clock (rising edge shifts the next bit).
*/
digitalWrite(clockPin, HIGH);
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(clockPin, LOW);
}
return(bytesVal);
}
At first glance I thought it was a simple int variable until I saw it being applied to pinValues and oldpinValues. Can someone please explain to me how this works? How can this "BYTES_VAL_T" be intepreted in java?
If anyone understand this that would be good to know. Everything works but I'm really confused about this segment.