-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathparsePin.cpp
618 lines (530 loc) · 7.32 KB
/
parsePin.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
#include "arduino_cli.h"
byte parsePin(String *pinStr)
{
if (pinStr == NULL)
{
Serial.println("ERROR: cannot parse NULL pin");
return PIN_INVALID;
}
byte pin = pinStr->toInt();
if (pin == 0 && *pinStr != "0")
{
// CONDITION: Non-numeric PIN ID
if (*pinStr == "")
{
// Just in case A0 isn't available for targeted board
return PIN_INVALID;
}
#ifdef PIN_A0
else if (*pinStr == "A0")
{
return PIN_A0;
}
#endif
#ifdef PIN_A1
else if (*pinStr == "A1")
{
return PIN_A1;
}
#endif
#ifdef PIN_A2
else if (*pinStr == "A2")
{
return PIN_A2;
}
#endif
#ifdef PIN_A3
else if (*pinStr == "A3")
{
return PIN_A3;
}
#endif
#ifdef PIN_A4
else if (*pinStr == "A4")
{
return PIN_A4;
}
#endif
#ifdef PIN_A5
else if (*pinStr == "A5")
{
return PIN_A5;
}
#endif
#ifdef PIN_A6
else if (*pinStr == "A6")
{
return PIN_A6;
}
#endif
#ifdef PIN_A7
else if (*pinStr == "A7")
{
return PIN_A7;
}
#endif
#ifdef PIN_A8
else if (*pinStr == "A8")
{
return PIN_A8;
}
#endif
#ifdef PIN_A9
else if (*pinStr == "A9")
{
return PIN_A9;
}
#endif
#ifdef PIN_A10
else if (*pinStr == "A10")
{
return PIN_A10;
}
#endif
#ifdef PIN_A11
else if (*pinStr == "A11")
{
return PIN_A11;
}
#endif
#ifdef PIN_A12
else if (*pinStr == "A12")
{
return PIN_A12;
}
#endif
#ifdef PIN_A13
else if (*pinStr == "A13")
{
return PIN_A13;
}
#endif
#ifdef PIN_A14
else if (*pinStr == "A14")
{
return PIN_A14;
}
#endif
#ifdef PIN_A15
else if (*pinStr == "A15")
{
return PIN_A15;
}
#endif
#ifdef PIN_A16
else if (*pinStr == "A16")
{
return PIN_A16;
}
#endif
#ifdef PIN_A17
else if (*pinStr == "A17")
{
return PIN_A17;
}
#endif
#ifdef PIN_A18
else if (*pinStr == "A18")
{
return PIN_A18;
}
#endif
#ifdef PIN_A19
else if (*pinStr == "A19")
{
return PIN_A19;
}
#endif
#ifdef PIN_A20
else if (*pinStr == "A20")
{
return PIN_A20;
}
#endif
#ifdef PIN_A21
else if (*pinStr == "A21")
{
return PIN_A21;
}
#endif
#ifdef PIN_A22
else if (*pinStr == "A22")
{
return PIN_A22;
}
#endif
#ifdef PIN_A23
else if (*pinStr == "A23")
{
return PIN_A23;
}
#endif
#ifdef PA1
else if (*pinStr == "PA1")
{
return PA1;
}
#endif
#ifdef PA2
else if (*pinStr == "PA2")
{
return PA2;
}
#endif
#ifdef PA3
else if (*pinStr == "PA3")
{
return PA3;
}
#endif
#ifdef PA4
else if (*pinStr == "PA4")
{
return PA4;
}
#endif
#ifdef PA5
else if (*pinStr == "PA5")
{
return PA5;
}
#endif
#ifdef PA6
else if (*pinStr == "PA6")
{
return PA6;
}
#endif
#ifdef PA7
else if (*pinStr == "PA7")
{
return PA7;
}
#endif
#ifdef PA8
else if (*pinStr == "PA8")
{
return PA8;
}
#endif
#ifdef PA9
else if (*pinStr == "PA9")
{
return PA9;
}
#endif
#ifdef PA10
else if (*pinStr == "PA10")
{
return PA10;
}
#endif
#ifdef PA11
else if (*pinStr == "PA11")
{
return PA11;
}
#endif
#ifdef PA12
else if (*pinStr == "PA12")
{
return PA12;
}
#endif
#ifdef PA13
else if (*pinStr == "PA13")
{
return PA13;
}
#endif
#ifdef PA14
else if (*pinStr == "PA14")
{
return PA14;
}
#endif
#ifdef PA15
else if (*pinStr == "PA15")
{
return PA15;
}
#endif
#ifdef PB1
else if (*pinStr == "PB1")
{
return PB1;
}
#endif
#ifdef PB2
else if (*pinStr == "PB2")
{
return PB2;
}
#endif
#ifdef PB3
else if (*pinStr == "PB3")
{
return PB3;
}
#endif
#ifdef PB4
else if (*pinStr == "PB4")
{
return PB4;
}
#endif
#ifdef PB5
else if (*pinStr == "PB5")
{
return PB5;
}
#endif
#ifdef PB6
else if (*pinStr == "PB6")
{
return PB6;
}
#endif
#ifdef PB7
else if (*pinStr == "PB7")
{
return PB7;
}
#endif
#ifdef PB8
else if (*pinStr == "PB8")
{
return PB8;
}
#endif
#ifdef PB9
else if (*pinStr == "PB9")
{
return PB9;
}
#endif
#ifdef PB10
else if (*pinStr == "PB10")
{
return PB10;
}
#endif
#ifdef PB11
else if (*pinStr == "PB11")
{
return PB11;
}
#endif
#ifdef PB12
else if (*pinStr == "PB12")
{
return PB12;
}
#endif
#ifdef PB13
else if (*pinStr == "PB13")
{
return PB13;
}
#endif
#ifdef PB14
else if (*pinStr == "PB14")
{
return PB14;
}
#endif
#ifdef PB15
else if (*pinStr == "PB15")
{
return PB15;
}
#endif
#ifdef PC1
else if (*pinStr == "PC1")
{
return PC1;
}
#endif
#ifdef PC2
else if (*pinStr == "PC2")
{
return PC2;
}
#endif
#ifdef PC3
else if (*pinStr == "PC3")
{
return PC3;
}
#endif
#ifdef PC4
else if (*pinStr == "PC4")
{
return PC4;
}
#endif
#ifdef PC5
else if (*pinStr == "PC5")
{
return PC5;
}
#endif
#ifdef PC6
else if (*pinStr == "PC6")
{
return PC6;
}
#endif
#ifdef PC7
else if (*pinStr == "PC7")
{
return PC7;
}
#endif
#ifdef PC8
else if (*pinStr == "PC8")
{
return PC8;
}
#endif
#ifdef PC9
else if (*pinStr == "PC9")
{
return PC9;
}
#endif
#ifdef PC10
else if (*pinStr == "PC10")
{
return PC10;
}
#endif
#ifdef PC11
else if (*pinStr == "PC11")
{
return PC11;
}
#endif
#ifdef PC12
else if (*pinStr == "PC12")
{
return PC12;
}
#endif
#ifdef PC13
else if (*pinStr == "PC13")
{
return PC13;
}
#endif
#ifdef PC14
else if (*pinStr == "PC14")
{
return PC14;
}
#endif
#ifdef PC15
else if (*pinStr == "PC15")
{
return PC15;
}
#endif
#ifdef PD1
else if (*pinStr == "PD1")
{
return PD1;
}
#endif
#ifdef PD2
else if (*pinStr == "PD2")
{
return PD2;
}
#endif
#ifdef PD3
else if (*pinStr == "PD3")
{
return PD3;
}
#endif
#ifdef PD4
else if (*pinStr == "PD4")
{
return PD4;
}
#endif
#ifdef PD5
else if (*pinStr == "PD5")
{
return PD5;
}
#endif
#ifdef PD6
else if (*pinStr == "PD6")
{
return PD6;
}
#endif
#ifdef PD7
else if (*pinStr == "PD7")
{
return PD7;
}
#endif
#ifdef PD8
else if (*pinStr == "PD8")
{
return PD8;
}
#endif
#ifdef PD9
else if (*pinStr == "PD9")
{
return PD9;
}
#endif
#ifdef PD10
else if (*pinStr == "PD10")
{
return PD10;
}
#endif
#ifdef PD11
else if (*pinStr == "PD11")
{
return PD11;
}
#endif
#ifdef PD12
else if (*pinStr == "PD12")
{
return PD12;
}
#endif
#ifdef PD13
else if (*pinStr == "PD13")
{
return PD13;
}
#endif
#ifdef PD14
else if (*pinStr == "PD14")
{
return PD14;
}
#endif
#ifdef PD15
else if (*pinStr == "PD15")
{
return PD15;
}
#endif
// CONDITION: Non-numeric PIN ID but not supported
return PIN_INVALID;
}
else
{
// CONDITION: Numeric PIN ID
return pin;
}
}