Serial and pins debug cleanup

- Rename some AVR / DUE / ESP32 serial types
- Reduce two #error to one static_assert
- Update AVR/DUE error messages
This commit is contained in:
Scott Lahteine 2021-05-06 22:39:34 -05:00
parent c1fb84e1a6
commit 4518506559
18 changed files with 76 additions and 171 deletions

View File

@ -93,13 +93,13 @@ typedef int8_t pin_t;
#define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0)
#else #else
#if !WITHIN(SERIAL_PORT, -1, 3) #if !WITHIN(SERIAL_PORT, -1, 3)
#error "SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#define MYSERIAL1 customizedSerial1 #define MYSERIAL1 customizedSerial1
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
#if !WITHIN(SERIAL_PORT_2, -1, 3) #if !WITHIN(SERIAL_PORT_2, -1, 3)
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#define MYSERIAL2 customizedSerial2 #define MYSERIAL2 customizedSerial2
#endif #endif
@ -107,14 +107,14 @@ typedef int8_t pin_t;
#ifdef MMU2_SERIAL_PORT #ifdef MMU2_SERIAL_PORT
#if !WITHIN(MMU2_SERIAL_PORT, -1, 3) #if !WITHIN(MMU2_SERIAL_PORT, -1, 3)
#error "MMU2_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "MMU2_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#define MMU2_SERIAL mmuSerial #define MMU2_SERIAL mmuSerial
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
#if !WITHIN(LCD_SERIAL_PORT, -1, 3) #if !WITHIN(LCD_SERIAL_PORT, -1, 3)
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "LCD_SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#define LCD_SERIAL lcdSerial #define LCD_SERIAL lcdSerial
#if HAS_DGUS_LCD #if HAS_DGUS_LCD

View File

@ -567,7 +567,7 @@ ISR(SERIAL_REGNAME(USART, SERIAL_PORT, _UDRE_vect)) {
// Because of the template definition above, it's required to instantiate the template to have all methods generated // Because of the template definition above, it's required to instantiate the template to have all methods generated
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >; template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
MSerialT customizedSerial1(MSerialT::HasEmergencyParser); MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser);
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
@ -596,7 +596,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
} }
template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >; template class MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> >;
MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser); MSerialMMU2 mmuSerial(MSerialMMU2::HasEmergencyParser);
#endif // MMU2_SERIAL_PORT #endif // MMU2_SERIAL_PORT
@ -611,7 +611,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
} }
template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >; template class MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> >;
MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser); MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser);
#if HAS_DGUS_LCD #if HAS_DGUS_LCD
template<typename Cfg> template<typename Cfg>
@ -630,7 +630,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser);
// For AT90USB targets use the UART for BT interfacing // For AT90USB targets use the UART for BT interfacing
#if defined(USBCON) && ENABLED(BLUETOOTH) #if defined(USBCON) && ENABLED(BLUETOOTH)
MSerialT5 bluetoothSerial(false); MSerialBT bluetoothSerial(false);
#endif #endif
#endif // __AVR__ #endif // __AVR__

View File

@ -238,8 +238,8 @@
static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED); static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
}; };
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT; typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT1;
extern MSerialT customizedSerial1; extern MSerialT1 customizedSerial1;
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2; typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT_2> > > MSerialT2;
@ -262,8 +262,8 @@
static constexpr bool RX_OVERRUNS = false; static constexpr bool RX_OVERRUNS = false;
}; };
typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialT3; typedef Serial1Class< MarlinSerial< MMU2SerialCfg<MMU2_SERIAL_PORT> > > MSerialMMU2;
extern MSerialT3 mmuSerial; extern MSerialMMU2 mmuSerial;
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
@ -281,12 +281,12 @@
static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS); static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS);
}; };
typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialT4; typedef Serial1Class< MarlinSerial< LCDSerialCfg<LCD_SERIAL_PORT> > > MSerialLCD;
extern MSerialT4 lcdSerial; extern MSerialLCD lcdSerial;
#endif #endif
// Use the UART for Bluetooth in AT90USB configurations // Use the UART for Bluetooth in AT90USB configurations
#if defined(USBCON) && ENABLED(BLUETOOTH) #if defined(USBCON) && ENABLED(BLUETOOTH)
typedef Serial1Class<HardwareSerial> MSerialT5; typedef Serial1Class<HardwareSerial> MSerialBT;
extern MSerialT5 bluetoothSerial; extern MSerialBT bluetoothSerial;
#endif #endif

