|
@@ -20,18 +20,13 @@
|
20
|
20
|
*
|
21
|
21
|
*/
|
22
|
22
|
|
23
|
|
-
|
24
|
23
|
bool endstop_monitor_flag = false;
|
25
|
24
|
|
26
|
|
-#define NAME_FORMAT "%-28s" // one place to specify the format of all the sources of names
|
|
25
|
+#define NAME_FORMAT "%-35s" // one place to specify the format of all the sources of names
|
27
|
26
|
// "-" left justify, "28" minimum width of name, pad with blanks
|
28
|
27
|
|
29
|
28
|
#define IS_ANALOG(P) ((P) >= analogInputToDigitalPin(0) && ((P) <= analogInputToDigitalPin(15) || (P) <= analogInputToDigitalPin(7)))
|
30
|
29
|
|
31
|
|
-#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) || defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__))
|
32
|
|
-#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__))
|
33
|
|
-#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__))
|
34
|
|
-
|
35
|
30
|
/**
|
36
|
31
|
* This routine minimizes RAM usage by creating a FLASH resident array to
|
37
|
32
|
* store the pin names, pin numbers and analog/digital flag.
|
|
@@ -52,7 +47,7 @@ bool endstop_monitor_flag = false;
|
52
|
47
|
#define REPORT_NAME_ANALOG(NAME, COUNTER) _ADD_PIN(#NAME, COUNTER)
|
53
|
48
|
|
54
|
49
|
#include "pinsDebug_list.h"
|
55
|
|
-#line 56
|
|
50
|
+#line 51
|
56
|
51
|
|
57
|
52
|
// manually add pins that have names that are macros which don't play well with these macros
|
58
|
53
|
#if SERIAL_PORT == 0 && (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY)
|
|
@@ -88,27 +83,34 @@ const char* const pin_array[][3] PROGMEM = {
|
88
|
83
|
// manually add pins ...
|
89
|
84
|
#if SERIAL_PORT == 0
|
90
|
85
|
#if AVR_ATmega2560_FAMILY
|
91
|
|
- { RXD_NAME, "0", "1" },
|
92
|
|
- { TXD_NAME, "1", "1" },
|
|
86
|
+ { RXD_NAME, 0, 1 },
|
|
87
|
+ { TXD_NAME, 1, 1 },
|
93
|
88
|
#elif AVR_ATmega1284_FAMILY
|
94
|
|
- { RXD_NAME, "8", "1" },
|
95
|
|
- { TXD_NAME, "9", "1" },
|
|
89
|
+ { RXD_NAME, 8, 1 },
|
|
90
|
+ { TXD_NAME, 9, 1 },
|
96
|
91
|
#endif
|
97
|
92
|
#endif
|
98
|
93
|
|
99
|
94
|
#include "pinsDebug_list.h"
|
100
|
|
- #line 101
|
|
95
|
+ #line 96
|
101
|
96
|
|
102
|
97
|
};
|
103
|
98
|
|
104
|
99
|
#define n_array (sizeof(pin_array) / sizeof(char*)) / 3
|
105
|
100
|
|
106
|
|
-#ifndef TIMER1B
|
107
|
|
- // working with Teensyduino extension so need to re-define some things
|
|
101
|
+#if AVR_AT90USB1286_FAMILY
|
|
102
|
+ // Working with Teensyduino extension so need to re-define some things
|
108
|
103
|
#include "pinsDebug_Teensyduino.h"
|
|
104
|
+ // Can't use the "digitalPinToPort" function from the Teensyduino type IDEs
|
|
105
|
+ // portModeRegister takes a different argument
|
|
106
|
+ #define digitalPinToPort_DEBUG(p) digitalPinToPort_Teensy(p)
|
|
107
|
+ #define get_pinMode(pin) (*portModeRegister(pin) & digitalPinToBitMask(pin))
|
|
108
|
+#else
|
|
109
|
+ #define digitalPinToPort_DEBUG(p) digitalPinToPort(p)
|
|
110
|
+ bool get_pinMode(int8_t pin) {return *portModeRegister(digitalPinToPort_DEBUG(pin)) & digitalPinToBitMask(pin); }
|
109
|
111
|
#endif
|
110
|
112
|
|
111
|
|
-#define PWM_PRINT(V) do{ sprintf(buffer, "PWM: %4d", V); SERIAL_ECHO(buffer); }while(0)
|
|
113
|
+#define PWM_PRINT(V) do{ sprintf_P(buffer, PSTR("PWM: %4d"), V); SERIAL_ECHO(buffer); }while(0)
|
112
|
114
|
#define PWM_CASE(N,Z) \
|
113
|
115
|
case TIMER##N##Z: \
|
114
|
116
|
if (TCCR##N##A & (_BV(COM##N##Z##1) | _BV(COM##N##Z##0))) { \
|
|
@@ -127,7 +129,9 @@ static bool pwm_status(uint8_t pin) {
|
127
|
129
|
|
128
|
130
|
#if defined(TCCR0A) && defined(COM0A1)
|
129
|
131
|
#ifdef TIMER0A
|
130
|
|
- PWM_CASE(0, A);
|
|
132
|
+ #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
|
133
|
+ PWM_CASE(0, A);
|
|
134
|
+ #endif
|
131
|
135
|
#endif
|
132
|
136
|
PWM_CASE(0, B);
|
133
|
137
|
#endif
|
|
@@ -244,9 +248,10 @@ const volatile uint8_t* const PWM_OCR[][3] PROGMEM = {
|
244
|
248
|
static void err_is_counter() { SERIAL_PROTOCOLPGM(" non-standard PWM mode"); }
|
245
|
249
|
static void err_is_interrupt() { SERIAL_PROTOCOLPGM(" compare interrupt enabled"); }
|
246
|
250
|
static void err_prob_interrupt() { SERIAL_PROTOCOLPGM(" overflow interrupt enabled"); }
|
|
251
|
+static void print_is_also_tied() { SERIAL_PROTOCOLPGM(" is also tied to this pin"); SERIAL_PROTOCOL_SP(14); }
|
247
|
252
|
|
248
|
253
|
void com_print(uint8_t N, uint8_t Z) {
|
249
|
|
- uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
|
254
|
+ const uint8_t *TCCRA = (uint8_t*)TCCR_A(N);
|
250
|
255
|
SERIAL_PROTOCOLPGM(" COM");
|
251
|
256
|
SERIAL_PROTOCOLCHAR(N + '0');
|
252
|
257
|
switch (Z) {
|
|
@@ -264,8 +269,8 @@ void com_print(uint8_t N, uint8_t Z) {
|
264
|
269
|
|
265
|
270
|
void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N - WGM bit layout
|
266
|
271
|
char buffer[20]; // for the sprintf statements
|
267
|
|
- uint8_t *TCCRB = (uint8_t*)TCCR_B(T);
|
268
|
|
- uint8_t *TCCRA = (uint8_t*)TCCR_A(T);
|
|
272
|
+ const uint8_t *TCCRB = (uint8_t*)TCCR_B(T),
|
|
273
|
+ *TCCRA = (uint8_t*)TCCR_A(T);
|
269
|
274
|
uint8_t WGM = (((*TCCRB & _BV(WGM_2)) >> 1) | (*TCCRA & (_BV(WGM_0) | _BV(WGM_1))));
|
270
|
275
|
if (N == 4) WGM |= ((*TCCRB & _BV(WGM_3)) >> 1);
|
271
|
276
|
|
|
@@ -275,11 +280,11 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
275
|
280
|
SERIAL_PROTOCOL_SP(3);
|
276
|
281
|
|
277
|
282
|
if (N == 3) {
|
278
|
|
- uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
|
|
283
|
+ const uint8_t *OCRVAL8 = (uint8_t*)OCR_VAL(T, L - 'A');
|
279
|
284
|
PWM_PRINT(*OCRVAL8);
|
280
|
285
|
}
|
281
|
286
|
else {
|
282
|
|
- uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A');
|
|
287
|
+ const uint16_t *OCRVAL16 = (uint16_t*)OCR_VAL(T, L - 'A');
|
283
|
288
|
PWM_PRINT(*OCRVAL16);
|
284
|
289
|
}
|
285
|
290
|
SERIAL_PROTOCOLPAIR(" WGM: ", WGM);
|
|
@@ -294,12 +299,12 @@ void timer_prefix(uint8_t T, char L, uint8_t N) { // T - timer L - pwm N -
|
294
|
299
|
SERIAL_PROTOCOLCHAR(T + '0');
|
295
|
300
|
SERIAL_PROTOCOLPAIR("B: ", *TCCRB);
|
296
|
301
|
|
297
|
|
- uint8_t *TMSK = (uint8_t*)TIMSK(T);
|
|
302
|
+ const uint8_t *TMSK = (uint8_t*)TIMSK(T);
|
298
|
303
|
SERIAL_PROTOCOLPGM(" TIMSK");
|
299
|
304
|
SERIAL_PROTOCOLCHAR(T + '0');
|
300
|
305
|
SERIAL_PROTOCOLPAIR(": ", *TMSK);
|
301
|
306
|
|
302
|
|
- uint8_t OCIE = L - 'A' + 1;
|
|
307
|
+ const uint8_t OCIE = L - 'A' + 1;
|
303
|
308
|
if (N == 3) { if (WGM == 0 || WGM == 2 || WGM == 4 || WGM == 6) err_is_counter(); }
|
304
|
309
|
else { if (WGM == 0 || WGM == 4 || WGM == 12 || WGM == 13) err_is_counter(); }
|
305
|
310
|
if (TEST(*TMSK, OCIE)) err_is_interrupt();
|
|
@@ -311,7 +316,9 @@ static void pwm_details(uint8_t pin) {
|
311
|
316
|
|
312
|
317
|
#if defined(TCCR0A) && defined(COM0A1)
|
313
|
318
|
#ifdef TIMER0A
|
314
|
|
- case TIMER0A: timer_prefix(0, 'A', 3); break;
|
|
319
|
+ #if !AVR_AT90USB1286_FAMILY // not available in Teensyduino type IDEs
|
|
320
|
+ case TIMER0A: timer_prefix(0, 'A', 3); break;
|
|
321
|
+ #endif
|
315
|
322
|
#endif
|
316
|
323
|
case TIMER0B: timer_prefix(0, 'B', 3); break;
|
317
|
324
|
#endif
|
|
@@ -357,136 +364,192 @@ static void pwm_details(uint8_t pin) {
|
357
|
364
|
// on pins that have two PWMs, print info on second PWM
|
358
|
365
|
#if AVR_ATmega2560_FAMILY || AVR_AT90USB1286_FAMILY
|
359
|
366
|
// looking for port B7 - PWMs 0A and 1C
|
360
|
|
- if (digitalPinToPort(pin) == 2 && digitalPinToBitMask(pin) == 0x80) {
|
361
|
|
- #ifndef TEENSYDUINO_IDE
|
|
367
|
+ if (digitalPinToPort_DEBUG(pin) == 'B' - 64 && 0x80 == digitalPinToBitMask(pin)) {
|
|
368
|
+ #if !AVR_AT90USB1286_FAMILY
|
362
|
369
|
SERIAL_PROTOCOLPGM("\n .");
|
363
|
370
|
SERIAL_PROTOCOL_SP(18);
|
364
|
|
- SERIAL_PROTOCOLPGM("TIMER1C is also tied to this pin");
|
365
|
|
- SERIAL_PROTOCOL_SP(13);
|
|
371
|
+ SERIAL_PROTOCOLPGM("TIMER1C");
|
|
372
|
+ print_is_also_tied();
|
366
|
373
|
timer_prefix(1, 'C', 4);
|
367
|
374
|
#else
|
368
|
375
|
SERIAL_PROTOCOLPGM("\n .");
|
369
|
376
|
SERIAL_PROTOCOL_SP(18);
|
370
|
|
- SERIAL_PROTOCOLPGM("TIMER0A is also tied to this pin");
|
371
|
|
- SERIAL_PROTOCOL_SP(13);
|
|
377
|
+ SERIAL_PROTOCOLPGM("TIMER0A");
|
|
378
|
+ print_is_also_tied();
|
372
|
379
|
timer_prefix(0, 'A', 3);
|
373
|
380
|
#endif
|
374
|
381
|
}
|
375
|
382
|
#endif
|
376
|
383
|
} // pwm_details
|
377
|
384
|
|
378
|
|
-bool get_pinMode(int8_t pin) { return *portModeRegister(digitalPinToPort(pin)) & digitalPinToBitMask(pin); }
|
379
|
|
-
|
380
|
|
-#ifndef digitalRead_mod // use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
381
|
|
- int digitalRead_mod(int8_t pin) { // same as digitalRead except the PWM stop section has been removed
|
382
|
|
- uint8_t port = digitalPinToPort(pin);
|
|
385
|
+#ifndef digitalRead_mod // Use Teensyduino's version of digitalRead - it doesn't disable the PWMs
|
|
386
|
+ int digitalRead_mod(const int8_t pin) { // same as digitalRead except the PWM stop section has been removed
|
|
387
|
+ const uint8_t port = digitalPinToPort_DEBUG(pin);
|
383
|
388
|
return (port != NOT_A_PIN) && (*portInputRegister(port) & digitalPinToBitMask(pin)) ? HIGH : LOW;
|
384
|
389
|
}
|
385
|
390
|
#endif
|
386
|
391
|
|
387
|
392
|
void print_port(int8_t pin) { // print port number
|
388
|
|
- #ifdef digitalPinToPort
|
|
393
|
+ #ifdef digitalPinToPort_DEBUG
|
|
394
|
+ uint8_t x;
|
389
|
395
|
SERIAL_PROTOCOLPGM(" Port: ");
|
390
|
|
- uint8_t x = digitalPinToPort(pin) + 64;
|
|
396
|
+ #if AVR_AT90USB1286_FAMILY
|
|
397
|
+ x = (pin == 46 || pin == 47) ? 'E' : digitalPinToPort_DEBUG(pin) + 64;
|
|
398
|
+ #else
|
|
399
|
+ x = digitalPinToPort_DEBUG(pin) + 64;
|
|
400
|
+ #endif
|
391
|
401
|
SERIAL_CHAR(x);
|
392
|
|
- uint8_t temp = digitalPinToBitMask(pin);
|
393
|
|
- for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
|
402
|
+
|
|
403
|
+ #if AVR_AT90USB1286_FAMILY
|
|
404
|
+ if (pin == 46)
|
|
405
|
+ x = '2';
|
|
406
|
+ else if (pin == 47)
|
|
407
|
+ x = '3';
|
|
408
|
+ else {
|
|
409
|
+ uint8_t temp = digitalPinToBitMask(pin);
|
|
410
|
+ for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
|
411
|
+ }
|
|
412
|
+ #else
|
|
413
|
+ uint8_t temp = digitalPinToBitMask(pin);
|
|
414
|
+ for (x = '0'; x < '9' && temp != 1; x++) temp >>= 1;
|
|
415
|
+ #endif
|
394
|
416
|
SERIAL_CHAR(x);
|
395
|
417
|
#else
|
396
|
418
|
SERIAL_PROTOCOL_SP(10);
|
397
|
419
|
#endif
|
398
|
420
|
}
|
399
|
421
|
|
|
422
|
+static void print_input_or_output(const bool isout) {
|
|
423
|
+ serialprintPGM(isout ? PSTR("Output = ") : PSTR("Input = "));
|
|
424
|
+}
|
|
425
|
+
|
400
|
426
|
// pretty report with PWM info
|
401
|
|
-inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = true) {
|
|
427
|
+inline void report_pin_state_extended(int8_t pin, bool ignore, bool extended = false,const char *start_string = "") {
|
402
|
428
|
uint8_t temp_char;
|
403
|
|
- char *name_mem_pointer;
|
404
|
|
- char buffer[30]; // for the sprintf statements
|
405
|
|
- bool found = false,
|
406
|
|
- multi_name_pin = false;
|
|
429
|
+ char *name_mem_pointer, buffer[30]; // for the sprintf statements
|
|
430
|
+ bool found = false, multi_name_pin = false;
|
407
|
431
|
for (uint8_t x = 0; x < n_array; x++) { // scan entire array and report all instances of this pin
|
408
|
432
|
if (pgm_read_byte(&pin_array[x][1]) == pin) {
|
409
|
433
|
if (found) multi_name_pin = true;
|
410
|
434
|
found = true;
|
411
|
435
|
if (!multi_name_pin) { // report digitial and analog pin number only on the first time through
|
412
|
|
- sprintf(buffer, "PIN: %3d ", pin); // digital pin number
|
|
436
|
+ sprintf_P(buffer, PSTR("%sPIN: %3d "), start_string, pin); // digital pin number
|
413
|
437
|
SERIAL_ECHO(buffer);
|
414
|
438
|
print_port(pin);
|
415
|
439
|
if (IS_ANALOG(pin)) {
|
416
|
|
- sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number
|
|
440
|
+ sprintf_P(buffer, PSTR(" (A%2d) "), int(pin - analogInputToDigitalPin(0))); // analog pin number
|
417
|
441
|
SERIAL_ECHO(buffer);
|
418
|
442
|
}
|
419
|
443
|
else SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
420
|
444
|
}
|
421
|
445
|
else {
|
422
|
446
|
SERIAL_CHAR('.');
|
423
|
|
- SERIAL_ECHO_SP(25); // add padding if not the first instance found
|
|
447
|
+ SERIAL_ECHO_SP(26 + strlen(start_string)); // add padding if not the first instance found
|
424
|
448
|
}
|
425
|
449
|
name_mem_pointer = (char*)pgm_read_word(&pin_array[x][0]);
|
426
|
450
|
for (uint8_t y = 0; y < 28; y++) { // always print pin name
|
427
|
451
|
temp_char = pgm_read_byte(name_mem_pointer + y);
|
428
|
|
- if (temp_char != 0) MYSERIAL.write(temp_char);
|
|
452
|
+ if (temp_char != 0)
|
|
453
|
+ MYSERIAL.write(temp_char);
|
429
|
454
|
else {
|
430
|
455
|
for (uint8_t i = 0; i < 28 - y; i++) MYSERIAL.write(' ');
|
431
|
456
|
break;
|
432
|
457
|
}
|
433
|
458
|
}
|
434
|
|
- if (pin_is_protected(pin) && !ignore)
|
435
|
|
- SERIAL_ECHOPGM("protected ");
|
436
|
|
- else {
|
437
|
|
- if (!(pgm_read_byte(&pin_array[x][2]))) {
|
438
|
|
- sprintf(buffer, "Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0)));
|
439
|
|
- SERIAL_ECHO(buffer);
|
440
|
|
- }
|
|
459
|
+ if (extended) {
|
|
460
|
+ if (pin_is_protected(pin) && !ignore)
|
|
461
|
+ SERIAL_ECHOPGM("protected ");
|
441
|
462
|
else {
|
442
|
|
- if (!get_pinMode(pin)) {
|
443
|
|
- //pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this
|
444
|
|
- // because this could interfere with inductive/capacitive
|
445
|
|
- // sensors (high impedance voltage divider) and with PT100 amplifier
|
446
|
|
- SERIAL_PROTOCOLPAIR("Input = ", digitalRead_mod(pin));
|
447
|
|
- }
|
448
|
|
- else if (pwm_status(pin)) {
|
449
|
|
- // do nothing
|
|
463
|
+ #ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
|
464
|
+ if (pin == 46) {
|
|
465
|
+ print_input_or_output(GET_OUTPUT(46));
|
|
466
|
+ SERIAL_PROTOCOL(READ(46));
|
|
467
|
+ }
|
|
468
|
+ else if (pin == 47)
|
|
469
|
+ print_input_or_output(GET_OUTPUT(47));
|
|
470
|
+ SERIAL_PROTOCOL(READ(47));
|
|
471
|
+ }
|
|
472
|
+ else
|
|
473
|
+ #endif
|
|
474
|
+ {
|
|
475
|
+ if (!(pgm_read_byte(&pin_array[x][2]))) {
|
|
476
|
+ sprintf_P(buffer, PSTR("Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
|
|
477
|
+ SERIAL_ECHO(buffer);
|
|
478
|
+ }
|
|
479
|
+ else {
|
|
480
|
+
|
|
481
|
+ if (!get_pinMode(pin)) {
|
|
482
|
+ //pinMode(pin, INPUT_PULLUP); // make sure input isn't floating - stopped doing this
|
|
483
|
+ // because this could interfere with inductive/capacitive
|
|
484
|
+ // sensors (high impedance voltage divider) and with PT100 amplifier
|
|
485
|
+ print_input_or_output(false);
|
|
486
|
+ SERIAL_PROTOCOL(digitalRead_mod(pin));
|
|
487
|
+ }
|
|
488
|
+ else if (pwm_status(pin)) {
|
|
489
|
+ // do nothing
|
|
490
|
+ }
|
|
491
|
+ else {
|
|
492
|
+ print_input_or_output(true);
|
|
493
|
+ SERIAL_PROTOCOL(digitalRead_mod(pin));
|
|
494
|
+ }
|
|
495
|
+ }
|
|
496
|
+ if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report
|
450
|
497
|
}
|
451
|
|
- else SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
|
452
|
498
|
}
|
453
|
|
- if (!multi_name_pin && extended) pwm_details(pin); // report PWM capabilities only on the first pass & only if doing an extended report
|
454
|
499
|
}
|
455
|
500
|
SERIAL_EOL();
|
456
|
501
|
} // end of IF
|
457
|
502
|
} // end of for loop
|
458
|
503
|
|
459
|
504
|
if (!found) {
|
460
|
|
- sprintf(buffer, "PIN: %3d ", pin);
|
|
505
|
+ sprintf_P(buffer, PSTR("%sPIN: %3d "), start_string, pin);
|
461
|
506
|
SERIAL_ECHO(buffer);
|
462
|
507
|
print_port(pin);
|
463
|
508
|
if (IS_ANALOG(pin)) {
|
464
|
|
- sprintf(buffer, " (A%2d) ", int(pin - analogInputToDigitalPin(0))); // analog pin number
|
|
509
|
+ sprintf_P(buffer, PSTR(" (A%2d) "), int(pin - analogInputToDigitalPin(0))); // analog pin number
|
465
|
510
|
SERIAL_ECHO(buffer);
|
466
|
511
|
}
|
467
|
|
- else
|
468
|
|
- SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
469
|
|
- SERIAL_ECHOPGM("<unused/unknown>");
|
470
|
|
- if (get_pinMode(pin)) {
|
471
|
|
- SERIAL_PROTOCOL_SP(12);
|
472
|
|
- SERIAL_PROTOCOLPAIR("Output = ", digitalRead_mod(pin));
|
473
|
|
- }
|
474
|
512
|
else {
|
475
|
|
- if (IS_ANALOG(pin)) {
|
476
|
|
- sprintf(buffer, " Analog in = %5d", analogRead(pin - analogInputToDigitalPin(0)));
|
477
|
|
- SERIAL_ECHO(buffer);
|
|
513
|
+ SERIAL_ECHO_SP(8); // add padding if not an analog pin
|
|
514
|
+ SERIAL_ECHOPGM("<unused/unknown>");
|
|
515
|
+ if (extended) {
|
|
516
|
+ #ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
|
|
517
|
+ if (pin == 46 || pin == 47) {
|
|
518
|
+ SERIAL_PROTOCOL_SP(12);
|
|
519
|
+ if (pin == 46) {
|
|
520
|
+ print_input_or_output(GET_OUTPUT(46));
|
|
521
|
+ SERIAL_PROTOCOL(READ(46));
|
|
522
|
+ }
|
|
523
|
+ else {
|
|
524
|
+ print_input_or_output(GET_OUTPUT(47));
|
|
525
|
+ SERIAL_PROTOCOL(READ(47));
|
|
526
|
+ }
|
|
527
|
+ }
|
|
528
|
+ else
|
|
529
|
+ #endif
|
|
530
|
+ {
|
|
531
|
+ if (get_pinMode(pin)) {
|
|
532
|
+ SERIAL_PROTOCOL_SP(12);
|
|
533
|
+ print_input_or_output(true);
|
|
534
|
+ SERIAL_PROTOCOL(digitalRead_mod(pin));
|
|
535
|
+ }
|
|
536
|
+ else {
|
|
537
|
+ if (IS_ANALOG(pin)) {
|
|
538
|
+ sprintf_P(buffer, PSTR(" Analog in = %5d"), analogRead(pin - analogInputToDigitalPin(0)));
|
|
539
|
+ SERIAL_ECHO(buffer);
|
|
540
|
+ SERIAL_ECHOPGM(" ");
|
|
541
|
+ }
|
|
542
|
+ else
|
|
543
|
+ SERIAL_ECHO_SP(12); // add padding if not an analog pin
|
|
544
|
+
|
|
545
|
+ print_input_or_output(false);
|
|
546
|
+ SERIAL_PROTOCOL(digitalRead_mod(pin));
|
|
547
|
+ }
|
|
548
|
+ //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
|
|
549
|
+ if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report
|
|
550
|
+ }
|
478
|
551
|
}
|
479
|
|
- else
|
480
|
|
- SERIAL_ECHO_SP(9); // add padding if not an analog pin
|
481
|
|
-
|
482
|
|
- SERIAL_PROTOCOLPAIR(" Input = ", digitalRead_mod(pin));
|
|
552
|
+ SERIAL_EOL();
|
483
|
553
|
}
|
484
|
|
- //if (!pwm_status(pin)) SERIAL_CHAR(' '); // add padding if it's not a PWM pin
|
485
|
|
- if (extended) pwm_details(pin); // report PWM capabilities only if doing an extended report
|
486
|
|
- SERIAL_EOL();
|
487
|
554
|
}
|
488
|
555
|
}
|
489
|
|
-
|
490
|
|
-inline void report_pin_state(int8_t pin) {
|
491
|
|
- report_pin_state_extended(pin, false, false);
|
492
|
|
-}
|