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.

SanityCheck.h 12KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  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. #if PIO_PLATFORM_VERSION < 1001
  24. #error "nxplpc-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries. You may need to remove the platform and let it reinstall automatically."
  25. #endif
  26. #if PIO_FRAMEWORK_VERSION < 2005
  27. #error "framework-arduino-lpc176x package is out of date, Please update the PlatformIO platforms, frameworks and libraries."
  28. #endif
  29. /**
  30. * Detect an old pins file by checking for old ADC pins values.
  31. */
  32. #define _OLD_TEMP_PIN(P) PIN_EXISTS(P) && _CAT(P,_PIN) <= 7 && _CAT(P,_PIN) != 2 && _CAT(P,_PIN) != 3
  33. #if _OLD_TEMP_PIN(TEMP_BED)
  34. #error "TEMP_BED_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  35. #elif _OLD_TEMP_PIN(TEMP_0)
  36. #error "TEMP_0_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  37. #elif _OLD_TEMP_PIN(TEMP_1)
  38. #error "TEMP_1_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  39. #elif _OLD_TEMP_PIN(TEMP_2)
  40. #error "TEMP_2_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  41. #elif _OLD_TEMP_PIN(TEMP_3)
  42. #error "TEMP_3_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  43. #elif _OLD_TEMP_PIN(TEMP_4)
  44. #error "TEMP_4_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  45. #elif _OLD_TEMP_PIN(TEMP_5)
  46. #error "TEMP_5_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  47. #elif _OLD_TEMP_PIN(TEMP_6)
  48. #error "TEMP_6_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  49. #elif _OLD_TEMP_PIN(TEMP_7)
  50. #error "TEMP_7_PIN must be defined using the Pn_nn or Pn_nn_An format. (See the included pins files)."
  51. #endif
  52. #undef _OLD_TEMP_PIN
  53. /**
  54. * Because PWM hardware channels all share the same frequency, along with the
  55. * fallback software channels, FAST_PWM_FAN is incompatible with Servos.
  56. */
  57. static_assert(!(NUM_SERVOS && ENABLED(FAST_PWM_FAN)), "BLTOUCH and Servos are incompatible with FAST_PWM_FAN on LPC176x boards.");
  58. #if SPINDLE_LASER_FREQUENCY
  59. static_assert(!NUM_SERVOS, "BLTOUCH and Servos are incompatible with SPINDLE_LASER_FREQUENCY on LPC176x boards.");
  60. #endif
  61. /**
  62. * Test LPC176x-specific configuration values for errors at compile-time.
  63. */
  64. //#if ENABLED(SPINDLE_LASER_PWM) && !(SPINDLE_LASER_PWM_PIN == 4 || SPINDLE_LASER_PWM_PIN == 6 || SPINDLE_LASER_PWM_PIN == 11)
  65. // #error "SPINDLE_LASER_PWM_PIN must use SERVO0, SERVO1 or SERVO3 connector"
  66. //#endif
  67. #if MB(RAMPS_14_RE_ARM_EFB, RAMPS_14_RE_ARM_EEB, RAMPS_14_RE_ARM_EFF, RAMPS_14_RE_ARM_EEF, RAMPS_14_RE_ARM_SF)
  68. #if ENABLED(REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER) && HAS_DRIVER(TMC2130) && DISABLED(TMC_USE_SW_SPI)
  69. #error "Re-ARM with REPRAP_DISCOUNT_FULL_GRAPHIC_SMART_CONTROLLER and TMC2130 requires TMC_USE_SW_SPI."
  70. #endif
  71. #endif
  72. static_assert(DISABLED(BAUD_RATE_GCODE), "BAUD_RATE_GCODE is not yet supported on LPC176x.");
  73. /**
  74. * Flag any serial port conflicts
  75. *
  76. * Port | TX | RX |
  77. * --- | --- | --- |
  78. * Serial | P0_02 | P0_03 |
  79. * Serial1 | P0_15 | P0_16 |
  80. * Serial2 | P0_10 | P0_11 |
  81. * Serial3 | P0_00 | P0_01 |
  82. */
  83. #define ANY_TX(N,V...) DO(IS_TX##N,||,V)
  84. #define ANY_RX(N,V...) DO(IS_RX##N,||,V)
  85. #if USING_SERIAL_0
  86. #define IS_TX0(P) (P == P0_02)
  87. #define IS_RX0(P) (P == P0_03)
  88. #if IS_TX0(TMC_SW_MISO) || IS_RX0(TMC_SW_MOSI)
  89. #error "Serial port pins (0) conflict with Trinamic SPI pins!"
  90. #elif ENABLED(MK2_MULTIPLEXER) && (IS_TX0(E_MUX1_PIN) || IS_RX0(E_MUX0_PIN))
  91. #error "Serial port pins (0) conflict with MK2 multiplexer pins!"
  92. #elif (AXIS_HAS_SPI(X) && IS_TX0(X_CS_PIN)) || (AXIS_HAS_SPI(Y) && IS_RX0(Y_CS_PIN))
  93. #error "Serial port pins (0) conflict with X/Y axis SPI pins!"
  94. #endif
  95. #undef IS_TX0
  96. #undef IS_RX0
  97. #endif
  98. #if USING_SERIAL_1
  99. #define IS_TX1(P) (P == P0_15)
  100. #define IS_RX1(P) (P == P0_16)
  101. #define _IS_TX1_1 IS_TX1
  102. #define _IS_RX1_1 IS_RX1
  103. #if IS_TX1(TMC_SW_SCK)
  104. #error "Serial port pins (1) conflict with other pins!"
  105. #elif HAS_WIRED_LCD
  106. #if IS_TX1(BTN_EN2) || IS_RX1(BTN_EN1)
  107. #error "Serial port pins (1) conflict with Encoder Buttons!"
  108. #elif ANY_TX(1, SCK_PIN, LCD_PINS_D4, DOGLCD_SCK, LCD_RESET_PIN, LCD_PINS_RS, SHIFT_CLK) \
  109. || ANY_RX(1, LCD_SDSS, LCD_PINS_RS, MISO_PIN, DOGLCD_A0, SS_PIN, LCD_SDSS, DOGLCD_CS, LCD_RESET_PIN, LCD_BACKLIGHT_PIN)
  110. #error "Serial port pins (1) conflict with LCD pins!"
  111. #endif
  112. #endif
  113. #undef IS_TX1
  114. #undef IS_RX1
  115. #undef _IS_TX1_1
  116. #undef _IS_RX1_1
  117. #endif
  118. #if USING_SERIAL_2
  119. #define IS_TX2(P) (P == P0_10)
  120. #define IS_RX2(P) (P == P0_11)
  121. #define _IS_TX2_1 IS_TX2
  122. #define _IS_RX2_1 IS_RX2
  123. #if IS_TX2(X2_ENABLE_PIN) || ANY_RX(2, X2_DIR_PIN, X2_STEP_PIN) || (AXIS_HAS_SPI(X2) && IS_TX2(X2_CS_PIN))
  124. #error "Serial port pins (2) conflict with X2 pins!"
  125. #elif IS_TX2(Y2_ENABLE_PIN) || ANY_RX(2, Y2_DIR_PIN, Y2_STEP_PIN) || (AXIS_HAS_SPI(Y2) && IS_TX2(Y2_CS_PIN))
  126. #error "Serial port pins (2) conflict with Y2 pins!"
  127. #elif IS_TX2(Z2_ENABLE_PIN) || ANY_RX(2, Z2_DIR_PIN, Z2_STEP_PIN) || (AXIS_HAS_SPI(Z2) && IS_TX2(Z2_CS_PIN))
  128. #error "Serial port pins (2) conflict with Z2 pins!"
  129. #elif IS_TX2(Z3_ENABLE_PIN) || ANY_RX(2, Z3_DIR_PIN, Z3_STEP_PIN) || (AXIS_HAS_SPI(Z3) && IS_TX2(Z3_CS_PIN))
  130. #error "Serial port pins (2) conflict with Z3 pins!"
  131. #elif IS_TX2(Z4_ENABLE_PIN) || ANY_RX(2, Z4_DIR_PIN, Z4_STEP_PIN) || (AXIS_HAS_SPI(Z4) && IS_TX2(Z4_CS_PIN))
  132. #error "Serial port pins (2) conflict with Z4 pins!"
  133. #elif ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
  134. #error "Serial port pins (2) conflict with other pins!"
  135. #elif Y_HOME_DIR < 0 && IS_TX2(Y_STOP_PIN)
  136. #error "Serial port pins (2) conflict with Y endstop pin!"
  137. #elif HAS_CUSTOM_PROBE_PIN && IS_TX2(Z_MIN_PROBE_PIN)
  138. #error "Serial port pins (2) conflict with probe pin!"
  139. #elif ANY_TX(2, X_ENABLE_PIN, Y_ENABLE_PIN) || ANY_RX(2, X_DIR_PIN, Y_DIR_PIN)
  140. #error "Serial port pins (2) conflict with X/Y stepper pins!"
  141. #elif HAS_MULTI_EXTRUDER && (IS_TX2(E1_ENABLE_PIN) || (AXIS_HAS_SPI(E1) && IS_TX2(E1_CS_PIN)))
  142. #error "Serial port pins (2) conflict with E1 stepper pins!"
  143. #elif EXTRUDERS && ANY_RX(2, E0_DIR_PIN, E0_STEP_PIN)
  144. #error "Serial port pins (2) conflict with E stepper pins!"
  145. #endif
  146. #undef IS_TX2
  147. #undef IS_RX2
  148. #undef _IS_TX2_1
  149. #undef _IS_RX2_1
  150. #endif
  151. #if USING_SERIAL_3
  152. #define PIN_IS_TX3(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
  153. #define PIN_IS_RX3(P) (P##_PIN == P0_01)
  154. #if PIN_IS_TX3(X_MIN) || PIN_IS_RX3(X_MAX)
  155. #error "Serial port pins (3) conflict with X endstop pins!"
  156. #elif PIN_IS_TX3(Y_SERIAL_TX) || PIN_IS_TX3(Y_SERIAL_RX) || PIN_IS_RX3(X_SERIAL_TX) || PIN_IS_RX3(X_SERIAL_RX)
  157. #error "Serial port pins (3) conflict with X/Y axis UART pins!"
  158. #elif PIN_IS_TX3(X2_DIR) || PIN_IS_RX3(X2_STEP)
  159. #error "Serial port pins (3) conflict with X2 pins!"
  160. #elif PIN_IS_TX3(Y2_DIR) || PIN_IS_RX3(Y2_STEP)
  161. #error "Serial port pins (3) conflict with Y2 pins!"
  162. #elif PIN_IS_TX3(Z2_DIR) || PIN_IS_RX3(Z2_STEP)
  163. #error "Serial port pins (3) conflict with Z2 pins!"
  164. #elif PIN_IS_TX3(Z3_DIR) || PIN_IS_RX3(Z3_STEP)
  165. #error "Serial port pins (3) conflict with Z3 pins!"
  166. #elif PIN_IS_TX3(Z4_DIR) || PIN_IS_RX3(Z4_STEP)
  167. #error "Serial port pins (3) conflict with Z4 pins!"
  168. #elif HAS_MULTI_EXTRUDER && (PIN_IS_TX3(E1_DIR) || PIN_IS_RX3(E1_STEP))
  169. #error "Serial port pins (3) conflict with E1 pins!"
  170. #endif
  171. #undef PIN_IS_TX3
  172. #undef PIN_IS_RX3
  173. #endif
  174. #undef ANY_TX
  175. #undef ANY_RX
  176. //
  177. // Flag any i2c pin conflicts
  178. //
  179. #if ANY(HAS_MOTOR_CURRENT_I2C, HAS_MOTOR_CURRENT_DAC, EXPERIMENTAL_I2CBUS, I2C_POSITION_ENCODERS, PCA9632, I2C_EEPROM)
  180. #define USEDI2CDEV_M 1 // <Arduino>/Wire.cpp
  181. #if USEDI2CDEV_M == 0 // P0_27 [D57] (AUX-1) .......... P0_28 [D58] (AUX-1)
  182. #define PIN_IS_SDA0(P) (P##_PIN == P0_27)
  183. #define IS_SCL0(P) (P == P0_28)
  184. #if ENABLED(SDSUPPORT) && PIN_IS_SDA0(SD_DETECT)
  185. #error "SDA0 overlaps with SD_DETECT_PIN!"
  186. #elif PIN_IS_SDA0(E0_AUTO_FAN)
  187. #error "SDA0 overlaps with E0_AUTO_FAN_PIN!"
  188. #elif PIN_IS_SDA0(BEEPER)
  189. #error "SDA0 overlaps with BEEPER_PIN!"
  190. #elif IS_SCL0(BTN_ENC)
  191. #error "SCL0 overlaps with Encoder Button!"
  192. #elif IS_SCL0(SS_PIN)
  193. #error "SCL0 overlaps with SS_PIN!"
  194. #elif IS_SCL0(LCD_SDSS)
  195. #error "SCL0 overlaps with LCD_SDSS!"
  196. #endif
  197. #undef PIN_IS_SDA0
  198. #undef IS_SCL0
  199. #elif USEDI2CDEV_M == 1 // P0_00 [D20] (SCA) ............ P0_01 [D21] (SCL)
  200. #define PIN_IS_SDA1(P) (PIN_EXISTS(P) && P##_PIN == P0_00)
  201. #define PIN_IS_SCL1(P) (P##_PIN == P0_01)
  202. #if PIN_IS_SDA1(X_MIN) || PIN_IS_SCL1(X_MAX)
  203. #error "One or more i2c (1) pins overlaps with X endstop pins! Disable i2c peripherals."
  204. #elif PIN_IS_SDA1(X2_DIR) || PIN_IS_SCL1(X2_STEP)
  205. #error "One or more i2c (1) pins overlaps with X2 pins! Disable i2c peripherals."
  206. #elif PIN_IS_SDA1(Y2_DIR) || PIN_IS_SCL1(Y2_STEP)
  207. #error "One or more i2c (1) pins overlaps with Y2 pins! Disable i2c peripherals."
  208. #elif PIN_IS_SDA1(Z2_DIR) || PIN_IS_SCL1(Z2_STEP)
  209. #error "One or more i2c (1) pins overlaps with Z2 pins! Disable i2c peripherals."
  210. #elif PIN_IS_SDA1(Z3_DIR) || PIN_IS_SCL1(Z3_STEP)
  211. #error "One or more i2c (1) pins overlaps with Z3 pins! Disable i2c peripherals."
  212. #elif PIN_IS_SDA1(Z4_DIR) || PIN_IS_SCL1(Z4_STEP)
  213. #error "One or more i2c (1) pins overlaps with Z4 pins! Disable i2c peripherals."
  214. #elif HAS_MULTI_EXTRUDER && (PIN_IS_SDA1(E1_DIR) || PIN_IS_SCL1(E1_STEP))
  215. #error "One or more i2c (1) pins overlaps with E1 pins! Disable i2c peripherals."
  216. #endif
  217. #undef PIN_IS_SDA1
  218. #undef PIN_IS_SCL1
  219. #elif USEDI2CDEV_M == 2 // P0_10 [D38] (X_ENABLE_PIN) ... P0_11 [D55] (X_DIR_PIN)
  220. #define PIN_IS_SDA2(P) (P##_PIN == P0_10)
  221. #define PIN_IS_SCL2(P) (P##_PIN == P0_11)
  222. #if PIN_IS_SDA2(Y_STOP)
  223. #error "i2c SDA2 overlaps with Y endstop pin!"
  224. #elif HAS_CUSTOM_PROBE_PIN && PIN_IS_SDA2(Z_MIN_PROBE)
  225. #error "i2c SDA2 overlaps with Z probe pin!"
  226. #elif PIN_IS_SDA2(X_ENABLE) || PIN_IS_SDA2(Y_ENABLE)
  227. #error "i2c SDA2 overlaps with X/Y ENABLE pin!"
  228. #elif AXIS_HAS_SPI(X) && PIN_IS_SDA2(X_CS)
  229. #error "i2c SDA2 overlaps with X CS pin!"
  230. #elif PIN_IS_SDA2(X2_ENABLE)
  231. #error "i2c SDA2 overlaps with X2 enable pin! Disable i2c peripherals."
  232. #elif PIN_IS_SDA2(Y2_ENABLE)
  233. #error "i2c SDA2 overlaps with Y2 enable pin! Disable i2c peripherals."
  234. #elif PIN_IS_SDA2(Z2_ENABLE)
  235. #error "i2c SDA2 overlaps with Z2 enable pin! Disable i2c peripherals."
  236. #elif PIN_IS_SDA2(Z3_ENABLE)
  237. #error "i2c SDA2 overlaps with Z3 enable pin! Disable i2c peripherals."
  238. #elif PIN_IS_SDA2(Z4_ENABLE)
  239. #error "i2c SDA2 overlaps with Z4 enable pin! Disable i2c peripherals."
  240. #elif HAS_MULTI_EXTRUDER && PIN_IS_SDA2(E1_ENABLE)
  241. #error "i2c SDA2 overlaps with E1 enable pin! Disable i2c peripherals."
  242. #elif HAS_MULTI_EXTRUDER && AXIS_HAS_SPI(E1) && PIN_IS_SDA2(E1_CS)
  243. #error "i2c SDA2 overlaps with E1 CS pin! Disable i2c peripherals."
  244. #elif EXTRUDERS && (PIN_IS_SDA2(E0_STEP) || PIN_IS_SDA2(E0_DIR))
  245. #error "i2c SCL2 overlaps with E0 STEP/DIR pin! Disable i2c peripherals."
  246. #elif PIN_IS_SDA2(X_DIR) || PIN_IS_SDA2(Y_DIR)
  247. #error "One or more i2c pins overlaps with X/Y DIR pin! Disable i2c peripherals."
  248. #endif
  249. #undef PIN_IS_SDA2
  250. #undef PIN_IS_SCL2
  251. #endif
  252. #undef USEDI2CDEV_M
  253. #endif
  254. #if ENABLED(SERIAL_STATS_MAX_RX_QUEUED)
  255. #error "SERIAL_STATS_MAX_RX_QUEUED is not supported on this platform."
  256. #elif ENABLED(SERIAL_STATS_DROPPED_RX)
  257. #error "SERIAL_STATS_DROPPED_RX is not supported on this platform."
  258. #endif