View File

@ -50,13 +50,12 @@ extern DefaultSerial4 MSerial3;
#define _MSERIAL(X) MSerial##X #define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X) #define MSERIAL(X) _MSERIAL(X)
// Define MYSERIAL1/2 before MarlinSerial includes!
#if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER)
#define MYSERIAL1 customizedSerial1 #define MYSERIAL1 customizedSerial1
#elif WITHIN(SERIAL_PORT, 0, 3) #elif WITHIN(SERIAL_PORT, 0, 3)
#define MYSERIAL1 MSERIAL(SERIAL_PORT) #define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else #else
#error "The required SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "The required SERIAL_PORT must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
@ -65,7 +64,7 @@ extern DefaultSerial4 MSerial3;
#elif WITHIN(SERIAL_PORT_2, 0, 3) #elif WITHIN(SERIAL_PORT_2, 0, 3)
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else #else
#error "SERIAL_PORT_2 must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "SERIAL_PORT_2 must be from 0 to 3, or -1 for USB Serial."
#endif #endif
#endif #endif
@ -78,12 +77,10 @@ extern DefaultSerial4 MSerial3;
#endif #endif
#ifdef LCD_SERIAL_PORT #ifdef LCD_SERIAL_PORT
#if LCD_SERIAL_PORT == -1 #if WITHIN(LCD_SERIAL_PORT, 0, 3)
#define LCD_SERIAL lcdSerial
#elif WITHIN(LCD_SERIAL_PORT, 0, 3)
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#else #else
#error "LCD_SERIAL_PORT must be from 0 to 3. You can also use -1 if the board supports Native USB." #error "LCD_SERIAL_PORT must be from 0 to 3."
#endif #endif
#endif #endif

View File

@ -478,7 +478,7 @@ void MarlinSerial<Cfg>::flushTX() {
// If not using the USB port as serial port // If not using the USB port as serial port
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 #if defined(SERIAL_PORT) && SERIAL_PORT >= 0
template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >; template class MarlinSerial< MarlinSerialCfg<SERIAL_PORT> >;
MSerialT customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER); MSerialT1 customizedSerial1(MarlinSerialCfg<SERIAL_PORT>::EMERGENCYPARSER);
#endif #endif
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0

View File

@ -141,8 +141,8 @@ struct MarlinSerialCfg {
}; };
#if defined(SERIAL_PORT) && SERIAL_PORT >= 0 #if defined(SERIAL_PORT) && SERIAL_PORT >= 0
typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT; typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT1;
extern MSerialT customizedSerial1; extern MSerialT1 customizedSerial1;
#endif #endif
#if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0

View File

