Skip to content

Commit ba5d66c

Browse files
committed
Fixed handling of Ax constants on Leonardo
Fixed mistake in assignment and handling of A6-A11 constants. Renumbered constants for all Ax channels.
1 parent 3ee847c commit ba5d66c

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

hardware/arduino/cores/arduino/wiring_analog.c

+2
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ int analogRead(uint8_t pin)
4343

4444
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)
4545
if (pin >= 54) pin -= 54; // allow for channel or pin numbers
46+
#elif defined(__AVR_ATmega32U4__)
47+
if (pin >= 18) pin -= 18; // allow for channel or pin numbers
4648
#else
4749
if (pin >= 14) pin -= 14; // allow for channel or pin numbers
4850
#endif

hardware/arduino/variants/leonardo/pins_arduino.h

+13-13
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ const static uint8_t MISO = 17;
4545
const static uint8_t SCK = 15;
4646

4747
// Mapping of analog pins as digital I/O
48-
// A6-A11 are already shared with digital pins
49-
const static uint8_t A0 = 14;
50-
const static uint8_t A1 = 15;
51-
const static uint8_t A2 = 16;
52-
const static uint8_t A3 = 17;
53-
const static uint8_t A4 = 18;
54-
const static uint8_t A5 = 19;
55-
const static uint8_t A6 = 4;
56-
const static uint8_t A7 = 6;
57-
const static uint8_t A8 = 8;
58-
const static uint8_t A9 = 9;
59-
const static uint8_t A10 = 10;
60-
const static uint8_t A11 = 12;
48+
// A6-A11 share with digital pins
49+
const static uint8_t A0 = 18;
50+
const static uint8_t A1 = 19;
51+
const static uint8_t A2 = 20;
52+
const static uint8_t A3 = 21;
53+
const static uint8_t A4 = 22;
54+
const static uint8_t A5 = 23;
55+
const static uint8_t A6 = 24; // D4
56+
const static uint8_t A7 = 25; // D6
57+
const static uint8_t A8 = 26; // D8
58+
const static uint8_t A9 = 27; // D9
59+
const static uint8_t A10 = 28; // D10
60+
const static uint8_t A11 = 29; // D12
6161

6262
// __AVR_ATmega32U4__ has an unusual mapping of pins to channels
6363
extern const uint8_t PROGMEM analog_pin_to_channel_PGM[];

0 commit comments

Comments
 (0)