Coolstep for TMC2130, 2209, 5130, 5160 (#16790)

This commit is contained in:
Fabio Santos
2020-02-08 19:01:57 -08:00
committed by GitHub
parent f0cbc85a07
commit 894762259b
25 changed files with 473 additions and 86 deletions

View File

@ -629,6 +629,15 @@
default: break;
}
}
#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;
default: _tmc_parse_drv_status(static_cast<TMC2208Stepper &>(st), i); break;
}
}
#endif
#endif
#if HAS_DRIVER(TMC2660)
@ -891,24 +900,24 @@
TMC_REPORT("stealthChop", TMC_STEALTHCHOP);
TMC_REPORT("msteps\t", TMC_MICROSTEPS);
TMC_REPORT("tstep\t", TMC_TSTEP);
TMC_REPORT("pwm\nthreshold", TMC_TPWMTHRS);
TMC_REPORT("PWM thresh.", TMC_TPWMTHRS);
TMC_REPORT("[mm/s]\t", TMC_TPWMTHRS_MMS);
TMC_REPORT("OT prewarn", TMC_OTPW);
#if ENABLED(MONITOR_DRIVER_STATUS)
TMC_REPORT("OT prewarn has\n"
"been triggered", TMC_OTPW_TRIGGERED);
TMC_REPORT("triggered\n OTP\t", TMC_OTPW_TRIGGERED);
#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("hysteresis\n -end\t", TMC_HEND);
TMC_REPORT(" -start\t", TMC_HSTRT);
TMC_REPORT("Stallguard thrs", TMC_SGT);
DRV_REPORT("DRVSTATUS", TMC_DRV_CODES);
#if HAS_TMCX1X0
DRV_REPORT("stallguard\t", TMC_STALLGUARD);
#if HAS_TMCX1X0 || HAS_TMC220x
DRV_REPORT("sg_result", TMC_SG_RESULT);
DRV_REPORT("fsactive\t", TMC_FSACTIVE);
#endif
#if HAS_TMCX1X0
DRV_REPORT("stallguard", TMC_STALLGUARD);
DRV_REPORT("fsactive", TMC_FSACTIVE);
#endif
DRV_REPORT("stst\t", TMC_STST);
DRV_REPORT("olb\t", TMC_OLB);
@ -1103,7 +1112,7 @@
#endif // USE_SENSORLESS
#if TMC_HAS_SPI
#if HAS_TMC_SPI
#define SET_CS_PIN(st) OUT_WRITE(st##_CS_PIN, HIGH)
void tmc_init_cs_pins() {
#if AXIS_HAS_SPI(X)
@ -1155,7 +1164,7 @@
SET_CS_PIN(E7);
#endif
}
#endif // TMC_HAS_SPI
#endif // HAS_TMC_SPI
template<typename TMC>
static bool test_connection(TMC &st) {

View File

@ -110,6 +110,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return this->en_pwm_mode(); }
#endif
#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -121,6 +122,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif
}
#endif
#if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC::sgt(); }
void homing_threshold(int16_t sgt_val) {
@ -135,6 +137,13 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
#endif
#endif
uint32_t get_cool_thrs() {
return _tmc_thrs(this->microsteps(), this->TCOOLTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_cool_thrs(const uint32_t thrs) {
TMC::TCOOLTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
}
#if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); }
@ -149,6 +158,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
static constexpr int8_t sgt_min = -64,
sgt_max = 63;
};
template<char AXIS_LETTER, char DRIVER_ID, AxisEnum AXIS_ID>
class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC2208Stepper, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
public:
@ -172,6 +182,7 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
#endif
#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -217,6 +228,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
inline void refresh_stepping_mode() { en_spreadCycle(!this->stored.stealthChop_enabled); }
inline bool get_stealthChop_status() { return !this->en_spreadCycle(); }
#endif
#if ENABLED(HYBRID_THRESHOLD)
uint32_t get_pwm_thrs() {
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
@ -228,6 +240,14 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#endif
}
#endif
uint32_t get_cool_thrs() {
return _tmc_thrs(this->microsteps(), this->TCOOLTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
}
void set_cool_thrs(const uint32_t thrs) {
TMC2209Stepper::TCOOLTHRS(_tmc_thrs(this->microsteps(), thrs, planner.settings.axis_steps_per_mm[AXIS_ID]));
}
#if USE_SENSORLESS
inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); }
void homing_threshold(int16_t sgt_val) {
@ -241,7 +261,6 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
#if HAS_LCD_MENU
inline void refresh_stepper_current() { rms_current(this->val_mA); }
#if ENABLED(HYBRID_THRESHOLD)
inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
#endif
@ -391,7 +410,7 @@ void test_tmc_connection(const bool test_x, const bool test_y, const bool test_z
#endif // USE_SENSORLESS
#if TMC_HAS_SPI
#if HAS_TMC_SPI
void tmc_init_cs_pins();
#endif