@@ -51,12 +51,9 @@ enum {
5151};
5252
5353// Arduino analog pins
54- #ifndef NUM_ANALOG_INPUTS
55- #define NUM_ANALOG_INPUTS 0
56- #endif
57- #ifndef NUM_ANALOG_FIRST
58- #define NUM_ANALOG_FIRST NUM_DIGITAL_PINS
59- #endif
54+ // If NUM_ANALOG_INPUTS is not defined there is no analog pins defined.
55+ // Anyway ADC internal channels are always avaialable.
56+ #if defined(NUM_ANALOG_INPUTS ) && (NUM_ANALOG_INPUTS > 0 )
6057
6158// Analog pins must be contiguous to be able to loop on each value
6259#define MAX_ANALOG_INPUTS 24
@@ -161,6 +158,11 @@ static const uint8_t A22 = PIN_A22;
161158#define PIN_A23 (PIN_A22 + 1)
162159static const uint8_t A23 = PIN_A23 ;
163160#endif
161+ #else
162+ #ifndef NUM_ANALOG_INPUTS
163+ #define NUM_ANALOG_INPUTS 0
164+ #endif
165+ #endif /* NUM_ANALOG_INPUTS */
164166
165167// Default for Arduino connector compatibility
166168// SPI Definitions
@@ -238,6 +240,7 @@ uint32_t pinNametoDigitalPin(PinName p);
238240// Used by analogRead api to have A0 == 0
239241#define analogInputToDigitalPin (p ) (((uint32_t)p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
240242#else
243+ // No analog pin defined
241244#define analogInputToDigitalPin (p ) (NUM_DIGITAL_PINS)
242245#endif
243246// Convert an analog pin number Axx to a PinName PX_n
0 commit comments