2017-12-15 21:03:14 +00:00
|
|
|
/**
|
|
|
|
* Marlin 3D Printer Firmware
|
|
|
|
* Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
|
|
|
*
|
|
|
|
* Based on Sprinter and grbl.
|
|
|
|
* Copyright (C) 2011 Camiel Gubbels / Erik van der Zalm
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "../inc/MarlinConfig.h"
|
|
|
|
|
|
|
|
#if HAS_TRINAMIC
|
|
|
|
|
|
|
|
#include "tmc_util.h"
|
|
|
|
#include "../Marlin.h"
|
|
|
|
|
|
|
|
#include "../module/stepper_indirection.h"
|
|
|
|
#include "../module/printcounter.h"
|
|
|
|
#include "../libs/duration_t.h"
|
|
|
|
#include "../gcode/gcode.h"
|
|
|
|
|
2018-01-10 01:14:07 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
#include "../module/planner.h"
|
2018-10-03 16:56:49 +00:00
|
|
|
static bool report_tmc_status; // = false;
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
|
2018-03-07 01:01:07 +00:00
|
|
|
/**
|
2017-12-15 21:03:14 +00:00
|
|
|
* Check for over temperature or short to ground error flags.
|
|
|
|
* Report and log warning of overtemperature condition.
|
|
|
|
* Reduce driver current in a persistent otpw condition.
|
|
|
|
* Keep track of otpw counter so we don't reduce current on a single instance,
|
|
|
|
* and so we don't repeatedly report warning before the condition is cleared.
|
|
|
|
*/
|
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS)
|
2018-10-03 07:48:49 +00:00
|
|
|
|
2017-12-15 21:03:14 +00:00
|
|
|
struct TMC_driver_data {
|
|
|
|
uint32_t drv_status;
|
|
|
|
bool is_otpw;
|
|
|
|
bool is_ot;
|
|
|
|
bool is_error;
|
|
|
|
};
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2130)
|
2018-10-06 22:18:10 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
static uint32_t get_pwm_scale(TMC2130Stepper &st) { return st.PWM_SCALE(); }
|
|
|
|
static uint8_t get_status_response(TMC2130Stepper &st) { return st.status_response & 0xF; }
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
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 DRIVER_ERROR_bm = 0x2UL;
|
|
|
|
constexpr uint8_t DRIVER_ERROR_bp = 1;
|
|
|
|
TMC_driver_data data;
|
|
|
|
data.drv_status = st.DRV_STATUS();
|
2018-01-10 01:14:07 +00:00
|
|
|
data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp;
|
|
|
|
data.is_ot = (data.drv_status & OT_bm) >> OT_bp;
|
|
|
|
data.is_error = (st.status_response & DRIVER_ERROR_bm) >> DRIVER_ERROR_bp;
|
2017-12-15 21:03:14 +00:00
|
|
|
return data;
|
|
|
|
}
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2208)
|
2018-10-06 22:18:10 +00:00
|
|
|
#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 = st.DRV_STATUS();
|
|
|
|
uint8_t gstat = st.GSTAT();
|
|
|
|
uint8_t response = 0;
|
|
|
|
response |= (drv_status >> (31-3)) & 0b1000;
|
|
|
|
response |= gstat & 0b11;
|
|
|
|
return response;
|
|
|
|
}
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
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;
|
|
|
|
TMC_driver_data data;
|
|
|
|
data.drv_status = st.DRV_STATUS();
|
2018-01-10 01:14:07 +00:00
|
|
|
data.is_otpw = (data.drv_status & OTPW_bm) >> OTPW_bp;
|
|
|
|
data.is_ot = (data.drv_status & OT_bm) >> OT_bp;
|
2017-12-15 21:03:14 +00:00
|
|
|
data.is_error = st.drv_err();
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if HAS_DRIVER(TMC2660)
|
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
static uint32_t get_pwm_scale(TMC2660Stepper) { return 0; }
|
|
|
|
static uint8_t get_status_response(TMC2660Stepper) { return 0; }
|
|
|
|
#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;
|
2018-10-07 20:37:44 +00:00
|
|
|
constexpr uint8_t DRIVER_ERROR_bm = 0x6;
|
2018-10-06 22:18:10 +00:00
|
|
|
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;
|
|
|
|
data.is_error = data.drv_status & DRIVER_ERROR_bm;
|
|
|
|
return data;
|
|
|
|
}
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
|
|
|
|
template<typename TMC>
|
2018-10-03 07:48:49 +00:00
|
|
|
void monitor_tmc_driver(TMC &st) {
|
2017-12-15 21:03:14 +00:00
|
|
|
TMC_driver_data data = get_driver_data(st);
|
|
|
|
|
|
|
|
#if ENABLED(STOP_ON_ERROR)
|
|
|
|
if (data.is_error) {
|
|
|
|
SERIAL_EOL();
|
2018-10-03 07:48:49 +00:00
|
|
|
st.printLabel();
|
2018-03-07 04:16:19 +00:00
|
|
|
SERIAL_ECHOLNPGM(" driver error detected:");
|
|
|
|
if (data.is_ot) SERIAL_ECHOLNPGM("overtemperature");
|
|
|
|
if (st.s2ga()) SERIAL_ECHOLNPGM("short to ground (coil A)");
|
|
|
|
if (st.s2gb()) SERIAL_ECHOLNPGM("short to ground (coil B)");
|
2017-12-15 21:03:14 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
2018-01-10 01:14:07 +00:00
|
|
|
tmc_report_all();
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
kill(PSTR("Driver error"));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Report if a warning was triggered
|
2018-10-03 07:48:49 +00:00
|
|
|
if (data.is_otpw && st.otpw_count == 0) {
|
2017-12-15 21:03:14 +00:00
|
|
|
char timestamp[10];
|
|
|
|
duration_t elapsed = print_job_timer.duration();
|
|
|
|
const bool has_days = (elapsed.value > 60*60*24L);
|
|
|
|
(void)elapsed.toDigital(timestamp, has_days);
|
|
|
|
SERIAL_EOL();
|
|
|
|
SERIAL_ECHO(timestamp);
|
|
|
|
SERIAL_ECHOPGM(": ");
|
2018-10-03 07:48:49 +00:00
|
|
|
st.printLabel();
|
2017-12-15 21:03:14 +00:00
|
|
|
SERIAL_ECHOPGM(" driver overtemperature warning! (");
|
2018-10-03 07:48:49 +00:00
|
|
|
SERIAL_ECHO(st.getMilliamps());
|
2018-01-10 01:14:07 +00:00
|
|
|
SERIAL_ECHOLNPGM("mA)");
|
2017-12-15 21:03:14 +00:00
|
|
|
}
|
|
|
|
#if CURRENT_STEP_DOWN > 0
|
2018-03-20 20:16:05 +00:00
|
|
|
// Decrease current if is_otpw is true and driver is enabled and there's been more than 4 warnings
|
2018-10-03 07:48:49 +00:00
|
|
|
if (data.is_otpw && st.isEnabled() && st.otpw_count > 4) {
|
|
|
|
st.rms_current(st.getMilliamps() - (CURRENT_STEP_DOWN));
|
2017-12-15 21:03:14 +00:00
|
|
|
#if ENABLED(REPORT_CURRENT_CHANGE)
|
2018-10-03 07:48:49 +00:00
|
|
|
st.printLabel();
|
|
|
|
SERIAL_ECHOLNPAIR(" current decreased to ", st.getMilliamps());
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (data.is_otpw) {
|
2018-10-03 07:48:49 +00:00
|
|
|
st.otpw_count++;
|
2017-12-15 21:03:14 +00:00
|
|
|
st.flag_otpw = true;
|
|
|
|
}
|
2018-10-03 07:48:49 +00:00
|
|
|
else if (st.otpw_count > 0) st.otpw_count = 0;
|
2017-12-15 21:03:14 +00:00
|
|
|
|
2018-10-03 16:56:49 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
if (report_tmc_status) {
|
|
|
|
const uint32_t pwm_scale = get_pwm_scale(st);
|
|
|
|
st.printLabel();
|
|
|
|
SERIAL_ECHOPAIR(":", pwm_scale);
|
|
|
|
SERIAL_ECHOPGM(" |0b"); SERIAL_PRINT(get_status_response(st), BIN);
|
|
|
|
SERIAL_ECHOPGM("| ");
|
|
|
|
if (data.is_error) 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('\t');
|
|
|
|
}
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
}
|
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
#define HAS_HW_COMMS(ST) AXIS_DRIVER_TYPE(ST, TMC2130) || AXIS_DRIVER_TYPE(ST, TMC2660) || (AXIS_DRIVER_TYPE(ST, TMC2208) && defined(ST##_HARDWARE_SERIAL))
|
2017-12-15 21:03:14 +00:00
|
|
|
|
|
|
|
void monitor_tmc_driver() {
|
|
|
|
static millis_t next_cOT = 0;
|
|
|
|
if (ELAPSED(millis(), next_cOT)) {
|
|
|
|
next_cOT = millis() + 500;
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_HW_COMMS(X)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperX);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_HW_COMMS(Y)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperY);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_HW_COMMS(Z)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperZ);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(X2)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperX2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(Y2)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperY2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(Z2)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperZ2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2018-06-19 16:55:49 +00:00
|
|
|
#if HAS_HW_COMMS(Z3)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperZ3);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_HW_COMMS(E0)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE0);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(E1)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE1);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(E2)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(E3)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE3);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#if HAS_HW_COMMS(E4)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE4);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2018-09-13 06:35:55 +00:00
|
|
|
#if HAS_HW_COMMS(E5)
|
2018-10-03 07:48:49 +00:00
|
|
|
monitor_tmc_driver(stepperE5);
|
2018-09-13 06:35:55 +00:00
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
|
2018-10-03 16:56:49 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
if (report_tmc_status) SERIAL_EOL();
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // MONITOR_DRIVER_STATUS
|
|
|
|
|
2018-01-10 01:14:07 +00:00
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
/**
|
|
|
|
* M122 S[1,0] 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|");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-03-07 04:35:22 +00:00
|
|
|
enum TMC_debug_enum : char {
|
2018-01-10 01:14:07 +00:00
|
|
|
TMC_CODES,
|
|
|
|
TMC_ENABLED,
|
|
|
|
TMC_CURRENT,
|
|
|
|
TMC_RMS_CURRENT,
|
|
|
|
TMC_MAX_CURRENT,
|
|
|
|
TMC_IRUN,
|
|
|
|
TMC_IHOLD,
|
|
|
|
TMC_CS_ACTUAL,
|
|
|
|
TMC_PWM_SCALE,
|
|
|
|
TMC_VSENSE,
|
|
|
|
TMC_STEALTHCHOP,
|
|
|
|
TMC_MICROSTEPS,
|
|
|
|
TMC_TSTEP,
|
|
|
|
TMC_TPWMTHRS,
|
|
|
|
TMC_TPWMTHRS_MMS,
|
|
|
|
TMC_OTPW,
|
|
|
|
TMC_OTPW_TRIGGERED,
|
|
|
|
TMC_TOFF,
|
|
|
|
TMC_TBL,
|
|
|
|
TMC_HEND,
|
|
|
|
TMC_HSTRT,
|
|
|
|
TMC_SGT
|
|
|
|
};
|
2018-03-07 04:35:22 +00:00
|
|
|
enum TMC_drv_status_enum : char {
|
2018-01-10 01:14:07 +00:00
|
|
|
TMC_DRV_CODES,
|
|
|
|
TMC_STST,
|
|
|
|
TMC_OLB,
|
|
|
|
TMC_OLA,
|
|
|
|
TMC_S2GB,
|
|
|
|
TMC_S2GA,
|
|
|
|
TMC_DRV_OTPW,
|
|
|
|
TMC_OT,
|
|
|
|
TMC_STALLGUARD,
|
|
|
|
TMC_DRV_CS_ACTUAL,
|
|
|
|
TMC_FSACTIVE,
|
|
|
|
TMC_SG_RESULT,
|
|
|
|
TMC_DRV_STATUS_HEX,
|
|
|
|
TMC_T157,
|
|
|
|
TMC_T150,
|
|
|
|
TMC_T143,
|
|
|
|
TMC_T120,
|
|
|
|
TMC_STEALTH,
|
|
|
|
TMC_S2VSB,
|
|
|
|
TMC_S2VSA
|
|
|
|
};
|
2018-10-03 07:48:49 +00:00
|
|
|
static void drv_status_print_hex(const uint32_t drv_status) {
|
2018-01-10 01:14:07 +00:00
|
|
|
for (int B = 24; B >= 8; B -= 8){
|
|
|
|
SERIAL_PRINT((drv_status >> (B + 4)) & 0xF, HEX);
|
|
|
|
SERIAL_PRINT((drv_status >> B) & 0xF, HEX);
|
|
|
|
SERIAL_CHAR(':');
|
|
|
|
}
|
|
|
|
SERIAL_PRINT((drv_status >> 4) & 0xF, HEX);
|
2018-03-07 01:01:07 +00:00
|
|
|
SERIAL_PRINT((drv_status) & 0xF, HEX);
|
2018-01-10 01:14:07 +00:00
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
2018-10-03 07:48:49 +00:00
|
|
|
template<class TMC>
|
|
|
|
static void print_vsense(TMC &st) { serialprintPGM(st.vsense() ? PSTR("1=.18") : PSTR("0=.325")); }
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2130)
|
2018-01-10 01:14:07 +00:00
|
|
|
static void tmc_status(TMC2130Stepper &st, const TMC_debug_enum i) {
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_PWM_SCALE: SERIAL_PRINT(st.PWM_SCALE(), DEC); break;
|
|
|
|
case TMC_SGT: SERIAL_PRINT(st.sgt(), DEC); break;
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_STEALTHCHOP: serialprintPGM(st.en_pwm_mode() ? PSTR("true") : PSTR("false")); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-03 07:48:49 +00:00
|
|
|
static void _tmc_parse_drv_status(TMC2130Stepper &st, const TMC_drv_status_enum i) {
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_STALLGUARD: if (st.stallguard()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_SG_RESULT: SERIAL_PRINT(st.sg_result(), DEC); break;
|
|
|
|
case TMC_FSACTIVE: if (st.fsactive()) SERIAL_CHAR('X'); break;
|
2018-10-06 22:18:10 +00:00
|
|
|
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2018-03-14 10:43:18 +00:00
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2208)
|
2018-01-10 01:14:07 +00:00
|
|
|
static void tmc_status(TMC2208Stepper &st, const TMC_debug_enum i) {
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_PWM_SCALE: SERIAL_PRINT(st.pwm_scale_sum(), DEC); break;
|
|
|
|
case TMC_STEALTHCHOP: serialprintPGM(st.stealth() ? PSTR("true") : PSTR("false")); break;
|
|
|
|
case TMC_S2VSA: if (st.s2vsa()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_S2VSB: if (st.s2vsb()) SERIAL_CHAR('X'); break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
2018-10-03 07:48:49 +00:00
|
|
|
static void _tmc_parse_drv_status(TMC2208Stepper &st, const TMC_drv_status_enum i) {
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_T157: if (st.t157()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_T150: if (st.t150()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_T143: if (st.t143()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_T120: if (st.t120()) SERIAL_CHAR('X'); break;
|
2018-10-06 22:18:10 +00:00
|
|
|
case TMC_DRV_CS_ACTUAL: SERIAL_PRINT(st.cs_actual(), DEC); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
#if HAS_DRIVER(TMC2660)
|
|
|
|
static void _tmc_parse_drv_status(TMC2660Stepper, const TMC_drv_status_enum) { }
|
|
|
|
#endif
|
|
|
|
|
2018-01-10 01:14:07 +00:00
|
|
|
template <typename TMC>
|
2018-10-03 07:48:49 +00:00
|
|
|
static void tmc_status(TMC &st, const TMC_debug_enum i, const float spmm) {
|
2018-01-10 01:14:07 +00:00
|
|
|
SERIAL_ECHO('\t');
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_CODES: st.printLabel(); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
|
2018-02-08 10:20:44 +00:00
|
|
|
case TMC_RMS_CURRENT: SERIAL_PROTOCOL(st.rms_current()); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_MAX_CURRENT: SERIAL_PRINT((float)st.rms_current() * 1.41, 0); break;
|
|
|
|
case TMC_IRUN:
|
|
|
|
SERIAL_PRINT(st.irun(), DEC);
|
|
|
|
SERIAL_ECHOPGM("/31");
|
|
|
|
break;
|
|
|
|
case TMC_IHOLD:
|
|
|
|
SERIAL_PRINT(st.ihold(), DEC);
|
|
|
|
SERIAL_ECHOPGM("/31");
|
|
|
|
break;
|
|
|
|
case TMC_CS_ACTUAL:
|
|
|
|
SERIAL_PRINT(st.cs_actual(), DEC);
|
|
|
|
SERIAL_ECHOPGM("/31");
|
|
|
|
break;
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_VSENSE: print_vsense(st); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_TSTEP: SERIAL_ECHO(st.TSTEP()); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_TPWMTHRS: {
|
|
|
|
uint32_t tpwmthrs_val = st.TPWMTHRS();
|
|
|
|
SERIAL_ECHO(tpwmthrs_val);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TMC_TPWMTHRS_MMS: {
|
|
|
|
uint32_t tpwmthrs_val = st.TPWMTHRS();
|
2018-04-17 21:13:10 +00:00
|
|
|
if (tpwmthrs_val)
|
|
|
|
SERIAL_ECHO(12650000UL * st.microsteps() / (256 * tpwmthrs_val * spmm));
|
|
|
|
else
|
|
|
|
SERIAL_CHAR('-');
|
2018-01-10 01:14:07 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
|
2018-10-06 22:18:10 +00:00
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS)
|
|
|
|
case TMC_OTPW_TRIGGERED: serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false")); break;
|
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_TOFF: SERIAL_PRINT(st.toff(), DEC); break;
|
|
|
|
case TMC_TBL: SERIAL_PRINT(st.blank_time(), DEC); break;
|
2018-03-16 02:03:12 +00:00
|
|
|
case TMC_HEND: SERIAL_PRINT(st.hysteresis_end(), DEC); break;
|
|
|
|
case TMC_HSTRT: SERIAL_PRINT(st.hysteresis_start(), DEC); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
default: tmc_status(st, i); break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
#if HAS_DRIVER(TMC2660)
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID>
|
|
|
|
void tmc_status(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID> &st, const TMC_debug_enum i, const float) {
|
|
|
|
SERIAL_ECHO('\t');
|
|
|
|
switch (i) {
|
|
|
|
case TMC_CODES: st.printLabel(); break;
|
|
|
|
case TMC_ENABLED: serialprintPGM(st.isEnabled() ? PSTR("true") : PSTR("false")); break;
|
|
|
|
case TMC_CURRENT: SERIAL_ECHO(st.getMilliamps()); break;
|
|
|
|
case TMC_RMS_CURRENT: SERIAL_PROTOCOL(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_ECHOPGM("/31");
|
|
|
|
break;
|
|
|
|
case TMC_VSENSE: serialprintPGM(st.vsense() ? PSTR("1=.165") : PSTR("0=.310")); break;
|
|
|
|
case TMC_MICROSTEPS: SERIAL_ECHO(st.microsteps()); break;
|
|
|
|
//case TMC_OTPW: serialprintPGM(st.otpw() ? PSTR("true") : PSTR("false")); break;
|
|
|
|
//case TMC_OTPW_TRIGGERED: serialprintPGM(st.getOTPW() ? PSTR("true") : PSTR("false")); 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;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2018-01-10 01:14:07 +00:00
|
|
|
template <typename TMC>
|
2018-10-03 07:48:49 +00:00
|
|
|
static void tmc_parse_drv_status(TMC &st, const TMC_drv_status_enum i) {
|
2018-01-10 01:14:07 +00:00
|
|
|
SERIAL_CHAR('\t');
|
2018-03-08 02:30:19 +00:00
|
|
|
switch (i) {
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_DRV_CODES: st.printLabel(); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
case TMC_STST: if (st.stst()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_OLB: if (st.olb()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_OLA: if (st.ola()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_S2GB: if (st.s2gb()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_S2GA: if (st.s2ga()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_DRV_OTPW: if (st.otpw()) SERIAL_CHAR('X'); break;
|
|
|
|
case TMC_OT: if (st.ot()) SERIAL_CHAR('X'); break;
|
2018-10-03 07:48:49 +00:00
|
|
|
case TMC_DRV_STATUS_HEX:
|
|
|
|
st.printLabel();
|
|
|
|
SERIAL_ECHOPGM("\t0x");
|
|
|
|
drv_status_print_hex(st.DRV_STATUS());
|
|
|
|
break;
|
|
|
|
default: _tmc_parse_drv_status(st, i); break;
|
2018-01-10 01:14:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tmc_debug_loop(const TMC_debug_enum i) {
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperX, i, planner.axis_steps_per_mm[X_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperX2, i, planner.axis_steps_per_mm[X_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperY, i, planner.axis_steps_per_mm[Y_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperY2, i, planner.axis_steps_per_mm[Y_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperZ, i, planner.axis_steps_per_mm[Z_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperZ2, i, planner.axis_steps_per_mm[Z_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-06-19 16:55:49 +00:00
|
|
|
#if AXIS_IS_TMC(Z3)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperZ3, i, planner.axis_steps_per_mm[Z_AXIS]);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E0)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE0, i, planner.axis_steps_per_mm[E_AXIS]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E1)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE1, i, planner.axis_steps_per_mm[E_AXIS
|
2018-02-04 01:33:26 +00:00
|
|
|
#if ENABLED(DISTINCT_E_FACTORS)
|
|
|
|
+ 1
|
|
|
|
#endif
|
|
|
|
]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE2, i, planner.axis_steps_per_mm[E_AXIS
|
2018-02-04 01:33:26 +00:00
|
|
|
#if ENABLED(DISTINCT_E_FACTORS)
|
|
|
|
+ 2
|
|
|
|
#endif
|
|
|
|
]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E3)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE3, i, planner.axis_steps_per_mm[E_AXIS
|
2018-02-04 01:33:26 +00:00
|
|
|
#if ENABLED(DISTINCT_E_FACTORS)
|
|
|
|
+ 3
|
|
|
|
#endif
|
|
|
|
]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E4)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE4, i, planner.axis_steps_per_mm[E_AXIS
|
2018-02-04 01:33:26 +00:00
|
|
|
#if ENABLED(DISTINCT_E_FACTORS)
|
|
|
|
+ 4
|
|
|
|
#endif
|
|
|
|
]);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-09-13 06:35:55 +00:00
|
|
|
#if AXIS_IS_TMC(E5)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_status(stepperE5, i, planner.axis_steps_per_mm[E_AXIS
|
2018-09-13 06:35:55 +00:00
|
|
|
#if ENABLED(DISTINCT_E_FACTORS)
|
|
|
|
+ 5
|
|
|
|
#endif
|
|
|
|
]);
|
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
static void drv_status_loop(const TMC_drv_status_enum i) {
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperX, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperX2, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperY, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperY2, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperZ, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperZ2, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-06-19 16:55:49 +00:00
|
|
|
#if AXIS_IS_TMC(Z3)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperZ3, i);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E0)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE0, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E1)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE1, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E2)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE2, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E3)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE3, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E4)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE4, i);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
2018-09-13 06:35:55 +00:00
|
|
|
#if AXIS_IS_TMC(E5)
|
2018-10-03 07:48:49 +00:00
|
|
|
tmc_parse_drv_status(stepperE5, i);
|
2018-09-13 06:35:55 +00:00
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
|
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* M122 report functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
void tmc_report_all() {
|
|
|
|
#define TMC_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); tmc_debug_loop(ITEM); }while(0)
|
|
|
|
#define DRV_REPORT(LABEL, ITEM) do{ SERIAL_ECHOPGM(LABEL); drv_status_loop(ITEM); }while(0)
|
|
|
|
TMC_REPORT("\t", TMC_CODES);
|
|
|
|
TMC_REPORT("Enabled\t", TMC_ENABLED);
|
|
|
|
TMC_REPORT("Set current", TMC_CURRENT);
|
|
|
|
TMC_REPORT("RMS current", TMC_RMS_CURRENT);
|
|
|
|
TMC_REPORT("MAX current", TMC_MAX_CURRENT);
|
|
|
|
TMC_REPORT("Run current", TMC_IRUN);
|
|
|
|
TMC_REPORT("Hold current", TMC_IHOLD);
|
|
|
|
TMC_REPORT("CS actual\t", TMC_CS_ACTUAL);
|
2018-10-03 07:48:49 +00:00
|
|
|
TMC_REPORT("PWM scale", TMC_PWM_SCALE);
|
2018-01-10 01:14:07 +00:00
|
|
|
TMC_REPORT("vsense\t", TMC_VSENSE);
|
|
|
|
TMC_REPORT("stealthChop", TMC_STEALTHCHOP);
|
|
|
|
TMC_REPORT("msteps\t", TMC_MICROSTEPS);
|
|
|
|
TMC_REPORT("tstep\t", TMC_TSTEP);
|
|
|
|
TMC_REPORT("pwm\nthreshold\t", TMC_TPWMTHRS);
|
|
|
|
TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS);
|
|
|
|
TMC_REPORT("OT prewarn", TMC_OTPW);
|
2018-10-06 22:18:10 +00:00
|
|
|
#if ENABLED(MONITOR_DRIVER_STATUS)
|
|
|
|
TMC_REPORT("OT prewarn has\n"
|
|
|
|
"been triggered", TMC_OTPW_TRIGGERED);
|
|
|
|
#endif
|
2018-01-10 01:14:07 +00:00
|
|
|
TMC_REPORT("off time\t", TMC_TOFF);
|
|
|
|
TMC_REPORT("blank time", TMC_TBL);
|
2018-03-16 02:03:12 +00:00
|
|
|
TMC_REPORT("hysteresis\n-end\t", TMC_HEND);
|
2018-01-10 01:14:07 +00:00
|
|
|
TMC_REPORT("-start\t", TMC_HSTRT);
|
|
|
|
TMC_REPORT("Stallguard thrs", TMC_SGT);
|
|
|
|
|
|
|
|
DRV_REPORT("DRVSTATUS", TMC_DRV_CODES);
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2130)
|
2018-01-10 01:14:07 +00:00
|
|
|
DRV_REPORT("stallguard\t", TMC_STALLGUARD);
|
|
|
|
DRV_REPORT("sg_result\t", TMC_SG_RESULT);
|
|
|
|
DRV_REPORT("fsactive\t", TMC_FSACTIVE);
|
|
|
|
#endif
|
|
|
|
DRV_REPORT("stst\t", TMC_STST);
|
|
|
|
DRV_REPORT("olb\t", TMC_OLB);
|
|
|
|
DRV_REPORT("ola\t", TMC_OLA);
|
|
|
|
DRV_REPORT("s2gb\t", TMC_S2GB);
|
|
|
|
DRV_REPORT("s2ga\t", TMC_S2GA);
|
|
|
|
DRV_REPORT("otpw\t", TMC_DRV_OTPW);
|
|
|
|
DRV_REPORT("ot\t", TMC_OT);
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC2208)
|
2018-01-10 01:14:07 +00:00
|
|
|
DRV_REPORT("157C\t", TMC_T157);
|
|
|
|
DRV_REPORT("150C\t", TMC_T150);
|
|
|
|
DRV_REPORT("143C\t", TMC_T143);
|
|
|
|
DRV_REPORT("120C\t", TMC_T120);
|
|
|
|
DRV_REPORT("s2vsa\t", TMC_S2VSA);
|
|
|
|
DRV_REPORT("s2vsb\t", TMC_S2VSB);
|
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
DRV_REPORT("Driver registers:\n",TMC_DRV_STATUS_HEX);
|
2018-01-10 01:14:07 +00:00
|
|
|
SERIAL_EOL();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // TMC_DEBUG
|
|
|
|
|
2018-09-09 19:59:12 +00:00
|
|
|
#if USE_SENSORLESS
|
2018-01-10 01:14:07 +00:00
|
|
|
|
2018-09-09 19:59:12 +00:00
|
|
|
void tmc_stallguard(TMC2130Stepper &st, const bool enable/*=true*/) {
|
2018-10-03 07:48:49 +00:00
|
|
|
st.TCOOLTHRS(enable ? 0xFFFFF : 0);
|
2018-01-10 01:14:07 +00:00
|
|
|
#if ENABLED(STEALTHCHOP)
|
2018-10-03 07:48:49 +00:00
|
|
|
st.en_pwm_mode(!enable);
|
2018-01-10 01:14:07 +00:00
|
|
|
#endif
|
|
|
|
st.diag1_stall(enable ? 1 : 0);
|
|
|
|
}
|
2018-10-06 22:18:10 +00:00
|
|
|
void tmc_sensorless_homing(TMC2660Stepper &st, const bool enable) {
|
|
|
|
// TODO
|
|
|
|
}
|
2018-01-10 01:14:07 +00:00
|
|
|
|
2018-09-09 19:59:12 +00:00
|
|
|
#endif // USE_SENSORLESS
|
2018-01-10 01:14:07 +00:00
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
#if TMC_HAS_SPI
|
2018-02-10 20:08:53 +00:00
|
|
|
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH)
|
|
|
|
void tmc_init_cs_pins() {
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(X)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(X);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(Y)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(Y);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(Z)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(Z);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(X2)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(X2);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(Y2)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(Y2);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(Z2)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(Z2);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(Z3)
|
2018-06-19 16:55:49 +00:00
|
|
|
SET_CS_PIN(Z3);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E0)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(E0);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E1)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(E1);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E2)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(E2);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E3)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(E3);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E4)
|
2018-02-10 20:08:53 +00:00
|
|
|
SET_CS_PIN(E4);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
#if AXIS_HAS_SPI(E5)
|
2018-09-13 06:35:55 +00:00
|
|
|
SET_CS_PIN(E5);
|
|
|
|
#endif
|
2018-02-10 20:08:53 +00:00
|
|
|
}
|
2018-10-06 22:18:10 +00:00
|
|
|
#endif // TMC_HAS_SPI
|
2018-02-10 20:08:53 +00:00
|
|
|
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif // HAS_TRINAMIC
|