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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389
  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_STATE
  385. #define SUICIDE_PIN_STATE LOW
  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. #ifndef I_MAX_PIN
  453. #define I_MAX_PIN -1
  454. #endif
  455. #else
  456. #define I_MAX_PIN I_STOP_PIN
  457. #ifndef I_MIN_PIN
  458. #define I_MIN_PIN -1
  459. #endif
  460. #endif
  461. #elif I_HOME_TO_MIN
  462. #define I_STOP_PIN I_MIN_PIN
  463. #else
  464. #define I_STOP_PIN I_MAX_PIN
  465. #endif
  466. #else
  467. #undef I_MIN_PIN
  468. #undef I_MAX_PIN
  469. #endif
  470. #if LINEAR_AXES >= 5
  471. #ifdef J_STOP_PIN
  472. #if J_HOME_TO_MIN
  473. #define J_MIN_PIN J_STOP_PIN
  474. #ifndef J_MAX_PIN
  475. #define J_MAX_PIN -1
  476. #endif
  477. #else
  478. #define J_MAX_PIN J_STOP_PIN
  479. #ifndef J_MIN_PIN
  480. #define J_MIN_PIN -1
  481. #endif
  482. #endif
  483. #elif J_HOME_TO_MIN
  484. #define J_STOP_PIN J_MIN_PIN
  485. #else
  486. #define J_STOP_PIN J_MAX_PIN
  487. #endif
  488. #else
  489. #undef J_MIN_PIN
  490. #undef J_MAX_PIN
  491. #endif
  492. #if LINEAR_AXES >= 6
  493. #ifdef K_STOP_PIN
  494. #if K_HOME_TO_MIN
  495. #define K_MIN_PIN K_STOP_PIN
  496. #ifndef K_MAX_PIN
  497. #define K_MAX_PIN -1
  498. #endif
  499. #else
  500. #define K_MAX_PIN K_STOP_PIN
  501. #ifndef K_MIN_PIN
  502. #define K_MIN_PIN -1
  503. #endif
  504. #endif
  505. #elif K_HOME_TO_MIN
  506. #define K_STOP_PIN K_MIN_PIN
  507. #else
  508. #define K_STOP_PIN K_MAX_PIN
  509. #endif
  510. #else
  511. #undef K_MIN_PIN
  512. #undef K_MAX_PIN
  513. #endif
  514. // Filament Sensor first pin alias
  515. #if HAS_FILAMENT_SENSOR
  516. #define FIL_RUNOUT1_PIN FIL_RUNOUT_PIN
  517. #else
  518. #undef FIL_RUNOUT_PIN
  519. #undef FIL_RUNOUT1_PIN
  520. #endif
  521. #ifndef LCD_PINS_D4
  522. #define LCD_PINS_D4 -1
  523. #endif
  524. #if HAS_MARLINUI_HD44780 || TOUCH_UI_ULTIPANEL
  525. #ifndef LCD_PINS_D5
  526. #define LCD_PINS_D5 -1
  527. #endif
  528. #ifndef LCD_PINS_D6
  529. #define LCD_PINS_D6 -1
  530. #endif
  531. #ifndef LCD_PINS_D7
  532. #define LCD_PINS_D7 -1
  533. #endif
  534. #endif
  535. /**
  536. * Auto-Assignment for Dual X, Dual Y, Multi-Z Steppers
  537. *
  538. * By default X2 is assigned to the next open E plug
  539. * on the board, then in order, Y2, Z2, Z3. These can be
  540. * overridden in Configuration.h or Configuration_adv.h.
  541. */
  542. #define __PEXI(p,q) PIN_EXISTS(E##p##_##q)
  543. #define _PEXI(p,q) __PEXI(p,q)
  544. #define __EPIN(p,q) E##p##_##q##_PIN
  545. #define _EPIN(p,q) __EPIN(p,q)
  546. #define DIAG_REMAPPED(p,q) (PIN_EXISTS(q) && _EPIN(p##_E_INDEX, DIAG) == q##_PIN)
  547. #define _En_DIAG_(p) _E##p##_DIAG_
  548. // The E0/E1 steppers are always used for Dual E
  549. #if ENABLED(E_DUAL_STEPPER_DRIVERS)
  550. #ifndef E1_STEP_PIN
  551. #error "No E1 stepper available for E_DUAL_STEPPER_DRIVERS!"
  552. #endif
  553. #define X2_E_INDEX INCREMENT(E_STEPPERS)
  554. #else
  555. #define X2_E_INDEX E_STEPPERS
  556. #endif
  557. // The X2 axis, if any, should be the next open extruder port
  558. #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS) && !defined(X2_DIAG_PIN) && !defined(X2_STEP_PIN) && !PIN_EXISTS(X2_CS_PIN)
  559. #define Y2_E_INDEX INCREMENT(X2_E_INDEX)
  560. #else
  561. #define Y2_E_INDEX X2_E_INDEX
  562. #endif
  563. #if EITHER(DUAL_X_CARRIAGE, X_DUAL_STEPPER_DRIVERS)
  564. #ifndef X2_STEP_PIN
  565. #define X2_STEP_PIN _EPIN(X2_E_INDEX, STEP)
  566. #define X2_DIR_PIN _EPIN(X2_E_INDEX, DIR)
  567. #define X2_ENABLE_PIN _EPIN(X2_E_INDEX, ENABLE)
  568. #if X2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(X2_STEP)
  569. #error "No E stepper plug left for X2!"
  570. #else
  571. #define AUTO_ASSIGNED_X2_STEPPER 1
  572. #endif
  573. #endif
  574. #ifndef X2_MS1_PIN
  575. #define X2_MS1_PIN _EPIN(X2_E_INDEX, MS1)
  576. #if PIN_EXISTS(X2_MS1)
  577. #define AUTO_ASSIGNED_X2_MS1 1
  578. #endif
  579. #endif
  580. #ifndef X2_MS2_PIN
  581. #define X2_MS2_PIN _EPIN(X2_E_INDEX, MS2)
  582. #if PIN_EXISTS(X2_MS2)
  583. #define AUTO_ASSIGNED_X2_MS2 1
  584. #endif
  585. #endif
  586. #ifndef X2_MS3_PIN
  587. #define X2_MS3_PIN _EPIN(X2_E_INDEX, MS3)
  588. #if PIN_EXISTS(X2_MS3)
  589. #define AUTO_ASSIGNED_X2_MS3 1
  590. #endif
  591. #endif
  592. #if AXIS_HAS_SPI(X2) && !defined(X2_CS_PIN)
  593. #define X2_CS_PIN _EPIN(X2_E_INDEX, CS)
  594. #if PIN_EXISTS(X2_CS)
  595. #define AUTO_ASSIGNED_X2_CS 1
  596. #endif
  597. #endif
  598. #if AXIS_HAS_UART(X2)
  599. #ifndef X2_SERIAL_TX_PIN
  600. #define X2_SERIAL_TX_PIN _EPIN(X2_E_INDEX, SERIAL_TX)
  601. #endif
  602. #ifndef X2_SERIAL_RX_PIN
  603. #define X2_SERIAL_RX_PIN _EPIN(X2_E_INDEX, SERIAL_RX)
  604. #endif
  605. #endif
  606. //
  607. // Auto-assign pins for stallGuard sensorless homing
  608. //
  609. #if !defined(X2_DIAG_PIN) && !defined(X2_USE_ENDSTOP) && defined(X2_STALL_SENSITIVITY) && ENABLED(X_DUAL_ENDSTOPS) && _PEXI(X2_E_INDEX, DIAG)
  610. #define X2_DIAG_PIN _EPIN(X2_E_INDEX, DIAG)
  611. #if DIAG_REMAPPED(X2, X_MIN) // If already remapped in the pins file...
  612. #define X2_USE_ENDSTOP _XMIN_
  613. #elif DIAG_REMAPPED(X2, Y_MIN)
  614. #define X2_USE_ENDSTOP _YMIN_
  615. #elif DIAG_REMAPPED(X2, Z_MIN)
  616. #define X2_USE_ENDSTOP _ZMIN_
  617. #elif DIAG_REMAPPED(X2, X_MAX)
  618. #define X2_USE_ENDSTOP _XMAX_
  619. #elif DIAG_REMAPPED(X2, Y_MAX)
  620. #define X2_USE_ENDSTOP _YMAX_
  621. #elif DIAG_REMAPPED(X2, Z_MAX)
  622. #define X2_USE_ENDSTOP _ZMAX_
  623. #else // Otherwise pick the next free En_DIAG_PIN directly
  624. #define X2_USE_ENDSTOP _En_DIAG_(X2_E_INDEX)
  625. #endif
  626. #define AUTO_ASSIGNED_X2_DIAG 1
  627. #undef X2_DIAG_PIN // Defined in Conditionals_post.h based on X2_USE_ENDSTOP
  628. #endif
  629. #endif
  630. #ifndef X2_CS_PIN
  631. #define X2_CS_PIN -1
  632. #endif
  633. #ifndef X2_MS1_PIN
  634. #define X2_MS1_PIN -1
  635. #endif
  636. #ifndef X2_MS2_PIN
  637. #define X2_MS2_PIN -1
  638. #endif
  639. #ifndef X2_MS3_PIN
  640. #define X2_MS3_PIN -1
  641. #endif
  642. // The Y2 axis, if any, should be the next open extruder port
  643. #if ENABLED(Y_DUAL_STEPPER_DRIVERS) && !defined(Y2_DIAG_PIN) && !defined(Y2_STEP_PIN) && !PIN_EXISTS(Y2_CS_PIN)
  644. #define Z2_E_INDEX INCREMENT(Y2_E_INDEX)
  645. #else
  646. #define Z2_E_INDEX Y2_E_INDEX
  647. #endif
  648. #if ENABLED(Y_DUAL_STEPPER_DRIVERS)
  649. #ifndef Y2_STEP_PIN
  650. #define Y2_STEP_PIN _EPIN(Y2_E_INDEX, STEP)
  651. #define Y2_DIR_PIN _EPIN(Y2_E_INDEX, DIR)
  652. #define Y2_ENABLE_PIN _EPIN(Y2_E_INDEX, ENABLE)
  653. #if Y2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Y2_STEP)
  654. #error "No E stepper plug left for Y2!"
  655. #else
  656. #define AUTO_ASSIGNED_Y2_STEPPER 1
  657. #endif
  658. #endif
  659. #ifndef Y2_MS1_PIN
  660. #define Y2_MS1_PIN _EPIN(Y2_E_INDEX, MS1)
  661. #if PIN_EXISTS(Y2_MS1)
  662. #define AUTO_ASSIGNED_Y2_MS1 1
  663. #endif
  664. #endif
  665. #ifndef Y2_MS2_PIN
  666. #define Y2_MS2_PIN _EPIN(Y2_E_INDEX, MS2)
  667. #if PIN_EXISTS(Y2_MS2)
  668. #define AUTO_ASSIGNED_Y2_MS2 1
  669. #endif
  670. #endif
  671. #ifndef Y2_MS3_PIN
  672. #define Y2_MS3_PIN _EPIN(Y2_E_INDEX, MS3)
  673. #if PIN_EXISTS(Y2_MS3)
  674. #define AUTO_ASSIGNED_Y2_MS3 1
  675. #endif
  676. #endif
  677. #if AXIS_HAS_SPI(Y2) && !defined(Y2_CS_PIN)
  678. #define Y2_CS_PIN _EPIN(Y2_E_INDEX, CS)
  679. #if PIN_EXISTS(Y2_CS)
  680. #define AUTO_ASSIGNED_Y2_CS 1
  681. #endif
  682. #endif
  683. #if AXIS_HAS_UART(Y2)
  684. #ifndef Y2_SERIAL_TX_PIN
  685. #define Y2_SERIAL_TX_PIN _EPIN(Y2_E_INDEX, SERIAL_TX)
  686. #endif
  687. #ifndef Y2_SERIAL_RX_PIN
  688. #define Y2_SERIAL_RX_PIN _EPIN(Y2_E_INDEX, SERIAL_RX)
  689. #endif
  690. #endif
  691. // Auto-assign pins for stallGuard sensorless homing
  692. #if !defined(Y2_DIAG_PIN) && !defined(Y2_USE_ENDSTOP) && defined(Y2_STALL_SENSITIVITY) && ENABLED(Y_DUAL_ENDSTOPS) && _PEXI(Y2_E_INDEX, DIAG)
  693. #define Y2_DIAG_PIN _EPIN(Y2_E_INDEX, DIAG)
  694. #if DIAG_REMAPPED(Y2, X_MIN)
  695. #define Y2_USE_ENDSTOP _XMIN_
  696. #elif DIAG_REMAPPED(Y2, Y_MIN)
  697. #define Y2_USE_ENDSTOP _YMIN_
  698. #elif DIAG_REMAPPED(Y2, Z_MIN)
  699. #define Y2_USE_ENDSTOP _ZMIN_
  700. #elif DIAG_REMAPPED(Y2, X_MAX)
  701. #define Y2_USE_ENDSTOP _XMAX_
  702. #elif DIAG_REMAPPED(Y2, Y_MAX)
  703. #define Y2_USE_ENDSTOP _YMAX_
  704. #elif DIAG_REMAPPED(Y2, Z_MAX)
  705. #define Y2_USE_ENDSTOP _ZMAX_
  706. #else
  707. #define Y2_USE_ENDSTOP _En_DIAG_(Y2_E_INDEX)
  708. #endif
  709. #define AUTO_ASSIGNED_Y2_DIAG 1
  710. #undef Y2_DIAG_PIN // Defined in Conditionals_post.h based on Y2_USE_ENDSTOP
  711. #endif
  712. #endif
  713. #ifndef Y2_CS_PIN
  714. #define Y2_CS_PIN -1
  715. #endif
  716. #ifndef Y2_MS1_PIN
  717. #define Y2_MS1_PIN -1
  718. #endif
  719. #ifndef Y2_MS2_PIN
  720. #define Y2_MS2_PIN -1
  721. #endif
  722. #ifndef Y2_MS3_PIN
  723. #define Y2_MS3_PIN -1
  724. #endif
  725. // The Z2 axis, if any, should be the next open extruder port
  726. #if NUM_Z_STEPPER_DRIVERS >= 2 && !defined(Z2_DIAG_PIN) && !defined(Z2_STEP_PIN) && !PIN_EXISTS(Z2_CS_PIN)
  727. #define Z3_E_INDEX INCREMENT(Z2_E_INDEX)
  728. #else
  729. #define Z3_E_INDEX Z2_E_INDEX
  730. #endif
  731. #if NUM_Z_STEPPER_DRIVERS >= 2
  732. #ifndef Z2_STEP_PIN
  733. #define Z2_STEP_PIN _EPIN(Z2_E_INDEX, STEP)
  734. #define Z2_DIR_PIN _EPIN(Z2_E_INDEX, DIR)
  735. #define Z2_ENABLE_PIN _EPIN(Z2_E_INDEX, ENABLE)
  736. #if Z2_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z2_STEP)
  737. #error "No E stepper plug left for Z2!"
  738. #else
  739. #define AUTO_ASSIGNED_Z2_STEPPER 1
  740. #endif
  741. #endif
  742. #ifndef Z2_MS1_PIN
  743. #define Z2_MS1_PIN _EPIN(Z2_E_INDEX, MS1)
  744. #if PIN_EXISTS(Z2_MS1)
  745. #define AUTO_ASSIGNED_Z2_MS1 1
  746. #endif
  747. #endif
  748. #ifndef Z2_MS2_PIN
  749. #define Z2_MS2_PIN _EPIN(Z2_E_INDEX, MS2)
  750. #if PIN_EXISTS(Z2_MS2)
  751. #define AUTO_ASSIGNED_Z2_MS2 1
  752. #endif
  753. #endif
  754. #ifndef Z2_MS3_PIN
  755. #define Z2_MS3_PIN _EPIN(Z2_E_INDEX, MS3)
  756. #if PIN_EXISTS(Z2_MS3)
  757. #define AUTO_ASSIGNED_Z2_MS3 1
  758. #endif
  759. #endif
  760. #if AXIS_HAS_SPI(Z2) && !defined(Z2_CS_PIN)
  761. #define Z2_CS_PIN _EPIN(Z2_E_INDEX, CS)
  762. #if PIN_EXISTS(Z2_CS)
  763. #define AUTO_ASSIGNED_Z2_CS 1
  764. #endif
  765. #endif
  766. #if AXIS_HAS_UART(Z2)
  767. #ifndef Z2_SERIAL_TX_PIN
  768. #define Z2_SERIAL_TX_PIN _EPIN(Z2_E_INDEX, SERIAL_TX)
  769. #endif
  770. #ifndef Z2_SERIAL_RX_PIN
  771. #define Z2_SERIAL_RX_PIN _EPIN(Z2_E_INDEX, SERIAL_RX)
  772. #endif
  773. #endif
  774. // Auto-assign pins for stallGuard sensorless homing
  775. #if !defined(Z2_DIAG_PIN) && !defined(Z2_USE_ENDSTOP) && defined(Z2_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 2 && _PEXI(Z2_E_INDEX, DIAG)
  776. #define Z2_DIAG_PIN _EPIN(Z2_E_INDEX, DIAG)
  777. #if DIAG_REMAPPED(Z2, X_MIN)
  778. #define Z2_USE_ENDSTOP _XMIN_
  779. #elif DIAG_REMAPPED(Z2, Y_MIN)
  780. #define Z2_USE_ENDSTOP _YMIN_
  781. #elif DIAG_REMAPPED(Z2, Z_MIN)
  782. #define Z2_USE_ENDSTOP _ZMIN_
  783. #elif DIAG_REMAPPED(Z2, X_MAX)
  784. #define Z2_USE_ENDSTOP _XMAX_
  785. #elif DIAG_REMAPPED(Z2, Y_MAX)
  786. #define Z2_USE_ENDSTOP _YMAX_
  787. #elif DIAG_REMAPPED(Z2, Z_MAX)
  788. #define Z2_USE_ENDSTOP _ZMAX_
  789. #else
  790. #define Z2_USE_ENDSTOP _En_DIAG_(Z2_E_INDEX)
  791. #endif
  792. #define AUTO_ASSIGNED_Z2_DIAG 1
  793. #undef Z2_DIAG_PIN // Defined in Conditionals_post.h based on Z2_USE_ENDSTOP
  794. #endif
  795. #endif
  796. #ifndef Z2_CS_PIN
  797. #define Z2_CS_PIN -1
  798. #endif
  799. #ifndef Z2_MS1_PIN
  800. #define Z2_MS1_PIN -1
  801. #endif
  802. #ifndef Z2_MS2_PIN
  803. #define Z2_MS2_PIN -1
  804. #endif
  805. #ifndef Z2_MS3_PIN
  806. #define Z2_MS3_PIN -1
  807. #endif
  808. // The Z3 axis, if any, should be the next open extruder port
  809. #if NUM_Z_STEPPER_DRIVERS >= 3 && !defined(Z3_DIAG_PIN) && !defined(Z3_STEP_PIN) && !PIN_EXISTS(Z3_CS_PIN)
  810. #define Z4_E_INDEX INCREMENT(Z3_E_INDEX)
  811. #else
  812. #define Z4_E_INDEX Z3_E_INDEX
  813. #endif
  814. #if NUM_Z_STEPPER_DRIVERS >= 3
  815. #ifndef Z3_STEP_PIN
  816. #define Z3_STEP_PIN _EPIN(Z3_E_INDEX, STEP)
  817. #define Z3_DIR_PIN _EPIN(Z3_E_INDEX, DIR)
  818. #define Z3_ENABLE_PIN _EPIN(Z3_E_INDEX, ENABLE)
  819. #if Z3_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z3_STEP)
  820. #error "No E stepper plug left for Z3!"
  821. #else
  822. #define AUTO_ASSIGNED_Z3_STEPPER 1
  823. #endif
  824. #endif
  825. #if AXIS_HAS_SPI(Z3) && !defined(Z3_CS_PIN)
  826. #define Z3_CS_PIN _EPIN(Z3_E_INDEX, CS)
  827. #if PIN_EXISTS(Z3_CS)
  828. #define AUTO_ASSIGNED_Z3_CS 1
  829. #endif
  830. #endif
  831. #ifndef Z3_MS1_PIN
  832. #define Z3_MS1_PIN _EPIN(Z3_E_INDEX, MS1)
  833. #if PIN_EXISTS(Z3_MS1)
  834. #define AUTO_ASSIGNED_Z3_MS1 1
  835. #endif
  836. #endif
  837. #ifndef Z3_MS2_PIN
  838. #define Z3_MS2_PIN _EPIN(Z3_E_INDEX, MS2)
  839. #if PIN_EXISTS(Z3_MS2)
  840. #define AUTO_ASSIGNED_Z3_MS2 1
  841. #endif
  842. #endif
  843. #ifndef Z3_MS3_PIN
  844. #define Z3_MS3_PIN _EPIN(Z3_E_INDEX, MS3)
  845. #if PIN_EXISTS(Z3_MS3)
  846. #define AUTO_ASSIGNED_Z3_MS3 1
  847. #endif
  848. #endif
  849. #if AXIS_HAS_UART(Z3)
  850. #ifndef Z3_SERIAL_TX_PIN
  851. #define Z3_SERIAL_TX_PIN _EPIN(Z3_E_INDEX, SERIAL_TX)
  852. #endif
  853. #ifndef Z3_SERIAL_RX_PIN
  854. #define Z3_SERIAL_RX_PIN _EPIN(Z3_E_INDEX, SERIAL_RX)
  855. #endif
  856. #endif
  857. // Auto-assign pins for stallGuard sensorless homing
  858. #if !defined(Z3_DIAG_PIN) && !defined(Z3_USE_ENDSTOP) && defined(Z3_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 3 && _PEXI(Z3_E_INDEX, DIAG)
  859. #define Z3_DIAG_PIN _EPIN(Z3_E_INDEX, DIAG)
  860. #if DIAG_REMAPPED(Z3, X_MIN)
  861. #define Z3_USE_ENDSTOP _XMIN_
  862. #elif DIAG_REMAPPED(Z3, Y_MIN)
  863. #define Z3_USE_ENDSTOP _YMIN_
  864. #elif DIAG_REMAPPED(Z3, Z_MIN)
  865. #define Z3_USE_ENDSTOP _ZMIN_
  866. #elif DIAG_REMAPPED(Z3, X_MAX)
  867. #define Z3_USE_ENDSTOP _XMAX_
  868. #elif DIAG_REMAPPED(Z3, Y_MAX)
  869. #define Z3_USE_ENDSTOP _YMAX_
  870. #elif DIAG_REMAPPED(Z3, Z_MAX)
  871. #define Z3_USE_ENDSTOP _ZMAX_
  872. #else
  873. #define Z3_USE_ENDSTOP _En_DIAG_(Z3_E_INDEX)
  874. #endif
  875. #define AUTO_ASSIGNED_Z3_DIAG 1
  876. #undef Z3_DIAG_PIN // Defined in Conditionals_post.h based on Z3_USE_ENDSTOP
  877. #endif
  878. #endif
  879. #ifndef Z3_CS_PIN
  880. #define Z3_CS_PIN -1
  881. #endif
  882. #ifndef Z3_MS1_PIN
  883. #define Z3_MS1_PIN -1
  884. #endif
  885. #ifndef Z3_MS2_PIN
  886. #define Z3_MS2_PIN -1
  887. #endif
  888. #ifndef Z3_MS3_PIN
  889. #define Z3_MS3_PIN -1
  890. #endif
  891. // The Z4 axis, if any, should be the next open extruder port
  892. #if NUM_Z_STEPPER_DRIVERS >= 4 && !defined(Z4_DIAG_PIN) && !defined(Z4_STEP_PIN) && !PIN_EXISTS(Z4_CS_PIN)
  893. #define I_E_INDEX INCREMENT(Z4_E_INDEX)
  894. #else
  895. #define I_E_INDEX Z4_E_INDEX
  896. #endif
  897. #if NUM_Z_STEPPER_DRIVERS >= 4
  898. #ifndef Z4_STEP_PIN
  899. #define Z4_STEP_PIN _EPIN(Z4_E_INDEX, STEP)
  900. #define Z4_DIR_PIN _EPIN(Z4_E_INDEX, DIR)
  901. #define Z4_ENABLE_PIN _EPIN(Z4_E_INDEX, ENABLE)
  902. #if Z4_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(Z4_STEP)
  903. #error "No E stepper plug left for Z4!"
  904. #else
  905. #define AUTO_ASSIGNED_Z4_STEPPER 1
  906. #endif
  907. #endif
  908. #if AXIS_HAS_SPI(Z4) && !defined(Z4_CS_PIN)
  909. #define Z4_CS_PIN _EPIN(Z4_E_INDEX, CS)
  910. #if PIN_EXISTS(Z4_CS)
  911. #define AUTO_ASSIGNED_Z4_CS 1
  912. #endif
  913. #endif
  914. #ifndef Z4_MS1_PIN
  915. #define Z4_MS1_PIN _EPIN(Z4_E_INDEX, MS1)
  916. #if PIN_EXISTS(Z4_MS1)
  917. #define AUTO_ASSIGNED_Z4_MS1 1
  918. #endif
  919. #endif
  920. #ifndef Z4_MS2_PIN
  921. #define Z4_MS2_PIN _EPIN(Z4_E_INDEX, MS2)
  922. #if PIN_EXISTS(Z4_MS2)
  923. #define AUTO_ASSIGNED_Z4_MS2 1
  924. #endif
  925. #endif
  926. #ifndef Z4_MS3_PIN
  927. #define Z4_MS3_PIN _EPIN(Z4_E_INDEX, MS3)
  928. #if PIN_EXISTS(Z4_MS3)
  929. #define AUTO_ASSIGNED_Z4_MS3 1
  930. #endif
  931. #endif
  932. #if AXIS_HAS_UART(Z4)
  933. #ifndef Z4_SERIAL_TX_PIN
  934. #define Z4_SERIAL_TX_PIN _EPIN(Z4_E_INDEX, SERIAL_TX)
  935. #endif
  936. #ifndef Z4_SERIAL_RX_PIN
  937. #define Z4_SERIAL_RX_PIN _EPIN(Z4_E_INDEX, SERIAL_RX)
  938. #endif
  939. #endif
  940. // Auto-assign pins for stallGuard sensorless homing
  941. #if !defined(Z4_DIAG_PIN) && !defined(Z4_USE_ENDSTOP) && defined(Z4_STALL_SENSITIVITY) && ENABLED(Z_MULTI_ENDSTOPS) && NUM_Z_STEPPER_DRIVERS >= 4 && _PEXI(Z4_E_INDEX, DIAG)
  942. #define Z4_DIAG_PIN _EPIN(Z4_E_INDEX, DIAG)
  943. #if DIAG_REMAPPED(Z4, X_MIN)
  944. #define Z4_USE_ENDSTOP _XMIN_
  945. #elif DIAG_REMAPPED(Z4, Y_MIN)
  946. #define Z4_USE_ENDSTOP _YMIN_
  947. #elif DIAG_REMAPPED(Z4, Z_MIN)
  948. #define Z4_USE_ENDSTOP _ZMIN_
  949. #elif DIAG_REMAPPED(Z4, X_MAX)
  950. #define Z4_USE_ENDSTOP _XMAX_
  951. #elif DIAG_REMAPPED(Z4, Y_MAX)
  952. #define Z4_USE_ENDSTOP _YMAX_
  953. #elif DIAG_REMAPPED(Z4, Z_MAX)
  954. #define Z4_USE_ENDSTOP _ZMAX_
  955. #else
  956. #define Z4_USE_ENDSTOP _En_DIAG_(Z4_E_INDEX)
  957. #endif
  958. #define AUTO_ASSIGNED_Z4_DIAG 1
  959. #undef Z4_DIAG_PIN // Defined in Conditionals_post.h based on Z4_USE_ENDSTOP
  960. #endif
  961. #endif
  962. #ifndef Z4_CS_PIN
  963. #define Z4_CS_PIN -1
  964. #endif
  965. #ifndef Z4_MS1_PIN
  966. #define Z4_MS1_PIN -1
  967. #endif
  968. #ifndef Z4_MS2_PIN
  969. #define Z4_MS2_PIN -1
  970. #endif
  971. #ifndef Z4_MS3_PIN
  972. #define Z4_MS3_PIN -1
  973. #endif
  974. // The I axis, if any, should be the next open extruder port
  975. #if LINEAR_AXES >= 4 && !defined(I_DIAG_PIN) && !defined(I_STEP_PIN) && !PIN_EXISTS(I_CS_PIN)
  976. #define J_E_INDEX INCREMENT(I_E_INDEX)
  977. #else
  978. #define J_E_INDEX I_E_INDEX
  979. #endif
  980. #if LINEAR_AXES >= 4
  981. #ifndef I_STEP_PIN
  982. #define I_STEP_PIN _EPIN(I_E_INDEX, STEP)
  983. #define I_DIR_PIN _EPIN(I_E_INDEX, DIR)
  984. #define I_ENABLE_PIN _EPIN(I_E_INDEX, ENABLE)
  985. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(I_STEP)
  986. #error "No E stepper plug left for I!"
  987. #else
  988. #define AUTO_ASSIGNED_I_STEPPER 1
  989. #endif
  990. #endif
  991. #if AXIS_HAS_SPI(I) && !defined(I_CS_PIN)
  992. #define I_CS_PIN _EPIN(I_E_INDEX, CS)
  993. #if PIN_EXISTS(I_CS)
  994. #define AUTO_ASSIGNED_I_CS 1
  995. #endif
  996. #endif
  997. #ifndef I_MS1_PIN
  998. #define I_MS1_PIN _EPIN(I_E_INDEX, MS1)
  999. #if PIN_EXISTS(I_MS1)
  1000. #define AUTO_ASSIGNED_I_MS1 1
  1001. #endif
  1002. #endif
  1003. #ifndef I_MS2_PIN
  1004. #define I_MS2_PIN _EPIN(I_E_INDEX, MS2)
  1005. #if PIN_EXISTS(I_MS2)
  1006. #define AUTO_ASSIGNED_I_MS2 1
  1007. #endif
  1008. #endif
  1009. #ifndef I_MS3_PIN
  1010. #define I_MS3_PIN _EPIN(I_E_INDEX, MS3)
  1011. #if PIN_EXISTS(I_MS3)
  1012. #define AUTO_ASSIGNED_I_MS3 1
  1013. #endif
  1014. #endif
  1015. #if AXIS_HAS_UART(I)
  1016. #ifndef I_SERIAL_TX_PIN
  1017. #define I_SERIAL_TX_PIN _EPIN(I_E_INDEX, SERIAL_TX)
  1018. #endif
  1019. #ifndef I_SERIAL_RX_PIN
  1020. #define I_SERIAL_RX_PIN _EPIN(I_E_INDEX, SERIAL_RX)
  1021. #endif
  1022. #endif
  1023. // Auto-assign pins for stallGuard sensorless homing
  1024. #if !defined(I_DIAG_PIN) && !defined(I_USE_ENDSTOP) && defined(I_STALL_SENSITIVITY) && _PEXI(I_E_INDEX, DIAG)
  1025. #define I_DIAG_PIN _EPIN(I_E_INDEX, DIAG)
  1026. #if DIAG_REMAPPED(I, X_MIN)
  1027. #define I_USE_ENDSTOP _XMIN_
  1028. #elif DIAG_REMAPPED(I, Y_MIN)
  1029. #define I_USE_ENDSTOP _YMIN_
  1030. #elif DIAG_REMAPPED(I, Z_MIN)
  1031. #define I_USE_ENDSTOP _ZMIN_
  1032. #elif DIAG_REMAPPED(I, X_MAX)
  1033. #define I_USE_ENDSTOP _XMAX_
  1034. #elif DIAG_REMAPPED(I, Y_MAX)
  1035. #define I_USE_ENDSTOP _YMAX_
  1036. #elif DIAG_REMAPPED(I, Z_MAX)
  1037. #define I_USE_ENDSTOP _ZMAX_
  1038. #else
  1039. #define I_USE_ENDSTOP _En_DIAG_(I_E_INDEX)
  1040. #endif
  1041. #define AUTO_ASSIGNED_I_DIAG 1
  1042. #undef I_DIAG_PIN // Defined in Conditionals_post.h based on I_USE_ENDSTOP
  1043. #endif
  1044. #endif
  1045. #ifndef I_CS_PIN
  1046. #define I_CS_PIN -1
  1047. #endif
  1048. #ifndef I_MS1_PIN
  1049. #define I_MS1_PIN -1
  1050. #endif
  1051. #ifndef I_MS2_PIN
  1052. #define I_MS2_PIN -1
  1053. #endif
  1054. #ifndef I_MS3_PIN
  1055. #define I_MS3_PIN -1
  1056. #endif
  1057. // The J axis, if any, should be the next open extruder port
  1058. #if LINEAR_AXES >= 5 && !defined(J_DIAG_PIN) && !defined(J_STEP_PIN) && !PIN_EXISTS(J_CS_PIN)
  1059. #define K_E_INDEX INCREMENT(J_E_INDEX)
  1060. #else
  1061. #define K_E_INDEX J_E_INDEX
  1062. #endif
  1063. #if LINEAR_AXES >= 5
  1064. #ifndef J_STEP_PIN
  1065. #define J_STEP_PIN _EPIN(J_E_INDEX, STEP)
  1066. #define J_DIR_PIN _EPIN(J_E_INDEX, DIR)
  1067. #define J_ENABLE_PIN _EPIN(J_E_INDEX, ENABLE)
  1068. #if I_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(J_STEP)
  1069. #error "No E stepper plug left for J!"
  1070. #else
  1071. #define AUTO_ASSIGNED_J_STEPPER 1
  1072. #endif
  1073. #endif
  1074. #if AXIS_HAS_SPI(J) && !defined(J_CS_PIN)
  1075. #define J_CS_PIN _EPIN(J_E_INDEX, CS)
  1076. #if PIN_EXISTS(J_CS)
  1077. #define AUTO_ASSIGNED_J_CS 1
  1078. #endif
  1079. #endif
  1080. #ifndef J_MS1_PIN
  1081. #define J_MS1_PIN _EPIN(J_E_INDEX, MS1)
  1082. #if PIN_EXISTS(J_MS1)
  1083. #define AUTO_ASSIGNED_J_MS1 1
  1084. #endif
  1085. #endif
  1086. #ifndef J_MS2_PIN
  1087. #define J_MS2_PIN _EPIN(J_E_INDEX, MS2)
  1088. #if PIN_EXISTS(J_MS2)
  1089. #define AUTO_ASSIGNED_J_MS2 1
  1090. #endif
  1091. #endif
  1092. #ifndef J_MS3_PIN
  1093. #define J_MS3_PIN _EPIN(J_E_INDEX, MS3)
  1094. #if PIN_EXISTS(J_MS3)
  1095. #define AUTO_ASSIGNED_J_MS3 1
  1096. #endif
  1097. #endif
  1098. #if AXIS_HAS_UART(J)
  1099. #ifndef J_SERIAL_TX_PIN
  1100. #define J_SERIAL_TX_PIN _EPIN(J_E_INDEX, SERIAL_TX)
  1101. #endif
  1102. #ifndef J_SERIAL_RX_PIN
  1103. #define J_SERIAL_RX_PIN _EPIN(J_E_INDEX, SERIAL_RX)
  1104. #endif
  1105. #endif
  1106. // Auto-assign pins for stallGuard sensorless homing
  1107. #if !defined(J_DIAG_PIN) && !defined(J_USE_ENDSTOP) && defined(J_STALL_SENSITIVITY) && _PEXI(J_E_INDEX, DIAG)
  1108. #define J_DIAG_PIN _EPIN(J_E_INDEX, DIAG)
  1109. #if DIAG_REMAPPED(J, X_MIN)
  1110. #define J_USE_ENDSTOP _XMIN_
  1111. #elif DIAG_REMAPPED(J, Y_MIN)
  1112. #define J_USE_ENDSTOP _YMIN_
  1113. #elif DIAG_REMAPPED(J, Z_MIN)
  1114. #define J_USE_ENDSTOP _ZMIN_
  1115. #elif DIAG_REMAPPED(J, X_MAX)
  1116. #define J_USE_ENDSTOP _XMAX_
  1117. #elif DIAG_REMAPPED(J, Y_MAX)
  1118. #define J_USE_ENDSTOP _YMAX_
  1119. #elif DIAG_REMAPPED(I, Z_MAX)
  1120. #define J_USE_ENDSTOP _ZMAX_
  1121. #else
  1122. #define J_USE_ENDSTOP _En_DIAG_(J_E_INDEX)
  1123. #endif
  1124. #define AUTO_ASSIGNED_J_DIAG 1
  1125. #undef J_DIAG_PIN // Defined in Conditionals_post.h based on J_USE_ENDSTOP
  1126. #endif
  1127. #endif
  1128. #ifndef J_CS_PIN
  1129. #define J_CS_PIN -1
  1130. #endif
  1131. #ifndef J_MS1_PIN
  1132. #define J_MS1_PIN -1
  1133. #endif
  1134. #ifndef J_MS2_PIN
  1135. #define J_MS2_PIN -1
  1136. #endif
  1137. #ifndef J_MS3_PIN
  1138. #define J_MS3_PIN -1
  1139. #endif
  1140. // The K axis, if any, should be the next open extruder port
  1141. #if LINEAR_AXES >= 6
  1142. #ifndef K_STEP_PIN
  1143. #define K_STEP_PIN _EPIN(K_E_INDEX, STEP)
  1144. #define K_DIR_PIN _EPIN(K_E_INDEX, DIR)
  1145. #define K_ENABLE_PIN _EPIN(K_E_INDEX, ENABLE)
  1146. #if K_E_INDEX >= MAX_E_STEPPERS || !PIN_EXISTS(K_STEP)
  1147. #error "No E stepper plug left for K!"
  1148. #else
  1149. #define AUTO_ASSIGNED_K_STEPPER 1
  1150. #endif
  1151. #endif
  1152. #if AXIS_HAS_SPI(K) && !defined(K_CS_PIN)
  1153. #define K_CS_PIN _EPIN(K_E_INDEX, CS)
  1154. #if PIN_EXISTS(K_CS)
  1155. #define AUTO_ASSIGNED_K_CS 1
  1156. #endif
  1157. #endif
  1158. #ifndef K_MS1_PIN
  1159. #define K_MS1_PIN _EPIN(K_E_INDEX, MS1)
  1160. #if PIN_EXISTS(K_MS1)
  1161. #define AUTO_ASSIGNED_K_MS1 1
  1162. #endif
  1163. #endif
  1164. #ifndef K_MS2_PIN
  1165. #define K_MS2_PIN _EPIN(K_E_INDEX, MS2)
  1166. #if PIN_EXISTS(K_MS2)
  1167. #define AUTO_ASSIGNED_K_MS2 1
  1168. #endif
  1169. #endif
  1170. #ifndef K_MS3_PIN
  1171. #define K_MS3_PIN _EPIN(K_E_INDEX, MS3)
  1172. #if PIN_EXISTS(K_MS3)
  1173. #define AUTO_ASSIGNED_K_MS3 1
  1174. #endif
  1175. #endif
  1176. #if AXIS_HAS_UART(K)
  1177. #ifndef K_SERIAL_TX_PIN
  1178. #define K_SERIAL_TX_PIN _EPIN(K_E_INDEX, SERIAL_TX)
  1179. #endif
  1180. #ifndef K_SERIAL_RX_PIN
  1181. #define K_SERIAL_RX_PIN _EPIN(K_E_INDEX, SERIAL_RX)
  1182. #endif
  1183. #endif
  1184. // Auto-assign pins for stallGuard sensorless homing
  1185. #if !defined(K_DIAG_PIN) && !defined(K_USE_ENDSTOP) && defined(K_STALL_SENSITIVITY) && _PEXI(K_E_INDEX, DIAG)
  1186. #define K_DIAG_PIN _EPIN(K_E_INDEX, DIAG)
  1187. #if DIAG_REMAPPED(K, X_MIN)
  1188. #define K_USE_ENDSTOP _XMIN_
  1189. #elif DIAG_REMAPPED(K, Y_MIN)
  1190. #define K_USE_ENDSTOP _YMIN_
  1191. #elif DIAG_REMAPPED(K, Z_MIN)
  1192. #define K_USE_ENDSTOP _ZMIN_
  1193. #elif DIAG_REMAPPED(K, X_MAX)
  1194. #define K_USE_ENDSTOP _XMAX_
  1195. #elif DIAG_REMAPPED(K, Y_MAX)
  1196. #define K_USE_ENDSTOP _YMAX_
  1197. #elif DIAG_REMAPPED(K, Z_MAX)
  1198. #define K_USE_ENDSTOP _ZMAX_
  1199. #else
  1200. #define K_USE_ENDSTOP _En_DIAG_(K_E_INDEX)
  1201. #endif
  1202. #define AUTO_ASSIGNED_K_DIAG 1
  1203. #undef K_DIAG_PIN // Defined in Conditionals_post.h based on K_USE_ENDSTOP
  1204. #endif
  1205. #endif
  1206. #ifndef K_CS_PIN
  1207. #define K_CS_PIN -1
  1208. #endif
  1209. #ifndef K_MS1_PIN
  1210. #define K_MS1_PIN -1
  1211. #endif
  1212. #ifndef K_MS2_PIN
  1213. #define K_MS2_PIN -1
  1214. #endif
  1215. #ifndef K_MS3_PIN
  1216. #define K_MS3_PIN -1
  1217. #endif
  1218. //
  1219. // Disable unused endstop / probe pins
  1220. //
  1221. #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)
  1222. #if _STOP_IN_USE(_XMAX_)
  1223. #define USE_XMAX_PLUG
  1224. #endif
  1225. #if _STOP_IN_USE(_YMAX_)
  1226. #define USE_YMAX_PLUG
  1227. #endif
  1228. #if _STOP_IN_USE(_ZMAX_)
  1229. #define USE_ZMAX_PLUG
  1230. #endif
  1231. #if _STOP_IN_USE(_XMIN_)
  1232. #define USE_XMIN_PLUG
  1233. #endif
  1234. #if _STOP_IN_USE(_YMIN_)
  1235. #define USE_YMIN_PLUG
  1236. #endif
  1237. #if _STOP_IN_USE(_ZMIN_)
  1238. #define USE_ZMIN_PLUG
  1239. #endif
  1240. #undef _STOP_IN_USE
  1241. #if !USES_Z_MIN_PROBE_PIN
  1242. #undef Z_MIN_PROBE_PIN
  1243. #define Z_MIN_PROBE_PIN -1
  1244. #endif
  1245. #if DISABLED(USE_XMIN_PLUG)
  1246. #undef X_MIN_PIN
  1247. #define X_MIN_PIN -1
  1248. #endif
  1249. #if DISABLED(USE_XMAX_PLUG)
  1250. #undef X_MAX_PIN
  1251. #define X_MAX_PIN -1
  1252. #endif
  1253. #if DISABLED(USE_YMIN_PLUG)
  1254. #undef Y_MIN_PIN
  1255. #define Y_MIN_PIN -1
  1256. #endif
  1257. #if DISABLED(USE_YMAX_PLUG)
  1258. #undef Y_MAX_PIN
  1259. #define Y_MAX_PIN -1
  1260. #endif
  1261. #if DISABLED(USE_ZMIN_PLUG)
  1262. #undef Z_MIN_PIN
  1263. #define Z_MIN_PIN -1
  1264. #endif
  1265. #if DISABLED(USE_ZMAX_PLUG)
  1266. #undef Z_MAX_PIN
  1267. #define Z_MAX_PIN -1
  1268. #endif
  1269. #if DISABLED(USE_IMIN_PLUG)
  1270. #undef I_MIN_PIN
  1271. #define I_MIN_PIN -1
  1272. #endif
  1273. #if DISABLED(USE_IMAX_PLUG)
  1274. #undef I_MAX_PIN
  1275. #define I_MAX_PIN -1
  1276. #endif
  1277. #if DISABLED(USE_JMIN_PLUG)
  1278. #undef J_MIN_PIN
  1279. #define J_MIN_PIN -1
  1280. #endif
  1281. #if DISABLED(USE_JMAX_PLUG)
  1282. #undef J_MAX_PIN
  1283. #define J_MAX_PIN -1
  1284. #endif
  1285. #if DISABLED(USE_KMIN_PLUG)
  1286. #undef K_MIN_PIN
  1287. #define K_MIN_PIN -1
  1288. #endif
  1289. #if DISABLED(USE_KMAX_PLUG)
  1290. #undef K_MAX_PIN
  1291. #define K_MAX_PIN -1
  1292. #endif
  1293. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MAX
  1294. #undef X2_MIN_PIN
  1295. #endif
  1296. #if DISABLED(X_DUAL_ENDSTOPS) || X_HOME_TO_MIN
  1297. #undef X2_MAX_PIN
  1298. #endif
  1299. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MAX
  1300. #undef Y2_MIN_PIN
  1301. #endif
  1302. #if DISABLED(Y_DUAL_ENDSTOPS) || Y_HOME_TO_MIN
  1303. #undef Y2_MAX_PIN
  1304. #endif
  1305. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MAX
  1306. #undef Z2_MIN_PIN
  1307. #endif
  1308. #if DISABLED(Z_MULTI_ENDSTOPS) || Z_HOME_TO_MIN
  1309. #undef Z2_MAX_PIN
  1310. #endif
  1311. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MAX
  1312. #undef Z3_MIN_PIN
  1313. #endif
  1314. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 3 || Z_HOME_TO_MIN
  1315. #undef Z3_MAX_PIN
  1316. #endif
  1317. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MAX
  1318. #undef Z4_MIN_PIN
  1319. #endif
  1320. #if DISABLED(Z_MULTI_ENDSTOPS) || NUM_Z_STEPPER_DRIVERS < 4 || Z_HOME_TO_MIN
  1321. #undef Z4_MAX_PIN
  1322. #endif
  1323. //
  1324. // Default DOGLCD SPI delays
  1325. //
  1326. #if !IS_U8GLIB_ST7920
  1327. #undef ST7920_DELAY_1
  1328. #undef ST7920_DELAY_2
  1329. #undef ST7920_DELAY_3
  1330. #undef LCD_ST7920_DELAY_1
  1331. #undef LCD_ST7920_DELAY_2
  1332. #undef LCD_ST7920_DELAY_3
  1333. #undef BOARD_ST7920_DELAY_1
  1334. #undef BOARD_ST7920_DELAY_2
  1335. #undef BOARD_ST7920_DELAY_3
  1336. #undef CPU_ST7920_DELAY_1
  1337. #undef CPU_ST7920_DELAY_2
  1338. #undef CPU_ST7920_DELAY_3
  1339. #endif
  1340. #if !NEED_CASE_LIGHT_PIN
  1341. #undef CASE_LIGHT_PIN
  1342. #endif
  1343. #undef HAS_FREE_AUX2_PINS
  1344. #undef DIAG_REMAPPED