Add TMC2130 support

This commit is contained in:
Moritz
2016-09-14 08:48:47 +02:00
committed by Scott Lahteine
parent 79c8591192
commit d67c1d825f
24 changed files with 4226 additions and 72 deletions

View File

@ -53,6 +53,13 @@
void tmc_init();
#endif
// TMC130 drivers have STEP/DIR/ENABLE on normal pins
#if ENABLED(HAVE_TMC2130DRIVER)
#include <SPI.h>
#include <Trinamic_TMC2130.h>
void tmc2130_init();
#endif
// L6470 has STEP on normal pins, but DIR/ENABLE via SPI
#if ENABLED(HAVE_L6470DRIVER)
#include <SPI.h>
@ -76,6 +83,9 @@
#define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
#define X_ENABLE_READ stepperX.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(X_IS_TMC2130)
extern Trinamic_TMC2130 stepperX;
#endif
#define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
#define X_ENABLE_WRITE(STATE) WRITE(X_ENABLE_PIN,STATE)
#define X_ENABLE_READ READ(X_ENABLE_PIN)
@ -104,6 +114,9 @@
#define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
#define Y_ENABLE_READ stepperY.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Y_IS_TMC2130)
extern Trinamic_TMC2130 stepperY;
#endif
#define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
#define Y_ENABLE_WRITE(STATE) WRITE(Y_ENABLE_PIN,STATE)
#define Y_ENABLE_READ READ(Y_ENABLE_PIN)
@ -132,6 +145,9 @@
#define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
#define Z_ENABLE_READ stepperZ.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Z_IS_TMC2130)
extern Trinamic_TMC2130 stepperZ;
#endif
#define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
#define Z_ENABLE_WRITE(STATE) WRITE(Z_ENABLE_PIN,STATE)
#define Z_ENABLE_READ READ(Z_ENABLE_PIN)
@ -161,6 +177,9 @@
#define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
#define X2_ENABLE_READ stepperX2.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(X2_IS_TMC2130)
extern Trinamic_TMC2130 stepperX2;
#endif
#define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
#define X2_ENABLE_WRITE(STATE) WRITE(X2_ENABLE_PIN,STATE)
#define X2_ENABLE_READ READ(X2_ENABLE_PIN)
@ -191,6 +210,9 @@
#define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
#define Y2_ENABLE_READ stepperY2.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Y2_IS_TMC2130)
extern Trinamic_TMC2130 stepperY2;
#endif
#define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
#define Y2_ENABLE_WRITE(STATE) WRITE(Y2_ENABLE_PIN,STATE)
#define Y2_ENABLE_READ READ(Y2_ENABLE_PIN)
@ -221,6 +243,9 @@
#define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
#define Z2_ENABLE_READ stepperZ2.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(Z2_IS_TMC2130)
extern Trinamic_TMC2130 stepperZ2;
#endif
#define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
#define Z2_ENABLE_WRITE(STATE) WRITE(Z2_ENABLE_PIN,STATE)
#define Z2_ENABLE_READ READ(Z2_ENABLE_PIN)
@ -250,6 +275,9 @@
#define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
#define E0_ENABLE_READ stepperE0.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(E0_IS_TMC2130)
extern Trinamic_TMC2130 stepperE0;
#endif
#define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
#define E0_ENABLE_WRITE(STATE) WRITE(E0_ENABLE_PIN,STATE)
#define E0_ENABLE_READ READ(E0_ENABLE_PIN)
@ -278,6 +306,9 @@
#define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
#define E1_ENABLE_READ stepperE1.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(E1_IS_TMC2130)
extern Trinamic_TMC2130 stepperE1;
#endif
#define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
#define E1_ENABLE_WRITE(STATE) WRITE(E1_ENABLE_PIN,STATE)
#define E1_ENABLE_READ READ(E1_ENABLE_PIN)
@ -306,6 +337,9 @@
#define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
#define E2_ENABLE_READ stepperE2.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(E2_IS_TMC2130)
extern Trinamic_TMC2130 stepperE2;
#endif
#define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
#define E2_ENABLE_WRITE(STATE) WRITE(E2_ENABLE_PIN,STATE)
#define E2_ENABLE_READ READ(E2_ENABLE_PIN)
@ -334,6 +368,9 @@
#define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
#define E3_ENABLE_READ stepperE3.isEnabled()
#else
#if ENABLED(HAVE_TMC2130DRIVER) && ENABLED(E3_IS_TMC2130)
extern Trinamic_TMC2130 stepperE3;
#endif
#define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
#define E3_ENABLE_WRITE(STATE) WRITE(E3_ENABLE_PIN,STATE)
#define E3_ENABLE_READ READ(E3_ENABLE_PIN)