My Marlin configs for Fabrikator Mini and CTC i3 Pro B
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

stepper_indirection.h 7.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. /*
  2. stepper_indirection.h - stepper motor driver indirection macros
  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. #ifndef STEPPER_INDIRECTION_H
  18. #define STEPPER_INDIRECTION_H
  19. // X motor
  20. #define X_STEP_INIT SET_OUTPUT(X_STEP_PIN)
  21. #define X_STEP_WRITE(STATE) WRITE(X_STEP_PIN,STATE)
  22. #define X_STEP_READ READ(X_STEP_PIN)
  23. #define X_DIR_INIT SET_OUTPUT(X_DIR_PIN)
  24. #define X_DIR_WRITE(STATE) WRITE(X_DIR_PIN,STATE)
  25. #define X_DIR_READ READ(X_DIR_PIN)
  26. #define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
  27. #define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
  28. #define X_ENABLE_READ READ(X_ENABLE_PIN)
  29. // X2 motor
  30. #define X2_STEP_INIT SET_OUTPUT(X2_STEP_PIN)
  31. #define X2_STEP_WRITE(STATE) WRITE(X2_STEP_PIN,STATE)
  32. #define X2_STEP_READ READ(X2_STEP_PIN)
  33. #define X2_DIR_INIT SET_OUTPUT(X2_DIR_PIN)
  34. #define X2_DIR_WRITE(STATE) WRITE(X2_DIR_PIN,STATE)
  35. #define X2_DIR_READ READ(X_DIR_PIN)
  36. #define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
  37. #define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
  38. #define X2_ENABLE_READ READ(X_ENABLE_PIN)
  39. // Y motor
  40. #define Y_STEP_INIT SET_OUTPUT(Y_STEP_PIN)
  41. #define Y_STEP_WRITE(STATE) WRITE(Y_STEP_PIN,STATE)
  42. #define Y_STEP_READ READ(Y_STEP_PIN)
  43. #define Y_DIR_INIT SET_OUTPUT(Y_DIR_PIN)
  44. #define Y_DIR_WRITE(STATE) WRITE(Y_DIR_PIN,STATE)
  45. #define Y_DIR_READ READ(Y_DIR_PIN)
  46. #define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
  47. #define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
  48. #define Y_ENABLE_READ READ(Y_ENABLE_PIN)
  49. // Y2 motor
  50. #define Y2_STEP_INIT SET_OUTPUT(Y2_STEP_PIN)
  51. #define Y2_STEP_WRITE(STATE) WRITE(Y2_STEP_PIN,STATE)
  52. #define Y2_STEP_READ READ(Y2_STEP_PIN)
  53. #define Y2_DIR_INIT SET_OUTPUT(Y2_DIR_PIN)
  54. #define Y2_DIR_WRITE(STATE) WRITE(Y2_DIR_PIN,STATE)
  55. #define Y2_DIR_READ READ(Y2_DIR_PIN)
  56. #define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
  57. #define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
  58. #define Y2_ENABLE_READ READ(Y2_ENABLE_PIN)
  59. // Z motor
  60. #define Z_STEP_INIT SET_OUTPUT(Z_STEP_PIN)
  61. #define Z_STEP_WRITE(STATE) WRITE(Z_STEP_PIN,STATE)
  62. #define Z_STEP_READ READ(Z_STEP_PIN)
  63. #define Z_DIR_INIT SET_OUTPUT(Z_DIR_PIN)
  64. #define Z_DIR_WRITE(STATE) WRITE(Z_DIR_PIN,STATE)
  65. #define Z_DIR_READ READ(Z_DIR_PIN)
  66. #define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
  67. #define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
  68. #define Z_ENABLE_READ READ(Z_ENABLE_PIN)
  69. // Z2 motor
  70. #define Z2_STEP_INIT SET_OUTPUT(Z2_STEP_PIN)
  71. #define Z2_STEP_WRITE(STATE) WRITE(Z2_STEP_PIN,STATE)
  72. #define Z2_STEP_READ READ(Z2_STEP_PIN)
  73. #define Z2_DIR_INIT SET_OUTPUT(Z2_DIR_PIN)
  74. #define Z2_DIR_WRITE(STATE) WRITE(Z2_DIR_PIN,STATE)
  75. #define Z2_DIR_READ READ(Z2_DIR_PIN)
  76. #define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
  77. #define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
  78. #define Z2_ENABLE_READ READ(Z2_ENABLE_PIN)
  79. // E0 motor
  80. #define E0_STEP_INIT SET_OUTPUT(E0_STEP_PIN)
  81. #define E0_STEP_WRITE(STATE) WRITE(E0_STEP_PIN,STATE)
  82. #define E0_STEP_READ READ(E0_STEP_PIN)
  83. #define E0_DIR_INIT SET_OUTPUT(E0_DIR_PIN)
  84. #define E0_DIR_WRITE(STATE) WRITE(E0_DIR_PIN,STATE)
  85. #define E0_DIR_READ READ(E0_DIR_PIN)
  86. #define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
  87. #define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
  88. #define E0_ENABLE_READ READ(E0_ENABLE_PIN)
  89. // E1 motor
  90. #define E1_STEP_INIT SET_OUTPUT(E1_STEP_PIN)
  91. #define E1_STEP_WRITE(STATE) WRITE(E1_STEP_PIN,STATE)
  92. #define E1_STEP_READ READ(E1_STEP_PIN)
  93. #define E1_DIR_INIT SET_OUTPUT(E1_DIR_PIN)
  94. #define E1_DIR_WRITE(STATE) WRITE(E1_DIR_PIN,STATE)
  95. #define E1_DIR_READ READ(E1_DIR_PIN)
  96. #define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
  97. #define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
  98. #define E1_ENABLE_READ READ(E1_ENABLE_PIN)
  99. // E2 motor
  100. #define E2_STEP_INIT SET_OUTPUT(E2_STEP_PIN)
  101. #define E2_STEP_WRITE(STATE) WRITE(E2_STEP_PIN,STATE)
  102. #define E2_STEP_READ READ(E2_STEP_PIN)
  103. #define E2_DIR_INIT SET_OUTPUT(E2_DIR_PIN)
  104. #define E2_DIR_WRITE(STATE) WRITE(E2_DIR_PIN,STATE)
  105. #define E2_DIR_READ READ(E2_DIR_PIN)
  106. #define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
  107. #define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
  108. #define E2_ENABLE_READ READ(E2_ENABLE_PIN)
  109. // E3 motor
  110. #define E3_STEP_INIT SET_OUTPUT(E3_STEP_PIN)
  111. #define E3_STEP_WRITE(STATE) WRITE(E3_STEP_PIN,STATE)
  112. #define E3_STEP_READ READ(E3_STEP_PIN)
  113. #define E3_DIR_INIT SET_OUTPUT(E3_DIR_PIN)
  114. #define E3_DIR_WRITE(STATE) WRITE(E3_DIR_PIN,STATE)
  115. #define E3_DIR_READ READ(E3_DIR_PIN)
  116. #define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
  117. #define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
  118. #define E3_ENABLE_READ READ(E3_ENABLE_PIN)
  119. //////////////////////////////////
  120. // Pin redefines for TMC drivers.
  121. // TMC26X drivers have step and dir on normal pins, but everything else via SPI
  122. //////////////////////////////////
  123. #ifdef HAVE_TMCDRIVER
  124. #ifdef X_IS_TMC
  125. #undef X_ENABLE_INIT
  126. #define X_ENABLE_INIT
  127. #undef X_ENABLE_WRITE
  128. #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
  129. #undef X_ENABLE_READ
  130. #define X_ENABLE_READ stepperX.isEnabled()
  131. #endif
  132. #ifdef X2_IS_TMC
  133. #undef X2_ENABLE_INIT
  134. #define X2_ENABLE_INIT
  135. #undef X2_ENABLE_WRITE
  136. #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
  137. #undef X2_ENABLE_READ
  138. #define X2_ENABLE_READ stepperX2.isEnabled()
  139. #endif
  140. #ifdef Y_IS_TMC
  141. #undef Y_ENABLE_INIT
  142. #define Y_ENABLE_INIT
  143. #undef Y_ENABLE_WRITE
  144. #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
  145. #undef Y_ENABLE_READ
  146. #define Y_ENABLE_READ stepperY.isEnabled()
  147. #endif
  148. #ifdef Y2_IS_TMC
  149. #undef Y2_ENABLE_INIT
  150. #define Y2_ENABLE_INIT
  151. #undef Y2_ENABLE_WRITE
  152. #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
  153. #undef Y2_ENABLE_READ
  154. #define Y2_ENABLE_READ stepperY2.isEnabled()
  155. #endif
  156. #ifdef Z_IS_TMC
  157. #undef Z_ENABLE_INIT
  158. #define Z_ENABLE_INIT
  159. #undef Z_ENABLE_WRITE
  160. #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
  161. #undef Z_ENABLE_READ
  162. #define Z_ENABLE_READ stepperZ.isEnabled()
  163. #endif
  164. #ifdef Z2_IS_TMC
  165. #undef Z2_ENABLE_INIT
  166. #define Z2_ENABLE_INIT
  167. #undef Z2_ENABLE_WRITE
  168. #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
  169. #undef Z2_ENABLE_READ
  170. #define Z2_ENABLE_READ stepperZ2.isEnabled()
  171. #endif
  172. #ifdef E0_IS_TMC
  173. #undef E0_ENABLE_INIT
  174. #define E0_ENABLE_INIT
  175. #undef E0_ENABLE_WRITE
  176. #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
  177. #undef E0_ENABLE_READ
  178. #define E0_ENABLE_READ stepperE0.isEnabled()
  179. #endif
  180. #ifdef E1_IS_TMC
  181. #undef E1_ENABLE_INIT
  182. #define E1_ENABLE_INIT
  183. #undef E1_ENABLE_WRITE
  184. #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
  185. #undef E1_ENABLE_READ
  186. #define E1_ENABLE_READ stepperE1.isEnabled()
  187. #endif
  188. #ifdef E2_IS_TMC
  189. #undef E2_ENABLE_INIT
  190. #define E2_ENABLE_INIT
  191. #undef E2_ENABLE_WRITE
  192. #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
  193. #undef E2_ENABLE_READ
  194. #define E2_ENABLE_READ stepperE2.isEnabled()
  195. #endif
  196. #ifdef E3_IS_TMC
  197. #undef E3_ENABLE_INIT
  198. #define E3_ENABLE_INIT
  199. #undef E3_ENABLE_WRITE
  200. #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
  201. #undef E3_ENABLE_READ
  202. #define E3_ENABLE_READ stepperE3.isEnabled()
  203. #endif
  204. #endif
  205. #endif