|
27 | 27 | #include "timers.h" |
28 | 28 |
|
29 | 29 | #define NUM_DIGITAL_PINS 22 // (14 on digital headers + 8 on analog headers) |
30 | | -#define NUM_ANALOG_INPUTS 8 |
| 30 | +#define NUM_ANALOG_INPUTS 14 |
31 | 31 | #define NUM_RESERVED_PINS 6 // (TOSC1/2, VREF, RESET, DEBUG USART Rx/Tx) |
32 | 32 | #define NUM_INTERNALLY_USED_PINS 10 // (2 x Chip select + 2 x UART + 4 x IO + LED_BUILTIN + 1 unused pin) |
33 | 33 | #define NUM_I2C_PINS 2 // (SDA / SCL) |
34 | 34 | #define NUM_SPI_PINS 3 // (MISO / MOSI / SCK) |
35 | 35 | #define NUM_TOTAL_FREE_PINS (NUM_DIGITAL_PINS) |
36 | 36 | #define NUM_TOTAL_PINS (NUM_DIGITAL_PINS + NUM_RESERVED_PINS + NUM_INTERNALLY_USED_PINS + NUM_I2C_PINS + NUM_SPI_PINS) |
37 | 37 | #define ANALOG_INPUT_OFFSET 14 |
38 | | -#define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? (p) : (p) - ANALOG_INPUT_OFFSET) |
39 | 38 |
|
40 | 39 | #define EXTERNAL_NUM_INTERRUPTS 48 |
41 | 40 |
|
@@ -90,14 +89,14 @@ static const uint8_t SCL = PIN_WIRE_SCL; |
90 | 89 |
|
91 | 90 | #define LED_BUILTIN (13) |
92 | 91 |
|
93 | | -#define PIN_A0 (17) |
94 | | -#define PIN_A1 (16) |
95 | | -#define PIN_A2 (15) |
96 | | -#define PIN_A3 (14) |
97 | | -#define PIN_A4 (26) // PF2 / AIN12 |
98 | | -#define PIN_A5 (27) // PF3 / AIN13 |
99 | | -#define PIN_A6 (18) |
100 | | -#define PIN_A7 (19) |
| 92 | +#define PIN_A0 (0) // AIN3 |
| 93 | +#define PIN_A1 (1) // AIN2 |
| 94 | +#define PIN_A2 (2) // AIN1 |
| 95 | +#define PIN_A3 (3) // AIN0 |
| 96 | +#define PIN_A4 (4) // PF2 / AIN12 |
| 97 | +#define PIN_A5 (5) // PF3 / AIN13 |
| 98 | +#define PIN_A6 (6) // AIN5 |
| 99 | +#define PIN_A7 (7) // AIN4 |
101 | 100 |
|
102 | 101 | static const uint8_t A0 = PIN_A0; |
103 | 102 | static const uint8_t A1 = PIN_A1; |
@@ -321,9 +320,22 @@ const uint8_t PROGMEM digital_pin_to_timer[] = { |
321 | 320 | NOT_ON_TIMER // 40 PF6 RESET |
322 | 321 | }; |
323 | 322 |
|
| 323 | +const uint8_t PROGMEM analog_pin_to_channel[] = { |
| 324 | + 3, |
| 325 | + 2, |
| 326 | + 1, |
| 327 | + 0, |
| 328 | + 12, |
| 329 | + 13, |
| 330 | + 5, |
| 331 | + 4 |
| 332 | +}; |
324 | 333 |
|
325 | 334 | #endif |
326 | 335 |
|
| 336 | +extern const uint8_t analog_pin_to_channel[]; |
| 337 | +#define digitalPinToAnalogInput(p) ((p < NUM_ANALOG_INPUTS) ? pgm_read_byte(analog_pin_to_channel + p) : NOT_A_PIN ) |
| 338 | + |
327 | 339 | // These serial port names are intended to allow libraries and architecture-neutral |
328 | 340 | // sketches to automatically default to the correct port name for a particular type |
329 | 341 | // of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN, |
|
0 commit comments