Define HW serial ports needed for TMC UART (#21446)

This commit is contained in:
Scott Lahteine
2021-03-25 16:19:03 -05:00
committed by GitHub
parent 8bf6b190ff
commit 84b961cb20
10 changed files with 134 additions and 37 deletions

View File

@@ -530,12 +530,6 @@
#define NEED_LSF 1
#endif
// Flag the indexed serial ports that are in use
#define ANY_SERIAL_IS(N) (defined(SERIAL_PORT) && SERIAL_PORT == (N)) || \
(defined(SERIAL_PORT_2) && SERIAL_PORT_2 == (N)) || \
(defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == (N)) || \
(defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT == (N))
#if BOTH(HAS_TFT_LVGL_UI, CUSTOM_MENU_MAIN)
#define _HAS_1(N) (defined(USER_DESC_##N) && defined(USER_GCODE_##N))
#define HAS_USER_ITEM(V...) DO(HAS,||,V)

View File

@@ -1838,6 +1838,112 @@
#define HAS_TMC_SW_SERIAL 1
#endif
//
// Set USING_HW_SERIALn flags for used Serial Ports
//
// ... HW_SerialX
#define _SERIAL_ID(P) _CAT(HW_,P)
// ... (HW_Serial1 == HW_SerialX || HW_Serial1 == HW_MSerialX)
#define _TMC_UART_IS(P,N) ( _SERIAL_ID(P##_HARDWARE_SERIAL) == _SERIAL_ID(Serial##N) || _SERIAL_ID(P) == _SERIAL_ID(MSerial##N) )
#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && _TMC_UART_IS(A, N))
// Flag the indexed hardware serial ports in use
#define CONF_SERIAL_IS(N) ( (defined(SERIAL_PORT) && SERIAL_PORT == N) \
|| (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 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 ANY_SERIAL_IS(N) ( CONF_SERIAL_IS(N) \
|| TMC_UART_IS(X, N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
|| TMC_UART_IS(X2, N) || TMC_UART_IS(Y2, N) || TMC_UART_IS(Z2, N) || TMC_UART_IS(Z3, N) || TMC_UART_IS(Z4, N) \
|| TMC_UART_IS(E0, N) || TMC_UART_IS(E1, N) || TMC_UART_IS(E2, N) || TMC_UART_IS(E3, N) || TMC_UART_IS(E4, N) )
#define HW_Serial 501
#define HW_Serial0 502
#define HW_Serial1 503
#define HW_Serial2 504
#define HW_Serial3 505
#define HW_Serial4 506
#define HW_Serial5 507
#define HW_Serial6 508
#define HW_MSerial0 509
#define HW_MSerial1 510
#define HW_MSerial2 511
#define HW_MSerial3 512
#define HW_MSerial4 513
#define HW_MSerial5 514
#define HW_MSerial6 515
#define HW_MSerial7 516
#define HW_MSerial8 517
#define HW_MSerial9 518
#define HW_MSerial10 519
#if CONF_SERIAL_IS(-1)
#define USING_HW_SERIALUSB 1
#endif
#if ANY_SERIAL_IS(0)
#define USING_HW_SERIAL0 1
#endif
#if ANY_SERIAL_IS(1)
#define USING_HW_SERIAL1 1
#endif
#if ANY_SERIAL_IS(2)
#define USING_HW_SERIAL2 1
#endif
#if ANY_SERIAL_IS(3)
#define USING_HW_SERIAL3 1
#endif
#if ANY_SERIAL_IS(4)
#define USING_HW_SERIAL4 1
#endif
#if ANY_SERIAL_IS(5)
#define USING_HW_SERIAL5 1
#endif
#if ANY_SERIAL_IS(6)
#define USING_HW_SERIAL6 1
#endif
#if ANY_SERIAL_IS(7)
#define USING_HW_SERIAL7 1
#endif
#if ANY_SERIAL_IS(8)
#define USING_HW_SERIAL8 1
#endif
#if ANY_SERIAL_IS(9)
#define USING_HW_SERIAL9 1
#endif
#if ANY_SERIAL_IS(10)
#define USING_HW_SERIAL10 1
#endif
#undef HW_Serial
#undef HW_Serial0
#undef HW_Serial1
#undef HW_Serial2
#undef HW_Serial3
#undef HW_Serial4
#undef HW_Serial5
#undef HW_Serial6
#undef HW_MSerial0
#undef HW_MSerial1
#undef HW_MSerial2
#undef HW_MSerial3
#undef HW_MSerial4
#undef HW_MSerial5
#undef HW_MSerial6
#undef HW_MSerial7
#undef HW_MSerial8
#undef HW_MSerial9
#undef HW_MSerial10
#undef _SERIAL_ID
#undef _TMC_UART_IS
#undef TMC_UART_IS
#undef CONF_SERIAL_IS
#undef ANY_SERIAL_IS
//
// Endstops and bed probe
//