pins_CREALITY_V4.h 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309
  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. * Creality 4.2.x (STM32F103RE / STM32F103RC) board pin assignments
  25. */
  26. #include "env_validate.h"
  27. #if HAS_MULTI_HOTEND || E_STEPPERS > 1
  28. #error "Creality v4 only supports 1 hotend / E stepper."
  29. #endif
  30. #ifndef BOARD_INFO_NAME
  31. #define BOARD_INFO_NAME "Creality V4"
  32. #endif
  33. #ifndef DEFAULT_MACHINE_NAME
  34. #define DEFAULT_MACHINE_NAME "Ender 3 V2"
  35. #endif
  36. #define BOARD_NO_NATIVE_USB
  37. //
  38. // Release PB4 (Y_ENABLE_PIN) from JTAG NRST role
  39. //
  40. #ifndef DISABLE_DEBUG
  41. #define DISABLE_DEBUG
  42. #endif
  43. //
  44. // EEPROM
  45. //
  46. #if NO_EEPROM_SELECTED
  47. #define IIC_BL24CXX_EEPROM // EEPROM on I2C-0
  48. //#define SDCARD_EEPROM_EMULATION
  49. #undef NO_EEPROM_SELECTED
  50. #endif
  51. #if ENABLED(IIC_BL24CXX_EEPROM)
  52. #define IIC_EEPROM_SDA PA11
  53. #define IIC_EEPROM_SCL PA12
  54. #define MARLIN_EEPROM_SIZE 0x800 // 2K (24C16)
  55. #elif ENABLED(SDCARD_EEPROM_EMULATION)
  56. #define MARLIN_EEPROM_SIZE 0x800 // 2K
  57. #endif
  58. //
  59. // Servos
  60. //
  61. #ifndef SERVO0_PIN
  62. #ifndef HAS_PIN_27_BOARD
  63. #define SERVO0_PIN PB0 // BLTouch OUT
  64. #else
  65. #define SERVO0_PIN PC6
  66. #endif
  67. #endif
  68. //
  69. // Limit Switches
  70. //
  71. #ifndef X_STOP_PIN
  72. #define X_STOP_PIN PA5
  73. #endif
  74. #ifndef Y_STOP_PIN
  75. #define Y_STOP_PIN PA6
  76. #endif
  77. #ifndef Z_STOP_PIN
  78. #define Z_STOP_PIN PA7
  79. #endif
  80. #ifndef Z_MIN_PROBE_PIN
  81. #define Z_MIN_PROBE_PIN PB1 // BLTouch IN
  82. #endif
  83. //
  84. // Filament Runout Sensor
  85. //
  86. #ifndef FIL_RUNOUT_PIN
  87. #define FIL_RUNOUT_PIN PA4 // "Pulled-high"
  88. #endif
  89. //
  90. // Steppers
  91. //
  92. #ifndef X_STEP_PIN
  93. #define X_STEP_PIN PC2
  94. #endif
  95. #ifndef X_DIR_PIN
  96. #define X_DIR_PIN PB9
  97. #endif
  98. #define X_ENABLE_PIN PC3 // Shared
  99. #ifndef Y_STEP_PIN
  100. #define Y_STEP_PIN PB8
  101. #endif
  102. #ifndef Y_DIR_PIN
  103. #define Y_DIR_PIN PB7
  104. #endif
  105. #define Y_ENABLE_PIN X_ENABLE_PIN
  106. #ifndef Z_STEP_PIN
  107. #define Z_STEP_PIN PB6
  108. #endif
  109. #ifndef Z_DIR_PIN
  110. #define Z_DIR_PIN PB5
  111. #endif
  112. #define Z_ENABLE_PIN X_ENABLE_PIN
  113. #ifndef E0_STEP_PIN
  114. #define E0_STEP_PIN PB4
  115. #endif
  116. #ifndef E0_DIR_PIN
  117. #define E0_DIR_PIN PB3
  118. #endif
  119. #define E0_ENABLE_PIN X_ENABLE_PIN
  120. //
  121. // Temperature Sensors
  122. //
  123. #define TEMP_0_PIN PC5 // TH1
  124. #define TEMP_BED_PIN PC4 // TB1
  125. //
  126. // Heaters / Fans
  127. //
  128. #ifndef HEATER_0_PIN
  129. #define HEATER_0_PIN PA1 // HEATER1
  130. #endif
  131. #ifndef HEATER_BED_PIN
  132. #define HEATER_BED_PIN PA2 // HOT BED
  133. #endif
  134. #ifndef FAN_PIN
  135. #define FAN_PIN PA0 // FAN
  136. #endif
  137. #define FAN_SOFT_PWM_REQUIRED
  138. //
  139. // SD Card
  140. //
  141. #define SD_DETECT_PIN PC7
  142. #define SDCARD_CONNECTION ONBOARD
  143. #define SDIO_SUPPORT
  144. #define NO_SD_HOST_DRIVE // This board's SD is only seen by the printer
  145. #if ANY(RET6_12864_LCD, HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
  146. /**
  147. * RET6 12864 LCD
  148. * ------
  149. * PC6 | 1 2 | PB2
  150. * PB10 | 3 4 | PB11
  151. * PB14 5 6 | PB13
  152. * PB12 | 7 8 | PB15
  153. * GND | 9 10 | 5V
  154. * ------
  155. */
  156. #define EXP3_01_PIN PC6
  157. #define EXP3_02_PIN PB2
  158. #define EXP3_03_PIN PB10
  159. #define EXP3_04_PIN PB11
  160. #define EXP3_05_PIN PB14
  161. #define EXP3_06_PIN PB13
  162. #define EXP3_07_PIN PB12
  163. #define EXP3_08_PIN PB15
  164. #elif EITHER(VET6_12864_LCD, DWIN_VET6_CREALITY_LCD)
  165. /**
  166. * VET6 12864 LCD
  167. * ------
  168. * ? | 1 2 | PC5
  169. * PB10 | 3 4 | ?
  170. * PA6 5 6 | PA5
  171. * PA4 | 7 8 | PA7
  172. * GND | 9 10 | 5V
  173. * ------
  174. */
  175. #define EXP3_01_PIN -1
  176. #define EXP3_02_PIN PC5
  177. #define EXP3_03_PIN PB10
  178. #define EXP3_04_PIN -1
  179. #define EXP3_05_PIN PA6
  180. #define EXP3_06_PIN PA5
  181. #define EXP3_07_PIN PA4
  182. #define EXP3_08_PIN PA7
  183. #elif EITHER(CR10_STOCKDISPLAY, FYSETC_MINI_12864_2_1)
  184. #error "Define RET6_12864_LCD or VET6_12864_LCD to select pins for the LCD with the Creality V4 controller."
  185. #endif
  186. #if ENABLED(CR10_STOCKDISPLAY)
  187. #define LCD_PINS_RS EXP3_07_PIN
  188. #define LCD_PINS_ENABLE EXP3_08_PIN
  189. #define LCD_PINS_D4 EXP3_06_PIN
  190. #define BTN_ENC EXP3_02_PIN
  191. #define BTN_EN1 EXP3_03_PIN
  192. #define BTN_EN2 EXP3_05_PIN
  193. #ifndef HAS_PIN_27_BOARD
  194. #define BEEPER_PIN EXP3_01_PIN
  195. #endif
  196. #elif ANY(HAS_DWIN_E3V2, IS_DWIN_MARLINUI, DWIN_VET6_CREALITY_LCD)
  197. #define BTN_ENC EXP3_05_PIN
  198. #define BTN_EN1 EXP3_08_PIN
  199. #define BTN_EN2 EXP3_07_PIN
  200. #ifndef BEEPER_PIN
  201. #define BEEPER_PIN EXP3_06_PIN
  202. #endif
  203. #elif ENABLED(FYSETC_MINI_12864_2_1)
  204. #ifndef NO_CONTROLLER_CUSTOM_WIRING_WARNING
  205. #error "CAUTION! FYSETC_MINI_12864_2_1 and clones require wiring modifications. See 'pins_CREALITY_V4.h' for details. Define NO_CONTROLLER_CUSTOM_WIRING_WARNING to suppress this warning."
  206. #endif
  207. #if SD_CONNECTION_IS(LCD)
  208. #error "The LCD SD Card is not connected with this configuration."
  209. #endif
  210. /**
  211. *
  212. * Board (RET6 12864 LCD) Display
  213. * ------ ------
  214. * (EN1) PC6 | 1 2 | PB2 (BTN_ENC) 5V |10 9 | GND
  215. * (LCD_CS) PB10 | 3 4 | PB11 (LCD RESET) -- | 8 7 | --
  216. * (LCD_A0) PB14 5 6 | PB13 (EN2) (DIN) | 6 5 (LCD RESET)
  217. * (LCD_SCK)PB12 | 7 8 | PB15 (MOSI) (LCD_A0) | 4 3 | (LCD_CS)
  218. * GND | 9 10 | 5V (BTN_ENC) | 2 1 | --
  219. * ------ ------
  220. * EXP1 EXP1
  221. *
  222. * ------
  223. * ----- -- |10 9 | --
  224. * | 1 | VCC (RESET) | 8 7 | --
  225. * | 2 | PA13 (DIN) (MOSI) | 6 5 (EN2)
  226. * | 3 | PA14 -- | 4 3 | (EN1)
  227. * | 4 | GND (LCD_SCK)| 2 1 | --
  228. * ----- ------
  229. * Debug port EXP2
  230. *
  231. * Needs custom cable. Connect EN2-EN2, LCD_CS-LCD_CS and so on.
  232. * Debug port is just above EXP1. You need to add pins.
  233. *
  234. */
  235. #define BTN_ENC EXP3_02_PIN
  236. #define BTN_EN1 EXP3_01_PIN
  237. #define BTN_EN2 EXP3_06_PIN
  238. #define BEEPER_PIN -1
  239. #define DOGLCD_CS EXP3_03_PIN
  240. #define DOGLCD_A0 EXP3_05_PIN
  241. #define DOGLCD_SCK EXP3_07_PIN
  242. #define DOGLCD_MOSI EXP3_08_PIN
  243. #define LCD_RESET_PIN EXP3_04_PIN
  244. #define FORCE_SOFT_SPI
  245. #define LCD_BACKLIGHT_PIN -1
  246. #define NEOPIXEL_PIN PA13
  247. #endif
  248. // Pins for documentation and sanity checks only.
  249. // Changing these will not change the pin they are on.
  250. // Hardware UART pins
  251. #define UART1_TX_PIN PA9 // default uses CH340 RX
  252. #define UART1_RX_PIN PA10 // default uses CH340 TX
  253. #define UART2_TX_PIN PA2 // default uses HEATER_BED_PIN
  254. #define UART2_RX_PIN PA3 // not connected
  255. #define UART3_TX_PIN PB10 // default uses LCD connector
  256. #define UART3_RX_PIN PB11 // default uses LCD connector
  257. #define UART4_TX_PIN PC10 // default uses sdcard SDIO_D2
  258. #define UART4_RX_PIN PC11 // default uses sdcard SDIO_D3
  259. #define UART5_TX_PIN PC12 // default uses sdcard SDIO_CK
  260. #define UART5_RX_PIN PD2 // default uses sdcard SDIO_CMD
  261. // SDIO pins
  262. #define SDIO_D0_PIN PC8
  263. #define SDIO_D1_PIN PC9
  264. #define SDIO_D2_PIN PC10
  265. #define SDIO_D3_PIN PC11
  266. #define SDIO_CK_PIN PC12
  267. #define SDIO_CMD_PIN PD2