Browse Source

🔧 Some STM32 UART Sanity Checks (#24795)

ellensp 2 years ago
parent
commit
42d30ed102
No account linked to committer's email address

+ 1
- 1
Marlin/Configuration_adv.h View File

@@ -1152,7 +1152,7 @@
1152 1152
 #endif
1153 1153
 
1154 1154
 /**
1155
- * Automatic backlash, position and hotend offset calibration
1155
+ * Automatic backlash, position, and hotend offset calibration
1156 1156
  *
1157 1157
  * Enable G425 to run automatic calibration using an electrically-
1158 1158
  * conductive cube, bolt, or washer mounted on the bed.

+ 9
- 7
Marlin/src/HAL/AVR/inc/SanityCheck.h View File

@@ -40,13 +40,15 @@
40 40
 #if SERIAL_IN_USE(0)
41 41
   // D0-D1. No known conflicts.
42 42
 #endif
43
-#if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
44
-  #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19))
45
-    #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
46
-  #endif
47
-#else
48
-  #if SERIAL_IN_USE(1) && (CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11))
49
-    #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
43
+#if SERIAL_IN_USE(1)
44
+  #if NOT_TARGET(__AVR_ATmega644P__, __AVR_ATmega1284P__)
45
+    #if CHECK_SERIAL_PIN(18) || CHECK_SERIAL_PIN(19)
46
+      #error "Serial Port 1 pin D18 and/or D19 conflicts with another pin on the board."
47
+    #endif
48
+  #else
49
+    #if CHECK_SERIAL_PIN(10) || CHECK_SERIAL_PIN(11)
50
+      #error "Serial Port 1 pin D10 and/or D11 conflicts with another pin on the board."
51
+    #endif
50 52
   #endif
51 53
 #endif
52 54
 #if SERIAL_IN_USE(2) && (CHECK_SERIAL_PIN(16) || CHECK_SERIAL_PIN(17))

+ 59
- 0
Marlin/src/HAL/STM32/inc/SanityCheck.h View File

@@ -50,3 +50,62 @@
50 50
 #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI) && NOT_TARGET(STM32H7xx, STM32F4xx, STM32F1xx)
51 51
   #error "TFT_COLOR_UI, TFT_LVGL_UI and TFT_CLASSIC_UI are currently only supported on STM32H7, STM32F4 and STM32F1 hardware."
52 52
 #endif
53
+
54
+/**
55
+ * Check for common serial pin conflicts
56
+ */
57
+#define _CHECK_SERIAL_PIN(N) (( \
58
+    BTN_EN1 == N || DOGLCD_CS == N || HEATER_BED_PIN == N || FAN_PIN == N || \
59
+    SDIO_D2_PIN == N || SDIO_D3_PIN == N || SDIO_CK_PIN == N || SDIO_CMD_PIN == N \
60
+  ))
61
+#define CHECK_SERIAL_PIN(T,N) defined(UART##N##_##T##_PIN) && _CHECK_SERIAL_PIN(UART##N##_##T##_PIN)
62
+#if SERIAL_IN_USE(1)
63
+  #if CHECK_SERIAL_PIN(TX,1)
64
+    #error "Serial Port 1 TX IO pins conflict with another pin on the board."
65
+  #endif
66
+  #if CHECK_SERIAL_PIN(RX,1)
67
+    #error "Serial Port 1 RX IO pins conflict with another pin on the board."
68
+  #endif
69
+#endif
70
+#if SERIAL_IN_USE(2)
71
+  #if CHECK_SERIAL_PIN(TX,2)
72
+    #error "Serial Port 2 TX IO pins conflict with another pin on the board."
73
+  #endif
74
+  #if CHECK_SERIAL_PIN(RX,2)
75
+    #error "Serial Port 2 RX IO pins conflict with another pin on the board."
76
+  #endif
77
+#endif
78
+#if SERIAL_IN_USE(3)
79
+  #if CHECK_SERIAL_PIN(TX,3)
80
+    #error "Serial Port 3 TX IO pins conflict with another pin on the board."
81
+  #endif
82
+  #if CHECK_SERIAL_PIN(RX,3)
83
+    #error "Serial Port 3 RX IO pins conflict with another pin on the board."
84
+  #endif
85
+#endif
86
+#if SERIAL_IN_USE(4)
87
+  #if CHECK_SERIAL_PIN(TX,4)
88
+    #error "Serial Port 4 TX IO pins conflict with another pin on the board."
89
+  #endif
90
+  #if CHECK_SERIAL_PIN(RX,4)
91
+    #error "Serial Port 4 RX IO pins conflict with another pin on the board."
92
+  #endif
93
+#endif
94
+#if SERIAL_IN_USE(5)
95
+  #if CHECK_SERIAL_PIN(TX,5)
96
+    #error "Serial Port 5 TX IO pins conflict with another pin on the board."
97
+  #endif
98
+  #if CHECK_SERIAL_PIN(RX,5)
99
+    #error "Serial Port 5 RX IO pins conflict with another pin on the board."
100
+  #endif
101
+#endif
102
+#if SERIAL_IN_USE(6)
103
+  #if CHECK_SERIAL_PIN(TX,6)
104
+    #error "Serial Port 6 TX IO pins conflict with another pin on the board."
105
+  #endif
106
+  #if CHECK_SERIAL_PIN(RX,6)
107
+    #error "Serial Port 6 RX IO pins conflict with another pin on the board."
108
+  #endif
109
+#endif
110
+#undef CHECK_SERIAL_PIN
111
+#undef _CHECK_SERIAL_PIN