@ -19,13 +19,13 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>. * along with this program. If not, see <https://www.gnu.org/licenses/>.
* *
*/ */
#ifdef ARDUINO_ARCH_SAM
/** /**
* MarlinSerial_Due.cpp - Hardware serial library for Arduino DUE * MarlinSerial_Due.cpp - Hardware serial library for Arduino DUE
* Copyright (c) 2017 Eduardo José Tagle. All right reserved * Copyright (c) 2017 Eduardo José Tagle. All right reserved
* Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved. * Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved.
*/ */
#ifdef ARDUINO_ARCH_SAM
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
@ -65,7 +65,7 @@ int MarlinSerialUSB::peek() {
pending_char = udi_cdc_getc(); pending_char = udi_cdc_getc();
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)pending_char)); TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT1*>(this)->emergency_state, (char)pending_char));
return pending_char; return pending_char;
} }
@ -87,7 +87,7 @@ int MarlinSerialUSB::read() {
int c = udi_cdc_getc(); int c = udi_cdc_getc();
TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT*>(this)->emergency_state, (char)c)); TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast<MSerialT1*>(this)->emergency_state, (char)c));
return c; return c;
} }
@ -129,10 +129,10 @@ size_t MarlinSerialUSB::write(const uint8_t c) {
// Preinstantiate // Preinstantiate
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
MSerialT customizedSerial1(TERN0(EMERGENCY_PARSER, true)); MSerialT1 customizedSerial1(TERN0(EMERGENCY_PARSER, true));
#endif #endif
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == -1
MSerialT customizedSerial2(TERN0(EMERGENCY_PARSER, true)); MSerialT2 customizedSerial2(TERN0(EMERGENCY_PARSER, true));
#endif #endif
#endif // HAS_USB_SERIAL #endif // HAS_USB_SERIAL

View File

@ -27,11 +27,9 @@
*/ */
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#if HAS_USB_SERIAL
#include <WString.h>
#include "../../core/serial_hook.h" #include "../../core/serial_hook.h"
#include <WString.h>
struct MarlinSerialUSB { struct MarlinSerialUSB {
void begin(const long); void begin(const long);
@ -50,14 +48,14 @@ struct MarlinSerialUSB {
FORCE_INLINE int rxMaxEnqueued() { return 0; } FORCE_INLINE int rxMaxEnqueued() { return 0; }
#endif #endif
}; };
typedef Serial1Class<MarlinSerialUSB> MSerialT;
#if SERIAL_PORT == -1 #if SERIAL_PORT == -1
extern MSerialT customizedSerial1; typedef Serial1Class<MarlinSerialUSB> MSerialT1;
extern MSerialT1 customizedSerial1;
#endif #endif
#if SERIAL_PORT_2 == -1 #if SERIAL_PORT_2 == -1
extern MSerialT customizedSerial2; typedef Serial1Class<MarlinSerialUSB> MSerialT2;
extern MSerialT2 customizedSerial2;
#endif #endif
#endif // HAS_USB_SERIAL

View File

@ -29,7 +29,7 @@
#include "wifi.h" #include "wifi.h"
#include <ESPAsyncWebServer.h> #include <ESPAsyncWebServer.h>
MSerialT webSocketSerial(false); MSerialWebSocketT webSocketSerial(false);
AsyncWebSocket ws("/ws"); // TODO Move inside the class. AsyncWebSocket ws("/ws"); // TODO Move inside the class.
// RingBuffer impl // RingBuffer impl

View File

@ -81,5 +81,5 @@ public:
#endif #endif
}; };
typedef Serial1Class<WebSocketSerial> MSerialT; typedef Serial1Class<WebSocketSerial> MSerialWebSocketT;
extern MSerialT webSocketSerial; extern MSerialWebSocketT webSocketSerial;

View File

@ -26,9 +26,9 @@
#include "../../inc/MarlinConfig.h" #include "../../inc/MarlinConfig.h"
#if USING_HW_SERIAL0 #if USING_HW_SERIAL0
MarlinSerial _MSerial(LPC_UART0); MarlinSerial _MSerial0(LPC_UART0);
MSerialT MSerial0(true, _MSerial); MSerialT MSerial0(true, _MSerial0);
extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); } extern "C" void UART0_IRQHandler() { _MSerial0.IRQHandler(); }
#endif #endif
#if USING_HW_SERIAL1 #if USING_HW_SERIAL1
MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1); MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1);
@ -52,7 +52,7 @@
// Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro) // Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro)
if (false) {} if (false) {}
#if USING_HW_SERIAL0 #if USING_HW_SERIAL0
else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c); else if (this == &_MSerial0) emergency_parser.update(MSerial0.emergency_state, c);
#endif #endif
#if USING_HW_SERIAL1 #if USING_HW_SERIAL1
else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c); else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c);

View File

