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

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