+ 5
- 5
Marlin/src/inc/Conditionals_post.h View File

@@ -2446,11 +2446,11 @@
2446 2446
 //
2447 2447
 
2448 2448
 // Flag the indexed hardware serial ports in use
2449
-#define SERIAL_IN_USE(N) (  (defined(SERIAL_PORT)      && SERIAL_PORT == N) \
2450
-                          || (defined(SERIAL_PORT_2)    && SERIAL_PORT_2 == N) \
2451
-                          || (defined(SERIAL_PORT_3)    && SERIAL_PORT_3 == N) \
2452
-                          || (defined(MMU2_SERIAL_PORT) && MMU2_SERIAL_PORT == N) \
2453
-                          || (defined(LCD_SERIAL_PORT)  && LCD_SERIAL_PORT == N) )
2449
+#define SERIAL_IN_USE(N) (   (defined(SERIAL_PORT)      && N == SERIAL_PORT) \
2450
+                          || (defined(SERIAL_PORT_2)    && N == SERIAL_PORT_2) \
2451
+                          || (defined(SERIAL_PORT_3)    && N == SERIAL_PORT_3) \
2452
+                          || (defined(MMU2_SERIAL_PORT) && N == MMU2_SERIAL_PORT) \
2453
+                          || (defined(LCD_SERIAL_PORT)  && N == LCD_SERIAL_PORT) )
2454 2454
 
2455 2455
 // Flag the named hardware serial ports in use
2456 2456
 #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))

+ 74
- 0
Marlin/src/pins/pinsDebug_list.h View File

@@ -2232,6 +2232,80 @@
2232 2232
 #endif
2233 2233
 
2234 2234
 //
2235
+// Hardware UART
2236
+//
2237
+#if SERIAL_IN_USE(1)
2238
+  #if PIN_EXISTS(UART1_TX)
2239
+    REPORT_NAME_DIGITAL(__LINE__, UART1_TX_PIN)
2240
+  #endif
2241
+  #if PIN_EXISTS(UART1_RX)
2242
+    REPORT_NAME_DIGITAL(__LINE__, UART1_RX_PIN)
2243
+  #endif
2244
+#endif
2245
+#if SERIAL_IN_USE(2)
2246
+  #if PIN_EXISTS(UART2_TX)
2247
+    REPORT_NAME_DIGITAL(__LINE__, UART2_TX_PIN)
2248
+  #endif
2249
+  #if PIN_EXISTS(UART2_RX)
2250
+    REPORT_NAME_DIGITAL(__LINE__, UART2_RX_PIN)
2251
+  #endif
2252
+#endif
2253
+#if SERIAL_IN_USE(3)
2254
+  #if PIN_EXISTS(UART3_TX)
2255
+    REPORT_NAME_DIGITAL(__LINE__, UART3_TX_PIN)
2256
+  #endif
2257
+  #if PIN_EXISTS(UART3_RX)
2258
+    REPORT_NAME_DIGITAL(__LINE__, UART3_RX_PIN)
2259
+  #endif
2260
+#endif
2261
+#if SERIAL_IN_USE(4)
2262
+  #if PIN_EXISTS(UART4_TX)
2263
+    REPORT_NAME_DIGITAL(__LINE__, UART4_TX_PIN)
2264
+  #endif
2265
+  #if PIN_EXISTS(UART4_RX)
2266
+    REPORT_NAME_DIGITAL(__LINE__, UART4_RX_PIN)
2267
+  #endif
2268
+#endif
2269
+#if SERIAL_IN_USE(5)
2270
+  #if PIN_EXISTS(UART5_TX)
2271
+    REPORT_NAME_DIGITAL(__LINE__, UART5_TX_PIN)
2272
+  #endif
2273
+  #if PIN_EXISTS(UART5_RX)
2274
+    REPORT_NAME_DIGITAL(__LINE__, UART5_RX_PIN)
2275
+  #endif
2276
+#endif
2277
+#if SERIAL_IN_USE(6)
2278
+  #if PIN_EXISTS(UART6_TX)
2279
+    REPORT_NAME_DIGITAL(__LINE__, UART6_TX_PIN)
2280
+  #endif
2281
+  #if PIN_EXISTS(UART6_RX)
2282
+    REPORT_NAME_DIGITAL(__LINE__, UART6_RX_PIN)
2283
+  #endif
2284
+#endif
2285
+
2286
+//
2287
+// SDIO
2288
+//
2289
+#if PIN_EXISTS(SDIO_D0)
2290
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_D0_PIN)
2291
+#endif
2292
+#if PIN_EXISTS(SDIO_D1)
2293
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_D1_PIN)
2294
+#endif
2295
+#if PIN_EXISTS(SDIO_D2)
2296
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_D2_PIN)
2297
+#endif
2298
+#if PIN_EXISTS(SDIO_D3)
2299
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_D3_PIN)
2300
+#endif
2301
+#if PIN_EXISTS(SDIO_CK)
2302
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_CK_PIN)
2303
+#endif
2304
+#if PIN_EXISTS(SDIO_CMD)
2305
+  REPORT_NAME_DIGITAL(__LINE__, SDIO_CMD_PIN)
2306
+#endif
2307
+
2308
+//
2235 2309
 // Miscellaneous