@ -43,8 +43,6 @@
extern DefaultSerial4 MSerial3; extern DefaultSerial4 MSerial3;
extern DefaultSerial5 MSerial4; extern DefaultSerial5 MSerial4;
// MYSERIAL1 required before MarlinSerial includes!
#define __MSERIAL(X) MSerial##X #define __MSERIAL(X) MSerial##X
#define _MSERIAL(X) __MSERIAL(X) #define _MSERIAL(X) __MSERIAL(X)
#define MSERIAL(X) _MSERIAL(INCREMENT(X)) #define MSERIAL(X) _MSERIAL(INCREMENT(X))

View File

@ -37,6 +37,9 @@
#include <stdint.h> #include <stdint.h>
//
// Serial Ports
//
#ifdef USBCON #ifdef USBCON
#include <USBSerial.h> #include <USBSerial.h>
#include "../../core/serial_hook.h" #include "../../core/serial_hook.h"
@ -44,9 +47,6 @@
extern DefaultSerial1 MSerial0; extern DefaultSerial1 MSerial0;
#endif #endif
// ------------------------
// Defines
// ------------------------
#define _MSERIAL(X) MSerial##X #define _MSERIAL(X) MSerial##X
#define MSERIAL(X) _MSERIAL(X) #define MSERIAL(X) _MSERIAL(X)

View File

@ -36,7 +36,6 @@
#include "fastio.h" #include "fastio.h"
#include "watchdog.h" #include "watchdog.h"
#include <stdint.h> #include <stdint.h>
#include <util/atomic.h> #include <util/atomic.h>
@ -63,11 +62,10 @@
#ifdef SERIAL_USB #ifdef SERIAL_USB
typedef ForwardSerial1Class< USBSerial > DefaultSerial1; typedef ForwardSerial1Class< USBSerial > DefaultSerial1;
extern DefaultSerial1 MSerial0; extern DefaultSerial1 MSerial0;
#if HAS_SD_HOST_DRIVE
#if !HAS_SD_HOST_DRIVE
#define UsbSerial MSerial0
#else
#define UsbSerial MarlinCompositeSerial #define UsbSerial MarlinCompositeSerial
#else
#define UsbSerial MSerial0
#endif #endif
#endif #endif
@ -86,11 +84,7 @@
#define MYSERIAL1 MSERIAL(SERIAL_PORT) #define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else #else
#define MYSERIAL1 MSERIAL(1) // dummy port #define MYSERIAL1 MSERIAL(1) // dummy port
#if NUM_UARTS == 5 static_assert(false, "SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#error "SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
#else
#error "SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif #endif
#ifdef SERIAL_PORT_2 #ifdef SERIAL_PORT_2
@ -100,11 +94,7 @@
#define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2)
#else #else
#define MYSERIAL2 MSERIAL(1) // dummy port #define MYSERIAL2 MSERIAL(1) // dummy port
#if NUM_UARTS == 5 static_assert(false, "SERIAL_PORT_2 must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#error "SERIAL_PORT_2 must be from 1 to 5. You can also use -1 if the board supports Native USB."
#else
#error "SERIAL_PORT_2 must be from 1 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif #endif
#endif #endif
@ -115,11 +105,7 @@
#define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT)
#else #else
#define MMU2_SERIAL MSERIAL(1) // dummy port #define MMU2_SERIAL MSERIAL(1) // dummy port
#if NUM_UARTS == 5 static_assert(false, "MMU2_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#error "MMU2_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
#else
#error "MMU2_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
#endif
#endif #endif
#endif #endif
@ -130,11 +116,7 @@
#define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT)
#else #else
#define LCD_SERIAL MSERIAL(1) // dummy port #define LCD_SERIAL MSERIAL(1) // dummy port
#if NUM_UARTS == 5 static_assert(false, "LCD_SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.")
#error "LCD_SERIAL_PORT must be from 1 to 5. You can also use -1 if the board supports Native USB."
#else
#error "LCD_SERIAL_PORT must be from 1 to 3. You can also use -1 if the board supports Native USB."
#endif
#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()

View File

