I'm looking for an efficient (preferably macro) way to extract the position of a bit and save it as a value in C.
data = 0x4000
would produce:
pos = 14
There is only going to be one bit set in the 16-bit register I'm reading. Currently, I'm just comparing the data to bit shifted values to extract the position, but there's gotta be a better way I don't know about.
I spent some time searching through here for a similar question and couldn't find one.