Skip to content

Commit c784d36

Browse files
committed
Defining NUM_DIGITAL_PINS and NUM_ANALOG_INPUTS as literals
1 parent a8becbf commit c784d36

File tree

23 files changed

+143
-3
lines changed

23 files changed

+143
-3
lines changed

cores/arduino/pins_arduino_var.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,16 @@
2525
// Include board variant
2626
#include "variant.h"
2727

28+
// Avoid pins number misalignment
29+
_Static_assert(NUM_DIGITAL_PINS==PEND, "NUM_DIGITAL_PINS and PEND differ!");
30+
_Static_assert(NUM_ANALOG_INPUTS==(AEND-A0), "NUM_DIGITAL_PINS and (AEND-A0) differ!");
31+
2832
#ifdef __cplusplus
2933
extern "C" {
3034
#endif
3135

3236
#define NOT_AN_INTERRUPT NC // -1
33-
#define DEND PEND
34-
#define NUM_DIGITAL_PINS ((uint32_t)DEND)
35-
#define NUM_ANALOG_INPUTS ((uint32_t)(AEND-A0))
37+
#define DEND NUM_DIGITAL_PINS
3638

3739
// Convert a digital pin number Dxx to a PinName PX_n
3840
// Note: Analog pin is also a digital pin.

variants/DISCO_F100RB/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,19 @@ enum {
105105
PEND
106106
};
107107

108+
// This must be a literal with the same value as PEND
109+
#define NUM_DIGITAL_PINS 63
110+
108111
enum {
109112
A_START_AFTER = D46,
110113
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
111114
A10, A11, A12, A13, A14, A15,
112115
AEND
113116
};
114117

118+
// This must be a literal with the same value as AEND-A0
119+
#define NUM_ANALOG_INPUTS 16
120+
115121
// On-board LED pin number
116122
#define LED_BUILTIN PC9
117123
#define LED_GREEN LED_BUILTIN

variants/DISCO_F407VG/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,18 @@ enum {
131131
PEND
132132
};
133133

134+
// This must be a literal with the same value as PEND
135+
#define NUM_DIGITAL_PINS 87
136+
134137
enum {
135138
A_START_AFTER = D78,
136139
A0, A1, A2, A3, A4, A5, A6, A7,
137140
AEND
138141
};
139142

143+
// This must be a literal with the same value as AEND-A0
144+
#define NUM_ANALOG_INPUTS 8
145+
140146
// On-board LED pin number
141147
#define LED_BUILTIN PD12
142148
#define LED_GREEN LED_BUILTIN

variants/DISCO_F746NG/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,18 @@ enum {
6363
PEND
6464
};
6565

66+
// This must be a literal with the same value as PEND
67+
#define NUM_DIGITAL_PINS 25
68+
6669
enum {
6770
A_START_AFTER = D15,
6871
A0, A1, A2, A3, A4, A5,
6972
AEND
7073
};
7174

75+
// This must be a literal with the same value as AEND-A0
76+
#define NUM_ANALOG_INPUTS 6
77+
7278
// On-board LED pin number
7379
#define LED_BUILTIN 13
7480
#define LED_GREEN LED_BUILTIN

variants/DISCO_L072CZ_LRWAN1/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,18 @@ enum {
7373
PEND
7474
};
7575

76+
// This must be a literal with the same value as PEND
77+
#define NUM_DIGITAL_PINS 33
78+
7679
enum {
7780
A_START_AFTER = D25,
7881
A0, A1, A2, A3, A4, A5, A6,
7982
AEND
8083
};
8184

85+
// This must be a literal with the same value as AEND-A0
86+
#define NUM_ANALOG_INPUTS 7
87+
8288
// On-board LED pin number
8389
#define LED_BUILTIN PA5
8490
#define LED_LD2 LED_BUILTIN

variants/DISCO_L475VG_IOT/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,19 @@ enum {
132132
PEND
133133
};
134134

135+
// This must be a literal with the same value as PEND
136+
#define NUM_DIGITAL_PINS 85
137+
135138
enum {
136139
A_START_AFTER = D68,
137140
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
138141
A10, A11, A12, A13, A14, A15,
139142
AEND
140143
};
141144

145+
// This must be a literal with the same value as AEND-A0
146+
#define NUM_ANALOG_INPUTS 16
147+
142148
// On-board LED pin number
143149
#define LED_BUILTIN 13
144150
#define LED1 LED_BUILTIN

variants/NUCLEO_F030R8/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,19 @@ enum {
105105
PEND
106106
};
107107

108+
// This must be a literal with the same value as PEND
109+
#define NUM_DIGITAL_PINS 61
110+
108111
enum {
109112
A_START_AFTER = D48,
110113
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
111114
A10, A11,
112115
AEND
113116
};
114117

118+
// This must be a literal with the same value as AEND-A0
119+
#define NUM_ANALOG_INPUTS 12
120+
115121
// On-board LED pin number
116122
#define LED_BUILTIN 13
117123
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F091RC/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ enum {
102102
PEND
103103
};
104104

105+
// This must be a literal with the same value as PEND
106+
#define NUM_DIGITAL_PINS 58
107+
105108
enum {
106109
A_START_AFTER = D45,
107110
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
108111
A10, A11,
109112
AEND
110113
};
111114

115+
// This must be a literal with the same value as AEND-A0
116+
#define NUM_ANALOG_INPUTS 12
117+
112118
// On-board LED pin number
113119
#define LED_BUILTIN 13
114120
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F103RB/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ enum {
104104
PEND
105105
};
106106

107+
// This must be a literal with the same value as PEND
108+
#define NUM_DIGITAL_PINS 60
109+
107110
enum {
108111
A_START_AFTER = D45,
109112
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
110113
A10, A11, A12, A13,
111114
AEND
112115
};
113116

117+
// This must be a literal with the same value as AEND-A0
118+
#define NUM_ANALOG_INPUTS 14
119+
114120
// On-board LED pin number
115121
#define LED_BUILTIN 13
116122
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F207ZG/variant.h

+7
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ enum {
147147
PF9_2,//D95/A17 = D63
148148
PEND
149149
};
150+
151+
// This must be a literal with the same value as PEND
152+
#define NUM_DIGITAL_PINS 96
153+
150154
// Enum defining Arduino style alias for analog pin number --> Ax
151155
enum {
152156
A_START_AFTER = D77, // pin number preceding A0
@@ -155,6 +159,9 @@ enum {
155159
AEND
156160
};
157161

162+
// This must be a literal with the same value as AEND-A0
163+
#define NUM_ANALOG_INPUTS 18
164+
158165
// On-board LED pin number
159166
#define LED_BUILTIN PB0
160167
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F302R8/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ enum {
102102
PEND
103103
};
104104

105+
// This must be a literal with the same value as PEND
106+
#define NUM_DIGITAL_PINS 58
107+
105108
enum {
106109
A_START_AFTER = D45,
107110
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
108111
A10, A11,
109112
AEND
110113
};
111114

115+
// This must be a literal with the same value as AEND-A0
116+
#define NUM_ANALOG_INPUTS 12
117+
112118
// On-board LED pin number
113119
#define LED_BUILTIN 13
114120
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F303K8/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ enum {
6161
PEND
6262
};
6363

64+
// This must be a literal with the same value as PEND
65+
#define NUM_DIGITAL_PINS 23
66+
6467
enum {
6568
A_START_AFTER = D13,
6669
A0, A1, A2, A3, A4, A5, A6,
6770
AEND
6871
};
6972

73+
// This must be a literal with the same value as AEND-A0
74+
#define NUM_ANALOG_INPUTS 7
75+
7076
// On-board LED pin number
7177
#define LED_BUILTIN 13
7278
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F303RE/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ enum {
104104
PEND
105105
};
106106

107+
// This must be a literal with the same value as PEND
108+
#define NUM_DIGITAL_PINS 60
109+
107110
enum {
108111
A_START_AFTER = D45,
109112
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
110113
A10, A11, A12, A13,
111114
AEND
112115
};
113116

117+
// This must be a literal with the same value as AEND-A0
118+
#define NUM_ANALOG_INPUTS 14
119+
114120
// On-board LED pin number
115121
#define LED_BUILTIN 13
116122
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F401RE/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ enum {
103103
PEND
104104
};
105105

106+
// This must be a literal with the same value as PEND
107+
#define NUM_DIGITAL_PINS 59
108+
106109
enum {
107110
A_START_AFTER = D45,
108111
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
109112
A10, A11, A12,
110113
AEND
111114
};
112115

116+
// This must be a literal with the same value as AEND-A0
117+
#define NUM_ANALOG_INPUTS 13
118+
113119
// On-board LED pin number
114120
#define LED_BUILTIN 13
115121
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F411RE/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -103,13 +103,19 @@ enum {
103103
PEND
104104
};
105105

106+
// This must be a literal with the same value as PEND
107+
#define NUM_DIGITAL_PINS 59
108+
106109
enum {
107110
A_START_AFTER = D45,
108111
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
109112
A10, A11, A12,
110113
AEND
111114
};
112115

116+
// This must be a literal with the same value as AEND-A0
117+
#define NUM_ANALOG_INPUTS 13
118+
113119
// On-board LED pin number
114120
#define LED_BUILTIN 13
115121
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F429ZI/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,19 @@ enum {
135135
PEND
136136
};
137137

138+
// This must be a literal with the same value as PEND
139+
#define NUM_DIGITAL_PINS 96
140+
138141
enum {
139142
A_START_AFTER = D77,
140143
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
141144
A10, A11, A12, A13, A14, A15, A16, A17,
142145
AEND
143146
};
144147

148+
// This must be a literal with the same value as AEND-A0
149+
#define NUM_ANALOG_INPUTS 18
150+
145151
// On-board LED pin number
146152
#define LED_BUILTIN PB0
147153
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_F446RE/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,19 @@ enum {
104104
PEND
105105
};
106106

107+
// This must be a literal with the same value as PEND
108+
#define NUM_DIGITAL_PINS 60
109+
107110
enum {
108111
A_START_AFTER = D45,
109112
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
110113
A10, A11, A12, A13,
111114
AEND
112115
};
113116

117+
// This must be a literal with the same value as AEND-A0
118+
#define NUM_ANALOG_INPUTS 14
119+
114120
// On-board LED pin number
115121
#define LED_BUILTIN 13
116122
#define LED_LD2 LED_BUILTIN

variants/NUCLEO_L031K6/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,18 @@ enum {
7373
PEND
7474
};
7575

76+
// This must be a literal with the same value as PEND
77+
#define NUM_DIGITAL_PINS 23
78+
7679
enum {
7780
A_START_AFTER = D13,
7881
A0, A1, A2, A3, A4, A5, A6,
7982
AEND
8083
};
8184

85+
// This must be a literal with the same value as AEND-A0
86+
#define NUM_ANALOG_INPUTS 7
87+
8288
// On-board LED pin number
8389
#define LED_BUILTIN 13
8490
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_L053R8/variant.h

+6
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,19 @@ enum {
102102
PEND
103103
};
104104

105+
// This must be a literal with the same value as PEND
106+
#define NUM_DIGITAL_PINS 58
107+
105108
enum {
106109
A_START_AFTER = D45,
107110
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
108111
A10, A11,
109112
AEND
110113
};
111114

115+
// This must be a literal with the same value as AEND-A0
116+
#define NUM_ANALOG_INPUTS 12
117+
112118
// On-board LED pin number
113119
#define LED_BUILTIN 13
114120
#define LED_GREEN LED_BUILTIN

variants/NUCLEO_L152RE/variant.h

+7
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,20 @@ enum {
107107
PEND
108108
};
109109

110+
// This must be a literal with the same value as PEND
111+
#define NUM_DIGITAL_PINS 63
112+
110113
enum {
111114
A_START_AFTER = D45,
112115
A0, A1, A2, A3, A4, A5, A6, A7, A8, A9,
113116
A10, A11, A12, A13, A14, A15, A16,
114117
AEND
115118
};
116119

120+
// This must be a literal with the same value as AEND-A0
121+
#define NUM_ANALOG_INPUTS 17
122+
123+
117124
// On-board LED pin number
118125
#define LED_BUILTIN 13
119126
#define LED_GREEN LED_BUILTIN

0 commit comments

Comments
 (0)