@ -68,6 +68,8 @@ extern USBSerialType USBSerial;
#elif WITHIN(SERIAL_PORT, 0, 3) #elif WITHIN(SERIAL_PORT, 0, 3)
DECLARE_SERIAL(SERIAL_PORT); DECLARE_SERIAL(SERIAL_PORT);
#define MYSERIAL1 MSERIAL(SERIAL_PORT) #define MYSERIAL1 MSERIAL(SERIAL_PORT)
#else
#error "The required SERIAL_PORT must be from 0 to 3, or -1 for Native USB."
#endif #endif
#define HAL_SERVO_LIB libServo #define HAL_SERVO_LIB libServo

View File

@ -87,16 +87,12 @@ extern uint8_t marlin_debug_flags;
// If we have a catchall, use that directly // If we have a catchall, use that directly
#ifdef SERIAL_CATCHALL #ifdef SERIAL_CATCHALL
#define _SERIAL_LEAF_2 SERIAL_CATCHALL #define _SERIAL_LEAF_2 SERIAL_CATCHALL
#else #elif HAS_ETHERNET
#if HAS_ETHERNET typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2; // We need to create an instance here
// We need to create an instance here
typedef ConditionalSerial<decltype(MYSERIAL2)> SerialLeafT2;
extern SerialLeafT2 msSerial2; extern SerialLeafT2 msSerial2;
#define _SERIAL_LEAF_2 msSerial2 #define _SERIAL_LEAF_2 msSerial2
#else #else
// Don't create a useless instance here, directly use the existing instance #define _SERIAL_LEAF_2 MYSERIAL2 // Don't create a useless instance here, directly use the existing instance
#define _SERIAL_LEAF_2 MYSERIAL2
#endif
#endif #endif
// Hook Meatpack if it's enabled on the second leaf // Hook Meatpack if it's enabled on the second leaf

View File

@ -1949,7 +1949,6 @@
#undef _SERIAL_ID #undef _SERIAL_ID
#undef _TMC_UART_IS #undef _TMC_UART_IS
#undef TMC_UART_IS #undef TMC_UART_IS
#undef CONF_SERIAL_IS
#undef ANY_SERIAL_IS #undef ANY_SERIAL_IS
// //

View File

