I am trying to implement the Arduino style _BV() macro for a different microcontroller using C programming. When used with a pin number it returns the bit mask associated with the bit.
#define _BV(bit) (1UL << (bit))
E.g:- _BV(PF0) gives (1 << PF0)
But the problem comes when defining the bitfields. If I start defining each bit position using symbolic constants it will end up repeating a lot of code as shown below
I tried checking the AVR implementation for the same from the following link
It is implemented in C++. Is there any efficient way of solving this problem in C?