Ver código fonte

🧑‍💻 Clarify MSerialUSB, drop HardwareSerial workaround

Scott Lahteine 2 anos atrás
pai
commit
66e32cb0fa

+ 0
- 1
Marlin/src/HAL/AVR/HAL.h Ver arquivo

32
 #ifdef USBCON
32
 #ifdef USBCON
33
   #include <HardwareSerial.h>
33
   #include <HardwareSerial.h>
34
 #else
34
 #else
35
-  #define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
36
   #include "MarlinSerial.h"
35
   #include "MarlinSerial.h"
37
 #endif
36
 #endif
38
 
37
 

+ 1
- 1
Marlin/src/HAL/STM32/HAL.cpp Ver arquivo

31
 #include "../shared/Delay.h"
31
 #include "../shared/Delay.h"
32
 
32
 
33
 #ifdef USBCON
33
 #ifdef USBCON
34
-  DefaultSerial1 MSerial0(false, SerialUSB);
34
+  DefaultSerial1 MSerialUSB(false, SerialUSB);
35
 #endif
35
 #endif
36
 
36
 
37
 #if ENABLED(SRAM_EEPROM_EMULATION)
37
 #if ENABLED(SRAM_EEPROM_EMULATION)

+ 31
- 21
Marlin/src/HAL/STM32/HAL.h Ver arquivo

51
   #include <USBSerial.h>
51
   #include <USBSerial.h>
52
   #include "../../core/serial_hook.h"
52
   #include "../../core/serial_hook.h"
53
   typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
53
   typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
54
-  extern DefaultSerial1 MSerial0;
54
+  extern DefaultSerial1 MSerialUSB;
55
 #endif
55
 #endif
56
 
56
 
57
 #define _MSERIAL(X) MSerial##X
57
 #define _MSERIAL(X) MSerial##X
58
 #define MSERIAL(X) _MSERIAL(X)
58
 #define MSERIAL(X) _MSERIAL(X)
59
 
59
 
60
-#if SERIAL_PORT == -1
61
-  #define MYSERIAL1 MSerial0
62
-#elif WITHIN(SERIAL_PORT, 1, 6)
60
+#if WITHIN(SERIAL_PORT, 1, 6)
63
   #define MYSERIAL1 MSERIAL(SERIAL_PORT)
61
   #define MYSERIAL1 MSERIAL(SERIAL_PORT)
62
+#elif !defined(USBCON)
63
+  #error "SERIAL_PORT must be from 1 to 6."
64
+#elif SERIAL_PORT == -1
65
+  #define MYSERIAL1 MSerialUSB
64
 #else
66
 #else
65
-  #error "SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
67
+  #error "SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
66
 #endif
68
 #endif
67
 
69
 
68
 #ifdef SERIAL_PORT_2
70
 #ifdef SERIAL_PORT_2
69
-  #if SERIAL_PORT_2 == -1
70
-    #define MYSERIAL2 MSerial0
71
-  #elif WITHIN(SERIAL_PORT_2, 1, 6)
71
+  #if WITHIN(SERIAL_PORT_2, 1, 6)
72
     #define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
72
     #define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
73
+  #elif !defined(USBCON)
74
+    #error "SERIAL_PORT must be from 1 to 6."
75
+  #elif SERIAL_PORT_2 == -1
76
+    #define MYSERIAL2 MSerialUSB
73
   #else
77
   #else
74
-    #error "SERIAL_PORT_2 must be from 1 to 6. You can also use -1 if the board supports Native USB."
78
+    #error "SERIAL_PORT_2 must be from 1 to 6, or -1 for Native USB."
75
   #endif
79
   #endif
76
 #endif
80
 #endif
77
 
81
 
78
 #ifdef SERIAL_PORT_3
82
 #ifdef SERIAL_PORT_3
79
-  #if SERIAL_PORT_3 == -1
80
-    #define MYSERIAL3 MSerial0
81
-  #elif WITHIN(SERIAL_PORT_3, 1, 6)
83
+  #if WITHIN(SERIAL_PORT_3, 1, 6)
82
     #define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
84
     #define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
85
+  #elif !defined(USBCON)
86
+    #error "SERIAL_PORT must be from 1 to 6."
87
+  #elif SERIAL_PORT_3 == -1
88
+    #define MYSERIAL3 MSerialUSB
83
   #else
89
   #else
84
-    #error "SERIAL_PORT_3 must be from 1 to 6. You can also use -1 if the board supports Native USB."
90
+    #error "SERIAL_PORT_3 must be from 1 to 6, or -1 for Native USB."
85
   #endif
91
   #endif
86
 #endif
92
 #endif
87
 
93
 
88
 #ifdef MMU2_SERIAL_PORT
94
 #ifdef MMU2_SERIAL_PORT
89
-  #if MMU2_SERIAL_PORT == -1
90
-    #define MMU2_SERIAL MSerial0
91
-  #elif WITHIN(MMU2_SERIAL_PORT, 1, 6)
95
+  #if WITHIN(MMU2_SERIAL_PORT, 1, 6)
92
     #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
96
     #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
97
+  #elif !defined(USBCON)
98
+    #error "SERIAL_PORT must be from 1 to 6."
99
+  #elif MMU2_SERIAL_PORT == -1
100
+    #define MMU2_SERIAL MSerialUSB
93
   #else
101
   #else
94
-    #error "MMU2_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
102
+    #error "MMU2_SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
95
   #endif
103
   #endif
96
 #endif
104
 #endif
97
 
105
 
98
 #ifdef LCD_SERIAL_PORT
106
 #ifdef LCD_SERIAL_PORT
99
-  #if LCD_SERIAL_PORT == -1
100
-    #define LCD_SERIAL MSerial0
101
-  #elif WITHIN(LCD_SERIAL_PORT, 1, 6)
107
+  #if WITHIN(LCD_SERIAL_PORT, 1, 6)
102
     #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
108
     #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
109
+  #elif !defined(USBCON)
110
+    #error "SERIAL_PORT must be from 1 to 6."
111
+  #elif LCD_SERIAL_PORT == -1
112
+    #define LCD_SERIAL MSerialUSB
103
   #else
113
   #else
104
-    #error "LCD_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
114
+    #error "LCD_SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
105
   #endif
115
   #endif
106
   #if HAS_DGUS_LCD
116
   #if HAS_DGUS_LCD
107
     #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()
117
     #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()

+ 1
- 1
Marlin/src/core/serial_hook.h Ver arquivo

300
 // Build the actual serial object depending on current configuration
300
 // Build the actual serial object depending on current configuration
301
 #define Serial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, BaseSerial)
301
 #define Serial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, BaseSerial)
302
 #define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial)
302
 #define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial)
303
-#ifdef HAS_MULTI_SERIAL
303
+#if HAS_MULTI_SERIAL
304
   #define Serial2Class ConditionalSerial
304
   #define Serial2Class ConditionalSerial
305
   #if NUM_SERIAL >= 3
305
   #if NUM_SERIAL >= 3
306
     #define Serial3Class ConditionalSerial
306
     #define Serial3Class ConditionalSerial

Carregando…
Cancelar
Salvar