The following code is from a PIC microcontroller header file, but I assume it's plain old C. I understand that the code is to be used for accessing individual bits at an address in memory, but as a C novice, I'd like some help in understanding what is going on here, and how I'd go about using it in my code to set or get bits from ADCON1.
volatile unsigned char ADCON1 @ 0x09F;
volatile bit VCFG0 @ ((unsigned)&ADCON1*8)+4;
volatile bit VCFG1 @ ((unsigned)&ADCON1*8)+5;
volatile bit ADFM @ ((unsigned)&ADCON1*8)+7;
volatile union {
struct {
unsigned : 4;
unsigned VCFG0 : 1;
unsigned VCFG1 : 1;
unsigned : 1;
unsigned ADFM : 1;
};
} ADCON1bits @ 0x09F;
tagged to C and C++. Let me know if it's not C++ compatible code, and I'll remove the tag