Skip to content

Commit a536cc8

Browse files
polygammafacchinm
authored andcommitted
make PINS_COUNT dynamic
1 parent 52e0052 commit a536cc8

File tree

20 files changed

+141
-10
lines changed

20 files changed

+141
-10
lines changed

variants/arduino_mzero/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ const PinDescription g_APinDescription[]=
194194
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, DAC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // DAC/VOUT
195195
} ;
196196

197+
extern "C" {
198+
unsigned int PINCOUNT_fn() {
199+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
200+
}
201+
}
202+
197203
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
198204

199205
// Multi-serial objects instantiation

variants/arduino_mzero/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern "C"
5353
*----------------------------------------------------------------------------*/
5454

5555
// Number of pins defined in PinDescription array
56-
#define PINS_COUNT (34u)
56+
#define PINS_COUNT (PINCOUNT_fn())
5757
#define NUM_DIGITAL_PINS (19u)
5858
#define NUM_ANALOG_INPUTS (5u)
5959
#define NUM_ANALOG_OUTPUTS (1u)
@@ -184,6 +184,14 @@ extern Uart Serial1;
184184

185185
#endif
186186

187+
#ifdef __cplusplus
188+
extern "C" {
189+
#endif
190+
unsigned int PINCOUNT_fn();
191+
#ifdef __cplusplus
192+
}
193+
#endif
194+
187195
// These serial port names are intended to allow libraries and architecture-neutral
188196
// sketches to automatically default to the correct port name for a particular type
189197
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/arduino_zero/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,12 @@ const PinDescription g_APinDescription[]=
203203
{ PORTA, 31, PIO_PWM, PIN_ATTR_DIGITAL|PIO_SERCOM, No_ADC_Channel, NOT_ON_PWM, TCC1_CH1, EXTERNAL_INT_11 }, // SWDIO
204204
} ;
205205

206+
extern "C" {
207+
unsigned int PINCOUNT_fn() {
208+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
209+
}
210+
}
211+
206212
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
207213

208214
// Multi-serial objects instantiation

variants/arduino_zero/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extern "C"
5353
*----------------------------------------------------------------------------*/
5454

5555
// Number of pins defined in PinDescription array
56-
#define PINS_COUNT (26u)
56+
#define PINS_COUNT (PINCOUNT_fn())
5757
#define NUM_DIGITAL_PINS (20u)
5858
#define NUM_ANALOG_INPUTS (6u)
5959
#define NUM_ANALOG_OUTPUTS (1u)
@@ -198,6 +198,14 @@ extern Uart Serial1;
198198

199199
#endif
200200

201+
#ifdef __cplusplus
202+
extern "C" {
203+
#endif
204+
unsigned int PINCOUNT_fn();
205+
#ifdef __cplusplus
206+
}
207+
#endif
208+
201209
// These serial port names are intended to allow libraries and architecture-neutral
202210
// sketches to automatically default to the correct port name for a particular type
203211
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/circuitplay/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,12 @@ const PinDescription g_APinDescription[]=
184184

185185
} ;
186186

187+
extern "C" {
188+
unsigned int PINCOUNT_fn() {
189+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
190+
}
191+
}
192+
187193
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
188194

189195
// Multi-serial objects instantiation

variants/circuitplay/variant.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// ----
3838

3939
// Number of pins defined in PinDescription array
40-
#define PINS_COUNT (39u)
40+
#define PINS_COUNT (PINCOUNT_fn())
4141
#define NUM_DIGITAL_PINS (39u)
4242
#define NUM_ANALOG_INPUTS (11u)
4343
#define NUM_ANALOG_OUTPUTS (1u)
@@ -179,6 +179,13 @@ extern Uart Serial1;
179179
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_1)
180180
#endif // __cplusplus
181181

182+
#ifdef __cplusplus
183+
extern "C" {
184+
#endif
185+
unsigned int PINCOUNT_fn();
186+
#ifdef __cplusplus
187+
}
188+
#endif
182189

183190

184191
// These serial port names are intended to allow libraries and architecture-neutral