@ -45,34 +45,22 @@
// manually add pins that have names that are macros which don't play well with these macros // manually add pins that have names that are macros which don't play well with these macros
#if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) #if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768)
#if SERIAL_PORT == 0 #if CONF_SERIAL_IS(0)
static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
#elif SERIAL_PORT == 1 #endif
#if CONF_SERIAL_IS(1)
static const char RXD_NAME_1[] PROGMEM = { "RXD1" }; static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
static const char TXD_NAME_1[] PROGMEM = { "TXD1" }; static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
#elif SERIAL_PORT == 2 #endif
#if CONF_SERIAL_IS(2)
static const char RXD_NAME_2[] PROGMEM = { "RXD2" }; static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
static const char TXD_NAME_2[] PROGMEM = { "TXD2" }; static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
#elif SERIAL_PORT == 3 #endif
#if CONF_SERIAL_IS(3)
static const char RXD_NAME_3[] PROGMEM = { "RXD3" }; static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
static const char TXD_NAME_3[] PROGMEM = { "TXD3" }; static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
#endif #endif
#ifdef SERIAL_PORT_2
#if SERIAL_PORT_2 == 0
static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
#elif SERIAL_PORT_2 == 1
static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
#elif SERIAL_PORT_2 == 2
static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
#elif SERIAL_PORT_2 == 3
static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
#endif
#endif
#endif #endif
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
@ -103,12 +91,11 @@ const PinInfo pin_array[] PROGMEM = {
* Each entry takes up 6 bytes in FLASH: * Each entry takes up 6 bytes in FLASH:
* 2 byte pointer to location of the name string * 2 byte pointer to location of the name string
* 2 bytes containing the pin number * 2 bytes containing the pin number
* analog pin numbers were convereted to digital when the array was created * analog pin numbers were converted to digital when the array was created
* 2 bytes containing the digital/analog bool flag * 2 bytes containing the digital/analog bool flag
*/ */
// manually add pins ... #if CONF_SERIAL_IS(0)
#if SERIAL_PORT == 0
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_0, 0, true }, { RXD_NAME_0, 0, true },
{ TXD_NAME_0, 1, true }, { TXD_NAME_0, 1, true },
@ -119,7 +106,9 @@ const PinInfo pin_array[] PROGMEM = {
{ RXD_NAME_0, 3, true }, { RXD_NAME_0, 3, true },
{ TXD_NAME_0, 2, true }, { TXD_NAME_0, 2, true },
#endif #endif
#elif SERIAL_PORT == 1 #endif
#if CONF_SERIAL_IS(1)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_1, 19, true }, { RXD_NAME_1, 19, true },
{ TXD_NAME_1, 18, true }, { TXD_NAME_1, 18, true },
@ -135,66 +124,9 @@ const PinInfo pin_array[] PROGMEM = {
{ TXD_NAME_1, 15, true }, { TXD_NAME_1, 15, true },
#endif #endif
#endif #endif
#elif SERIAL_PORT == 2
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_2, 17, true },
{ TXD_NAME_2, 16, true },
#elif defined(TARGET_LPC1768)
#ifdef LPC_PINCFG_UART2_P2_08 // TX P2_08 RX P2_09
{ RXD_NAME_2, 0x49, true },
{ TXD_NAME_2, 0x48, true },
#else // TX P0_10 RX P0_11
{ RXD_NAME_2, 11, true },
{ TXD_NAME_2, 10, true },
#endif
#endif
#elif SERIAL_PORT == 3
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_3, 15, true },
{ TXD_NAME_3, 14, true },
#elif defined(TARGET_LPC1768)
#ifdef LPC_PINCFG_UART3_P0_25 // TX P0_25 RX P0_26
{ RXD_NAME_3, 0x1A, true },
{ TXD_NAME_3, 0x19, true },
#elif defined(LPC_PINCFG_UART3_P4_28) // TX P4_28 RX P4_29
{ RXD_NAME_3, 0x9D, true },
{ TXD_NAME_3, 0x9C, true },
#else // TX P0_00 RX P0_01
{ RXD_NAME_3, 1, true },
{ TXD_NAME_3, 0, true },
#endif
#endif
#endif #endif
#ifdef SERIAL_PORT_2 #if CONF_SERIAL_IS(2)
#if SERIAL_PORT_2 == 0
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_0, 0, true },
{ TXD_NAME_0, 1, true },
#elif AVR_ATmega1284_FAMILY
{ RXD_NAME_0, 8, true },
{ TXD_NAME_0, 9, true },
#elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03
{ RXD_NAME_0, 3, true },
{ TXD_NAME_0, 2, true },
#endif
#elif SERIAL_PORT_2 == 1
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_1, 19, true },
{ TXD_NAME_1, 18, true },
#elif AVR_ATmega1284_FAMILY
{ RXD_NAME_1, 10, true },
{ TXD_NAME_1, 11, true },
#elif defined(TARGET_LPC1768)
#ifdef LPC_PINCFG_UART1_P2_00 // TX P2_00 RX P2_01
{ RXD_NAME_1, 0x41, true },
{ TXD_NAME_1, 0x40, true },
#else // TX P0_15 RX P0_16
{ RXD_NAME_1, 16, true },
{ TXD_NAME_1, 15, true },
#endif
#endif
#elif SERIAL_PORT_2 == 2
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_2, 17, true }, { RXD_NAME_2, 17, true },
{ TXD_NAME_2, 16, true }, { TXD_NAME_2, 16, true },
@ -207,7 +139,9 @@ const PinInfo pin_array[] PROGMEM = {
{ TXD_NAME_2, 10, true }, { TXD_NAME_2, 10, true },
#endif #endif
#endif #endif
#elif SERIAL_PORT_2 == 3 #endif
#if CONF_SERIAL_IS(3)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_3, 15, true }, { RXD_NAME_3, 15, true },
{ TXD_NAME_3, 14, true }, { TXD_NAME_3, 14, true },
@ -224,10 +158,9 @@ const PinInfo pin_array[] PROGMEM = {
#endif #endif
#endif #endif
#endif #endif
#endif
#include "pinsDebug_list.h" #include "pinsDebug_list.h"
#line 231 #line 164
}; };