Skip to content

Commit

Permalink
CONF_SERIAL_IS => SERIAL_IN_USE
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Oct 11, 2022
1 parent ba0861a commit 9020a67
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 53 deletions.
22 changes: 12 additions & 10 deletions Marlin/src/HAL/AVR/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,22 +37,24 @@
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
|| BTN_EN1 == N || BTN_EN2 == N \
)
#if CONF_SERIAL_IS(0)
#if SERIAL_IN_USE(0)
// D0-D1. No known conflicts.
#endif
#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#else
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
#error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
#if SERIAL_IN_USE(1)
#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
#if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#else
#if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)
#error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
#endif
#endif
#endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif
#undef CHECK_SERIAL_PIN
Expand Down
8 changes: 4 additions & 4 deletions Marlin/src/HAL/DUE/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@
|| X_DIR_PIN == N || Y_DIR_PIN == N || Z_DIR_PIN == N \
|| X_ENA_PIN == N || Y_ENA_PIN == N || Z_ENA_PIN == N \
)
#if CONF_SERIAL_IS(0) // D0-D1. No known conflicts.
#if SERIAL_IN_USE(0) // D0-D1. No known conflicts.
#endif
#if CONF_SERIAL_IS(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
#error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))
#error "Serial Port 2 pin D16 and/or D17 conflicts with another pin on the board."
#endif
#if CONF_SERIAL_IS(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#if SERIAL_IN_USE(3) && (CHECK_SERIAL_PIN(14) || CHECK_SERIAL_PIN(15))
#error "Serial Port 3 pin D14 and/or D15 conflicts with another pin on the board."
#endif
#undef CHECK_SERIAL_PIN
Expand Down
46 changes: 24 additions & 22 deletions Marlin/src/HAL/STM32/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,56 +54,58 @@
/**
* Check for common serial pin conflicts
*/
#define CHECK_SERIAL_PIN(N) ( \
BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \
)
#if CONF_SERIAL_IS(1)
#if defined(UART1_TX_PIN) && CHECK_SERIAL_PIN(UART1_TX_PIN)
#define _CHECK_SERIAL_PIN(N) (defined(N) && ( \
BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \
SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \
))
#define CHECK_SERIAL_PIN(T,N) _CHECK_SERIAL_PIN(UART##N##_##T##_PIN)
#if SERIAL_IN_USE(1)
#if CHECK_SERIAL_PIN(TX,1)
#error "Serial Port 1 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART1_RX_PIN) && CHECK_SERIAL_PIN(UART1_RX_PIN)
#if CHECK_SERIAL_PIN(RX,1)
#error "Serial Port 1 RX IO pins conflict with another pin on the board."
#endif
#endif
#if CONF_SERIAL_IS(2)
#if defined(UART2_TX_PIN) && CHECK_SERIAL_PIN(UART2_TX_PIN)
#if SERIAL_IN_USE(2)
#if CHECK_SERIAL_PIN(TX,2)
#error "Serial Port 2 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART2_RX_PIN) && CHECK_SERIAL_PIN(UART2_RX_PIN)
#if CHECK_SERIAL_PIN(RX,2)
#error "Serial Port 2 RX IO pins conflict with another pin on the board."
#endif
#endif
#if CONF_SERIAL_IS(3)
#if defined(UART3_TX_PIN) && CHECK_SERIAL_PIN(UART3_TX_PIN)
#if SERIAL_IN_USE(3)
#if CHECK_SERIAL_PIN(TX,3)
#error "Serial Port 3 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART3_RX_PIN) && CHECK_SERIAL_PIN(UART3_RX_PIN)
#if CHECK_SERIAL_PIN(RX,3)
#error "Serial Port 3 RX IO pins conflict with another pin on the board."
#endif
#endif
#if CONF_SERIAL_IS(4)
#if defined(UART4_TX_PIN) && CHECK_SERIAL_PIN(UART4_TX_PIN)
#if SERIAL_IN_USE(4)
#if CHECK_SERIAL_PIN(TX,4)
#error "Serial Port 4 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART4_RX_PIN) && CHECK_SERIAL_PIN(UART4_RX_PIN)
#if CHECK_SERIAL_PIN(RX,4)
#error "Serial Port 4 RX IO pins conflict with another pin on the board."
#endif
#endif
#if CONF_SERIAL_IS(5)
#if defined(UART5_TX_PIN) && CHECK_SERIAL_PIN(UART5_TX_PIN)
#if SERIAL_IN_USE(5)
#if CHECK_SERIAL_PIN(TX,5)
#error "Serial Port 5 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART5_RX_PIN) && CHECK_SERIAL_PIN(UART5_RX_PIN)
#if CHECK_SERIAL_PIN(RX,5)
#error "Serial Port 5 RX IO pins conflict with another pin on the board."
#endif
#endif
#if CONF_SERIAL_IS(6)
#if defined(UART6_TX_PIN) && CHECK_SERIAL_PIN(UART6_TX_PIN)
#if SERIAL_IN_USE(6)
#if CHECK_SERIAL_PIN(TX,6)
#error "Serial Port 6 TX IO pins conflict with another pin on the board."
#endif
#if defined(UART6_RX_PIN) && CHECK_SERIAL_PIN(UART6_RX_PIN)
#if CHECK_SERIAL_PIN(RX,6)
#error "Serial Port 6 RX IO pins conflict with another pin on the board."
#endif
#endif
#undef CHECK_SERIAL_PIN
#undef _CHECK_SERIAL_PIN
6 changes: 3 additions & 3 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -2446,15 +2446,15 @@
//

// Flag the indexed hardware serial ports in use
#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
#define SERIAL_IN_USE(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
|| (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == N) \
|| (defined(SERIAL_PORT_3) && SERIAL_PORT_3 == N) \
|| (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
|| (defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == N) )

