1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-12-01 12:24:14 +01:00

Use analogPinToChannel if it's defined

This commit is contained in:
Kristian Sloth Lauszus 2013-04-17 19:49:40 +02:00
parent a138309ff6
commit 938351bcae

View File

@ -41,14 +41,14 @@ int analogRead(uint8_t pin)
{ {
uint8_t low, high; uint8_t low, high;
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) #if defined(analogPinToChannel)
pin = analogPinToChannel(pin);
#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
if (pin >= 54) pin -= 54; // allow for channel or pin numbers if (pin >= 54) pin -= 54; // allow for channel or pin numbers
#elif defined(__AVR_ATmega32U4__) #elif defined(__AVR_ATmega32U4__)
if (pin >= 18) pin -= 18; // allow for channel or pin numbers if (pin >= 18) pin -= 18; // allow for channel or pin numbers
#elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__) #elif defined(__AVR_ATmega1284P__) || defined(__AVR_ATmega644P__)
if (pin >= 24) pin -= 24; // allow for channel or pin numbers if (pin >= 24) pin -= 24; // allow for channel or pin numbers
#elif defined(analogPinToChannel) && (defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__))
pin = analogPinToChannel(pin);
#else #else
if (pin >= 14) pin -= 14; // allow for channel or pin numbers if (pin >= 14) pin -= 14; // allow for channel or pin numbers
#endif #endif