My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pins_MKS_ROBIN_NANO_V3.h 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2020 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. #if NOT_TARGET(STM32F4, STM32F4xx)
  24. #error "Oops! Select an STM32F4 board in 'Tools > Board.'"
  25. #elif HOTENDS > 2 || E_STEPPERS > 2
  26. #error "MKS Robin Nano V3 supports up to 2 hotends / E-steppers."
  27. #elif HAS_FSMC_TFT
  28. #error "MKS Robin Nano V3 doesn't support FSMC-based TFT displays."
  29. #endif
  30. #define BOARD_INFO_NAME "MKS Robin Nano V3"
  31. // Avoid conflict with TIMER_TONE
  32. #define STEP_TIMER 10
  33. // Use one of these or SDCard-based Emulation will be used
  34. //#define SRAM_EEPROM_EMULATION // Use BackSRAM-based EEPROM emulation
  35. //#define FLASH_EEPROM_EMULATION // Use Flash-based EEPROM emulation
  36. #define I2C_EEPROM
  37. //
  38. // Release PB4 (Z_DIR_PIN) from JTAG NRST role
  39. //
  40. //
  41. // Limit Switches
  42. //
  43. #define X_DIAG_PIN PD15
  44. #define Y_DIAG_PIN PD2
  45. #define Z_DIAG_PIN PC8
  46. #define E0_DIAG_PIN PC4
  47. #define E1_DIAG_PIN PE7
  48. //
  49. #define X_STOP_PIN PA15
  50. #define Y_STOP_PIN PD2
  51. #define Z_MIN_PIN PC8
  52. #define Z_MAX_PIN PC4
  53. //
  54. // Steppers
  55. //
  56. #define X_ENABLE_PIN PE4
  57. #define X_STEP_PIN PE3
  58. #define X_DIR_PIN PE2
  59. #ifndef X_CS_PIN
  60. #define X_CS_PIN PD5
  61. #endif
  62. #define Y_ENABLE_PIN PE1
  63. #define Y_STEP_PIN PE0
  64. #define Y_DIR_PIN PB9
  65. #ifndef Y_CS_PIN
  66. #define Y_CS_PIN PD7
  67. #endif
  68. #define Z_ENABLE_PIN PB8
  69. #define Z_STEP_PIN PB5
  70. #define Z_DIR_PIN PB4
  71. #ifndef Z_CS_PIN
  72. #define Z_CS_PIN PD4
  73. #endif
  74. #define E0_ENABLE_PIN PB3
  75. #define E0_STEP_PIN PD6
  76. #define E0_DIR_PIN PD3
  77. #ifndef E0_CS_PIN
  78. #define E0_CS_PIN PD9
  79. #endif
  80. #define E1_ENABLE_PIN PA3
  81. #define E1_STEP_PIN PD15
  82. #define E1_DIR_PIN PA1
  83. #ifndef E1_CS_PIN
  84. #define E1_CS_PIN PD8
  85. #endif
  86. //
  87. // Software SPI pins for TMC2130 stepper drivers
  88. //
  89. // This board only support SW SPI for stepper drivers
  90. #if HAS_TMC_SPI
  91. #define TMC_USE_SW_SPI
  92. #endif
  93. #if ENABLED(TMC_USE_SW_SPI)
  94. #if !defined(TMC_SW_MOSI) || TMC_SW_MOSI == -1
  95. #define TMC_SW_MOSI PD14
  96. #endif
  97. #if !defined(TMC_SW_MISO) || TMC_SW_MISO == -1
  98. #define TMC_SW_MISO PD1
  99. #endif
  100. #if !defined(TMC_SW_SCK) || TMC_SW_SCK == -1
  101. #define TMC_SW_SCK PD0
  102. #endif
  103. #endif
  104. #if HAS_TMC_UART
  105. //
  106. // Software serial
  107. // No Hardware serial for steppers
  108. //
  109. #define X_SERIAL_TX_PIN PD5
  110. #define X_SERIAL_RX_PIN PD5
  111. #define Y_SERIAL_TX_PIN PD7
  112. #define Y_SERIAL_RX_PIN PD7
  113. #define Z_SERIAL_TX_PIN PD4
  114. #define Z_SERIAL_RX_PIN PD4
  115. #define E0_SERIAL_TX_PIN PD9
  116. #define E0_SERIAL_RX_PIN PD9
  117. #define E1_SERIAL_TX_PIN PD8
  118. #define E1_SERIAL_RX_PIN PD8
  119. // Reduce baud rate to improve software serial reliability
  120. #define TMC_BAUD_RATE 19200
  121. #endif
  122. //
  123. // Temperature Sensors
  124. //
  125. #define TEMP_0_PIN PC1 // TH1
  126. #define TEMP_1_PIN PA2 // TH2
  127. #define TEMP_BED_PIN PC0 // TB1
  128. //
  129. // Heaters / Fans
  130. //
  131. #define HEATER_0_PIN PE5 // HEATER1
  132. #define HEATER_1_PIN PB0 // HEATER2
  133. #define HEATER_BED_PIN PA0 // HOT BED
  134. #define FAN_PIN PB1 // FAN
  135. #define FAN1_PIN PC14 // FAN1
  136. //
  137. // Thermocouples
  138. //
  139. //#define MAX6675_SS_PIN HEATER_0_PIN // TC1 - CS1
  140. //#define MAX6675_SS_PIN HEATER_1_PIN // TC2 - CS2
  141. //
  142. // Misc. Functions
  143. //
  144. #define MT_DET_1 PA4
  145. #define MT_DET_2 PE6
  146. #define PW_DET PA13
  147. #define PW_OFF PB2
  148. #ifndef FIL_RUNOUT_PIN
  149. #define FIL_RUNOUT_PIN MT_DET_1
  150. #endif
  151. #ifndef FIL_RUNOUT2_PIN
  152. #define FIL_RUNOUT2_PIN MT_DET_2
  153. #endif
  154. #define POWER_LOSS_PIN PW_DET
  155. #define PS_ON_PIN PW_OFF
  156. //
  157. // Enable MKSPWC support
  158. //
  159. //#define SUICIDE_PIN PB2
  160. //#define KILL_PIN PA2
  161. //#define KILL_PIN_INVERTING true
  162. #define SERVO0_PIN PA8 // Enable BLTOUCH support
  163. //#define LED_PIN PB2
  164. // Random Info
  165. #define USB_SERIAL -1 //Usb Serial
  166. #define WIFI_SERIAL 3 //USART3
  167. #define MKS_WIFI_MODULE_SERIAL 1 //USART1
  168. #define MKS_WIFI_MODULE_SPI 2 //SPI2
  169. #ifndef SDCARD_CONNECTION
  170. #define SDCARD_CONNECTION ONBOARD
  171. #endif
  172. //
  173. // Onboard SD card
  174. //
  175. // detect pin dont work when ONBOARD and NO_SD_HOST_DRIVE disabled
  176. #if SD_CONNECTION_IS(ONBOARD)
  177. #define CUSTOM_SPI_PINS // TODO: needed because is the only way to set SPI3 for SD on STM32 (by now)
  178. #if ENABLED(CUSTOM_SPI_PINS)
  179. #define ENABLE_SPI3
  180. #define SS_PIN -1
  181. #define SDSS PC9
  182. #define SCK_PIN PC10
  183. #define MISO_PIN PC11
  184. #define MOSI_PIN PC12
  185. #define SD_DETECT_PIN PD12
  186. #endif
  187. #endif
  188. //
  189. // LCD SD
  190. //
  191. #if SD_CONNECTION_IS(LCD)
  192. #define CUSTOM_SPI_PINS
  193. #if ENABLED(CUSTOM_SPI_PINS)
  194. #define ENABLE_SPI1
  195. #define SDSS PE10
  196. #define SCK_PIN PA5
  197. #define MISO_PIN PA6
  198. #define MOSI_PIN PA7
  199. #define SD_DETECT_PIN PE12
  200. #endif
  201. #endif
  202. //
  203. // LCD / Controller
  204. #define SPI_FLASH
  205. #define HAS_SPI_FLASH 1
  206. #define SPI_DEVICE 2
  207. #define SPI_FLASH_SIZE 0x1000000
  208. #if ENABLED(SPI_FLASH)
  209. #define W25QXX_CS_PIN PB12
  210. #define W25QXX_MOSI_PIN PC3
  211. #define W25QXX_MISO_PIN PC2
  212. #define W25QXX_SCK_PIN PB13
  213. #endif
  214. /**
  215. * _____ _____
  216. * (BEEPER)PC5 | · · | PE13(BTN_ENC) (SPI1 MISO) PA6 | · · | PA5 (SPI1 SCK)
  217. * (LCD_EN)PD13 | · · | PC6(LCD_RS) (BTN_EN1) PE8 | · · | PE10 (SPI1 CS)
  218. * (LCD_D4)PE14 | · · PE15(LCD_D5) (BTN_EN2) PE11 | · · PA7 (SPI1 MOSI)
  219. * (LCD_D6)PD11 | · · | PD10(LCD_D7) (SPI1_RS) PE12 | · · | RESET
  220. * GND | · · | 5V GND | · · | 3.3V
  221. *  ̄ ̄ ̄  ̄ ̄ ̄
  222. * EXP1 EXP2
  223. */
  224. #if ANY(TFT_COLOR_UI, TFT_LVGL_UI, TFT_CLASSIC_UI)
  225. #ifndef TOUCH_CALIBRATION_X
  226. #define TOUCH_CALIBRATION_X -17253
  227. #endif
  228. #ifndef TOUCH_CALIBRATION_Y
  229. #define TOUCH_CALIBRATION_Y 11579
  230. #endif
  231. #ifndef TOUCH_OFFSET_X
  232. #define TOUCH_OFFSET_X 514
  233. #endif
  234. #ifndef TOUCH_OFFSET_Y
  235. #define TOUCH_OFFSET_Y -24
  236. #endif
  237. #ifndef TOUCH_ORIENTATION
  238. #define TOUCH_ORIENTATION TOUCH_LANDSCAPE
  239. #endif
  240. #define TFT_CS_PIN PD11
  241. #define TFT_SCK_PIN PA5
  242. #define TFT_MISO_PIN PA6
  243. #define TFT_MOSI_PIN PA7
  244. #define TFT_DC_PIN PD10
  245. #define TFT_RST_PIN PC6
  246. #define TFT_A0_PIN TFT_DC_PIN
  247. #define TFT_RESET_PIN PC6
  248. #define TFT_BACKLIGHT_PIN PD13
  249. #define TOUCH_BUTTONS_HW_SPI
  250. #define TOUCH_BUTTONS_HW_SPI_DEVICE 1
  251. #define LCD_BACKLIGHT_PIN PD13
  252. #ifndef TFT_WIDTH
  253. #define TFT_WIDTH 480
  254. #endif
  255. #ifndef TFT_HEIGHT
  256. #define TFT_HEIGHT 320
  257. #endif
  258. #define TOUCH_CS_PIN PE14 // SPI1_NSS
  259. #define TOUCH_SCK_PIN PA5 // SPI1_SCK
  260. #define TOUCH_MISO_PIN PA6 // SPI1_MISO
  261. #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
  262. #define BTN_EN1 PE8
  263. #define BTN_EN2 PE11
  264. #define BEEPER_PIN PC5
  265. #define BTN_ENC PE13
  266. #define LCD_READ_ID 0xD3
  267. #define LCD_USE_DMA_SPI
  268. #define TFT_BUFFER_SIZE 14400
  269. #elif HAS_SPI_LCD
  270. #define BEEPER_PIN PC5
  271. #define BTN_ENC PE13
  272. #define LCD_PINS_ENABLE PD13
  273. #define LCD_PINS_RS PC6
  274. #define BTN_EN1 PE8
  275. #define BTN_EN2 PE11
  276. #define LCD_BACKLIGHT_PIN -1
  277. // MKS MINI12864 and MKS LCD12864B; If using MKS LCD12864A (Need to remove RPK2 resistor)
  278. #if ENABLED(MKS_MINI_12864)
  279. //#define LCD_BACKLIGHT_PIN -1
  280. //#define LCD_RESET_PIN -1
  281. #define DOGLCD_A0 PD11
  282. #define DOGLCD_CS PE15
  283. //#define DOGLCD_SCK PA5
  284. //#define DOGLCD_MOSI PA7
  285. // Required for MKS_MINI_12864 with this board
  286. //#define MKS_LCD12864B
  287. //#undef SHOW_BOOTSCREEN
  288. #else // !MKS_MINI_12864
  289. #define LCD_PINS_D4 PE14
  290. #if ENABLED(ULTIPANEL)
  291. #define LCD_PINS_D5 PE15
  292. #define LCD_PINS_D6 PD11
  293. #define LCD_PINS_D7 PD10
  294. #endif
  295. #define BOARD_ST7920_DELAY_1 DELAY_NS(96)
  296. #define BOARD_ST7920_DELAY_2 DELAY_NS(48)
  297. #define BOARD_ST7920_DELAY_3 DELAY_NS(600)
  298. #endif // !MKS_MINI_12864
  299. #endif // HAS_SPI_LCD
  300. #define HAS_OTG_USB_HOST_SUPPORT