Merge pull request #10102 from thinkyhead/bf2_eeprom_M913

[2.0.x] More complete Trinamic driver options
This commit is contained in:
Scott Lahteine 2018-03-20 23:14:19 -05:00 committed by GitHub
commit 8dfaf1539e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 745 additions and 416 deletions

View File

@ -88,6 +88,11 @@ void Power::check() {
void Power::power_on() { void Power::power_on() {
lastPowerOn = millis(); lastPowerOn = millis();
PSU_PIN_ON(); PSU_PIN_ON();
#if HAS_TRINAMIC
delay(100); // Wait for power to settle
restore_stepper_drivers();
#endif
} }
void Power::power_off() { void Power::power_off() {

View File

@ -331,6 +331,7 @@ void _tmc_say_sgt(const TMC_AxisEnum axis, const int8_t sgt) {
} }
} }
#endif #endif
#if ENABLED(HAVE_TMC2208) #if ENABLED(HAVE_TMC2208)
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) { static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) { switch (i) {

View File

@ -35,7 +35,7 @@
extern bool report_tmc_status; extern bool report_tmc_status;
enum TMC_AxisEnum : char { TMC_X, TMC_X2, TMC_Y, TMC_Y2, TMC_Z, TMC_Z2, TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4 }; enum TMC_AxisEnum : char { TMC_X, TMC_Y, TMC_Z, TMC_X2, TMC_Y2, TMC_Z2, TMC_E0, TMC_E1, TMC_E2, TMC_E3, TMC_E4 };
constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) { constexpr uint32_t _tmc_thrs(const uint16_t msteps, const int32_t thrs, const uint32_t spmm) {
return 12650000UL * msteps / (256 * thrs * spmm); return 12650000UL * msteps / (256 * thrs * spmm);
@ -55,7 +55,6 @@ void tmc_get_current(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC> template<typename TMC>
void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) { void tmc_set_current(TMC &st, const TMC_AxisEnum axis, const int mA) {
st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER); st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
tmc_get_current(st, axis);
} }
template<typename TMC> template<typename TMC>
void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) { void tmc_report_otpw(TMC &st, const TMC_AxisEnum axis) {
@ -73,7 +72,6 @@ void tmc_get_pwmthrs(TMC &st, const TMC_AxisEnum axis, const uint16_t spmm) {
template<typename TMC> template<typename TMC>
void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) { void tmc_set_pwmthrs(TMC &st, const TMC_AxisEnum axis, const int32_t thrs, const uint32_t spmm) {
st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm)); st.TPWMTHRS(_tmc_thrs(st.microsteps(), thrs, spmm));
tmc_get_pwmthrs(st, axis, spmm);
} }
template<typename TMC> template<typename TMC>
void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) { void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
@ -82,7 +80,6 @@ void tmc_get_sgt(TMC &st, const TMC_AxisEnum axis) {
template<typename TMC> template<typename TMC>
void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) { void tmc_set_sgt(TMC &st, const TMC_AxisEnum axis, const int8_t sgt_val) {
st.sgt(sgt_val); st.sgt(sgt_val);
tmc_get_sgt(st, axis);
} }
void monitor_tmc_driver(); void monitor_tmc_driver();

View File

@ -76,14 +76,9 @@
OUT_WRITE(SUICIDE_PIN, HIGH); OUT_WRITE(SUICIDE_PIN, HIGH);
#endif #endif
#if ENABLED(HAVE_TMC2130) #if DISABLED(AUTO_POWER_CONTROL)
delay(100); delay(100); // Wait for power to settle
tmc2130_init(); // Settings only stick when the driver has power restore_stepper_drivers();
#endif
#if ENABLED(HAVE_TMC2208)
delay(100);
tmc2208_init();
#endif #endif
#if ENABLED(ULTIPANEL) #if ENABLED(ULTIPANEL)

View File

@ -33,46 +33,104 @@
* Report driver currents when no axis specified * Report driver currents when no axis specified
*/ */
void GcodeSuite::M906() { void GcodeSuite::M906() {
uint16_t values[XYZE]; #define TMC_SAY_CURRENT(Q) tmc_get_current(stepper##Q, TMC_##Q)
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]); #define TMC_SET_CURRENT(Q) tmc_set_current(stepper##Q, TMC_##Q, value)
#define TMC_SET_GET_CURRENT(P,Q) do { \
if (values[P##_AXIS]) tmc_set_current(stepper##Q, TMC_##Q, values[P##_AXIS]); \
else tmc_get_current(stepper##Q, TMC_##Q); } while(0)
bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZE(i) if (uint16_t value = parser.intval(axis_codes[i])) {
report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SET_GET_CURRENT(X,X); if (index == 0) TMC_SET_CURRENT(X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SET_GET_CURRENT(X,X2); if (index == 1) TMC_SET_CURRENT(X2);
#endif #endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SET_GET_CURRENT(Y,Y); if (index == 0) TMC_SET_CURRENT(Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SET_GET_CURRENT(Y,Y2); if (index == 1) TMC_SET_CURRENT(Y2);
#endif #endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_GET_CURRENT(Z,Z); if (index == 0) TMC_SET_CURRENT(Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_GET_CURRENT(Z,Z2); if (index == 1) TMC_SET_CURRENT(Z2);
#endif #endif
break;
case E_AXIS: {
if (get_target_extruder_from_command()) return;
switch (target_extruder) {
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E0); case 0: TMC_SET_CURRENT(E0); break;
#endif #endif
#if E1_IS_TRINAMIC #if E1_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E1); case 1: TMC_SET_CURRENT(E1); break;
#endif #endif
#if E2_IS_TRINAMIC #if E2_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E2); case 2: TMC_SET_CURRENT(E2); break;
#endif #endif
#if E3_IS_TRINAMIC #if E3_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E3); case 3: TMC_SET_CURRENT(E3); break;
#endif #endif
#if E4_IS_TRINAMIC #if E4_IS_TRINAMIC
TMC_SET_GET_CURRENT(E,E4); case 4: TMC_SET_CURRENT(E4); break;
#endif #endif
}
} break;
}
}
if (report) LOOP_XYZE(i) switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SAY_CURRENT(X);
#endif
#if X2_IS_TRINAMIC
TMC_SAY_CURRENT(X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SAY_CURRENT(Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SAY_CURRENT(Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SAY_CURRENT(Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SAY_CURRENT(Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SAY_CURRENT(E0);
#endif
#if E1_IS_TRINAMIC
TMC_SAY_CURRENT(E1);
#endif
#if E2_IS_TRINAMIC
TMC_SAY_CURRENT(E2);
#endif
#if E3_IS_TRINAMIC
TMC_SAY_CURRENT(E3);
#endif
#if E4_IS_TRINAMIC
TMC_SAY_CURRENT(E4);
#endif
break;
}
} }
#endif // HAS_TRINAMIC #endif // HAS_TRINAMIC

View File

@ -80,47 +80,107 @@ void GcodeSuite::M912() {
*/ */
#if ENABLED(HYBRID_THRESHOLD) #if ENABLED(HYBRID_THRESHOLD)
void GcodeSuite::M913() { void GcodeSuite::M913() {
uint16_t values[XYZE]; #define TMC_SAY_PWMTHRS(P,Q) tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS])
LOOP_XYZE(i) values[i] = parser.intval(axis_codes[i]); #define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, TMC_##Q, value, planner.axis_steps_per_mm[P##_AXIS])
#define TMC_SAY_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_get_pwmthrs(stepperE##E, TMC_E##E, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
#define TMC_SET_GET_PWMTHRS(P,Q) do { \ #define TMC_SET_PWMTHRS_E(E) do{ const uint8_t extruder = E; tmc_set_pwmthrs(stepperE##E, TMC_E##E, value, planner.axis_steps_per_mm[E_AXIS_N]); }while(0)
if (values[P##_AXIS]) tmc_set_pwmthrs(stepper##Q, TMC_##Q, values[P##_AXIS], planner.axis_steps_per_mm[P##_AXIS]); \
else tmc_get_pwmthrs(stepper##Q, TMC_##Q, planner.axis_steps_per_mm[P##_AXIS]); } while(0)
bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZE(i) if (int32_t value = parser.longval(axis_codes[i])) {
report = false;
switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(X,X); if (index == 0) TMC_SET_PWMTHRS(X,X);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(X,X2); if (index == 1) TMC_SET_PWMTHRS(X,X2);
#endif #endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Y,Y); if (index == 0) TMC_SET_PWMTHRS(Y,Y);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Y,Y2); if (index == 1) TMC_SET_PWMTHRS(Y,Y2);
#endif #endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Z,Z); if (index == 0) TMC_SET_PWMTHRS(Z,Z);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(Z,Z2); if (index == 1) TMC_SET_PWMTHRS(Z,Z2);
#endif #endif
break;
case E_AXIS: {
if (get_target_extruder_from_command()) return;
switch (target_extruder) {
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E0); case 0: TMC_SET_PWMTHRS_E(0); break;
#endif #endif
#if E1_IS_TRINAMIC #if E_STEPPERS > 1 && E1_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E1); case 1: TMC_SET_PWMTHRS_E(1); break;
#endif #endif
#if E2_IS_TRINAMIC #if E_STEPPERS > 2 && E2_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E2); case 2: TMC_SET_PWMTHRS_E(2); break;
#endif #endif
#if E3_IS_TRINAMIC #if E_STEPPERS > 3 && E3_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E3); case 3: TMC_SET_PWMTHRS_E(3); break;
#endif #endif
#if E4_IS_TRINAMIC #if E_STEPPERS > 4 && E4_IS_TRINAMIC
TMC_SET_GET_PWMTHRS(E,E4); case 4: TMC_SET_PWMTHRS_E(4); break;
#endif #endif
} }
} break;
}
}
if (report) LOOP_XYZE(i) switch (i) {
case X_AXIS:
#if X_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X);
#endif
#if X2_IS_TRINAMIC
TMC_SAY_PWMTHRS(X,X2);
#endif
break;
case Y_AXIS:
#if Y_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y);
#endif
#if Y2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Y,Y2);
#endif
break;
case Z_AXIS:
#if Z_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z);
#endif
#if Z2_IS_TRINAMIC
TMC_SAY_PWMTHRS(Z,Z2);
#endif
break;
case E_AXIS:
#if E0_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(0);
#endif
#if E_STEPPERS > 1 && E1_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(1);
#endif
#if E_STEPPERS > 2 && E2_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(2);
#endif
#if E_STEPPERS > 3 && E3_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(3);
#endif
#if E_STEPPERS > 4 && E4_IS_TRINAMIC
TMC_SAY_PWMTHRS_E(4);
#endif
break;
}
}
#endif // HYBRID_THRESHOLD #endif // HYBRID_THRESHOLD
/** /**
@ -128,34 +188,68 @@ void GcodeSuite::M912() {
*/ */
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
void GcodeSuite::M914() { void GcodeSuite::M914() {
#define TMC_SET_GET_SGT(P,Q) do { \ #define TMC_SAY_SGT(Q) tmc_get_sgt(stepper##Q, TMC_##Q)
if (parser.seen(axis_codes[P##_AXIS])) tmc_set_sgt(stepper##Q, TMC_##Q, parser.value_int()); \ #define TMC_SET_SGT(Q) tmc_set_sgt(stepper##Q, TMC_##Q, value)
else tmc_get_sgt(stepper##Q, TMC_##Q); } while(0)
#ifdef X_HOMING_SENSITIVITY bool report = true;
const uint8_t index = parser.byteval('I');
LOOP_XYZ(i) if (parser.seen(axis_codes[i])) {
const int8_t value = (int8_t)constrain(parser.value_int(), -63, 64);
report = false;
switch (i) {
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(X,X); if (index == 0) TMC_SET_SGT(X);
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
TMC_SET_GET_SGT(X,X2); if (index == 1) TMC_SET_SGT(X2);
#endif #endif
#endif break;
#ifdef Y_HOMING_SENSITIVITY case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(Y,Y); if (index == 0) TMC_SET_SGT(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
TMC_SET_GET_SGT(Y,Y2); if (index == 1) TMC_SET_SGT(Y2);
#endif #endif
#endif break;
#ifdef Z_HOMING_SENSITIVITY case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SET_GET_SGT(Z,Z); if (index == 0) TMC_SET_SGT(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
TMC_SET_GET_SGT(Z,Z2); if (index == 1) TMC_SET_SGT(Z2);
#endif #endif
break;
}
}
if (report) LOOP_XYZ(i) switch (i) {
case X_AXIS:
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(X);
#endif #endif
#if ENABLED(X2_IS_TMC2130)
TMC_SAY_SGT(X2);
#endif
break;
case Y_AXIS:
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Y);
#endif
#if ENABLED(Y2_IS_TMC2130)
TMC_SAY_SGT(Y2);
#endif
break;
case Z_AXIS:
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
TMC_SAY_SGT(Z);
#endif
#if ENABLED(Z2_IS_TMC2130)
TMC_SAY_SGT(Z2);
#endif
break;
}
} }
#endif // SENSORLESS_HOMING #endif // SENSORLESS_HOMING

View File

@ -37,7 +37,7 @@
*/ */
// Change EEPROM version if the structure changes // Change EEPROM version if the structure changes
#define EEPROM_VERSION "V52" #define EEPROM_VERSION "V53"
#define EEPROM_OFFSET 100 #define EEPROM_OFFSET 100
// Check the integrity of data offsets. // Check the integrity of data offsets.
@ -74,8 +74,10 @@
#include "../module/probe.h" #include "../module/probe.h"
#endif #endif
#if ENABLED(HAVE_TMC2130) #if HAS_TRINAMIC
#include "stepper_indirection.h" #include "stepper_indirection.h"
#include "../feature/tmc_util.h"
#define TMC_GET_PWMTHRS(P,Q) _tmc_thrs(stepper##Q.microsteps(), stepper##Q.TPWMTHRS(), planner.axis_steps_per_mm[P##_AXIS])
#endif #endif
#if ENABLED(FWRETRACT) #if ENABLED(FWRETRACT)
@ -230,7 +232,9 @@ typedef struct SettingsDataStruct {
// //
// HAS_TRINAMIC // HAS_TRINAMIC
// //
uint16_t tmc_stepper_current[11]; // M906 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4 #define TMC_AXES (MAX_EXTRUDERS + 6)
uint16_t tmc_stepper_current[TMC_AXES]; // M906 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
uint32_t tmc_hybrid_threshold[TMC_AXES]; // M913 X Y Z X2 Y2 Z2 E0 E1 E2 E3 E4
int16_t tmc_sgt[XYZ]; // M914 X Y Z int16_t tmc_sgt[XYZ]; // M914 X Y Z
// //
@ -658,7 +662,7 @@ void MarlinSettings::postprocess() {
_FIELD_TEST(tmc_stepper_current); _FIELD_TEST(tmc_stepper_current);
uint16_t currents[11] = { uint16_t tmc_stepper_current[TMC_AXES] = {
#if HAS_TRINAMIC #if HAS_TRINAMIC
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
stepperX.getCurrent(), stepperX.getCurrent(),
@ -719,24 +723,95 @@ void MarlinSettings::postprocess() {
0 0
#endif #endif
}; };
EEPROM_WRITE(currents); EEPROM_WRITE(tmc_stepper_current);
//
// Save TMC2130 or TMC2208 Hybrid Threshold, and placeholder values
//
_FIELD_TEST(tmc_hybrid_threshold);
uint32_t tmc_hybrid_threshold[TMC_AXES] = {
#if HAS_TRINAMIC
#if X_IS_TRINAMIC
TMC_GET_PWMTHRS(X, X),
#else
X_HYBRID_THRESHOLD,
#endif
#if Y_IS_TRINAMIC
TMC_GET_PWMTHRS(Y, Y),
#else
Y_HYBRID_THRESHOLD,
#endif
#if Z_IS_TRINAMIC
TMC_GET_PWMTHRS(Z, Z),
#else
Z_HYBRID_THRESHOLD,
#endif
#if X2_IS_TRINAMIC
TMC_GET_PWMTHRS(X, X2),
#else
X2_HYBRID_THRESHOLD,
#endif
#if Y2_IS_TRINAMIC
TMC_GET_PWMTHRS(Y, Y2),
#else
Y2_HYBRID_THRESHOLD,
#endif
#if Z2_IS_TRINAMIC
TMC_GET_PWMTHRS(Z, Z2),
#else
Z2_HYBRID_THRESHOLD,
#endif
#if E0_IS_TRINAMIC
TMC_GET_PWMTHRS(E, E0),
#else
E0_HYBRID_THRESHOLD,
#endif
#if E1_IS_TRINAMIC
TMC_GET_PWMTHRS(E, E1),
#else
E1_HYBRID_THRESHOLD,
#endif
#if E2_IS_TRINAMIC
TMC_GET_PWMTHRS(E, E2),
#else
E2_HYBRID_THRESHOLD,
#endif
#if E3_IS_TRINAMIC
TMC_GET_PWMTHRS(E, E3),
#else
E3_HYBRID_THRESHOLD,
#endif
#if E4_IS_TRINAMIC
TMC_GET_PWMTHRS(E, E4)
#else
E4_HYBRID_THRESHOLD
#endif
#else
100, 100, 3, // X, Y, Z
100, 100, 3, // X2, Y2, Z2
30, 30, 30, 30, 30 // E0, E1, E2, E3, E4
#endif
};
EEPROM_WRITE(tmc_hybrid_threshold);
// //
// TMC2130 Sensorless homing threshold // TMC2130 Sensorless homing threshold
// //
int16_t thrs[XYZ] = { int16_t tmc_sgt[XYZ] = {
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
#if ENABLED(X_IS_TMC2130) && defined(X_HOMING_SENSITIVITY) #if defined(X_HOMING_SENSITIVITY) && (ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS))
stepperX.sgt(), stepperX.sgt(),
#else #else
0, 0,
#endif #endif
#if ENABLED(Y_IS_TMC2130) && defined(Y_HOMING_SENSITIVITY) #if defined(Y_HOMING_SENSITIVITY) && (ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS))
stepperY.sgt(), stepperY.sgt(),
#else #else
0 0
#endif #endif
#if ENABLED(Z_IS_TMC2130) && defined(Z_HOMING_SENSITIVITY) #if defined(Z_HOMING_SENSITIVITY) && (ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS))
stepperZ.sgt() stepperZ.sgt()
#else #else
0 0
@ -745,7 +820,7 @@ void MarlinSettings::postprocess() {
0 0
#endif #endif
}; };
EEPROM_WRITE(thrs); EEPROM_WRITE(tmc_sgt);
// //
// Linear Advance // Linear Advance
@ -794,7 +869,7 @@ void MarlinSettings::postprocess() {
EEPROM_WRITE(planner.yz_skew_factor); EEPROM_WRITE(planner.yz_skew_factor);
#else #else
dummy = 0.0f; dummy = 0.0f;
for (uint8_t q = XYZ; q--;) EEPROM_WRITE(dummy); for (uint8_t q = 3; q--;) EEPROM_WRITE(dummy);
#endif #endif
// //
@ -1197,54 +1272,101 @@ void MarlinSettings::postprocess() {
#endif #endif
if (!validating) reset_stepper_drivers();
// //
// TMC2130 Stepper Current // TMC2130 Stepper Settings
// //
_FIELD_TEST(tmc_stepper_current); _FIELD_TEST(tmc_stepper_current);
#if HAS_TRINAMIC #if HAS_TRINAMIC
#define SET_CURR(N,Q) stepper##Q.setCurrent(currents[N] ? currents[N] : Q##_CURRENT, R_SENSE, HOLD_MULTIPLIER)
uint16_t currents[11]; #define SET_CURR(Q) stepper##Q.setCurrent(currents[TMC_##Q] ? currents[TMC_##Q] : Q##_CURRENT, R_SENSE, HOLD_MULTIPLIER)
uint16_t currents[TMC_AXES];
EEPROM_READ(currents); EEPROM_READ(currents);
if (!validating) { if (!validating) {
#if X_IS_TRINAMIC #if X_IS_TRINAMIC
SET_CURR(0, X); SET_CURR(X);
#endif #endif
#if Y_IS_TRINAMIC #if Y_IS_TRINAMIC
SET_CURR(1, Y); SET_CURR(Y);
#endif #endif
#if Z_IS_TRINAMIC #if Z_IS_TRINAMIC
SET_CURR(2, Z); SET_CURR(Z);
#endif #endif
#if X2_IS_TRINAMIC #if X2_IS_TRINAMIC
SET_CURR(3, X2); SET_CURR(X2);
#endif #endif
#if Y2_IS_TRINAMIC #if Y2_IS_TRINAMIC
SET_CURR(4, Y2); SET_CURR(Y2);
#endif #endif
#if Z2_IS_TRINAMIC #if Z2_IS_TRINAMIC
SET_CURR(5, Z2); SET_CURR(Z2);
#endif #endif
#if E0_IS_TRINAMIC #if E0_IS_TRINAMIC
SET_CURR(6, E0); SET_CURR(E0);
#endif #endif
#if E1_IS_TRINAMIC #if E1_IS_TRINAMIC
SET_CURR(7, E1); SET_CURR(E1);
#endif #endif
#if E2_IS_TRINAMIC #if E2_IS_TRINAMIC
SET_CURR(8, E2); SET_CURR(E2);
#endif #endif
#if E3_IS_TRINAMIC #if E3_IS_TRINAMIC
SET_CURR(9, E3); SET_CURR(E3);
#endif #endif
#if E4_IS_TRINAMIC #if E4_IS_TRINAMIC
SET_CURR(10, E4); SET_CURR(E4);
#endif #endif
} }
#else #else
uint16_t val; uint16_t val;
for (uint8_t q=11; q--;) EEPROM_READ(val); for (uint8_t q=TMC_AXES; q--;) EEPROM_READ(val);
#endif
#if HAS_TRINAMIC
#define TMC_SET_PWMTHRS(P,Q) tmc_set_pwmthrs(stepper##Q, TMC_##Q, tmc_hybrid_threshold[TMC_##Q], planner.axis_steps_per_mm[P##_AXIS])
uint16_t tmc_hybrid_threshold[TMC_AXES];
EEPROM_READ(tmc_hybrid_threshold);
if (!validating) {
#if X_IS_TRINAMIC
TMC_SET_PWMTHRS(X, X);
#endif
#if Y_IS_TRINAMIC
TMC_SET_PWMTHRS(Y, Y);
#endif
#if Z_IS_TRINAMIC
TMC_SET_PWMTHRS(Z, Z);
#endif
#if X2_IS_TRINAMIC
TMC_SET_PWMTHRS(X, X2);
#endif
#if Y2_IS_TRINAMIC
TMC_SET_PWMTHRS(Y, Y2);
#endif
#if Z2_IS_TRINAMIC
TMC_SET_PWMTHRS(Z, Z2);
#endif
#if E0_IS_TRINAMIC
TMC_SET_PWMTHRS(E, E0);
#endif
#if E1_IS_TRINAMIC
TMC_SET_PWMTHRS(E, E1);
#endif
#if E2_IS_TRINAMIC
TMC_SET_PWMTHRS(E, E2);
#endif
#if E3_IS_TRINAMIC
TMC_SET_PWMTHRS(E, E3);
#endif
#if E4_IS_TRINAMIC
TMC_SET_PWMTHRS(E, E4);
#endif
}
#else
uint16_t thrs_val;
for (uint8_t q=TMC_AXES; q--;) EEPROM_READ(thrs_val);
#endif #endif
/* /*
@ -1253,32 +1375,32 @@ void MarlinSettings::postprocess() {
* Y and Y2 use the same value * Y and Y2 use the same value
* Z and Z2 use the same value * Z and Z2 use the same value
*/ */
int16_t thrs[XYZ]; int16_t tmc_sgt[XYZ];
EEPROM_READ(thrs); EEPROM_READ(tmc_sgt);
#if ENABLED(SENSORLESS_HOMING) #if ENABLED(SENSORLESS_HOMING)
if (!validating) { if (!validating) {
#ifdef X_HOMING_SENSITIVITY #ifdef X_HOMING_SENSITIVITY
#if ENABLED(X_IS_TMC2130) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperX.sgt(thrs[0]); stepperX.sgt(tmc_sgt[0]);
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
stepperX2.sgt(thrs[0]); stepperX2.sgt(tmc_sgt[0]);
#endif #endif
#endif #endif
#ifdef Y_HOMING_SENSITIVITY #ifdef Y_HOMING_SENSITIVITY
#if ENABLED(Y_IS_TMC2130) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperY.sgt(thrs[1]); stepperY.sgt(tmc_sgt[1]);
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
stepperY2.sgt(thrs[1]); stepperY2.sgt(tmc_sgt[1]);
#endif #endif
#endif #endif
#ifdef Z_HOMING_SENSITIVITY #ifdef Z_HOMING_SENSITIVITY
#if ENABLED(Z_IS_TMC2130) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperZ.sgt(thrs[2]); stepperZ.sgt(tmc_sgt[2]);
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
stepperZ2.sgt(thrs[2]); stepperZ2.sgt(tmc_sgt[2]);
#endif #endif
#endif #endif
} }
@ -1338,7 +1460,7 @@ void MarlinSettings::postprocess() {
EEPROM_READ(dummy); EEPROM_READ(dummy);
#endif #endif
#else #else
for (uint8_t q = XYZ; q--;) EEPROM_READ(dummy); for (uint8_t q = 3; q--;) EEPROM_READ(dummy);
#endif #endif
// //
@ -1731,66 +1853,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif #endif
); );
#if X_IS_TRINAMIC reset_stepper_drivers();
stepperX.setCurrent(X_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if Y_IS_TRINAMIC
stepperY.setCurrent(Y_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if Z_IS_TRINAMIC
stepperZ.setCurrent(Z_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if X2_IS_TRINAMIC
stepperX2.setCurrent(X2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if Y2_IS_TRINAMIC
stepperY2.setCurrent(Y2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if Z2_IS_TRINAMIC
stepperZ2.setCurrent(Z2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if E0_IS_TRINAMIC
stepperE0.setCurrent(E0_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if E1_IS_TRINAMIC
stepperE1.setCurrent(E1_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if E2_IS_TRINAMIC
stepperE2.setCurrent(E2_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if E3_IS_TRINAMIC
stepperE3.setCurrent(E3_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if E4_IS_TRINAMIC
stepperE4.setCurrent(E4_CURRENT, R_SENSE, HOLD_MULTIPLIER);
#endif
#if ENABLED(SENSORLESS_HOMING)
#ifdef X_HOMING_SENSITIVITY
#if ENABLED(X_IS_TMC2130)
stepperX.sgt(X_HOMING_SENSITIVITY);
#endif
#if ENABLED(X2_IS_TMC2130)
stepperX2.sgt(X_HOMING_SENSITIVITY);
#endif
#endif
#ifdef Y_HOMING_SENSITIVITY
#if ENABLED(Y_IS_TMC2130)
stepperY.sgt(Y_HOMING_SENSITIVITY);
#endif
#if ENABLED(Y2_IS_TMC2130)
stepperY2.sgt(Y_HOMING_SENSITIVITY);
#endif
#endif
#ifdef Z_HOMING_SENSITIVITY
#if ENABLED(Z_IS_TMC2130)
stepperZ.sgt(Z_HOMING_SENSITIVITY);
#endif
#if ENABLED(Z2_IS_TMC2130)
stepperZ2.sgt(Z_HOMING_SENSITIVITY);
#endif
#endif
#endif
#if ENABLED(LIN_ADVANCE) #if ENABLED(LIN_ADVANCE)
planner.extruder_advance_K = LIN_ADVANCE_K; planner.extruder_advance_K = LIN_ADVANCE_K;
@ -1829,6 +1892,18 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0) #define CONFIG_ECHO_START do{ if (!forReplay) SERIAL_ECHO_START_P(port); }while(0)
#if HAS_TRINAMIC
void say_M906() { SERIAL_ECHOPGM_P(port, " M906 "); }
void say_M913() { SERIAL_ECHOPGM_P(port, " M913 "); }
#if ENABLED(SENSORLESS_HOMING)
void say_M914() { SERIAL_ECHOPGM_P(port, " M914 "); }
#endif
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void say_M603() { SERIAL_ECHOPGM_P(port, " M603 "); }
#endif
/** /**
* M503 - Report current settings in RAM * M503 - Report current settings in RAM
* *
@ -1849,7 +1924,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOPGM_P(port, " G2"); SERIAL_ECHOPGM_P(port, " G2");
SERIAL_CHAR_P(port, parser.linear_unit_factor == 1.0 ? '1' : '0'); SERIAL_CHAR_P(port, parser.linear_unit_factor == 1.0 ? '1' : '0');
SERIAL_ECHOPGM_P(port, " ; Units in "); SERIAL_ECHOPGM_P(port, " ; Units in ");
serialprintPGM(parser.linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n")); serialprintPGM_P(port, parser.linear_unit_factor == 1.0 ? PSTR("mm\n") : PSTR("inches\n"));
#else #else
#define LINEAR_UNIT(N) (N) #define LINEAR_UNIT(N) (N)
#define VOLUMETRIC_UNIT(N) (N) #define VOLUMETRIC_UNIT(N) (N)
@ -2076,7 +2151,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOPAIR_P(port, " G29 S3 X", (int)px + 1); SERIAL_ECHOPAIR_P(port, " G29 S3 X", (int)px + 1);
SERIAL_ECHOPAIR_P(port, " Y", (int)py + 1); SERIAL_ECHOPAIR_P(port, " Y", (int)py + 1);
SERIAL_ECHOPGM_P(port, " Z"); SERIAL_ECHOPGM_P(port, " Z");
SERIAL_PROTOCOL_F_P(port, LINEAR_UNIT(mbl.z_values[px][py]), 5); SERIAL_ECHO_F_P(port, LINEAR_UNIT(mbl.z_values[px][py]), 5);
SERIAL_EOL_P(port); SERIAL_EOL_P(port);
} }
} }
@ -2103,7 +2178,7 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOPAIR_P(port, " G29 W I", (int)px + 1); SERIAL_ECHOPAIR_P(port, " G29 W I", (int)px + 1);
SERIAL_ECHOPAIR_P(port, " J", (int)py + 1); SERIAL_ECHOPAIR_P(port, " J", (int)py + 1);
SERIAL_ECHOPGM_P(port, " Z"); SERIAL_ECHOPGM_P(port, " Z");
SERIAL_PROTOCOL_F_P(port, LINEAR_UNIT(z_values[px][py]), 5); SERIAL_ECHO_F_P(port, LINEAR_UNIT(z_values[px][py]), 5);
SERIAL_EOL_P(port); SERIAL_EOL_P(port);
} }
} }
@ -2296,51 +2371,115 @@ void MarlinSettings::reset(PORTARG_SOLO) {
#endif #endif
#endif #endif
/**
* TMC2130 stepper driver current
*/
#if HAS_TRINAMIC #if HAS_TRINAMIC
/**
* TMC2130 / TMC2208 / TRAMS stepper driver current
*/
if (!forReplay) { if (!forReplay) {
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOLNPGM_P(port, "Stepper driver current:"); SERIAL_ECHOLNPGM_P(port, "Stepper driver current:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM_P(port, " M906"); #if X_IS_TRINAMIC
#if ENABLED(X_IS_TMC2130) || ENABLED(X_IS_TMC2208) say_M906();
SERIAL_ECHOPAIR_P(port, " X ", stepperX.getCurrent()); SERIAL_ECHOLNPAIR_P(port, "X", stepperX.getCurrent());
#endif #endif
#if ENABLED(Y_IS_TMC2130) || ENABLED(Y_IS_TMC2208) #if X2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Y ", stepperY.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.getCurrent());
#endif #endif
#if ENABLED(Z_IS_TMC2130) || ENABLED(Z_IS_TMC2208) #if Y_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Z ", stepperZ.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.getCurrent());
#endif #endif
#if ENABLED(X2_IS_TMC2130) || ENABLED(X2_IS_TMC2208) #if Y2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " X2 ", stepperX2.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.getCurrent());
#endif #endif
#if ENABLED(Y2_IS_TMC2130) || ENABLED(Y2_IS_TMC2208) #if Z_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Y2 ", stepperY2.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.getCurrent());
#endif #endif
#if ENABLED(Z2_IS_TMC2130) || ENABLED(Z2_IS_TMC2208) #if Z2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " Z2 ", stepperZ2.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.getCurrent());
#endif #endif
#if ENABLED(E0_IS_TMC2130) || ENABLED(E0_IS_TMC2208) #if E0_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E0 ", stepperE0.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "T0 E", stepperE0.getCurrent());
#endif #endif
#if ENABLED(E1_IS_TMC2130) || ENABLED(E1_IS_TMC2208) #if E_STEPPERS > 1 && E1_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E1 ", stepperE1.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "T1 E", stepperE1.getCurrent());
#endif #endif
#if ENABLED(E2_IS_TMC2130) || ENABLED(E2_IS_TMC2208) #if E_STEPPERS > 2 && E2_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E2 ", stepperE2.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "T2 E", stepperE2.getCurrent());
#endif #endif
#if ENABLED(E3_IS_TMC2130) || ENABLED(E3_IS_TMC2208) #if E_STEPPERS > 3 && E3_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E3 ", stepperE3.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "T3 E", stepperE3.getCurrent());
#endif #endif
#if ENABLED(E4_IS_TMC2130) || ENABLED(E4_IS_TMC2208) #if E_STEPPERS > 4 && E4_IS_TRINAMIC
SERIAL_ECHOPAIR_P(port, " E4 ", stepperE4.getCurrent()); say_M906();
SERIAL_ECHOLNPAIR_P(port, "T4 E", stepperE4.getCurrent());
#endif #endif
SERIAL_EOL_P(port); SERIAL_EOL_P(port);
/**
* TMC2130 / TMC2208 / TRAMS Hybrid Threshold
*/
if (!forReplay) {
CONFIG_ECHO_START;
SERIAL_ECHOLNPGM_P(port, "Hybrid Threshold:");
}
CONFIG_ECHO_START;
#if X_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "X", TMC_GET_PWMTHRS(X, X));
#endif #endif
#if X2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 X", TMC_GET_PWMTHRS(X, X2));
#endif
#if Y_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "Y", TMC_GET_PWMTHRS(Y, Y));
#endif
#if Y2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", TMC_GET_PWMTHRS(Y, Y2));
#endif
#if Z_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "Z", TMC_GET_PWMTHRS(Z, Z));
#endif
#if Z2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", TMC_GET_PWMTHRS(Z, Z2));
#endif
#if E0_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T0 E", TMC_GET_PWMTHRS(E, E0));
#endif
#if E_STEPPERS > 1 && E1_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T1 E", TMC_GET_PWMTHRS(E, E1));
#endif
#if E_STEPPERS > 2 && E2_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T2 E", TMC_GET_PWMTHRS(E, E2));
#endif
#if E_STEPPERS > 3 && E3_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T3 E", TMC_GET_PWMTHRS(E, E3));
#endif
#if E_STEPPERS > 4 && E4_IS_TRINAMIC
say_M913();
SERIAL_ECHOLNPAIR_P(port, "T4 E", TMC_GET_PWMTHRS(E, E4));
#endif
SERIAL_EOL_P(port);
/** /**
* TMC2130 Sensorless homing thresholds * TMC2130 Sensorless homing thresholds
@ -2351,34 +2490,41 @@ void MarlinSettings::reset(PORTARG_SOLO) {
SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:"); SERIAL_ECHOLNPGM_P(port, "Sensorless homing threshold:");
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPGM_P(port, " M914");
#ifdef X_HOMING_SENSITIVITY #ifdef X_HOMING_SENSITIVITY
#if ENABLED(X_IS_TMC2130) #if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " X", stepperX.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "X", stepperX.sgt());
#endif #endif
#if ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
SERIAL_ECHOPAIR_P(port, " X2 ", stepperX2.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 X", stepperX2.sgt());
#endif #endif
#endif #endif
#ifdef Y_HOMING_SENSITIVITY #ifdef Y_HOMING_SENSITIVITY
#if ENABLED(Y_IS_TMC2130) #if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " Y", stepperY.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "Y", stepperY.sgt());
#endif #endif
#if ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
SERIAL_ECHOPAIR_P(port, " Y2 ", stepperY2.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 Y", stepperY2.sgt());
#endif #endif
#endif #endif
#ifdef Z_HOMING_SENSITIVITY #ifdef Z_HOMING_SENSITIVITY
#if ENABLED(Z_IS_TMC2130) #if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
SERIAL_ECHOPAIR_P(port, " Z ", stepperZ.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "Z", stepperZ.sgt());
#endif #endif
#if ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
SERIAL_ECHOPAIR_P(port, " Z2 ", stepperZ2.sgt()); say_M914();
SERIAL_ECHOLNPAIR_P(port, "I1 Z", stepperZ2.sgt());
#endif #endif
#endif #endif
SERIAL_EOL_P(port); SERIAL_EOL_P(port);
#endif #endif
#endif // HAS_TRINAMIC
/** /**
* Linear Advance * Linear Advance
*/ */
@ -2413,25 +2559,31 @@ void MarlinSettings::reset(PORTARG_SOLO) {
} }
CONFIG_ECHO_START; CONFIG_ECHO_START;
#if EXTRUDERS == 1 #if EXTRUDERS == 1
SERIAL_ECHOPAIR_P(port, " M603 L", LINEAR_UNIT(filament_change_load_length[0])); say_M603();
SERIAL_ECHOPAIR_P(port, "L", LINEAR_UNIT(filament_change_load_length[0]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0]));
#else #else
SERIAL_ECHOPAIR_P(port, " M603 T0 L", LINEAR_UNIT(filament_change_load_length[0])); say_M603();
SERIAL_ECHOPAIR_P(port, "T0 L", LINEAR_UNIT(filament_change_load_length[0]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[0]));
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR_P(port, " M603 T1 L", LINEAR_UNIT(filament_change_load_length[1])); say_M603();
SERIAL_ECHOPAIR_P(port, "T1 L", LINEAR_UNIT(filament_change_load_length[1]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[1])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[1]));
#if EXTRUDERS > 2 #if EXTRUDERS > 2
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR_P(port, " M603 T2 L", LINEAR_UNIT(filament_change_load_length[2])); say_M603();
SERIAL_ECHOPAIR_P(port, "T2 L", LINEAR_UNIT(filament_change_load_length[2]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[2])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[2]));
#if EXTRUDERS > 3 #if EXTRUDERS > 3
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR_P(port, " M603 T3 L", LINEAR_UNIT(filament_change_load_length[3])); say_M603();
SERIAL_ECHOPAIR_P(port, "T3 L", LINEAR_UNIT(filament_change_load_length[3]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[3])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[3]));
#if EXTRUDERS > 4 #if EXTRUDERS > 4
CONFIG_ECHO_START; CONFIG_ECHO_START;
SERIAL_ECHOPAIR_P(port, " M603 T4 L", LINEAR_UNIT(filament_change_load_length[4])); say_M603();
SERIAL_ECHOPAIR_P(port, "T4 L", LINEAR_UNIT(filament_change_load_length[4]));
SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[4])); SERIAL_ECHOLNPAIR_P(port, " U", LINEAR_UNIT(filament_change_unload_length[4]));
#endif // EXTRUDERS > 4 #endif // EXTRUDERS > 4
#endif // EXTRUDERS > 3 #endif // EXTRUDERS > 3

View File

@ -921,31 +921,6 @@ void Stepper::init() {
microstep_init(); microstep_init();
#endif #endif
// Init TMC Steppers
#if ENABLED(HAVE_TMC26X)
tmc26x_init();
#endif
// Init TMC2130 Steppers
#if ENABLED(HAVE_TMC2130)
tmc2130_init();
#endif
// Init TMC2208 Steppers
#if ENABLED(HAVE_TMC2208)
tmc2208_init();
#endif
// TRAMS, TMC2130 and TMC2208 advanced settings
#if HAS_TRINAMIC
TMC_ADV()
#endif
// Init L6470 Steppers
#if ENABLED(HAVE_L6470DRIVER)
L6470_init();
#endif
// Init Dir Pins // Init Dir Pins
#if HAS_X_DIR #if HAS_X_DIR
X_DIR_INIT; X_DIR_INIT;

View File

@ -47,83 +47,82 @@
#include <TMC26XStepper.h> #include <TMC26XStepper.h>
#endif #endif
#define _TMC_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_ENABLE_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR) #define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_ENABLE_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR)
#if ENABLED(X_IS_TMC26X) #if ENABLED(X_IS_TMC26X)
_TMC_DEFINE(X); _TMC26X_DEFINE(X);
#endif #endif
#if ENABLED(X2_IS_TMC26X) #if ENABLED(X2_IS_TMC26X)
_TMC_DEFINE(X2); _TMC26X_DEFINE(X2);
#endif #endif
#if ENABLED(Y_IS_TMC26X) #if ENABLED(Y_IS_TMC26X)
_TMC_DEFINE(Y); _TMC26X_DEFINE(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC26X) #if ENABLED(Y2_IS_TMC26X)
_TMC_DEFINE(Y2); _TMC26X_DEFINE(Y2);
#endif #endif
#if ENABLED(Z_IS_TMC26X) #if ENABLED(Z_IS_TMC26X)
_TMC_DEFINE(Z); _TMC26X_DEFINE(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC26X) #if ENABLED(Z2_IS_TMC26X)
_TMC_DEFINE(Z2); _TMC26X_DEFINE(Z2);
#endif #endif
#if ENABLED(E0_IS_TMC26X) #if ENABLED(E0_IS_TMC26X)
_TMC_DEFINE(E0); _TMC26X_DEFINE(E0);
#endif #endif
#if ENABLED(E1_IS_TMC26X) #if ENABLED(E1_IS_TMC26X)
_TMC_DEFINE(E1); _TMC26X_DEFINE(E1);
#endif #endif
#if ENABLED(E2_IS_TMC26X) #if ENABLED(E2_IS_TMC26X)
_TMC_DEFINE(E2); _TMC26X_DEFINE(E2);
#endif #endif
#if ENABLED(E3_IS_TMC26X) #if ENABLED(E3_IS_TMC26X)
_TMC_DEFINE(E3); _TMC26X_DEFINE(E3);
#endif #endif
#if ENABLED(E4_IS_TMC26X) #if ENABLED(E4_IS_TMC26X)
_TMC_DEFINE(E4); _TMC26X_DEFINE(E4);
#endif #endif
#define _TMC_INIT(A) do{ \ #define _TMC26X_INIT(A) do{ \
stepper##A.setMicrosteps(A##_MICROSTEPS); \ stepper##A.setMicrosteps(A##_MICROSTEPS); \
stepper##A.start(); \ stepper##A.start(); \
}while(0) }while(0)
void tmc26x_init() { void tmc26x_init_to_defaults() {
#if ENABLED(X_IS_TMC26X) #if ENABLED(X_IS_TMC26X)
_TMC_INIT(X); _TMC26X_INIT(X);
#endif #endif
#if ENABLED(X2_IS_TMC26X) #if ENABLED(X2_IS_TMC26X)
_TMC_INIT(X2); _TMC26X_INIT(X2);
#endif #endif
#if ENABLED(Y_IS_TMC26X) #if ENABLED(Y_IS_TMC26X)
_TMC_INIT(Y); _TMC26X_INIT(Y);
#endif #endif
#if ENABLED(Y2_IS_TMC26X) #if ENABLED(Y2_IS_TMC26X)
_TMC_INIT(Y2); _TMC26X_INIT(Y2);
#endif #endif
#if ENABLED(Z_IS_TMC26X) #if ENABLED(Z_IS_TMC26X)
_TMC_INIT(Z); _TMC26X_INIT(Z);
#endif #endif
#if ENABLED(Z2_IS_TMC26X) #if ENABLED(Z2_IS_TMC26X)
_TMC_INIT(Z2); _TMC26X_INIT(Z2);
#endif #endif
#if ENABLED(E0_IS_TMC26X) #if ENABLED(E0_IS_TMC26X)
_TMC_INIT(E0); _TMC26X_INIT(E0);
#endif #endif
#if ENABLED(E1_IS_TMC26X) #if ENABLED(E1_IS_TMC26X)
_TMC_INIT(E1); _TMC26X_INIT(E1);
#endif #endif
#if ENABLED(E2_IS_TMC26X) #if ENABLED(E2_IS_TMC26X)
_TMC_INIT(E2); _TMC26X_INIT(E2);
#endif #endif
#if ENABLED(E3_IS_TMC26X) #if ENABLED(E3_IS_TMC26X)
_TMC_INIT(E3); _TMC26X_INIT(E3);
#endif #endif
#if ENABLED(E4_IS_TMC26X) #if ENABLED(E4_IS_TMC26X)
_TMC_INIT(E4); _TMC26X_INIT(E4);
#endif #endif
} }
#endif // HAVE_TMC26X #endif // HAVE_TMC26X
// //
@ -180,9 +179,9 @@
// Use internal reference voltage for current calculations. This is the default. // Use internal reference voltage for current calculations. This is the default.
// Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609) // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
// https://www.trinamic.com/products/integrated-circuits/details/tmc2130/ // https://www.trinamic.com/products/integrated-circuits/details/tmc2130/
void tmc2130_init(TMC2130Stepper &st, const uint16_t microsteps, const uint32_t thrs, const float spmm) { void tmc2130_init(TMC2130Stepper &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
st.begin(); st.begin();
st.setCurrent(st.getCurrent(), R_SENSE, HOLD_MULTIPLIER); st.setCurrent(mA, R_SENSE, HOLD_MULTIPLIER);
st.microsteps(microsteps); st.microsteps(microsteps);
st.blank_time(24); st.blank_time(24);
st.off_time(5); // Only enables the driver if used with stealthChop st.off_time(5); // Only enables the driver if used with stealthChop
@ -209,9 +208,9 @@
st.GSTAT(); // Clear GSTAT st.GSTAT(); // Clear GSTAT
} }
#define _TMC2130_INIT(ST, SPMM) tmc2130_init(stepper##ST, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM) #define _TMC2130_INIT(ST, SPMM) tmc2130_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
void tmc2130_init() { void tmc2130_init_to_defaults() {
#if ENABLED(X_IS_TMC2130) #if ENABLED(X_IS_TMC2130)
_TMC2130_INIT( X, planner.axis_steps_per_mm[X_AXIS]); _TMC2130_INIT( X, planner.axis_steps_per_mm[X_AXIS]);
#endif #endif
@ -234,34 +233,45 @@
_TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]); _TMC2130_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
#endif #endif
#if ENABLED(E1_IS_TMC2130) #if ENABLED(E1_IS_TMC2130)
_TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 1; _TMC2130_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 1
#endif
]);
#endif #endif
#if ENABLED(E2_IS_TMC2130) #if ENABLED(E2_IS_TMC2130)
_TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 2; _TMC2130_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 2
#endif
]);
#endif #endif
#if ENABLED(E3_IS_TMC2130) #if ENABLED(E3_IS_TMC2130)
_TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 3; _TMC2130_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 3
#endif
]);
#endif #endif
#if ENABLED(E4_IS_TMC2130) #if ENABLED(E4_IS_TMC2130)
_TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 4; _TMC2130_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 4
#endif
]);
#endif #endif
#if ENABLED(SENSORLESS_HOMING)
#define TMC_INIT_SGT(P,Q) stepper##Q.sgt(P##_HOMING_SENSITIVITY);
#ifdef X_HOMING_SENSITIVITY
#if ENABLED(X_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperX.sgt(X_HOMING_SENSITIVITY);
#endif
#if ENABLED(X2_IS_TMC2130)
stepperX2.sgt(X_HOMING_SENSITIVITY);
#endif
#endif
#ifdef Y_HOMING_SENSITIVITY
#if ENABLED(Y_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperY.sgt(Y_HOMING_SENSITIVITY);
#endif
#if ENABLED(Y2_IS_TMC2130)
stepperY2.sgt(Y_HOMING_SENSITIVITY);
#endif
#endif
#ifdef Z_HOMING_SENSITIVITY
#if ENABLED(Z_IS_TMC2130) || ENABLED(IS_TRAMS)
stepperZ.sgt(Z_HOMING_SENSITIVITY);
#endif
#if ENABLED(Z2_IS_TMC2130)
stepperZ2.sgt(Z_HOMING_SENSITIVITY);
#endif
#endif
#endif
} }
#endif // HAVE_TMC2130 #endif // HAVE_TMC2130
@ -396,11 +406,11 @@
// Use internal reference voltage for current calculations. This is the default. // Use internal reference voltage for current calculations. This is the default.
// Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609) // Following values from Trinamic's spreadsheet with values for a NEMA17 (42BYGHW609)
void tmc2208_init(TMC2208Stepper &st, const uint16_t microsteps, const uint32_t thrs, const float spmm) { void tmc2208_init(TMC2208Stepper &st, const uint16_t mA, const uint16_t microsteps, const uint32_t thrs, const float spmm) {
st.pdn_disable(true); // Use UART st.pdn_disable(true); // Use UART
st.mstep_reg_select(true); // Select microsteps with UART st.mstep_reg_select(true); // Select microsteps with UART
st.I_scale_analog(false); st.I_scale_analog(false);
st.rms_current(st.getCurrent(), HOLD_MULTIPLIER, R_SENSE); st.rms_current(mA, HOLD_MULTIPLIER, R_SENSE);
st.microsteps(microsteps); st.microsteps(microsteps);
st.blank_time(24); st.blank_time(24);
st.toff(5); st.toff(5);
@ -430,9 +440,9 @@
delay(200); delay(200);
} }
#define _TMC2208_INIT(ST, SPMM) tmc2208_init(stepper##ST, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM) #define _TMC2208_INIT(ST, SPMM) tmc2208_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, SPMM)
void tmc2208_init() { void tmc2208_init_to_defaults() {
#if ENABLED(X_IS_TMC2208) #if ENABLED(X_IS_TMC2208)
_TMC2208_INIT(X, planner.axis_steps_per_mm[X_AXIS]); _TMC2208_INIT(X, planner.axis_steps_per_mm[X_AXIS]);
#endif #endif
@ -455,36 +465,76 @@
_TMC2208_INIT(E0, planner.axis_steps_per_mm[E_AXIS]); _TMC2208_INIT(E0, planner.axis_steps_per_mm[E_AXIS]);
#endif #endif
#if ENABLED(E1_IS_TMC2208) #if ENABLED(E1_IS_TMC2208)
_TMC2208_INIT(E1, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 1; _TMC2208_INIT(E1, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 1
#endif
]);
#endif #endif
#if ENABLED(E2_IS_TMC2208) #if ENABLED(E2_IS_TMC2208)
_TMC2208_INIT(E2, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 2; _TMC2208_INIT(E2, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 2
#endif
]);
#endif #endif
#if ENABLED(E3_IS_TMC2208) #if ENABLED(E3_IS_TMC2208)
_TMC2208_INIT(E3, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 3; _TMC2208_INIT(E3, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 3
#endif
]);
#endif #endif
#if ENABLED(E4_IS_TMC2208) #if ENABLED(E4_IS_TMC2208)
_TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS { constexpr int extruder = 4; _TMC2208_INIT(E4, planner.axis_steps_per_mm[E_AXIS_N]); }
#if ENABLED(DISTINCT_E_FACTORS)
+ 4
#endif
]);
#endif #endif
} }
#endif // HAVE_TMC2208 #endif // HAVE_TMC2208
void restore_stepper_drivers() {
#if X_IS_TRINAMIC
stepperX.push();
#endif
#if X2_IS_TRINAMIC
stepperX2.push();
#endif
#if Y_IS_TRINAMIC
stepperY.push();
#endif
#if Y2_IS_TRINAMIC
stepperY2.push();
#endif
#if Z_IS_TRINAMIC
stepperZ.push();
#endif
#if Z2_IS_TRINAMIC
stepperZ2.push();
#endif
#if E0_IS_TRINAMIC
stepperE0.push();
#endif
#if E1_IS_TRINAMIC
stepperE1.push();
#endif
#if E2_IS_TRINAMIC
stepperE2.push();
#endif
#if E3_IS_TRINAMIC
stepperE3.push();
#endif
#if E4_IS_TRINAMIC
stepperE4.push();
#endif
}
void reset_stepper_drivers() {
#if ENABLED(HAVE_TMC26X)
tmc26x_init_to_defaults();
#endif
#if ENABLED(HAVE_TMC2130)
delay(100);
tmc2130_init_to_defaults();
#endif
#if ENABLED(HAVE_TMC2208)
delay(100);
tmc2208_init_to_defaults();
#endif
#ifdef TMC_ADV
TMC_ADV()
#endif
#if ENABLED(HAVE_L6470DRIVER)
L6470_init_to_defaults();
#endif
}
// //
// L6470 Driver objects and inits // L6470 Driver objects and inits
// //
@ -538,7 +588,7 @@
stepper##A.setStallCurrent(A##_STALLCURRENT); \ stepper##A.setStallCurrent(A##_STALLCURRENT); \
}while(0) }while(0)
void L6470_init() { void L6470_init_to_defaults() {
#if ENABLED(X_IS_L6470) #if ENABLED(X_IS_L6470)
_L6470_INIT(X); _L6470_INIT(X);
#endif #endif
@ -575,4 +625,3 @@
} }
#endif // HAVE_L6470DRIVER #endif // HAVE_L6470DRIVER

View File

@ -54,29 +54,32 @@
#else #else
#include <TMC26XStepper.h> #include <TMC26XStepper.h>
#endif #endif
void tmc26x_init(); void tmc26x_init_to_defaults();
#endif #endif
#if ENABLED(HAVE_TMC2130) #if ENABLED(HAVE_TMC2130)
#include <TMC2130Stepper.h> #include <TMC2130Stepper.h>
void tmc2130_init(); void tmc2130_init_to_defaults();
#endif #endif
#if ENABLED(HAVE_TMC2208) #if ENABLED(HAVE_TMC2208)
#include <TMC2208Stepper.h> #include <TMC2208Stepper.h>
void tmc2208_serial_begin(); void tmc2208_serial_begin();
void tmc2208_init(); void tmc2208_init_to_defaults();
#endif #endif
// L6470 has STEP on normal pins, but DIR/ENABLE via SPI // L6470 has STEP on normal pins, but DIR/ENABLE via SPI
#if ENABLED(HAVE_L6470DRIVER) #if ENABLED(HAVE_L6470DRIVER)
#include <SPI.h> #include <SPI.h>
#include <L6470.h> #include <L6470.h>
void L6470_init(); void L6470_init_to_defaults();
#endif #endif
void restore_stepper_drivers(); // Called by PSU_ON
void reset_stepper_drivers(); // Called by settings.load / settings.reset
// X Stepper // X Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(X_IS_L6470) #if ENABLED(X_IS_L6470)
extern L6470 stepperX; extern L6470 stepperX;
#define X_ENABLE_INIT NOOP #define X_ENABLE_INIT NOOP
#define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0) #define X_ENABLE_WRITE(STATE) do{ if (STATE) stepperX.Step_Clock(stepperX.getStatus() & STATUS_HIZ); else stepperX.softFree(); }while(0)
@ -91,9 +94,9 @@
#define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE) #define X_ENABLE_WRITE(STATE) stepperX.setEnabled(STATE)
#define X_ENABLE_READ stepperX.isEnabled() #define X_ENABLE_READ stepperX.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(X_IS_TMC2130) #if ENABLED(X_IS_TMC2130)
extern TMC2130Stepper stepperX; extern TMC2130Stepper stepperX;
#elif ENABLED(HAVE_TMC2208) && ENABLED(X_IS_TMC2208) #elif ENABLED(X_IS_TMC2208)
extern TMC2208Stepper stepperX; extern TMC2208Stepper stepperX;
#endif #endif
#define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN) #define X_ENABLE_INIT SET_OUTPUT(X_ENABLE_PIN)
@ -109,7 +112,7 @@
#define X_STEP_READ READ(X_STEP_PIN) #define X_STEP_READ READ(X_STEP_PIN)
// Y Stepper // Y Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Y_IS_L6470) #if ENABLED(Y_IS_L6470)
extern L6470 stepperY; extern L6470 stepperY;
#define Y_ENABLE_INIT NOOP #define Y_ENABLE_INIT NOOP
#define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0) #define Y_ENABLE_WRITE(STATE) do{ if (STATE) stepperY.Step_Clock(stepperY.getStatus() & STATUS_HIZ); else stepperY.softFree(); }while(0)
@ -124,9 +127,9 @@
#define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE) #define Y_ENABLE_WRITE(STATE) stepperY.setEnabled(STATE)
#define Y_ENABLE_READ stepperY.isEnabled() #define Y_ENABLE_READ stepperY.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(Y_IS_TMC2130) #if ENABLED(Y_IS_TMC2130)
extern TMC2130Stepper stepperY; extern TMC2130Stepper stepperY;
#elif ENABLED(HAVE_TMC2208) && ENABLED(Y_IS_TMC2208) #elif ENABLED(Y_IS_TMC2208)
extern TMC2208Stepper stepperY; extern TMC2208Stepper stepperY;
#endif #endif
#define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN) #define Y_ENABLE_INIT SET_OUTPUT(Y_ENABLE_PIN)
@ -142,7 +145,7 @@
#define Y_STEP_READ READ(Y_STEP_PIN) #define Y_STEP_READ READ(Y_STEP_PIN)
// Z Stepper // Z Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Z_IS_L6470) #if ENABLED(Z_IS_L6470)
extern L6470 stepperZ; extern L6470 stepperZ;
#define Z_ENABLE_INIT NOOP #define Z_ENABLE_INIT NOOP
#define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0) #define Z_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ.Step_Clock(stepperZ.getStatus() & STATUS_HIZ); else stepperZ.softFree(); }while(0)
@ -157,9 +160,9 @@
#define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE) #define Z_ENABLE_WRITE(STATE) stepperZ.setEnabled(STATE)
#define Z_ENABLE_READ stepperZ.isEnabled() #define Z_ENABLE_READ stepperZ.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(Z_IS_TMC2130) #if ENABLED(Z_IS_TMC2130)
extern TMC2130Stepper stepperZ; extern TMC2130Stepper stepperZ;
#elif ENABLED(HAVE_TMC2208) && ENABLED(Z_IS_TMC2208) #elif ENABLED(Z_IS_TMC2208)
extern TMC2208Stepper stepperZ; extern TMC2208Stepper stepperZ;
#endif #endif
#define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN) #define Z_ENABLE_INIT SET_OUTPUT(Z_ENABLE_PIN)
@ -176,7 +179,7 @@
// X2 Stepper // X2 Stepper
#if HAS_X2_ENABLE #if HAS_X2_ENABLE
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(X2_IS_L6470) #if ENABLED(X2_IS_L6470)
extern L6470 stepperX2; extern L6470 stepperX2;
#define X2_ENABLE_INIT NOOP #define X2_ENABLE_INIT NOOP
#define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0) #define X2_ENABLE_WRITE(STATE) do{ if (STATE) stepperX2.Step_Clock(stepperX2.getStatus() & STATUS_HIZ); else stepperX2.softFree(); }while(0)
@ -191,9 +194,9 @@
#define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE) #define X2_ENABLE_WRITE(STATE) stepperX2.setEnabled(STATE)
#define X2_ENABLE_READ stepperX2.isEnabled() #define X2_ENABLE_READ stepperX2.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(X2_IS_TMC2130) #if ENABLED(X2_IS_TMC2130)
extern TMC2130Stepper stepperX2; extern TMC2130Stepper stepperX2;
#elif ENABLED(HAVE_TMC2208) && ENABLED(X2_IS_TMC2208) #elif ENABLED(X2_IS_TMC2208)
extern TMC2208Stepper stepperX2; extern TMC2208Stepper stepperX2;
#endif #endif
#define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN) #define X2_ENABLE_INIT SET_OUTPUT(X2_ENABLE_PIN)
@ -211,7 +214,7 @@
// Y2 Stepper // Y2 Stepper
#if HAS_Y2_ENABLE #if HAS_Y2_ENABLE
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Y2_IS_L6470) #if ENABLED(Y2_IS_L6470)
extern L6470 stepperY2; extern L6470 stepperY2;
#define Y2_ENABLE_INIT NOOP #define Y2_ENABLE_INIT NOOP
#define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0) #define Y2_ENABLE_WRITE(STATE) do{ if (STATE) stepperY2.Step_Clock(stepperY2.getStatus() & STATUS_HIZ); else stepperY2.softFree(); }while(0)
@ -226,9 +229,9 @@
#define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE) #define Y2_ENABLE_WRITE(STATE) stepperY2.setEnabled(STATE)
#define Y2_ENABLE_READ stepperY2.isEnabled() #define Y2_ENABLE_READ stepperY2.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(Y2_IS_TMC2130) #if ENABLED(Y2_IS_TMC2130)
extern TMC2130Stepper stepperY2; extern TMC2130Stepper stepperY2;
#elif ENABLED(HAVE_TMC2208) && ENABLED(Y2_IS_TMC2208) #elif ENABLED(Y2_IS_TMC2208)
extern TMC2208Stepper stepperY2; extern TMC2208Stepper stepperY2;
#endif #endif
#define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN) #define Y2_ENABLE_INIT SET_OUTPUT(Y2_ENABLE_PIN)
@ -246,7 +249,7 @@
// Z2 Stepper // Z2 Stepper
#if HAS_Z2_ENABLE #if HAS_Z2_ENABLE
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(Z2_IS_L6470) #if ENABLED(Z2_IS_L6470)
extern L6470 stepperZ2; extern L6470 stepperZ2;
#define Z2_ENABLE_INIT NOOP #define Z2_ENABLE_INIT NOOP
#define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0) #define Z2_ENABLE_WRITE(STATE) do{ if (STATE) stepperZ2.Step_Clock(stepperZ2.getStatus() & STATUS_HIZ); else stepperZ2.softFree(); }while(0)
@ -261,9 +264,9 @@
#define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE) #define Z2_ENABLE_WRITE(STATE) stepperZ2.setEnabled(STATE)
#define Z2_ENABLE_READ stepperZ2.isEnabled() #define Z2_ENABLE_READ stepperZ2.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(Z2_IS_TMC2130) #if ENABLED(Z2_IS_TMC2130)
extern TMC2130Stepper stepperZ2; extern TMC2130Stepper stepperZ2;
#elif ENABLED(HAVE_TMC2208) && ENABLED(Z2_IS_TMC2208) #elif ENABLED(Z2_IS_TMC2208)
extern TMC2208Stepper stepperZ2; extern TMC2208Stepper stepperZ2;
#endif #endif
#define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN) #define Z2_ENABLE_INIT SET_OUTPUT(Z2_ENABLE_PIN)
@ -280,7 +283,7 @@
#endif #endif
// E0 Stepper // E0 Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E0_IS_L6470) #if ENABLED(E0_IS_L6470)
extern L6470 stepperE0; extern L6470 stepperE0;
#define E0_ENABLE_INIT NOOP #define E0_ENABLE_INIT NOOP
#define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0) #define E0_ENABLE_WRITE(STATE) do{ if (STATE) stepperE0.Step_Clock(stepperE0.getStatus() & STATUS_HIZ); else stepperE0.softFree(); }while(0)
@ -295,9 +298,9 @@
#define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE) #define E0_ENABLE_WRITE(STATE) stepperE0.setEnabled(STATE)
#define E0_ENABLE_READ stepperE0.isEnabled() #define E0_ENABLE_READ stepperE0.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(E0_IS_TMC2130) #if ENABLED(E0_IS_TMC2130)
extern TMC2130Stepper stepperE0; extern TMC2130Stepper stepperE0;
#elif ENABLED(HAVE_TMC2208) && ENABLED(E0_IS_TMC2208) #elif ENABLED(E0_IS_TMC2208)
extern TMC2208Stepper stepperE0; extern TMC2208Stepper stepperE0;
#endif #endif
#define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN) #define E0_ENABLE_INIT SET_OUTPUT(E0_ENABLE_PIN)
@ -313,7 +316,7 @@
#define E0_STEP_READ READ(E0_STEP_PIN) #define E0_STEP_READ READ(E0_STEP_PIN)
// E1 Stepper // E1 Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E1_IS_L6470) #if ENABLED(E1_IS_L6470)
extern L6470 stepperE1; extern L6470 stepperE1;
#define E1_ENABLE_INIT NOOP #define E1_ENABLE_INIT NOOP
#define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0) #define E1_ENABLE_WRITE(STATE) do{ if (STATE) stepperE1.Step_Clock(stepperE1.getStatus() & STATUS_HIZ); else stepperE1.softFree(); }while(0)
@ -328,9 +331,9 @@
#define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE) #define E1_ENABLE_WRITE(STATE) stepperE1.setEnabled(STATE)
#define E1_ENABLE_READ stepperE1.isEnabled() #define E1_ENABLE_READ stepperE1.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(E1_IS_TMC2130) #if ENABLED(E1_IS_TMC2130)
extern TMC2130Stepper stepperE1; extern TMC2130Stepper stepperE1;
#elif ENABLED(HAVE_TMC2208) && ENABLED(E1_IS_TMC2208) #elif ENABLED(E1_IS_TMC2208)
extern TMC2208Stepper stepperE1; extern TMC2208Stepper stepperE1;
#endif #endif
#define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN) #define E1_ENABLE_INIT SET_OUTPUT(E1_ENABLE_PIN)
@ -346,7 +349,7 @@
#define E1_STEP_READ READ(E1_STEP_PIN) #define E1_STEP_READ READ(E1_STEP_PIN)
// E2 Stepper // E2 Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E2_IS_L6470) #if ENABLED(E2_IS_L6470)
extern L6470 stepperE2; extern L6470 stepperE2;
#define E2_ENABLE_INIT NOOP #define E2_ENABLE_INIT NOOP
#define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0) #define E2_ENABLE_WRITE(STATE) do{ if (STATE) stepperE2.Step_Clock(stepperE2.getStatus() & STATUS_HIZ); else stepperE2.softFree(); }while(0)
@ -361,9 +364,9 @@
#define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE) #define E2_ENABLE_WRITE(STATE) stepperE2.setEnabled(STATE)
#define E2_ENABLE_READ stepperE2.isEnabled() #define E2_ENABLE_READ stepperE2.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(E2_IS_TMC2130) #if ENABLED(E2_IS_TMC2130)
extern TMC2130Stepper stepperE2; extern TMC2130Stepper stepperE2;
#elif ENABLED(HAVE_TMC2208) && ENABLED(E2_IS_TMC2208) #elif ENABLED(E2_IS_TMC2208)
extern TMC2208Stepper stepperE2; extern TMC2208Stepper stepperE2;
#endif #endif
#define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN) #define E2_ENABLE_INIT SET_OUTPUT(E2_ENABLE_PIN)
@ -379,7 +382,7 @@
#define E2_STEP_READ READ(E2_STEP_PIN) #define E2_STEP_READ READ(E2_STEP_PIN)
// E3 Stepper // E3 Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E3_IS_L6470) #if ENABLED(E3_IS_L6470)
extern L6470 stepperE3; extern L6470 stepperE3;
#define E3_ENABLE_INIT NOOP #define E3_ENABLE_INIT NOOP
#define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0) #define E3_ENABLE_WRITE(STATE) do{ if (STATE) stepperE3.Step_Clock(stepperE3.getStatus() & STATUS_HIZ); else stepperE3.softFree(); }while(0)
@ -394,9 +397,9 @@
#define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE) #define E3_ENABLE_WRITE(STATE) stepperE3.setEnabled(STATE)
#define E3_ENABLE_READ stepperE3.isEnabled() #define E3_ENABLE_READ stepperE3.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(E3_IS_TMC2130) #if ENABLED(E3_IS_TMC2130)
extern TMC2130Stepper stepperE3; extern TMC2130Stepper stepperE3;
#elif ENABLED(HAVE_TMC2208) && ENABLED(E3_IS_TMC2208) #elif ENABLED(E3_IS_TMC2208)
extern TMC2208Stepper stepperE3; extern TMC2208Stepper stepperE3;
#endif #endif
#define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN) #define E3_ENABLE_INIT SET_OUTPUT(E3_ENABLE_PIN)
@ -412,7 +415,7 @@
#define E3_STEP_READ READ(E3_STEP_PIN) #define E3_STEP_READ READ(E3_STEP_PIN)
// E4 Stepper // E4 Stepper
#if ENABLED(HAVE_L6470DRIVER) && ENABLED(E4_IS_L6470) #if ENABLED(E4_IS_L6470)
extern L6470 stepperE4; extern L6470 stepperE4;
#define E4_ENABLE_INIT NOOP #define E4_ENABLE_INIT NOOP
#define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0) #define E4_ENABLE_WRITE(STATE) do{ if (STATE) stepperE4.Step_Clock(stepperE4.getStatus() & STATUS_HIZ); else stepperE4.softFree(); }while(0)
@ -427,9 +430,9 @@
#define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE) #define E4_ENABLE_WRITE(STATE) stepperE4.setEnabled(STATE)
#define E4_ENABLE_READ stepperE4.isEnabled() #define E4_ENABLE_READ stepperE4.isEnabled()
#else #else
#if ENABLED(HAVE_TMC2130) && ENABLED(E4_IS_TMC2130) #if ENABLED(E4_IS_TMC2130)
extern TMC2130Stepper stepperE4; extern TMC2130Stepper stepperE4;
#elif ENABLED(HAVE_TMC2208) && ENABLED(E4_IS_TMC2208) #elif ENABLED(E4_IS_TMC2208)
extern TMC2208Stepper stepperE4; extern TMC2208Stepper stepperE4;
#endif #endif
#define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN) #define E4_ENABLE_INIT SET_OUTPUT(E4_ENABLE_PIN)