diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.cpp b/Marlin/src/HAL/TEENSY31_32/HAL.cpp index 8a13f1d88..7b7202547 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.cpp +++ b/Marlin/src/HAL/TEENSY31_32/HAL.cpp @@ -31,7 +31,11 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) +#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) +#if WITHIN(SERIAL_PORT, 0, 3) + IMPLEMENT_SERIAL(SERIAL_PORT); +#endif 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 cd1c33489..bbfc50a36 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -51,8 +51,13 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; + +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef ForwardSerial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -62,6 +67,7 @@ extern USBSerialType USBSerial; #if SERIAL_PORT == -1 #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) + DECLARE_SERIAL(SERIAL_PORT); #define MYSERIAL1 MSERIAL(SERIAL_PORT) #endif diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index 8640bdfe0..5d808cd19 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,7 @@ #include -#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false) +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) #define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) #if WITHIN(SERIAL_PORT, 0, 3) IMPLEMENT_SERIAL(SERIAL_PORT); diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index e769454b3..5b120d852 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -57,7 +57,7 @@ #define Serial0 Serial #define _DECLARE_SERIAL(X) \ - typedef Serial1Class DefaultSerial##X; \ + typedef ForwardSerial1Class DefaultSerial##X; \ extern DefaultSerial##X MSerial##X #define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) diff --git a/Marlin/src/HAL/TEENSY40_41/HAL.cpp b/Marlin/src/HAL/TEENSY40_41/HAL.cpp index 0fde9da53..1eab3d837 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.cpp +++ b/Marlin/src/HAL/TEENSY40_41/HAL.cpp @@ -32,7 +32,11 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false, Serial##X) +#define IMPLEMENT_SERIAL(X) _IMPLEMENT_SERIAL(X) +#if WITHIN(SERIAL_PORT, 0, 3) + IMPLEMENT_SERIAL(SERIAL_PORT); +#endif 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 03a12e1b9..ce985dadb 100644 --- a/Marlin/src/HAL/TEENSY40_41/HAL.h +++ b/Marlin/src/HAL/TEENSY40_41/HAL.h @@ -56,8 +56,12 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef ForwardSerial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -67,6 +71,7 @@ extern USBSerialType USBSerial; #if SERIAL_PORT == -1 #define MYSERIAL1 SerialUSB #elif WITHIN(SERIAL_PORT, 0, 8) + DECLARE_SERIAL(SERIAL_PORT); #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #error "The required SERIAL_PORT must be from -1 to 8. Please update your configuration."