Quellcode durchsuchen

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

Scott Lahteine vor 3 Jahren
Ursprung
Commit
84b961cb20
Es ist kein Account mit der E-Mail-Adresse des Committers verbunden

+ 4
- 4
Marlin/src/HAL/DUE/HAL.cpp Datei anzeigen

@@ -106,16 +106,16 @@ uint16_t HAL_adc_get_result() {
106 106
 }
107 107
 
108 108
 // Forward the default serial ports
109
-#if ANY_SERIAL_IS(0)
109
+#if USING_HW_SERIAL0
110 110
   DefaultSerial1 MSerial0(false, Serial);
111 111
 #endif
112
-#if ANY_SERIAL_IS(1)
112
+#if USING_HW_SERIAL1
113 113
   DefaultSerial2 MSerial1(false, Serial1);
114 114
 #endif
115
-#if ANY_SERIAL_IS(2)
115
+#if USING_HW_SERIAL2
116 116
   DefaultSerial3 MSerial2(false, Serial2);
117 117
 #endif
118
-#if ANY_SERIAL_IS(3)
118
+#if USING_HW_SERIAL3
119 119
   DefaultSerial4 MSerial3(false, Serial3);
120 120
 #endif
121 121
 

+ 1
- 1
Marlin/src/HAL/DUE/MarlinSerial.h Datei anzeigen

@@ -140,7 +140,7 @@ struct MarlinSerialCfg {
140 140
   static constexpr bool MAX_RX_QUEUED     = ENABLED(SERIAL_STATS_MAX_RX_QUEUED);
141 141
 };
142 142
 
143
-#if SERIAL_PORT >= 0
143
+#if defined(SERIAL_PORT) && SERIAL_PORT >= 0
144 144
   typedef Serial1Class< MarlinSerial< MarlinSerialCfg<SERIAL_PORT> > > MSerialT;
145 145
   extern MSerialT customizedSerial1;
146 146
 #endif

+ 10
- 9
Marlin/src/HAL/LPC1768/MarlinSerial.cpp Datei anzeigen

@@ -21,25 +21,26 @@
21 21
  */
22 22
 #ifdef TARGET_LPC1768
23 23
 
24
-#include "../../inc/MarlinConfigPre.h"
25 24
 #include "MarlinSerial.h"
26 25
 
27
-#if ANY_SERIAL_IS(0)
26
+#include "../../inc/MarlinConfig.h"
27
+
28
+#if USING_HW_SERIAL0
28 29
   MarlinSerial _MSerial(LPC_UART0);
29 30
   MSerialT MSerial0(true, _MSerial);
30 31
   extern "C" void UART0_IRQHandler() { _MSerial.IRQHandler(); }
31 32
 #endif
32
-#if ANY_SERIAL_IS(1)
33
+#if USING_HW_SERIAL1
33 34
   MarlinSerial _MSerial1((LPC_UART_TypeDef *) LPC_UART1);
34 35
   MSerialT MSerial1(true, _MSerial1);
35 36
   extern "C" void UART1_IRQHandler() { _MSerial1.IRQHandler(); }
36 37
 #endif
37
-#if ANY_SERIAL_IS(2)
38
+#if USING_HW_SERIAL2
38 39
   MarlinSerial _MSerial2(LPC_UART2);
39 40
   MSerialT MSerial2(true, _MSerial2);
40 41
   extern "C" void UART2_IRQHandler() { _MSerial2.IRQHandler(); }
41 42
 #endif
42
-#if ANY_SERIAL_IS(3)
43
+#if USING_HW_SERIAL3
43 44
   MarlinSerial _MSerial3(LPC_UART3);
44 45
   MSerialT MSerial3(true, _MSerial3);
45 46
   extern "C" void UART3_IRQHandler() { _MSerial3.IRQHandler(); }
