diff --git a/Marlin/src/HAL/AVR/HAL.cpp b/Marlin/src/HAL/AVR/HAL.cpp index 4c45a5d78e..cfa9e47f18 100644 --- a/Marlin/src/HAL/AVR/HAL.cpp +++ b/Marlin/src/HAL/AVR/HAL.cpp @@ -25,7 +25,7 @@ #include "HAL.h" #ifdef USBCON - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #ifdef BLUETOOTH BTSerial btSerial(false, bluetoothSerial); #endif diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 5e22ac0836..f6adf1bd31 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -83,25 +83,25 @@ typedef int8_t pin_t; // Serial ports #ifdef USBCON #include "../../core/serial_hook.h" - typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; + extern DefaultSerial1 MSerial0; #ifdef BLUETOOTH - typedef ForwardSerial0Type< decltype(bluetoothSerial) > BTSerial; + typedef ForwardSerial1Class< decltype(bluetoothSerial) > BTSerial; extern BTSerial btSerial; #endif - #define MYSERIAL0 TERN(BLUETOOTH, btSerial, MSerial) + #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else #if !WITHIN(SERIAL_PORT, -1, 3) #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif - #define MYSERIAL0 customizedSerial1 + #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 #if !WITHIN(SERIAL_PORT_2, -1, 3) #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif - #define MYSERIAL1 customizedSerial2 + #define MYSERIAL2 customizedSerial2 #endif #endif diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 9abc3dbed0..ab49e9440a 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -238,11 +238,11 @@ static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED); }; - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #ifdef SERIAL_PORT_2 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT2; extern MSerialT2 customizedSerial2; #endif @@ -262,7 +262,7 @@ static constexpr bool RX_OVERRUNS = false; }; - typedef Serial0Type< MarlinSerial< MMU2SerialCfg > > MSerialT3; + typedef Serial1Class< MarlinSerial< MMU2SerialCfg > > MSerialT3; extern MSerialT3 mmuSerial; #endif @@ -292,12 +292,12 @@ }; - typedef Serial0Type< MarlinSerial< LCDSerialCfg > > MSerialT4; + typedef Serial1Class< MarlinSerial< LCDSerialCfg > > MSerialT4; extern MSerialT4 lcdSerial; #endif // Use the UART for Bluetooth in AT90USB configurations #if defined(USBCON) && ENABLED(BLUETOOTH) - typedef Serial0Type MSerialT5; + typedef Serial1Class MSerialT5; extern MSerialT5 bluetoothSerial; #endif diff --git a/Marlin/src/HAL/DUE/HAL.cpp b/Marlin/src/HAL/DUE/HAL.cpp index 034b86ccb0..0e4caa47ac 100644 --- a/Marlin/src/HAL/DUE/HAL.cpp +++ b/Marlin/src/HAL/DUE/HAL.cpp @@ -107,16 +107,16 @@ uint16_t HAL_adc_get_result() { // Forward the default serial ports #if ANY_SERIAL_IS(0) - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #endif #if ANY_SERIAL_IS(1) - DefaultSerial1 MSerial1(false, Serial1); + DefaultSerial2 MSerial1(false, Serial1); #endif #if ANY_SERIAL_IS(2) - DefaultSerial2 MSerial2(false, Serial2); + DefaultSerial3 MSerial2(false, Serial2); #endif #if ANY_SERIAL_IS(3) - DefaultSerial3 MSerial3(false, Serial3); + DefaultSerial4 MSerial3(false, Serial3); #endif #endif // ARDUINO_ARCH_SAM diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index b1c6a38c0f..095538f6a6 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -38,33 +38,32 @@ #include "../../core/serial_hook.h" -typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; -typedef ForwardSerial0Type< decltype(Serial1) > DefaultSerial1; -typedef ForwardSerial0Type< decltype(Serial2) > DefaultSerial2; -typedef ForwardSerial0Type< decltype(Serial3) > DefaultSerial3; -extern DefaultSerial MSerial; -extern DefaultSerial1 MSerial1; -extern DefaultSerial2 MSerial2; -extern DefaultSerial3 MSerial3; +typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; +typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; +typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; +typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4; +extern DefaultSerial1 MSerial0; +extern DefaultSerial2 MSerial1; +extern DefaultSerial3 MSerial2; +extern DefaultSerial4 MSerial3; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial -// Define MYSERIAL0/1 before MarlinSerial includes! +// Define MYSERIAL1/2 before MarlinSerial includes! #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) - #define MYSERIAL0 customizedSerial1 + #define MYSERIAL1 customizedSerial1 #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 || ENABLED(EMERGENCY_PARSER) - #define MYSERIAL1 customizedSerial2 + #define MYSERIAL2 customizedSerial2 #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index 7fc21264bb..e74d234b4a 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -141,11 +141,11 @@ struct MarlinSerialCfg { }; #if SERIAL_PORT >= 0 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; extern MSerialT customizedSerial1; #endif #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 - typedef Serial0Type< MarlinSerial< MarlinSerialCfg > > MSerialT2; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT2; extern MSerialT2 customizedSerial2; #endif diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.h b/Marlin/src/HAL/DUE/MarlinSerialUSB.h index f9cea29869..4c299dced5 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.h +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.h @@ -50,7 +50,7 @@ struct MarlinSerialUSB { FORCE_INLINE int rxMaxEnqueued() { return 0; } #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; #if SERIAL_PORT == -1 extern MSerialT customizedSerial1; diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp index 9e2f4c1d96..145662215a 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.cpp @@ -24,6 +24,6 @@ #include "FlushableHardwareSerial.h" -Serial0Type flushableSerial(false, 0); +Serial1Class flushableSerial(false, 0); #endif diff --git a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h index d2762c0efa..012dda8626 100644 --- a/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h +++ b/Marlin/src/HAL/ESP32/FlushableHardwareSerial.h @@ -31,4 +31,4 @@ public: FlushableHardwareSerial(int uart_nr) : HardwareSerial(uart_nr) {} }; -extern Serial0Type flushableSerial; +extern Serial1Class flushableSerial; diff --git a/Marlin/src/HAL/ESP32/HAL.cpp b/Marlin/src/HAL/ESP32/HAL.cpp index ab28595071..365706c3e2 100644 --- a/Marlin/src/HAL/ESP32/HAL.cpp +++ b/Marlin/src/HAL/ESP32/HAL.cpp @@ -41,7 +41,7 @@ #endif #if ENABLED(ESP3D_WIFISUPPORT) - DefaultSerial MSerial(false, Serial2Socket); + DefaultSerial1 MSerial0(false, Serial2Socket); #endif // ------------------------ diff --git a/Marlin/src/HAL/ESP32/HAL.h b/Marlin/src/HAL/ESP32/HAL.h index 4d1db571d0..9258f97702 100644 --- a/Marlin/src/HAL/ESP32/HAL.h +++ b/Marlin/src/HAL/ESP32/HAL.h @@ -51,15 +51,15 @@ extern portMUX_TYPE spinlock; -#define MYSERIAL0 flushableSerial +#define MYSERIAL1 flushableSerial #if EITHER(WIFISUPPORT, ESP3D_WIFISUPPORT) #if ENABLED(ESP3D_WIFISUPPORT) - typedef ForwardSerial0Type< decltype(Serial2Socket) > DefaultSerial; - extern DefaultSerial MSerial; - #define MYSERIAL1 MSerial + typedef ForwardSerial1Class< decltype(Serial2Socket) > DefaultSerial1; + extern DefaultSerial1 MSerial0; + #define MYSERIAL2 MSerial0 #else - #define MYSERIAL1 webSocketSerial + #define MYSERIAL2 webSocketSerial #endif #endif diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/WebSocketSerial.h index c68792c8c1..924d36f15c 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.h @@ -81,5 +81,5 @@ public: #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT webSocketSerial; diff --git a/Marlin/src/HAL/LINUX/HAL.h b/Marlin/src/HAL/LINUX/HAL.h index e4f4dd3fc3..f21e3e2c65 100644 --- a/Marlin/src/HAL/LINUX/HAL.h +++ b/Marlin/src/HAL/LINUX/HAL.h @@ -61,7 +61,7 @@ uint8_t _getc(); #define SHARED_SERVOS HAS_SERVOS extern MSerialT usb_serial; -#define MYSERIAL0 usb_serial +#define MYSERIAL1 usb_serial #define ST7920_DELAY_1 DELAY_NS(600) #define ST7920_DELAY_2 DELAY_NS(750) diff --git a/Marlin/src/HAL/LINUX/include/serial.h b/Marlin/src/HAL/LINUX/include/serial.h index 2585be25bf..ebae066c3a 100644 --- a/Marlin/src/HAL/LINUX/include/serial.h +++ b/Marlin/src/HAL/LINUX/include/serial.h @@ -115,4 +115,4 @@ struct HalSerial { volatile bool host_connected; }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; diff --git a/Marlin/src/HAL/LINUX/main.cpp b/Marlin/src/HAL/LINUX/main.cpp index c409a83e5d..31f6de98ee 100644 --- a/Marlin/src/HAL/LINUX/main.cpp +++ b/Marlin/src/HAL/LINUX/main.cpp @@ -105,8 +105,8 @@ int main() { std::thread write_serial (write_serial_thread); std::thread read_serial (read_serial_thread); - #ifdef MYSERIAL0 - MYSERIAL0.begin(BAUDRATE); + #ifdef MYSERIAL1 + MYSERIAL1.begin(BAUDRATE); SERIAL_ECHOLNPGM("x86_64 Initialized"); SERIAL_FLUSHTX(); #endif diff --git a/Marlin/src/HAL/LPC1768/HAL.cpp b/Marlin/src/HAL/LPC1768/HAL.cpp index 26a2c0e7db..442c41afe7 100644 --- a/Marlin/src/HAL/LPC1768/HAL.cpp +++ b/Marlin/src/HAL/LPC1768/HAL.cpp @@ -29,7 +29,7 @@ #include "watchdog.h" #endif -DefaultSerial USBSerial(false, UsbSerial); +DefaultSerial1 USBSerial(false, UsbSerial); uint32_t HAL_adc_reading = 0; diff --git a/Marlin/src/HAL/LPC1768/HAL.h b/Marlin/src/HAL/LPC1768/HAL.h index 1dc4fe6ff9..58f9cb71fb 100644 --- a/Marlin/src/HAL/LPC1768/HAL.h +++ b/Marlin/src/HAL/LPC1768/HAL.h @@ -60,26 +60,25 @@ extern "C" volatile uint32_t _millis; #define ST7920_DELAY_3 DELAY_NS(750) #endif -typedef ForwardSerial0Type< decltype(UsbSerial) > DefaultSerial; -extern DefaultSerial USBSerial; +typedef ForwardSerial1Class< decltype(UsbSerial) > DefaultSerial1; +extern DefaultSerial1 USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 USBSerial + #define MYSERIAL2 USBSerial #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index b0dfc0ae90..be42c7f960 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -26,7 +26,7 @@ #if ANY_SERIAL_IS(0) MarlinSerial _MSerial(LPC_UART0); - MSerialT MSerial(true, _MSerial); + MSerialT MSerial0(true, _MSerial); extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); } #endif #if ANY_SERIAL_IS(1) @@ -51,7 +51,7 @@ // Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro) if (false) {} #if ANY_SERIAL_IS(0) - else if (this == &_MSerial) emergency_parser.update(MSerial.emergency_state, c); + else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c); #endif #if ANY_SERIAL_IS(1) else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c); diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.h b/Marlin/src/HAL/LPC1768/MarlinSerial.h index 35c9362b9f..489bd8cc6c 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.h +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.h @@ -54,8 +54,8 @@ public: // On LPC176x framework, HardwareSerial does not implement the same interface as Arduino's Serial, so overloads // of 'available' and 'read' method are not used in this multiple inheritance scenario. // Instead, use a ForwardSerial here that adapts the interface. -typedef ForwardSerial0Type MSerialT; -extern MSerialT MSerial; +typedef ForwardSerial1Class MSerialT; +extern MSerialT MSerial0; extern MSerialT MSerial1; extern MSerialT MSerial2; extern MSerialT MSerial3; diff --git a/Marlin/src/HAL/SAMD51/HAL.cpp b/Marlin/src/HAL/SAMD51/HAL.cpp index 4a6100b96b..8dd2fefd0a 100644 --- a/Marlin/src/HAL/SAMD51/HAL.cpp +++ b/Marlin/src/HAL/SAMD51/HAL.cpp @@ -26,19 +26,19 @@ #ifdef ADAFRUIT_GRAND_CENTRAL_M4 #if ANY_SERIAL_IS(-1) - DefaultSerial MSerial(false, Serial); + DefaultSerial1 MSerial0(false, Serial); #endif #if ANY_SERIAL_IS(0) - DefaultSerial1 MSerial1(false, Serial1); + DefaultSerial2 MSerial1(false, Serial1); #endif #if ANY_SERIAL_IS(1) - DefaultSerial2 MSerial2(false, Serial2); + DefaultSerial3 MSerial2(false, Serial2); #endif #if ANY_SERIAL_IS(2) - DefaultSerial3 MSerial3(false, Serial3); + DefaultSerial4 MSerial3(false, Serial3); #endif #if ANY_SERIAL_IS(3) - DefaultSerial4 MSerial4(false, Serial4); + DefaultSerial5 MSerial4(false, Serial4); #endif #endif diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 7b272af842..de72c476e4 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -32,36 +32,36 @@ #include "MarlinSerial_AGCM4.h" // Serial ports - typedef ForwardSerial0Type< decltype(Serial) > DefaultSerial; - typedef ForwardSerial0Type< decltype(Serial1) > DefaultSerial1; - typedef ForwardSerial0Type< decltype(Serial2) > DefaultSerial2; - typedef ForwardSerial0Type< decltype(Serial3) > DefaultSerial3; - typedef ForwardSerial0Type< decltype(Serial4) > DefaultSerial4; - extern DefaultSerial MSerial; - extern DefaultSerial1 MSerial1; - extern DefaultSerial2 MSerial2; - extern DefaultSerial3 MSerial3; - extern DefaultSerial4 MSerial4; - - // MYSERIAL0 required before MarlinSerial includes! + typedef ForwardSerial1Class< decltype(Serial) > DefaultSerial1; + typedef ForwardSerial1Class< decltype(Serial1) > DefaultSerial2; + typedef ForwardSerial1Class< decltype(Serial2) > DefaultSerial3; + typedef ForwardSerial1Class< decltype(Serial3) > DefaultSerial4; + typedef ForwardSerial1Class< decltype(Serial4) > DefaultSerial5; + extern DefaultSerial1 MSerial0; + extern DefaultSerial2 MSerial1; + extern DefaultSerial3 MSerial2; + extern DefaultSerial4 MSerial3; + extern DefaultSerial5 MSerial4; + + // MYSERIAL1 required before MarlinSerial includes! #define __MSERIAL(X) MSerial##X #define _MSERIAL(X) __MSERIAL(X) #define MSERIAL(X) _MSERIAL(INCREMENT(X)) #if SERIAL_PORT == -1 - #define MYSERIAL0 MSerial + #define MYSERIAL1 MSerial0 #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be from -1 to 3. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 MSerial + #define MYSERIAL2 MSerial0 #elif WITHIN(SERIAL_PORT_2, 0, 3) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -1 to 3. Please update your configuration." #endif @@ -69,7 +69,7 @@ #ifdef MMU2_SERIAL_PORT #if MMU2_SERIAL_PORT == -1 - #define MMU2_SERIAL MSerial + #define MMU2_SERIAL MSerial0 #elif WITHIN(MMU2_SERIAL_PORT, 0, 3) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else @@ -79,7 +79,7 @@ #ifdef LCD_SERIAL_PORT #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL MSerial + #define LCD_SERIAL MSerial0 #elif WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else diff --git a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h index b7293415d1..ac5a379398 100644 --- a/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h +++ b/Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.h @@ -22,7 +22,7 @@ #include "../../core/serial_hook.h" -typedef Serial0Type UartT; +typedef Serial1Class UartT; extern UartT Serial2; extern UartT Serial3; diff --git a/Marlin/src/HAL/STM32/HAL.cpp b/Marlin/src/HAL/STM32/HAL.cpp index d13be1a21a..c66f061d91 100644 --- a/Marlin/src/HAL/STM32/HAL.cpp +++ b/Marlin/src/HAL/STM32/HAL.cpp @@ -29,7 +29,7 @@ #include "../shared/Delay.h" #ifdef USBCON - DefaultSerial MSerial(false, SerialUSB); + DefaultSerial1 MSerial0(false, SerialUSB); #endif #if ENABLED(SRAM_EEPROM_EMULATION) diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index be0cc30962..ad3a9963d7 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -40,8 +40,8 @@ #ifdef USBCON #include #include "../../core/serial_hook.h" - typedef ForwardSerial0Type< decltype(SerialUSB) > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; + extern DefaultSerial1 MSerial0; #endif // ------------------------ @@ -51,18 +51,18 @@ #define MSERIAL(X) _MSERIAL(X) #if SERIAL_PORT == -1 - #define MYSERIAL0 MSerial + #define MYSERIAL1 MSerial0 #elif WITHIN(SERIAL_PORT, 1, 6) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "SERIAL_PORT must be -1 or from 1 to 6. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 MSerial + #define MYSERIAL2 MSerial0 #elif WITHIN(SERIAL_PORT_2, 1, 6) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be -1 or from 1 to 6. Please update your configuration." #endif @@ -70,7 +70,7 @@ #ifdef MMU2_SERIAL_PORT #if MMU2_SERIAL_PORT == -1 - #define MMU2_SERIAL MSerial + #define MMU2_SERIAL MSerial0 #elif WITHIN(MMU2_SERIAL_PORT, 1, 6) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else @@ -80,7 +80,7 @@ #ifdef LCD_SERIAL_PORT #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL MSerial + #define LCD_SERIAL MSerial0 #elif WITHIN(LCD_SERIAL_PORT, 1, 6) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else diff --git a/Marlin/src/HAL/STM32/MarlinSerial.h b/Marlin/src/HAL/STM32/MarlinSerial.h index 8cc4f0dd4c..7b0529cfd2 100644 --- a/Marlin/src/HAL/STM32/MarlinSerial.h +++ b/Marlin/src/HAL/STM32/MarlinSerial.h @@ -42,7 +42,7 @@ protected: usart_rx_callback_t _rx_callback; }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT MSerial1; extern MSerialT MSerial2; extern MSerialT MSerial3; diff --git a/Marlin/src/HAL/STM32F1/HAL.cpp b/Marlin/src/HAL/STM32F1/HAL.cpp index 182d9401c1..40452b5d70 100644 --- a/Marlin/src/HAL/STM32F1/HAL.cpp +++ b/Marlin/src/HAL/STM32F1/HAL.cpp @@ -84,7 +84,7 @@ #if defined(SERIAL_USB) && !HAS_SD_HOST_DRIVE USBSerial SerialUSB; - DefaultSerial MSerial(true, SerialUSB); + DefaultSerial1 MSerial0(true, SerialUSB); #if ENABLED(EMERGENCY_PARSER) #include "../libmaple/usb/stm32f1/usb_reg_map.h" @@ -107,7 +107,7 @@ len = usb_cdcacm_peek(buf, total); for (uint32 i = 0; i < len; i++) - emergency_parser.update(MSerial.emergency_state, buf[i + total - len]); + emergency_parser.update(MSerial0.emergency_state, buf[i + total - len]); } #endif #endif diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index 30bf60b6e8..4656583590 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -61,11 +61,11 @@ #endif #ifdef SERIAL_USB - typedef ForwardSerial0Type< USBSerial > DefaultSerial; - extern DefaultSerial MSerial; + typedef ForwardSerial1Class< USBSerial > DefaultSerial1; + extern DefaultSerial1 MSerial0; #if !HAS_SD_HOST_DRIVE - #define UsbSerial MSerial + #define UsbSerial MSerial0 #else #define UsbSerial MarlinCompositeSerial #endif @@ -81,9 +81,9 @@ #endif #if SERIAL_PORT == -1 - #define MYSERIAL0 UsbSerial + #define MYSERIAL1 UsbSerial #elif WITHIN(SERIAL_PORT, 1, NUM_UARTS) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #elif NUM_UARTS == 5 #error "SERIAL_PORT must be -1 or from 1 to 5. Please update your configuration." #else @@ -92,9 +92,9 @@ #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 UsbSerial + #define MYSERIAL2 UsbSerial #elif WITHIN(SERIAL_PORT_2, 1, NUM_UARTS) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #elif NUM_UARTS == 5 #error "SERIAL_PORT_2 must be -1 or from 1 to 5. Please update your configuration." #else diff --git a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp index e6b89f1105..2cb75bb1e9 100644 --- a/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/HAL_MinSerial.cpp @@ -44,8 +44,8 @@ static void TXBegin() { #warning "Using POSTMORTEM_DEBUGGING requires a physical U(S)ART hardware in case of severe error." #warning "Disabling the severe error reporting feature currently because the used serial port is not a HW port." #else - // We use MYSERIAL0 here, so we need to figure out how to get the linked register - struct usart_dev* dev = MYSERIAL0.c_dev(); + // We use MYSERIAL1 here, so we need to figure out how to get the linked register + struct usart_dev* dev = MYSERIAL1.c_dev(); // Or use this if removing libmaple // int irq = dev->irq_num; @@ -80,7 +80,7 @@ static void TXBegin() { #define sw_barrier() __asm__ volatile("": : :"memory"); static void TX(char c) { #if WITHIN(SERIAL_PORT, 1, 6) - struct usart_dev* dev = MYSERIAL0.c_dev(); + struct usart_dev* dev = MYSERIAL1.c_dev(); while (!(dev->regs->SR & USART_SR_TXE)) { TERN_(USE_WATCHDOG, HAL_watchdog_refresh()); sw_barrier(); diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp index c404e81b35..a46e3ab3ab 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.cpp +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.cpp @@ -134,12 +134,12 @@ constexpr bool IsSerialClassAllowed(const HardwareSerial&) { return false; } // If you encounter this error, replace SerialX with MSerialX, for example MSerial3. // Non-TMC ports were already validated in HAL.h, so do not require verbose error messages. -#ifdef MYSERIAL0 - CHECK_CFG_SERIAL(MYSERIAL0); -#endif #ifdef MYSERIAL1 CHECK_CFG_SERIAL(MYSERIAL1); #endif +#ifdef MYSERIAL2 + CHECK_CFG_SERIAL(MYSERIAL2); +#endif #ifdef LCD_SERIAL CHECK_CFG_SERIAL(LCD_SERIAL); #endif diff --git a/Marlin/src/HAL/STM32F1/MarlinSerial.h b/Marlin/src/HAL/STM32F1/MarlinSerial.h index 692e97e618..dda32fe7a2 100644 --- a/Marlin/src/HAL/STM32F1/MarlinSerial.h +++ b/Marlin/src/HAL/STM32F1/MarlinSerial.h @@ -47,7 +47,7 @@ struct MarlinSerial : public HardwareSerial { #endif }; -typedef Serial0Type MSerialT; +typedef Serial1Class MSerialT; extern MSerialT MSerial1; extern MSerialT MSerial2; diff --git a/Marlin/src/HAL/STM32F1/msc_sd.cpp b/Marlin/src/HAL/STM32F1/msc_sd.cpp index 1e2fe88174..7725b2c324 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.cpp +++ b/Marlin/src/HAL/STM32F1/msc_sd.cpp @@ -24,7 +24,7 @@ #define PRODUCT_ID 0x29 USBMassStorage MarlinMSC; -Serial0Type MarlinCompositeSerial(true); +Serial1Class MarlinCompositeSerial(true); #include "../../inc/MarlinConfig.h" diff --git a/Marlin/src/HAL/STM32F1/msc_sd.h b/Marlin/src/HAL/STM32F1/msc_sd.h index 151287f7a7..f4636bdff7 100644 --- a/Marlin/src/HAL/STM32F1/msc_sd.h +++ b/Marlin/src/HAL/STM32F1/msc_sd.h @@ -21,6 +21,6 @@ #include "../../core/serial_hook.h" extern USBMassStorage MarlinMSC; -extern Serial0Type MarlinCompositeSerial; +extern Serial1Class MarlinCompositeSerial; void MSC_SD_init(); diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 51636d29bf..8a13f1d884 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,7 +31,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result; diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 5273b38637..cd1c334899 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -51,19 +51,18 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 547681de5f..fe2f79f415 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 94c514bf62..48fee6b9a9 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -54,19 +54,18 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 USBSerial + #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 26449d7eb2..0fde9da537 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -32,7 +32,7 @@ #include -DefaultSerial MSerial(false); +DefaultSerial1 MSerial0(false); USBSerialType USBSerial(false, SerialUSB); uint16_t HAL_adc_result, HAL_adc_select; diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.h b/Marlin/src/HAL/TEENSY40_41/HAL.h index 6aa1e521a4..03a12e1b92 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -56,30 +56,29 @@ #endif #include "../../core/serial_hook.h" -typedef Serial0Type DefaultSerial; -extern DefaultSerial MSerial; -typedef ForwardSerial0Type USBSerialType; +typedef Serial1Class DefaultSerial1; +extern DefaultSerial1 MSerial0; +typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -#define MSerial0 MSerial #if SERIAL_PORT == -1 - #define MYSERIAL0 SerialUSB + #define MYSERIAL1 SerialUSB #elif WITHIN(SERIAL_PORT, 0, 8) - #define MYSERIAL0 MSERIAL(SERIAL_PORT) + #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration." #endif #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == -1 - #define MYSERIAL1 usbSerial + #define MYSERIAL2 usbSerial #elif SERIAL_PORT_2 == -2 - #define MYSERIAL1 ethernet.telnetClient + #define MYSERIAL2 ethernet.telnetClient #elif WITHIN(SERIAL_PORT_2, 0, 8) - #define MYSERIAL1 MSERIAL(SERIAL_PORT_2) + #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #error "SERIAL_PORT_2 must be from -2 to 8. Please update your configuration." #endif diff --git a/Marlin/src/core/serial.cpp b/Marlin/src/core/serial.cpp index 01f850ba56..326baf0c54 100644 --- a/Marlin/src/core/serial.cpp +++ b/Marlin/src/core/serial.cpp @@ -43,12 +43,12 @@ PGMSTR(SP_X_LBL, " X:"); PGMSTR(SP_Y_LBL, " Y:"); PGMSTR(SP_Z_LBL, " Z:"); PGMST #else #if HAS_ETHERNET // Runtime checking of the condition variable - ConditionalSerial serialOut1(ethernet.have_telnet_client, MYSERIAL1, false); // Takes reference here + ConditionalSerial serialOut2(ethernet.have_telnet_client, MYSERIAL2, false); // Takes reference here #else // Don't pay for runtime checking a true variable, instead use the output directly - #define serialOut1 MYSERIAL1 + #define serialOut2 MYSERIAL2 #endif - SerialOutputT multiSerial(MYSERIAL0, serialOut1); + SerialOutputT multiSerial(MYSERIAL1, serialOut2); #endif #endif diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 57e9636be0..87c2a390db 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -69,15 +69,15 @@ extern uint8_t marlin_debug_flags; #ifdef SERIAL_CATCHALL typedef MultiSerial SerialOutputT; #else - typedef MultiSerial, decltype(MYSERIAL1)), 0> SerialOutputT; + typedef MultiSerial, decltype(MYSERIAL2)), 0> SerialOutputT; #endif - extern SerialOutputT multiSerial; - #define _SERIAL_IMPL multiSerial + extern SerialOutputT multiSerial; + #define _SERIAL_IMPL multiSerial #else #define _PORT_REDIRECT(n,p) NOOP #define _PORT_RESTORE(n) NOOP #define SERIAL_ASSERT(P) NOOP - #define _SERIAL_IMPL MYSERIAL0 + #define _SERIAL_IMPL MYSERIAL1 #endif #if ENABLED(MEATPACK) diff --git a/Marlin/src/core/serial_hook.h b/Marlin/src/core/serial_hook.h index 5e81e9e0e4..c687891fb4 100644 --- a/Marlin/src/core/serial_hook.h +++ b/Marlin/src/core/serial_hook.h @@ -257,8 +257,8 @@ struct MultiSerial : public SerialBase< MultiSerial, ConditionalSerial > Serial0Type; +typedef MultiSerial< RuntimeSerial, ConditionalSerial > Serial1Class; ``` To send the same output to 4 serial ports you could nest `MultiSerial` like this: ```cpp -typedef MultiSerial< MultiSerial< BaseSerial, BaseSerial >, MultiSerial< BaseSerial, BaseSerial, 2, 1>, 0, 2> Serial0Type; +typedef MultiSerial< MultiSerial< BaseSerial, BaseSerial >, MultiSerial< BaseSerial, BaseSerial, 2, 1>, 0, 2> Serial1Class; ``` The magical numbers here are the step and offset for computing the serial port. Simplifying the above monster a bit: ```cpp