variants/mkr1000/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,12 @@ const PinDescription g_APinDescription[] = {
160160
{ PORTA, 1, PIO_DIGITAL, (PIN_ATTR_NONE ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
161161
};
162162

163+
extern "C" {
164+
unsigned int PINCOUNT_fn() {
165+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
166+
}
167+
}
168+
163169
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
164170

165171
// Multi-serial objects instantiation

variants/mkr1000/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (26u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (22u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -176,6 +176,14 @@ extern Uart Serial1;
176176
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
177177
#endif // __cplusplus
178178

179+
#ifdef __cplusplus
180+
extern "C" {
181+
#endif
182+
unsigned int PINCOUNT_fn();
183+
#ifdef __cplusplus
184+
}
185+
#endif
186+
179187
// These serial port names are intended to allow libraries and architecture-neutral
180188
// sketches to automatically default to the correct port name for a particular type
181189
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/mkrfox1200/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ const PinDescription g_APinDescription[] = {
158158
{ PORTA, 1, PIO_DIGITAL, (PIN_ATTR_NONE ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
159159
};
160160

161+
extern "C" {
162+
unsigned int PINCOUNT_fn() {
163+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
164+
}
165+
}
166+
161167
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
162168

163169
// Multi-serial objects instantiation

variants/mkrfox1200/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (26u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (15u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -178,6 +178,14 @@ extern Uart Serial1;
178178
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
179179
#endif // __cplusplus
180180

181+
#ifdef __cplusplus
182+
extern "C" {
183+
#endif
184+
unsigned int PINCOUNT_fn();
185+
#ifdef __cplusplus
186+
}
187+
#endif
188+
181189
// These serial port names are intended to allow libraries and architecture-neutral
182190
// sketches to automatically default to the correct port name for a particular type
183191
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/mkrgsm1400/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ const PinDescription g_APinDescription[] = {
161161
{ PORTA, 28, PIO_DIGITAL, (PIN_ATTR_NONE ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
162162
};
163163

164+
extern "C" {
165+
unsigned int PINCOUNT_fn() {
166+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
167+
}
168+
}
169+
164170
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
165171

166172
// Multi-serial objects instantiation

variants/mkrgsm1400/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (26u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (15u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -169,6 +169,14 @@ extern Uart Serial2;
169169

170170
#endif // __cplusplus
171171

172+
#ifdef __cplusplus
173+
extern "C" {
174+
#endif
175+
unsigned int PINCOUNT_fn();
176+
#ifdef __cplusplus
177+
}
178+
#endif
179+
172180
// These serial port names are intended to allow libraries and architecture-neutral
173181
// sketches to automatically default to the correct port name for a particular type
174182
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/mkrwan1300/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ const PinDescription g_APinDescription[] = {
161161
{ PORTA, 15, PIO_SERCOM_ALT, (PIN_ATTR_NONE ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE }, // MISO: SERCOM4/PAD[3]
162162
};
163163

164+
extern "C" {
165+
unsigned int PINCOUNT_fn() {
166+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
167+
}
168+
}
169+
164170
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
165171

166172

variants/mkrwan1300/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (35u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (15u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -176,6 +176,14 @@ extern Uart Serial2;
176176

177177
#endif // __cplusplus
178178

179+
#ifdef __cplusplus
180+
extern "C" {
181+
#endif
182+
unsigned int PINCOUNT_fn();
183+
#ifdef __cplusplus
184+
}
185+
#endif
186+
179187
// These serial port names are intended to allow libraries and architecture-neutral
180188
// sketches to automatically default to the correct port name for a particular type
181189
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/mkrwifi1010/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ const PinDescription g_APinDescription[] = {
161161
{ PORTA, 28, PIO_DIGITAL, (PIN_ATTR_DIGITAL ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
162162
};
163163

164+
extern "C" {
165+
unsigned int PINCOUNT_fn() {
166+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
167+
}
168+
}
169+
164170
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
165171

166172
// Multi-serial objects instantiation

variants/mkrwifi1010/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (26u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (15u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -185,6 +185,14 @@ extern Uart Serial2;
185185

186186
#endif // __cplusplus
187187

188+
#ifdef __cplusplus
189+
extern "C" {
190+
#endif
191+
unsigned int PINCOUNT_fn();
192+
#ifdef __cplusplus
193+
}
194+
#endif
195+
188196
// These serial port names are intended to allow libraries and architecture-neutral
189197
// sketches to automatically default to the correct port name for a particular type
190198
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/mkrzero/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,12 @@ const PinDescription g_APinDescription[] = {
159159
{ PORTA, 1, PIO_DIGITAL, (PIN_ATTR_NONE ), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_NONE },
160160
};
161161

162+
extern "C" {
163+
unsigned int PINCOUNT_fn() {
164+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
165+
}
166+
}
167+
162168
const void* g_apTCInstances[TCC_INST_NUM + TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 };
163169

164170
// Multi-serial objects instantiation

variants/mkrzero/variant.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
// ----
3737

3838
// Number of pins defined in PinDescription array
39-
#define PINS_COUNT (26u)
39+
#define PINS_COUNT (PINCOUNT_fn())
4040
#define NUM_DIGITAL_PINS (15u)
4141
#define NUM_ANALOG_INPUTS (7u)
4242
#define NUM_ANALOG_OUTPUTS (1u)
@@ -172,6 +172,14 @@ extern Uart Serial1;
172172
#define PAD_SERIAL1_RX (SERCOM_RX_PAD_3)
173173
#endif // __cplusplus
174174

175+
#ifdef __cplusplus
176+
extern "C" {
177+
#endif
178+
unsigned int PINCOUNT_fn();
179+
#ifdef __cplusplus
180+
}
181+
#endif
182+
175183
// These serial port names are intended to allow libraries and architecture-neutral
176184
// sketches to automatically default to the correct port name for a particular type
177185
// of use. For example, a GPS module would normally connect to SERIAL_PORT_HARDWARE_OPEN,

variants/nona_wlan/variant.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,12 @@ const PinDescription g_APinDescription[]=
186186

187187
} ;
188188

189+
extern "C" {
190+
unsigned int PINCOUNT_fn() {
191+
return (sizeof(g_APinDescription) / sizeof(g_APinDescription[0]));
192+
}
193+
}
194+
189195
const void* g_apTCInstances[TCC_INST_NUM+TC_INST_NUM]={ TCC0, TCC1, TCC2, TC3, TC4, TC5 } ;
190196

191197
void initVariant() {

variants/nona_wlan/variant.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
// ----
3838

3939
// Number of pins defined in PinDescription array
40-
#define PINS_COUNT (33u)
40+
#define PINS_COUNT (PINCOUNT_fn())
4141
#define NUM_DIGITAL_PINS (31u)
4242
#define NUM_ANALOG_INPUTS (8u)
4343
#define NUM_ANALOG_OUTPUTS (1u)

0 commit comments

Comments
 (0)