I wonder if there is a nice way to get the shift that is required out of a bitmask applied to a variable without the need to define it.
Simple Example:
#define MASK 0xf0
#define SHIFT 4
uint8_t var = 0x20;
uint8_t wanted = (var & MASK) >> SHIFT;
How can I avoid using the SHIFT define but still get the same result?