Skip to content

Commit 8f8688b

Browse files
committed
Use analogPinToChannel() macro if present for ATtiny25/45/85.
This allows use of A0, A1, A2, A3 constants and for them to be mapped to the appropriate analog input channel. It should only be used if the macro is actually defined.
1 parent 862a273 commit 8f8688b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

arduino/cores/arduino/wiring_analog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ int analogRead(uint8_t pin)
4747
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
4848
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
4949
if (pin >= 24) pin -= 24; // allow for channel or pin numbers
50+
#elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
51+
pin = analogPinToChannel(pin);
5052
#else
5153
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
5254
#endif

0 commit comments

Comments
 (0)