|
|
|
@ -36,7 +36,7 @@
|
|
|
|
|
#include <SPI.h>
|
|
|
|
|
|
|
|
|
|
enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST)
|
|
|
|
|
#define TMC_INIT(ST, STEALTH_INDEX) tmc_init(stepper##ST, ST##_CURRENT, ST##_MICROSTEPS, ST##_HYBRID_THRESHOLD, stealthchop_by_axis[STEALTH_INDEX], chopper_timing_##ST, ST##_INTERPOLATE)
|
|
|
|
|
|
|
|
|
|
// IC = TMC model number
|
|
|
|
|
// ST = Stepper object letter
|
|
|
|
@ -131,13 +131,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2130)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
st.begin();
|
|
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01;
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
@ -166,13 +166,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2160)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
st.begin();
|
|
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01;
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
@ -484,7 +484,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2208)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
TMC2208_n::GCONF_t gconf{0};
|
|
|
|
|
gconf.pdn_disable = true; // Use UART
|
|
|
|
|
gconf.mstep_reg_select = true; // Select microsteps with UART
|
|
|
|
@ -496,7 +496,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
TMC2208_n::CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01; // blank_time = 24
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
@ -526,7 +526,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2209)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
TMC2208_n::GCONF_t gconf{0};
|
|
|
|
|
gconf.pdn_disable = true; // Use UART
|
|
|
|
|
gconf.mstep_reg_select = true; // Select microsteps with UART
|
|
|
|
@ -538,7 +538,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
TMC2208_n::CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01; // blank_time = 24
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
@ -568,7 +568,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC2660)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t, const bool, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
st.begin();
|
|
|
|
|
|
|
|
|
|
TMC2660_n::CHOPCONF_t chopconf{0};
|
|
|
|
@ -582,7 +582,7 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
st.rms_current(mA);
|
|
|
|
|
st.microsteps(microsteps);
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, st.dedge(true));
|
|
|
|
|
st.intpol(INTERPOLATE);
|
|
|
|
|
st.intpol(interpolate);
|
|
|
|
|
st.diss2g(true); // Disable short to ground protection. Too many false readings?
|
|
|
|
|
TERN_(TMC_DEBUG, st.rdsel(0b01));
|
|
|
|
|
}
|
|
|
|
@ -590,13 +590,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC5130)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC5130Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
st.begin();
|
|
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01;
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
@ -625,13 +625,13 @@ enum StealthIndex : uint8_t { STEALTH_AXIS_XY, STEALTH_AXIS_Z, STEALTH_AXIS_E };
|
|
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC5160)
|
|
|
|
|
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
|
|
|
|
|
void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init) {
|
|
|
|
|
void tmc_init(TMCMarlin<TMC5160Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> &st, const uint16_t mA, const uint16_t microsteps, const uint32_t hyb_thrs, const bool stealth, const chopper_timing_t &chop_init, const bool interpolate) {
|
|
|
|
|
st.begin();
|
|
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
|
chopconf.tbl = 0b01;
|
|
|
|
|
chopconf.toff = chop_init.toff;
|
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
|
chopconf.intpol = interpolate;
|
|
|
|
|
chopconf.hend = chop_init.hend + 3;
|
|
|
|
|
chopconf.hstrt = chop_init.hstrt - 1;
|
|
|
|
|
TERN_(SQUARE_WAVE_STEPPING, chopconf.dedge = true);
|
|
|
|
|