From d0b0f3e45d5c4cf3a7fbcf5832c5e6cc764016e0 Mon Sep 17 00:00:00 2001 From: Zach Eveland Date: Tue, 13 Sep 2011 23:52:26 -0400 Subject: fixed analog pin mapping for 32u4 --- variants/leonardo/pins_arduino.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'variants/leonardo') diff --git a/variants/leonardo/pins_arduino.h b/variants/leonardo/pins_arduino.h index 6fc3ea9..65ab5e2 100644 --- a/variants/leonardo/pins_arduino.h +++ b/variants/leonardo/pins_arduino.h @@ -48,6 +48,10 @@ const static uint8_t A5 = 19; const static uint8_t A6 = 20; const static uint8_t A7 = 21; +// __AVR_ATmega32U4__ has an unusual mapping of pins to channels +extern const uint8_t PROGMEM analog_pin_to_channel_PGM[]; +#define analogPinToChannel(P) ( pgm_read_byte( analog_pin_to_channel_PGM + (P) ) ) + #ifdef ARDUINO_MAIN // On the Arduino board, digital pins are also used @@ -228,6 +232,35 @@ const uint8_t PROGMEM digital_pin_to_timer_PGM[18] = { NOT_ON_TIMER, }; +const uint8_t PROGMEM analog_pin_to_channel_PGM[11] = { + /* + A0 PF7 ADC7 + A1 PF6 ADC6 + A2 PF5 ADC5 + A3 PF4 ADC4 + A4 PF1 ADC1 + A5 PF0 ADC0 + D4 A6 PD4 ADC8 + D5 A7 PD6 FastPWM OC4D/ADC9 + D6 A8 PD7 FastPWM #OC4D/ADC10 + D9 A9 PB5 PWM16 OC1A/#OC4B/ADC13/PCINT5 + D10 A10 PB6 PWM16 OC1B/0c4B/ADC12/PCINT6 + */ + + 7, + 6, + 5, + 4, + 1, + 0, + 8, + 9, + + 10, + 13, + 12 +}; + #endif #endif \ No newline at end of file -- cgit v1.2.3-18-g5258