🧑‍💻 Clarify MSerialUSB, drop HardwareSerial workaround

This commit is contained in:
Scott Lahteine 2022-05-13 19:31:07 -05:00
parent a13cceaad1
commit 2204f05dca
4 changed files with 33 additions and 24 deletions

View File

@ -28,7 +28,6 @@
#ifdef USBCON
#include <HardwareSerial.h>
#else
#define HardwareSerial_h // Hack to prevent HardwareSerial.h header inclusion
#include "MarlinSerial.h"
#endif

View File

@ -31,7 +31,7 @@
#include "../shared/Delay.h"
#ifdef USBCON
DefaultSerial1 MSerial0(false, SerialUSB);
DefaultSerial1 MSerialUSB(false, SerialUSB);
#endif
#if ENABLED(SRAM_EEPROM_EMULATION)

View File

@ -51,57 +51,67 @@
#include <USBSerial.h>
#include "../../core/serial_hook.h"
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
extern DefaultSerial1 MSerial0;
extern DefaultSerial1 MSerialUSB;
#endif
#define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X)
#if SERIAL_PORT == -1
#define MYSERIAL1 MSerial0
#elif WITHIN(SERIAL_PORT, 1, 6)
#if WITHIN(SERIAL_PORT, 1, 6)
#define MYSERIAL1 MSERIAL(SERIAL_PORT)
#elif !defined(USBCON)
#error "SERIAL_PORT must be from 1 to 6."
#elif SERIAL_PORT == -1
#define MYSERIAL1 MSerialUSB
#else
#error "SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
#error "SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
#endif
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1
#define MYSERIAL2 MSerial0
#elif WITHIN(SERIAL_PORT_2, 1, 6)
#if WITHIN(SERIAL_PORT_2, 1, 6)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#elif !defined(USBCON)
#error "SERIAL_PORT must be from 1 to 6."
#elif SERIAL_PORT_2 == -1
#define MYSERIAL2 MSerialUSB
#else
#error "SERIAL_PORT_2 must be from 1 to 6. You can also use -1 if the board supports Native USB."
#error "SERIAL_PORT_2 must be from 1 to 6, or -1 for Native USB."
#endif
#endif
#ifdef SERIAL_PORT_3
#if SERIAL_PORT_3 == -1
#define MYSERIAL3 MSerial0
#elif WITHIN(SERIAL_PORT_3, 1, 6)
#if WITHIN(SERIAL_PORT_3, 1, 6)
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3)
#elif !defined(USBCON)
#error "SERIAL_PORT must be from 1 to 6."
#elif SERIAL_PORT_3 == -1
#define MYSERIAL3 MSerialUSB
#else
#error "SERIAL_PORT_3 must be from 1 to 6. You can also use -1 if the board supports Native USB."
#error "SERIAL_PORT_3 must be from 1 to 6, or -1 for Native USB."
#endif
#endif
#ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL MSerial0
#elif WITHIN(MMU2_SERIAL_PORT, 1, 6)
#if WITHIN(MMU2_SERIAL_PORT, 1, 6)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#elif !defined(USBCON)
#error "SERIAL_PORT must be from 1 to 6."
#elif MMU2_SERIAL_PORT == -1
#define MMU2_SERIAL MSerialUSB
#else
#error "MMU2_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
#error "MMU2_SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
#endif
#endif
#ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1
#define LCD_SERIAL MSerial0
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
#if WITHIN(LCD_SERIAL_PORT, 1, 6)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#elif !defined(USBCON)
#error "SERIAL_PORT must be from 1 to 6."
#elif LCD_SERIAL_PORT == -1
#define LCD_SERIAL MSerialUSB
#else
#error "LCD_SERIAL_PORT must be from 1 to 6. You can also use -1 if the board supports Native USB."
#error "LCD_SERIAL_PORT must be from 1 to 6, or -1 for Native USB."
#endif
#if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()

View File

@ -298,7 +298,7 @@ struct MultiSerial : public SerialBase< MultiSerial< REPEAT(NUM_SERIAL, _S_NAME)
// Build the actual serial object depending on current configuration
#define Serial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, BaseSerial)
#define ForwardSerial1Class TERN(SERIAL_RUNTIME_HOOK, RuntimeSerial, ForwardSerial)
#ifdef HAS_MULTI_SERIAL
#if HAS_MULTI_SERIAL
#define Serial2Class ConditionalSerial
#if NUM_SERIAL >= 3
#define Serial3Class ConditionalSerial