What does the syntax imply? EXAMPLE: if(VAL << x) & BIT15))
I do not understand what is happening in this statement.
Code:
#ifdef ENABLE_TEST_POINTS//tp_write_val(u16);
// Display a value using a test point
void tp_write_val(u16 val)
{
u8 c;
PC7_LOW;
//PC7_HIGH;
nop();
nop();
nop();
PC7_LOW;
for(c=0; c<15; c++)
{
if( (val << c) & BIT15 )
PC7_HIGH;
else
PC7_LOW;
}
PC7_LOW;
//PC7_HIGH;
nop();
nop();
nop();
//PC7_LOW;
}
What is ((val << c) & BIT15) about? I am sending 15 bits of data to this function and outputting the data serially onto a scope, testing someone else's code to ensue usability (RS-232 may not always be available). I do not understand how this code is comparing each bit as as the loop iterates. BIT15 is defined as 0x8000. PC7_HIGH simply makes test point 34 a high voltage, and PC7_LOW makes it low. I know I am missing something really simple...
please and thank you!