Selaa lähdekoodia

Add USB serial support to SERIAL_PORT_2 on DUE (#17245)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
ellensp 4 vuotta sitten
vanhempi
commit
cd4060a99c
No account linked to committer's email address

+ 0
- 1
Marlin/src/HAL/DUE/HAL.h Näytä tiedosto

@@ -94,7 +94,6 @@
94 94
   #endif
95 95
 #endif
96 96
 
97
-
98 97
 #include "MarlinSerial.h"
99 98
 #include "MarlinSerialUSB.h"
100 99
 

+ 5
- 15
Marlin/src/HAL/DUE/MarlinSerial.cpp Näytä tiedosto

@@ -629,23 +629,13 @@ void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
629 629
 
630 630
 // If not using the USB port as serial port
631 631
 #if SERIAL_PORT >= 0
632
-
633
-  // Preinstantiate
634
-  template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;
635
-
636
-  // Instantiate
637
-  MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
638
-
632
+  template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;      // Define
633
+  MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;   // Instantiate
639 634
 #endif
640 635
 
641
-#ifdef SERIAL_PORT_2
642
-
643
-  // Preinstantiate
644
-  template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>;
645
-
646
-  // Instantiate
647
-  MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
648
-
636
+#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
637
+  template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>;    // Define
638
+  MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2; // Instantiate
649 639
 #endif
650 640
 
651 641
 #endif // ARDUINO_ARCH_SAM

+ 2
- 6
Marlin/src/HAL/DUE/MarlinSerial.h Näytä tiedosto

@@ -172,13 +172,9 @@ struct MarlinSerialCfg {
172 172
 };
173 173
 
174 174
 #if SERIAL_PORT >= 0
175
-
176 175
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
176
+#endif
177 177
 
178
-#endif // SERIAL_PORT >= 0
179
-
180
-#ifdef SERIAL_PORT_2
181
-
178
+#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
182 179
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
183
-
184 180
 #endif

+ 8
- 4
Marlin/src/HAL/DUE/MarlinSerialUSB.cpp Näytä tiedosto

@@ -29,7 +29,7 @@
29 29
 
30 30
 #include "../../inc/MarlinConfig.h"
31 31
 
32
-#if SERIAL_PORT == -1
32
+#if HAS_USB_SERIAL
33 33
 
34 34
 #include "MarlinSerialUSB.h"
35 35
 
@@ -283,8 +283,12 @@ void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
283 283
 }
284 284
 
285 285
 // Preinstantiate
286
-MarlinSerialUSB customizedSerial1;
287
-
288
-#endif // SERIAL_PORT == -1
286
+#if SERIAL_PORT == -1
287
+  MarlinSerialUSB customizedSerial1;
288
+#endif
289
+#if SERIAL_PORT_2 == -1
290
+  MarlinSerialUSB customizedSerial2;
291
+#endif
289 292
 
293
+#endif // HAS_USB_SERIAL
290 294
 #endif // ARDUINO_ARCH_SAM

+ 9
- 3
Marlin/src/HAL/DUE/MarlinSerialUSB.h Näytä tiedosto

@@ -28,7 +28,7 @@
28 28
 
29 29
 #include "../../inc/MarlinConfig.h"
30 30
 
31
-#if SERIAL_PORT == -1
31
+#if HAS_USB_SERIAL
32 32
 
33 33
 #include <WString.h>
34 34
 
@@ -88,6 +88,12 @@ private:
88 88
   static void printFloat(double, uint8_t);
89 89
 };
90 90
 
91
-extern MarlinSerialUSB customizedSerial1;
91
+#if SERIAL_PORT == -1
92
+  extern MarlinSerialUSB customizedSerial1;
93
+#endif
94
+
95
+#if SERIAL_PORT_2 == -1
96
+  extern MarlinSerialUSB customizedSerial2;
97
+#endif
92 98
 
93
-#endif // SERIAL_PORT == -1
99
+#endif // HAS_USB_SERIAL

+ 4
- 0
Marlin/src/inc/Conditionals_LCD.h Näytä tiedosto

@@ -683,6 +683,10 @@
683 683
   #define SPI_SPEED SPI_FULL_SPEED
684 684
 #endif
685 685
 
686
+#if SERIAL_PORT == -1 || SERIAL_PORT_2 == -1
687
+  #define HAS_USB_SERIAL 1
688
+#endif
689
+
686 690
 /**
687 691
  * This setting is also used by M109 when trying to calculate
688 692
  * a ballpark safe margin to prevent wait-forever situation.

Loading…
Peruuta
Tallenna