@@ -50,16 +51,16 @@
50 51
   bool MarlinSerial::recv_callback(const char c) {
51 52
     // Need to figure out which serial port we are and react in consequence (Marlin does not have CONTAINER_OF macro)
52 53
     if (false) {}
53
-    #if ANY_SERIAL_IS(0)
54
+    #if USING_HW_SERIAL0
54 55
       else if (this == &_MSerial) emergency_parser.update(MSerial0.emergency_state, c);
55 56
     #endif
56
-    #if ANY_SERIAL_IS(1)
57
+    #if USING_HW_SERIAL1
57 58
       else if (this == &_MSerial1) emergency_parser.update(MSerial1.emergency_state, c);
58 59
     #endif
59
-    #if ANY_SERIAL_IS(2)
60
+    #if USING_HW_SERIAL2
60 61
       else if (this == &_MSerial2) emergency_parser.update(MSerial2.emergency_state, c);
61 62
     #endif
62
-    #if ANY_SERIAL_IS(3)
63
+    #if USING_HW_SERIAL3
63 64
       else if (this == &_MSerial3) emergency_parser.update(MSerial3.emergency_state, c);
64 65
     #endif
65 66
     return true;

+ 4
- 4
Marlin/src/HAL/LPC1768/inc/SanityCheck.h Datei anzeigen

@@ -92,7 +92,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
92 92
 #define ANY_TX(N,V...) DO(IS_TX##N,||,V)
93 93
 #define ANY_RX(N,V...) DO(IS_RX##N,||,V)
94 94
 
95
-#if ANY_SERIAL_IS(0)
95
+#if USING_HW_SERIAL0
96 96
   #define IS_TX0(P) (P == P0_02)
97 97
   #define IS_RX0(P) (P == P0_03)
98 98
   #if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
@@ -106,7 +106,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
106 106
   #undef IS_RX0
107 107
 #endif
108 108
 
109
-#if ANY_SERIAL_IS(1)
109
+#if USING_HW_SERIAL1
110 110
   #define IS_TX1(P) (P == P0_15)
111 111
   #define IS_RX1(P) (P == P0_16)
112 112
   #define _IS_TX1_1 IS_TX1
@@ -127,7 +127,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
127 127
   #undef _IS_RX1_1
128 128
 #endif
129 129
 
130
-#if ANY_SERIAL_IS(2)
130
+#if USING_HW_SERIAL2
131 131
   #define IS_TX2(P) (P == P0_10)
132 132
   #define IS_RX2(P) (P == P0_11)
133 133
   #define _IS_TX2_1 IS_TX2
@@ -161,7 +161,7 @@ static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported o
161 161
   #undef _IS_RX2_1
162 162
 #endif
163 163
 
164
-#if ANY_SERIAL_IS(3)
164
+#if USING_HW_SERIAL3
165 165
   #define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
166 166
   #define PIN_IS_RX3(P) (P##_PIN == P0_01)
167 167
   #if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)

+ 5
- 5
Marlin/src/HAL/SAMD51/HAL.cpp Datei anzeigen

@@ -25,19 +25,19 @@
25 25
 #include <wiring_private.h>
26 26
 
27 27
 #ifdef ADAFRUIT_GRAND_CENTRAL_M4
28
-  #if ANY_SERIAL_IS(-1)
28
+  #if USING_HW_SERIALUSB
29 29
     DefaultSerial1 MSerial0(false, Serial);
30 30
   #endif
31
-  #if ANY_SERIAL_IS(0)
31
+  #if USING_HW_SERIAL0
32 32
     DefaultSerial2 MSerial1(false, Serial1);
33 33
   #endif
34
-  #if ANY_SERIAL_IS(1)
34
+  #if USING_HW_SERIAL1
35 35
     DefaultSerial3 MSerial2(false, Serial2);
36 36
   #endif
37
-  #if ANY_SERIAL_IS(2)
37
+  #if USING_HW_SERIAL2
38 38
     DefaultSerial4 MSerial3(false, Serial3);
39 39
   #endif
40
-  #if ANY_SERIAL_IS(3)
40
+  #if USING_HW_SERIAL3
41 41
     DefaultSerial5 MSerial4(false, Serial4);
42 42
   #endif
43 43
 #endif

+ 3
- 3
Marlin/src/HAL/SAMD51/MarlinSerial_AGCM4.cpp Datei anzeigen

@@ -27,7 +27,7 @@
27 27
 
28 28
 #include "../../inc/MarlinConfig.h"
29 29
 
30
-#if ANY_SERIAL_IS(1)
30
+#if USING_HW_SERIAL1
31 31
   UartT Serial2(false, &sercom4, PIN_SERIAL2_RX, PIN_SERIAL2_TX, PAD_SERIAL2_RX, PAD_SERIAL2_TX);
32 32
   void SERCOM4_0_Handler() { Serial2.IrqHandler(); }
33 33
   void SERCOM4_1_Handler() { Serial2.IrqHandler(); }
@@ -35,7 +35,7 @@
35 35
   void SERCOM4_3_Handler() { Serial2.IrqHandler(); }
36 36
 #endif
37 37
 
38
-#if ANY_SERIAL_IS(2)
38
+#if USING_HW_SERIAL2
39 39
   UartT Serial3(false, &sercom1, PIN_SERIAL3_RX, PIN_SERIAL3_TX, PAD_SERIAL3_RX, PAD_SERIAL3_TX);
40 40
   void SERCOM1_0_Handler() { Serial3.IrqHandler(); }
41 41
   void SERCOM1_1_Handler() { Serial3.IrqHandler(); }
@@ -43,7 +43,7 @@
43 43
   void SERCOM1_3_Handler() { Serial3.IrqHandler(); }
44 44
 #endif
45 45
 
46
-#if ANY_SERIAL_IS(3)
46
+#if USING_HW_SERIAL3
47 47
   UartT Serial4(false, &sercom5, PIN_SERIAL4_RX, PIN_SERIAL4_TX, PAD_SERIAL4_RX, PAD_SERIAL4_TX);
48 48
   void SERCOM5_0_Handler() { Serial4.IrqHandler(); }
49 49
   void SERCOM5_1_Handler() { Serial4.IrqHandler(); }

+ 0
- 4
Marlin/src/HAL/STM32/MarlinSerial.cpp Datei anzeigen

@@ -28,7 +28,6 @@
28 28
 #ifndef USART4
29 29
   #define USART4 UART4
30 30
 #endif
31
-
32 31
 #ifndef USART5
33 32
   #define USART5 UART5
34 33
 #endif
@@ -43,15 +42,12 @@
43 42
 #if defined(SERIAL_PORT) && SERIAL_PORT >= 0
44 43
   DECLARE_SERIAL_PORT_EXP(SERIAL_PORT)
45 44
 #endif
46
-
47 45
 #if defined(SERIAL_PORT_2) && SERIAL_PORT_2 >= 0
48 46
   DECLARE_SERIAL_PORT_EXP(SERIAL_PORT_2)
49 47
 #endif
50
-
51 48
 #if defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT >= 0
52 49
   DECLARE_SERIAL_PORT_EXP(MMU2_SERIAL_PORT)
53 50
 #endif
54
-
55 51
 #if defined(LCD_SERIAL_PORT) && LCD_SERIAL_PORT >= 0
56 52
   DECLARE_SERIAL_PORT_EXP(LCD_SERIAL_PORT)
57 53
 #endif

+ 0
- 6
Marlin/src/inc/Conditionals_adv.h Datei anzeigen

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

+ 106
- 0
Marlin/src/inc/Conditionals_post.h Datei anzeigen

@@ -1839,6 +1839,112 @@
1839 1839
 #endif
1840 1840
 
1841 1841
 //
1842
+// Set USING_HW_SERIALn flags for used Serial Ports
1843
+//
1844
+
1845
+// ... HW_SerialX
1846
+#define _SERIAL_ID(P) _CAT(HW_,P)
1847
+
1848
+// ... (HW_Serial1 == HW_SerialX || HW_Serial1 == HW_MSerialX)
1849
+#define _TMC_UART_IS(P,N) ( _SERIAL_ID(P##_HARDWARE_SERIAL) == _SERIAL_ID(Serial##N) || _SERIAL_ID(P) == _SERIAL_ID(MSerial##N) )
1850
+#define TMC_UART_IS(A,N) (defined(A##_HARDWARE_SERIAL) && _TMC_UART_IS(A, N))
1851
+
1852
+// Flag the indexed hardware serial ports in use
1853
+#define CONF_SERIAL_IS(N) (  (defined(SERIAL_PORT)      && SERIAL_PORT == N) \
1854
+                          || (defined(SERIAL_PORT_2)    && SERIAL_PORT_2 == N) \
1855
+                          || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
1856
+                          || (defined(LCD_SERIAL_PORT)  && LCD_SERIAL_PORT == N) )
1857
+
1858
+// Flag the named hardware serial ports in use
1859
+#define ANY_SERIAL_IS(N) (  CONF_SERIAL_IS(N) \
1860
+                         || TMC_UART_IS(X,  N) || TMC_UART_IS(Y , N) || TMC_UART_IS(Z , N) \
1861
+                         || 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) \
1862
+                         || 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) )
1863
+
1864
+#define HW_Serial    501
1865
+#define HW_Serial0   502
1866
+#define HW_Serial1   503
1867
+#define HW_Serial2   504
1868
+#define HW_Serial3   505
1869
+#define HW_Serial4   506
1870
+#define HW_Serial5   507
1871
+#define HW_Serial6   508
1872
+#define HW_MSerial0  509
1873
+#define HW_MSerial1  510
1874
+#define HW_MSerial2  511
1875
+#define HW_MSerial3  512
1876
+#define HW_MSerial4  513
1877
+#define HW_MSerial5  514
1878
+#define HW_MSerial6  515
1879
+#define HW_MSerial7  516
1880
+#define HW_MSerial8  517
1881
+#define HW_MSerial9  518
1882
+#define HW_MSerial10 519
1883
+
1884
+#if CONF_SERIAL_IS(-1)
1885
+  #define USING_HW_SERIALUSB 1
1886
+#endif
1887
+#if ANY_SERIAL_IS(0)
1888
+  #define USING_HW_SERIAL0 1
1889
+#endif
1890
+#if ANY_SERIAL_IS(1)
1891
+  #define USING_HW_SERIAL1 1
1892
+#endif
1893
+#if ANY_SERIAL_IS(2)
1894
+  #define USING_HW_SERIAL2 1
1895
+#endif
1896
+#if ANY_SERIAL_IS(3)
1897
+  #define USING_HW_SERIAL3 1
1898
+#endif
1899
+#if ANY_SERIAL_IS(4)
1900
+  #define USING_HW_SERIAL4 1
1901
+#endif
1902
+#if ANY_SERIAL_IS(5)
1903
+  #define USING_HW_SERIAL5 1
1904
+#endif
1905
+#if ANY_SERIAL_IS(6)
1906
+  #define USING_HW_SERIAL6 1
1907
+#endif
1908
+#if ANY_SERIAL_IS(7)
1909
+  #define USING_HW_SERIAL7 1
1910
+#endif
1911
+#if ANY_SERIAL_IS(8)
1912
+  #define USING_HW_SERIAL8 1
1913
+#endif
1914
+#if ANY_SERIAL_IS(9)
1915
+  #define USING_HW_SERIAL9 1
1916
+#endif
1917
+#if ANY_SERIAL_IS(10)
1918
+  #define USING_HW_SERIAL10 1
1919
+#endif
1920
+
1921
+#undef HW_Serial
1922
+#undef HW_Serial0
1923
+#undef HW_Serial1
1924
+#undef HW_Serial2
1925
+#undef HW_Serial3
1926
+#undef HW_Serial4
1927
+#undef HW_Serial5
1928
+#undef HW_Serial6
1929
+#undef HW_MSerial0
1930
+#undef HW_MSerial1
1931
+#undef HW_MSerial2
1932
+#undef HW_MSerial3
1933
+#undef HW_MSerial4
1934
+#undef HW_MSerial5
1935
+#undef HW_MSerial6
1936
+#undef HW_MSerial7
1937
+#undef HW_MSerial8
1938
+#undef HW_MSerial9
1939
+#undef HW_MSerial10
1940
+
1941
+#undef _SERIAL_ID
1942
+#undef _TMC_UART_IS
1943
+#undef TMC_UART_IS
1944
+#undef CONF_SERIAL_IS
1945
+#undef ANY_SERIAL_IS
1946
+
1947
+//
1842 1948
 // Endstops and bed probe
1843 1949
 //
1844 1950
 

+ 1
- 1
buildroot/share/extras/header.h Datei anzeigen

@@ -1,6 +1,6 @@
1 1
 /**
2 2
  * Marlin 3D Printer Firmware
3
- * Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
3
+ * Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4 4
  *
5 5
  * Based on Sprinter and grbl.
6 6
  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm

Laden…
Abbrechen
Speichern