Sorry to ask again... But I seem to struggle with binary... I stumbled upon the following line
MGC_SSPBUF_REG = (GESTIC_I2C_ADDR << 1) | 1; // write Address to MGC3130
Beside the fact, that don`t know, why one would shift the address to the left in order to save it, I cannot get my head around that OR operation.
Having an address ORed with "1" will always result in 1111 1111, wouldn`t it?
I am programming a Microchip PIC18F14K50 in C. While checking a code written by another company I stumbled across the following line:
if(MGC_SSPCON2_REG & 0x1F) { // MSSP not idle
...
}
Now, MGC_SSPCON2_REG is implemented as follows
#define MGC_SSPCON2_REG SSPCON2
Where SSPCON is the 8bit MSSP Control register (in I2C MODE).
What I do not understand, is how this if-condition works. Is it true when all the bits of the 8bit binary numbers are set to 1? As far as I understand, the argument is the bit wise AND operation on the 8bit register and the binary number 0001 1111 (0x1F).
I hope that I provided enough code to understand the question. I didn`t want to go to much into detail about how the register works.
Thank you in advance for your help :)