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.

stepper_indirection.cpp 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 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 <http://www.gnu.org/licenses/>.
  20. *
  21. */
  22. /**
  23. stepper_indirection.c - stepper motor driver indirection
  24. to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
  25. Part of Marlin
  26. Copyright (c) 2015 Dominik Wenger
  27. Marlin is free software: you can redistribute it and/or modify
  28. it under the terms of the GNU General Public License as published by
  29. the Free Software Foundation, either version 3 of the License, or
  30. (at your option) any later version.
  31. Marlin is distributed in the hope that it will be useful,
  32. but WITHOUT ANY WARRANTY; without even the implied warranty of
  33. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  34. GNU General Public License for more details.
  35. You should have received a copy of the GNU General Public License
  36. along with Marlin. If not, see <http://www.gnu.org/licenses/>.
  37. */
  38. #include "stepper_indirection.h"
  39. #include "MarlinConfig.h"
  40. #if ENABLED(HAVE_TMCDRIVER)
  41. #include <SPI.h>
  42. #include <TMC26XStepper.h>
  43. #endif
  44. // Stepper objects of TMC steppers used
  45. #if ENABLED(X_IS_TMC)
  46. TMC26XStepper stepperX(200, X_ENABLE_PIN, X_STEP_PIN, X_DIR_PIN, X_MAX_CURRENT, X_SENSE_RESISTOR);
  47. #endif
  48. #if ENABLED(X2_IS_TMC)
  49. TMC26XStepper stepperX2(200, X2_ENABLE_PIN, X2_STEP_PIN, X2_DIR_PIN, X2_MAX_CURRENT, X2_SENSE_RESISTOR);
  50. #endif
  51. #if ENABLED(Y_IS_TMC)
  52. TMC26XStepper stepperY(200, Y_ENABLE_PIN, Y_STEP_PIN, Y_DIR_PIN, Y_MAX_CURRENT, Y_SENSE_RESISTOR);
  53. #endif
  54. #if ENABLED(Y2_IS_TMC)
  55. TMC26XStepper stepperY2(200, Y2_ENABLE_PIN, Y2_STEP_PIN, Y2_DIR_PIN, Y2_MAX_CURRENT, Y2_SENSE_RESISTOR);
  56. #endif
  57. #if ENABLED(Z_IS_TMC)
  58. TMC26XStepper stepperZ(200, Z_ENABLE_PIN, Z_STEP_PIN, Z_DIR_PIN, Z_MAX_CURRENT, Z_SENSE_RESISTOR);
  59. #endif
  60. #if ENABLED(Z2_IS_TMC)
  61. TMC26XStepper stepperZ2(200, Z2_ENABLE_PIN, Z2_STEP_PIN, Z2_DIR_PIN, Z2_MAX_CURRENT, Z2_SENSE_RESISTOR);
  62. #endif
  63. #if ENABLED(E0_IS_TMC)
  64. TMC26XStepper stepperE0(200, E0_ENABLE_PIN, E0_STEP_PIN, E0_DIR_PIN, E0_MAX_CURRENT, E0_SENSE_RESISTOR);
  65. #endif
  66. #if ENABLED(E1_IS_TMC)
  67. TMC26XStepper stepperE1(200, E1_ENABLE_PIN, E1_STEP_PIN, E1_DIR_PIN, E1_MAX_CURRENT, E1_SENSE_RESISTOR);
  68. #endif
  69. #if ENABLED(E2_IS_TMC)
  70. TMC26XStepper stepperE2(200, E2_ENABLE_PIN, E2_STEP_PIN, E2_DIR_PIN, E2_MAX_CURRENT, E2_SENSE_RESISTOR);
  71. #endif
  72. #if ENABLED(E3_IS_TMC)
  73. TMC26XStepper stepperE3(200, E3_ENABLE_PIN, E3_STEP_PIN, E3_DIR_PIN, E3_MAX_CURRENT, E3_SENSE_RESISTOR);
  74. #endif
  75. #if ENABLED(HAVE_TMCDRIVER)
  76. void tmc_init() {
  77. #if ENABLED(X_IS_TMC)
  78. stepperX.setMicrosteps(X_MICROSTEPS);
  79. stepperX.start();
  80. #endif
  81. #if ENABLED(X2_IS_TMC)
  82. stepperX2.setMicrosteps(X2_MICROSTEPS);
  83. stepperX2.start();
  84. #endif
  85. #if ENABLED(Y_IS_TMC)
  86. stepperY.setMicrosteps(Y_MICROSTEPS);
  87. stepperY.start();
  88. #endif
  89. #if ENABLED(Y2_IS_TMC)
  90. stepperY2.setMicrosteps(Y2_MICROSTEPS);
  91. stepperY2.start();
  92. #endif
  93. #if ENABLED(Z_IS_TMC)
  94. stepperZ.setMicrosteps(Z_MICROSTEPS);
  95. stepperZ.start();
  96. #endif
  97. #if ENABLED(Z2_IS_TMC)
  98. stepperZ2.setMicrosteps(Z2_MICROSTEPS);
  99. stepperZ2.start();
  100. #endif
  101. #if ENABLED(E0_IS_TMC)
  102. stepperE0.setMicrosteps(E0_MICROSTEPS);
  103. stepperE0.start();
  104. #endif
  105. #if ENABLED(E1_IS_TMC)
  106. stepperE1.setMicrosteps(E1_MICROSTEPS);
  107. stepperE1.start();
  108. #endif
  109. #if ENABLED(E2_IS_TMC)
  110. stepperE2.setMicrosteps(E2_MICROSTEPS);
  111. stepperE2.start();
  112. #endif
  113. #if ENABLED(E3_IS_TMC)
  114. stepperE3.setMicrosteps(E3_MICROSTEPS);
  115. stepperE3.start();
  116. #endif
  117. }
  118. #endif
  119. #if ENABLED(HAVE_TMC2130DRIVER)
  120. #include <SPI.h>
  121. #include <Trinamic_TMC2130.h>
  122. #endif
  123. // Stepper objects of TMC2310 steppers used
  124. #if ENABLED(X_IS_TMC2130)
  125. Trinamic_TMC2130 stepperX(X_CS_PIN);
  126. #endif
  127. #if ENABLED(X2_IS_TMC2130)
  128. Trinamic_TMC2130 stepperX2(X2_CS_PIN);
  129. #endif
  130. #if ENABLED(Y_IS_TMC2130)
  131. Trinamic_TMC2130 stepperY(Y_CS_PIN);
  132. #endif
  133. #if ENABLED(Y2_IS_TMC2130)
  134. Trinamic_TMC2130 stepperY2(Y2_CS_PINR);
  135. #endif
  136. #if ENABLED(Z_IS_TMC2130)
  137. Trinamic_TMC2130 stepperZ(Z_CS_PIN);
  138. #endif
  139. #if ENABLED(Z2_IS_TMC2130)
  140. Trinamic_TMC2130 stepperZ2(Z2_CS_PIN);
  141. #endif
  142. #if ENABLED(E0_IS_TMC2130)
  143. Trinamic_TMC2130 stepperE0(E0_CS_PIN);
  144. #endif
  145. #if ENABLED(E1_IS_TMC2130)
  146. Trinamic_TMC2130 stepperE1(E1_CS_PIN);
  147. #endif
  148. #if ENABLED(E2_IS_TMC2130)
  149. Trinamic_TMC2130 stepperE2(E2_CS_PIN);
  150. #endif
  151. #if ENABLED(E3_IS_TMC2130)
  152. Trinamic_TMC2130 stepperE3(E3_CS_PIN);
  153. #endif
  154. #if ENABLED(HAVE_TMC2130DRIVER)
  155. #if ENABLED(TMC2130_ADVANCED_CONFIGURATION)
  156. void tmc2130_init() {
  157. // If you've enabled TMC2130_ADVANCED_CONFIGURATION configure your
  158. // steppers manually here. The ENABLED(XYZ_IS_TMC2130) is optional,
  159. #if ENABLED(X_IS_TMC2130)
  160. stepperX.init();
  161. stepperX.set_I_scale_analog(GLOBAL_I_SCALE_ANALOG);
  162. //stepperX.set_internal_Rsense(GLOBAL_INTERNAL_RSENSE);
  163. stepperX.set_en_pwm_mode(GLOBAL_EN_PWM_MODE);
  164. //stepperX.set_enc_commutation(GLOBAL_ENC_COMMUTATION);
  165. stepperX.set_shaft(GLOBAL_SHAFT);
  166. //stepperX.set_diag0_error(GLOBAL_DIAG0_ERROR);
  167. //stepperX.set_diag0_otpw(GLOBAL_DIAG0_OTPW);
  168. //stepperX.set_diag0_stall(GLOBAL_DIAG0_STALL);
  169. //stepperX.set_diag1_stall(GLOBAL_DIAG1_STALL);
  170. //stepperX.set_diag1_index(GLOBAL_DIAG1_INDEX);
  171. //stepperX.set_diag1_onstate(GLOBAL_DIAG1_ONSTATE);
  172. //stepperX.set_diag1_steps_skipped(GLOBAL_DIAG1_ONSTATE);
  173. //stepperX.set_diag0_int_pushpull(GLOBAL_DIAG0_INT_PUSHPULL);
  174. //stepperX.set_diag1_int_pushpull(GLOBAL_DIAG1_INT_PUSHPULL);
  175. //stepperX.set_small_hysteresis(GLOBAL_SMALL_HYSTERESIS);
  176. //stepperX.set_stop_enable(GLOBAL_STOP_ENABLE);
  177. //stepperX.set_direct_mode(GLOBAL_DIRECT_MODE);
  178. stepperX.set_IHOLD_IRUN(GLOBAL_IHOLD,GLOBAL_IRUN,GLOBAL_IHOLDDELAY);
  179. //stepperX.set_TPOWERDOWN(GLOBAL_TPOWERDOWN);
  180. //stepperX.set_TPWMTHRS(GLOBAL_TPWMTHRS);
  181. //stepperX.set_TCOOLTHRS(GLOBAL_TCOOLTHRS);
  182. stepperX.set_THIGH(GLOBAL_THIGH);
  183. //stepperX.set_XDIRECT(GLOBAL_XDIRECT);
  184. //stepperX.set_VDCMIN(GLOBAL_VDCMIN);
  185. //stepperX.set_dedge(GLOBAL_DEDGE);
  186. //stepperX.set_diss2g(GLOBAL_DISS2G);
  187. stepperX.set_intpol(GLOBAL_INTPOL);
  188. stepperX.set_mres(GLOBAL_MRES);
  189. stepperX.set_sync(GLOBAL_SYNC);
  190. stepperX.set_vhighchm(GLOBAL_VHIGHCHM);
  191. stepperX.set_vhighfs(GLOBAL_VHIGHFS);
  192. //stepperX.set_vsense(GLOBAL_VSENSE);
  193. stepperX.set_tbl(GLOBAL_TBL);
  194. stepperX.set_chm(GLOBAL_CHM);
  195. //stepperX.set_rndtf(GLOBAL_RNDTF);
  196. //stepperX.set_disfdcc(GLOBAL_DISFDCC);
  197. //stepperX.set_fd(GLOBAL_FD);
  198. //stepperX.set_hend(GLOBAL_HEND);
  199. //stepperX.set_hstrt(GLOBAL_HSTRT);
  200. stepperX.set_toff(GLOBAL_TOFF);
  201. //stepperX.set_sfilt(GLOBAL_SFILT);
  202. //stepperX.set_sgt(GLOBAL_SGT);
  203. //stepperX.set_seimin(GLOBAL_SEIMIN);
  204. //stepperX.set_sedn(GLOBAL_SEDN);
  205. //stepperX.set_semax(GLOBAL_SEMAX);
  206. //stepperX.set_seup(GLOBAL_SEUP);
  207. //stepperX.set_semin(GLOBAL_SEMIN);
  208. //stepperX.set_DCCTRL(GLOBAL_DC_TIME, GLOBAL_DC_SG);
  209. //stepperX.set_freewheel(GLOBAL_FREEWHEEL);
  210. //stepperX.set_pwm_symmetric(GLOBAL_PWM_SYMMETRIC);
  211. //stepperX.set_pwm_autoscale(GLOBAL_PWM_AUTOSCALE);
  212. //stepperX.set_pwm_freq(GLOBAL_PWM_FREQ);
  213. //stepperX.set_PWM_GRAD(GLOBAL_PWM_GRAD);
  214. //stepperX.set_PWM_AMPL(GLOBAL_PWM_AMPL);
  215. //stepperX.set_ENCM_CTRL(GLOBAL_ENCM_CTRL);
  216. #endif
  217. #if ENABLED(Y_IS_TMC2130)
  218. stepperY.init();
  219. stepperY.set_I_scale_analog(GLOBAL_I_SCALE_ANALOG);
  220. //stepperY.set_internal_Rsense(GLOBAL_INTERNAL_RSENSE);
  221. stepperY.set_en_pwm_mode(GLOBAL_EN_PWM_MODE);
  222. //stepperY.set_enc_commutation(GLOBAL_ENC_COMMUTATION);
  223. stepperY.set_shaft(GLOBAL_SHAFT);
  224. //stepperY.set_diag0_error(GLOBAL_DIAG0_ERROR);
  225. //stepperY.set_diag0_otpw(GLOBAL_DIAG0_OTPW);
  226. //stepperY.set_diag0_stall(GLOBAL_DIAG0_STALL);
  227. //stepperY.set_diag1_stall(GLOBAL_DIAG1_STALL);
  228. //stepperY.set_diag1_index(GLOBAL_DIAG1_INDEX);
  229. //stepperY.set_diag1_onstate(GLOBAL_DIAG1_ONSTATE);
  230. //stepperY.set_diag1_steps_skipped(GLOBAL_DIAG1_ONSTATE);
  231. //stepperY.set_diag0_int_pushpull(GLOBAL_DIAG0_INT_PUSHPULL);
  232. //stepperY.set_diag1_int_pushpull(GLOBAL_DIAG1_INT_PUSHPULL);
  233. //stepperY.set_small_hysteresis(GLOBAL_SMALL_HYSTERESIS);
  234. //stepperY.set_stop_enable(GLOBAL_STOP_ENABLE);
  235. //stepperY.set_direct_mode(GLOBAL_DIRECT_MODE);
  236. stepperY.set_IHOLD_IRUN(GLOBAL_IHOLD,GLOBAL_IRUN,GLOBAL_IHOLDDELAY);
  237. //stepperY.set_TPOWERDOWN(GLOBAL_TPOWERDOWN);
  238. //stepperY.set_TPWMTHRS(GLOBAL_TPWMTHRS);
  239. //stepperY.set_TCOOLTHRS(GLOBAL_TCOOLTHRS);
  240. stepperY.set_THIGH(GLOBAL_THIGH);
  241. //stepperY.set_XDIRECT(GLOBAL_XDIRECT);
  242. //stepperY.set_VDCMIN(GLOBAL_VDCMIN);
  243. //stepperY.set_dedge(GLOBAL_DEDGE);
  244. //stepperY.set_diss2g(GLOBAL_DISS2G);
  245. stepperY.set_intpol(GLOBAL_INTPOL);
  246. stepperY.set_mres(GLOBAL_MRES);
  247. stepperY.set_sync(GLOBAL_SYNC);
  248. stepperY.set_vhighchm(GLOBAL_VHIGHCHM);
  249. stepperY.set_vhighfs(GLOBAL_VHIGHFS);
  250. //stepperY.set_vsense(GLOBAL_VSENSE);
  251. stepperY.set_tbl(GLOBAL_TBL);
  252. stepperY.set_chm(GLOBAL_CHM);
  253. //stepperY.set_rndtf(GLOBAL_RNDTF);
  254. //stepperY.set_disfdcc(GLOBAL_DISFDCC);
  255. //stepperY.set_fd(GLOBAL_FD);
  256. //stepperY.set_hend(GLOBAL_HEND);
  257. //stepperY.set_hstrt(GLOBAL_HSTRT);
  258. stepperY.set_toff(GLOBAL_TOFF);
  259. //stepperY.set_sfilt(GLOBAL_SFILT);
  260. //stepperY.set_sgt(GLOBAL_SGT);
  261. //stepperY.set_seimin(GLOBAL_SEIMIN);
  262. //stepperY.set_sedn(GLOBAL_SEDN);
  263. //stepperY.set_semax(GLOBAL_SEMAX);
  264. //stepperY.set_seup(GLOBAL_SEUP);
  265. //stepperY.set_semin(GLOBAL_SEMIN);
  266. //stepperY.set_DCCTRL(GLOBAL_DC_TIME, GLOBAL_DC_SG);
  267. //stepperY.set_freewheel(GLOBAL_FREEWHEEL);
  268. //stepperY.set_pwm_symmetric(GLOBAL_PWM_SYMMETRIC);
  269. //stepperY.set_pwm_autoscale(GLOBAL_PWM_AUTOSCALE);
  270. //stepperY.set_pwm_freq(GLOBAL_PWM_FREQ);
  271. //stepperY.set_PWM_GRAD(GLOBAL_PWM_GRAD);
  272. //stepperY.set_PWM_AMPL(GLOBAL_PWM_AMPL);
  273. //stepperY.set_ENCM_CTRL(GLOBAL_ENCM_CTRL);
  274. #endif
  275. }
  276. #else // !TMC2130_ADVANCED_CONFIGURATION
  277. void tmc2130_init() {
  278. #if ENABLED(X_IS_TMC2130)
  279. stepperX.init();
  280. stepperX.set_mres(X_MRES);
  281. stepperX.set_IHOLD_IRUN(X_IHOLD,X_IRUN,X_IHOLDDELAY);
  282. stepperX.set_I_scale_analog(X_ISCALE);
  283. stepperX.set_tbl(X_TBL);
  284. stepperX.set_toff(X_TOFF);
  285. #endif
  286. #if ENABLED(X2_IS_TMC2130)
  287. stepperX2.init();
  288. stepperX2.set_mres(X2_MRES);
  289. stepperX2.set_IHOLD_IRUN(X2_IHOLD,X2_IRUN,X2_IHOLDDELAY);
  290. stepperX2.set_I_scale_analog(X2_ISCALE);
  291. stepperX2.set_tbl(X2_TBL);
  292. stepperX2.set_toff(X2_TOFF);
  293. #endif
  294. #if ENABLED(Y_IS_TMC2130)
  295. stepperY.init();
  296. stepperY.set_mres(Y_MRES);
  297. stepperY.set_IHOLD_IRUN(Y_IHOLD,Y_IRUN,Y_IHOLDDELAY);
  298. stepperY.set_I_scale_analog(Y_ISCALE);
  299. stepperY.set_tbl(Y_TBL);
  300. stepperY.set_toff(Y_TOFF);
  301. #endif
  302. #if ENABLED(Y2_IS_TMC2130)
  303. stepperY2.init();
  304. stepperY2.set_mres(Y2_MRES);
  305. stepperY2.set_IHOLD_IRUN(Y2_IHOLD,Y2_IRUN,Y2_IHOLDDELAY);
  306. stepperY2.set_I_scale_analog(Y2_ISCALE);
  307. stepperY2.set_tbl(Y2_TBL);
  308. stepperY2.set_toff(Y2_TOFF);
  309. #endif
  310. #if ENABLED(Z_IS_TMC2130)
  311. stepperZ.init();
  312. stepperZ.set_mres(Z_MRES);
  313. stepperZ.set_IHOLD_IRUN(Z_IHOLD,Z_IRUN,Z_IHOLDDELAY);
  314. stepperZ.set_I_scale_analog(Z_ISCALE);
  315. stepperZ.set_tbl(Z_TBL);
  316. stepperZ.set_toff(Z_TOFF);
  317. #endif
  318. #if ENABLED(Z2_IS_TMC2130)
  319. stepperZ2.init();
  320. stepperZ2.set_mres(Z2_MRES);
  321. stepperZ2.set_IHOLD_IRUN(Z2_IHOLD,Z2_IRUN,Z2_IHOLDDELAY);
  322. stepperZ2.set_I_scale_analog(Z2_ISCALE);
  323. stepperZ2.set_tbl(Z2_TBL);
  324. stepperZ2.set_toff(Z2_TOFF);
  325. #endif
  326. #if ENABLED(E0_IS_TMC2130)
  327. stepperE0.init();
  328. stepperE0.set_mres(E0_MRES);
  329. stepperE0.set_IHOLD_IRUN(E0_IHOLD,E0_IRUN,E0_IHOLDDELAY);
  330. stepperE0.set_I_scale_analog(E0_ISCALE);
  331. stepperE0.set_tbl(E0_TBL);
  332. stepperE0.set_toff(E0_TOFF);
  333. #endif
  334. #if ENABLED(E1_IS_TMC2130)
  335. stepperE1.init();
  336. stepperE1.set_mres(E1_MRES);
  337. stepperE1.set_IHOLD_IRUN(E1_IHOLD,E1_IRUN,E1_IHOLDDELAY);
  338. stepperE1.set_I_scale_analog(E1_ISCALE);
  339. stepperE1.set_tbl(E1_TBL);
  340. stepperE1.set_toff(E1_TOFF);
  341. #endif
  342. #if ENABLED(E2_IS_TMC2130)
  343. stepperE2.init();
  344. stepperE2.set_mres(E2_MRES);
  345. stepperE2.set_IHOLD_IRUN(E2_IHOLD,E2_IRUN,E2_IHOLDDELAY);
  346. stepperE2.set_I_scale_analog(E2_ISCALE);
  347. stepperE2.set_tbl(E2_TBL);
  348. stepperE2.set_toff(E2_TOFF);
  349. #endif
  350. #if ENABLED(E3_IS_TMC2130)
  351. stepperE3.init();
  352. stepperE3.set_mres(E3_MRES);
  353. stepperE3.set_IHOLD_IRUN(E3_IHOLD,E3_IRUN,E3_IHOLDDELAY);
  354. stepperE3.set_I_scale_analog(E3_ISCALE);
  355. stepperE3.set_tbl(E3_TBL);
  356. stepperE3.set_toff(E3_TOFF);
  357. #endif
  358. }
  359. #endif // TMC2130_ADVANCED_CONFIGURATION
  360. #endif // HAVE_TMC2130DRIVER
  361. // L6470 Driver objects and inits
  362. #if ENABLED(HAVE_L6470DRIVER)
  363. #include <SPI.h>
  364. #include <L6470.h>
  365. #endif
  366. // L6470 Stepper objects
  367. #if ENABLED(X_IS_L6470)
  368. L6470 stepperX(X_ENABLE_PIN);
  369. #endif
  370. #if ENABLED(X2_IS_L6470)
  371. L6470 stepperX2(X2_ENABLE_PIN);
  372. #endif
  373. #if ENABLED(Y_IS_L6470)
  374. L6470 stepperY(Y_ENABLE_PIN);
  375. #endif
  376. #if ENABLED(Y2_IS_L6470)
  377. L6470 stepperY2(Y2_ENABLE_PIN);
  378. #endif
  379. #if ENABLED(Z_IS_L6470)
  380. L6470 stepperZ(Z_ENABLE_PIN);
  381. #endif
  382. #if ENABLED(Z2_IS_L6470)
  383. L6470 stepperZ2(Z2_ENABLE_PIN);
  384. #endif
  385. #if ENABLED(E0_IS_L6470)
  386. L6470 stepperE0(E0_ENABLE_PIN);
  387. #endif
  388. #if ENABLED(E1_IS_L6470)
  389. L6470 stepperE1(E1_ENABLE_PIN);
  390. #endif
  391. #if ENABLED(E2_IS_L6470)
  392. L6470 stepperE2(E2_ENABLE_PIN);
  393. #endif
  394. #if ENABLED(E3_IS_L6470)
  395. L6470 stepperE3(E3_ENABLE_PIN);
  396. #endif
  397. // init routine
  398. #if ENABLED(HAVE_L6470DRIVER)
  399. void L6470_init() {
  400. #if ENABLED(X_IS_L6470)
  401. stepperX.init(X_K_VAL);
  402. stepperX.softFree();
  403. stepperX.setMicroSteps(X_MICROSTEPS);
  404. stepperX.setOverCurrent(X_OVERCURRENT); //set overcurrent protection
  405. stepperX.setStallCurrent(X_STALLCURRENT);
  406. #endif
  407. #if ENABLED(X2_IS_L6470)
  408. stepperX2.init(X2_K_VAL);
  409. stepperX2.softFree();
  410. stepperX2.setMicroSteps(X2_MICROSTEPS);
  411. stepperX2.setOverCurrent(X2_OVERCURRENT); //set overcurrent protection
  412. stepperX2.setStallCurrent(X2_STALLCURRENT);
  413. #endif
  414. #if ENABLED(Y_IS_L6470)
  415. stepperY.init(Y_K_VAL);
  416. stepperY.softFree();
  417. stepperY.setMicroSteps(Y_MICROSTEPS);
  418. stepperY.setOverCurrent(Y_OVERCURRENT); //set overcurrent protection
  419. stepperY.setStallCurrent(Y_STALLCURRENT);
  420. #endif
  421. #if ENABLED(Y2_IS_L6470)
  422. stepperY2.init(Y2_K_VAL);
  423. stepperY2.softFree();
  424. stepperY2.setMicroSteps(Y2_MICROSTEPS);
  425. stepperY2.setOverCurrent(Y2_OVERCURRENT); //set overcurrent protection
  426. stepperY2.setStallCurrent(Y2_STALLCURRENT);
  427. #endif
  428. #if ENABLED(Z_IS_L6470)
  429. stepperZ.init(Z_K_VAL);
  430. stepperZ.softFree();
  431. stepperZ.setMicroSteps(Z_MICROSTEPS);
  432. stepperZ.setOverCurrent(Z_OVERCURRENT); //set overcurrent protection
  433. stepperZ.setStallCurrent(Z_STALLCURRENT);
  434. #endif
  435. #if ENABLED(Z2_IS_L6470)
  436. stepperZ2.init(Z2_K_VAL);
  437. stepperZ2.softFree();
  438. stepperZ2.setMicroSteps(Z2_MICROSTEPS);
  439. stepperZ2.setOverCurrent(Z2_OVERCURRENT); //set overcurrent protection
  440. stepperZ2.setStallCurrent(Z2_STALLCURRENT);
  441. #endif
  442. #if ENABLED(E0_IS_L6470)
  443. stepperE0.init(E0_K_VAL);
  444. stepperE0.softFree();
  445. stepperE0.setMicroSteps(E0_MICROSTEPS);
  446. stepperE0.setOverCurrent(E0_OVERCURRENT); //set overcurrent protection
  447. stepperE0.setStallCurrent(E0_STALLCURRENT);
  448. #endif
  449. #if ENABLED(E1_IS_L6470)
  450. stepperE1.init(E1_K_VAL);
  451. stepperE1.softFree();
  452. stepperE1.setMicroSteps(E1_MICROSTEPS);
  453. stepperE1.setOverCurrent(E1_OVERCURRENT); //set overcurrent protection
  454. stepperE1.setStallCurrent(E1_STALLCURRENT);
  455. #endif
  456. #if ENABLED(E2_IS_L6470)
  457. stepperE2.init(E2_K_VAL);
  458. stepperE2.softFree();
  459. stepperE2.setMicroSteps(E2_MICROSTEPS);
  460. stepperE2.setOverCurrent(E2_OVERCURRENT); //set overcurrent protection
  461. stepperE2.setStallCurrent(E2_STALLCURRENT);
  462. #endif
  463. #if ENABLED(E3_IS_L6470)
  464. stepperE3.init(E3_K_VAL);
  465. stepperE3.softFree();
  466. stepperE3.setMicroSteps(E3_MICROSTEPS);
  467. stepperE3.setOverCurrent(E3_OVERCURRENT); //set overcurrent protection
  468. stepperE3.setStallCurrent(E3_STALLCURRENT);
  469. #endif
  470. }
  471. #endif