Prusa MINI Firmware overview
pins_MKS_SBASE.h
Go to the documentation of this file.
1 /**
2  * Marlin 3D Printer Firmware
3  * Copyright (c) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
4  *
5  * Based on Sprinter and grbl.
6  * Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
20  *
21  */
22 #pragma once
23 
24 /**
25  * MKS SBASE pin assignments
26  */
27 
28 #ifndef TARGET_LPC1768
29  #error "Oops! Make sure you have the LPC1768 environment selected in your IDE."
30 #endif
31 
32 #ifndef BOARD_INFO_NAME
33  #define BOARD_INFO_NAME "MKS SBASE"
34 #endif
35 #ifndef BOARD_WEBSITE_URL
36  #define BOARD_WEBSITE_URL "github.com/makerbase-mks/MKS-SBASE"
37 #endif
38 
39 #define LED_PIN P1_18 // Used as a status indicator
40 #define LED2_PIN P1_19
41 #define LED3_PIN P1_20
42 #define LED4_PIN P1_21
43 
44 //
45 // Servos
46 //
47 #define SERVO0_PIN P1_23 // J8-3 (low jitter)
48 #define SERVO1_PIN P2_12 // J8-4
49 #define SERVO2_PIN P2_11 // J8-5
50 #define SERVO3_PIN P4_28 // J8-6
51 
52 //
53 // Limit Switches - Not Interrupt Capable
54 //
55 #define X_MIN_PIN P1_24 // 10k pullup to 3.3V, 1K series
56 #define X_MAX_PIN P1_25 // 10k pullup to 3.3V, 1K series
57 #define Y_MIN_PIN P1_26 // 10k pullup to 3.3V, 1K series
58 #define Y_MAX_PIN P1_27 // 10k pullup to 3.3V, 1K series
59 #define Z_MIN_PIN P1_28 // The original Mks Sbase DIO19 has a 10k pullup to 3.3V or 5V, 1K series, so when using a Zprobe we must use DIO41 (J8 P1.22)
60 #define Z_MAX_PIN P1_29 // 10k pullup to 3.3V, 1K series
61 
62 #ifndef Z_MIN_PROBE_PIN
63  #define Z_MIN_PROBE_PIN P4_28 // Connector J8
64 #endif
65 
66 //
67 // Steppers
68 //
69 #define X_STEP_PIN P2_00
70 #define X_DIR_PIN P0_05
71 #define X_ENABLE_PIN P0_04
72 
73 #define Y_STEP_PIN P2_01
74 #define Y_DIR_PIN P0_11
75 #define Y_ENABLE_PIN P0_10
76 
77 #define Z_STEP_PIN P2_02
78 #define Z_DIR_PIN P0_20
79 #define Z_ENABLE_PIN P0_19
80 
81 #define E0_STEP_PIN P2_03
82 #define E0_DIR_PIN P0_22
83 #define E0_ENABLE_PIN P0_21
84 
85 #define E1_STEP_PIN P2_08
86 #define E1_DIR_PIN P2_13
87 #define E1_ENABLE_PIN P4_29
88 
89 //
90 // Temperature Sensors
91 // 3.3V max when defined as an analog input
92 //
93 #define TEMP_BED_PIN 0 // A0 (TH1)
94 #define TEMP_0_PIN 1 // A1 (TH2)
95 #define TEMP_1_PIN 2 // A2 (TH3)
96 #define TEMP_2_PIN 3 // A3 (TH4)
97 
98 //
99 // Heaters / Fans
100 //
101 #define HEATER_BED_PIN P2_05
102 #define HEATER_0_PIN P2_07
103 #define HEATER_1_PIN P2_06
104 #ifndef FAN_PIN
105  #define FAN_PIN P2_04
106 #endif
107 
108 //
109 // Connector J7
110 // Note: These pins are all digitally shared with the EXP1/EXP2 Connector.
111 // Using them with an LCD connected or configured will lead to hangs & crashes.
112 //
113 
114 // 5V
115 // NC
116 // GND
117 #define PIN_P0_17 P0_17
118 #define PIN_P0_16 P0_16
119 #define PIN_P0_15 P0_15
120 
121 //
122 // Connector J8
123 //
124 
125 // GND
126 #define PIN_P1_22 P1_22
127 #define PIN_P1_23 P1_23 // PWM Capable
128 #define PIN_P2_12 P2_12 // Interrupt Capable
129 #define PIN_P2_11 P2_11 // Interrupt Capable
130 
131 //
132 // Průša i3 MK2 Multi Material Multiplexer Support
133 //
134 #if ENABLED(MK2_MULTIPLEXER)
135  #define E_MUX0_PIN P1_23 // J8-3
136  #define E_MUX1_PIN P2_12 // J8-4
137  #define E_MUX2_PIN P2_11 // J8-5
138 #endif
139 
140 //
141 // Misc. Functions
142 //
143 #define PS_ON_PIN P0_25 // TH3 Connector
144 
145 //
146 // Ethernet pins
147 //
148 #ifndef ULTIPANEL
149  #define ENET_MDIO P1_17 // J12-4
150  #define ENET_RX_ER P1_14 // J12-6
151  #define ENET_RXD1 P1_10 // J12-8
152 #endif
153 
154 #define ENET_MOC P1_16 // J12-3
155 #define REF_CLK P1_15 // J12-5
156 #define ENET_RXD0 P1_09 // J12-7
157 #define ENET_CRS P1_08 // J12-9
158 #define ENET_TX_EN P1_04 // J12-10
159 #define ENET_TXD0 P1_00 // J12-11
160 #define ENET_TXD1 P1_01 // J12-12
161 
162 #ifndef SDCARD_CONNECTION
163  #define SDCARD_CONNECTION ONBOARD
164 #endif
165 
166 #define ONBOARD_SD_CS_PIN P0_06 // Chip select for "System" SD card
167 
168 #if SD_CONNECTION_IS(CUSTOM_CABLE)
169 
170  /**
171  * A custom cable is needed. See the README file in the
172  * Marlin\src\config\examples\Mks\Sbase directory
173  * P0.27 is on EXP2 and the on-board SD card's socket. That means it can't be
174  * used as the SD_DETECT for the LCD's SD card.
175  *
176  * The best solution is to use the custom cable to connect the LCD's SD_DETECT
177  * to a pin NOT on EXP2.
178  *
179  * If you can't find a pin to use for the LCD's SD_DETECT then comment out
180  * SD_DETECT_PIN entirely and remove that wire from the the custom cable.
181  */
182  #define SD_DETECT_PIN P2_11 // J8-5 (moved from EXP2 P0.27)
183  #define SCK_PIN P1_22 // J8-2 (moved from EXP2 P0.7)
184  #define MISO_PIN P1_23 // J8-3 (moved from EXP2 P0.8)
185  #define MOSI_PIN P2_12 // J8-4 (moved from EXP2 P0.9)
186  #define SS_PIN P0_28
187  #define LPC_SOFTWARE_SPI // With a custom cable we need software SPI because the
188  // selected pins are not on a hardware SPI controller
189 #elif SD_CONNECTION_IS(LCD)
190  // use standard cable and header, SPI and SD detect sre shared with on-board SD card
191  // hardware SPI is used for both SD cards. The detect pin is shred between the
192  // LCD and onboard SD readers so we disable it.
193  #define SCK_PIN P0_07
194  #define MISO_PIN P0_08
195  #define MOSI_PIN P0_09
196  #define SS_PIN P0_28
197 #elif SD_CONNECTION_IS(ONBOARD)
198  #define SD_DETECT_PIN P0_27
199  #define SCK_PIN P0_07
200  #define MISO_PIN P0_08
201  #define MOSI_PIN P0_09
202  #define SS_PIN ONBOARD_SD_CS_PIN
203 #endif
204 
205 /**
206  * Smart LCD adapter
207  *
208  * The Smart LCD adapter can be used for the two 10 pin LCD controllers such as
209  * REPRAP_DISCOUNT_SMART_CONTROLLER. It can't be used for controllers that use
210  * DOGLCD_A0, DOGLCD_CS, LCD_PINS_D5, LCD_PINS_D6 or LCD_PINS_D7. A custom cable
211  * is needed to pick up 5V for the EXP1 connection.
212  *
213  * SD card on the LCD uses the same SPI signals as the LCD. This results in garbage/lines
214  * on the LCD display during accesses of the SD card. The menus/code has been arranged so
215  * that the garbage/lines are erased immediately after the SD card accesses are completed.
216  */
217 
218 #if HAS_SPI_LCD
219  #define BEEPER_PIN P1_31 // EXP1.1
220  #define BTN_ENC P1_30 // EXP1.2
221  #define BTN_EN1 P3_26 // EXP2.5
222  #define BTN_EN2 P3_25 // EXP2.3
223  #define LCD_PINS_RS P0_16 // EXP1.4
224  #define LCD_SDSS P0_28 // EXP2.4
225  #define LCD_PINS_ENABLE P0_18 // EXP1.3
226  #define LCD_PINS_D4 P0_15 // EXP1.5
227  #if ANY(VIKI2, miniVIKI)
228  #define DOGLCD_SCK SCK_PIN
229  #define DOGLCD_MOSI MOSI_PIN
230  #endif
231 
232  #if ENABLED(FYSETC_MINI_12864)
233  /**
234  * The FYSETC display can NOT use the SCK and MOSI pins on EXP2, so a
235  * special cable is needed to go between EXP2 on the FYSETC and the
236  * controller board's EXP2 and J8. It also means that a software SPI
237  * is needed to drive those pins.
238  *
239  * The FYSETC requires mode 3 SPI interface.
240  *
241  * Pins 6, 7 & 8 on EXP2 are no connects. That means a second special
242  * cable will be needed if the RGB LEDs are to be active.
243  */
244  #define DOGLCD_CS LCD_PINS_ENABLE // EXP1.3 (LCD_EN on FYSETC schematic)
245  #define DOGLCD_A0 LCD_PINS_RS // EXP1.4 (LCD_A0 on FYSETC schematic)
246  #define DOGLCD_SCK P2_11 // J8-5 (SCK on FYSETC schematic)
247  #define DOGLCD_MOSI P4_28 // J8-6 (MOSI on FYSETC schematic)
248 
249  //#define FORCE_SOFT_SPI // Use this if default of hardware SPI causes display problems
250  // results in LCD soft SPI mode 3, SD soft SPI mode 0
251 
252  #if EITHER(FYSETC_MINI_12864_1_2, FYSETC_MINI_12864_2_0)
253  #ifndef RGB_LED_R_PIN
254  #define RGB_LED_R_PIN P2_12 // J8-4 (LCD_D6 on FYSETC schematic)
255  #endif
256  #ifndef RGB_LED_G_PIN
257  #define RGB_LED_G_PIN P1_23 // J8-3 (LCD_D5 on FYSETC schematic)
258  #endif
259  #ifndef RGB_LED_B_PIN
260  #define RGB_LED_B_PIN P1_22 // J8-2 (LCD_D7 on FYSETC schematic)
261  #endif
262  #elif ENABLED(FYSETC_MINI_12864_2_1)
263  #define NEOPIXEL_PIN P2_12
264  #endif
265 
266  #elif ENABLED(MINIPANEL)
267  // GLCD features
268  // Uncomment screen orientation
269  //#define LCD_SCREEN_ROT_90
270  //#define LCD_SCREEN_ROT_180
271  //#define LCD_SCREEN_ROT_270
272  #endif
273 
274 #endif
275 
276 /**
277  * Example for trinamic drivers using the J8 connector on MKs Sbase.
278  * 2130s need 1 pin for each driver. 2208/2209s need 2 pins for serial control.
279  * This board does not have enough pins to use hardware serial.
280  */
281 
282 #if HAS_DRIVER(TMC2130)
283  // J8
284  #define X_CS_PIN P1_22
285  #define Y_CS_PIN P1_23
286  #define Z_CS_PIN P2_12
287  #define E0_CS_PIN P2_11
288  #define E1_CS_PIN P4_28
289 
290 // Hardware SPI is on EXP2. See if you can make it work:
291 // https://github.com/makerbase-mks/MKS-SBASE/issues/25
292 #define TMC_USE_SW_SPI
293 #if ENABLED(TMC_USE_SW_SPI)
294  #ifndef TMC_SW_MOSI
295  #define TMC_SW_MOSI P0_03 // AUX1
296  #endif
297  #ifndef TMC_SW_MISO
298  #define TMC_SW_MISO P0_02 // AUX1
299  #endif
300  #ifndef TMC_SW_SCK
301  #define TMC_SW_SCK P0_26 // TH4
302  #endif
303  #endif
304 #endif
305 
306 #if MB(MKS_SBASE) && HAS_TMC220x
307 
308  /**
309  * TMC2208/TMC2209 stepper drivers
310  *
311  * The shortage of pins becomes apparent.
312  * Worst case you may have to give up the LCD
313  * RX pins need to be interrupt capable
314  */
315  #define X_SERIAL_TX_PIN P1_22 // J8-2
316  #define X_SERIAL_RX_PIN P2_12 // J8-4 Interrupt Capable
317  #define Y_SERIAL_TX_PIN P1_23 // J8-3
318  #define Y_SERIAL_RX_PIN P2_11 // J8-5 Interrupt Capable
319  #define Z_SERIAL_TX_PIN P2_12 // J8-4
320  #define Z_SERIAL_RX_PIN P0_25 // TH3
321  #define E0_SERIAL_TX_PIN P4_28 // J8-6
322  #define E0_SERIAL_RX_PIN P0_26 // TH4
323 #endif
324 
325 // UNUSED
326 #define PIN_P0_27 P0_27 // EXP2/Onboard SD
327 #define PIN_P0_28 P0_28 // EXP2
328 #define PIN_P0_02 P0_02 // AUX1 (Interrupt Capable/ADC/Serial Port 0)
329 #define PIN_P0_03 P0_03 // AUX1 (Interrupt Capable/ADC/Serial Port 0)
330 
331 /**
332  * PWMs
333  *
334  * There are 6 PWMs. Each PWM can be assigned to one of two pins.
335  *
336  * SERVO2 does NOT have a PWM assigned to it.
337  *
338  * PWM1.1 P1_18 SERVO3_PIN FIL_RUNOUT_PIN 5V output, PWM
339  * PWM1.1 P2_00 E0_STEP_PIN
340  * PWM1.2 P1_20 SERVO0_PIN
341  * PWM1.2 P2_01 X_STEP_PIN
342  * PWM1.3 P1_21 SERVO1_PIN J5-1
343  * PWM1.3 P2_02 Y_STEP_PIN
344  * PWM1.4 P1_23 SDSS(SSEL0) J3-5 AUX-3
345  * PWM1.4 P2_03 Z_STEP_PIN
346  * PWM1.5 P1_24 X_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES
347  * PWM1.5 P2_04 RAMPS_D9_PIN
348  * PWM1.6 P1_26 Y_MIN_PIN 10K PULLUP TO 3.3v, 1K SERIES
349  * PWM1.6 P2_05 RAMPS_D10_PIN
350  */
351 
352 /**
353  * Special pins
354  * P1_30 - not 5V tolerant - EXP1
355  * P1_31 - not 5V tolerant - EXP1
356  * P0_27 - open collector - EXP2
357  * P0_28 - open collector - EXP2
358  *
359  */
360 
361 /**
362  * Serial Ports
363  * P0_00 - Port 3
364  * P0_01 - SD Card (Onboard)
365  * P0_10 - Port 2
366  * P0_11 - Y_EN/Y_DIR
367  * P0_15 - Port 1
368  * P0_16 - EXP1
369  * P0_02 - Port 0
370  * P0_03 - AUX1
371  * P0_29 - Port -1
372  * P0_30 - USB
373  *
374  */