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.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (c) 2019 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/L6470.cpp
  24. * Stepper driver indirection for L6470 drivers
  25. */
  26. #include "../../inc/MarlinConfig.h"
  27. #if HAS_DRIVER(L6470)
  28. #include "L6470.h"
  29. #define _L6470_DEFINE(ST) L6470 stepper##ST((const int)L6470_CHAIN_SS_PIN)
  30. // L6470 Stepper objects
  31. #if AXIS_DRIVER_TYPE_X(L6470)
  32. _L6470_DEFINE(X);
  33. #endif
  34. #if AXIS_DRIVER_TYPE_X2(L6470)
  35. _L6470_DEFINE(X2);
  36. #endif
  37. #if AXIS_DRIVER_TYPE_Y(L6470)
  38. _L6470_DEFINE(Y);
  39. #endif
  40. #if AXIS_DRIVER_TYPE_Y2(L6470)
  41. _L6470_DEFINE(Y2);
  42. #endif
  43. #if AXIS_DRIVER_TYPE_Z(L6470)
  44. _L6470_DEFINE(Z);
  45. #endif
  46. #if AXIS_DRIVER_TYPE_Z2(L6470)
  47. _L6470_DEFINE(Z2);
  48. #endif
  49. #if AXIS_DRIVER_TYPE_Z3(L6470)
  50. _L6470_DEFINE(Z3);
  51. #endif
  52. #if AXIS_DRIVER_TYPE_E0(L6470)
  53. _L6470_DEFINE(E0);
  54. #endif
  55. #if AXIS_DRIVER_TYPE_E1(L6470)
  56. _L6470_DEFINE(E1);
  57. #endif
  58. #if AXIS_DRIVER_TYPE_E2(L6470)
  59. _L6470_DEFINE(E2);
  60. #endif
  61. #if AXIS_DRIVER_TYPE_E3(L6470)
  62. _L6470_DEFINE(E3);
  63. #endif
  64. #if AXIS_DRIVER_TYPE_E4(L6470)
  65. _L6470_DEFINE(E4);
  66. #endif
  67. #if AXIS_DRIVER_TYPE_E5(L6470)
  68. _L6470_DEFINE(E5);
  69. #endif
  70. // not using L6470 library's init command because it
  71. // briefly sends power to the steppers
  72. #define _L6470_INIT_CHIP(Q) do{ \
  73. stepper##Q.resetDev(); \
  74. stepper##Q.softFree(); \
  75. stepper##Q.SetParam(L6470_CONFIG, CONFIG_PWM_DIV_1 \
  76. | CONFIG_PWM_MUL_2 \
  77. | CONFIG_SR_290V_us \
  78. | CONFIG_OC_SD_DISABLE \
  79. | CONFIG_VS_COMP_DISABLE \
  80. | CONFIG_SW_HARD_STOP \
  81. | CONFIG_INT_16MHZ); \
  82. stepper##Q.SetParam(L6470_KVAL_RUN, 0xFF); \
  83. stepper##Q.SetParam(L6470_KVAL_ACC, 0xFF); \
  84. stepper##Q.SetParam(L6470_KVAL_DEC, 0xFF); \
  85. stepper##Q.setMicroSteps(Q##_MICROSTEPS); \
  86. stepper##Q.setOverCurrent(Q##_OVERCURRENT); \
  87. stepper##Q.setStallCurrent(Q##_STALLCURRENT); \
  88. stepper##Q.SetParam(L6470_KVAL_HOLD, Q##_MAX_VOLTAGE); \
  89. stepper##Q.SetParam(L6470_ABS_POS, 0); \
  90. stepper##Q.getStatus(); \
  91. }while(0)
  92. void L6470_Marlin::init_to_defaults() {
  93. #if AXIS_DRIVER_TYPE_X(L6470)
  94. _L6470_INIT_CHIP(X);
  95. #endif
  96. #if AXIS_DRIVER_TYPE_X2(L6470)
  97. _L6470_INIT_CHIP(X2);
  98. #endif
  99. #if AXIS_DRIVER_TYPE_Y(L6470)
  100. _L6470_INIT_CHIP(Y);
  101. #endif
  102. #if AXIS_DRIVER_TYPE_Y2(L6470)
  103. _L6470_INIT_CHIP(Y2);
  104. #endif
  105. #if AXIS_DRIVER_TYPE_Z(L6470)
  106. _L6470_INIT_CHIP(Z);
  107. #endif
  108. #if AXIS_DRIVER_TYPE_Z2(L6470)
  109. _L6470_INIT_CHIP(Z2);
  110. #endif
  111. #if AXIS_DRIVER_TYPE_Z3(L6470)
  112. _L6470_INIT_CHIP(Z3);
  113. #endif
  114. #if AXIS_DRIVER_TYPE_E0(L6470)
  115. _L6470_INIT_CHIP(E0);
  116. #endif
  117. #if AXIS_DRIVER_TYPE_E1(L6470)
  118. _L6470_INIT_CHIP(E1);
  119. #endif
  120. #if AXIS_DRIVER_TYPE_E2(L6470)
  121. _L6470_INIT_CHIP(E2);
  122. #endif
  123. #if AXIS_DRIVER_TYPE_E3(L6470)
  124. _L6470_INIT_CHIP(E3);
  125. #endif
  126. #if AXIS_DRIVER_TYPE_E4(L6470)
  127. _L6470_INIT_CHIP(E4);
  128. #endif
  129. #if AXIS_DRIVER_TYPE_E5(L6470)
  130. _L6470_INIT_CHIP(E5);
  131. #endif
  132. }
  133. #endif // L6470