소스 검색

Clean up pins debugging

Scott Lahteine 5 년 전
부모
커밋
ca4423ed2a
3개의 변경된 파일71개의 추가작업 그리고 40개의 파일을 삭제
  1. 2
    2
      Marlin/src/gcode/config/M43.cpp
  2. 40
    0
      Marlin/src/pins/pins.h
  3. 29
    38
      Marlin/src/pins/pinsDebug.h

+ 2
- 2
Marlin/src/gcode/config/M43.cpp 파일 보기

61
     pin_t pin = GET_PIN_MAP_PIN_M43(i);
61
     pin_t pin = GET_PIN_MAP_PIN_M43(i);
62
     if (!VALID_PIN(pin)) continue;
62
     if (!VALID_PIN(pin)) continue;
63
     if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
63
     if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
64
-      report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
64
+      report_pin_state_extended(pin, ignore_protection, true, PSTR("Untouched "));
65
       SERIAL_EOL();
65
       SERIAL_EOL();
66
     }
66
     }
67
     else {
67
     else {
68
       watchdog_refresh();
68
       watchdog_refresh();
69
-      report_pin_state_extended(pin, ignore_protection, true, "Pulsing   ");
69
+      report_pin_state_extended(pin, ignore_protection, true, PSTR("Pulsing   "));
70
       #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
70
       #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
71
         if (pin == TEENSY_E2) {
71
         if (pin == TEENSY_E2) {
72
           SET_OUTPUT(TEENSY_E2);
72
           SET_OUTPUT(TEENSY_E2);

+ 40
- 0
Marlin/src/pins/pins.h 파일 보기

862
   #define E7_ENABLE_PIN -1
862
   #define E7_ENABLE_PIN -1
863
 #endif
863
 #endif
864
 
864
 
865
+//
866
+// Destroy unused CS pins
867
+//
868
+#if !AXIS_HAS_SPI(X)
869
+  #undef X_CS_PIN
870
+#endif
871
+#if !AXIS_HAS_SPI(Y)
872
+  #undef Y_CS_PIN
873
+#endif
874
+#if !AXIS_HAS_SPI(Z)
875
+  #undef Z_CS_PIN
876
+#endif
877
+#if !AXIS_HAS_SPI(E0)
878
+  #undef E0_CS_PIN
879
+#endif
880
+#if !AXIS_HAS_SPI(E1)
881
+  #undef E1_CS_PIN
882
+#endif
883
+#if !AXIS_HAS_SPI(E2)
884
+  #undef E2_CS_PIN
885
+#endif
886
+#if !AXIS_HAS_SPI(E3)
887
+  #undef E3_CS_PIN
888
+#endif
889
+#if !AXIS_HAS_SPI(E4)
890
+  #undef E4_CS_PIN
891
+#endif
892
+#if !AXIS_HAS_SPI(E5)
893
+  #undef E5_CS_PIN
894
+#endif
895
+#if !AXIS_HAS_SPI(E6)
896
+  #undef E6_CS_PIN
897
+#endif
898
+#if !AXIS_HAS_SPI(E7)
899
+  #undef E7_CS_PIN
900
+#endif
901
+
865
 #ifndef X_CS_PIN
902
 #ifndef X_CS_PIN
866
   #define X_CS_PIN -1
903
   #define X_CS_PIN -1
867
 #endif
904
 #endif
1170
 
1207
 
1171
 #if HAS_FILAMENT_SENSOR
1208
 #if HAS_FILAMENT_SENSOR
1172
   #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
1209
   #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
1210
+#else
1211
+  #undef FIL_RUNOUT_PIN
1212
+  #undef FIL_RUNOUT1_PIN
1173
 #endif
1213
 #endif
1174
 
1214
 
1175
 #ifndef LCD_PINS_D4
1215
 #ifndef LCD_PINS_D4

+ 29
- 38
Marlin/src/pins/pinsDebug.h 파일 보기

207
 }
207
 }
208
 
208
 
209
 // pretty report with PWM info
209
 // pretty report with PWM info
210
-inline void report_pin_state_extended(pin_t pin, bool ignore, bool extended = false, const char *start_string = "") {
210
+inline void report_pin_state_extended(const pin_t pin, const bool ignore, const bool extended=false, PGM_P const start_string=nullptr) {
211
   char buffer[MAX_NAME_LENGTH + 1];   // for the sprintf statements
211
   char buffer[MAX_NAME_LENGTH + 1];   // for the sprintf statements
212
   bool found = false, multi_name_pin = false;
212
   bool found = false, multi_name_pin = false;
213
 
213
 
214
+  auto alt_pin_echo = [](const pin_t &pin) {
215
+    #if AVR_AT90USB1286_FAMILY
216
+      // Use FastIO for pins Teensy doesn't expose
217
+      if (pin == 46) {
218
+        print_input_or_output(IS_OUTPUT(46));
219
+        SERIAL_CHAR('0' + READ(46));
220
+        return false;
221
+      }
222
+      else if (pin == 47) {
223
+        print_input_or_output(IS_OUTPUT(47));
224
+        SERIAL_CHAR('0' + READ(47));
225
+        return false;
226
+      }
227
+    #endif
228
+    return true;
229
+  };
230
+
214
   for (uint8_t x = 0; x < COUNT(pin_array); x++)  {    // scan entire array and report all instances of this pin
231
   for (uint8_t x = 0; x < COUNT(pin_array); x++)  {    // scan entire array and report all instances of this pin
215
     if (GET_ARRAY_PIN(x) == pin) {
232
     if (GET_ARRAY_PIN(x) == pin) {
216
-      if (found) multi_name_pin = true;
217
-      found = true;
218
-      if (!multi_name_pin) {    // report digital and analog pin number only on the first time through
219
-        sprintf_P(buffer, PSTR("%sPIN: "), start_string);     // digital pin number
220
-        SERIAL_ECHO(buffer);
233
+      if (!found) {    // report digital and analog pin number only on the first time through
234
+        if (start_string) serialprintPGM(start_string);
235
+        serialprintPGM(PSTR("PIN: "));
221
         PRINT_PIN(pin);
236
         PRINT_PIN(pin);
222
         PRINT_PORT(pin);
237
         PRINT_PORT(pin);
223
         if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
238
         if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
228
       }
243
       }
229
       else {
244
       else {
230
         SERIAL_CHAR('.');
245
         SERIAL_CHAR('.');
231
-        SERIAL_ECHO_SP(MULTI_NAME_PAD + strlen(start_string));  // add padding if not the first instance found
246
+        SERIAL_ECHO_SP(MULTI_NAME_PAD + (start_string ? strlen_P(start_string) : 0));  // add padding if not the first instance found
232
       }
247
       }
233
       PRINT_ARRAY_NAME(x);
248
       PRINT_ARRAY_NAME(x);
234
       if (extended) {
249
       if (extended) {
235
         if (pin_is_protected(pin) && !ignore)
250
         if (pin_is_protected(pin) && !ignore)
236
           SERIAL_ECHOPGM("protected ");
251
           SERIAL_ECHOPGM("protected ");
237
         else {
252
         else {
238
-          #if AVR_AT90USB1286_FAMILY //Teensy IDEs don't know about these pins so must use FASTIO
239
-            if (pin == 46 || pin == 47) {
240
-              if (pin == 46) {
241
-                print_input_or_output(IS_OUTPUT(46));
242
-                SERIAL_CHAR('0' + READ(46));
243
-              }
244
-              else if (pin == 47) {
245
-                print_input_or_output(IS_OUTPUT(47));
246
-                SERIAL_CHAR('0' + READ(47));
247
-              }
248
-            }
249
-            else
250
-          #endif
251
-          {
253
+          if (alt_pin_echo(pin)) {
252
             if (!GET_ARRAY_IS_DIGITAL(x)) {
254
             if (!GET_ARRAY_IS_DIGITAL(x)) {
253
               sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
255
               sprintf_P(buffer, PSTR("Analog in = %5ld"), (long)analogRead(DIGITAL_PIN_TO_ANALOG_PIN(pin)));
254
               SERIAL_ECHO(buffer);
256
               SERIAL_ECHO(buffer);
274
         }
276
         }
275
       }
277
       }
276
       SERIAL_EOL();
278
       SERIAL_EOL();
279
+      multi_name_pin = found;
280
+      found = true;
277
     }  // end of IF
281
     }  // end of IF
278
   } // end of for loop
282
   } // end of for loop
279
 
283
 
280
   if (!found) {
284
   if (!found) {
281
-    sprintf_P(buffer, PSTR("%sPIN: "), start_string);
282
-    SERIAL_ECHO(buffer);
285
+    if (start_string) serialprintPGM(start_string);
286
+    serialprintPGM(PSTR("PIN: "));
283
     PRINT_PIN(pin);
287
     PRINT_PIN(pin);
284
     PRINT_PORT(pin);
288
     PRINT_PORT(pin);
285
     if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
289
     if (int8_t(DIGITAL_PIN_TO_ANALOG_PIN(pin)) >= 0) {
290
       SERIAL_ECHO_SP(8);   // add padding if not an analog pin
294
       SERIAL_ECHO_SP(8);   // add padding if not an analog pin
291
     SERIAL_ECHOPGM("<unused/unknown>");
295
     SERIAL_ECHOPGM("<unused/unknown>");
292
     if (extended) {
296
     if (extended) {
293
-      #if AVR_AT90USB1286_FAMILY  //Teensy IDEs don't know about these pins so must use FASTIO
294
-        if (pin == 46 || pin == 47) {
295
-          SERIAL_ECHO_SP(12);
296
-          if (pin == 46) {
297
-            print_input_or_output(IS_OUTPUT(46));
298
-            SERIAL_CHAR('0' + READ(46));
299
-          }
300
-          else {
301
-            print_input_or_output(IS_OUTPUT(47));
302
-            SERIAL_CHAR('0' + READ(47));
303
-          }
304
-        }
305
-        else
306
-      #endif
307
-      {
297
+
298
+      if (alt_pin_echo(pin)) {
308
         if (pwm_status(pin)) {
299
         if (pwm_status(pin)) {
309
           // do nothing
300
           // do nothing
310
         }
301
         }

Loading…
취소
저장