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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /*
  2. stepper_indirection.c - stepper motor driver indirection
  3. to allow some stepper functions to be done via SPI/I2c instead of direct pin manipulation
  4. Part of Marlin
  5. Copyright (c) 2015 Dominik Wenger
  6. Marlin is free software: you can redistribute it and/or modify
  7. it under the terms of the GNU General Public License as published by
  8. the Free Software Foundation, either version 3 of the License, or
  9. (at your option) any later version.
  10. Marlin is distributed in the hope that it will be useful,
  11. but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. GNU General Public License for more details.
  14. You should have received a copy of the GNU General Public License
  15. along with Marlin. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include "stepper_indirection.h"
  18. #include "Configuration.h"
  19. #ifdef HAVE_TMCDRIVER
  20. #include <SPI.h>
  21. #include <TMC26XStepper.h>
  22. #endif
  23. // Stepper objects of TMC steppers used
  24. #ifdef X_IS_TMC
  25. TMC26XStepper stepperX(200,X_ENABLE_PIN,X_STEP_PIN,X_DIR_PIN,X_MAX_CURRENT,X_SENSE_RESISTOR);
  26. #endif
  27. #ifdef X2_IS_TMC
  28. TMC26XStepper stepperX2(200,X2_ENABLE_PIN,X2_STEP_PIN,X2_DIR_PIN,X2_MAX_CURRENT,X2_SENSE_RESISTOR);
  29. #endif
  30. #ifdef Y_IS_TMC
  31. TMC26XStepper stepperY(200,Y_ENABLE_PIN,Y_STEP_PIN,Y_DIR_PIN,Y_MAX_CURRENT,Y_SENSE_RESISTOR);
  32. #endif
  33. #ifdef Y2_IS_TMC
  34. TMC26XStepper stepperY2(200,Y2_ENABLE_PIN,Y2_STEP_PIN,Y2_DIR_PIN,Y2_MAX_CURRENT,Y2_SENSE_RESISTOR);
  35. #endif
  36. #ifdef Z_IS_TMC
  37. TMC26XStepper stepperZ(200,Z_ENABLE_PIN,Z_STEP_PIN,Z_DIR_PIN,Z_MAX_CURRENT,Z_SENSE_RESISTOR);
  38. #endif
  39. #ifdef Z2_IS_TMC
  40. TMC26XStepper stepperZ2(200,Z2_ENABLE_PIN,Z2_STEP_PIN,Z2_DIR_PIN,Z2_MAX_CURRENT,Z2_SENSE_RESISTOR);
  41. #endif
  42. #ifdef E0_IS_TMC
  43. TMC26XStepper stepperE0(200,E0_ENABLE_PIN,E0_STEP_PIN,E0_DIR_PIN,E0_MAX_CURRENT,E0_SENSE_RESISTOR);
  44. #endif
  45. #ifdef E1_IS_TMC
  46. TMC26XStepper stepperE1(200,E1_ENABLE_PIN,E1_STEP_PIN,E1_DIR_PIN,E1_MAX_CURRENT,E1_SENSE_RESISTOR);
  47. #endif
  48. #ifdef E2_IS_TMC
  49. TMC26XStepper stepperE2(200,E2_ENABLE_PIN,E2_STEP_PIN,E2_DIR_PIN,E2_MAX_CURRENT,E2_SENSE_RESISTOR);
  50. #endif
  51. #ifdef E3_IS_TMC
  52. TMC26XStepper stepperE3(200,E3_ENABLE_PIN,E3_STEP_PIN,E3_DIR_PIN,E3_MAX_CURRENT,E3_SENSE_RESISTOR);
  53. #endif
  54. #ifdef HAVE_TMCDRIVER
  55. void tmc_init()
  56. {
  57. #ifdef X_IS_TMC
  58. stepperX.setMicrosteps(X_MICROSTEPS);
  59. stepperX.start();
  60. #endif
  61. #ifdef X2_IS_TMC
  62. stepperX2.setMicrosteps(X2_MICROSTEPS);
  63. stepperX2.start();
  64. #endif
  65. #ifdef Y_IS_TMC
  66. stepperY.setMicrosteps(Y_MICROSTEPS);
  67. stepperY.start();
  68. #endif
  69. #ifdef Y2_IS_TMC
  70. stepperY2.setMicrosteps(Y2_MICROSTEPS);
  71. stepperY2.start();
  72. #endif
  73. #ifdef Z_IS_TMC
  74. stepperZ.setMicrosteps(Z_MICROSTEPS);
  75. stepperZ.start();
  76. #endif
  77. #ifdef Z2_IS_TMC
  78. stepperZ2.setMicrosteps(Z2_MICROSTEPS);
  79. stepperZ2.start();
  80. #endif
  81. #ifdef E0_IS_TMC
  82. stepperE0.setMicrosteps(E0_MICROSTEPS);
  83. stepperE0.start();
  84. #endif
  85. #ifdef E1_IS_TMC
  86. stepperE1.setMicrosteps(E1_MICROSTEPS);
  87. stepperE1.start();
  88. #endif
  89. #ifdef E2_IS_TMC
  90. stepperE2.setMicrosteps(E2_MICROSTEPS);
  91. stepperE2.start();
  92. #endif
  93. #ifdef E3_IS_TMC
  94. stepperE3.setMicrosteps(E3_MICROSTEPS);
  95. stepperE3.start();
  96. #endif
  97. }
  98. #endif