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_postprocess.h 44KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813
  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. // File: pins/pins_postprocess.h
  25. // Post-process pins according to configured settings
  26. //
  27. // Define certain undefined pins
  28. #ifndef X_MS1_PIN
  29. #define X_MS1_PIN -1
  30. #endif
  31. #ifndef X_MS2_PIN
  32. #define X_MS2_PIN -1
  33. #endif
  34. #ifndef X_MS3_PIN
  35. #define X_MS3_PIN -1
  36. #endif
  37. #ifndef Y_MS1_PIN
  38. #define Y_MS1_PIN -1
  39. #endif
  40. #ifndef Y_MS2_PIN
  41. #define Y_MS2_PIN -1
  42. #endif
  43. #ifndef Y_MS3_PIN
  44. #define Y_MS3_PIN -1
  45. #endif
  46. #ifndef Z_MS1_PIN
  47. #define Z_MS1_PIN -1
  48. #endif
  49. #ifndef Z_MS2_PIN
  50. #define Z_MS2_PIN -1
  51. #endif
  52. #ifndef Z_MS3_PIN
  53. #define Z_MS3_PIN -1
  54. #endif
  55. #ifndef E0_MS1_PIN
  56. #define E0_MS1_PIN -1
  57. #endif
  58. #ifndef E0_MS2_PIN
  59. #define E0_MS2_PIN -1
  60. #endif
  61. #ifndef E0_MS3_PIN
  62. #define E0_MS3_PIN -1
  63. #endif
  64. #ifndef E1_MS1_PIN
  65. #define E1_MS1_PIN -1
  66. #endif
  67. #ifndef E1_MS2_PIN
  68. #define E1_MS2_PIN -1
  69. #endif
  70. #ifndef E1_MS3_PIN
  71. #define E1_MS3_PIN -1
  72. #endif
  73. #ifndef E2_MS1_PIN
  74. #define E2_MS1_PIN -1
  75. #endif
  76. #ifndef E2_MS2_PIN
  77. #define E2_MS2_PIN -1
  78. #endif
  79. #ifndef E2_MS3_PIN
  80. #define E2_MS3_PIN -1
  81. #endif
  82. #ifndef E3_MS1_PIN
  83. #define E3_MS1_PIN -1
  84. #endif
  85. #ifndef E3_MS2_PIN
  86. #define E3_MS2_PIN -1
  87. #endif
  88. #ifndef E3_MS3_PIN
  89. #define E3_MS3_PIN -1
  90. #endif
  91. #ifndef E4_MS1_PIN
  92. #define E4_MS1_PIN -1
  93. #endif
  94. #ifndef E4_MS2_PIN
  95. #define E4_MS2_PIN -1
  96. #endif
  97. #ifndef E4_MS3_PIN
  98. #define E4_MS3_PIN -1
  99. #endif
  100. #ifndef E5_MS1_PIN
  101. #define E5_MS1_PIN -1
  102. #endif
  103. #ifndef E5_MS2_PIN
  104. #define E5_MS2_PIN -1
  105. #endif
  106. #ifndef E5_MS3_PIN
  107. #define E5_MS3_PIN -1
  108. #endif
  109. #ifndef E6_MS1_PIN
  110. #define E6_MS1_PIN -1
  111. #endif
  112. #ifndef E6_MS2_PIN
  113. #define E6_MS2_PIN -1
  114. #endif
  115. #ifndef E6_MS3_PIN
  116. #define E6_MS3_PIN -1
  117. #endif
  118. #ifndef E7_MS1_PIN
  119. #define E7_MS1_PIN -1
  120. #endif
  121. #ifndef E7_MS2_PIN
  122. #define E7_MS2_PIN -1
  123. #endif
  124. #ifndef E7_MS3_PIN
  125. #define E7_MS3_PIN -1
  126. #endif
  127. #ifndef E0_STEP_PIN
  128. #define E0_STEP_PIN -1
  129. #endif
  130. #ifndef E0_DIR_PIN
  131. #define E0_DIR_PIN -1
  132. #endif
  133. #ifndef E0_ENABLE_PIN
  134. #define E0_ENABLE_PIN -1
  135. #endif
  136. #ifndef E1_STEP_PIN
  137. #define E1_STEP_PIN -1
  138. #endif
  139. #ifndef E1_DIR_PIN
  140. #define E1_DIR_PIN -1
  141. #endif
  142. #ifndef E1_ENABLE_PIN
  143. #define E1_ENABLE_PIN -1
  144. #endif
  145. #ifndef E2_STEP_PIN
  146. #define E2_STEP_PIN -1
  147. #endif
  148. #ifndef E2_DIR_PIN
  149. #define E2_DIR_PIN -1
  150. #endif
  151. #ifndef E2_ENABLE_PIN
  152. #define E2_ENABLE_PIN -1
  153. #endif
  154. #ifndef E3_STEP_PIN
  155. #define E3_STEP_PIN -1
  156. #endif
  157. #ifndef E3_DIR_PIN
  158. #define E3_DIR_PIN -1
  159. #endif
  160. #ifndef E3_ENABLE_PIN
  161. #define E3_ENABLE_PIN -1
  162. #endif
  163. #ifndef E4_STEP_PIN
  164. #define E4_STEP_PIN -1
  165. #endif
  166. #ifndef E4_DIR_PIN
  167. #define E4_DIR_PIN -1
  168. #endif
  169. #ifndef E4_ENABLE_PIN
  170. #define E4_ENABLE_PIN -1
  171. #endif
  172. #ifndef E5_STEP_PIN
  173. #define E5_STEP_PIN -1
  174. #endif
  175. #ifndef E5_DIR_PIN
  176. #define E5_DIR_PIN -1
  177. #endif
  178. #ifndef E5_ENABLE_PIN
  179. #define E5_ENABLE_PIN -1
  180. #endif
  181. #ifndef E6_STEP_PIN
  182. #define E6_STEP_PIN -1
  183. #endif
  184. #ifndef E6_DIR_PIN
  185. #define E6_DIR_PIN -1
  186. #endif
  187. #ifndef E6_ENABLE_PIN
  188. #define E6_ENABLE_PIN -1
  189. #endif
  190. #ifndef E7_STEP_PIN
  191. #define E7_STEP_PIN -1
  192. #endif
  193. #ifndef E7_DIR_PIN
  194. #define E7_DIR_PIN -1
  195. #endif
  196. #ifndef E7_ENABLE_PIN
  197. #define E7_ENABLE_PIN -1
  198. #endif
  199. //
  200. // Destroy unused CS pins
  201. //
  202. #if !AXIS_HAS_SPI(X)
  203. #undef X_CS_PIN
  204. #endif
  205. #if !AXIS_HAS_SPI(Y)
  206. #undef Y_CS_PIN
  207. #endif
  208. #if !AXIS_HAS_SPI(Z)
  209. #undef Z_CS_PIN
  210. #endif
  211. #if !AXIS_HAS_SPI(I)
  212. #undef I_CS_PIN
  213. #endif
  214. #if !AXIS_HAS_SPI(J)
  215. #undef J_CS_PIN
  216. #endif
  217. #if !AXIS_HAS_SPI(K)
  218. #undef K_CS_PIN
  219. #endif
  220. #if !AXIS_HAS_SPI(U)
  221. #undef U_CS_PIN
  222. #endif
  223. #if !AXIS_HAS_SPI(V)
  224. #undef V_CS_PIN
  225. #endif
  226. #if !AXIS_HAS_SPI(W)
  227. #undef W_CS_PIN
  228. #endif
  229. #if E_STEPPERS && !AXIS_HAS_SPI(E0)
  230. #undef E0_CS_PIN
  231. #endif
  232. #if E_STEPPERS > 1 && !AXIS_HAS_SPI(E1)
  233. #undef E1_CS_PIN
  234. #endif
  235. #if E_STEPPERS > 2 && !AXIS_HAS_SPI(E2)
  236. #undef E2_CS_PIN
  237. #endif
  238. #if E_STEPPERS > 3 && !AXIS_HAS_SPI(E3)
  239. #undef E3_CS_PIN
  240. #endif
  241. #if E_STEPPERS > 4 && !AXIS_HAS_SPI(E4)
  242. #undef E4_CS_PIN
  243. #endif
  244. #if E_STEPPERS > 5 && !AXIS_HAS_SPI(E5)
  245. #undef E5_CS_PIN
  246. #endif
  247. #if E_STEPPERS > 6 && !AXIS_HAS_SPI(E6)
  248. #undef E6_CS_PIN
  249. #endif
  250. #if E_STEPPERS > 7 && !AXIS_HAS_SPI(E7)
  251. #undef E7_CS_PIN
  252. #endif
  253. #ifndef X_CS_PIN
  254. #define X_CS_PIN -1
  255. #endif
  256. #ifndef Y_CS_PIN
  257. #define Y_CS_PIN -1
  258. #endif
  259. #ifndef Z_CS_PIN
  260. #define Z_CS_PIN -1
  261. #endif
  262. #ifndef I_CS_PIN
  263. #define I_CS_PIN -1
  264. #endif
  265. #ifndef J_CS_PIN
  266. #define J_CS_PIN -1
  267. #endif
  268. #ifndef K_CS_PIN
  269. #define K_CS_PIN -1
  270. #endif
  271. #ifndef U_CS_PIN
  272. #define U_CS_PIN -1
  273. #endif
  274. #ifndef V_CS_PIN
  275. #define V_CS_PIN -1
  276. #endif
  277. #ifndef W_CS_PIN
  278. #define W_CS_PIN -1
  279. #endif
  280. #ifndef E0_CS_PIN
  281. #define E0_CS_PIN -1
  282. #endif
  283. #ifndef E1_CS_PIN
  284. #define E1_CS_PIN -1
  285. #endif
  286. #ifndef E2_CS_PIN
  287. #define E2_CS_PIN -1
  288. #endif
  289. #ifndef E3_CS_PIN
  290. #define E3_CS_PIN -1
  291. #endif
  292. #ifndef E4_CS_PIN
  293. #define E4_CS_PIN -1
  294. #endif
  295. #ifndef E5_CS_PIN
  296. #define E5_CS_PIN -1
  297. #endif
  298. #ifndef E6_CS_PIN
  299. #define E6_CS_PIN -1
  300. #endif
  301. #ifndef E7_CS_PIN
  302. #define E7_CS_PIN -1
  303. #endif
  304. #ifndef FAN_PIN
  305. #define FAN_PIN -1
  306. #endif
  307. #define FAN0_PIN FAN_PIN
  308. #ifndef FAN1_PIN
  309. #define FAN1_PIN -1
  310. #endif
  311. #ifndef FAN2_PIN
  312. #define FAN2_PIN -1
  313. #endif
  314. #ifndef CONTROLLER_FAN_PIN
  315. #define CONTROLLER_FAN_PIN -1
  316. #endif
  317. #ifndef FANMUX0_PIN
  318. #define FANMUX0_PIN -1
  319. #endif
  320. #ifndef FANMUX1_PIN
  321. #define FANMUX1_PIN -1
  322. #endif
  323. #ifndef FANMUX2_PIN
  324. #define FANMUX2_PIN -1
  325. #endif
  326. #ifndef HEATER_0_PIN
  327. #define HEATER_0_PIN -1
  328. #endif
  329. #ifndef HEATER_1_PIN
  330. #define HEATER_1_PIN -1
  331. #endif
  332. #ifndef HEATER_2_PIN
  333. #define HEATER_2_PIN -1
  334. #endif
  335. #ifndef HEATER_3_PIN
  336. #define HEATER_3_PIN -1
  337. #endif
  338. #ifndef HEATER_4_PIN
  339. #define HEATER_4_PIN -1
  340. #endif
  341. #ifndef HEATER_5_PIN
  342. #define HEATER_5_PIN -1
  343. #endif
  344. #ifndef HEATER_6_PIN
  345. #define HEATER_6_PIN -1
  346. #endif
  347. #ifndef HEATER_7_PIN
  348. #define HEATER_7_PIN -1
  349. #endif
  350. #ifndef HEATER_BED_PIN
  351. #define HEATER_BED_PIN -1
  352. #endif
  353. #ifndef TEMP_0_PIN
  354. #define TEMP_0_PIN -1
  355. #endif
  356. #ifndef TEMP_1_PIN
  357. #define TEMP_1_PIN -1
  358. #endif
  359. #ifndef TEMP_2_PIN
  360. #define TEMP_2_PIN -1
  361. #endif
  362. #ifndef TEMP_3_PIN
  363. #define TEMP_3_PIN -1
  364. #endif
  365. #ifndef TEMP_4_PIN
  366. #define TEMP_4_PIN -1
  367. #endif
  368. #ifndef TEMP_5_PIN
  369. #define TEMP_5_PIN -1
  370. #endif
  371. #ifndef TEMP_6_PIN
  372. #define TEMP_6_PIN -1
  373. #endif
  374. #ifndef TEMP_7_PIN
  375. #define TEMP_7_PIN -1
  376. #endif
  377. #ifndef TEMP_BED_PIN
  378. #define TEMP_BED_PIN -1
  379. #endif
  380. #ifndef SD_DETECT_PIN
  381. #define SD_DETECT_PIN -1
  382. #endif
  383. #ifndef SDPOWER_PIN
  384. #define SDPOWER_PIN -1
  385. #endif
  386. #ifndef SDSS
  387. #define SDSS -1
  388. #endif
  389. #ifndef LED_PIN
  390. #define LED_PIN -1
  391. #endif
  392. #if DISABLED(PSU_CONTROL) || !defined(PS_ON_PIN)
  393. #undef PS_ON_PIN
  394. #define PS_ON_PIN -1
  395. #endif
  396. #ifndef KILL_PIN
  397. #define KILL_PIN -1
  398. #endif
  399. #ifndef SUICIDE_PIN
  400. #define SUICIDE_PIN -1
  401. #endif
  402. #ifndef SUICIDE_PIN_STATE
  403. #define SUICIDE_PIN_STATE LOW
  404. #endif
  405. #ifndef NUM_SERVO_PLUGS
  406. #define NUM_SERVO_PLUGS 4
  407. #endif
  408. //
  409. // Assign endstop pins for boards with only 3 connectors
  410. //
  411. #ifdef X_STOP_PIN
  412. #if X_HOME_TO_MIN
  413. #define X_MIN_PIN X_STOP_PIN
  414. #ifndef X_MAX_PIN
  415. #define X_MAX_PIN -1
  416. #endif
  417. #else
  418. #define X_MAX_PIN X_STOP_PIN
  419. #ifndef X_MIN_PIN
  420. #define X_MIN_PIN -1
  421. #endif
  422. #endif
  423. #elif X_HOME_TO_MIN
  424. #define X_STOP_PIN X_MIN_PIN
  425. #else
  426. #define X_STOP_PIN X_MAX_PIN
  427. #endif
  428. #if !defined(X2_USE_ENDSTOP) && ENABLED(X_DUAL_ENDSTOPS) && PIN_EXISTS(X_STOP)
  429. #define X2_USE_ENDSTOP _XSTOP_
  430. #endif
  431. #if HAS_Y_AXIS
  432. #ifdef Y_STOP_PIN
  433. #if Y_HOME_TO_MIN
  434. #define Y_MIN_PIN Y_STOP_PIN
  435. #ifndef Y_MAX_PIN
  436. #define Y_MAX_PIN -1
  437. #endif
  438. #else
  439. #define Y_MAX_PIN Y_STOP_PIN
  440. #ifndef Y_MIN_PIN
  441. #define Y_MIN_PIN -1
  442. #endif
  443. #endif
  444. #elif Y_HOME_TO_MIN
  445. #define Y_STOP_PIN Y_MIN_PIN
  446. #else
  447. #define Y_STOP_PIN Y_MAX_PIN
  448. #endif
  449. #if !defined(Y2_USE_ENDSTOP) && ENABLED(Y_DUAL_ENDSTOPS) && PIN_EXISTS(Y_STOP)
  450. #define Y2_USE_ENDSTOP _YSTOP_
  451. #endif
  452. #endif
  453. #if HAS_Z_AXIS
  454. #ifdef Z_STOP_PIN
  455. #if Z_HOME_TO_MIN
  456. #define Z_MIN_PIN Z_STOP_PIN
  457. #ifndef Z_MAX_PIN
  458. #define Z_MAX_PIN -1
  459. #endif
  460. #else
  461. #define Z_MAX_PIN Z_STOP_PIN
  462. #ifndef Z_MIN_PIN
  463. #define Z_MIN_PIN -1
  464. #endif
  465. #endif
  466. #elif Z_HOME_TO_MIN
  467. #define Z_STOP_PIN Z_MIN_PIN
  468. #else
  469. #define Z_STOP_PIN Z_MAX_PIN
  470. #endif
  471. #if ENABLED(Z_MULTI_ENDSTOPS) && PIN_EXISTS(Z_STOP)
  472. #ifndef Z2_USE_ENDSTOP
  473. #define Z2_USE_ENDSTOP _ZSTOP_
  474. #endif
  475. #if NUM_Z_STEPPERS >= 3 && !defined(Z3_USE_ENDSTOP)
  476. #define Z3_USE_ENDSTOP _ZSTOP_
  477. #endif
  478. #if NUM_Z_STEPPERS >= 4 && !defined(Z4_USE_ENDSTOP)
  479. #define Z4_USE_ENDSTOP _ZSTOP_
  480. #endif
  481. #endif
  482. #endif
  483. #if HAS_I_AXIS
  484. #ifdef I_STOP_PIN
  485. #if I_HOME_TO_MIN
  486. #define I_MIN_PIN I_STOP_PIN
  487. #ifndef I_MAX_PIN
  488. #define I_MAX_PIN -1
  489. #endif
  490. #else
  491. #define I_MAX_PIN I_STOP_PIN
  492. #ifndef I_MIN_PIN
  493. #define I_MIN_PIN -1
  494. #endif
  495. #endif
  496. #elif I_HOME_TO_MIN
  497. #define I_STOP_PIN I_MIN_PIN
  498. #else
  499. #define I_STOP_PIN I_MAX_PIN
  500. #endif
  501. #else
  502. #undef I_MIN_PIN
  503. #undef I_MAX_PIN
  504. #endif
  505. #if HAS_J_AXIS
  506. #ifdef J_STOP_PIN
  507. #if J_HOME_TO_MIN
  508. #define J_MIN_PIN J_STOP_PIN
  509. #ifndef J_MAX_PIN
  510. #define J_MAX_PIN -1
  511. #endif
  512. #else
  513. #define J_MAX_PIN J_STOP_PIN
  514. #ifndef J_MIN_PIN
  515. #define J_MIN_PIN -1
  516. #endif
  517. #endif
  518. #elif J_HOME_TO_MIN
  519. #define J_STOP_PIN J_MIN_PIN
  520. #else
  521. #define J_STOP_PIN J_MAX_PIN
  522. #endif
  523. #else
  524. #undef J_MIN_PIN
  525. #undef J_MAX_PIN
  526. #endif
  527. #if HAS_K_AXIS
  528. #ifdef K_STOP_PIN
  529. #if K_HOME_TO_MIN
  530. #define K_MIN_PIN K_STOP_PIN
  531. #ifndef K_MAX_PIN
  532. #define K_MAX_PIN -1
  533. #endif
  534. #else
  535. #define K_MAX_PIN K_STOP_PIN
  536. #ifndef K_MIN_PIN
  537. #define K_MIN_PIN -1
  538. #endif
  539. #endif
  540. #elif K_HOME_TO_MIN
  541. #define K_STOP_PIN K_MIN_PIN
  542. #else
  543. #define K_STOP_PIN K_MAX_PIN
  544. #endif
  545. #else
  546. #undef K_MIN_PIN
  547. #undef K_MAX_PIN
  548. #endif
  549. #if HAS_U_AXIS
  550. #ifdef U_STOP_PIN
  551. #if U_HOME_TO_MIN
  552. #define U_MIN_PIN U_STOP_PIN
  553. #ifndef U_MAX_PIN
  554. #define U_MAX_PIN -1
  555. #endif
  556. #else
  557. #define U_MAX_PIN U_STOP_PIN
  558. #ifndef U_MIN_PIN
  559. #define U_MIN_PIN -1
  560. #endif
  561. #endif
  562. #elif U_HOME_TO_MIN
  563. #define U_STOP_PIN U_MIN_PIN
  564. #else
  565. #define U_STOP_PIN U_MAX_PIN
  566. #endif
  567. #else
  568. #undef U_MIN_PIN
  569. #undef U_MAX_PIN
  570. #endif
  571. #if HAS_V_AXIS
  572. #ifdef V_STOP_PIN
  573. #if V_HOME_TO_MIN
  574. #define V_MIN_PIN V_STOP_PIN
  575. #ifndef V_MAX_PIN
  576. #define V_MAX_PIN -1
  577. #endif
  578. #else
  579. #define V_MAX_PIN V_STOP_PIN
  580. #ifndef V_MIN_PIN
  581. #define V_MIN_PIN -1
  582. #endif
  583. #endif
  584. #elif V_HOME_TO_MIN
  585. #define V_STOP_PIN V_MIN_PIN
  586. #else
  587. #define V_STOP_PIN V_MAX_PIN
  588. #endif
  589. #else
  590. #undef V_MIN_PIN
  591. #undef V_MAX_PIN
  592. #endif
  593. #if HAS_W_AXIS
  594. #ifdef W_STOP_PIN
  595. #if W_HOME_TO_MIN
  596. #define W_MIN_PIN W_STOP_PIN
  597. #ifndef W_MAX_PIN
  598. #define W_MAX_PIN -1
  599. #endif
  600. #else
  601. #define W_MAX_PIN W_STOP_PIN
  602. #ifndef W_MIN_PIN
  603. #define W_MIN_PIN -1
  604. #endif
  605. #endif
  606. #elif W_HOME_TO_MIN
  607. #define W_STOP_PIN W_MIN_PIN
  608. #else
  609. #define W_STOP_PIN W_MAX_PIN
  610. #endif
  611. #else
  612. #undef W_MIN_PIN
  613. #undef W_MAX_PIN
  614. #endif
  615. // Filament Sensor first pin alias
  616. #if HAS_FILAMENT_SENSOR
  617. #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN // Filament Sensor first pin alias
  618. #else
  619. #undef FIL_RUNOUT_PIN
  620. #undef FIL_RUNOUT1_PIN
  621. #endif
  622. #if NUM_RUNOUT_SENSORS < 2
  623. #undef FIL_RUNOUT2_PIN
  624. #endif
  625. #ifndef LCD_PINS_D4
  626. #define LCD_PINS_D4 -1
  627. #endif
  628. #if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL
  629. #ifndef LCD_PINS_D5
  630. #define LCD_PINS_D5 -1
  631. #endif
  632. #ifndef LCD_PINS_D6
  633. #define LCD_PINS_D6 -1
  634. #endif
  635. #ifndef LCD_PINS_D7
  636. #define LCD_PINS_D7 -1
  637. #endif
  638. #endif
  639. /**
  640. * Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
  641. *
  642. * By default X2 is assigned to the next open E plug
  643. * on the board, then in order, Y2, Z2, Z3. These can be
  644. * overridden in Configuration.h or Configuration_adv.h.
  645. */
  646. #define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
  647. #define _PEXI(p,q) __PEXI(p,q)
  648. #define __EPIN(p,q) E##p##_##q##_PIN
  649. #define _EPIN(p,q) __EPIN(p,q)
  650. #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
  651. #define _En_DIAG_(p) _E##p##_DIAG_
  652. // The E0/E1 steppers are always used for Dual E
  653. #if ENABLED(E_DUAL_STEPPER_DRIVERS)
  654. #ifndef E1_STEP_PIN
  655. #error "No E1 stepper available for E_DUAL_STEPPER_DRIVERS!"
  656. #endif
  657. #define X2_E_INDEX INCREMENT(E_STEPPERS)
  658. #else
  659. #define X2_E_INDEX E_STEPPERS
  660. #endif
  661. #if HAS_X2_STEPPER && !defined(X2_DIAG_PIN) && !defined(X2_STEP_PIN) && !PIN_EXISTS(X2_CS_PIN)
  662. #define Y2_E_INDEX INCREMENT(X2_E_INDEX)
  663. #else
  664. #define Y2_E_INDEX X2_E_INDEX
  665. #endif
  666. // The X2 axis, if any, should be the next open extruder port
  667. #if HAS_X2_STEPPER
  668. #ifndef X2_STEP_PIN
  669. #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
  670. #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
  671. #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
  672. #if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP)
  673. #error "No E stepper plug left for X2!"
  674. #else
  675. #define AUTO_ASSIGNED_X2_STEPPER 1
  676. #endif
  677. #endif
  678. #ifndef X2_MS1_PIN
  679. #define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
  680. #if PIN_EXISTS(X2_MS1)
  681. #define AUTO_ASSIGNED_X2_MS1 1
  682. #endif
  683. #endif
  684. #ifndef X2_MS2_PIN
  685. #define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
  686. #if PIN_EXISTS(X2_MS2)
  687. #define AUTO_ASSIGNED_X2_MS2 1
  688. #endif
  689. #endif
  690. #ifndef X2_MS3_PIN
  691. #define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
  692. #if PIN_EXISTS(X2_MS3)
  693. #define AUTO_ASSIGNED_X2_MS3 1
  694. #endif
  695. #endif
  696. #if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
  697. #define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
  698. #if PIN_EXISTS(X2_CS)
  699. #define AUTO_ASSIGNED_X2_CS 1
  700. #endif
  701. #endif
  702. #if AXIS_HAS_UART(X2)
  703. #ifndef X2_SERIAL_TX_PIN
  704. #define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
  705. #endif
  706. #ifndef X2_SERIAL_RX_PIN
  707. #define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
  708. #endif
  709. #endif
  710. //
  711. // Auto-assign pins for stallGuard sensorless homing
  712. //
  713. #if !defined(X2_DIAG_PIN) && !defined(X2_USE_ENDSTOP) && defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
  714. #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
  715. #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
  716. #define X2_USE_ENDSTOP _XMIN_
  717. #elif DIAG_REMAPPED(X2, Y_MIN)
  718. #define X2_USE_ENDSTOP _YMIN_
  719. #elif DIAG_REMAPPED(X2, Z_MIN)
  720. #define X2_USE_ENDSTOP _ZMIN_
  721. #elif DIAG_REMAPPED(X2, X_MAX)
  722. #define X2_USE_ENDSTOP _XMAX_
  723. #elif DIAG_REMAPPED(X2, Y_MAX)
  724. #define X2_USE_ENDSTOP _YMAX_
  725. #elif DIAG_REMAPPED(X2, Z_MAX)
  726. #define X2_USE_ENDSTOP _ZMAX_
  727. #else // Otherwise pick the next free En_DIAG_PIN directly
  728. #define X2_USE_ENDSTOP _En_DIAG_(X2_E_INDEX)
  729. #endif
  730. #define AUTO_ASSIGNED_X2_DIAG 1
  731. #undef X2_DIAG_PIN // Defined in Conditionals_post.h based on X2_USE_ENDSTOP
  732. #endif
  733. #endif
  734. #ifndef X2_CS_PIN
  735. #define X2_CS_PIN -1
  736. #endif
  737. #ifndef X2_MS1_PIN
  738. #define X2_MS1_PIN -1
  739. #endif
  740. #ifndef X2_MS2_PIN
  741. #define X2_MS2_PIN -1
  742. #endif
  743. #ifndef X2_MS3_PIN
  744. #define X2_MS3_PIN -1
  745. #endif
  746. #if HAS_DUAL_Y_STEPPERS && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN)
  747. #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
  748. #else
  749. #define Z2_E_INDEX Y2_E_INDEX
  750. #endif
  751. // The Y2 axis, if any, should be the next open extruder port
  752. #if HAS_DUAL_Y_STEPPERS
  753. #ifndef Y2_STEP_PIN
  754. #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
  755. #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
  756. #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
  757. #if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP)
  758. #error "No E stepper plug left for Y2!"
  759. #else
  760. #define AUTO_ASSIGNED_Y2_STEPPER 1
  761. #endif
  762. #endif
  763. #ifndef Y2_MS1_PIN
  764. #define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
  765. #if PIN_EXISTS(Y2_MS1)
  766. #define AUTO_ASSIGNED_Y2_MS1 1
  767. #endif
  768. #endif
  769. #ifndef Y2_MS2_PIN
  770. #define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
  771. #if PIN_EXISTS(Y2_MS2)
  772. #define AUTO_ASSIGNED_Y2_MS2 1
  773. #endif
  774. #endif
  775. #ifndef Y2_MS3_PIN
  776. #define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
  777. #if PIN_EXISTS(Y2_MS3)
  778. #define AUTO_ASSIGNED_Y2_MS3 1
  779. #endif
  780. #endif
  781. #if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
  782. #define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
  783. #if PIN_EXISTS(Y2_CS)
  784. #define AUTO_ASSIGNED_Y2_CS 1
  785. #endif
  786. #endif
  787. #if AXIS_HAS_UART(Y2)
  788. #ifndef Y2_SERIAL_TX_PIN
  789. #define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
  790. #endif
  791. #ifndef Y2_SERIAL_RX_PIN
  792. #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
  793. #endif
  794. #endif
  795. // Auto-assign pins for stallGuard sensorless homing
  796. #if !defined(Y2_DIAG_PIN) && !defined(Y2_USE_ENDSTOP) && defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
  797. #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
  798. #if DIAG_REMAPPED(Y2, X_MIN)
  799. #define Y2_USE_ENDSTOP _XMIN_
  800. #elif DIAG_REMAPPED(Y2, Y_MIN)
  801. #define Y2_USE_ENDSTOP _YMIN_
  802. #elif DIAG_REMAPPED(Y2, Z_MIN)
  803. #define Y2_USE_ENDSTOP _ZMIN_
  804. #elif DIAG_REMAPPED(Y2, X_MAX)
  805. #define Y2_USE_ENDSTOP _XMAX_
  806. #elif DIAG_REMAPPED(Y2, Y_MAX)
  807. #define Y2_USE_ENDSTOP _YMAX_
  808. #elif DIAG_REMAPPED(Y2, Z_MAX)
  809. #define Y2_USE_ENDSTOP _ZMAX_
  810. #else
  811. #define Y2_USE_ENDSTOP _En_DIAG_(Y2_E_INDEX)
  812. #endif
  813. #define AUTO_ASSIGNED_Y2_DIAG 1
  814. #undef Y2_DIAG_PIN // Defined in Conditionals_post.h based on Y2_USE_ENDSTOP
  815. #endif
  816. #endif
  817. #ifndef Y2_CS_PIN
  818. #define Y2_CS_PIN -1
  819. #endif
  820. #ifndef Y2_MS1_PIN
  821. #define Y2_MS1_PIN -1
  822. #endif
  823. #ifndef Y2_MS2_PIN
  824. #define Y2_MS2_PIN -1
  825. #endif
  826. #ifndef Y2_MS3_PIN
  827. #define Y2_MS3_PIN -1
  828. #endif
  829. #if NUM_Z_STEPPERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN)
  830. #define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
  831. #else
  832. #define Z3_E_INDEX Z2_E_INDEX
  833. #endif
  834. // The Z2 axis, if any, should be the next open extruder port
  835. #if NUM_Z_STEPPERS >= 2
  836. #ifndef Z2_STEP_PIN
  837. #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
  838. #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
  839. #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
  840. #if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP)
  841. #error "No E stepper plug left for Z2!"
  842. #else
  843. #define AUTO_ASSIGNED_Z2_STEPPER 1
  844. #endif
  845. #endif
  846. #ifndef Z2_MS1_PIN
  847. #define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
  848. #if PIN_EXISTS(Z2_MS1)
  849. #define AUTO_ASSIGNED_Z2_MS1 1
  850. #endif
  851. #endif
  852. #ifndef Z2_MS2_PIN
  853. #define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
  854. #if PIN_EXISTS(Z2_MS2)
  855. #define AUTO_ASSIGNED_Z2_MS2 1
  856. #endif
  857. #endif
  858. #ifndef Z2_MS3_PIN
  859. #define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
  860. #if PIN_EXISTS(Z2_MS3)
  861. #define AUTO_ASSIGNED_Z2_MS3 1
  862. #endif
  863. #endif
  864. #if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
  865. #define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
  866. #if PIN_EXISTS(Z2_CS)
  867. #define AUTO_ASSIGNED_Z2_CS 1
  868. #endif
  869. #endif
  870. #if AXIS_HAS_UART(Z2)
  871. #ifndef Z2_SERIAL_TX_PIN
  872. #define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
  873. #endif
  874. #ifndef Z2_SERIAL_RX_PIN
  875. #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
  876. #endif
  877. #endif
  878. // Auto-assign pins for stallGuard sensorless homing
  879. #if !defined(Z2_DIAG_PIN) && !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z2_E_INDEX, DIAG)
  880. #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
  881. #if DIAG_REMAPPED(Z2, X_MIN)
  882. #define Z2_USE_ENDSTOP _XMIN_
  883. #elif DIAG_REMAPPED(Z2, Y_MIN)
  884. #define Z2_USE_ENDSTOP _YMIN_
  885. #elif DIAG_REMAPPED(Z2, Z_MIN)
  886. #define Z2_USE_ENDSTOP _ZMIN_
  887. #elif DIAG_REMAPPED(Z2, X_MAX)
  888. #define Z2_USE_ENDSTOP _XMAX_
  889. #elif DIAG_REMAPPED(Z2, Y_MAX)
  890. #define Z2_USE_ENDSTOP _YMAX_
  891. #elif DIAG_REMAPPED(Z2, Z_MAX)
  892. #define Z2_USE_ENDSTOP _ZMAX_
  893. #else
  894. #define Z2_USE_ENDSTOP _En_DIAG_(Z2_E_INDEX)
  895. #endif
  896. #define AUTO_ASSIGNED_Z2_DIAG 1
  897. #undef Z2_DIAG_PIN // Defined in Conditionals_post.h based on Z2_USE_ENDSTOP
  898. #endif
  899. #endif
  900. #ifndef Z2_CS_PIN
  901. #define Z2_CS_PIN -1
  902. #endif
  903. #ifndef Z2_MS1_PIN
  904. #define Z2_MS1_PIN -1
  905. #endif
  906. #ifndef Z2_MS2_PIN
  907. #define Z2_MS2_PIN -1
  908. #endif
  909. #ifndef Z2_MS3_PIN
  910. #define Z2_MS3_PIN -1
  911. #endif
  912. #if NUM_Z_STEPPERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN)
  913. #define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
  914. #else
  915. #define Z4_E_INDEX Z3_E_INDEX
  916. #endif
  917. // The Z3 axis, if any, should be the next open extruder port
  918. #if NUM_Z_STEPPERS >= 3
  919. #ifndef Z3_STEP_PIN
  920. #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
  921. #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
  922. #define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
  923. #if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP)
  924. #error "No E stepper plug left for Z3!"
  925. #else
  926. #define AUTO_ASSIGNED_Z3_STEPPER 1
  927. #endif
  928. #endif
  929. #if AXIS_HAS_SPI(Z3) && !defined(Z3_CS_PIN)
  930. #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
  931. #if PIN_EXISTS(Z3_CS)
  932. #define AUTO_ASSIGNED_Z3_CS 1
  933. #endif
  934. #endif
  935. #ifndef Z3_MS1_PIN
  936. #define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
  937. #if PIN_EXISTS(Z3_MS1)
  938. #define AUTO_ASSIGNED_Z3_MS1 1
  939. #endif
  940. #endif
  941. #ifndef Z3_MS2_PIN
  942. #define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
  943. #if PIN_EXISTS(Z3_MS2)
  944. #define AUTO_ASSIGNED_Z3_MS2 1
  945. #endif
  946. #endif
  947. #ifndef Z3_MS3_PIN
  948. #define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
  949. #if PIN_EXISTS(Z3_MS3)
  950. #define AUTO_ASSIGNED_Z3_MS3 1
  951. #endif
  952. #endif
  953. #if AXIS_HAS_UART(Z3)
  954. #ifndef Z3_SERIAL_TX_PIN
  955. #define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
  956. #endif
  957. #ifndef Z3_SERIAL_RX_PIN
  958. #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
  959. #endif
  960. #endif
  961. // Auto-assign pins for stallGuard sensorless homing
  962. #if !defined(Z3_DIAG_PIN) && !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z3_E_INDEX, DIAG)
  963. #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
  964. #if DIAG_REMAPPED(Z3, X_MIN)
  965. #define Z3_USE_ENDSTOP _XMIN_
  966. #elif DIAG_REMAPPED(Z3, Y_MIN)
  967. #define Z3_USE_ENDSTOP _YMIN_
  968. #elif DIAG_REMAPPED(Z3, Z_MIN)
  969. #define Z3_USE_ENDSTOP _ZMIN_
  970. #elif DIAG_REMAPPED(Z3, X_MAX)
  971. #define Z3_USE_ENDSTOP _XMAX_
  972. #elif DIAG_REMAPPED(Z3, Y_MAX)
  973. #define Z3_USE_ENDSTOP _YMAX_
  974. #elif DIAG_REMAPPED(Z3, Z_MAX)
  975. #define Z3_USE_ENDSTOP _ZMAX_
  976. #else
  977. #define Z3_USE_ENDSTOP _En_DIAG_(Z3_E_INDEX)
  978. #endif
  979. #define AUTO_ASSIGNED_Z3_DIAG 1
  980. #undef Z3_DIAG_PIN // Defined in Conditionals_post.h based on Z3_USE_ENDSTOP
  981. #endif
  982. #endif
  983. #ifndef Z3_CS_PIN
  984. #define Z3_CS_PIN -1
  985. #endif
  986. #ifndef Z3_MS1_PIN
  987. #define Z3_MS1_PIN -1
  988. #endif
  989. #ifndef Z3_MS2_PIN
  990. #define Z3_MS2_PIN -1
  991. #endif
  992. #ifndef Z3_MS3_PIN
  993. #define Z3_MS3_PIN -1
  994. #endif
  995. #if NUM_Z_STEPPERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN)
  996. #define I_E_INDEX INCREMENT(Z4_E_INDEX)
  997. #else
  998. #define I_E_INDEX Z4_E_INDEX
  999. #endif
  1000. // The Z4 axis, if any, should be the next open extruder port
  1001. #if NUM_Z_STEPPERS >= 4
  1002. #ifndef Z4_STEP_PIN
  1003. #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
  1004. #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
  1005. #define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
  1006. #if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP)
  1007. #error "No E stepper plug left for Z4!"
  1008. #else
  1009. #define AUTO_ASSIGNED_Z4_STEPPER 1
  1010. #endif
  1011. #endif
  1012. #if AXIS_HAS_SPI(Z4) && !defined(Z4_CS_PIN)
  1013. #define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
  1014. #if PIN_EXISTS(Z4_CS)
  1015. #define AUTO_ASSIGNED_Z4_CS 1
  1016. #endif
  1017. #endif
  1018. #ifndef Z4_MS1_PIN
  1019. #define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
  1020. #if PIN_EXISTS(Z4_MS1)
  1021. #define AUTO_ASSIGNED_Z4_MS1 1
  1022. #endif
  1023. #endif
  1024. #ifndef Z4_MS2_PIN
  1025. #define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
  1026. #if PIN_EXISTS(Z4_MS2)
  1027. #define AUTO_ASSIGNED_Z4_MS2 1
  1028. #endif
  1029. #endif
  1030. #ifndef Z4_MS3_PIN
  1031. #define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
  1032. #if PIN_EXISTS(Z4_MS3)
  1033. #define AUTO_ASSIGNED_Z4_MS3 1
  1034. #endif
  1035. #endif
  1036. #if AXIS_HAS_UART(Z4)
  1037. #ifndef Z4_SERIAL_TX_PIN
  1038. #define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
  1039. #endif
  1040. #ifndef Z4_SERIAL_RX_PIN
  1041. #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
  1042. #endif
  1043. #endif
  1044. // Auto-assign pins for stallGuard sensorless homing
  1045. #if !defined(Z4_DIAG_PIN) && !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && _PEXI(Z4_E_INDEX, DIAG)
  1046. #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
  1047. #if DIAG_REMAPPED(Z4, X_MIN)
  1048. #define Z4_USE_ENDSTOP _XMIN_
  1049. #elif DIAG_REMAPPED(Z4, Y_MIN)
  1050. #define Z4_USE_ENDSTOP _YMIN_
  1051. #elif DIAG_REMAPPED(Z4, Z_MIN)
  1052. #define Z4_USE_ENDSTOP _ZMIN_
  1053. #elif DIAG_REMAPPED(Z4, X_MAX)
  1054. #define Z4_USE_ENDSTOP _XMAX_
  1055. #elif DIAG_REMAPPED(Z4, Y_MAX)
  1056. #define Z4_USE_ENDSTOP _YMAX_
  1057. #elif DIAG_REMAPPED(Z4, Z_MAX)
  1058. #define Z4_USE_ENDSTOP _ZMAX_
  1059. #else
  1060. #define Z4_USE_ENDSTOP _En_DIAG_(Z4_E_INDEX)
  1061. #endif
  1062. #define AUTO_ASSIGNED_Z4_DIAG 1
  1063. #undef Z4_DIAG_PIN // Defined in Conditionals_post.h based on Z4_USE_ENDSTOP
  1064. #endif
  1065. #endif
  1066. #ifndef Z4_CS_PIN
  1067. #define Z4_CS_PIN -1
  1068. #endif
  1069. #ifndef Z4_MS1_PIN
  1070. #define Z4_MS1_PIN -1
  1071. #endif
  1072. #ifndef Z4_MS2_PIN
  1073. #define Z4_MS2_PIN -1
  1074. #endif
  1075. #ifndef Z4_MS3_PIN
  1076. #define Z4_MS3_PIN -1
  1077. #endif
  1078. #if HAS_I_AXIS && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN)
  1079. #define J_E_INDEX INCREMENT(I_E_INDEX)
  1080. #else
  1081. #define J_E_INDEX I_E_INDEX
  1082. #endif
  1083. // The I axis, if any, should be the next open extruder port
  1084. #if HAS_I_AXIS
  1085. #ifndef I_STEP_PIN
  1086. #define I_STEP_PIN _EPIN(I_E_INDEX, STEP)
  1087. #define I_DIR_PIN _EPIN(I_E_INDEX, DIR)
  1088. #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE)
  1089. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP)
  1090. #error "No E stepper plug left for I!"
  1091. #else
  1092. #define AUTO_ASSIGNED_I_STEPPER 1
  1093. #endif
  1094. #endif
  1095. #if AXIS_HAS_SPI(I) && !defined(I_CS_PIN)
  1096. #define I_CS_PIN _EPIN(I_E_INDEX, CS)
  1097. #if PIN_EXISTS(I_CS)
  1098. #define AUTO_ASSIGNED_I_CS 1
  1099. #endif
  1100. #endif
  1101. #ifndef I_MS1_PIN
  1102. #define I_MS1_PIN _EPIN(I_E_INDEX, MS1)
  1103. #if PIN_EXISTS(I_MS1)
  1104. #define AUTO_ASSIGNED_I_MS1 1
  1105. #endif
  1106. #endif
  1107. #ifndef I_MS2_PIN
  1108. #define I_MS2_PIN _EPIN(I_E_INDEX, MS2)
  1109. #if PIN_EXISTS(I_MS2)
  1110. #define AUTO_ASSIGNED_I_MS2 1
  1111. #endif
  1112. #endif
  1113. #ifndef I_MS3_PIN
  1114. #define I_MS3_PIN _EPIN(I_E_INDEX, MS3)
  1115. #if PIN_EXISTS(I_MS3)
  1116. #define AUTO_ASSIGNED_I_MS3 1
  1117. #endif
  1118. #endif
  1119. #if AXIS_HAS_UART(I)
  1120. #ifndef I_SERIAL_TX_PIN
  1121. #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX)
  1122. #endif
  1123. #ifndef I_SERIAL_RX_PIN
  1124. #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX)
  1125. #endif
  1126. #endif
  1127. // Auto-assign pins for stallGuard sensorless homing
  1128. #if !defined(I_DIAG_PIN) && !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)
  1129. #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG)
  1130. #if DIAG_REMAPPED(I, X_MIN)
  1131. #define I_USE_ENDSTOP _XMIN_
  1132. #elif DIAG_REMAPPED(I, Y_MIN)
  1133. #define I_USE_ENDSTOP _YMIN_
  1134. #elif DIAG_REMAPPED(I, Z_MIN)
  1135. #define I_USE_ENDSTOP _ZMIN_
  1136. #elif DIAG_REMAPPED(I, X_MAX)
  1137. #define I_USE_ENDSTOP _XMAX_
  1138. #elif DIAG_REMAPPED(I, Y_MAX)
  1139. #define I_USE_ENDSTOP _YMAX_
  1140. #elif DIAG_REMAPPED(I, Z_MAX)
  1141. #define I_USE_ENDSTOP _ZMAX_
  1142. #else
  1143. #define I_USE_ENDSTOP _En_DIAG_(I_E_INDEX)
  1144. #endif
  1145. #define AUTO_ASSIGNED_I_DIAG 1
  1146. #undef I_DIAG_PIN // Defined in Conditionals_post.h based on I_USE_ENDSTOP
  1147. #endif
  1148. #endif
  1149. #ifndef I_CS_PIN
  1150. #define I_CS_PIN -1
  1151. #endif
  1152. #ifndef I_MS1_PIN
  1153. #define I_MS1_PIN -1
  1154. #endif
  1155. #ifndef I_MS2_PIN
  1156. #define I_MS2_PIN -1
  1157. #endif
  1158. #ifndef I_MS3_PIN
  1159. #define I_MS3_PIN -1
  1160. #endif
  1161. #if HAS_J_AXIS && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN)
  1162. #define K_E_INDEX INCREMENT(J_E_INDEX)
  1163. #else
  1164. #define K_E_INDEX J_E_INDEX
  1165. #endif
  1166. // The J axis, if any, should be the next open extruder port
  1167. #if HAS_J_AXIS
  1168. #ifndef J_STEP_PIN
  1169. #define J_STEP_PIN _EPIN(J_E_INDEX, STEP)
  1170. #define J_DIR_PIN _EPIN(J_E_INDEX, DIR)
  1171. #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE)
  1172. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP)
  1173. #error "No E stepper plug left for J!"
  1174. #else
  1175. #define AUTO_ASSIGNED_J_STEPPER 1
  1176. #endif
  1177. #endif
  1178. #if AXIS_HAS_SPI(J) && !defined(J_CS_PIN)
  1179. #define J_CS_PIN _EPIN(J_E_INDEX, CS)
  1180. #if PIN_EXISTS(J_CS)
  1181. #define AUTO_ASSIGNED_J_CS 1
  1182. #endif
  1183. #endif
  1184. #ifndef J_MS1_PIN
  1185. #define J_MS1_PIN _EPIN(J_E_INDEX, MS1)
  1186. #if PIN_EXISTS(J_MS1)
  1187. #define AUTO_ASSIGNED_J_MS1 1
  1188. #endif
  1189. #endif
  1190. #ifndef J_MS2_PIN
  1191. #define J_MS2_PIN _EPIN(J_E_INDEX, MS2)
  1192. #if PIN_EXISTS(J_MS2)
  1193. #define AUTO_ASSIGNED_J_MS2 1
  1194. #endif
  1195. #endif
  1196. #ifndef J_MS3_PIN
  1197. #define J_MS3_PIN _EPIN(J_E_INDEX, MS3)
  1198. #if PIN_EXISTS(J_MS3)
  1199. #define AUTO_ASSIGNED_J_MS3 1
  1200. #endif
  1201. #endif
  1202. #if AXIS_HAS_UART(J)
  1203. #ifndef J_SERIAL_TX_PIN
  1204. #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX)
  1205. #endif
  1206. #ifndef J_SERIAL_RX_PIN
  1207. #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX)
  1208. #endif
  1209. #endif
  1210. // Auto-assign pins for stallGuard sensorless homing
  1211. #if !defined(J_DIAG_PIN) && !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)
  1212. #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG)
  1213. #if DIAG_REMAPPED(J, X_MIN)
  1214. #define J_USE_ENDSTOP _XMIN_
  1215. #elif DIAG_REMAPPED(J, Y_MIN)
  1216. #define J_USE_ENDSTOP _YMIN_
  1217. #elif DIAG_REMAPPED(J, Z_MIN)
  1218. #define J_USE_ENDSTOP _ZMIN_
  1219. #elif DIAG_REMAPPED(J, X_MAX)
  1220. #define J_USE_ENDSTOP _XMAX_
  1221. #elif DIAG_REMAPPED(J, Y_MAX)
  1222. #define J_USE_ENDSTOP _YMAX_
  1223. #elif DIAG_REMAPPED(I, Z_MAX)
  1224. #define J_USE_ENDSTOP _ZMAX_
  1225. #else
  1226. #define J_USE_ENDSTOP _En_DIAG_(J_E_INDEX)
  1227. #endif
  1228. #define AUTO_ASSIGNED_J_DIAG 1
  1229. #undef J_DIAG_PIN // Defined in Conditionals_post.h based on J_USE_ENDSTOP
  1230. #endif
  1231. #endif
  1232. #ifndef J_CS_PIN
  1233. #define J_CS_PIN -1
  1234. #endif
  1235. #ifndef J_MS1_PIN
  1236. #define J_MS1_PIN -1
  1237. #endif
  1238. #ifndef J_MS2_PIN
  1239. #define J_MS2_PIN -1
  1240. #endif
  1241. #ifndef J_MS3_PIN
  1242. #define J_MS3_PIN -1
  1243. #endif
  1244. #if HAS_K_AXIS && !defined(K_DIAG_PIN) && !defined(K_STEP_PIN) && !PIN_EXISTS(K_CS_PIN)
  1245. #define U_E_INDEX INCREMENT(K_E_INDEX)
  1246. #else
  1247. #define U_E_INDEX K_E_INDEX
  1248. #endif
  1249. // The K axis, if any, should be the next open extruder port
  1250. #if HAS_K_AXIS
  1251. #ifndef K_STEP_PIN
  1252. #define K_STEP_PIN _EPIN(K_E_INDEX, STEP)
  1253. #define K_DIR_PIN _EPIN(K_E_INDEX, DIR)
  1254. #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE)
  1255. #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP)
  1256. #error "No E stepper plug left for K!"
  1257. #else
  1258. #define AUTO_ASSIGNED_K_STEPPER 1
  1259. #endif
  1260. #endif
  1261. #if AXIS_HAS_SPI(K) && !defined(K_CS_PIN)
  1262. #define K_CS_PIN _EPIN(K_E_INDEX, CS)
  1263. #if PIN_EXISTS(K_CS)
  1264. #define AUTO_ASSIGNED_K_CS 1
  1265. #endif
  1266. #endif
  1267. #ifndef K_MS1_PIN
  1268. #define K_MS1_PIN _EPIN(K_E_INDEX, MS1)
  1269. #if PIN_EXISTS(K_MS1)
  1270. #define AUTO_ASSIGNED_K_MS1 1
  1271. #endif
  1272. #endif
  1273. #ifndef K_MS2_PIN
  1274. #define K_MS2_PIN _EPIN(K_E_INDEX, MS2)
  1275. #if PIN_EXISTS(K_MS2)
  1276. #define AUTO_ASSIGNED_K_MS2 1
  1277. #endif
  1278. #endif
  1279. #ifndef K_MS3_PIN
  1280. #define K_MS3_PIN _EPIN(K_E_INDEX, MS3)
  1281. #if PIN_EXISTS(K_MS3)
  1282. #define AUTO_ASSIGNED_K_MS3 1
  1283. #endif
  1284. #endif
  1285. #if AXIS_HAS_UART(K)
  1286. #ifndef K_SERIAL_TX_PIN
  1287. #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX)
  1288. #endif
  1289. #ifndef K_SERIAL_RX_PIN
  1290. #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX)
  1291. #endif
  1292. #endif
  1293. // Auto-assign pins for stallGuard sensorless homing
  1294. #if !defined(K_DIAG_PIN) && !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)
  1295. #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG)
  1296. #if DIAG_REMAPPED(K, X_MIN)
  1297. #define K_USE_ENDSTOP _XMIN_
  1298. #elif DIAG_REMAPPED(K, Y_MIN)
  1299. #define K_USE_ENDSTOP _YMIN_
  1300. #elif DIAG_REMAPPED(K, Z_MIN)
  1301. #define K_USE_ENDSTOP _ZMIN_
  1302. #elif DIAG_REMAPPED(K, X_MAX)
  1303. #define K_USE_ENDSTOP _XMAX_
  1304. #elif DIAG_REMAPPED(K, Y_MAX)
  1305. #define K_USE_ENDSTOP _YMAX_
  1306. #elif DIAG_REMAPPED(K, Z_MAX)
  1307. #define K_USE_ENDSTOP _ZMAX_
  1308. #else
  1309. #define K_USE_ENDSTOP _En_DIAG_(K_E_INDEX)
  1310. #endif
  1311. #define AUTO_ASSIGNED_K_DIAG 1
  1312. #undef K_DIAG_PIN // Defined in Conditionals_post.h based on K_USE_ENDSTOP
  1313. #endif
  1314. #endif
  1315. #ifndef K_CS_PIN
  1316. #define K_CS_PIN -1
  1317. #endif
  1318. #ifndef K_MS1_PIN
  1319. #define K_MS1_PIN -1
  1320. #endif
  1321. #ifndef K_MS2_PIN
  1322. #define K_MS2_PIN -1
  1323. #endif
  1324. #ifndef K_MS3_PIN
  1325. #define K_MS3_PIN -1
  1326. #endif
  1327. #if HAS_U_AXIS && !defined(U_DIAG_PIN) && !defined(U_STEP_PIN) && !PIN_EXISTS(U_CS_PIN)
  1328. #define V_E_INDEX INCREMENT(U_E_INDEX)
  1329. #else
  1330. #define V_E_INDEX U_E_INDEX
  1331. #endif
  1332. // The U axis, if any, should be the next open extruder port
  1333. #if HAS_U_AXIS
  1334. #ifndef U_STEP_PIN
  1335. #define U_STEP_PIN _EPIN(U_E_INDEX, STEP)
  1336. #define U_DIR_PIN _EPIN(U_E_INDEX, DIR)
  1337. #define U_ENABLE_PIN _EPIN(U_E_INDEX, ENABLE)
  1338. #if M_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(U_STEP)
  1339. #error "No E stepper plug left for U!"
  1340. #else
  1341. #define AUTO_ASSIGNED_U_STEPPER 1
  1342. #endif
  1343. #endif
  1344. #if AXIS_HAS_SPI(U) && !defined(U_CS_PIN)
  1345. #define U_CS_PIN _EPIN(U_E_INDEX, CS)
  1346. #if PIN_EXISTS(U_CS)
  1347. #define AUTO_ASSIGNED_U_CS 1
  1348. #endif
  1349. #endif
  1350. #ifndef U_MS1_PIN
  1351. #define U_MS1_PIN _EPIN(U_E_INDEX, MS1)
  1352. #if PIN_EXISTS(U_MS1)
  1353. #define AUTO_ASSIGNED_U_MS1 1
  1354. #endif
  1355. #endif
  1356. #ifndef U_MS2_PIN
  1357. #define U_MS2_PIN _EPIN(U_E_INDEX, MS2)
  1358. #if PIN_EXISTS(U_MS2)
  1359. #define AUTO_ASSIGNED_U_MS2 1
  1360. #endif
  1361. #endif
  1362. #ifndef U_MS3_PIN
  1363. #define U_MS3_PIN _EPIN(U_E_INDEX, MS3)
  1364. #if PIN_EXISTS(U_MS3)
  1365. #define AUTO_ASSIGNED_U_MS3 1
  1366. #endif
  1367. #endif
  1368. #if AXIS_HAS_UART(U)
  1369. #ifndef U_SERIAL_TX_PIN
  1370. #define U_SERIAL_TX_PIN _EPIN(U_E_INDEX, SERIAL_TX)
  1371. #endif
  1372. #ifndef U_SERIAL_RX_PIN
  1373. #define U_SERIAL_RX_PIN _EPIN(U_E_INDEX, SERIAL_RX)
  1374. #endif
  1375. #endif
  1376. // Auto-assign pins for stallGuard sensorless homing
  1377. #if !defined(U_DIAG_PIN) && !defined(U_USE_ENDSTOP) && defined(U_STALL_SENSITIVITY) && _PEXI(U_E_INDEX, DIAG)
  1378. #define U_DIAG_PIN _EPIN(U_E_INDEX, DIAG)
  1379. #if DIAG_REMAPPED(U, X_MIN)
  1380. #define U_USE_ENDSTOP _XMIN_
  1381. #elif DIAG_REMAPPED(U, Y_MIN)
  1382. #define U_USE_ENDSTOP _YMIN_
  1383. #elif DIAG_REMAPPED(U, Z_MIN)
  1384. #define U_USE_ENDSTOP _ZMIN_
  1385. #elif DIAG_REMAPPED(U, X_MAX)
  1386. #define U_USE_ENDSTOP _XMAX_
  1387. #elif DIAG_REMAPPED(U, Y_MAX)
  1388. #define U_USE_ENDSTOP _YMAX_
  1389. #elif DIAG_REMAPPED(U, Z_MAX)
  1390. #define U_USE_ENDSTOP _ZMAX_
  1391. #else
  1392. #define U_USE_ENDSTOP _En_DIAG_(U_E_INDEX)
  1393. #endif
  1394. #define AUTO_ASSIGNED_U_DIAG 1
  1395. #undef U_DIAG_PIN // Defined in Conditionals_post.h based on U_USE_ENDSTOP
  1396. #endif
  1397. #endif
  1398. #ifndef U_CS_PIN
  1399. #define U_CS_PIN -1
  1400. #endif
  1401. #ifndef U_MS1_PIN
  1402. #define U_MS1_PIN -1
  1403. #endif
  1404. #ifndef U_MS2_PIN
  1405. #define U_MS2_PIN -1
  1406. #endif
  1407. #ifndef U_MS3_PIN
  1408. #define U_MS3_PIN -1
  1409. #endif
  1410. #if HAS_V_AXIS && !defined(V_DIAG_PIN) && !defined(V_STEP_PIN) && !PIN_EXISTS(V_CS_PIN)
  1411. #define W_E_INDEX INCREMENT(V_E_INDEX)
  1412. #else
  1413. #define W_E_INDEX V_E_INDEX
  1414. #endif
  1415. // The V axis, if any, should be the next open extruder port
  1416. #if HAS_V_AXIS
  1417. #ifndef V_STEP_PIN
  1418. #define V_STEP_PIN _EPIN(V_E_INDEX, STEP)
  1419. #define V_DIR_PIN _EPIN(V_E_INDEX, DIR)
  1420. #define V_ENABLE_PIN _EPIN(V_E_INDEX, ENABLE)
  1421. #if V_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(V_STEP)
  1422. #error "No E stepper plug left for V!"
  1423. #else
  1424. #define AUTO_ASSIGNED_V_STEPPER 1
  1425. #endif
  1426. #endif
  1427. #if AXIS_HAS_SPI(V) && !defined(V_CS_PIN)
  1428. #define V_CS_PIN _EPIN(V_E_INDEX, CS)
  1429. #if PIN_EXISTS(V_CS)
  1430. #define AUTO_ASSIGNED_V_CS 1
  1431. #endif
  1432. #endif
  1433. #ifndef V_MS1_PIN
  1434. #define V_MS1_PIN _EPIN(V_E_INDEX, MS1)
  1435. #if PIN_EXISTS(V_MS1)
  1436. #define AUTO_ASSIGNED_V_MS1 1
  1437. #endif
  1438. #endif
  1439. #ifndef V_MS2_PIN
  1440. #define V_MS2_PIN _EPIN(V_E_INDEX, MS2)
  1441. #if PIN_EXISTS(V_MS2)
  1442. #define AUTO_ASSIGNED_V_MS2 1
  1443. #endif
  1444. #endif
  1445. #ifndef V_MS3_PIN
  1446. #define V_MS3_PIN _EPIN(V_E_INDEX, MS3)
  1447. #if PIN_EXISTS(V_MS3)
  1448. #define AUTO_ASSIGNED_V_MS3 1
  1449. #endif
  1450. #endif
  1451. #if AXIS_HAS_UART(V)
  1452. #ifndef V_SERIAL_TX_PIN
  1453. #define V_SERIAL_TX_PIN _EPIN(V_E_INDEX, SERIAL_TX)
  1454. #endif
  1455. #ifndef V_SERIAL_RX_PIN
  1456. #define V_SERIAL_RX_PIN _EPIN(V_E_INDEX, SERIAL_RX)
  1457. #endif
  1458. #endif
  1459. // Auto-assign pins for stallGuard sensorless homing
  1460. #if !defined(V_DIAG_PIN) && !defined(V_USE_ENDSTOP) && defined(V_STALL_SENSITIVITY) && _PEXI(V_E_INDEX, DIAG)
  1461. #define V_DIAG_PIN _EPIN(V_E_INDEX, DIAG)
  1462. #if DIAG_REMAPPED(V, X_MIN)
  1463. #define V_USE_ENDSTOP _XMIN_
  1464. #elif DIAG_REMAPPED(V, Y_MIN)
  1465. #define V_USE_ENDSTOP _YMIN_
  1466. #elif DIAG_REMAPPED(V, Z_MIN)
  1467. #define V_USE_ENDSTOP _ZMIN_
  1468. #elif DIAG_REMAPPED(V, X_MAX)
  1469. #define V_USE_ENDSTOP _XMAX_
  1470. #elif DIAG_REMAPPED(V, Y_MAX)
  1471. #define V_USE_ENDSTOP _YMAX_
  1472. #elif DIAG_REMAPPED(V, Z_MAX)
  1473. #define V_USE_ENDSTOP _ZMAX_
  1474. #else
  1475. #define V_USE_ENDSTOP _En_DIAG_(V_E_INDEX)
  1476. #endif
  1477. #define AUTO_ASSIGNED_V_DIAG 1
  1478. #undef V_DIAG_PIN // Defined in Conditionals_post.h based on O_USE_ENDSTOP
  1479. #endif
  1480. #endif
  1481. #ifndef V_CS_PIN
  1482. #define V_CS_PIN -1
  1483. #endif
  1484. #ifndef V_MS1_PIN
  1485. #define V_MS1_PIN -1
  1486. #endif
  1487. #ifndef V_MS2_PIN
  1488. #define V_MS2_PIN -1
  1489. #endif
  1490. #ifndef V_MS3_PIN
  1491. #define V_MS3_PIN -1
  1492. #endif
  1493. // The W axis, if any, should be the next open extruder port
  1494. #if HAS_W_AXIS
  1495. #ifndef W_STEP_PIN
  1496. #define W_STEP_PIN _EPIN(W_E_INDEX, STEP)
  1497. #define W_DIR_PIN _EPIN(W_E_INDEX, DIR)
  1498. #define W_ENABLE_PIN _EPIN(W_E_INDEX, ENABLE)
  1499. #if W_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(W_STEP)
  1500. #error "No E stepper plug left for W!"
  1501. #else
  1502. #define AUTO_ASSIGNED_W_STEPPER 1
  1503. #endif
  1504. #endif
  1505. #if AXIS_HAS_SPI(W) && !defined(W_CS_PIN)
  1506. #define W_CS_PIN _EPIN(W_E_INDEX, CS)
  1507. #if PIN_EXISTS(W_CS)
  1508. #define AUTO_ASSIGNED_W_CS 1
  1509. #endif
  1510. #endif
  1511. #ifndef W_MS1_PIN
  1512. #define W_MS1_PIN _EPIN(W_E_INDEX, MS1)
  1513. #if PIN_EXISTS(W_MS1)
  1514. #define AUTO_ASSIGNED_W_MS1 1
  1515. #endif
  1516. #endif
  1517. #ifndef W_MS2_PIN
  1518. #define W_MS2_PIN _EPIN(W_E_INDEX, MS2)
  1519. #if PIN_EXISTS(W_MS2)
  1520. #define AUTO_ASSIGNED_W_MS2 1
  1521. #endif
  1522. #endif
  1523. #ifndef W_MS3_PIN
  1524. #define W_MS3_PIN _EPIN(W_E_INDEX, MS3)
  1525. #if PIN_EXISTS(W_MS3)
  1526. #define AUTO_ASSIGNED_W_MS3 1
  1527. #endif
  1528. #endif
  1529. #if AXIS_HAS_UART(W)
  1530. #ifndef W_SERIAL_TX_PIN
  1531. #define W_SERIAL_TX_PIN _EPIN(W_E_INDEX, SERIAL_TX)
  1532. #endif
  1533. #ifndef W_SERIAL_RX_PIN
  1534. #define W_SERIAL_RX_PIN _EPIN(W_E_INDEX, SERIAL_RX)
  1535. #endif
  1536. #endif
  1537. // Auto-assign pins for stallGuard sensorless homing
  1538. #if !defined(W_DIAG_PIN) && !defined(W_USE_ENDSTOP) && defined(W_STALL_SENSITIVITY) && _PEXI(W_E_INDEX, DIAG)
  1539. #define W_DIAG_PIN _EPIN(W_E_INDEX, DIAG)
  1540. #if DIAG_REMAPPED(W, X_MIN)
  1541. #define W_USE_ENDSTOP _XMIN_
  1542. #elif DIAG_REMAPPED(W, Y_MIN)
  1543. #define W_USE_ENDSTOP _YMIN_
  1544. #elif DIAG_REMAPPED(W, Z_MIN)
  1545. #define W_USE_ENDSTOP _ZMIN_
  1546. #elif DIAG_REMAPPED(W, X_MAX)
  1547. #define W_USE_ENDSTOP _XMAX_
  1548. #elif DIAG_REMAPPED(W, Y_MAX)
  1549. #define W_USE_ENDSTOP _YMAX_
  1550. #elif DIAG_REMAPPED(W, Z_MAX)
  1551. #define W_USE_ENDSTOP _ZMAX_
  1552. #else
  1553. #define W_USE_ENDSTOP _En_DIAG_(W_E_INDEX)
  1554. #endif
  1555. #define AUTO_ASSIGNED_W_DIAG 1
  1556. #undef W_DIAG_PIN // Defined in Conditionals_post.h based on Q_USE_ENDSTOP
  1557. #endif
  1558. #endif
  1559. #ifndef W_CS_PIN
  1560. #define W_CS_PIN -1
  1561. #endif
  1562. #ifndef W_MS1_PIN
  1563. #define W_MS1_PIN -1
  1564. #endif
  1565. #ifndef W_MS2_PIN
  1566. #define W_MS2_PIN -1
  1567. #endif
  1568. #ifndef W_MS3_PIN
  1569. #define W_MS3_PIN -1
  1570. #endif
  1571. //
  1572. // Disable unused endstop / probe pins
  1573. //
  1574. #define _STOP_IN_USE(N) (X2_USE_ENDSTOP == N || Y2_USE_ENDSTOP == N || Z2_USE_ENDSTOP == N || Z3_USE_ENDSTOP == N || Z4_USE_ENDSTOP == N)
  1575. #if !defined(USE_XMAX_PLUG) && _STOP_IN_USE(_XMAX_)
  1576. #define USE_XMAX_PLUG
  1577. #endif
  1578. #if !defined(USE_YMAX_PLUG) && _STOP_IN_USE(_YMAX_)
  1579. #define USE_YMAX_PLUG
  1580. #endif
  1581. #if !defined(USE_ZMAX_PLUG) && _STOP_IN_USE(_ZMAX_)
  1582. #define USE_ZMAX_PLUG
  1583. #endif
  1584. #if !defined(USE_XMIN_PLUG) && _STOP_IN_USE(_XMIN_)
  1585. #define USE_XMIN_PLUG
  1586. #endif
  1587. #if !defined(USE_YMIN_PLUG) && _STOP_IN_USE(_YMIN_)
  1588. #define USE_YMIN_PLUG
  1589. #endif
  1590. #if !defined(USE_ZMIN_PLUG) && _STOP_IN_USE(_ZMIN_)
  1591. #define USE_ZMIN_PLUG
  1592. #endif
  1593. #undef _STOP_IN_USE
  1594. #if !USES_Z_MIN_PROBE_PIN
  1595. #undef Z_MIN_PROBE_PIN
  1596. #define Z_MIN_PROBE_PIN -1
  1597. #endif
  1598. #if DISABLED(USE_XMIN_PLUG)
  1599. #undef X_MIN_PIN
  1600. #define X_MIN_PIN -1
  1601. #endif
  1602. #if DISABLED(USE_XMAX_PLUG)
  1603. #undef X_MAX_PIN
  1604. #define X_MAX_PIN -1
  1605. #endif
  1606. #if NONE(USE_XMIN_PLUG, USE_XMAX_PLUG)
  1607. #undef X_STOP_PIN
  1608. #endif
  1609. #if DISABLED(USE_YMIN_PLUG)
  1610. #undef Y_MIN_PIN
  1611. #define Y_MIN_PIN -1
  1612. #endif
  1613. #if DISABLED(USE_YMAX_PLUG)
  1614. #undef Y_MAX_PIN
  1615. #define Y_MAX_PIN -1
  1616. #endif
  1617. #if NONE(USE_YMIN_PLUG, USE_YMAX_PLUG)
  1618. #undef Y_STOP_PIN
  1619. #endif
  1620. #if DISABLED(USE_ZMIN_PLUG)
  1621. #undef Z_MIN_PIN
  1622. #define Z_MIN_PIN -1
  1623. #endif
  1624. #if DISABLED(USE_ZMAX_PLUG)
  1625. #undef Z_MAX_PIN
  1626. #define Z_MAX_PIN -1
  1627. #endif
  1628. #if NONE(USE_ZMIN_PLUG, USE_ZMAX_PLUG)
  1629. #undef Z_STOP_PIN
  1630. #endif
  1631. #if DISABLED(USE_IMIN_PLUG)
  1632. #undef I_MIN_PIN
  1633. #define I_MIN_PIN -1
  1634. #endif
  1635. #if DISABLED(USE_IMAX_PLUG)
  1636. #undef I_MAX_PIN
  1637. #define I_MAX_PIN -1
  1638. #endif
  1639. #if NONE(USE_IMIN_PLUG, USE_IMAX_PLUG)
  1640. #undef I_STOP_PIN
  1641. #endif
  1642. #if DISABLED(USE_JMIN_PLUG)
  1643. #undef J_MIN_PIN
  1644. #define J_MIN_PIN -1
  1645. #endif
  1646. #if DISABLED(USE_JMAX_PLUG)
  1647. #undef J_MAX_PIN
  1648. #define J_MAX_PIN -1
  1649. #endif
  1650. #if NONE(USE_JMIN_PLUG, USE_JMAX_PLUG)
  1651. #undef J_STOP_PIN
  1652. #endif
  1653. #if DISABLED(USE_KMIN_PLUG)
  1654. #undef K_MIN_PIN
  1655. #define K_MIN_PIN -1
  1656. #endif
  1657. #if DISABLED(USE_KMAX_PLUG)
  1658. #undef K_MAX_PIN
  1659. #define K_MAX_PIN -1
  1660. #endif
  1661. #if NONE(USE_KMIN_PLUG, USE_KMAX_PLUG)
  1662. #undef K_STOP_PIN
  1663. #endif
  1664. #if DISABLED(USE_UMIN_PLUG)
  1665. #undef U_MIN_PIN
  1666. #define U_MIN_PIN -1
  1667. #endif
  1668. #if DISABLED(USE_UMAX_PLUG)
  1669. #undef U_MAX_PIN
  1670. #define U_MAX_PIN -1
  1671. #endif
  1672. #if NONE(USE_UMIN_PLUG, USE_UMAX_PLUG)
  1673. #undef U_STOP_PIN
  1674. #endif
  1675. #if DISABLED(USE_VMIN_PLUG)
  1676. #undef V_MIN_PIN
  1677. #define V_MIN_PIN -1
  1678. #endif
  1679. #if DISABLED(USE_VMAX_PLUG)
  1680. #undef V_MAX_PIN
  1681. #define V_MAX_PIN -1
  1682. #endif
  1683. #if NONE(USE_VMIN_PLUG, USE_VMAX_PLUG)
  1684. #undef V_STOP_PIN
  1685. #endif
  1686. #if DISABLED(USE_WMIN_PLUG)
  1687. #undef W_MIN_PIN
  1688. #define W_MIN_PIN -1
  1689. #endif
  1690. #if DISABLED(USE_WMAX_PLUG)
  1691. #undef W_MAX_PIN
  1692. #define W_MAX_PIN -1
  1693. #endif
  1694. #if NONE(USE_WMIN_PLUG, USE_WMAX_PLUG)
  1695. #undef W_STOP_PIN
  1696. #endif
  1697. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX
  1698. #undef X2_MIN_PIN
  1699. #endif
  1700. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MIN
  1701. #undef X2_MAX_PIN
  1702. #endif
  1703. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MAX
  1704. #undef Y2_MIN_PIN
  1705. #endif
  1706. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MIN
  1707. #undef Y2_MAX_PIN
  1708. #endif
  1709. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MAX
  1710. #undef Z2_MIN_PIN
  1711. #endif
  1712. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN
  1713. #undef Z2_MAX_PIN
  1714. #endif
  1715. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MAX
  1716. #undef Z3_MIN_PIN
  1717. #endif
  1718. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 3 || Z_HOME_TO_MIN
  1719. #undef Z3_MAX_PIN
  1720. #endif
  1721. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MAX
  1722. #undef Z4_MIN_PIN
  1723. #endif
  1724. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPERS < 4 || Z_HOME_TO_MIN
  1725. #undef Z4_MAX_PIN
  1726. #endif
  1727. //
  1728. // Default DOGLCD SPI delays
  1729. //
  1730. #if !IS_U8GLIB_ST7920
  1731. #undef ST7920_DELAY_1
  1732. #undef ST7920_DELAY_2
  1733. #undef ST7920_DELAY_3
  1734. #undef LCD_ST7920_DELAY_1
  1735. #undef LCD_ST7920_DELAY_2
  1736. #undef LCD_ST7920_DELAY_3
  1737. #undef BOARD_ST7920_DELAY_1
  1738. #undef BOARD_ST7920_DELAY_2
  1739. #undef BOARD_ST7920_DELAY_3
  1740. #undef CPU_ST7920_DELAY_1
  1741. #undef CPU_ST7920_DELAY_2
  1742. #undef CPU_ST7920_DELAY_3
  1743. #endif
  1744. #if !NEED_CASE_LIGHT_PIN
  1745. #undef CASE_LIGHT_PIN
  1746. #endif
  1747. #undef HAS_FREE_AUX2_PINS
  1748. #undef DIAG_REMAPPED