2236 2310
 //
2237 2311
 #if _EXISTS(UNUSED_PWM)

+ 39
- 16
Marlin/src/pins/stm32f1/pins_CREALITY_V4.h View File

@@ -173,14 +173,14 @@
173 173
    *   GND | 9 10 | 5V
174 174
    *        ------
175 175
    */
176
-  #define EXP3_01_PIN                     PC6
177
-  #define EXP3_02_PIN                     PB2
178
-  #define EXP3_03_PIN                     PB10
179
-  #define EXP3_04_PIN                     PB11
180
-  #define EXP3_05_PIN                     PB14
181
-  #define EXP3_06_PIN                     PB13
182
-  #define EXP3_07_PIN                     PB12
183
-  #define EXP3_08_PIN                     PB15
176
+  #define EXP3_01_PIN                       PC6
177
+  #define EXP3_02_PIN                       PB2
178
+  #define EXP3_03_PIN                       PB10
179
+  #define EXP3_04_PIN                       PB11
180
+  #define EXP3_05_PIN                       PB14
181
+  #define EXP3_06_PIN                       PB13
182
+  #define EXP3_07_PIN                       PB12
183
+  #define EXP3_08_PIN                       PB15
184 184
 
185 185
 #elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD)
186 186
 
@@ -194,14 +194,14 @@
194 194
    *   GND | 9 10 | 5V
195 195
    *        ------
196 196
    */
197
-  #define EXP3_01_PIN                     -1
198
-  #define EXP3_02_PIN                     PC5
199
-  #define EXP3_03_PIN                     PB10
200
-  #define EXP3_04_PIN                     -1
201
-  #define EXP3_05_PIN                     PA6
202
-  #define EXP3_06_PIN                     PA5
203
-  #define EXP3_07_PIN                     PA4
204
-  #define EXP3_08_PIN                     PA7
197
+  #define EXP3_01_PIN                       -1
198
+  #define EXP3_02_PIN                       PC5
199
+  #define EXP3_03_PIN                       PB10
200
+  #define EXP3_04_PIN                       -1
201
+  #define EXP3_05_PIN                       PA6
202
+  #define EXP3_06_PIN                       PA5
203
+  #define EXP3_07_PIN                       PA4
204
+  #define EXP3_08_PIN                       PA7
205 205
 
206 206
 #elif EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1)
207 207
   #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller."
@@ -283,3 +283,26 @@
283 283
   #define NEOPIXEL_PIN                      PA13
284 284
 
285 285
 #endif
286
+
287
+// Pins for documentation and sanity checks only.
288
+// Changing these will not change the pin they are on.
289
+
290
+// Hardware UART pins
291
+#define UART1_TX_PIN                        PA9   // default uses CH340 RX
292
+#define UART1_RX_PIN                        PA10  // default uses CH340 TX
293
+#define UART2_TX_PIN                        PA2   // default uses HEATER_BED_PIN
294
+#define UART2_RX_PIN                        PA3   // not connected
295
+#define UART3_TX_PIN                        PB10  // default uses LCD connector
296
+#define UART3_RX_PIN                        PB11  // default uses LCD connector
297
+#define UART4_TX_PIN                        PC10  // default uses sdcard SDIO_D2
298
+#define UART4_RX_PIN                        PC11  // default uses sdcard SDIO_D3
299
+#define UART5_TX_PIN                        PC12  // default uses sdcard SDIO_CK
300
+#define UART5_RX_PIN                        PD2   // default uses sdcard SDIO_CMD
301
+
302
+// SDIO pins
303
+#define SDIO_D0_PIN                         PC8
304
+#define SDIO_D1_PIN                         PC9
305
+#define SDIO_D2_PIN                         PC10
306
+#define SDIO_D3_PIN                         PC11
307
+#define SDIO_CK_PIN                         PC12
308
+#define SDIO_CMD_PIN                        PD2

Loading…
Cancel
Save