I'm trying to understand this piece of code to address bits:
/* GPIO bits */
static bit GP5 @ (unsigned)&GPIO*8+5;
static bit GP4 @ (unsigned)&GPIO*8+4;
static bit GP3 @ (unsigned)&GPIO*8+3;
static bit GP2 @ (unsigned)&GPIO*8+2;
static bit GP1 @ (unsigned)&GPIO*8+1;
static bit GP0 @ (unsigned)&GPIO*8+0;
The GPIO is defined in this way:
static volatile unsigned char GPIO @ 0x06;
Why GPIO address is multiplied by 8 and then added by the number of the bit? What the result of this macro and how can I address the bit?
The code above is for XC8 compiler for PIC Microcontrollers. Atmel uses the same when they use the macro IOPORT_CREATE_PIN. This macro is defined as below:
#define IOPORT_CREATE_PIN(port, pin) ((IOPORT_##port)*8 + (pin))
