arduino / arduino/ArduinoCore-avr

A6, A7, PIN_A6, PIN_A7 exist when there are not 8 analog pins

Open
#141 6 comments 0 reactions 0 assignees View on GitHub
Dominant language
C
Stars
1.5k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

The standard variant always creates the defines PIN_A6 and PIN_A7 and the constants A6 and A7 even when there are not 8 analog inputs.

The variant eightanaloginputs exists to declare that the h/w as 8 analog inputs so why not use that in the standard variant to disable the extra two inputs when they don't exist.
It only requires a slight tweaking of the files.

i.e.
In eightanalog inputs pins_arduino.h

```
#define NUM_ANALOG_INPUTS 8
#include "../standard/pins_arduino.h"
```

And in the standard pins_arduino.h

```
// assume 6 analog inputs if not told 8 by another variant file including this file
#ifndef NUM_ANALOG_INPUTS
#define NUM_ANALOG_INPUTS 6
#endif

// define additional symbols when there are 8 analog iputs
#if (NUM_ANALOG_INPUTS == 8)
#define PIN_A6 (20)
#define PIN A7 (21)
static const uint8_t A6 = PIN_A6;
static const uint8_t A7 = PIN_A7;
#endif
```

That way they only exist when they should and sketch could actually use something like
`# ifdef PIN_A6`

to determine if there is an analog pin A6 or not.
Same for A7

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the standard and eightanaloginputs pins_arduino.h files and compare how NUM_ANALOG_INPUTS is defined and consumed. Confirm that the standard variant exposes only A0–A5 while the eightanaloginputs variant exposes A6 and A7 as well. Done means sketches can use PIN_A6 or PIN_A7 conditionally without those symbols existing on six-input hardware.

Written by the indexing model from the issue text.

Assessment

Tech stack
c
Domain
embedded-iot
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.