From 4518506559930cc0ac4f90ae3704c1a6d76eaf23 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Thu, 6 May 2021 22:39:34 -0500 Subject: [PATCH] Serial and pins debug cleanup - Rename some AVR / DUE / ESP32 serial types - Reduce two #error to one static_assert - Update AVR/DUE error messages --- Marlin/src/HAL/AVR/HAL.h | 8 +- Marlin/src/HAL/AVR/MarlinSerial.cpp | 8 +- Marlin/src/HAL/AVR/MarlinSerial.h | 16 ++-- Marlin/src/HAL/DUE/HAL.h | 11 +-- Marlin/src/HAL/DUE/MarlinSerial.cpp | 2 +- Marlin/src/HAL/DUE/MarlinSerial.h | 4 +- Marlin/src/HAL/DUE/MarlinSerialUSB.cpp | 10 +-- Marlin/src/HAL/DUE/MarlinSerialUSB.h | 12 ++- Marlin/src/HAL/ESP32/WebSocketSerial.cpp | 2 +- Marlin/src/HAL/ESP32/WebSocketSerial.h | 4 +- Marlin/src/HAL/LPC1768/MarlinSerial.cpp | 8 +- Marlin/src/HAL/SAMD51/HAL.h | 2 - Marlin/src/HAL/STM32/HAL.h | 6 +- Marlin/src/HAL/STM32F1/HAL.h | 32 ++----- Marlin/src/HAL/TEENSY31_32/HAL.h | 2 + Marlin/src/core/serial.h | 14 ++- Marlin/src/inc/Conditionals_post.h | 1 - Marlin/src/pins/pinsDebug.h | 105 ++++------------------- 18 files changed, 76 insertions(+), 171 deletions(-) diff --git a/Marlin/src/HAL/AVR/HAL.h b/Marlin/src/HAL/AVR/HAL.h index 7adf1aad49..64e4f764dc 100644 --- a/Marlin/src/HAL/AVR/HAL.h +++ b/Marlin/src/HAL/AVR/HAL.h @@ -93,13 +93,13 @@ typedef int8_t pin_t; #define MYSERIAL1 TERN(BLUETOOTH, btSerial, MSerial0) #else #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 #define MYSERIAL1 customizedSerial1 #ifdef SERIAL_PORT_2 #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 #define MYSERIAL2 customizedSerial2 #endif @@ -107,14 +107,14 @@ typedef int8_t pin_t; #ifdef MMU2_SERIAL_PORT #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 #define MMU2_SERIAL mmuSerial #endif #ifdef LCD_SERIAL_PORT #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 #define LCD_SERIAL lcdSerial #if HAS_DGUS_LCD diff --git a/Marlin/src/HAL/AVR/MarlinSerial.cpp b/Marlin/src/HAL/AVR/MarlinSerial.cpp index 8f82b7b418..82cdcfbe83 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.cpp +++ b/Marlin/src/HAL/AVR/MarlinSerial.cpp @@ -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 template class MarlinSerial< MarlinSerialCfg >; -MSerialT customizedSerial1(MSerialT::HasEmergencyParser); +MSerialT1 customizedSerial1(MSerialT1::HasEmergencyParser); #ifdef SERIAL_PORT_2 @@ -596,7 +596,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser); } template class MarlinSerial< MMU2SerialCfg >; - MSerialT3 mmuSerial(MSerialT3::HasEmergencyParser); + MSerialMMU2 mmuSerial(MSerialMMU2::HasEmergencyParser); #endif // MMU2_SERIAL_PORT @@ -611,7 +611,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser); } template class MarlinSerial< LCDSerialCfg >; - MSerialT4 lcdSerial(MSerialT4::HasEmergencyParser); + MSerialLCD lcdSerial(MSerialLCD::HasEmergencyParser); #if HAS_DGUS_LCD template @@ -630,7 +630,7 @@ MSerialT customizedSerial1(MSerialT::HasEmergencyParser); // For AT90USB targets use the UART for BT interfacing #if defined(USBCON) && ENABLED(BLUETOOTH) - MSerialT5 bluetoothSerial(false); + MSerialBT bluetoothSerial(false); #endif #endif // __AVR__ diff --git a/Marlin/src/HAL/AVR/MarlinSerial.h b/Marlin/src/HAL/AVR/MarlinSerial.h index 355ecd41fd..26066d7208 100644 --- a/Marlin/src/HAL/AVR/MarlinSerial.h +++ b/Marlin/src/HAL/AVR/MarlinSerial.h @@ -238,8 +238,8 @@ static constexpr bool MAX_RX_QUEUED = ENABLED(SERIAL_STATS_MAX_RX_QUEUED); }; - typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; - extern MSerialT customizedSerial1; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT1; + extern MSerialT1 customizedSerial1; #ifdef SERIAL_PORT_2 typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT2; @@ -262,8 +262,8 @@ static constexpr bool RX_OVERRUNS = false; }; - typedef Serial1Class< MarlinSerial< MMU2SerialCfg > > MSerialT3; - extern MSerialT3 mmuSerial; + typedef Serial1Class< MarlinSerial< MMU2SerialCfg > > MSerialMMU2; + extern MSerialMMU2 mmuSerial; #endif #ifdef LCD_SERIAL_PORT @@ -281,12 +281,12 @@ static constexpr bool RX_OVERRUNS = BOTH(HAS_DGUS_LCD, SERIAL_STATS_RX_BUFFER_OVERRUNS); }; - typedef Serial1Class< MarlinSerial< LCDSerialCfg > > MSerialT4; - extern MSerialT4 lcdSerial; + typedef Serial1Class< MarlinSerial< LCDSerialCfg > > MSerialLCD; + extern MSerialLCD lcdSerial; #endif // Use the UART for Bluetooth in AT90USB configurations #if defined(USBCON) && ENABLED(BLUETOOTH) - typedef Serial1Class MSerialT5; - extern MSerialT5 bluetoothSerial; + typedef Serial1Class MSerialBT; + extern MSerialBT bluetoothSerial; #endif diff --git a/Marlin/src/HAL/DUE/HAL.h b/Marlin/src/HAL/DUE/HAL.h index 1bc3bf7410..2fb927948c 100644 --- a/Marlin/src/HAL/DUE/HAL.h +++ b/Marlin/src/HAL/DUE/HAL.h @@ -50,13 +50,12 @@ extern DefaultSerial4 MSerial3; #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) -// Define MYSERIAL1/2 before MarlinSerial includes! #if SERIAL_PORT == -1 || ENABLED(EMERGENCY_PARSER) #define MYSERIAL1 customizedSerial1 #elif WITHIN(SERIAL_PORT, 0, 3) #define MYSERIAL1 MSERIAL(SERIAL_PORT) #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 #ifdef SERIAL_PORT_2 @@ -65,7 +64,7 @@ extern DefaultSerial4 MSerial3; #elif WITHIN(SERIAL_PORT_2, 0, 3) #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #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 @@ -78,12 +77,10 @@ extern DefaultSerial4 MSerial3; #endif #ifdef LCD_SERIAL_PORT - #if LCD_SERIAL_PORT == -1 - #define LCD_SERIAL lcdSerial - #elif WITHIN(LCD_SERIAL_PORT, 0, 3) + #if WITHIN(LCD_SERIAL_PORT, 0, 3) #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #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 diff --git a/Marlin/src/HAL/DUE/MarlinSerial.cpp b/Marlin/src/HAL/DUE/MarlinSerial.cpp index 5b333fbeb5..29d9ab0797 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerial.cpp @@ -478,7 +478,7 @@ void MarlinSerial::flushTX() { // If not using the USB port as serial port #if defined(SERIAL_PORT) && SERIAL_PORT >= 0 template class MarlinSerial< MarlinSerialCfg >; - MSerialT customizedSerial1(MarlinSerialCfg::EMERGENCYPARSER); + MSerialT1 customizedSerial1(MarlinSerialCfg::EMERGENCYPARSER); #endif #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 diff --git a/Marlin/src/HAL/DUE/MarlinSerial.h b/Marlin/src/HAL/DUE/MarlinSerial.h index 0fb15cf8ad..496e54c151 100644 --- a/Marlin/src/HAL/DUE/MarlinSerial.h +++ b/Marlin/src/HAL/DUE/MarlinSerial.h @@ -141,8 +141,8 @@ struct MarlinSerialCfg { }; #if defined(SERIAL_PORT) && SERIAL_PORT >= 0 - typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT; - extern MSerialT customizedSerial1; + typedef Serial1Class< MarlinSerial< MarlinSerialCfg > > MSerialT1; + extern MSerialT1 customizedSerial1; #endif #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0 diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp index fca677c798..fb5f013255 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.cpp @@ -19,13 +19,13 @@ * along with this program. If not, see . * */ +#ifdef ARDUINO_ARCH_SAM /** * MarlinSerial_Due.cpp - Hardware serial library for Arduino DUE * Copyright (c) 2017 Eduardo José Tagle. All right reserved * Based on MarlinSerial for AVR, copyright (c) 2006 Nicholas Zambetti. All right reserved. */ -#ifdef ARDUINO_ARCH_SAM #include "../../inc/MarlinConfig.h" @@ -65,7 +65,7 @@ int MarlinSerialUSB::peek() { pending_char = udi_cdc_getc(); - TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)pending_char)); + TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)pending_char)); return pending_char; } @@ -87,7 +87,7 @@ int MarlinSerialUSB::read() { int c = udi_cdc_getc(); - TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)c)); + TERN_(EMERGENCY_PARSER, emergency_parser.update(static_cast(this)->emergency_state, (char)c)); return c; } @@ -129,10 +129,10 @@ size_t MarlinSerialUSB::write(const uint8_t c) { // Preinstantiate #if SERIAL_PORT == -1 - MSerialT customizedSerial1(TERN0(EMERGENCY_PARSER, true)); + MSerialT1 customizedSerial1(TERN0(EMERGENCY_PARSER, true)); #endif #if SERIAL_PORT_2 == -1 - MSerialT customizedSerial2(TERN0(EMERGENCY_PARSER, true)); + MSerialT2 customizedSerial2(TERN0(EMERGENCY_PARSER, true)); #endif #endif // HAS_USB_SERIAL diff --git a/Marlin/src/HAL/DUE/MarlinSerialUSB.h b/Marlin/src/HAL/DUE/MarlinSerialUSB.h index 4c299dced5..d19fc60eb6 100644 --- a/Marlin/src/HAL/DUE/MarlinSerialUSB.h +++ b/Marlin/src/HAL/DUE/MarlinSerialUSB.h @@ -27,11 +27,9 @@ */ #include "../../inc/MarlinConfig.h" -#if HAS_USB_SERIAL - -#include #include "../../core/serial_hook.h" +#include struct MarlinSerialUSB { void begin(const long); @@ -50,14 +48,14 @@ struct MarlinSerialUSB { FORCE_INLINE int rxMaxEnqueued() { return 0; } #endif }; -typedef Serial1Class MSerialT; #if SERIAL_PORT == -1 - extern MSerialT customizedSerial1; + typedef Serial1Class MSerialT1; + extern MSerialT1 customizedSerial1; #endif #if SERIAL_PORT_2 == -1 - extern MSerialT customizedSerial2; + typedef Serial1Class MSerialT2; + extern MSerialT2 customizedSerial2; #endif -#endif // HAS_USB_SERIAL diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp index 96769f261f..eb5b9d6039 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.cpp +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.cpp @@ -29,7 +29,7 @@ #include "wifi.h" #include -MSerialT webSocketSerial(false); +MSerialWebSocketT webSocketSerial(false); AsyncWebSocket ws("/ws"); // TODO Move inside the class. // RingBuffer impl diff --git a/Marlin/src/HAL/ESP32/WebSocketSerial.h b/Marlin/src/HAL/ESP32/WebSocketSerial.h index 574f7b10f0..6b3e419d10 100644 --- a/Marlin/src/HAL/ESP32/WebSocketSerial.h +++ b/Marlin/src/HAL/ESP32/WebSocketSerial.h @@ -81,5 +81,5 @@ public: #endif }; -typedef Serial1Class MSerialT; -extern MSerialT webSocketSerial; +typedef Serial1Class MSerialWebSocketT; +extern MSerialWebSocketT webSocketSerial; diff --git a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp index f35328d22f..f2aecf54a0 100644 --- a/Marlin/src/HAL/LPC1768/MarlinSerial.cpp +++ b/Marlin/src/HAL/LPC1768/MarlinSerial.cpp @@ -26,9 +26,9 @@ #include "../../inc/MarlinConfig.h" #if USING_HW_SERIAL0 - MarlinSerial _MSerial(LPC_UART0); - MSerialT MSerial0(true, _MSerial); - extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); } + MarlinSerial _MSerial0(LPC_UART0); + MSerialT MSerial0(true, _MSerial0); + extern "C" void UART0_IRQHandler() { _MSerial0.IRQHandler(); } #endif #if USING_HW_SERIAL1 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) if (false) {} #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 #if USING_HW_SERIAL1 else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c); diff --git a/Marlin/src/HAL/SAMD51/HAL.h b/Marlin/src/HAL/SAMD51/HAL.h index 85ac5dd00c..491c3f82c4 100644 --- a/Marlin/src/HAL/SAMD51/HAL.h +++ b/Marlin/src/HAL/SAMD51/HAL.h @@ -43,8 +43,6 @@ extern DefaultSerial4 MSerial3; extern DefaultSerial5 MSerial4; - // MYSERIAL1 required before MarlinSerial includes! - #define __MSERIAL(X) MSerial##X #define _MSERIAL(X) __MSERIAL(X) #define MSERIAL(X) _MSERIAL(INCREMENT(X)) diff --git a/Marlin/src/HAL/STM32/HAL.h b/Marlin/src/HAL/STM32/HAL.h index 469d08e435..8ac9e6bd80 100644 --- a/Marlin/src/HAL/STM32/HAL.h +++ b/Marlin/src/HAL/STM32/HAL.h @@ -37,6 +37,9 @@ #include +// +// Serial Ports +// #ifdef USBCON #include #include "../../core/serial_hook.h" @@ -44,9 +47,6 @@ extern DefaultSerial1 MSerial0; #endif -// ------------------------ -// Defines -// ------------------------ #define _MSERIAL(X) MSerial##X #define MSERIAL(X) _MSERIAL(X) diff --git a/Marlin/src/HAL/STM32F1/HAL.h b/Marlin/src/HAL/STM32F1/HAL.h index af4d27f43e..8b306f48fa 100644 --- a/Marlin/src/HAL/STM32F1/HAL.h +++ b/Marlin/src/HAL/STM32F1/HAL.h @@ -36,7 +36,6 @@ #include "fastio.h" #include "watchdog.h" - #include #include @@ -63,11 +62,10 @@ #ifdef SERIAL_USB typedef ForwardSerial1Class< USBSerial > DefaultSerial1; extern DefaultSerial1 MSerial0; - - #if !HAS_SD_HOST_DRIVE - #define UsbSerial MSerial0 - #else + #if HAS_SD_HOST_DRIVE #define UsbSerial MarlinCompositeSerial + #else + #define UsbSerial MSerial0 #endif #endif @@ -86,11 +84,7 @@ #define MYSERIAL1 MSERIAL(SERIAL_PORT) #else #define MYSERIAL1 MSERIAL(1) // dummy port - #if NUM_UARTS == 5 - #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 + static_assert(false, "SERIAL_PORT must be from 1 to " STRINGIFY(NUM_UARTS) ". You can also use -1 if the board supports Native USB.") #endif #ifdef SERIAL_PORT_2 @@ -100,11 +94,7 @@ #define MYSERIAL2 MSERIAL(SERIAL_PORT_2) #else #define MYSERIAL2 MSERIAL(1) // dummy port - #if NUM_UARTS == 5 - #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 + 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.") #endif #endif @@ -115,11 +105,7 @@ #define MMU2_SERIAL MSERIAL(MMU2_SERIAL_PORT) #else #define MMU2_SERIAL MSERIAL(1) // dummy port - #if NUM_UARTS == 5 - #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 + 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.") #endif #endif @@ -130,11 +116,7 @@ #define LCD_SERIAL MSERIAL(LCD_SERIAL_PORT) #else #define LCD_SERIAL MSERIAL(1) // dummy port - #if NUM_UARTS == 5 - #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 + 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.") #endif #if HAS_DGUS_LCD #define SERIAL_GET_TX_BUFFER_FREE() LCD_SERIAL.availableForWrite() diff --git a/Marlin/src/HAL/TEENSY31_32/HAL.h b/Marlin/src/HAL/TEENSY31_32/HAL.h index 52904465be..8baa7936f5 100644 --- a/Marlin/src/HAL/TEENSY31_32/HAL.h +++ b/Marlin/src/HAL/TEENSY31_32/HAL.h @@ -68,6 +68,8 @@ extern USBSerialType USBSerial; #elif WITHIN(SERIAL_PORT, 0, 3) DECLARE_SERIAL(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 #define HAL_SERVO_LIB libServo diff --git a/Marlin/src/core/serial.h b/Marlin/src/core/serial.h index 842a2b02c5..2628b3d2e5 100644 --- a/Marlin/src/core/serial.h +++ b/Marlin/src/core/serial.h @@ -87,16 +87,12 @@ extern uint8_t marlin_debug_flags; // If we have a catchall, use that directly #ifdef SERIAL_CATCHALL #define _SERIAL_LEAF_2 SERIAL_CATCHALL + #elif HAS_ETHERNET + typedef ConditionalSerial SerialLeafT2; // We need to create an instance here + extern SerialLeafT2 msSerial2; + #define _SERIAL_LEAF_2 msSerial2 #else - #if HAS_ETHERNET - // We need to create an instance here - typedef ConditionalSerial SerialLeafT2; - extern SerialLeafT2 msSerial2; - #define _SERIAL_LEAF_2 msSerial2 - #else - // Don't create a useless instance here, directly use the existing instance - #define _SERIAL_LEAF_2 MYSERIAL2 - #endif + #define _SERIAL_LEAF_2 MYSERIAL2 // Don't create a useless instance here, directly use the existing instance #endif // Hook Meatpack if it's enabled on the second leaf diff --git a/Marlin/src/inc/Conditionals_post.h b/Marlin/src/inc/Conditionals_post.h index 67a6ce86e1..d5bb3e68db 100644 --- a/Marlin/src/inc/Conditionals_post.h +++ b/Marlin/src/inc/Conditionals_post.h @@ -1949,7 +1949,6 @@ #undef _SERIAL_ID #undef _TMC_UART_IS #undef TMC_UART_IS -#undef CONF_SERIAL_IS #undef ANY_SERIAL_IS // diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 72e31b7b25..0c55232969 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,34 +45,22 @@ // 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 SERIAL_PORT == 0 + #if CONF_SERIAL_IS(0) static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; 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 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 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 TXD_NAME_3[] PROGMEM = { "TXD3" }; #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 ///////////////////////////////////////////////////////////////////////////// @@ -103,12 +91,11 @@ const PinInfo pin_array[] PROGMEM = { * Each entry takes up 6 bytes in FLASH: * 2 byte pointer to location of the name string * 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 */ - // manually add pins ... - #if SERIAL_PORT == 0 + #if CONF_SERIAL_IS(0) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, @@ -119,7 +106,9 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif - #elif SERIAL_PORT == 1 + #endif + + #if CONF_SERIAL_IS(1) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, @@ -135,7 +124,9 @@ const PinInfo pin_array[] PROGMEM = { { TXD_NAME_1, 15, true }, #endif #endif - #elif SERIAL_PORT == 2 + #endif + + #if CONF_SERIAL_IS(2) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, @@ -148,7 +139,9 @@ const PinInfo pin_array[] PROGMEM = { { TXD_NAME_2, 10, true }, #endif #endif - #elif SERIAL_PORT == 3 + #endif + + #if CONF_SERIAL_IS(3) #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, @@ -166,68 +159,8 @@ const PinInfo pin_array[] PROGMEM = { #endif #endif - #ifdef SERIAL_PORT_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) - { 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_2 == 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 - #include "pinsDebug_list.h" - #line 231 + #line 164 };