From 048f6b4731366c8e843edac0adff1872e9e6763b Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 10 Mar 2021 12:35:26 -0600 Subject: [PATCH] Tricked-out declaration --- Marlin/src/HAL/TEENSY35_36/HAL.cpp | 7 ++++++- Marlin/src/HAL/TEENSY35_36/HAL.h | 10 ++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Marlin/src/HAL/TEENSY35_36/HAL.cpp b/Marlin/src/HAL/TEENSY35_36/HAL.cpp index fe2f79f415..8640bdfe00 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.cpp +++ b/Marlin/src/HAL/TEENSY35_36/HAL.cpp @@ -31,7 +31,12 @@ #include -DefaultSerial1 MSerial0(false); +#define _IMPLEMENT_SERIAL(X) DefaultSerial##X MSerial##X(false) +#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/TEENSY35_36/HAL.h b/Marlin/src/HAL/TEENSY35_36/HAL.h index 48fee6b9a9..e769454b3f 100644 --- a/Marlin/src/HAL/TEENSY35_36/HAL.h +++ b/Marlin/src/HAL/TEENSY35_36/HAL.h @@ -54,8 +54,13 @@ #endif #include "../../core/serial_hook.h" -typedef Serial1Class DefaultSerial1; -extern DefaultSerial1 MSerial0; + +#define Serial0 Serial +#define _DECLARE_SERIAL(X) \ + typedef Serial1Class DefaultSerial##X; \ + extern DefaultSerial##X MSerial##X +#define DECLARE_SERIAL(X) _DECLARE_SERIAL(X) + typedef ForwardSerial1Class USBSerialType; extern USBSerialType USBSerial; @@ -66,6 +71,7 @@ extern USBSerialType USBSerial; #define MYSERIAL1 USBSerial #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) + DECLARE_SERIAL(SERIAL_PORT); #endif #define HAL_SERVO_LIB libServo