|
|
@ -36,7 +36,7 @@ |
|
|
|
#include "../module/planner.h" |
|
|
|
#include "../libs/hex_print_routines.h" |
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS) |
|
|
|
static bool report_tmc_status; // = false;
|
|
|
|
static uint16_t report_tmc_status_interval; // = 0
|
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
@ -55,87 +55,159 @@ |
|
|
|
|
|
|
|
struct TMC_driver_data { |
|
|
|
uint32_t drv_status; |
|
|
|
bool is_otpw, |
|
|
|
is_ot, |
|
|
|
is_s2ga, |
|
|
|
is_s2gb, |
|
|
|
is_error; |
|
|
|
bool is_otpw:1, |
|
|
|
is_ot:1, |
|
|
|
is_s2g:1, |
|
|
|
is_error:1 |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
, is_stall:1 |
|
|
|
, is_stealth:1 |
|
|
|
, is_standstill:1 |
|
|
|
#if HAS_STALLGUARD |
|
|
|
, sg_result_reasonable:1 |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
; |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
#if HAS_TMCX1X0 || HAS_DRIVER(TMC2208) |
|
|
|
uint8_t cs_actual; |
|
|
|
#endif |
|
|
|
#if HAS_STALLGUARD |
|
|
|
uint16_t sg_result; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
}; |
|
|
|
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) |
|
|
|
|
|
|
|
#if HAS_TMCX1X0 |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
static uint32_t get_pwm_scale(TMC2130Stepper &st) { return st.PWM_SCALE(); } |
|
|
|
static uint8_t get_status_response(TMC2130Stepper &st, uint32_t) { return st.status_response & 0xF; } |
|
|
|
#endif |
|
|
|
|
|
|
|
static TMC_driver_data get_driver_data(TMC2130Stepper &st) { |
|
|
|
constexpr uint32_t OTPW_bm = 0x4000000UL; |
|
|
|
constexpr uint8_t OTPW_bp = 26; |
|
|
|
constexpr uint32_t OT_bm = 0x2000000UL; |
|
|
|
constexpr uint8_t OT_bp = 25; |
|
|
|
constexpr uint8_t S2GA_bp = 27; |
|
|
|
constexpr uint8_t S2GB_bp = 28; |
|
|
|
constexpr uint16_t SG_RESULT_bm = 0x3FF; // 0:9
|
|
|
|
constexpr uint8_t STEALTH_bp = 14, CS_ACTUAL_sb = 16; |
|
|
|
constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
|
|
|
|
constexpr uint8_t STALL_GUARD_bp = 24, OT_bp = 25, OTPW_bp = 26; |
|
|
|
constexpr uint32_t S2G_bm = 0x18000000; |
|
|
|
constexpr uint8_t STST_bp = 31; |
|
|
|
TMC_driver_data data; |
|
|
|
data.drv_status = st.DRV_STATUS(); |
|
|
|
data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; |
|
|
|
data.is_ot = (data.drv_status & OT_bm) >> OT_bp; |
|
|
|
data.is_s2ga = (data.drv_status >> S2GA_bp) & 0b1; |
|
|
|
data.is_s2gb = (data.drv_status >> S2GB_bp) & 0b1; |
|
|
|
#ifdef __AVR__ |
|
|
|
// 8-bit optimization saves up to 70 bytes of PROGMEM per axis
|
|
|
|
uint8_t spart; |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
data.sg_result = data.drv_status & SG_RESULT_bm; |
|
|
|
spart = data.drv_status >> 8; |
|
|
|
data.is_stealth = !!(spart & _BV(STEALTH_bp - 8)); |
|
|
|
spart = data.drv_status >> 16; |
|
|
|
data.cs_actual = spart & (CS_ACTUAL_bm >> 16); |
|
|
|
#endif |
|
|
|
spart = data.drv_status >> 24; |
|
|
|
data.is_ot = !!(spart & _BV(OT_bp - 24)); |
|
|
|
data.is_otpw = !!(spart & _BV(OTPW_bp - 24)); |
|
|
|
data.is_s2g = !!(spart & (S2G_bm >> 24)); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
data.is_stall = !!(spart & _BV(STALL_GUARD_bp - 24)); |
|
|
|
data.is_standstill = !!(spart & _BV(STST_bp - 24)); |
|
|
|
data.sg_result_reasonable = !data.is_standstill; // sg_result has no reasonable meaning while standstill
|
|
|
|
#endif |
|
|
|
|
|
|
|
#else // !__AVR__
|
|
|
|
|
|
|
|
data.is_ot = !!(data.drv_status & _BV(OT_bp)); |
|
|
|
data.is_otpw = !!(data.drv_status & _BV(OTPW_bp)); |
|
|
|
data.is_s2g = !!(data.drv_status & S2G_bm); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
data.sg_result = data.drv_status & SG_RESULT_bm; |
|
|
|
data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp)); |
|
|
|
data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb; |
|
|
|
data.is_stall = !!(data.drv_status & _BV(STALL_GUARD_bp)); |
|
|
|
data.is_standstill = !!(data.drv_status & _BV(STST_bp)); |
|
|
|
data.sg_result_reasonable = !data.is_standstill; // sg_result has no reasonable meaning while standstill
|
|
|
|
#endif |
|
|
|
|
|
|
|
#endif // !__AVR__
|
|
|
|
|
|
|
|
return data; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif // HAS_TMCX1X0
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2208) |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
static uint32_t get_pwm_scale(TMC2208Stepper &st) { return st.pwm_scale_sum(); } |
|
|
|
static uint8_t get_status_response(TMC2208Stepper &st, uint32_t drv_status) { |
|
|
|
uint8_t gstat = st.GSTAT(); |
|
|
|
uint8_t response = 0; |
|
|
|
response |= (drv_status >> (31 - 3)) & 0b1000; |
|
|
|
response |= gstat & 0b11; |
|
|
|
return response; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
static TMC_driver_data get_driver_data(TMC2208Stepper &st) { |
|
|
|
constexpr uint32_t OTPW_bm = 0b1ul; |
|
|
|
constexpr uint8_t OTPW_bp = 0; |
|
|
|
constexpr uint32_t OT_bm = 0b10ul; |
|
|
|
constexpr uint8_t OT_bp = 1; |
|
|
|
constexpr uint8_t S2GA_bp = 2; |
|
|
|
constexpr uint8_t S2GB_bp = 3; |
|
|
|
constexpr uint8_t OTPW_bp = 0, OT_bp = 1; |
|
|
|
constexpr uint8_t S2G_bm = 0b11110; // 2..5
|
|
|
|
constexpr uint8_t CS_ACTUAL_sb = 16; |
|
|
|
constexpr uint32_t CS_ACTUAL_bm = 0x1F0000; // 16:20
|
|
|
|
constexpr uint8_t STEALTH_bp = 30, STST_bp = 31; |
|
|
|
TMC_driver_data data; |
|
|
|
data.drv_status = st.DRV_STATUS(); |
|
|
|
data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; |
|
|
|
data.is_ot = (data.drv_status & OT_bm) >> OT_bp; |
|
|
|
data.is_s2ga = (data.drv_status >> S2GA_bp) & 0b1; |
|
|
|
data.is_s2gb = (data.drv_status >> S2GB_bp) & 0b1; |
|
|
|
data.is_otpw = !!(data.drv_status & _BV(OTPW_bp)); |
|
|
|
data.is_ot = !!(data.drv_status & _BV(OT_bp)); |
|
|
|
data.is_s2g = !!(data.drv_status & S2G_bm); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
#ifdef __AVR__ |
|
|
|
// 8-bit optimization saves up to 12 bytes of PROGMEM per axis
|
|
|
|
uint8_t spart = data.drv_status >> 16; |
|
|
|
data.cs_actual = spart & (CS_ACTUAL_bm >> 16); |
|
|
|
spart = data.drv_status >> 24; |
|
|
|
data.is_stealth = !!(spart & _BV(STEALTH_bp - 24)); |
|
|
|
data.is_standstill = !!(spart & _BV(STST_bp - 24)); |
|
|
|
#else |
|
|
|
data.cs_actual = (data.drv_status & CS_ACTUAL_bm) >> CS_ACTUAL_sb; |
|
|
|
data.is_stealth = !!(data.drv_status & _BV(STEALTH_bp)); |
|
|
|
data.is_standstill = !!(data.drv_status & _BV(STST_bp)); |
|
|
|
#endif |
|
|
|
#if HAS_STALLGUARD |
|
|
|
data.sg_result_reasonable = false; |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
return data; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif // TMC2208
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2660) |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
static uint32_t get_pwm_scale(TMC2660Stepper) { return 0; } |
|
|
|
static uint8_t get_status_response(TMC2660Stepper, uint32_t drv_status) { |
|
|
|
return drv_status & 0xFF; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
static TMC_driver_data get_driver_data(TMC2660Stepper &st) { |
|
|
|
constexpr uint32_t OTPW_bm = 0x4UL; |
|
|
|
constexpr uint8_t OTPW_bp = 2; |
|
|
|
constexpr uint32_t OT_bm = 0x2UL; |
|
|
|
constexpr uint8_t OT_bp = 1; |
|
|
|
constexpr uint8_t STALL_GUARD_bp = 0; |
|
|
|
constexpr uint8_t OT_bp = 1, OTPW_bp = 2; |
|
|
|
constexpr uint8_t S2G_bm = 0b11000; |
|
|
|
constexpr uint8_t STST_bp = 7, SG_RESULT_sp = 10; |
|
|
|
constexpr uint32_t SG_RESULT_bm = 0xFFC00; // 10:19
|
|
|
|
TMC_driver_data data; |
|
|
|
data.drv_status = st.DRVSTATUS(); |
|
|
|
data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp; |
|
|
|
data.is_ot = (data.drv_status & OT_bm) >> OT_bp; |
|
|
|
uint8_t spart = data.drv_status & 0xFF; |
|
|
|
data.is_otpw = !!(spart & _BV(OTPW_bp)); |
|
|
|
data.is_ot = !!(spart & _BV(OT_bp)); |
|
|
|
data.is_s2g = !!(data.drv_status & S2G_bm); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
data.is_stall = !!(spart & _BV(STALL_GUARD_bp)); |
|
|
|
data.is_standstill = !!(spart & _BV(STST_bp)); |
|
|
|
data.sg_result = (data.drv_status & SG_RESULT_bm) >> SG_RESULT_sp; |
|
|
|
data.sg_result_reasonable = true; |
|
|
|
#endif |
|
|
|
return data; |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
#endif // TMC2660
|
|
|
|
|
|
|
|
#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); |
|
|
|
if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature"); |
|
|
|
if (data.is_s2ga) SERIAL_ECHOLNPGM("short to ground (coil A)"); |
|
|
|
if (data.is_s2gb) SERIAL_ECHOLNPGM("short to ground (coil B)"); |
|
|
|
if (data.is_s2g) SERIAL_ECHOLNPGM("coil short circuit"); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
tmc_report_all(true, true, true, true); |
|
|
|
#endif |
|
|
@ -162,61 +234,79 @@ |
|
|
|
void report_polled_driver_data(TMC &st, const TMC_driver_data &data) { |
|
|
|
const uint32_t pwm_scale = get_pwm_scale(st); |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOPAIR(":", pwm_scale); |
|
|
|
SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st, data.drv_status), BIN); |
|
|
|
SERIAL_ECHOPGM("| "); |
|
|
|
if (st.error_count) SERIAL_CHAR('E'); |
|
|
|
else if (data.is_ot) SERIAL_CHAR('O'); |
|
|
|
else if (data.is_otpw) SERIAL_CHAR('W'); |
|
|
|
else if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); |
|
|
|
else if (st.flag_otpw) SERIAL_CHAR('F'); |
|
|
|
SERIAL_CHAR(':'); SERIAL_PRINT(pwm_scale, DEC); |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
#if HAS_TMCX1X0 || HAS_DRIVER(TMC2208) |
|
|
|
SERIAL_CHAR('/'); SERIAL_PRINT(data.cs_actual, DEC); |
|
|
|
#endif |
|
|
|
#if HAS_STALLGUARD |
|
|
|
SERIAL_CHAR('/'); |
|
|
|
if (data.sg_result_reasonable) |
|
|
|
SERIAL_ECHO(data.sg_result); |
|
|
|
else |
|
|
|
SERIAL_CHAR('-'); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
SERIAL_CHAR('|'); |
|
|
|
if (st.error_count) SERIAL_CHAR('E'); // Error
|
|
|
|
if (data.is_ot) SERIAL_CHAR('O'); // Over-temperature
|
|
|
|
if (data.is_otpw) SERIAL_CHAR('W'); // over-temperature pre-Warning
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
if (data.is_stall) SERIAL_CHAR('G'); // stallGuard
|
|
|
|
if (data.is_stealth) SERIAL_CHAR('T'); // stealthChop
|
|
|
|
if (data.is_standstill) SERIAL_CHAR('I'); // standstIll
|
|
|
|
#endif |
|
|
|
if (st.flag_otpw) SERIAL_CHAR('F'); // otpw Flag
|
|
|
|
SERIAL_CHAR('|'); |
|
|
|
if (st.otpw_count > 0) SERIAL_PRINT(st.otpw_count, DEC); |
|
|
|
SERIAL_CHAR('\t'); |
|
|
|
} |
|
|
|
|
|
|
|
template<typename TMC> |
|
|
|
void monitor_tmc_driver(TMC &st) { |
|
|
|
void monitor_tmc_driver(TMC &st, const bool need_update_error_counters, const bool need_debug_reporting) { |
|
|
|
TMC_driver_data data = get_driver_data(st); |
|
|
|
if ((data.drv_status == 0xFFFFFFFF) || (data.drv_status == 0x0)) return; |
|
|
|
if (data.drv_status == 0xFFFFFFFF || data.drv_status == 0x0) return; |
|
|
|
|
|
|
|
if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++; |
|
|
|
else if (st.error_count > 0) st.error_count--; |
|
|
|
if (need_update_error_counters) { |
|
|
|
if (data.is_ot /* | data.s2ga | data.s2gb*/) st.error_count++; |
|
|
|
else if (st.error_count > 0) st.error_count--; |
|
|
|
|
|
|
|
#if ENABLED(STOP_ON_ERROR) |
|
|
|
if (st.error_count >= 10) { |
|
|
|
SERIAL_EOL(); |
|
|
|
st.printLabel(); |
|
|
|
report_driver_error(data); |
|
|
|
} |
|
|
|
#endif |
|
|
|
#if ENABLED(STOP_ON_ERROR) |
|
|
|
if (st.error_count >= 10) { |
|
|
|
SERIAL_EOL(); |
|
|
|
st.printLabel(); |
|
|
|
report_driver_error(data); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// Report if a warning was triggered
|
|
|
|
if (data.is_otpw && st.otpw_count == 0) { |
|
|
|
report_driver_otpw(st); |
|
|
|
} |
|
|
|
#if CURRENT_STEP_DOWN > 0 |
|
|
|
// Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
|
|
|
|
if (data.is_otpw && st.otpw_count > 4) { |
|
|
|
uint16_t I_rms = st.getMilliamps(); |
|
|
|
if (st.isEnabled() && I_rms > 100) { |
|
|
|
st.rms_current(I_rms - (CURRENT_STEP_DOWN)); |
|
|
|
#if ENABLED(REPORT_CURRENT_CHANGE) |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps()); |
|
|
|
#endif |
|
|
|
// Report if a warning was triggered
|
|
|
|
if (data.is_otpw && st.otpw_count == 0) |
|
|
|
report_driver_otpw(st); |
|
|
|
|
|
|
|
#if CURRENT_STEP_DOWN > 0 |
|
|
|
// Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
|
|
|
|
if (data.is_otpw && st.otpw_count > 4) { |
|
|
|
uint16_t I_rms = st.getMilliamps(); |
|
|
|
if (st.isEnabled() && I_rms > 100) { |
|
|
|
st.rms_current(I_rms - (CURRENT_STEP_DOWN)); |
|
|
|
#if ENABLED(REPORT_CURRENT_CHANGE) |
|
|
|
st.printLabel(); |
|
|
|
SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps()); |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
if (data.is_otpw) { |
|
|
|
st.otpw_count++; |
|
|
|
st.flag_otpw = true; |
|
|
|
if (data.is_otpw) { |
|
|
|
st.otpw_count++; |
|
|
|
st.flag_otpw = true; |
|
|
|
} |
|
|
|
else if (st.otpw_count > 0) st.otpw_count = 0; |
|
|
|
} |
|
|
|
else if (st.otpw_count > 0) st.otpw_count = 0; |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
if (report_tmc_status) { |
|
|
|
if (need_debug_reporting) |
|
|
|
report_polled_driver_data(st, data); |
|
|
|
} |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
@ -225,50 +315,60 @@ |
|
|
|
void monitor_tmc_driver() { |
|
|
|
static millis_t next_poll = 0; |
|
|
|
const millis_t ms = millis(); |
|
|
|
if (ELAPSED(ms, next_poll)) { |
|
|
|
next_poll = ms + 500; |
|
|
|
bool need_update_error_counters = ELAPSED(ms, next_poll); |
|
|
|
bool need_debug_reporting = false; |
|
|
|
if (need_update_error_counters) |
|
|
|
next_poll = ms + MONITOR_DRIVER_STATUS_INTERVAL_MS; |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
static millis_t next_debug_reporting = 0; |
|
|
|
if (report_tmc_status_interval && ELAPSED(ms, next_debug_reporting)) { |
|
|
|
need_debug_reporting = true; |
|
|
|
next_debug_reporting = ms + report_tmc_status_interval; |
|
|
|
} |
|
|
|
#endif |
|
|
|
if (need_update_error_counters || need_debug_reporting) { |
|
|
|
#if HAS_HW_COMMS(X) |
|
|
|
monitor_tmc_driver(stepperX); |
|
|
|
monitor_tmc_driver(stepperX, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Y) |
|
|
|
monitor_tmc_driver(stepperY); |
|
|
|
monitor_tmc_driver(stepperY, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z) |
|
|
|
monitor_tmc_driver(stepperZ); |
|
|
|
monitor_tmc_driver(stepperZ, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(X2) |
|
|
|
monitor_tmc_driver(stepperX2); |
|
|
|
monitor_tmc_driver(stepperX2, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Y2) |
|
|
|
monitor_tmc_driver(stepperY2); |
|
|
|
monitor_tmc_driver(stepperY2, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z2) |
|
|
|
monitor_tmc_driver(stepperZ2); |
|
|
|
monitor_tmc_driver(stepperZ2, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(Z3) |
|
|
|
monitor_tmc_driver(stepperZ3); |
|
|
|
monitor_tmc_driver(stepperZ3, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E0) |
|
|
|
monitor_tmc_driver(stepperE0); |
|
|
|
monitor_tmc_driver(stepperE0, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E1) |
|
|
|
monitor_tmc_driver(stepperE1); |
|
|
|
monitor_tmc_driver(stepperE1, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E2) |
|
|
|
monitor_tmc_driver(stepperE2); |
|
|
|
monitor_tmc_driver(stepperE2, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E3) |
|
|
|
monitor_tmc_driver(stepperE3); |
|
|
|
monitor_tmc_driver(stepperE3, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E4) |
|
|
|
monitor_tmc_driver(stepperE4); |
|
|
|
monitor_tmc_driver(stepperE4, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
#if HAS_HW_COMMS(E5) |
|
|
|
monitor_tmc_driver(stepperE5); |
|
|
|
monitor_tmc_driver(stepperE5, need_update_error_counters, need_debug_reporting); |
|
|
|
#endif |
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
if (report_tmc_status) SERIAL_EOL(); |
|
|
|
if (need_debug_reporting) SERIAL_EOL(); |
|
|
|
#endif |
|
|
|
} |
|
|
|
} |
|
|
@ -278,12 +378,20 @@ |
|
|
|
#if ENABLED(TMC_DEBUG) |
|
|
|
|
|
|
|
/**
|
|
|
|
* M122 S[1,0] Enable periodic status reports |
|
|
|
* M122 [S<0|1>] [Pnnn] Enable periodic status reports |
|
|
|
*/ |
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS) |
|
|
|
void tmc_set_report_status(const bool status) { |
|
|
|
if ((report_tmc_status = status)) |
|
|
|
SERIAL_ECHOLNPGM("axis:pwm_scale |status_response|"); |
|
|
|
void tmc_set_report_interval(const uint16_t update_interval) { |
|
|
|
if ((report_tmc_status_interval = update_interval)) |
|
|
|
SERIAL_ECHOLNPGM("axis:pwm_scale" |
|
|
|
#if HAS_STEALTHCHOP |
|
|
|
"/current_scale" |
|
|
|
#endif |
|
|
|
#if HAS_STALLGUARD |
|
|
|
"/mech_load" |
|
|
|
#endif |
|
|
|
"|flags|warncount" |
|
|
|
); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
@ -360,7 +468,7 @@ |
|
|
|
template<class TMC> |
|
|
|
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); } |
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) |
|
|
|
#if HAS_TMCX1X0 |
|
|
|
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) { |
|
|
|
switch (i) { |
|
|
|
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break; |
|
|
@ -702,7 +810,7 @@ |
|
|
|
TMC_REPORT("Stallguard thrs", TMC_SGT); |
|
|
|
|
|
|
|
DRV_REPORT("DRVSTATUS", TMC_DRV_CODES); |
|
|
|
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) |
|
|
|
#if HAS_TMCX1X0 |
|
|
|
DRV_REPORT("stallguard\t", TMC_STALLGUARD); |
|
|
|
DRV_REPORT("sg_result\t", TMC_SG_RESULT); |
|
|
|
DRV_REPORT("fsactive\t", TMC_FSACTIVE); |
|
|
@ -728,7 +836,7 @@ |
|
|
|
|
|
|
|
#define PRINT_TMC_REGISTER(REG_CASE) case TMC_GET_##REG_CASE: print_hex_long(st.REG_CASE(), ':'); break |
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2130) || HAS_DRIVER(TMC2160) || HAS_DRIVER(TMC5130) || HAS_DRIVER(TMC5160) |
|
|
|
#if HAS_TMCX1X0 |
|
|
|
static void tmc_get_ic_registers(TMC2130Stepper &st, const TMC_get_registers_enum i) { |
|
|
|
switch (i) { |
|
|
|
PRINT_TMC_REGISTER(TCOOLTHRS); |
|
|
|