Browse Source

Fix M43 on LPC176x (#13587)

The real fix. PR #13568 was wrong.
Bob Kuhn 6 years ago
parent
commit
9a56d90150

+ 6
- 4
Marlin/src/HAL/HAL_LPC1768/HAL.cpp View File

52
   return result;
52
   return result;
53
 }
53
 }
54
 
54
 
55
+// scan command line for code
56
+//   return index into pin map array if found and the pin is valid.
57
+//   return dval if not found or not a valid pin.
55
 int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
58
 int16_t PARSED_PIN_INDEX(const char code, const int16_t dval) {
56
-  const uint16_t val = (uint16_t)parser.intval(code), port = val / 100, pin = val % 100;
57
-  const  int16_t ind = (port < (NUM_DIGITAL_PINS >> 5) && (pin < 32))
58
-                      ? GET_PIN_MAP_INDEX(port << 5 | pin) : -2;
59
-  return ind > -2 ? ind : dval;
59
+  const uint16_t val = (uint16_t)parser.intval(code, -1), port = val / 100, pin = val % 100;
60
+  const  int16_t ind = (port < ((NUM_DIGITAL_PINS) >> 5) && pin < 32) ? GET_PIN_MAP_INDEX((port << 5) | pin) : -2;
61
+  return ind > -1 ? ind : dval;
60
 }
62
 }
61
 
63
 
62
 void flashFirmware(int16_t value) {
64
 void flashFirmware(int16_t value) {

+ 6
- 0
Marlin/src/HAL/HAL_LPC1768/pinsDebug.h View File

40
 #define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
40
 #define PRINT_PIN(p) do {sprintf_P(buffer, PSTR("%d.%02d"), LPC1768_PIN_PORT(p), LPC1768_PIN_PIN(p)); SERIAL_ECHO(buffer);} while (0)
41
 #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
41
 #define MULTI_NAME_PAD 16 // space needed to be pretty if not first name assigned to a pin
42
 
42
 
43
+// pins that will cause hang/reset/disconnect in M43 Toggle and Watch utilities
44
+//  uses pin index
45
+#ifndef M43_NEVER_TOUCH
46
+  #define M43_NEVER_TOUCH(Q) ((Q) == 29 || (Q) == 30 || (Q) == 73)  // USB pins
47
+#endif
48
+
43
 // active ADC function/mode/code values for PINSEL registers
49
 // active ADC function/mode/code values for PINSEL registers
44
 constexpr int8_t ADC_pin_mode(pin_t pin) {
50
 constexpr int8_t ADC_pin_mode(pin_t pin) {
45
   return (LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 2  ? 2 :
51
   return (LPC1768_PIN_PORT(pin) == 0 && LPC1768_PIN_PIN(pin) == 2  ? 2 :

+ 8
- 8
Marlin/src/gcode/config/M43.cpp View File

47
 
47
 
48
   for (uint8_t i = start; i <= end; i++) {
48
   for (uint8_t i = start; i <= end; i++) {
49
     pin_t pin = GET_PIN_MAP_PIN(i);
49
     pin_t pin = GET_PIN_MAP_PIN(i);
50
-    //report_pin_state_extended(pin, ignore_protection, false);
51
     if (!VALID_PIN(pin)) continue;
50
     if (!VALID_PIN(pin)) continue;
52
-    if (!ignore_protection && pin_is_protected(pin)) {
51
+    if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) {
53
       report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
52
       report_pin_state_extended(pin, ignore_protection, true, "Untouched ");
54
       SERIAL_EOL();
53
       SERIAL_EOL();
55
     }
54
     }
56
     else {
55
     else {
56
+      watchdog_reset();
57
       report_pin_state_extended(pin, ignore_protection, true, "Pulsing   ");
57
       report_pin_state_extended(pin, ignore_protection, true, "Pulsing   ");
58
       #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
58
       #if AVR_AT90USB1286_FAMILY // Teensy IDEs don't know about these pins so must use FASTIO
59
         if (pin == TEENSY_E2) {
59
         if (pin == TEENSY_E2) {
77
       {
77
       {
78
         pinMode(pin, OUTPUT);
78
         pinMode(pin, OUTPUT);
79
         for (int16_t j = 0; j < repeat; j++) {
79
         for (int16_t j = 0; j < repeat; j++) {
80
-          extDigitalWrite(pin, 0); safe_delay(wait);
81
-          extDigitalWrite(pin, 1); safe_delay(wait);
82
-          extDigitalWrite(pin, 0); safe_delay(wait);
80
+          watchdog_reset(); extDigitalWrite(pin, 0); safe_delay(wait);
81
+          watchdog_reset(); extDigitalWrite(pin, 1); safe_delay(wait);
82
+          watchdog_reset(); extDigitalWrite(pin, 0); safe_delay(wait);
83
+          watchdog_reset();
83
         }
84
         }
84
       }
85
       }
85
-
86
     }
86
     }
87
     SERIAL_EOL();
87
     SERIAL_EOL();
88
   }
88
   }
277
     for (uint8_t i = first_pin; i <= last_pin; i++) {
277
     for (uint8_t i = first_pin; i <= last_pin; i++) {
278
       pin_t pin = GET_PIN_MAP_PIN(i);
278
       pin_t pin = GET_PIN_MAP_PIN(i);
279
       if (!VALID_PIN(pin)) continue;
279
       if (!VALID_PIN(pin)) continue;
280
-      if (!ignore_protection && pin_is_protected(pin)) continue;
280
+      if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
281
       pinMode(pin, INPUT_PULLUP);
281
       pinMode(pin, INPUT_PULLUP);
282
       delay(1);
282
       delay(1);
283
       /*
283
       /*
300
       for (uint8_t i = first_pin; i <= last_pin; i++) {
300
       for (uint8_t i = first_pin; i <= last_pin; i++) {
301
         pin_t pin = GET_PIN_MAP_PIN(i);
301
         pin_t pin = GET_PIN_MAP_PIN(i);
302
         if (!VALID_PIN(pin)) continue;
302
         if (!VALID_PIN(pin)) continue;
303
-        if (!ignore_protection && pin_is_protected(pin)) continue;
303
+        if (M43_NEVER_TOUCH(i) || (!ignore_protection && pin_is_protected(pin))) continue;
304
         const byte val =
304
         const byte val =
305
           /*
305
           /*
306
             IS_ANALOG(pin)
306
             IS_ANALOG(pin)

+ 3
- 0
Marlin/src/pins/pinsDebug.h View File

102
 
102
 
103
 #include HAL_PATH(../HAL, pinsDebug.h)  // get the correct support file for this CPU
103
 #include HAL_PATH(../HAL, pinsDebug.h)  // get the correct support file for this CPU
104
 
104
 
105
+#ifndef M43_NEVER_TOUCH
106
+  #define M43_NEVER_TOUCH(Q) false
107
+#endif
105
 
108
 
106
 static void print_input_or_output(const bool isout) {
109
 static void print_input_or_output(const bool isout) {
107
   serialprintPGM(isout ? PSTR("Output = ") : PSTR("Input  = "));
110
   serialprintPGM(isout ? PSTR("Output = ") : PSTR("Input  = "));

Loading…
Cancel
Save