Bitwise Operations

Set Bit

#define MASK(x) (1<<(x))
//Set bit 31 and 3
result |= (MASK(31)|MASK(3));

Clear Bit

#define MASK(x) (1<<(x))
//Clear bit 31 and 3
result &= ~(MASK(31)|MASK(3));

Read Bit

#define MASK(x) (1<<(x))
//Read bit 4
result = ((readVariable >> 4u) & 1u);

Invert Bit

#define MASK(x) (1<<(x))
//Clear bit 31 and 3
result ^= (MASK(31)|MASK(3));