Explorar el Código

Unify AVR90USB: pinsDebug changes

Scott Lahteine hace 7 años
padre
commit
748bf32388
Se han modificado 4 ficheros con 235 adiciones y 132 borrados
  1. 45
    23
      Marlin/Marlin_main.cpp
  2. 151
    88
      Marlin/pinsDebug.h
  3. 11
    15
      Marlin/pinsDebug_Teensyduino.h
  4. 28
    6
      Marlin/pinsDebug_list.h

+ 45
- 23
Marlin/Marlin_main.cpp Ver fichero

@@ -732,9 +732,7 @@ void report_current_position_detail();
732 732
     SERIAL_ECHOPAIR(", ", y);
733 733
     SERIAL_ECHOPAIR(", ", z);
734 734
     SERIAL_CHAR(')');
735
-
736
-    if (suffix) {serialprintPGM(suffix);}  //won't compile for Teensy with the previous construction
737
-    else SERIAL_EOL();
735
+    if (suffix) serialprintPGM(suffix); else SERIAL_EOL();
738 736
   }
739 737
 
740 738
   void print_xyz(const char* prefix, const char* suffix, const float xyz[]) {
@@ -6366,23 +6364,44 @@ inline void gcode_M42() {
6366 6364
               wait = parser.seen('W') ? parser.value_int() : 500;
6367 6365
 
6368 6366
     for (uint8_t pin = start; pin <= end; pin++) {
6367
+      //report_pin_state_extended(pin, I_flag, false);
6368
+
6369 6369
       if (!I_flag && pin_is_protected(pin)) {
6370
-        SERIAL_ECHOPAIR("Sensitive Pin: ", pin);
6371
-        SERIAL_ECHOLNPGM(" untouched.");
6370
+        report_pin_state_extended(pin, I_flag, true, "Untouched ");
6371
+        SERIAL_EOL();
6372 6372
       }
6373 6373
       else {
6374
-        SERIAL_ECHOPAIR("Pulsing Pin: ", pin);
6375
-        pinMode(pin, OUTPUT);
6376
-        for (int16_t j = 0; j < repeat; j++) {
6377
-          digitalWrite(pin, 0);
6378
-          safe_delay(wait);
6379
-          digitalWrite(pin, 1);
6380
-          safe_delay(wait);
6381
-          digitalWrite(pin, 0);
6382
-          safe_delay(wait);
6374
+        report_pin_state_extended(pin, I_flag, true, "Pulsing   ");
6375
+        #ifdef AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
6376
+          if (pin == 46) {
6377
+            SET_OUTPUT(46);
6378
+            for (int16_t j = 0; j < repeat; j++) {
6379
+              WRITE(46, 0); safe_delay(wait);
6380
+              WRITE(46, 1); safe_delay(wait);
6381
+              WRITE(46, 0); safe_delay(wait);
6382
+            }
6383
+          }
6384
+          else if (pin == 47) {
6385
+            SET_OUTPUT(47);
6386
+            for (int16_t j = 0; j < repeat; j++) {
6387
+              WRITE(47, 0); safe_delay(wait);
6388
+              WRITE(47, 1); safe_delay(wait);
6389
+              WRITE(47, 0); safe_delay(wait);
6390
+            }
6391
+          }
6392
+          else
6393
+        #endif
6394
+        {
6395
+          pinMode(pin, OUTPUT);
6396
+          for (int16_t j = 0; j < repeat; j++) {
6397
+            digitalWrite(pin, 0); safe_delay(wait);
6398
+            digitalWrite(pin, 1); safe_delay(wait);
6399
+            digitalWrite(pin, 0); safe_delay(wait);
6400
+          }
6383 6401
         }
6402
+
6384 6403
       }
6385
-      SERIAL_CHAR('\n');
6404
+      SERIAL_EOL();
6386 6405
     }
6387 6406
     SERIAL_ECHOLNPGM("Done.");
6388 6407
 
@@ -6527,13 +6546,13 @@ inline void gcode_M42() {
6527 6546
    *  M43 E<bool> - Enable / disable background endstop monitoring
6528 6547
    *                  - Machine continues to operate
6529 6548
    *                  - Reports changes to endstops
6530
-   *                  - Toggles LED when an endstop changes
6549
+   *                  - Toggles LED_PIN when an endstop changes
6531 6550
    *                  - Can not reliably catch the 5mS pulse from BLTouch type probes
6532 6551
    *
6533 6552
    *  M43 T       - Toggle pin(s) and report which pin is being toggled
6534 6553
    *                  S<pin>  - Start Pin number.   If not given, will default to 0
6535 6554
    *                  L<pin>  - End Pin number.   If not given, will default to last pin defined for this board
6536
-   *                  I       - Flag to ignore Marlin's pin protection.   Use with caution!!!!
6555
+   *                  I<bool> - Flag to ignore Marlin's pin protection.   Use with caution!!!!
6537 6556
    *                  R       - Repeat pulses on each pin this number of times before continueing to next pin
6538 6557
    *                  W       - Wait time (in miliseconds) between pulses.  If not given will default to 500
6539 6558
    *
@@ -6542,7 +6561,7 @@ inline void gcode_M42() {
6542 6561
    */
6543 6562
   inline void gcode_M43() {
6544 6563
 
6545
-    if (parser.seen('T')) {   // must be first ot else it's "S" and "E" parameters will execute endstop or servo test
6564
+    if (parser.seen('T')) {   // must be first or else it's "S" and "E" parameters will execute endstop or servo test
6546 6565
       toggle_pins();
6547 6566
       return;
6548 6567
     }
@@ -6576,6 +6595,7 @@ inline void gcode_M42() {
6576 6595
       for (int8_t pin = first_pin; pin <= last_pin; pin++) {
6577 6596
         if (pin_is_protected(pin) && !ignore_protection) continue;
6578 6597
         pinMode(pin, INPUT_PULLUP);
6598
+        delay(1);
6579 6599
         /*
6580 6600
           if (IS_ANALOG(pin))
6581 6601
             pin_state[pin - first_pin] = analogRead(pin - analogInputToDigitalPin(0)); // int16_t pin_state[...]
@@ -6591,7 +6611,7 @@ inline void gcode_M42() {
6591 6611
 
6592 6612
       for (;;) {
6593 6613
         for (int8_t pin = first_pin; pin <= last_pin; pin++) {
6594
-          if (pin_is_protected(pin)) continue;
6614
+          if (pin_is_protected(pin) && !ignore_protection) continue;
6595 6615
           const byte val =
6596 6616
             /*
6597 6617
               IS_ANALOG(pin)
@@ -6600,7 +6620,7 @@ inline void gcode_M42() {
6600 6620
             //*/
6601 6621
               digitalRead(pin);
6602 6622
           if (val != pin_state[pin - first_pin]) {
6603
-            report_pin_state(pin);
6623
+            report_pin_state_extended(pin, ignore_protection, false);
6604 6624
             pin_state[pin - first_pin] = val;
6605 6625
           }
6606 6626
         }
@@ -6612,14 +6632,14 @@ inline void gcode_M42() {
6612 6632
           }
6613 6633
         #endif
6614 6634
 
6615
-        safe_delay(500);
6635
+        safe_delay(200);
6616 6636
       }
6617 6637
       return;
6618 6638
     }
6619 6639
 
6620 6640
     // Report current state of selected pin(s)
6621 6641
     for (uint8_t pin = first_pin; pin <= last_pin; pin++)
6622
-      report_pin_state_extended(pin, ignore_protection);
6642
+      report_pin_state_extended(pin, ignore_protection, true);
6623 6643
   }
6624 6644
 
6625 6645
 #endif // PINS_DEBUGGING
@@ -12164,7 +12184,9 @@ void prepare_move_to_destination() {
12164 12184
     val &= 0x07;
12165 12185
     switch (digitalPinToTimer(pin)) {
12166 12186
       #ifdef TCCR0A
12167
-        case TIMER0A:
12187
+        #if !AVR_AT90USB1286_FAMILY
12188
+          case TIMER0A:
12189
+        #endif
12168 12190
         case TIMER0B:
12169 12191
           //_SET_CS(0, val);
12170 12192
           break;

+ 151
- 88
Marlin/pinsDebug.h Ver fichero

@@ -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
-}

+ 11
- 15
Marlin/pinsDebug_Teensyduino.h Ver fichero

@@ -25,21 +25,16 @@
25 25
 //  do not function the same as the other Arduino extensions
26 26
 //
27 27
 
28
+#ifndef __PINSDEBUG_TEENSYDUINO_H__
29
+#define __PINSDEBUG_TEENSYDUINO_H__
28 30
 
29
-#define TEENSYDUINO_IDE
31
+#undef NUM_DIGITAL_PINS
32
+#define NUM_DIGITAL_PINS 48  // Teensy says 46 but FASTIO is 48
30 33
 
31
-//digitalPinToTimer(pin) function works like Arduino but Timers are not defined
32
-#define TIMER0B 1
33
-#define TIMER1A 7
34
-#define TIMER1B 8
35
-#define TIMER1C 9
36
-#define TIMER2A 6
37
-#define TIMER2B 2
38
-#define TIMER3A 5
39
-#define TIMER3B 4
40
-#define TIMER3C 3
34
+// "digitalPinToPort" function just returns the pin number so need to create our own.
35
+// Can't use the name "digitalPinToPort" for our own because it interferes with the
36
+// FAST_PWM_FAN function if we do
41 37
 
42
-// digitalPinToPort function just returns the pin number so need to create our own
43 38
 #define PA 1
44 39
 #define PB 2
45 40
 #define PC 3
@@ -47,9 +42,8 @@
47 42
 #define PE 5
48 43
 #define PF 6
49 44
 
50
-#undef digitalPinToPort
51 45
 
52
-const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
46
+const uint8_t PROGMEM digital_pin_to_port_PGM_Teensy[] = {
53 47
   PD, // 0  - PD0 - INT0 - PWM
54 48
   PD, // 1  - PD1 - INT1 - PWM
55 49
   PD, // 2  - PD2 - INT2 - RX
@@ -100,7 +94,7 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
100 94
   PE, // 47 - PE3 (not defined in teensyduino)
101 95
 };
102 96
 
103
-#define digitalPinToPort(P) ( pgm_read_byte( digital_pin_to_port_PGM + (P) ) )
97
+#define digitalPinToPort_Teensy(P) ( pgm_read_byte( digital_pin_to_port_PGM_Teensy + (P) ) )
104 98
 
105 99
 // digitalPinToBitMask(pin) is OK
106 100
 
@@ -108,3 +102,5 @@ const uint8_t PROGMEM digital_pin_to_port_PGM[] = {
108 102
                                              // disable the PWMs so we can use it as is
109 103
 
110 104
 // portModeRegister(pin) is OK
105
+
106
+#endif // __PINSDEBUG_TEENSYDUINO_H__

+ 28
- 6
Marlin/pinsDebug_list.h Ver fichero

@@ -353,22 +353,22 @@
353 353
 #if defined(LCD_CONTRAST) && LCD_CONTRAST >= 0
354 354
   REPORT_NAME_DIGITAL(LCD_CONTRAST, __LINE__ )
355 355
 #endif
356
-#if PIN_EXISTS(LCD)
356
+#if defined(LCD_PINS_D4) && LCD_PINS_D4 >= 0
357 357
   REPORT_NAME_DIGITAL(LCD_PINS_D4, __LINE__ )
358 358
 #endif
359
-#if PIN_EXISTS(LCD)
359
+#if defined(LCD_PINS_D5) && LCD_PINS_D5 >= 0
360 360
   REPORT_NAME_DIGITAL(LCD_PINS_D5, __LINE__ )
361 361
 #endif
362
-#if PIN_EXISTS(LCD)
362
+#if defined(LCD_PINS_D6) && LCD_PINS_D6 >= 0
363 363
   REPORT_NAME_DIGITAL(LCD_PINS_D6, __LINE__ )
364 364
 #endif
365
-#if PIN_EXISTS(LCD)
365
+#if defined(LCD_PINS_D7) && LCD_PINS_D7 >= 0
366 366
   REPORT_NAME_DIGITAL(LCD_PINS_D7, __LINE__ )
367 367
 #endif
368
-#if PIN_EXISTS(LCD)
368
+#if defined(LCD_PINS_ENABLE) && LCD_PINS_ENABLE >= 0
369 369
   REPORT_NAME_DIGITAL(LCD_PINS_ENABLE, __LINE__ )
370 370
 #endif
371
-#if PIN_EXISTS(LCD)
371
+#if defined(LCD_PINS_RS) && LCD_PINS_RS >= 0
372 372
   REPORT_NAME_DIGITAL(LCD_PINS_RS, __LINE__ )
373 373
 #endif
374 374
 #if defined(LCD_SDSS) && LCD_SDSS >= 0
@@ -446,6 +446,18 @@
446 446
 #if PIN_EXISTS(RAMPS_D9)
447 447
   REPORT_NAME_DIGITAL(RAMPS_D9_PIN, __LINE__ )
448 448
 #endif
449
+#if PIN_EXISTS(RGB_LED_R)
450
+  REPORT_NAME_DIGITAL(RGB_LED_R_PIN, __LINE__ )
451
+#endif
452
+#if PIN_EXISTS(RGB_LED_G)
453
+  REPORT_NAME_DIGITAL(RGB_LED_G_PIN, __LINE__ )
454
+#endif
455
+#if PIN_EXISTS(RGB_LED_B)
456
+  REPORT_NAME_DIGITAL(RGB_LED_B_PIN, __LINE__ )
457
+#endif
458
+#if PIN_EXISTS(RGB_LED_W)
459
+  REPORT_NAME_DIGITAL(RGB_LED_W_PIN, __LINE__ )
460
+#endif
449 461
 #if PIN_EXISTS(RX_ENABLE)
450 462
   REPORT_NAME_DIGITAL(RX_ENABLE_PIN, __LINE__ )
451 463
 #endif
@@ -500,12 +512,21 @@
500 512
 #if PIN_EXISTS(SLEEP_WAKE)
501 513
   REPORT_NAME_DIGITAL(SLEEP_WAKE_PIN, __LINE__ )
502 514
 #endif
515
+#if PIN_EXISTS(SOL0)
516
+  REPORT_NAME_DIGITAL(SOL0_PIN, __LINE__ )
517
+#endif
503 518
 #if PIN_EXISTS(SOL1)
504 519
   REPORT_NAME_DIGITAL(SOL1_PIN, __LINE__ )
505 520
 #endif
506 521
 #if PIN_EXISTS(SOL2)
507 522
   REPORT_NAME_DIGITAL(SOL2_PIN, __LINE__ )
508 523
 #endif
524
+#if PIN_EXISTS(SOL3)
525
+  REPORT_NAME_DIGITAL(SOL3_PIN, __LINE__ )
526
+#endif
527
+#if PIN_EXISTS(SOL4)
528
+  REPORT_NAME_DIGITAL(SOL4_PIN, __LINE__ )
529
+#endif
509 530
 #if defined(SPARE_IO) && SPARE_IO >= 0
510 531
   REPORT_NAME_DIGITAL(SPARE_IO, __LINE__ )
511 532
 #endif
@@ -749,3 +770,4 @@
749 770
 #if PIN_EXISTS(Z2_STEP)
750 771
   REPORT_NAME_DIGITAL(Z2_STEP_PIN, __LINE__ )
751 772
 #endif
773
+

Loading…
Cancelar
Guardar