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

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
ellensp 2020-03-24 11:55:21 +13:00 committed by GitHub
parent adb7a88428
commit cd4060a99c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 31 deletions

View File

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

View File

@ -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

View File

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

View File

@ -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

View File

@ -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
#endif // SERIAL_PORT == -1
#if SERIAL_PORT_2 == -1
extern MarlinSerialUSB customizedSerial2;
#endif
#endif // HAS_USB_SERIAL

View File

@ -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.