#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit)) and its argument bitvalue is not enclosed in parentheses. This gives incorrect result for some arguments, ...
This produces unexpected problems when the a ternary operator is used within the bitvalue argument. Adding a set of parens around the use of the bitvalue argument would fix the issue. There was an ...