@@ -30,9 +30,6 @@ _Static_assert(LastPort <= 0x0F, "PortName must be less than 16");
30
30
31
31
_Static_assert (NUM_ANALOG_INPUTS <= MAX_ANALOG_INPUTS ,
32
32
"Core NUM_ANALOG_INPUTS limited to MAX_ANALOG_INPUTS" );
33
- /* Analog pins must be contiguous to be able to loop on each value */
34
- _Static_assert (NUM_ANALOG_FIRST >= NUM_ANALOG_INPUTS ,
35
- "First analog pin value (A0) must be greater than or equal to NUM_ANALOG_INPUTS" );
36
33
37
34
/* Default for Arduino connector compatibility */
38
35
/* SPI Definitions */
@@ -86,34 +83,29 @@ extern const uint32_t analogInputPin[];
86
83
#define NOT_AN_INTERRUPT (uint32_t)NC
87
84
88
85
/* Convert a digital pin number Dxx to a PinName PX_n */
86
+ #if NUM_ANALOG_INPUTS > 0
89
87
/* Note: Analog pin is also a digital pin */
90
- #ifndef NUM_ANALOG_LAST
91
- #define digitalPinToPinName (p ) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC)
92
- #else
93
88
#define digitalPinToPinName (p ) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : \
94
89
((uint32_t)p >= NUM_ANALOG_FIRST) && ((uint32_t)p <= NUM_ANALOG_LAST) ? \
95
90
digitalPin[analogInputPin[p-NUM_ANALOG_FIRST]] : NC)
96
- #endif
91
+ #else
92
+ #define digitalPinToPinName (p ) (((uint32_t)p < NUM_DIGITAL_PINS) ? digitalPin[p] : NC)
93
+ #endif /* NUM_ANALOG_INPUTS > 0 */
97
94
/* Convert a PinName PX_n to a digital pin number */
98
95
uint32_t pinNametoDigitalPin (PinName p );
99
96
100
97
/* Convert an analog pin number to a digital pin number */
101
98
#if NUM_ANALOG_INPUTS > 0
102
99
/* Used by analogRead api to have A0 == 0 */
103
- /* For contiguous analog pins definition in digitalPin array */
104
- #ifndef NUM_ANALOG_LAST
105
- #define analogInputToDigitalPin (p ) (((uint32_t)p < NUM_ANALOG_INPUTS) ? (p+A0) : p)
106
- #else
107
- /* For non contiguous analog pins definition in digitalPin array */
100
+ /* Non contiguous analog pins definition in digitalPin array */
108
101
#define analogInputToDigitalPin (p ) ( \
109
102
((uint32_t)p < NUM_ANALOG_INPUTS) ? analogInputPin[p] : \
110
103
((uint32_t)p >= NUM_ANALOG_FIRST) && ((uint32_t)p <= NUM_ANALOG_LAST) ? \
111
104
analogInputPin[p-NUM_ANALOG_FIRST] : p)
112
- #endif // !NUM_ANALOG_LAST
113
105
#else
114
106
/* No analog pin defined */
115
107
#define analogInputToDigitalPin (p ) (NUM_DIGITAL_PINS)
116
- #endif // NUM_ANALOG_INPUTS > 0
108
+ #endif /* NUM_ANALOG_INPUTS > 0 */
117
109
118
110
/* Convert an analog pin number Axx to a PinName PX_n */
119
111
PinName analogInputToPinName (uint32_t pin );
0 commit comments