Browse Source

Sanity check for LPC serial pin conflict (#16981)

Scott Lahteine 4 years ago
parent
commit
daa32013b1
No account linked to committer's email address

+ 3
- 3
Marlin/src/HAL/HAL_LPC1768/MarlinSerial.cpp View File

@@ -32,21 +32,21 @@
32 32
   }
33 33
 #endif
34 34
 
35
-#if (defined(SERIAL_PORT) && SERIAL_PORT == 1) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 1) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 1)
35
+#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
36 36
   MarlinSerial MSerial1((LPC_UART_TypeDef *) LPC_UART1);
37 37
   extern "C" void UART1_IRQHandler() {
38 38
     MSerial1.IRQHandler();
39 39
   }
40 40
 #endif
41 41
 
42
-#if (defined(SERIAL_PORT) && SERIAL_PORT == 2) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 2) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 2)
42
+#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
43 43
   MarlinSerial MSerial2(LPC_UART2);
44 44
   extern "C" void UART2_IRQHandler() {
45 45
     MSerial2.IRQHandler();
46 46
   }
47 47
 #endif
48 48
 
49
-#if (defined(SERIAL_PORT) && SERIAL_PORT == 3) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 3) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 3)
49
+#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
50 50
   MarlinSerial MSerial3(LPC_UART3);
51 51
   extern "C" void UART3_IRQHandler() {
52 52
     MSerial3.IRQHandler();

+ 49
- 0
Marlin/src/HAL/HAL_LPC1768/inc/SanityCheck.h View File

@@ -76,3 +76,52 @@
76 76
 #if ENABLED(BAUD_RATE_GCODE)
77 77
   #error "BAUD_RATE_GCODE is not yet supported on LPC176x."
78 78
 #endif
79
+
80
+/**
81
+ * Flag any serial port conflicts
82
+ *
83
+ *   Port  |  TX   |  RX   |
84
+ *    ---  |  ---  |  ---  |
85
+ * Serial  | P0_02 | P0_03 |
86
+ * Serial1 | P0_15 | P0_16 |
87
+ * Serial2 | P0_10 | P0_11 |
88
+ * Serial3 | P0_00 | P0_01 |
89
+ */
90
+#if (defined(SERIAL_PORT) && SERIAL_PORT == 0) || (defined(SERIAL_PORT_2) && SERIAL_PORT_2 == 0) || (defined(DGUS_SERIAL_PORT) && DGUS_SERIAL_PORT == 0)
91
+  #if  X_CS_PIN == P0_02 || TMC_SW_MISO == P0_02 || (E_STEPPERS && E_MUX1_PIN == P0_02) \
92
+    || Y_CS_PIN == P0_03 || TMC_SW_MOSI == P0_03 || (E_STEPPERS && E_MUX0_PIN == P0_03)
93
+    #error "Serial port assignment (0) conflicts with other pins!"
94
+  #endif
95
+#endif
96
+
97
+#if SERIAL_PORT == 1 || SERIAL_PORT_2 == 1 || DGUS_SERIAL_PORT == 1
98
+  #if TMC_SW_SCK == P0_15
99
+    #error "Serial port assignment (1) conflicts with other pins!"
100
+  #elif HAS_SPI_LCD
101
+    #if  BTN_EN2 == P0_15 || SCK_PIN == P0_15 || LCD_PINS_D4 == P0_15 || DOGLCD_SCK == P0_15 || LCD_RESET_PIN == P0_15 || LCD_PINS_RS == P0_15 || SHIFT_CLK == P0_15 \
102
+      || BTN_EN1 == P0_16 || LCD_SDSS == P0_16 || LCD_PINS_RS == P0_16 || MISO_PIN == P0_16 || DOGLCD_A0 == P0_16 || SS_PIN == P0_16 || LCD_SDSS == P0_16 || DOGLCD_CS == P0_16 || LCD_RESET_PIN == P0_16 || LCD_BACKLIGHT_PIN == P0_16
103
+      #error "Serial port assignment (1) conflicts with other pins!"
104
+    #endif
105
+  #endif
106
+#endif
107
+
108
+#if SERIAL_PORT == 2 || SERIAL_PORT_2 == 2 || DGUS_SERIAL_PORT == 2
109
+  #if  Y_MIN_PIN == P0_10 || Z_MIN_PROBE_PIN == P0_10 \
110
+    || X_ENABLE_PIN == P0_10 || Y_ENABLE_PIN == P0_10 || X2_ENABLE_PIN == P0_10 || Y2_ENABLE_PIN == P0_10 || Z2_ENABLE_PIN == P0_10 || Z3_ENABLE_PIN == P0_10 || Z4_ENABLE_PIN == P0_10 \
111
+    || X2_CS_PIN == P0_10 || Y2_CS_PIN == P0_10 || Z2_CS_PIN == P0_10 || Z3_CS_PIN == P0_10 || Z4_CS_PIN == P0_10 \
112
+    || X_DIR_PIN == P0_11 || Y_DIR_PIN == P0_11 || X2_DIR_PIN == P0_11 || Y2_DIR_PIN == P0_11 || Z2_DIR_PIN == P0_11 || Z3_DIR_PIN == P0_11 || Z4_DIR_PIN == P0_11 \
113
+    || X2_STEP_PIN == P0_11 || Y2_STEP_PIN == P0_11 || Z2_STEP_PIN == P0_11 || Z3_STEP_PIN == P0_11 || Z4_STEP_PIN == P0_11
114
+    #error "Serial port assignment (2) conflicts with other pins!"
115
+  #elif  (E_STEPPERS > 1 && (E1_ENABLE_PIN == P0_10 || E1_CS_PIN == P0_10)) || (E_STEPPERS > 0 && (E0_DIR_PIN == P0_11 || E0_STEP_PIN == P0_11))
116
+    #error "Serial port assignment (2) conflicts with other pins!"
117
+  #endif
118
+#endif
119
+
120
+#if SERIAL_PORT == 3 || SERIAL_PORT_2 == 3 || DGUS_SERIAL_PORT == 3
121
+  #if  X_MIN_PIN == P0_00 || Y_SERIAL_TX_PIN == P0_00 || Y_SERIAL_RX_PIN == P0_00 \
122
+    || X_MAX_PIN == P0_01 || X_SERIAL_TX_PIN == P0_01 || X_SERIAL_RX_PIN == P0_01
123
+    #error "Serial port assignment (2) conflicts with other pins!"
124
+  #elif E_STEPPERS > 1 && (E1_DIR_PIN == P0_00 || E1_STEP_PIN == P0_01)
125
+    #error "Serial port assignment (2) conflicts with other pins!"
126
+  #endif
127
+#endif

Loading…
Cancel
Save