Anyone know what analogInPinToBit() macro is for?

This is defined in the official core. It is not used anywhere in the official core.

It's a very complicated definition:

#define analogInPinToBit(P) (P)

Anyone know what exactly it does? I'm trying to figure out
a) whether it is in use in the wild or if it's just litter in the files that was left there because nobody knew what it was for but I'd better leave it for compatibility
b) whether any of my cores would need a more complicated definition of this macro if so.

If nothing actually calls it, I should gun it. The only time I've seen it used, it was used like digitalPinToAnalogInput() in an older core - but that ain't what the current form of it does!..... (but there it's internal to the core)

unless I can find evidence of it being used anywhere, I'm sorely tempted to comment it out and see if anyone complains

Anyone know what exactly it does?

There is a comment just above the definition in Arduino.h

 // Get the bit location within the hardware port of the given virtual pin.
// This comes from the pins_*.c file for the active board configuration.

#define analogInPinToBit(P) (P)

probably came as a convenience macro from the old time (it’s even twice in the file) where it was possibly used in analogRead()? (Guessing)

It’s buggy too if you call it with A1 instead of 1 (for example) (and worse on a mega)

Some variant got rid of it. For example it’s commented out in ArduinoCore for SAMD, i suppose because they considered it was AVR-specific.

I guess the idea for keeping it around was that If it’s not called then it does not impact anything so who cares...

I don’t think you’ll come under flack if that goes away nor get in trouble.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.