// Flag the named hardware serial ports in use
#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && (CAT(HW_,A##_HARDWARE_SERIAL) == HW_Serial##N || CAT(HW_,A##_HARDWARE_SERIAL) == HW_MSerial##N))
#define ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \
#define ANY_SERIAL_IS(N) ( SERIAL_IN_USE(N) \
|| TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
|| TMC_UART_IS(I, N) || TMC_UART_IS(J , N) || TMC_UART_IS(K , N) \
|| TMC_UART_IS(U, N) || TMC_UART_IS(V , N) || TMC_UART_IS(W , N) \
Expand All @@ -2481,7 +2481,7 @@
#define HW_MSerial9 518
#define HW_MSerial10 519

#if CONF_SERIAL_IS(-1)
#if SERIAL_IN_USE(-1)
#define USING_HW_SERIALUSB 1
#endif
#if ANY_SERIAL_IS(0)
Expand Down
16 changes: 8 additions & 8 deletions Marlin/src/pins/pinsDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,19 +49,19 @@

// 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 CONF_SERIAL_IS(0)
#if SERIAL_IN_USE(0)
static const char RXD_NAME_0[] PROGMEM = { "RXD0" };
static const char TXD_NAME_0[] PROGMEM = { "TXD0" };
#endif
#if CONF_SERIAL_IS(1)
#if SERIAL_IN_USE(1)
static const char RXD_NAME_1[] PROGMEM = { "RXD1" };
static const char TXD_NAME_1[] PROGMEM = { "TXD1" };
#endif
#if CONF_SERIAL_IS(2)
#if SERIAL_IN_USE(2)
static const char RXD_NAME_2[] PROGMEM = { "RXD2" };
static const char TXD_NAME_2[] PROGMEM = { "TXD2" };
#endif
#if CONF_SERIAL_IS(3)
#if SERIAL_IN_USE(3)
static const char RXD_NAME_3[] PROGMEM = { "RXD3" };
static const char TXD_NAME_3[] PROGMEM = { "TXD3" };
#endif
Expand Down Expand Up @@ -99,7 +99,7 @@ const PinInfo pin_array[] PROGMEM = {
* 2 bytes containing the digital/analog bool flag
*/

#if CONF_SERIAL_IS(0)
#if SERIAL_IN_USE(0)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_0, 0, true },
{ TXD_NAME_0, 1, true },
Expand All @@ -112,7 +112,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif
#endif

#if CONF_SERIAL_IS(1)
#if SERIAL_IN_USE(1)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_1, 19, true },
{ TXD_NAME_1, 18, true },
Expand All @@ -130,7 +130,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif
#endif

#if CONF_SERIAL_IS(2)
#if SERIAL_IN_USE(2)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_2, 17, true },
{ TXD_NAME_2, 16, true },
Expand All @@ -145,7 +145,7 @@ const PinInfo pin_array[] PROGMEM = {
#endif
#endif

#if CONF_SERIAL_IS(3)
#if SERIAL_IN_USE(3)
#if EITHER(AVR_ATmega2560_FAMILY, ARDUINO_ARCH_SAM)
{ RXD_NAME_3, 15, true },
{ TXD_NAME_3, 14, true },
Expand Down
12 changes: 6 additions & 6 deletions Marlin/src/pins/pinsDebug_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -1899,47 +1899,47 @@

// Hardware UART pins

#if CONF_SERIAL_IS(1)
#if SERIAL_IN_USE(1)
#if PIN_EXISTS(UART1_TX)
REPORT_NAME_DIGITAL(__LINE__, UART1_TX_PIN)
#endif
#if PIN_EXISTS(UART1_RX)
REPORT_NAME_DIGITAL(__LINE__, UART1_RX_PIN)
#endif
#endif
#if CONF_SERIAL_IS(2)
#if SERIAL_IN_USE(2)
#if PIN_EXISTS(UART2_TX)
REPORT_NAME_DIGITAL(__LINE__, UART2_TX_PIN)
#endif
#if PIN_EXISTS(UART2_RX)
REPORT_NAME_DIGITAL(__LINE__, UART2_RX_PIN)
#endif
#endif
#if CONF_SERIAL_IS(3)
#if SERIAL_IN_USE(3)
#if PIN_EXISTS(UART3_TX)
REPORT_NAME_DIGITAL(__LINE__, UART3_TX_PIN)
#endif
#if PIN_EXISTS(UART3_RX)
REPORT_NAME_DIGITAL(__LINE__, UART3_RX_PIN)
#endif
#endif
#if CONF_SERIAL_IS(4)
#if SERIAL_IN_USE(4)
#if PIN_EXISTS(UART4_TX)
REPORT_NAME_DIGITAL(__LINE__, UART4_TX_PIN)
#endif
#if PIN_EXISTS(UART4_RX)
REPORT_NAME_DIGITAL(__LINE__, UART4_RX_PIN)
#endif
#endif
#if CONF_SERIAL_IS(5)
#if SERIAL_IN_USE(5)
#if PIN_EXISTS(UART5_TX)
REPORT_NAME_DIGITAL(__LINE__, UART5_TX_PIN)
#endif
#if PIN_EXISTS(UART5_RX)
REPORT_NAME_DIGITAL(__LINE__, UART5_RX_PIN)
#endif
#endif
#if CONF_SERIAL_IS(6)
#if SERIAL_IN_USE(6)
#if PIN_EXISTS(UART6_TX)
REPORT_NAME_DIGITAL(__LINE__, UART6_TX_PIN)
#endif
Expand Down

0 comments on commit 9020a67

Please sign in to comment.