Skip to content

Commit cf1d84a

Browse files
authored
Merge pull request stm32duino#214 from fpistm/Analog_hardening
Avoid to have first analog pin value (A0) lesser than NUM_ANALOG_INPUTS
2 parents 224a11e + 0cfe280 commit cf1d84a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

Diff for: cores/arduino/pins_arduino.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ enum {
5050
// Arduino analog pins
5151
// Analog pins must be contiguous to be able to loop on each value
5252
#define MAX_ANALOG_INPUTS 20
53-
_Static_assert(NUM_ANALOG_INPUTS <= MAX_ANALOG_INPUTS, "Core NUM_ANALOG_INPUTS limited to MAX_ANALOG_INPUTS" );
53+
_Static_assert(NUM_ANALOG_INPUTS <= MAX_ANALOG_INPUTS,
54+
"Core NUM_ANALOG_INPUTS limited to MAX_ANALOG_INPUTS" );
55+
_Static_assert(NUM_ANALOG_FIRST >= NUM_ANALOG_INPUTS,
56+
"First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS" );
5457

5558
// Defined for backward compatibility with Firmata which unfortunately use it
5659
#define AEND (NUM_ANALOG_FIRST+NUM_ANALOG_INPUTS)

Diff for: variants/board_template/variant.h

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ enum {
7575
// !!!
7676
#define NUM_ANALOG_INPUTS 0
7777
// Define digital pin number of the first analog input (i.e. which digital pin is A0)
78+
// First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS
7879
#define NUM_ANALOG_FIRST 0
7980

8081
// Below ADC, DAC and PWM definitions already done in the core

0 commit comments

Comments
 (0)