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 29KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240
  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 E_STEPPERS && !AXIS_HAS_SPI(E0)
  221. #undef E0_CS_PIN
  222. #endif
  223. #if E_STEPPERS > 1 && !AXIS_HAS_SPI(E1)
  224. #undef E1_CS_PIN
  225. #endif
  226. #if E_STEPPERS > 2 && !AXIS_HAS_SPI(E2)
  227. #undef E2_CS_PIN
  228. #endif
  229. #if E_STEPPERS > 3 && !AXIS_HAS_SPI(E3)
  230. #undef E3_CS_PIN
  231. #endif
  232. #if E_STEPPERS > 4 && !AXIS_HAS_SPI(E4)
  233. #undef E4_CS_PIN
  234. #endif
  235. #if E_STEPPERS > 5 && !AXIS_HAS_SPI(E5)
  236. #undef E5_CS_PIN
  237. #endif
  238. #if E_STEPPERS > 6 && !AXIS_HAS_SPI(E6)
  239. #undef E6_CS_PIN
  240. #endif
  241. #if E_STEPPERS > 7 && !AXIS_HAS_SPI(E7)
  242. #undef E7_CS_PIN
  243. #endif
  244. #ifndef X_CS_PIN
  245. #define X_CS_PIN -1
  246. #endif
  247. #ifndef Y_CS_PIN
  248. #define Y_CS_PIN -1
  249. #endif
  250. #ifndef Z_CS_PIN
  251. #define Z_CS_PIN -1
  252. #endif
  253. #ifndef I_CS_PIN
  254. #define I_CS_PIN -1
  255. #endif
  256. #ifndef J_CS_PIN
  257. #define J_CS_PIN -1
  258. #endif
  259. #ifndef K_CS_PIN
  260. #define K_CS_PIN -1
  261. #endif
  262. #ifndef E0_CS_PIN
  263. #define E0_CS_PIN -1
  264. #endif
  265. #ifndef E1_CS_PIN
  266. #define E1_CS_PIN -1
  267. #endif
  268. #ifndef E2_CS_PIN
  269. #define E2_CS_PIN -1
  270. #endif
  271. #ifndef E3_CS_PIN
  272. #define E3_CS_PIN -1
  273. #endif
  274. #ifndef E4_CS_PIN
  275. #define E4_CS_PIN -1
  276. #endif
  277. #ifndef E5_CS_PIN
  278. #define E5_CS_PIN -1
  279. #endif
  280. #ifndef E6_CS_PIN
  281. #define E6_CS_PIN -1
  282. #endif
  283. #ifndef E7_CS_PIN
  284. #define E7_CS_PIN -1
  285. #endif
  286. #ifndef FAN_PIN
  287. #define FAN_PIN -1
  288. #endif
  289. #define FAN0_PIN FAN_PIN
  290. #ifndef FAN1_PIN
  291. #define FAN1_PIN -1
  292. #endif
  293. #ifndef FAN2_PIN
  294. #define FAN2_PIN -1
  295. #endif
  296. #ifndef CONTROLLER_FAN_PIN
  297. #define CONTROLLER_FAN_PIN -1
  298. #endif
  299. #ifndef FANMUX0_PIN
  300. #define FANMUX0_PIN -1
  301. #endif
  302. #ifndef FANMUX1_PIN
  303. #define FANMUX1_PIN -1
  304. #endif
  305. #ifndef FANMUX2_PIN
  306. #define FANMUX2_PIN -1
  307. #endif
  308. #ifndef HEATER_0_PIN
  309. #define HEATER_0_PIN -1
  310. #endif
  311. #ifndef HEATER_1_PIN
  312. #define HEATER_1_PIN -1
  313. #endif
  314. #ifndef HEATER_2_PIN
  315. #define HEATER_2_PIN -1
  316. #endif
  317. #ifndef HEATER_3_PIN
  318. #define HEATER_3_PIN -1
  319. #endif
  320. #ifndef HEATER_4_PIN
  321. #define HEATER_4_PIN -1
  322. #endif
  323. #ifndef HEATER_5_PIN
  324. #define HEATER_5_PIN -1
  325. #endif
  326. #ifndef HEATER_6_PIN
  327. #define HEATER_6_PIN -1
  328. #endif
  329. #ifndef HEATER_7_PIN
  330. #define HEATER_7_PIN -1
  331. #endif
  332. #ifndef HEATER_BED_PIN
  333. #define HEATER_BED_PIN -1
  334. #endif
  335. #ifndef TEMP_0_PIN
  336. #define TEMP_0_PIN -1
  337. #endif
  338. #ifndef TEMP_1_PIN
  339. #define TEMP_1_PIN -1
  340. #endif
  341. #ifndef TEMP_2_PIN
  342. #define TEMP_2_PIN -1
  343. #endif
  344. #ifndef TEMP_3_PIN
  345. #define TEMP_3_PIN -1
  346. #endif
  347. #ifndef TEMP_4_PIN
  348. #define TEMP_4_PIN -1
  349. #endif
  350. #ifndef TEMP_5_PIN
  351. #define TEMP_5_PIN -1
  352. #endif
  353. #ifndef TEMP_6_PIN
  354. #define TEMP_6_PIN -1
  355. #endif
  356. #ifndef TEMP_7_PIN
  357. #define TEMP_7_PIN -1
  358. #endif
  359. #ifndef TEMP_BED_PIN
  360. #define TEMP_BED_PIN -1
  361. #endif
  362. #ifndef SD_DETECT_PIN
  363. #define SD_DETECT_PIN -1
  364. #endif
  365. #ifndef SDPOWER_PIN
  366. #define SDPOWER_PIN -1
  367. #endif
  368. #ifndef SDSS
  369. #define SDSS -1
  370. #endif
  371. #ifndef LED_PIN
  372. #define LED_PIN -1
  373. #endif
  374. #if DISABLED(PSU_CONTROL) || !defined(PS_ON_PIN)
  375. #undef PS_ON_PIN
  376. #define PS_ON_PIN -1
  377. #endif
  378. #ifndef KILL_PIN
  379. #define KILL_PIN -1
  380. #endif
  381. #ifndef SUICIDE_PIN
  382. #define SUICIDE_PIN -1
  383. #endif
  384. #ifndef SUICIDE_PIN_INVERTING
  385. #define SUICIDE_PIN_INVERTING false
  386. #endif
  387. #ifndef NUM_SERVO_PLUGS
  388. #define NUM_SERVO_PLUGS 4
  389. #endif
  390. //
  391. // Assign endstop pins for boards with only 3 connectors
  392. //
  393. #ifdef X_STOP_PIN
  394. #if X_HOME_TO_MIN
  395. #define X_MIN_PIN X_STOP_PIN
  396. #ifndef X_MAX_PIN
  397. #define X_MAX_PIN -1
  398. #endif
  399. #else
  400. #define X_MAX_PIN X_STOP_PIN
  401. #ifndef X_MIN_PIN
  402. #define X_MIN_PIN -1
  403. #endif
  404. #endif
  405. #elif X_HOME_TO_MIN
  406. #define X_STOP_PIN X_MIN_PIN
  407. #else
  408. #define X_STOP_PIN X_MAX_PIN
  409. #endif
  410. #if HAS_Y_AXIS
  411. #ifdef Y_STOP_PIN
  412. #if Y_HOME_TO_MIN
  413. #define Y_MIN_PIN Y_STOP_PIN
  414. #ifndef Y_MAX_PIN
  415. #define Y_MAX_PIN -1
  416. #endif
  417. #else
  418. #define Y_MAX_PIN Y_STOP_PIN
  419. #ifndef Y_MIN_PIN
  420. #define Y_MIN_PIN -1
  421. #endif
  422. #endif
  423. #elif Y_HOME_TO_MIN
  424. #define Y_STOP_PIN Y_MIN_PIN
  425. #else
  426. #define Y_STOP_PIN Y_MAX_PIN
  427. #endif
  428. #endif
  429. #if HAS_Z_AXIS
  430. #ifdef Z_STOP_PIN
  431. #if Z_HOME_TO_MIN
  432. #define Z_MIN_PIN Z_STOP_PIN
  433. #ifndef Z_MAX_PIN
  434. #define Z_MAX_PIN -1
  435. #endif
  436. #else
  437. #define Z_MAX_PIN Z_STOP_PIN
  438. #ifndef Z_MIN_PIN
  439. #define Z_MIN_PIN -1
  440. #endif
  441. #endif
  442. #elif Z_HOME_TO_MIN
  443. #define Z_STOP_PIN Z_MIN_PIN
  444. #else
  445. #define Z_STOP_PIN Z_MAX_PIN
  446. #endif
  447. #endif
  448. #if LINEAR_AXES >= 4
  449. #ifdef I_STOP_PIN
  450. #if I_HOME_TO_MIN
  451. #define I_MIN_PIN I_STOP_PIN
  452. #define I_MAX_PIN -1
  453. #else
  454. #define I_MIN_PIN -1
  455. #define I_MAX_PIN I_STOP_PIN
  456. #endif
  457. #endif
  458. #else
  459. #undef I_MIN_PIN
  460. #undef I_MAX_PIN
  461. #endif
  462. #if LINEAR_AXES >= 5
  463. #ifdef J_STOP_PIN
  464. #if J_HOME_TO_MIN
  465. #define J_MIN_PIN J_STOP_PIN
  466. #define J_MAX_PIN -1
  467. #else
  468. #define J_MIN_PIN -1
  469. #define J_MAX_PIN J_STOP_PIN
  470. #endif
  471. #endif
  472. #else
  473. #undef J_MIN_PIN
  474. #undef J_MAX_PIN
  475. #endif
  476. #if LINEAR_AXES >= 6
  477. #ifdef K_STOP_PIN
  478. #if K_HOME_TO_MIN
  479. #define K_MIN_PIN K_STOP_PIN
  480. #define K_MAX_PIN -1
  481. #else
  482. #define K_MIN_PIN -1
  483. #define K_MAX_PIN K_STOP_PIN
  484. #endif
  485. #endif
  486. #else
  487. #undef K_MIN_PIN
  488. #undef K_MAX_PIN
  489. #endif
  490. // Filament Sensor first pin alias
  491. #if HAS_FILAMENT_SENSOR
  492. #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
  493. #else
  494. #undef FIL_RUNOUT_PIN
  495. #undef FIL_RUNOUT1_PIN
  496. #endif
  497. #ifndef LCD_PINS_D4
  498. #define LCD_PINS_D4 -1
  499. #endif
  500. #if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL
  501. #ifndef LCD_PINS_D5
  502. #define LCD_PINS_D5 -1
  503. #endif
  504. #ifndef LCD_PINS_D6
  505. #define LCD_PINS_D6 -1
  506. #endif
  507. #ifndef LCD_PINS_D7
  508. #define LCD_PINS_D7 -1
  509. #endif
  510. #endif
  511. /**
  512. * Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
  513. *
  514. * By default X2 is assigned to the next open E plug
  515. * on the board, then in order, Y2, Z2, Z3. These can be
  516. * overridden in Configuration.h or Configuration_adv.h.
  517. */
  518. #define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
  519. #define _PEXI(p,q) __PEXI(p,q)
  520. #define __EPIN(p,q) E##p##_##q##_PIN
  521. #define _EPIN(p,q) __EPIN(p,q)
  522. #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
  523. // The X2 axis, if any, should be the next open extruder port
  524. #define X2_E_INDEX E_STEPPERS
  525. #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
  526. #ifndef X2_STEP_PIN
  527. #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
  528. #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
  529. #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
  530. #if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP)
  531. #error "No E stepper plug left for X2!"
  532. #endif
  533. #endif
  534. #ifndef X2_MS1_PIN
  535. #define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
  536. #endif
  537. #ifndef X2_MS2_PIN
  538. #define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
  539. #endif
  540. #ifndef X2_MS3_PIN
  541. #define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
  542. #endif
  543. #if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
  544. #define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
  545. #endif
  546. #if AXIS_HAS_UART(X2)
  547. #ifndef X2_SERIAL_TX_PIN
  548. #define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
  549. #endif
  550. #ifndef X2_SERIAL_RX_PIN
  551. #define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
  552. #endif
  553. #endif
  554. //
  555. // Auto-assign pins for stallGuard sensorless homing
  556. //
  557. #if !defined(X2_USE_ENDSTOP) && defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
  558. #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
  559. #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
  560. #define X2_USE_ENDSTOP _XMIN_
  561. #elif DIAG_REMAPPED(X2, Y_MIN)
  562. #define X2_USE_ENDSTOP _YMIN_
  563. #elif DIAG_REMAPPED(X2, Z_MIN)
  564. #define X2_USE_ENDSTOP _ZMIN_
  565. #elif DIAG_REMAPPED(X2, X_MAX)
  566. #define X2_USE_ENDSTOP _XMAX_
  567. #elif DIAG_REMAPPED(X2, Y_MAX)
  568. #define X2_USE_ENDSTOP _YMAX_
  569. #elif DIAG_REMAPPED(X2, Z_MAX)
  570. #define X2_USE_ENDSTOP _ZMAX_
  571. #else // Otherwise use the driver DIAG_PIN directly
  572. #define _X2_USE_ENDSTOP(P) _E##P##_DIAG_
  573. #define X2_USE_ENDSTOP _X2_USE_ENDSTOP(X2_E_INDEX)
  574. #endif
  575. #undef X2_DIAG_PIN
  576. #endif
  577. #define Y2_E_INDEX INCREMENT(X2_E_INDEX)
  578. #else
  579. #define Y2_E_INDEX X2_E_INDEX
  580. #endif
  581. #ifndef X2_CS_PIN
  582. #define X2_CS_PIN -1
  583. #endif
  584. #ifndef X2_MS1_PIN
  585. #define X2_MS1_PIN -1
  586. #endif
  587. #ifndef X2_MS2_PIN
  588. #define X2_MS2_PIN -1
  589. #endif
  590. #ifndef X2_MS3_PIN
  591. #define X2_MS3_PIN -1
  592. #endif
  593. // The Y2 axis, if any, should be the next open extruder port
  594. #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
  595. #ifndef Y2_STEP_PIN
  596. #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
  597. #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
  598. #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
  599. #if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP)
  600. #error "No E stepper plug left for Y2!"
  601. #endif
  602. #endif
  603. #ifndef Y2_MS1_PIN
  604. #define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
  605. #endif
  606. #ifndef Y2_MS2_PIN
  607. #define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
  608. #endif
  609. #ifndef Y2_MS3_PIN
  610. #define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
  611. #endif
  612. #if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
  613. #define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
  614. #endif
  615. #if AXIS_HAS_UART(Y2)
  616. #ifndef Y2_SERIAL_TX_PIN
  617. #define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
  618. #endif
  619. #ifndef Y2_SERIAL_RX_PIN
  620. #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
  621. #endif
  622. #endif
  623. // Auto-assign pins for stallGuard sensorless homing
  624. #if !defined(Y2_USE_ENDSTOP) && defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
  625. #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
  626. #if DIAG_REMAPPED(Y2, X_MIN)
  627. #define Y2_USE_ENDSTOP _XMIN_
  628. #elif DIAG_REMAPPED(Y2, Y_MIN)
  629. #define Y2_USE_ENDSTOP _YMIN_
  630. #elif DIAG_REMAPPED(Y2, Z_MIN)
  631. #define Y2_USE_ENDSTOP _ZMIN_
  632. #elif DIAG_REMAPPED(Y2, X_MAX)
  633. #define Y2_USE_ENDSTOP _XMAX_
  634. #elif DIAG_REMAPPED(Y2, Y_MAX)
  635. #define Y2_USE_ENDSTOP _YMAX_
  636. #elif DIAG_REMAPPED(Y2, Z_MAX)
  637. #define Y2_USE_ENDSTOP _ZMAX_
  638. #else
  639. #define _Y2_USE_ENDSTOP(P) _E##P##_DIAG_
  640. #define Y2_USE_ENDSTOP _Y2_USE_ENDSTOP(Y2_E_INDEX)
  641. #endif
  642. #undef Y2_DIAG_PIN
  643. #endif
  644. #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
  645. #else
  646. #define Z2_E_INDEX Y2_E_INDEX
  647. #endif
  648. #ifndef Y2_CS_PIN
  649. #define Y2_CS_PIN -1
  650. #endif
  651. #ifndef Y2_MS1_PIN
  652. #define Y2_MS1_PIN -1
  653. #endif
  654. #ifndef Y2_MS2_PIN
  655. #define Y2_MS2_PIN -1
  656. #endif
  657. #ifndef Y2_MS3_PIN
  658. #define Y2_MS3_PIN -1
  659. #endif
  660. // The Z2 axis, if any, should be the next open extruder port
  661. #if NUM_Z_STEPPER_DRIVERS >= 2
  662. #ifndef Z2_STEP_PIN
  663. #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
  664. #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
  665. #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
  666. #if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP)
  667. #error "No E stepper plug left for Z2!"
  668. #endif
  669. #endif
  670. #ifndef Z2_MS1_PIN
  671. #define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
  672. #endif
  673. #ifndef Z2_MS2_PIN
  674. #define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
  675. #endif
  676. #ifndef Z2_MS3_PIN
  677. #define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
  678. #endif
  679. #if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
  680. #define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
  681. #endif
  682. #if AXIS_HAS_UART(Z2)
  683. #ifndef Z2_SERIAL_TX_PIN
  684. #define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
  685. #endif
  686. #ifndef Z2_SERIAL_RX_PIN
  687. #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
  688. #endif
  689. #endif
  690. // Auto-assign pins for stallGuard sensorless homing
  691. #if !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
  692. #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
  693. #if DIAG_REMAPPED(Z2, X_MIN)
  694. #define Z2_USE_ENDSTOP _XMIN_
  695. #elif DIAG_REMAPPED(Z2, Y_MIN)
  696. #define Z2_USE_ENDSTOP _YMIN_
  697. #elif DIAG_REMAPPED(Z2, Z_MIN)
  698. #define Z2_USE_ENDSTOP _ZMIN_
  699. #elif DIAG_REMAPPED(Z2, X_MAX)
  700. #define Z2_USE_ENDSTOP _XMAX_
  701. #elif DIAG_REMAPPED(Z2, Y_MAX)
  702. #define Z2_USE_ENDSTOP _YMAX_
  703. #elif DIAG_REMAPPED(Z2, Z_MAX)
  704. #define Z2_USE_ENDSTOP _ZMAX_
  705. #else
  706. #define _Z2_USE_ENDSTOP(P) _E##P##_DIAG_
  707. #define Z2_USE_ENDSTOP _Z2_USE_ENDSTOP(Z2_E_INDEX)
  708. #endif
  709. #undef Z2_DIAG_PIN
  710. #endif
  711. #define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
  712. #else
  713. #define Z3_E_INDEX Z2_E_INDEX
  714. #endif
  715. #ifndef Z2_CS_PIN
  716. #define Z2_CS_PIN -1
  717. #endif
  718. #ifndef Z2_MS1_PIN
  719. #define Z2_MS1_PIN -1
  720. #endif
  721. #ifndef Z2_MS2_PIN
  722. #define Z2_MS2_PIN -1
  723. #endif
  724. #ifndef Z2_MS3_PIN
  725. #define Z2_MS3_PIN -1
  726. #endif
  727. #if NUM_Z_STEPPER_DRIVERS >= 3
  728. #ifndef Z3_STEP_PIN
  729. #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
  730. #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
  731. #define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
  732. #if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP)
  733. #error "No E stepper plug left for Z3!"
  734. #endif
  735. #endif
  736. #if AXIS_HAS_SPI(Z3)
  737. #ifndef Z3_CS_PIN
  738. #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
  739. #endif
  740. #endif
  741. #ifndef Z3_MS1_PIN
  742. #define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
  743. #endif
  744. #ifndef Z3_MS2_PIN
  745. #define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
  746. #endif
  747. #ifndef Z3_MS3_PIN
  748. #define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
  749. #endif
  750. #if AXIS_HAS_UART(Z3)
  751. #ifndef Z3_SERIAL_TX_PIN
  752. #define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
  753. #endif
  754. #ifndef Z3_SERIAL_RX_PIN
  755. #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
  756. #endif
  757. #endif
  758. // Auto-assign pins for stallGuard sensorless homing
  759. #if !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
  760. #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
  761. #if DIAG_REMAPPED(Z3, X_MIN)
  762. #define Z3_USE_ENDSTOP _XMIN_
  763. #elif DIAG_REMAPPED(Z3, Y_MIN)
  764. #define Z3_USE_ENDSTOP _YMIN_
  765. #elif DIAG_REMAPPED(Z3, Z_MIN)
  766. #define Z3_USE_ENDSTOP _ZMIN_
  767. #elif DIAG_REMAPPED(Z3, X_MAX)
  768. #define Z3_USE_ENDSTOP _XMAX_
  769. #elif DIAG_REMAPPED(Z3, Y_MAX)
  770. #define Z3_USE_ENDSTOP _YMAX_
  771. #elif DIAG_REMAPPED(Z3, Z_MAX)
  772. #define Z3_USE_ENDSTOP _ZMAX_
  773. #else
  774. #define _Z3_USE_ENDSTOP(P) _E##P##_DIAG_
  775. #define Z3_USE_ENDSTOP _Z3_USE_ENDSTOP(Z3_E_INDEX)
  776. #endif
  777. #undef Z3_DIAG_PIN
  778. #endif
  779. #define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
  780. #else
  781. #define Z4_E_INDEX Z3_E_INDEX
  782. #endif
  783. #ifndef Z3_CS_PIN
  784. #define Z3_CS_PIN -1
  785. #endif
  786. #ifndef Z3_MS1_PIN
  787. #define Z3_MS1_PIN -1
  788. #endif
  789. #ifndef Z3_MS2_PIN
  790. #define Z3_MS2_PIN -1
  791. #endif
  792. #ifndef Z3_MS3_PIN
  793. #define Z3_MS3_PIN -1
  794. #endif
  795. #if NUM_Z_STEPPER_DRIVERS >= 4
  796. #ifndef Z4_STEP_PIN
  797. #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
  798. #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
  799. #define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
  800. #if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP)
  801. #error "No E stepper plug left for Z4!"
  802. #endif
  803. #endif
  804. #if AXIS_HAS_SPI(Z4)
  805. #ifndef Z4_CS_PIN
  806. #define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
  807. #endif
  808. #endif
  809. #ifndef Z4_MS1_PIN
  810. #define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
  811. #endif
  812. #ifndef Z4_MS2_PIN
  813. #define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
  814. #endif
  815. #ifndef Z4_MS3_PIN
  816. #define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
  817. #endif
  818. #if AXIS_HAS_UART(Z4)
  819. #ifndef Z4_SERIAL_TX_PIN
  820. #define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
  821. #endif
  822. #ifndef Z4_SERIAL_RX_PIN
  823. #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
  824. #endif
  825. #endif
  826. // Auto-assign pins for stallGuard sensorless homing
  827. #if !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
  828. #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
  829. #if DIAG_REMAPPED(Z4, X_MIN)
  830. #define Z4_USE_ENDSTOP _XMIN_
  831. #elif DIAG_REMAPPED(Z4, Y_MIN)
  832. #define Z4_USE_ENDSTOP _YMIN_
  833. #elif DIAG_REMAPPED(Z4, Z_MIN)
  834. #define Z4_USE_ENDSTOP _ZMIN_
  835. #elif DIAG_REMAPPED(Z4, X_MAX)
  836. #define Z4_USE_ENDSTOP _XMAX_
  837. #elif DIAG_REMAPPED(Z4, Y_MAX)
  838. #define Z4_USE_ENDSTOP _YMAX_
  839. #elif DIAG_REMAPPED(Z4, Z_MAX)
  840. #define Z4_USE_ENDSTOP _ZMAX_
  841. #else
  842. #define _Z4_USE_ENDSTOP(P) _E##P##_DIAG_
  843. #define Z4_USE_ENDSTOP _Z4_USE_ENDSTOP(Z4_E_INDEX)
  844. #endif
  845. #undef Z4_DIAG_PIN
  846. #endif
  847. #define I_E_INDEX INCREMENT(Z4_E_INDEX)
  848. #else
  849. #define I_E_INDEX Z4_E_INDEX
  850. #endif
  851. #ifndef Z4_CS_PIN
  852. #define Z4_CS_PIN -1
  853. #endif
  854. #ifndef Z4_MS1_PIN
  855. #define Z4_MS1_PIN -1
  856. #endif
  857. #ifndef Z4_MS2_PIN
  858. #define Z4_MS2_PIN -1
  859. #endif
  860. #ifndef Z4_MS3_PIN
  861. #define Z4_MS3_PIN -1
  862. #endif
  863. #if LINEAR_AXES >= 4
  864. #ifndef I_STEP_PIN
  865. #define I_STEP_PIN _EPIN(I_E_INDEX, STEP)
  866. #define I_DIR_PIN _EPIN(I_E_INDEX, DIR)
  867. #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE)
  868. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP)
  869. #error "No E stepper plug left for I!"
  870. #endif
  871. #endif
  872. #if AXIS_HAS_SPI(I)
  873. #ifndef I_CS_PIN
  874. #define I_CS_PIN _EPIN(I_E_INDEX, CS)
  875. #endif
  876. #endif
  877. #ifndef I_MS1_PIN
  878. #define I_MS1_PIN _EPIN(I_E_INDEX, MS1)
  879. #endif
  880. #ifndef I_MS2_PIN
  881. #define I_MS2_PIN _EPIN(I_E_INDEX, MS2)
  882. #endif
  883. #ifndef I_MS3_PIN
  884. #define I_MS3_PIN _EPIN(I_E_INDEX, MS3)
  885. #endif
  886. #if AXIS_HAS_UART(I)
  887. #ifndef I_SERIAL_TX_PIN
  888. #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX)
  889. #endif
  890. #ifndef I_SERIAL_RX_PIN
  891. #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX)
  892. #endif
  893. #endif
  894. // Auto-assign pins for stallGuard sensorless homing
  895. #if !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)
  896. #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG)
  897. #if DIAG_REMAPPED(I, X_MIN)
  898. #define I_USE_ENDSTOP _XMIN_
  899. #elif DIAG_REMAPPED(I, Y_MIN)
  900. #define I_USE_ENDSTOP _YMIN_
  901. #elif DIAG_REMAPPED(I, Z_MIN)
  902. #define I_USE_ENDSTOP _ZMIN_
  903. #elif DIAG_REMAPPED(I, X_MAX)
  904. #define I_USE_ENDSTOP _XMAX_
  905. #elif DIAG_REMAPPED(I, Y_MAX)
  906. #define I_USE_ENDSTOP _YMAX_
  907. #elif DIAG_REMAPPED(I, Z_MAX)
  908. #define I_USE_ENDSTOP _ZMAX_
  909. #else
  910. #define _I_USE_ENDSTOP(P) _E##P##_DIAG_
  911. #define I_USE_ENDSTOP _I_USE_ENDSTOP(I_E_INDEX)
  912. #endif
  913. #undef I_DIAG_PIN
  914. #endif
  915. #define J_E_INDEX INCREMENT(I_E_INDEX)
  916. #else
  917. #define J_E_INDEX I_E_INDEX
  918. #endif
  919. #ifndef I_CS_PIN
  920. #define I_CS_PIN -1
  921. #endif
  922. #ifndef I_MS1_PIN
  923. #define I_MS1_PIN -1
  924. #endif
  925. #ifndef I_MS2_PIN
  926. #define I_MS2_PIN -1
  927. #endif
  928. #ifndef I_MS3_PIN
  929. #define I_MS3_PIN -1
  930. #endif
  931. #if LINEAR_AXES >= 5
  932. #ifndef J_STEP_PIN
  933. #define J_STEP_PIN _EPIN(J_E_INDEX, STEP)
  934. #define J_DIR_PIN _EPIN(J_E_INDEX, DIR)
  935. #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE)
  936. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP)
  937. #error "No E stepper plug left for J!"
  938. #endif
  939. #endif
  940. #if AXIS_HAS_SPI(J)
  941. #ifndef J_CS_PIN
  942. #define J_CS_PIN _EPIN(J_E_INDEX, CS)
  943. #endif
  944. #endif
  945. #ifndef J_MS1_PIN
  946. #define J_MS1_PIN _EPIN(J_E_INDEX, MS1)
  947. #endif
  948. #ifndef J_MS2_PIN
  949. #define J_MS2_PIN _EPIN(J_E_INDEX, MS2)
  950. #endif
  951. #ifndef J_MS3_PIN
  952. #define J_MS3_PIN _EPIN(J_E_INDEX, MS3)
  953. #endif
  954. #if AXIS_HAS_UART(J)
  955. #ifndef J_SERIAL_TX_PIN
  956. #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX)
  957. #endif
  958. #ifndef J_SERIAL_RX_PIN
  959. #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX)
  960. #endif
  961. #endif
  962. // Auto-assign pins for stallGuard sensorless homing
  963. #if !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)
  964. #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG)
  965. #if DIAG_REMAPPED(J, X_MIN)
  966. #define J_USE_ENDSTOP _XMIN_
  967. #elif DIAG_REMAPPED(J, Y_MIN)
  968. #define J_USE_ENDSTOP _YMIN_
  969. #elif DIAG_REMAPPED(J, Z_MIN)
  970. #define J_USE_ENDSTOP _ZMIN_
  971. #elif DIAG_REMAPPED(J, X_MAX)
  972. #define J_USE_ENDSTOP _XMAX_
  973. #elif DIAG_REMAPPED(J, Y_MAX)
  974. #define J_USE_ENDSTOP _YMAX_
  975. #elif DIAG_REMAPPED(I, Z_MAX)
  976. #define J_USE_ENDSTOP _ZMAX_
  977. #else
  978. #define _J_USE_ENDSTOP(P) _E##P##_DIAG_
  979. #define J_USE_ENDSTOP _J_USE_ENDSTOP(J_E_INDEX)
  980. #endif
  981. #undef J_DIAG_PIN
  982. #endif
  983. #define K_E_INDEX INCREMENT(J_E_INDEX)
  984. #else
  985. #define K_E_INDEX J_E_INDEX
  986. #endif
  987. #ifndef J_CS_PIN
  988. #define J_CS_PIN -1
  989. #endif
  990. #ifndef J_MS1_PIN
  991. #define J_MS1_PIN -1
  992. #endif
  993. #ifndef J_MS2_PIN
  994. #define J_MS2_PIN -1
  995. #endif
  996. #ifndef J_MS3_PIN
  997. #define J_MS3_PIN -1
  998. #endif
  999. #if LINEAR_AXES >= 6
  1000. #ifndef K_STEP_PIN
  1001. #define K_STEP_PIN _EPIN(K_E_INDEX, STEP)
  1002. #define K_DIR_PIN _EPIN(K_E_INDEX, DIR)
  1003. #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE)
  1004. #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP)
  1005. #error "No E stepper plug left for K!"
  1006. #endif
  1007. #endif
  1008. #if AXIS_HAS_SPI(K)
  1009. #ifndef K_CS_PIN
  1010. #define K_CS_PIN _EPIN(K_E_INDEX, CS)
  1011. #endif
  1012. #endif
  1013. #ifndef K_MS1_PIN
  1014. #define K_MS1_PIN _EPIN(K_E_INDEX, MS1)
  1015. #endif
  1016. #ifndef K_MS2_PIN
  1017. #define K_MS2_PIN _EPIN(K_E_INDEX, MS2)
  1018. #endif
  1019. #ifndef K_MS3_PIN
  1020. #define K_MS3_PIN _EPIN(K_E_INDEX, MS3)
  1021. #endif
  1022. #if AXIS_HAS_UART(K)
  1023. #ifndef K_SERIAL_TX_PIN
  1024. #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX)
  1025. #endif
  1026. #ifndef K_SERIAL_RX_PIN
  1027. #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX)
  1028. #endif
  1029. #endif
  1030. // Auto-assign pins for stallGuard sensorless homing
  1031. #if !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)
  1032. #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG)
  1033. #if DIAG_REMAPPED(K, X_MIN)
  1034. #define K_USE_ENDSTOP _XMIN_
  1035. #elif DIAG_REMAPPED(K, Y_MIN)
  1036. #define K_USE_ENDSTOP _YMIN_
  1037. #elif DIAG_REMAPPED(K, Z_MIN)
  1038. #define K_USE_ENDSTOP _ZMIN_
  1039. #elif DIAG_REMAPPED(K, X_MAX)
  1040. #define K_USE_ENDSTOP _XMAX_
  1041. #elif DIAG_REMAPPED(K, Y_MAX)
  1042. #define K_USE_ENDSTOP _YMAX_
  1043. #elif DIAG_REMAPPED(K, Z_MAX)
  1044. #define K_USE_ENDSTOP _ZMAX_
  1045. #else
  1046. #define _K_USE_ENDSTOP(P) _E##P##_DIAG_
  1047. #define K_USE_ENDSTOP _K_USE_ENDSTOP(K_E_INDEX)
  1048. #endif
  1049. #undef K_DIAG_PIN
  1050. #endif
  1051. #endif
  1052. #ifndef K_CS_PIN
  1053. #define K_CS_PIN -1
  1054. #endif
  1055. #ifndef K_MS1_PIN
  1056. #define K_MS1_PIN -1
  1057. #endif
  1058. #ifndef K_MS2_PIN
  1059. #define K_MS2_PIN -1
  1060. #endif
  1061. #ifndef K_MS3_PIN
  1062. #define K_MS3_PIN -1
  1063. #endif
  1064. //
  1065. // Disable unused endstop / probe pins
  1066. //
  1067. #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)
  1068. #if _STOP_IN_USE(_XMAX_)
  1069. #define USE_XMAX_PLUG
  1070. #endif
  1071. #if _STOP_IN_USE(_YMAX_)
  1072. #define USE_YMAX_PLUG
  1073. #endif
  1074. #if _STOP_IN_USE(_ZMAX_)
  1075. #define USE_ZMAX_PLUG
  1076. #endif
  1077. #if _STOP_IN_USE(_XMIN_)
  1078. #define USE_XMIN_PLUG
  1079. #endif
  1080. #if _STOP_IN_USE(_YMIN_)
  1081. #define USE_YMIN_PLUG
  1082. #endif
  1083. #if _STOP_IN_USE(_ZMIN_)
  1084. #define USE_ZMIN_PLUG
  1085. #endif
  1086. #undef _STOP_IN_USE
  1087. #if !HAS_CUSTOM_PROBE_PIN
  1088. #undef Z_MIN_PROBE_PIN
  1089. #define Z_MIN_PROBE_PIN -1
  1090. #endif
  1091. #if DISABLED(USE_XMIN_PLUG)
  1092. #undef X_MIN_PIN
  1093. #define X_MIN_PIN -1
  1094. #endif
  1095. #if DISABLED(USE_XMAX_PLUG)
  1096. #undef X_MAX_PIN
  1097. #define X_MAX_PIN -1
  1098. #endif
  1099. #if DISABLED(USE_YMIN_PLUG)
  1100. #undef Y_MIN_PIN
  1101. #define Y_MIN_PIN -1
  1102. #endif
  1103. #if DISABLED(USE_YMAX_PLUG)
  1104. #undef Y_MAX_PIN
  1105. #define Y_MAX_PIN -1
  1106. #endif
  1107. #if DISABLED(USE_ZMIN_PLUG)
  1108. #undef Z_MIN_PIN
  1109. #define Z_MIN_PIN -1
  1110. #endif
  1111. #if DISABLED(USE_ZMAX_PLUG)
  1112. #undef Z_MAX_PIN
  1113. #define Z_MAX_PIN -1
  1114. #endif
  1115. #if DISABLED(USE_IMIN_PLUG)
  1116. #undef I_MIN_PIN
  1117. #define I_MIN_PIN -1
  1118. #endif
  1119. #if DISABLED(USE_IMAX_PLUG)
  1120. #undef I_MAX_PIN
  1121. #define I_MAX_PIN -1
  1122. #endif
  1123. #if DISABLED(USE_JMIN_PLUG)
  1124. #undef J_MIN_PIN
  1125. #define J_MIN_PIN -1
  1126. #endif
  1127. #if DISABLED(USE_JMAX_PLUG)
  1128. #undef J_MAX_PIN
  1129. #define J_MAX_PIN -1
  1130. #endif
  1131. #if DISABLED(USE_KMIN_PLUG)
  1132. #undef K_MIN_PIN
  1133. #define K_MIN_PIN -1
  1134. #endif
  1135. #if DISABLED(USE_KMAX_PLUG)
  1136. #undef K_MAX_PIN
  1137. #define K_MAX_PIN -1
  1138. #endif
  1139. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX
  1140. #undef X2_MIN_PIN
  1141. #endif
  1142. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MIN
  1143. #undef X2_MAX_PIN
  1144. #endif
  1145. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MAX
  1146. #undef Y2_MIN_PIN
  1147. #endif
  1148. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MIN
  1149. #undef Y2_MAX_PIN
  1150. #endif
  1151. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MAX
  1152. #undef Z2_MIN_PIN
  1153. #endif
  1154. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN
  1155. #undef Z2_MAX_PIN
  1156. #endif
  1157. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MAX
  1158. #undef Z3_MIN_PIN
  1159. #endif
  1160. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MIN
  1161. #undef Z3_MAX_PIN
  1162. #endif
  1163. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MAX
  1164. #undef Z4_MIN_PIN
  1165. #endif
  1166. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MIN
  1167. #undef Z4_MAX_PIN
  1168. #endif
  1169. //
  1170. // Default DOGLCD SPI delays
  1171. //
  1172. #if HAS_MARLINUI_U8GLIB
  1173. #if !defined(ST7920_DELAY_1) && defined(BOARD_ST7920_DELAY_1)
  1174. #define ST7920_DELAY_1 BOARD_ST7920_DELAY_1
  1175. #endif
  1176. #if !defined(ST7920_DELAY_2) && defined(BOARD_ST7920_DELAY_2)
  1177. #define ST7920_DELAY_2 BOARD_ST7920_DELAY_2
  1178. #endif
  1179. #if !defined(ST7920_DELAY_3) && defined(BOARD_ST7920_DELAY_3)
  1180. #define ST7920_DELAY_3 BOARD_ST7920_DELAY_3
  1181. #endif
  1182. #else
  1183. #undef ST7920_DELAY_1
  1184. #undef ST7920_DELAY_2
  1185. #undef ST7920_DELAY_3
  1186. #undef BOARD_ST7920_DELAY_1
  1187. #undef BOARD_ST7920_DELAY_2
  1188. #undef BOARD_ST7920_DELAY_3
  1189. #endif
  1190. #if !NEED_CASE_LIGHT_PIN
  1191. #undef CASE_LIGHT_PIN
  1192. #endif
  1193. #undef HAS_FREE_AUX2_PINS
  1194. #undef DIAG_REMAPPED