Browse Source

🧑‍💻 Clarify MSerialUSB, drop HardwareSerial workaround

FB4S_WIFI
Scott Lahteine 3 years ago
parent
commit
2204f05dca
  1. 1
      Marlin/src/HAL/AVR/HAL.h
  2. 2
      Marlin/src/HAL/STM32/HAL.cpp
  3. 52
      Marlin/src/HAL/STM32/HAL.h
  4. 2
      Marlin/src/core/serial_hook.h

1
Marlin/src/HAL/AVR/HAL.h

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

2
Marlin/src/HAL/STM32/HAL.cpp

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

52
Marlin/src/HAL/STM32/HAL.h

@ -51,57 +51,67 @@
#include <USBSerial.h> #include <USBSerial.h>
#include "../../core/serial_hook.h" #include "../../core/serial_hook.h"
typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1; typedef ForwardSerial1Class< decltype(SerialUSB) > DefaultSerial1;
extern DefaultSerial1 MSerial0; extern DefaultSerial1 MSerialUSB;
#endif #endif
#define _MSERIAL(X) MSerial##X #define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X) #define MSERIAL(X) _MSERIAL(X)
#if SERIAL_PORT == -1 #if WITHIN(SERIAL_PORT, 1, 6)
#define MYSERIAL1 MSerial0
#elif WITHIN(SERIAL_PORT, 1, 6)
#define MYSERIAL1 MSERIAL(SERIAL_PORT) #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 #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 #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == -1 #if WITHIN(SERIAL_PORT_2, 1, 6)
#define MYSERIAL2 MSerial0
#elif WITHIN(SERIAL_PORT_2, 1, 6)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #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 #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
#endif #endif
#ifdef SERIAL_PORT_3 #ifdef SERIAL_PORT_3
#if SERIAL_PORT_3 == -1 #if WITHIN(SERIAL_PORT_3, 1, 6)
#define MYSERIAL3 MSerial0
#elif WITHIN(SERIAL_PORT_3, 1, 6)
#define MYSERIAL3 MSERIAL(SERIAL_PORT_3) #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 #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
#endif #endif
#ifdef MMU2_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if MMU2_SERIAL_PORT == -1 #if WITHIN(MMU2_SERIAL_PORT, 1, 6)
#define MMU2_SERIAL MSerial0
#elif WITHIN(MMU2_SERIAL_PORT, 1, 6)
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #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 #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
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1 #if WITHIN(LCD_SERIAL_PORT, 1, 6)
#define LCD_SERIAL MSerial0
#elif WITHIN(LCD_SERIAL_PORT, 1, 6)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #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 #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 #endif
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
#define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite()

2
Marlin/src/core/serial_hook.h

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

Loading…
Cancel
Save