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_V2.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396
  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 <https://www.gnu.org/licenses/>.
  20. *
  21. */
  22. #pragma once
  23. /**
  24. * MKS Robin nano (STM32F103VET6) board pin assignments
  25. */
  26. #if NOT_TARGET(__STM32F1__, STM32F1)
  27. #error "Oops! Select an STM32F1 board in 'Tools > Board.'"
  28. #elif HOTENDS > 2 || E_STEPPERS > 2
  29. #error "MKS Robin nano supports up to 2 hotends / E steppers."
  30. #elif HAS_FSMC_TFT
  31. #error "MKS Robin nano v2 doesn't support FSMC-based TFT displays."
  32. #endif
  33. #define BOARD_INFO_NAME "MKS Robin nano V2.0"
  34. #define BOARD_NO_NATIVE_USB
  35. #define USES_DIAG_PINS
  36. // Avoid conflict with TIMER_SERVO when using the STM32 HAL
  37. #define TEMP_TIMER 5
  38. //
  39. // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
  40. //
  41. #define DISABLE_DEBUG
  42. //
  43. // EEPROM
  44. //
  45. //#define FLASH_EEPROM_EMULATION
  46. //#define SDCARD_EEPROM_EMULATION
  47. #if EITHER(NO_EEPROM_SELECTED, I2C_EEPROM)
  48. #define I2C_EEPROM // EEPROM on I2C-0
  49. #define MARLIN_EEPROM_SIZE 0x1000 // 4K
  50. #endif
  51. //
  52. // Note: MKS Robin board is using SPI2 interface.
  53. //
  54. #define SPI_DEVICE 2
  55. //
  56. // Servos
  57. //
  58. #define SERVO0_PIN PA8 // Enable BLTOUCH
  59. //
  60. // Limit Switches
  61. //
  62. #define X_DIAG_PIN PA15
  63. #define Y_DIAG_PIN PA12
  64. #define Z_DIAG_PIN PA11
  65. #define E0_DIAG_PIN PC4
  66. #define E1_DIAG_PIN PE7
  67. #define X_STOP_PIN PA15
  68. #define Y_STOP_PIN PA12
  69. #define Z_MIN_PIN PA11
  70. #define Z_MAX_PIN PC4
  71. //
  72. // Steppers
  73. //
  74. #define X_ENABLE_PIN PE4
  75. #define X_STEP_PIN PE3
  76. #define X_DIR_PIN PE2
  77. #ifndef X_CS_PIN
  78. #define X_CS_PIN PD5
  79. #endif
  80. #define Y_ENABLE_PIN PE1
  81. #define Y_STEP_PIN PE0
  82. #define Y_DIR_PIN PB9
  83. #ifndef Y_CS_PIN
  84. #define Y_CS_PIN PD7
  85. #endif
  86. #define Z_ENABLE_PIN PB8
  87. #define Z_STEP_PIN PB5
  88. #define Z_DIR_PIN PB4
  89. #ifndef Z_CS_PIN
  90. #define Z_CS_PIN PD4
  91. #endif
  92. #define E0_ENABLE_PIN PB3
  93. #define E0_STEP_PIN PD6
  94. #define E0_DIR_PIN PD3
  95. #ifndef E0_CS_PIN
  96. #define E0_CS_PIN PD9
  97. #endif
  98. #define E1_ENABLE_PIN PA3
  99. #define E1_STEP_PIN PD15
  100. #define E1_DIR_PIN PA1
  101. #ifndef E1_CS_PIN
  102. #define E1_CS_PIN PD8
  103. #endif
  104. //
  105. // Software SPI pins for TMC2130 stepper drivers
  106. //
  107. #if ENABLED(TMC_USE_SW_SPI)
  108. #ifndef TMC_SW_MOSI
  109. #define TMC_SW_MOSI PD14
  110. #endif
  111. #ifndef TMC_SW_MISO
  112. #define TMC_SW_MISO PD1
  113. #endif
  114. #ifndef TMC_SW_SCK
  115. #define TMC_SW_SCK PD0
  116. #endif
  117. #endif
  118. #if HAS_TMC_UART
  119. /**
  120. * TMC2208/TMC2209 stepper drivers
  121. *
  122. * Hardware serial communication ports.
  123. * If undefined software serial is used according to the pins below
  124. */
  125. //#define X_HARDWARE_SERIAL MSerial1
  126. //#define Y_HARDWARE_SERIAL MSerial1
  127. //#define Z_HARDWARE_SERIAL MSerial1
  128. //#define E0_HARDWARE_SERIAL MSerial1
  129. //#define E1_HARDWARE_SERIAL MSerial1
  130. #define X_SERIAL_TX_PIN PD5
  131. #define X_SERIAL_RX_PIN PD5
  132. #define Y_SERIAL_TX_PIN PD7
  133. #define Y_SERIAL_RX_PIN PD7
  134. #define Z_SERIAL_TX_PIN PD4
  135. #define Z_SERIAL_RX_PIN PD4
  136. #define E0_SERIAL_TX_PIN PD9
  137. #define E0_SERIAL_RX_PIN PD9
  138. #define E1_SERIAL_TX_PIN PD8
  139. #define E1_SERIAL_RX_PIN PD8
  140. // Reduce baud rate to improve software serial reliability
  141. #define TMC_BAUD_RATE 19200
  142. #endif // HAS_TMC_UART
  143. //
  144. // Temperature Sensors
  145. //
  146. #define TEMP_0_PIN PC1 // TH1
  147. #define TEMP_1_PIN PC2 // TH2
  148. #define TEMP_BED_PIN PC0 // TB1
  149. //
  150. // Heaters / Fans
  151. //
  152. #define HEATER_0_PIN PC3 // HEATER1
  153. #define HEATER_1_PIN PB0 // HEATER2
  154. #define HEATER_BED_PIN PA0 // HOT BED
  155. #define FAN_PIN PB1 // FAN
  156. //
  157. // Thermocouples
  158. //
  159. //#define TEMP_0_CS_PIN PE5 // TC1 - CS1
  160. //#define TEMP_0_CS_PIN PE6 // TC2 - CS2
  161. //
  162. // Power Supply Control
  163. //
  164. #if ENABLED(MKS_PWC)
  165. #if ENABLED(TFT_LVGL_UI)
  166. #if ENABLED(PSU_CONTROL)
  167. #error "PSU_CONTROL is incompatible with MKS_PWC plus TFT_LVGL_UI."
  168. #endif
  169. #undef MKS_PWC
  170. #define SUICIDE_PIN PB2
  171. #define SUICIDE_PIN_STATE LOW
  172. #else
  173. #define PS_ON_PIN PB2 // PW_OFF
  174. #endif
  175. #define KILL_PIN PA2
  176. #define KILL_PIN_STATE HIGH
  177. #endif
  178. //
  179. // Misc. Functions
  180. //
  181. #if HAS_TFT_LVGL_UI
  182. #define MT_DET_1_PIN PA4
  183. #define MT_DET_2_PIN PE6
  184. #define MT_DET_PIN_STATE LOW
  185. #define WIFI_IO0_PIN PC13
  186. #define WIFI_IO1_PIN PC7
  187. #define WIFI_RESET_PIN PE9
  188. #if ENABLED(MKS_TEST)
  189. #define MKS_TEST_POWER_LOSS_PIN PA2 // PW_DET
  190. #define MKS_TEST_PS_ON_PIN PB2 // PW_OFF
  191. #endif
  192. #else
  193. //#define POWER_LOSS_PIN PA2 // PW_DET
  194. //#define PS_ON_PIN PB2 // PW_OFF
  195. #define FIL_RUNOUT_PIN PA4
  196. #define FIL_RUNOUT2_PIN PE6
  197. #endif
  198. //#define LED_PIN PB2
  199. //
  200. // SD Card
  201. //
  202. #ifndef SDCARD_CONNECTION
  203. #define SDCARD_CONNECTION ONBOARD
  204. #endif
  205. #if SD_CONNECTION_IS(ONBOARD)
  206. #define SDIO_SUPPORT
  207. #define SDIO_CLOCK 4500000 // 4.5 MHz
  208. #define SD_DETECT_PIN PD12
  209. #define ONBOARD_SD_CS_PIN PC11
  210. #elif SD_CONNECTION_IS(LCD)
  211. #define ENABLE_SPI1
  212. #define SDSS PE10
  213. #define SD_SCK_PIN PA5
  214. #define SD_MISO_PIN PA6
  215. #define SD_MOSI_PIN PA7
  216. #define SD_DETECT_PIN PE12
  217. #endif
  218. //
  219. // LCD / Controller
  220. //
  221. /**
  222. * Note: MKS Robin TFT screens use various TFT controllers.
  223. * If the screen stays white, disable 'LCD_RESET_PIN'
  224. * to let the bootloader init the screen.
  225. */
  226. #if HAS_SPI_TFT
  227. // Shared SPI TFT
  228. #define LCD_BACKLIGHT_PIN PD13
  229. #define TOUCH_CS_PIN PE14 // SPI1_NSS
  230. #define TOUCH_SCK_PIN PA5 // SPI1_SCK
  231. #define TOUCH_MISO_PIN PA6 // SPI1_MISO
  232. #define TOUCH_MOSI_PIN PA7 // SPI1_MOSI
  233. #define BTN_EN1 PE8
  234. #define BTN_EN2 PE11
  235. #define BTN_ENC PE13
  236. #define TFT_CS_PIN PD11
  237. #define TFT_SCK_PIN PA5
  238. #define TFT_MISO_PIN PA6
  239. #define TFT_MOSI_PIN PA7
  240. #define TFT_DC_PIN PD10
  241. #define TFT_RST_PIN PC6
  242. #define TFT_A0_PIN TFT_DC_PIN
  243. #define TFT_RESET_PIN PC6
  244. #define TFT_BACKLIGHT_PIN PD13
  245. #define TOUCH_BUTTONS_HW_SPI
  246. #define TOUCH_BUTTONS_HW_SPI_DEVICE 1
  247. #define LCD_USE_DMA_SPI
  248. #endif
  249. #if ENABLED(TFT_CLASSIC_UI)
  250. // Emulated DOGM SPI
  251. #define LCD_PINS_ENABLE PD13
  252. #define LCD_PINS_RS PC6
  253. #define BTN_ENC PE13
  254. #define BTN_EN1 PE8
  255. #define BTN_EN2 PE11
  256. #elif ENABLED(TFT_COLOR_UI)
  257. #define TFT_BUFFER_SIZE 14400
  258. #endif
  259. #if HAS_WIRED_LCD && !HAS_SPI_TFT
  260. #define BEEPER_PIN PC5
  261. #define BTN_ENC PE13
  262. #define LCD_PINS_ENABLE PD13
  263. #define LCD_PINS_RS PC6
  264. #define BTN_EN1 PE8
  265. #define BTN_EN2 PE11
  266. #define LCD_BACKLIGHT_PIN -1
  267. #if ENABLED(MKS_MINI_12864)
  268. // MKS MINI12864 and MKS LCD12864B
  269. // If using MKS LCD12864A (Need to remove RPK2 resistor)
  270. #define LCD_BACKLIGHT_PIN -1
  271. #define LCD_RESET_PIN -1
  272. #define DOGLCD_A0 PD11
  273. #define DOGLCD_CS PE15
  274. #define DOGLCD_SCK PA5
  275. #define DOGLCD_MOSI PA7
  276. #elif IS_TFTGLCD_PANEL
  277. #if ENABLED(TFTGLCD_PANEL_SPI)
  278. #define PIN_SPI_SCK PA5
  279. #define PIN_TFT_MISO PA6
  280. #define PIN_TFT_MOSI PA7
  281. #define TFTGLCD_CS PE8
  282. #endif
  283. #ifndef BEEPER_PIN
  284. #define BEEPER_PIN -1
  285. #endif
  286. #elif ENABLED(FYSETC_MINI_12864_2_1)
  287. #define LCD_PINS_DC PC6
  288. #define DOGLCD_CS PD13
  289. #define DOGLCD_A0 DOGLCD_A0
  290. #define LCD_BACKLIGHT_PIN -1
  291. #define LCD_RESET_PIN PE14
  292. #define NEOPIXEL_PIN PE15
  293. #define DOGLCD_MOSI PA7
  294. #define DOGLCD_SCK PA5
  295. #if SD_CONNECTION_IS(ONBOARD)
  296. #define FORCE_SOFT_SPI
  297. #endif
  298. //#define LCD_SCREEN_ROTATE 180 // 0, 90, 180, 270
  299. #else // !MKS_MINI_12864
  300. #define LCD_PINS_D4 PE14
  301. #if IS_ULTIPANEL
  302. #define LCD_PINS_D5 PE15
  303. #define LCD_PINS_D6 PD11
  304. #define LCD_PINS_D7 PD10
  305. #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER)
  306. #define BTN_ENC_EN LCD_PINS_D7 // Detect the presence of the encoder
  307. #endif
  308. #endif
  309. #if IS_U8GLIB_ST7920
  310. #define BOARD_ST7920_DELAY_1 125
  311. #define BOARD_ST7920_DELAY_2 125
  312. #define BOARD_ST7920_DELAY_3 125
  313. #endif
  314. #endif // !MKS_MINI_12864
  315. #endif // HAS_WIRED_LCD && !HAS_SPI_TFT
  316. #define HAS_SPI_FLASH 1
  317. #if HAS_SPI_FLASH
  318. #define SPI_FLASH_SIZE 0x1000000 // 16MB
  319. #define SPI_FLASH_CS_PIN PB12
  320. #define SPI_FLASH_MOSI_PIN PB15
  321. #define SPI_FLASH_MISO_PIN PB14
  322. #define SPI_FLASH_SCK_PIN PB13
  323. #endif
  324. #ifndef BEEPER_PIN
  325. #define BEEPER_PIN PC5
  326. #endif
  327. #if ENABLED(SPEAKER) && BEEPER_PIN == PC5
  328. #error "MKS Robin nano default BEEPER_PIN is not a SPEAKER."
  329. #endif