update code base to Marlin 2.0.9.2

This commit is contained in:
Stefan Kalscheuer
2021-10-03 18:57:12 +02:00
parent b9d7ba838e
commit 7077da3591
2617 changed files with 332093 additions and 103438 deletions

342
Marlin/src/feature/tmc_util.cpp Executable file → Normal file
View File

@@ -16,7 +16,7 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
@@ -34,7 +34,7 @@
#if ENABLED(TMC_DEBUG)
#include "../module/planner.h"
#include "../libs/hex_print_routines.h"
#include "../libs/hex_print.h"
#if ENABLED(MONITOR_DRIVER_STATUS)
static uint16_t report_tmc_status_interval; // = 0
#endif
@@ -63,9 +63,9 @@
, is_stall:1
, is_stealth:1
, is_standstill:1
#if HAS_STALLGUARD
, sg_result_reasonable:1
#endif
#if HAS_STALLGUARD
, sg_result_reasonable:1
#endif
#endif
;
#if ENABLED(TMC_DEBUG)
@@ -147,7 +147,7 @@
static TMC_driver_data get_driver_data(TMC2208Stepper &st) {
constexpr uint8_t OTPW_bp = 0, OT_bp = 1;
constexpr uint8_t S2G_bm = 0b11110; // 2..5
constexpr uint8_t S2G_bm = 0b111100; // 2..5
TMC_driver_data data;
const auto ds = data.drv_status = st.DRV_STATUS();
data.is_otpw = TEST(ds, OTPW_bp);
@@ -169,9 +169,7 @@
data.is_stealth = TEST(ds, STEALTH_bp);
data.is_standstill = TEST(ds, STST_bp);
#endif
#if HAS_STALLGUARD
data.sg_result_reasonable = false;
#endif
TERN_(HAS_STALLGUARD, data.sg_result_reasonable = false);
#endif
return data;
}
@@ -210,12 +208,10 @@
#if ENABLED(STOP_ON_ERROR)
void report_driver_error(const TMC_driver_data &data) {
SERIAL_ECHOPGM(" driver error detected: 0x");
SERIAL_PRINTLN(data.drv_status, HEX);
SERIAL_PRINTLN(data.drv_status, PrintBase::Hex);
if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit");
#if ENABLED(TMC_DEBUG)
tmc_report_all(true, true, true, true);
#endif
TERN_(TMC_DEBUG, tmc_report_all());
kill(PSTR("Driver error"));
}
#endif
@@ -230,17 +226,17 @@
SERIAL_ECHO(timestamp);
SERIAL_ECHOPGM(": ");
st.printLabel();
SERIAL_ECHOLNPAIR(" driver overtemperature warning! (", st.getMilliamps(), "mA)");
SERIAL_ECHOLNPGM(" driver overtemperature warning! (", st.getMilliamps(), "mA)");
}
template<typename TMC>
void report_polled_driver_data(TMC &st, const TMC_driver_data &data) {
const uint32_t pwm_scale = get_pwm_scale(st);
st.printLabel();
SERIAL_CHAR(':'); SERIAL_PRINT(pwm_scale, DEC);
SERIAL_CHAR(':'); SERIAL_ECHO(pwm_scale);
#if ENABLED(TMC_DEBUG)
#if HAS_TMCX1X0 || HAS_TMC220x
SERIAL_CHAR('/'); SERIAL_PRINT(data.cs_actual, DEC);
SERIAL_CHAR('/'); SERIAL_ECHO(data.cs_actual);
#endif
#if HAS_STALLGUARD
SERIAL_CHAR('/');
@@ -261,7 +257,7 @@
#endif
if (st.flag_otpw) SERIAL_CHAR('F'); // otpw Flag
SERIAL_CHAR('|');
if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC);
if (st.otpw_count > 0) SERIAL_ECHO(st.otpw_count);
SERIAL_CHAR('\t');
}
@@ -275,7 +271,7 @@
st.rms_current(I_rms);
#if ENABLED(REPORT_CURRENT_CHANGE)
st.printLabel();
SERIAL_ECHOLNPAIR(" current decreased to ", I_rms);
SERIAL_ECHOLNPGM(" current decreased to ", I_rms);
#endif
}
}
@@ -295,7 +291,7 @@
bool should_step_down = false;
if (need_update_error_counters) {
if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++;
if (data.is_ot | data.is_s2g) st.error_count++;
else if (st.error_count > 0) st.error_count--;
#if ENABLED(STOP_ON_ERROR)
@@ -421,6 +417,21 @@
}
#endif
#if AXIS_IS_TMC(I)
if (monitor_tmc_driver(stepperI, need_update_error_counters, need_debug_reporting))
step_current_down(stepperI);
#endif
#if AXIS_IS_TMC(J)
if (monitor_tmc_driver(stepperJ, need_update_error_counters, need_debug_reporting))
step_current_down(stepperJ);
#endif
#if AXIS_IS_TMC(K)
if (monitor_tmc_driver(stepperK, need_update_error_counters, need_debug_reporting))
step_current_down(stepperK);
#endif
#if AXIS_IS_TMC(E0)
(void)monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting);
#endif
@@ -446,9 +457,7 @@
(void)monitor_tmc_driver(stepperE7, need_update_error_counters, need_debug_reporting);
#endif
#if ENABLED(TMC_DEBUG)
if (need_debug_reporting) SERIAL_EOL();
#endif
if (TERN0(TMC_DEBUG, need_debug_reporting)) SERIAL_EOL();
}
}
@@ -486,6 +495,10 @@
TMC_GLOBAL_SCALER,
TMC_CS_ACTUAL,
TMC_PWM_SCALE,
TMC_PWM_SCALE_SUM,
TMC_PWM_SCALE_AUTO,
TMC_PWM_OFS_AUTO,
TMC_PWM_GRAD_AUTO,
TMC_VSENSE,
TMC_STEALTHCHOP,
TMC_MICROSTEPS,
@@ -498,7 +511,9 @@
TMC_TBL,
TMC_HEND,
TMC_HSTRT,
TMC_SGT
TMC_SGT,
TMC_MSCNT,
TMC_INTERPOLATE
};
enum TMC_drv_status_enum : char {
TMC_DRV_CODES,
@@ -546,14 +561,15 @@
};
template<class TMC>
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
static void print_vsense(TMC &st) { SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC5130)
static void _tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@@ -562,9 +578,9 @@
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('*'); break;
case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break;
case TMC_SG_RESULT: SERIAL_ECHO(st.sg_result()); break;
case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('*'); break;
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break;
default: break;
}
}
@@ -579,16 +595,17 @@
static void _tmc_status(TMC2160Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_PWM_SCALE: SERIAL_ECHO(st.PWM_SCALE()); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.en_pwm_mode()); break;
case TMC_GLOBAL_SCALER:
{
uint16_t value = st.GLOBAL_SCALER();
SERIAL_PRINT(value ?: 256, DEC);
SERIAL_ECHO(value ? value : 256);
SERIAL_ECHOPGM("/256");
}
break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@@ -597,10 +614,12 @@
#if HAS_TMC220x
static void _tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
case TMC_PWM_SCALE_SUM: SERIAL_ECHO(st.pwm_scale_sum()); break;
case TMC_PWM_SCALE_AUTO: SERIAL_ECHO(st.pwm_scale_auto()); break;
case TMC_PWM_OFS_AUTO: SERIAL_ECHO(st.pwm_ofs_auto()); break;
case TMC_PWM_GRAD_AUTO: SERIAL_ECHO(st.pwm_grad_auto()); break;
case TMC_STEALTHCHOP: serialprint_truefalse(st.stealth()); break;
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('*'); break;
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('*'); break;
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
@@ -609,8 +628,8 @@
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
static void _tmc_status(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const TMC_debug_enum i) {
switch (i) {
case TMC_SGT: SERIAL_PRINT(st.SGTHRS(), DEC); break;
case TMC_UART_ADDR: SERIAL_PRINT(st.get_address(), DEC); break;
case TMC_SGT: SERIAL_ECHO(st.SGTHRS()); break;
case TMC_UART_ADDR: SERIAL_ECHO(st.get_address()); break;
default:
TMC2208Stepper *parent = &st;
_tmc_status(*parent, i);
@@ -625,7 +644,9 @@
case TMC_T150: if (st.t150()) SERIAL_CHAR('*'); break;
case TMC_T143: if (st.t143()) SERIAL_CHAR('*'); break;
case TMC_T120: if (st.t120()) SERIAL_CHAR('*'); break;
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('*'); break;
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('*'); break;
case TMC_DRV_CS_ACTUAL: SERIAL_ECHO(st.cs_actual()); break;
default: break;
}
}
@@ -633,7 +654,7 @@
#if HAS_DRIVER(TMC2209)
static void _tmc_parse_drv_status(TMC2209Stepper &st, const TMC_drv_status_enum i) {
switch (i) {
case TMC_SG_RESULT: SERIAL_PRINT(st.SG_RESULT(), DEC); break;
case TMC_SG_RESULT: SERIAL_ECHO(st.SG_RESULT()); break;
default: _tmc_parse_drv_status(static_cast<TMC2208Stepper &>(st), i); break;
}
}
@@ -642,6 +663,12 @@
#if HAS_DRIVER(TMC2660)
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
static void _tmc_status(TMC2660Stepper &st, const TMC_debug_enum i) {
switch (i) {
case TMC_INTERPOLATE: serialprint_truefalse(st.intpol()); break;
default: break;
}
}
#endif
template <typename TMC>
@@ -654,15 +681,15 @@
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
case TMC_IRUN:
SERIAL_PRINT(st.irun(), DEC);
SERIAL_ECHO(st.irun());
SERIAL_ECHOPGM("/31");
break;
case TMC_IHOLD:
SERIAL_PRINT(st.ihold(), DEC);
SERIAL_ECHO(st.ihold());
SERIAL_ECHOPGM("/31");
break;
case TMC_CS_ACTUAL:
SERIAL_PRINT(st.cs_actual(), DEC);
SERIAL_ECHO(st.cs_actual());
SERIAL_ECHOPGM("/31");
break;
case TMC_VSENSE: print_vsense(st); break;
@@ -682,10 +709,11 @@
#if ENABLED(MONITOR_DRIVER_STATUS)
case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
#endif
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: SERIAL_ECHO(st.blank_time()); break;
case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break;
case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break;
case TMC_MSCNT: SERIAL_ECHO(st.get_microstep_counter()); break;
default: _tmc_status(st, i); break;
}
}
@@ -701,18 +729,18 @@
case TMC_RMS_CURRENT: SERIAL_ECHO(st.rms_current()); break;
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
case TMC_IRUN:
SERIAL_PRINT(st.cs(), DEC);
SERIAL_ECHO(st.cs());
SERIAL_ECHOPGM("/31");
break;
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
case TMC_VSENSE: SERIAL_ECHOPGM_P(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
//case TMC_OTPW: serialprint_truefalse(st.otpw()); break;
//case TMC_OTPW_TRIGGERED: serialprint_truefalse(st.getOTPW()); break;
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
case TMC_SGT: SERIAL_ECHO(st.sgt()); break;
case TMC_TOFF: SERIAL_ECHO(st.toff()); break;
case TMC_TBL: SERIAL_ECHO(st.blank_time()); break;
case TMC_HEND: SERIAL_ECHO(st.hysteresis_end()); break;
case TMC_HSTRT: SERIAL_ECHO(st.hysteresis_start()); break;
default: break;
}
}
@@ -744,128 +772,148 @@
}
}
static void tmc_debug_loop(const TMC_debug_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) {
if (print_x) {
static void tmc_debug_loop(const TMC_debug_enum n, LOGICAL_AXIS_ARGS(const bool)) {
if (x) {
#if AXIS_IS_TMC(X)
tmc_status(stepperX, i);
tmc_status(stepperX, n);
#endif
#if AXIS_IS_TMC(X2)
tmc_status(stepperX2, i);
tmc_status(stepperX2, n);
#endif
}
if (print_y) {
if (TERN0(HAS_Y_AXIS, y)) {
#if AXIS_IS_TMC(Y)
tmc_status(stepperY, i);
tmc_status(stepperY, n);
#endif
#if AXIS_IS_TMC(Y2)
tmc_status(stepperY2, i);
tmc_status(stepperY2, n);
#endif
}
if (print_z) {
if (TERN0(HAS_Z_AXIS, z)) {
#if AXIS_IS_TMC(Z)
tmc_status(stepperZ, i);
tmc_status(stepperZ, n);
#endif
#if AXIS_IS_TMC(Z2)
tmc_status(stepperZ2, i);
tmc_status(stepperZ2, n);
#endif
#if AXIS_IS_TMC(Z3)
tmc_status(stepperZ3, i);
tmc_status(stepperZ3, n);
#endif
#if AXIS_IS_TMC(Z4)
tmc_status(stepperZ4, i);
tmc_status(stepperZ4, n);
#endif
}
if (print_e) {
#if AXIS_IS_TMC(I)
if (i) tmc_status(stepperI, n);
#endif
#if AXIS_IS_TMC(J)
if (j) tmc_status(stepperJ, n);
#endif
#if AXIS_IS_TMC(K)
if (k) tmc_status(stepperK, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
tmc_status(stepperE0, i);
tmc_status(stepperE0, n);
#endif
#if AXIS_IS_TMC(E1)
tmc_status(stepperE1, i);
tmc_status(stepperE1, n);
#endif
#if AXIS_IS_TMC(E2)
tmc_status(stepperE2, i);
tmc_status(stepperE2, n);
#endif
#if AXIS_IS_TMC(E3)
tmc_status(stepperE3, i);
tmc_status(stepperE3, n);
#endif
#if AXIS_IS_TMC(E4)
tmc_status(stepperE4, i);
tmc_status(stepperE4, n);
#endif
#if AXIS_IS_TMC(E5)
tmc_status(stepperE5, i);
tmc_status(stepperE5, n);
#endif
#if AXIS_IS_TMC(E6)
tmc_status(stepperE6, i);
tmc_status(stepperE6, n);
#endif
#if AXIS_IS_TMC(E7)
tmc_status(stepperE7, i);
tmc_status(stepperE7, n);
#endif
}
SERIAL_EOL();
}
static void drv_status_loop(const TMC_drv_status_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) {
if (print_x) {
static void drv_status_loop(const TMC_drv_status_enum n, LOGICAL_AXIS_ARGS(const bool)) {
if (x) {
#if AXIS_IS_TMC(X)
tmc_parse_drv_status(stepperX, i);
tmc_parse_drv_status(stepperX, n);
#endif
#if AXIS_IS_TMC(X2)
tmc_parse_drv_status(stepperX2, i);
tmc_parse_drv_status(stepperX2, n);
#endif
}
if (print_y) {
if (TERN0(HAS_Y_AXIS, y)) {
#if AXIS_IS_TMC(Y)
tmc_parse_drv_status(stepperY, i);
tmc_parse_drv_status(stepperY, n);
#endif
#if AXIS_IS_TMC(Y2)
tmc_parse_drv_status(stepperY2, i);
tmc_parse_drv_status(stepperY2, n);
#endif
}
if (print_z) {
if (TERN0(HAS_Z_AXIS, z)) {
#if AXIS_IS_TMC(Z)
tmc_parse_drv_status(stepperZ, i);
tmc_parse_drv_status(stepperZ, n);
#endif
#if AXIS_IS_TMC(Z2)
tmc_parse_drv_status(stepperZ2, i);
tmc_parse_drv_status(stepperZ2, n);
#endif
#if AXIS_IS_TMC(Z3)
tmc_parse_drv_status(stepperZ3, i);
tmc_parse_drv_status(stepperZ3, n);
#endif
#if AXIS_IS_TMC(Z4)
tmc_parse_drv_status(stepperZ4, i);
tmc_parse_drv_status(stepperZ4, n);
#endif
}
if (print_e) {
#if AXIS_IS_TMC(I)
if (i) tmc_parse_drv_status(stepperI, n);
#endif
#if AXIS_IS_TMC(J)
if (j) tmc_parse_drv_status(stepperJ, n);
#endif
#if AXIS_IS_TMC(K)
if (k) tmc_parse_drv_status(stepperK, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
tmc_parse_drv_status(stepperE0, i);
tmc_parse_drv_status(stepperE0, n);
#endif
#if AXIS_IS_TMC(E1)
tmc_parse_drv_status(stepperE1, i);
tmc_parse_drv_status(stepperE1, n);
#endif
#if AXIS_IS_TMC(E2)
tmc_parse_drv_status(stepperE2, i);
tmc_parse_drv_status(stepperE2, n);
#endif
#if AXIS_IS_TMC(E3)
tmc_parse_drv_status(stepperE3, i);
tmc_parse_drv_status(stepperE3, n);
#endif
#if AXIS_IS_TMC(E4)
tmc_parse_drv_status(stepperE4, i);
tmc_parse_drv_status(stepperE4, n);
#endif
#if AXIS_IS_TMC(E5)
tmc_parse_drv_status(stepperE5, i);
tmc_parse_drv_status(stepperE5, n);
#endif
#if AXIS_IS_TMC(E6)
tmc_parse_drv_status(stepperE6, i);
tmc_parse_drv_status(stepperE6, n);
#endif
#if AXIS_IS_TMC(E7)
tmc_parse_drv_status(stepperE7, i);
tmc_parse_drv_status(stepperE7, n);
#endif
}
@@ -876,9 +924,10 @@
* M122 report functions
*/
void tmc_report_all(bool print_x, const bool print_y, const bool print_z, const bool print_e) {
#define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM, print_x, print_y, print_z, print_e); }while(0)
#define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM, print_x, print_y, print_z, print_e); }while(0)
void tmc_report_all(LOGICAL_AXIS_ARGS(const bool)) {
#define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM, LOGICAL_AXIS_ARGS()); }while(0)
#define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM, LOGICAL_AXIS_ARGS()); }while(0)
TMC_REPORT("\t", TMC_CODES);
#if HAS_DRIVER(TMC2209)
TMC_REPORT("Address\t", TMC_UART_ADDR);
@@ -899,6 +948,7 @@
#endif
TMC_REPORT("stealthChop", TMC_STEALTHCHOP);
TMC_REPORT("msteps\t", TMC_MICROSTEPS);
TMC_REPORT("interp\t", TMC_INTERPOLATE);
TMC_REPORT("tstep\t", TMC_TSTEP);
TMC_REPORT("PWM thresh.", TMC_TPWMTHRS);
TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS);
@@ -906,11 +956,20 @@
#if ENABLED(MONITOR_DRIVER_STATUS)
TMC_REPORT("triggered\n OTP\t", TMC_OTPW_TRIGGERED);
#endif
#if HAS_TMC220x
TMC_REPORT("pwm scale sum", TMC_PWM_SCALE_SUM);
TMC_REPORT("pwm scale auto", TMC_PWM_SCALE_AUTO);
TMC_REPORT("pwm offset auto", TMC_PWM_OFS_AUTO);
TMC_REPORT("pwm grad auto", TMC_PWM_GRAD_AUTO);
#endif
TMC_REPORT("off time", TMC_TOFF);
TMC_REPORT("blank time", TMC_TBL);
TMC_REPORT("hysteresis\n -end\t", TMC_HEND);
TMC_REPORT(" -start\t", TMC_HSTRT);
TMC_REPORT("Stallguard thrs", TMC_SGT);
TMC_REPORT("uStep count", TMC_MSCNT);
DRV_REPORT("DRVSTATUS", TMC_DRV_CODES);
#if HAS_TMCX1X0 || HAS_TMC220x
DRV_REPORT("sg_result", TMC_SG_RESULT);
@@ -992,72 +1051,82 @@
}
#endif
static void tmc_get_registers(TMC_get_registers_enum i, const bool print_x, const bool print_y, const bool print_z, const bool print_e) {
if (print_x) {
static void tmc_get_registers(TMC_get_registers_enum n, LOGICAL_AXIS_ARGS(const bool)) {
if (x) {
#if AXIS_IS_TMC(X)
tmc_get_registers(stepperX, i);
tmc_get_registers(stepperX, n);
#endif
#if AXIS_IS_TMC(X2)
tmc_get_registers(stepperX2, i);
tmc_get_registers(stepperX2, n);
#endif
}
if (print_y) {
if (TERN0(HAS_Y_AXIS, y)) {
#if AXIS_IS_TMC(Y)
tmc_get_registers(stepperY, i);
tmc_get_registers(stepperY, n);
#endif
#if AXIS_IS_TMC(Y2)
tmc_get_registers(stepperY2, i);
tmc_get_registers(stepperY2, n);
#endif
}
if (print_z) {
if (TERN0(HAS_Z_AXIS, z)) {
#if AXIS_IS_TMC(Z)
tmc_get_registers(stepperZ, i);
tmc_get_registers(stepperZ, n);
#endif
#if AXIS_IS_TMC(Z2)
tmc_get_registers(stepperZ2, i);
tmc_get_registers(stepperZ2, n);
#endif
#if AXIS_IS_TMC(Z3)
tmc_get_registers(stepperZ3, i);
tmc_get_registers(stepperZ3, n);
#endif
#if AXIS_IS_TMC(Z4)
tmc_get_registers(stepperZ4, i);
tmc_get_registers(stepperZ4, n);
#endif
}
if (print_e) {
#if AXIS_IS_TMC(I)
if (i) tmc_get_registers(stepperI, n);
#endif
#if AXIS_IS_TMC(J)
if (j) tmc_get_registers(stepperJ, n);
#endif
#if AXIS_IS_TMC(K)
if (k) tmc_get_registers(stepperK, n);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
tmc_get_registers(stepperE0, i);
tmc_get_registers(stepperE0, n);
#endif
#if AXIS_IS_TMC(E1)
tmc_get_registers(stepperE1, i);
tmc_get_registers(stepperE1, n);
#endif
#if AXIS_IS_TMC(E2)
tmc_get_registers(stepperE2, i);
tmc_get_registers(stepperE2, n);
#endif
#if AXIS_IS_TMC(E3)
tmc_get_registers(stepperE3, i);
tmc_get_registers(stepperE3, n);
#endif
#if AXIS_IS_TMC(E4)
tmc_get_registers(stepperE4, i);
tmc_get_registers(stepperE4, n);
#endif
#if AXIS_IS_TMC(E5)
tmc_get_registers(stepperE5, i);
tmc_get_registers(stepperE5, n);
#endif
#if AXIS_IS_TMC(E6)
tmc_get_registers(stepperE6, i);
tmc_get_registers(stepperE6, n);
#endif
#if AXIS_IS_TMC(E7)
tmc_get_registers(stepperE7, i);
tmc_get_registers(stepperE7, n);
#endif
}
SERIAL_EOL();
}
void tmc_get_registers(bool print_x, bool print_y, bool print_z, bool print_e) {
#define _TMC_GET_REG(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_get_registers(ITEM, print_x, print_y, print_z, print_e); }while(0)
void tmc_get_registers(LOGICAL_AXIS_ARGS(bool)) {
#define _TMC_GET_REG(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_get_registers(ITEM, LOGICAL_AXIS_ARGS()); }while(0)
#define TMC_GET_REG(NAME, TABS) _TMC_GET_REG(STRINGIFY(NAME) TABS, TMC_GET_##NAME)
_TMC_GET_REG("\t", TMC_AXIS_CODES);
TMC_GET_REG(GCONF, "\t\t");
@@ -1142,6 +1211,15 @@
#if AXIS_HAS_SPI(Z4)
SET_CS_PIN(Z4);
#endif
#if AXIS_HAS_SPI(I)
SET_CS_PIN(I);
#endif
#if AXIS_HAS_SPI(J)
SET_CS_PIN(J);
#endif
#if AXIS_HAS_SPI(K)
SET_CS_PIN(K);
#endif
#if AXIS_HAS_SPI(E0)
SET_CS_PIN(E0);
#endif
@@ -1185,16 +1263,16 @@ static bool test_connection(TMC &st) {
case 1: stat = PSTR("HIGH"); break;
case 2: stat = PSTR("LOW"); break;
}
serialprintPGM(stat);
SERIAL_ECHOPGM_P(stat);
SERIAL_EOL();
return test_result;
}
void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z, const bool test_e) {
void test_tmc_connection(LOGICAL_AXIS_ARGS(const bool)) {
uint8_t axis_connection = 0;
if (test_x) {
if (x) {
#if AXIS_IS_TMC(X)
axis_connection += test_connection(stepperX);
#endif
@@ -1203,7 +1281,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif
}
if (test_y) {
if (TERN0(HAS_Y_AXIS, y)) {
#if AXIS_IS_TMC(Y)
axis_connection += test_connection(stepperY);
#endif
@@ -1212,7 +1290,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif
}
if (test_z) {
if (TERN0(HAS_Z_AXIS, z)) {
#if AXIS_IS_TMC(Z)
axis_connection += test_connection(stepperZ);
#endif
@@ -1227,7 +1305,17 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif
}
if (test_e) {
#if AXIS_IS_TMC(I)
if (i) axis_connection += test_connection(stepperI);
#endif
#if AXIS_IS_TMC(J)
if (j) axis_connection += test_connection(stepperJ);
#endif
#if AXIS_IS_TMC(K)
if (k) axis_connection += test_connection(stepperK);
#endif
if (TERN0(HAS_EXTRUDERS, e)) {
#if AXIS_IS_TMC(E0)
axis_connection += test_connection(stepperE0);
#endif
@@ -1254,7 +1342,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif
}
if (axis_connection) ui.set_status_P(GET_TEXT(MSG_ERROR_TMC));
if (axis_connection) LCD_MESSAGEPGM(MSG_ERROR_TMC);
}
#endif // HAS_TRINAMIC_CONFIG