Browse Source

Add USB serial support to SERIAL_PORT_2 on DUE (#17245)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
vanilla_fb_2.0.x
ellensp 5 years ago
committed by GitHub
parent
commit
cd4060a99c
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      Marlin/src/HAL/DUE/HAL.h
  2. 20
      Marlin/src/HAL/DUE/MarlinSerial.cpp
  3. 8
      Marlin/src/HAL/DUE/MarlinSerial.h
  4. 12
      Marlin/src/HAL/DUE/MarlinSerialUSB.cpp
  5. 12
      Marlin/src/HAL/DUE/MarlinSerialUSB.h
  6. 4
      Marlin/src/inc/Conditionals_LCD.h

1
Marlin/src/HAL/DUE/HAL.h

@ -94,7 +94,6 @@
#endif
#endif
#include "MarlinSerial.h"
#include "MarlinSerialUSB.h"

20
Marlin/src/HAL/DUE/MarlinSerial.cpp

@ -629,23 +629,13 @@ void MarlinSerial<Cfg>::printFloat(double number, uint8_t digits) {
// If not using the USB port as serial port
#if SERIAL_PORT >= 0
// Preinstantiate
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>;
// Instantiate
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT>>; // Define
MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1; // Instantiate
#endif
#ifdef SERIAL_PORT_2
// Preinstantiate
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>;
// Instantiate
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
template class MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>>; // Define
MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2; // Instantiate
#endif
#endif // ARDUINO_ARCH_SAM

8
Marlin/src/HAL/DUE/MarlinSerial.h

@ -172,13 +172,9 @@ struct MarlinSerialCfg {
};
#if SERIAL_PORT >= 0
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT>> customizedSerial1;
#endif
#endif // SERIAL_PORT >= 0
#ifdef SERIAL_PORT_2
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
extern MarlinSerial<MarlinSerialCfg<SERIAL_PORT_2>> customizedSerial2;
#endif

12
Marlin/src/HAL/DUE/MarlinSerialUSB.cpp

@ -29,7 +29,7 @@
#include "../../inc/MarlinConfig.h"
#if SERIAL_PORT == -1
#if HAS_USB_SERIAL
#include "MarlinSerialUSB.h"
@ -283,8 +283,12 @@ void MarlinSerialUSB::printFloat(double number, uint8_t digits) {
}
// Preinstantiate
MarlinSerialUSB customizedSerial1;
#endif // SERIAL_PORT == -1
#if SERIAL_PORT == -1
MarlinSerialUSB customizedSerial1;
#endif
#if SERIAL_PORT_2 == -1
MarlinSerialUSB customizedSerial2;
#endif
#endif // HAS_USB_SERIAL
#endif // ARDUINO_ARCH_SAM

12
Marlin/src/HAL/DUE/MarlinSerialUSB.h

@ -28,7 +28,7 @@
#include "../../inc/MarlinConfig.h"
#if SERIAL_PORT == -1
#if HAS_USB_SERIAL
#include <WString.h>
@ -88,6 +88,12 @@ private:
static void printFloat(double, uint8_t);
};
extern MarlinSerialUSB customizedSerial1;
#if SERIAL_PORT == -1
extern MarlinSerialUSB customizedSerial1;
#endif
#if SERIAL_PORT_2 == -1
extern MarlinSerialUSB customizedSerial2;
#endif
#endif // SERIAL_PORT == -1
#endif // HAS_USB_SERIAL

4
Marlin/src/inc/Conditionals_LCD.h

@ -683,6 +683,10 @@
#define SPI_SPEED SPI_FULL_SPEED
#endif
#if SERIAL_PORT == -1 || SERIAL_PORT_2 == -1
#define HAS_USB_SERIAL 1
#endif
/**
* This setting is also used by M109 when trying to calculate
* a ballpark safe margin to prevent wait-forever situation.

Loading…
Cancel
Save