From 5b6cb83d00c7add0803bfe7be1b9d41e7ae81440 Mon Sep 17 00:00:00 2001 From: ellensp Date: Tue, 22 Sep 2020 20:04:22 +1200 Subject: [PATCH 1/3] Update LPC1768/9 debug uart pins when using new LPC_PINCFG_UART defines --- Marlin/src/pins/pinsDebug.h | 64 +++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 14 deletions(-) diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 0766d818e75f..21bca02ec811 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -116,7 +116,7 @@ const PinInfo pin_array[] PROGMEM = { #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif @@ -128,24 +128,42 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_1, 16, true }, - { TXD_NAME_1, 15, true }, + #if defined(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 #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_2, 11, true }, - { TXD_NAME_2, 10, true }, + #if defined(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 (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_3, 1, true }, - { TXD_NAME_3, 0, true }, + #if defined(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 @@ -157,7 +175,7 @@ const PinInfo pin_array[] PROGMEM = { #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif @@ -169,24 +187,42 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_1, 16, true }, - { TXD_NAME_1, 15, true }, + #if defined(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 (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_2, 11, true }, - { TXD_NAME_2, 10, true }, + #if defined(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 (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - { RXD_NAME_3, 1, true }, - { TXD_NAME_3, 0, true }, + #if defined(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 From 6a4a68fc466bbb77a1a3adb7451ca0159959a1c4 Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 15:47:38 -0500 Subject: [PATCH 2/3] Update pinsDebug.h --- Marlin/src/pins/pinsDebug.h | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 21bca02ec811..4db538e4ee99 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -116,7 +116,7 @@ const PinInfo pin_array[] PROGMEM = { #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif @@ -128,10 +128,10 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART1_P2_00) // TX P2_00 RX P2_01 + #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 + #else // TX P0_15 RX P0_16 { RXD_NAME_1, 16, true }, { TXD_NAME_1, 15, true }, #endif @@ -141,10 +141,10 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART2_P2_08) // TX P2_08 RX P2_09 + #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 + #else // TX P0_10 RX P0_11 { RXD_NAME_2, 11, true }, { TXD_NAME_2, 10, true }, #endif @@ -154,13 +154,13 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART3_P0_25) // TX P0_25 RX P0_26 + #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 + #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 + #else // TX P0_00 RX P0_01 { RXD_NAME_3, 1, true }, { TXD_NAME_3, 0, true }, #endif @@ -175,7 +175,7 @@ const PinInfo pin_array[] PROGMEM = { #elif AVR_ATmega1284_FAMILY { RXD_NAME_0, 8, true }, { TXD_NAME_0, 9, true }, - #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 + #elif defined(TARGET_LPC1768) // TX P0_02 RX P0_03 { RXD_NAME_0, 3, true }, { TXD_NAME_0, 2, true }, #endif @@ -187,10 +187,10 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_1, 10, true }, { TXD_NAME_1, 11, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART1_P2_00) // TX P2_00 RX P2_01 + #if defined(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 + #else // TX P0_15 RX P0_16 { RXD_NAME_1, 16, true }, { TXD_NAME_1, 15, true }, #endif @@ -200,10 +200,10 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART2_P2_08) // TX P2_08 RX P2_09 + #if defined(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 + #else // TX P0_10 RX P0_11 { RXD_NAME_2, 11, true }, { TXD_NAME_2, 10, true }, #endif @@ -213,13 +213,13 @@ const PinInfo pin_array[] PROGMEM = { { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART3_P0_25) // TX P0_25 RX P0_26 + #if defined(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 + #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 + #else // TX P0_00 RX P0_01 { RXD_NAME_3, 1, true }, { TXD_NAME_3, 0, true }, #endif From 9edb932d736509a54c3c840cbec09e07ab4c408f Mon Sep 17 00:00:00 2001 From: Scott Lahteine Date: Wed, 23 Sep 2020 15:54:32 -0500 Subject: [PATCH 3/3] Better pinsDebug defines --- Marlin/src/HAL/AVR/fastio.h | 16 ++++++++++----- Marlin/src/HAL/AVR/pinsDebug.h | 4 +++- Marlin/src/pins/pinsDebug.h | 36 +++++++++++++++++----------------- 3 files changed, 32 insertions(+), 24 deletions(-) diff --git a/Marlin/src/HAL/AVR/fastio.h b/Marlin/src/HAL/AVR/fastio.h index bd6935aaf0ce..dd0163466110 100644 --- a/Marlin/src/HAL/AVR/fastio.h +++ b/Marlin/src/HAL/AVR/fastio.h @@ -29,11 +29,17 @@ #include -#define AVR_AT90USB1286_FAMILY (defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__)) -#define AVR_ATmega1284_FAMILY (defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__)) -#define AVR_ATmega2560_FAMILY (defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__)) -#define AVR_ATmega2561_FAMILY (defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__)) -#define AVR_ATmega328_FAMILY (defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__)) +#if defined(__AVR_AT90USB1287__) || defined(__AVR_AT90USB1286__) || defined(__AVR_AT90USB1286P__) || defined(__AVR_AT90USB646__) || defined(__AVR_AT90USB646P__) || defined(__AVR_AT90USB647__) + #define AVR_AT90USB1286_FAMILY 1 +#elif defined(__AVR_ATmega644__) || defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644PA__) || defined(__AVR_ATmega1284P__) + #define AVR_ATmega1284_FAMILY 1 +#elif defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) + #define AVR_ATmega2560_FAMILY 1 +#elif defined(__AVR_ATmega1281__) || defined(__AVR_ATmega2561__) + #define AVR_ATmega2561_FAMILY 1 +#elif defined(__AVR_ATmega168__) || defined(__AVR_ATmega328__) || defined(__AVR_ATmega328P__) + #define AVR_ATmega328_FAMILY 1 +#endif /** * Include Ports and Functions diff --git a/Marlin/src/HAL/AVR/pinsDebug.h b/Marlin/src/HAL/AVR/pinsDebug.h index d73f520d1494..2cf740a5597a 100644 --- a/Marlin/src/HAL/AVR/pinsDebug.h +++ b/Marlin/src/HAL/AVR/pinsDebug.h @@ -26,7 +26,9 @@ #define NUMBER_PINS_TOTAL NUM_DIGITAL_PINS -#define AVR_ATmega2560_FAMILY_PLUS_70 MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H) +#if MB(BQ_ZUM_MEGA_3D, MIGHTYBOARD_REVE, MINIRAMBO, SCOOVO_X9H) + #define AVR_ATmega2560_FAMILY_PLUS_70 1 +#endif #if AVR_AT90USB1286_FAMILY diff --git a/Marlin/src/pins/pinsDebug.h b/Marlin/src/pins/pinsDebug.h index 4db538e4ee99..06a8144291ca 100644 --- a/Marlin/src/pins/pinsDebug.h +++ b/Marlin/src/pins/pinsDebug.h @@ -45,7 +45,7 @@ #line 46 // manually add pins that have names that are macros which don't play well with these macros -#if (AVR_ATmega2560_FAMILY || AVR_ATmega1284_FAMILY || defined(ARDUINO_ARCH_SAM) || defined(TARGET_LPC1768)) +#if ANY(AVR_ATmega2560_FAMILY, AVR_ATmega1284_FAMILY, ARDUINO_ARCH_SAM, TARGET_LPC1768) #if SERIAL_PORT == 0 static const char RXD_NAME_0[] PROGMEM = { "RXD0" }; static const char TXD_NAME_0[] PROGMEM = { "TXD0" }; @@ -110,7 +110,7 @@ const PinInfo pin_array[] PROGMEM = { // manually add pins ... #if SERIAL_PORT == 0 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, #elif AVR_ATmega1284_FAMILY @@ -121,7 +121,7 @@ const PinInfo pin_array[] PROGMEM = { { TXD_NAME_0, 2, true }, #endif #elif SERIAL_PORT == 1 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_1, 19, true }, { TXD_NAME_1, 18, true }, #elif AVR_ATmega1284_FAMILY @@ -134,23 +134,23 @@ const PinInfo pin_array[] PROGMEM = { #else // TX P0_15 RX P0_16 { RXD_NAME_1, 16, true }, { TXD_NAME_1, 15, true }, - #endif + #endif #endif #elif SERIAL_PORT == 2 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #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 }, + { 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 (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) @@ -169,7 +169,7 @@ const PinInfo pin_array[] PROGMEM = { #ifdef SERIAL_PORT_2 #if SERIAL_PORT_2 == 0 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_0, 0, true }, { TXD_NAME_0, 1, true }, #elif AVR_ATmega1284_FAMILY @@ -180,40 +180,40 @@ const PinInfo pin_array[] PROGMEM = { { TXD_NAME_0, 2, true }, #endif #elif SERIAL_PORT_2 == 1 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #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) - #if defined(LPC_PINCFG_UART1_P2_00) // TX P2_00 RX P2_01 + #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 #endif #elif SERIAL_PORT_2 == 2 - #if (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_2, 17, true }, { TXD_NAME_2, 16, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART2_P2_08) // TX P2_08 RX P2_09 - { RXD_NAME_2, 0x49, true }, - { TXD_NAME_2, 0x48, true }, + #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 (AVR_ATmega2560_FAMILY || defined(ARDUINO_ARCH_SAM)) + #if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM) { RXD_NAME_3, 15, true }, { TXD_NAME_3, 14, true }, #elif defined(TARGET_LPC1768) - #if defined(LPC_PINCFG_UART3_P0_25) // TX P0_25 RX P0_26 + #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