浏览代码

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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
ellensp 5 年前
父节点
当前提交
cd4060a99c
没有帐户链接到提交者的电子邮件

+ 0
- 1
Marlin/src/HAL/DUE/HAL.h 查看文件

94
   #endif
94
   #endif
95
 #endif
95
 #endif
96
 
96
 
97
-
98
 #include "MarlinSerial.h"
97
 #include "MarlinSerial.h"
99
 #include "MarlinSerialUSB.h"
98
 #include "MarlinSerialUSB.h"
100
 
99
 

+ 5
- 15
Marlin/src/HAL/DUE/MarlinSerial.cpp 查看文件

629
 
629
 
630
 // If not using the USB port as serial port
630
 // If not using the USB port as serial port
631
 #if SERIAL_PORT >= 0
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
 #endif
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
 #endif
639
 #endif
650
 
640
 
651
 #endif // ARDUINO_ARCH_SAM
641
 #endif // ARDUINO_ARCH_SAM

+ 2
- 6
Marlin/src/HAL/DUE/MarlinSerial.h 查看文件

172
 };
172
 };
173
 
173
 
174
 #if SERIAL_PORT >= 0
174
 #if SERIAL_PORT >= 0
175
-
176
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
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
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
179
   extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
183
-
184
 #endif
180
 #endif

+ 8
- 4
Marlin/src/HAL/DUE/MarlinSerialUSB.cpp 查看文件

29
 
29
 
30
 #include "../../inc/MarlinConfig.h"
30
 #include "../../inc/MarlinConfig.h"
31
 
31
 
32
-#if SERIAL_PORT == -1
32
+#if HAS_USB_SERIAL
33
 
33
 
34
 #include "MarlinSerialUSB.h"
34
 #include "MarlinSerialUSB.h"
35
 
35
 
283
 }
283
 }
284
 
284
 
285
 // Preinstantiate
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
 #endif // ARDUINO_ARCH_SAM
294
 #endif // ARDUINO_ARCH_SAM

+ 9
- 3
Marlin/src/HAL/DUE/MarlinSerialUSB.h 查看文件

28
 
28
 
29
 #include "../../inc/MarlinConfig.h"
29
 #include "../../inc/MarlinConfig.h"
30
 
30
 
31
-#if SERIAL_PORT == -1
31
+#if HAS_USB_SERIAL
32
 
32
 
33
 #include <WString.h>
33
 #include <WString.h>
34
 
34
 
88
   static void printFloat(double, uint8_t);
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 查看文件

683
   #define SPI_SPEED SPI_FULL_SPEED
683
   #define SPI_SPEED SPI_FULL_SPEED
684
 #endif
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
  * This setting is also used by M109 when trying to calculate
691
  * This setting is also used by M109 when trying to calculate
688
  * a ballpark safe margin to prevent wait-forever situation.
692
  * a ballpark safe margin to prevent wait-forever situation.

正在加载...
取消
保存