2016-03-25 06:19:46 +00:00
|
|
|
/**
|
2016-03-24 18:01:20 +00:00
|
|
|
* Marlin 3D Printer Firmware
|
2019-02-12 21:06:53 +00:00
|
|
|
* Copyright (C) 2019 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
2016-03-24 18:01:20 +00:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2016-03-25 06:19:46 +00:00
|
|
|
/**
|
2017-03-07 05:00:43 +00:00
|
|
|
* stepper_indirection.cpp
|
|
|
|
*
|
|
|
|
* Stepper motor driver indirection to allow some stepper functions to
|
|
|
|
* be done via SPI/I2c instead of direct pin manipulation.
|
|
|
|
*
|
|
|
|
* Part of Marlin
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015 Dominik Wenger
|
|
|
|
*/
|
2015-02-26 11:57:46 +00:00
|
|
|
|
|
|
|
#include "stepper_indirection.h"
|
2016-07-25 01:54:24 +00:00
|
|
|
|
2017-09-06 11:28:32 +00:00
|
|
|
#include "../inc/MarlinConfig.h"
|
2015-02-26 11:57:46 +00:00
|
|
|
|
2019-02-04 09:41:55 +00:00
|
|
|
#include "stepper.h"
|
2018-09-15 01:00:55 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
#if HAS_DRIVER(L6470)
|
|
|
|
#include "L6470/L6470_Marlin.h"
|
|
|
|
#endif
|
|
|
|
|
2016-11-07 20:46:01 +00:00
|
|
|
//
|
|
|
|
// TMC26X Driver objects and inits
|
|
|
|
//
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC26X)
|
2015-07-31 05:28:11 +00:00
|
|
|
#include <SPI.h>
|
2018-01-21 23:13:56 +00:00
|
|
|
|
2018-01-15 08:28:39 +00:00
|
|
|
#ifdef STM32F7
|
2018-01-11 21:29:08 +00:00
|
|
|
#include "../HAL/HAL_STM32F7/TMC2660.h"
|
|
|
|
#else
|
|
|
|
#include <TMC26XStepper.h>
|
|
|
|
#endif
|
2015-02-26 11:57:46 +00:00
|
|
|
|
2018-04-28 17:02:45 +00:00
|
|
|
#define _TMC26X_DEFINE(ST) TMC26XStepper stepper##ST(200, ST##_CS_PIN, ST##_STEP_PIN, ST##_DIR_PIN, ST##_MAX_CURRENT, ST##_SENSE_RESISTOR)
|
2017-03-07 05:00:43 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(X);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(X2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(Y);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(Y2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(Z);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(Z2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z3(TMC26X)
|
2018-06-19 16:55:49 +00:00
|
|
|
_TMC26X_DEFINE(Z3);
|
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E0(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(E0);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E1(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(E1);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(E2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E3(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(E3);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E4(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_DEFINE(E4);
|
2017-04-09 08:23:05 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E5(TMC26X)
|
2018-09-17 04:57:50 +00:00
|
|
|
_TMC26X_DEFINE(E5);
|
|
|
|
#endif
|
2015-02-27 11:43:23 +00:00
|
|
|
|
2018-03-19 00:01:42 +00:00
|
|
|
#define _TMC26X_INIT(A) do{ \
|
2017-03-04 11:17:39 +00:00
|
|
|
stepper##A.setMicrosteps(A##_MICROSTEPS); \
|
|
|
|
stepper##A.start(); \
|
2017-03-07 05:00:43 +00:00
|
|
|
}while(0)
|
2016-11-07 20:46:01 +00:00
|
|
|
|
2018-03-19 00:01:42 +00:00
|
|
|
void tmc26x_init_to_defaults() {
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(X);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(X2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(Y);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(Y2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(Z);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(Z2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z3(TMC26X)
|
2018-06-19 16:55:49 +00:00
|
|
|
_TMC26X_INIT(Z3);
|
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E0(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(E0);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E1(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(E1);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E2(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(E2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E3(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(E3);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E4(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
_TMC26X_INIT(E4);
|
2017-04-09 08:23:05 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E5(TMC26X)
|
2018-09-17 04:57:50 +00:00
|
|
|
_TMC26X_INIT(E5);
|
|
|
|
#endif
|
2016-11-07 20:46:01 +00:00
|
|
|
}
|
2018-07-14 11:13:06 +00:00
|
|
|
#endif // TMC26X
|
2016-11-07 20:46:01 +00:00
|
|
|
|
2018-10-03 07:48:49 +00:00
|
|
|
#if HAS_TRINAMIC
|
2019-05-25 23:22:12 +00:00
|
|
|
#include <HardwareSerial.h>
|
2016-09-14 06:48:47 +00:00
|
|
|
#include <SPI.h>
|
2017-12-15 21:03:14 +00:00
|
|
|
#include "planner.h"
|
2017-09-06 11:28:32 +00:00
|
|
|
#include "../core/enum.h"
|
2016-09-14 06:48:47 +00:00
|
|
|
|
2019-05-25 23:22:12 +00:00
|
|
|
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])
|
|
|
|
|
|
|
|
// IC = TMC model number
|
|
|
|
// ST = Stepper object letter
|
|
|
|
// L = Label characters
|
|
|
|
// AI = Axis Enum Index
|
|
|
|
// SWHW = SW/SH UART selection
|
2018-02-02 03:49:40 +00:00
|
|
|
#if ENABLED(TMC_USE_SW_SPI)
|
2019-05-25 23:22:12 +00:00
|
|
|
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, ST##_RSENSE, TMC_SW_MOSI, TMC_SW_MISO, TMC_SW_SCK)
|
2018-02-02 03:49:40 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
#define __TMC_SPI_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_CS_PIN, ST##_RSENSE)
|
2018-02-02 03:49:40 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
|
2019-06-20 20:47:50 +00:00
|
|
|
#define TMC_UART_HW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(&ST##_HARDWARE_SERIAL, ST##_RSENSE, ST##_SLAVE_ADDRESS)
|
|
|
|
#define TMC_UART_SW_DEFINE(IC, ST, L, AI) TMCMarlin<IC##Stepper, L, AI> stepper##ST(ST##_SERIAL_RX_PIN, ST##_SERIAL_TX_PIN, ST##_RSENSE, ST##_SLAVE_ADDRESS, ST##_SERIAL_RX_PIN > -1)
|
2019-05-25 23:22:12 +00:00
|
|
|
|
|
|
|
#define _TMC_SPI_DEFINE(IC, ST, AI) __TMC_SPI_DEFINE(IC, ST, TMC_##ST##_LABEL, AI)
|
|
|
|
#define TMC_SPI_DEFINE(ST, AI) _TMC_SPI_DEFINE(ST##_DRIVER_TYPE, ST, AI##_AXIS)
|
|
|
|
|
|
|
|
#define _TMC_UART_DEFINE(SWHW, IC, ST, AI) TMC_UART_##SWHW##_DEFINE(IC, ST, TMC_##ST##_LABEL, AI)
|
|
|
|
#define TMC_UART_DEFINE(SWHW, ST, AI) _TMC_UART_DEFINE(SWHW, ST##_DRIVER_TYPE, ST, AI##_AXIS)
|
|
|
|
|
|
|
|
#if ENABLED(DISTINCT_E_FACTORS) && E_STEPPERS > 1
|
|
|
|
#define TMC_SPI_DEFINE_E(AI) TMC_SPI_DEFINE(E##AI, E##AI)
|
|
|
|
#define TMC_UART_DEFINE_E(SWHW, AI) TMC_UART_DEFINE(SWHW, E##AI, E##AI)
|
|
|
|
#else
|
|
|
|
#define TMC_SPI_DEFINE_E(AI) TMC_SPI_DEFINE(E##AI, E)
|
|
|
|
#define TMC_UART_DEFINE_E(SWHW, AI) TMC_UART_DEFINE(SWHW, E##AI, E)
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
|
|
|
|
// Stepper objects of TMC2130/TMC2160/TMC2660/TMC5130/TMC5160 steppers used
|
|
|
|
#if AXIS_HAS_SPI(X)
|
|
|
|
TMC_SPI_DEFINE(X, X);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(X2)
|
|
|
|
TMC_SPI_DEFINE(X2, X);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(Y)
|
|
|
|
TMC_SPI_DEFINE(Y, Y);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(Y2)
|
|
|
|
TMC_SPI_DEFINE(Y2, Y);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(Z)
|
|
|
|
TMC_SPI_DEFINE(Z, Z);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(Z2)
|
|
|
|
TMC_SPI_DEFINE(Z2, Z);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(Z3)
|
|
|
|
TMC_SPI_DEFINE(Z3, Z);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E0)
|
|
|
|
TMC_SPI_DEFINE_E(0);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E1)
|
|
|
|
TMC_SPI_DEFINE_E(1);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E2)
|
|
|
|
TMC_SPI_DEFINE_E(2);
|
2016-11-07 20:35:14 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E3)
|
|
|
|
TMC_SPI_DEFINE_E(3);
|
2017-04-09 08:23:05 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E4)
|
|
|
|
TMC_SPI_DEFINE_E(4);
|
2018-09-17 04:57:50 +00:00
|
|
|
#endif
|
2019-05-25 23:22:12 +00:00
|
|
|
#if AXIS_HAS_SPI(E5)
|
|
|
|
TMC_SPI_DEFINE_E(5);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
2016-11-07 20:35:14 +00:00
|
|
|
|
2019-05-25 23:22:12 +00:00
|
|
|
#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 thrs, const bool stealth) {
|
2017-03-07 05:00:43 +00:00
|
|
|
st.begin();
|
2018-10-03 07:48:49 +00:00
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 1;
|
2019-01-17 19:17:16 +00:00
|
|
|
chopconf.toff = chopper_timing.toff;
|
2018-10-03 07:48:49 +00:00
|
|
|
chopconf.intpol = INTERPOLATE;
|
2019-01-20 00:57:02 +00:00
|
|
|
chopconf.hend = chopper_timing.hend + 3;
|
|
|
|
chopconf.hstrt = chopper_timing.hstrt - 1;
|
2019-06-09 10:08:05 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
chopconf.dedge = true;
|
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
2017-03-07 05:00:43 +00:00
|
|
|
st.microsteps(microsteps);
|
2018-10-03 07:48:49 +00:00
|
|
|
st.iholddelay(10);
|
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
|
|
|
|
2018-12-07 21:34:21 +00:00
|
|
|
st.en_pwm_mode(stealth);
|
2019-01-17 19:17:16 +00:00
|
|
|
st.stored.stealthChop_enabled = stealth;
|
2017-03-07 05:00:43 +00:00
|
|
|
|
2018-12-07 21:34:21 +00:00
|
|
|
PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_freq = 0b01; // f_pwm = 2/683 f_clk
|
|
|
|
pwmconf.pwm_autoscale = true;
|
|
|
|
pwmconf.pwm_grad = 5;
|
|
|
|
pwmconf.pwm_ampl = 180;
|
|
|
|
st.PWMCONF(pwmconf.sr);
|
2017-03-07 05:00:43 +00:00
|
|
|
|
2018-12-07 21:34:21 +00:00
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2019-05-25 23:22:12 +00:00
|
|
|
st.set_pwm_thrs(thrs);
|
2018-12-07 21:34:21 +00:00
|
|
|
#else
|
|
|
|
UNUSED(thrs);
|
2018-03-19 00:01:42 +00:00
|
|
|
#endif
|
2018-12-07 21:34:21 +00:00
|
|
|
|
2018-10-03 07:48:49 +00:00
|
|
|
st.GSTAT(); // Clear GSTAT
|
2016-11-07 20:35:14 +00:00
|
|
|
}
|
2018-07-14 11:13:06 +00:00
|
|
|
#endif // TMC2130
|
2016-11-07 20:35:14 +00:00
|
|
|
|
2019-02-06 12:33:14 +00:00
|
|
|
#if HAS_DRIVER(TMC2160)
|
2019-05-25 23:22:12 +00:00
|
|
|
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 thrs, const bool stealth) {
|
2019-02-06 12:33:14 +00:00
|
|
|
st.begin();
|
|
|
|
|
|
|
|
static constexpr int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 1;
|
|
|
|
chopconf.toff = timings[0];
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
chopconf.hend = timings[1] + 3;
|
|
|
|
chopconf.hstrt = timings[2] - 1;
|
2019-06-09 10:08:05 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
chopconf.dedge = true;
|
|
|
|
#endif
|
2019-02-06 12:33:14 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
|
|
|
st.microsteps(microsteps);
|
|
|
|
st.iholddelay(10);
|
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
|
|
|
st.TCOOLTHRS(0xFFFFF);
|
|
|
|
|
|
|
|
#if ENABLED(ADAPTIVE_CURRENT)
|
|
|
|
COOLCONF_t coolconf{0};
|
|
|
|
coolconf.semin = INCREASE_CURRENT_THRS;
|
|
|
|
coolconf.semax = REDUCE_CURRENT_THRS;
|
|
|
|
st.COOLCONF(coolconf.sr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
st.en_pwm_mode(stealth);
|
|
|
|
|
2019-06-08 19:34:50 +00:00
|
|
|
TMC2160_n::PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_lim = 12;
|
|
|
|
pwmconf.pwm_reg = 8;
|
|
|
|
pwmconf.pwm_autograd = true;
|
2019-02-06 12:33:14 +00:00
|
|
|
pwmconf.pwm_autoscale = true;
|
2019-06-08 19:34:50 +00:00
|
|
|
pwmconf.pwm_freq = 0b01;
|
|
|
|
pwmconf.pwm_grad = 14;
|
|
|
|
pwmconf.pwm_ofs = 36;
|
2019-02-06 12:33:14 +00:00
|
|
|
st.PWMCONF(pwmconf.sr);
|
|
|
|
|
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2019-05-25 23:22:12 +00:00
|
|
|
st.set_pwm_thrs(thrs);
|
2019-02-06 12:33:14 +00:00
|
|
|
#else
|
|
|
|
UNUSED(thrs);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
st.GSTAT(); // Clear GSTAT
|
|
|
|
}
|
|
|
|
#endif // TMC2160
|
|
|
|
|
2017-12-15 21:03:14 +00:00
|
|
|
//
|
2019-06-20 20:47:50 +00:00
|
|
|
// TMC2208/2209 Driver objects and inits
|
2017-12-15 21:03:14 +00:00
|
|
|
//
|
2019-06-20 20:47:50 +00:00
|
|
|
#if HAS_DRIVER(TMC2208) || HAS_DRIVER(TMC2209)
|
|
|
|
#if AXIS_HAS_UART(X)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef X_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, X, X);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, X, X);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(X2)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef X2_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, X2, X);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, X2, X);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Y)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef Y_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, Y, Y);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, Y, Y);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Y2)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef Y2_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, Y2, Y);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, Y2, Y);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef Z_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, Z, Z);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, Z, Z);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z2)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef Z2_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, Z2, Z);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, Z2, Z);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z3)
|
2018-06-19 16:55:49 +00:00
|
|
|
#ifdef Z3_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(HW, Z3, Z);
|
2018-06-19 16:55:49 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE(SW, Z3, Z);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E0)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef E0_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 0);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 0);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E1)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef E1_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 1);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 1);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E2)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef E2_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 2);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E3)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef E3_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 3);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 3);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E4)
|
2018-01-22 16:24:30 +00:00
|
|
|
#ifdef E4_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 4);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 4);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E5)
|
2018-09-17 04:57:50 +00:00
|
|
|
#ifdef E5_HARDWARE_SERIAL
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(HW, 5);
|
2018-09-17 04:57:50 +00:00
|
|
|
#else
|
2019-05-25 23:22:12 +00:00
|
|
|
TMC_UART_DEFINE_E(SW, 5);
|
2018-09-17 04:57:50 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
|
2019-06-20 20:47:50 +00:00
|
|
|
void tmc_serial_begin() {
|
|
|
|
#if AXIS_HAS_UART(X)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef X_HARDWARE_SERIAL
|
|
|
|
X_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperX.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(X2)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef X2_HARDWARE_SERIAL
|
|
|
|
X2_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperX2.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Y)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef Y_HARDWARE_SERIAL
|
|
|
|
Y_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperY.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Y2)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef Y2_HARDWARE_SERIAL
|
|
|
|
Y2_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperY2.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef Z_HARDWARE_SERIAL
|
|
|
|
Z_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperZ.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z2)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef Z2_HARDWARE_SERIAL
|
|
|
|
Z2_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperZ2.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(Z3)
|
2018-06-19 16:55:49 +00:00
|
|
|
#ifdef Z3_HARDWARE_SERIAL
|
|
|
|
Z3_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperZ3.beginSerial(115200);
|
|
|
|
#endif
|
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E0)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef E0_HARDWARE_SERIAL
|
|
|
|
E0_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE0.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E1)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef E1_HARDWARE_SERIAL
|
|
|
|
E1_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE1.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E2)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef E2_HARDWARE_SERIAL
|
|
|
|
E2_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE2.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E3)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef E3_HARDWARE_SERIAL
|
|
|
|
E3_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE3.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E4)
|
2018-08-14 23:41:37 +00:00
|
|
|
#ifdef E4_HARDWARE_SERIAL
|
|
|
|
E4_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE4.beginSerial(115200);
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2019-06-20 20:47:50 +00:00
|
|
|
#if AXIS_HAS_UART(E5)
|
2018-09-17 04:57:50 +00:00
|
|
|
#ifdef E5_HARDWARE_SERIAL
|
|
|
|
E5_HARDWARE_SERIAL.begin(115200);
|
|
|
|
#else
|
|
|
|
stepperE5.beginSerial(115200);
|
|
|
|
#endif
|
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
}
|
2019-06-20 20:47:50 +00:00
|
|
|
#endif
|
2017-12-15 21:03:14 +00:00
|
|
|
|
2019-06-20 20:47:50 +00:00
|
|
|
#if HAS_DRIVER(TMC2208)
|
2019-05-25 23:22:12 +00:00
|
|
|
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 thrs, const bool stealth) {
|
2018-10-03 07:48:49 +00:00
|
|
|
TMC2208_n::GCONF_t gconf{0};
|
|
|
|
gconf.pdn_disable = true; // Use UART
|
|
|
|
gconf.mstep_reg_select = true; // Select microsteps with UART
|
|
|
|
gconf.i_scale_analog = false;
|
2018-12-07 21:34:21 +00:00
|
|
|
gconf.en_spreadcycle = !stealth;
|
|
|
|
st.GCONF(gconf.sr);
|
2019-01-17 19:17:16 +00:00
|
|
|
st.stored.stealthChop_enabled = stealth;
|
2018-10-03 07:48:49 +00:00
|
|
|
|
|
|
|
TMC2208_n::CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 0b01; // blank_time = 24
|
2019-01-17 19:17:16 +00:00
|
|
|
chopconf.toff = chopper_timing.toff;
|
2018-10-03 07:48:49 +00:00
|
|
|
chopconf.intpol = INTERPOLATE;
|
2019-01-20 00:57:02 +00:00
|
|
|
chopconf.hend = chopper_timing.hend + 3;
|
|
|
|
chopconf.hstrt = chopper_timing.hstrt - 1;
|
2019-06-09 10:08:05 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
chopconf.dedge = true;
|
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
2017-12-15 21:03:14 +00:00
|
|
|
st.microsteps(microsteps);
|
2018-10-03 07:48:49 +00:00
|
|
|
st.iholddelay(10);
|
2017-12-15 21:03:14 +00:00
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
2018-12-07 21:34:21 +00:00
|
|
|
|
|
|
|
TMC2208_n::PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_lim = 12;
|
|
|
|
pwmconf.pwm_reg = 8;
|
|
|
|
pwmconf.pwm_autograd = true;
|
|
|
|
pwmconf.pwm_autoscale = true;
|
|
|
|
pwmconf.pwm_freq = 0b01;
|
|
|
|
pwmconf.pwm_grad = 14;
|
|
|
|
pwmconf.pwm_ofs = 36;
|
|
|
|
st.PWMCONF(pwmconf.sr);
|
|
|
|
|
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2019-05-25 23:22:12 +00:00
|
|
|
st.set_pwm_thrs(thrs);
|
2017-12-15 21:03:14 +00:00
|
|
|
#else
|
2018-12-07 21:34:21 +00:00
|
|
|
UNUSED(thrs);
|
2017-12-15 21:03:14 +00:00
|
|
|
#endif
|
2018-12-07 21:34:21 +00:00
|
|
|
|
2017-12-15 21:03:14 +00:00
|
|
|
st.GSTAT(0b111); // Clear
|
|
|
|
delay(200);
|
|
|
|
}
|
2018-07-14 11:13:06 +00:00
|
|
|
#endif // TMC2208
|
2017-12-15 21:03:14 +00:00
|
|
|
|
2019-06-20 20:47:50 +00:00
|
|
|
#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 thrs, const bool stealth) {
|
|
|
|
TMC2208_n::GCONF_t gconf{0};
|
|
|
|
gconf.pdn_disable = true; // Use UART
|
|
|
|
gconf.mstep_reg_select = true; // Select microsteps with UART
|
|
|
|
gconf.i_scale_analog = false;
|
|
|
|
gconf.en_spreadcycle = !stealth;
|
|
|
|
st.GCONF(gconf.sr);
|
|
|
|
st.stored.stealthChop_enabled = stealth;
|
|
|
|
|
|
|
|
TMC2208_n::CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 0b01; // blank_time = 24
|
|
|
|
chopconf.toff = chopper_timing.toff;
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
chopconf.hend = chopper_timing.hend + 3;
|
|
|
|
chopconf.hstrt = chopper_timing.hstrt - 1;
|
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
|
|
|
st.microsteps(microsteps);
|
|
|
|
st.iholddelay(10);
|
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
|
|
|
|
|
|
|
TMC2208_n::PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_lim = 12;
|
|
|
|
pwmconf.pwm_reg = 8;
|
|
|
|
pwmconf.pwm_autograd = true;
|
|
|
|
pwmconf.pwm_autoscale = true;
|
|
|
|
pwmconf.pwm_freq = 0b01;
|
|
|
|
pwmconf.pwm_grad = 14;
|
|
|
|
pwmconf.pwm_ofs = 36;
|
|
|
|
st.PWMCONF(pwmconf.sr);
|
|
|
|
|
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
|
|
|
st.set_pwm_thrs(thrs);
|
|
|
|
#else
|
|
|
|
UNUSED(thrs);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
st.GSTAT(0b111); // Clear
|
|
|
|
}
|
|
|
|
#endif // TMC2209
|
|
|
|
|
2018-10-06 22:18:10 +00:00
|
|
|
#if HAS_DRIVER(TMC2660)
|
2019-05-25 23:22:12 +00:00
|
|
|
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) {
|
2018-10-06 22:18:10 +00:00
|
|
|
st.begin();
|
2018-12-10 02:54:48 +00:00
|
|
|
|
|
|
|
TMC2660_n::CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 1;
|
2019-01-17 19:17:16 +00:00
|
|
|
chopconf.toff = chopper_timing.toff;
|
2019-01-20 00:57:02 +00:00
|
|
|
chopconf.hend = chopper_timing.hend + 3;
|
|
|
|
chopconf.hstrt = chopper_timing.hstrt - 1;
|
2018-12-10 02:54:48 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
2019-06-14 04:16:10 +00:00
|
|
|
st.sdoff(0);
|
2018-10-06 22:18:10 +00:00
|
|
|
st.rms_current(mA);
|
|
|
|
st.microsteps(microsteps);
|
2019-06-14 04:16:10 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
st.dedge(true);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
st.intpol(INTERPOLATE);
|
2018-12-10 02:54:48 +00:00
|
|
|
st.diss2g(true); // Disable short to ground protection. Too many false readings?
|
2019-02-20 08:22:42 +00:00
|
|
|
|
|
|
|
#if ENABLED(TMC_DEBUG)
|
|
|
|
st.rdsel(0b01);
|
|
|
|
#endif
|
2018-10-06 22:18:10 +00:00
|
|
|
}
|
|
|
|
#endif // TMC2660
|
|
|
|
|
2019-02-06 12:33:14 +00:00
|
|
|
#if HAS_DRIVER(TMC5130)
|
2019-05-25 23:22:12 +00:00
|
|
|
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 thrs, const bool stealth) {
|
2019-02-06 12:33:14 +00:00
|
|
|
st.begin();
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 1;
|
|
|
|
chopconf.toff = chopper_timing.toff;
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
chopconf.hend = chopper_timing.hend + 3;
|
|
|
|
chopconf.hstrt = chopper_timing.hstrt - 1;
|
2019-06-09 10:08:05 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
chopconf.dedge = true;
|
|
|
|
#endif
|
2019-02-06 12:33:14 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
|
|
|
st.microsteps(microsteps);
|
|
|
|
st.iholddelay(10);
|
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
|
|
|
|
|
|
|
st.en_pwm_mode(stealth);
|
|
|
|
st.stored.stealthChop_enabled = stealth;
|
|
|
|
|
|
|
|
PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_freq = 0b01; // f_pwm = 2/683 f_clk
|
|
|
|
pwmconf.pwm_autoscale = true;
|
|
|
|
pwmconf.pwm_grad = 5;
|
|
|
|
pwmconf.pwm_ampl = 180;
|
|
|
|
st.PWMCONF(pwmconf.sr);
|
|
|
|
|
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2019-05-25 23:22:12 +00:00
|
|
|
st.set_pwm_thrs(thrs);
|
2019-02-06 12:33:14 +00:00
|
|
|
#else
|
|
|
|
UNUSED(thrs);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
st.GSTAT(); // Clear GSTAT
|
|
|
|
}
|
|
|
|
#endif // TMC5130
|
|
|
|
|
|
|
|
#if HAS_DRIVER(TMC5160)
|
2019-05-25 23:22:12 +00:00
|
|
|
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 thrs, const bool stealth) {
|
2019-02-06 12:33:14 +00:00
|
|
|
st.begin();
|
|
|
|
|
|
|
|
int8_t timings[] = CHOPPER_TIMING; // Default 4, -2, 1
|
|
|
|
|
|
|
|
CHOPCONF_t chopconf{0};
|
|
|
|
chopconf.tbl = 1;
|
|
|
|
chopconf.toff = timings[0];
|
|
|
|
chopconf.intpol = INTERPOLATE;
|
|
|
|
chopconf.hend = timings[1] + 3;
|
|
|
|
chopconf.hstrt = timings[2] - 1;
|
2019-06-09 10:08:05 +00:00
|
|
|
#if ENABLED(SQUARE_WAVE_STEPPING)
|
|
|
|
chopconf.dedge = true;
|
|
|
|
#endif
|
2019-02-06 12:33:14 +00:00
|
|
|
st.CHOPCONF(chopconf.sr);
|
|
|
|
|
|
|
|
st.rms_current(mA, HOLD_MULTIPLIER);
|
|
|
|
st.microsteps(microsteps);
|
|
|
|
st.iholddelay(10);
|
|
|
|
st.TPOWERDOWN(128); // ~2s until driver lowers to hold current
|
|
|
|
|
|
|
|
#if ENABLED(ADAPTIVE_CURRENT)
|
|
|
|
COOLCONF_t coolconf{0};
|
|
|
|
coolconf.semin = INCREASE_CURRENT_THRS;
|
|
|
|
coolconf.semax = REDUCE_CURRENT_THRS;
|
|
|
|
st.COOLCONF(coolconf.sr);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
st.en_pwm_mode(stealth);
|
|
|
|
|
2019-06-08 19:34:50 +00:00
|
|
|
TMC2160_n::PWMCONF_t pwmconf{0};
|
|
|
|
pwmconf.pwm_lim = 12;
|
|
|
|
pwmconf.pwm_reg = 8;
|
|
|
|
pwmconf.pwm_autograd = true;
|
2019-02-06 12:33:14 +00:00
|
|
|
pwmconf.pwm_autoscale = true;
|
2019-06-08 19:34:50 +00:00
|
|
|
pwmconf.pwm_freq = 0b01;
|
|
|
|
pwmconf.pwm_grad = 14;
|
|
|
|
pwmconf.pwm_ofs = 36;
|
2019-02-06 12:33:14 +00:00
|
|
|
st.PWMCONF(pwmconf.sr);
|
|
|
|
|
|
|
|
#if ENABLED(HYBRID_THRESHOLD)
|
2019-05-25 23:22:12 +00:00
|
|
|
st.set_pwm_thrs(thrs);
|
2019-02-06 12:33:14 +00:00
|
|
|
#else
|
|
|
|
UNUSED(thrs);
|
|
|
|
#endif
|
|
|
|
st.GSTAT(); // Clear GSTAT
|
|
|
|
}
|
|
|
|
#endif // TMC5160
|
|
|
|
|
2018-03-19 00:01:42 +00:00
|
|
|
void restore_stepper_drivers() {
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperX.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(X2)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperX2.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperY.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Y2)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperY2.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperZ.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(Z2)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperZ2.push();
|
|
|
|
#endif
|
2018-06-19 16:55:49 +00:00
|
|
|
#if AXIS_IS_TMC(Z3)
|
|
|
|
stepperZ3.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E0)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperE0.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E1)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperE1.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E2)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperE2.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E3)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperE3.push();
|
|
|
|
#endif
|
2018-07-14 11:13:06 +00:00
|
|
|
#if AXIS_IS_TMC(E4)
|
2018-03-19 00:01:42 +00:00
|
|
|
stepperE4.push();
|
|
|
|
#endif
|
2018-09-17 04:57:50 +00:00
|
|
|
#if AXIS_IS_TMC(E5)
|
|
|
|
stepperE5.push();
|
|
|
|
#endif
|
2018-03-19 00:01:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void reset_stepper_drivers() {
|
2019-01-24 01:06:54 +00:00
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(TMC26X)
|
2018-03-19 00:01:42 +00:00
|
|
|
tmc26x_init_to_defaults();
|
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
|
|
|
|
#if HAS_DRIVER(L6470)
|
|
|
|
L6470.init_to_defaults();
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
|
2018-12-07 21:34:21 +00:00
|
|
|
#if HAS_TRINAMIC
|
|
|
|
static constexpr bool stealthchop_by_axis[] = {
|
|
|
|
#if ENABLED(STEALTHCHOP_XY)
|
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
,
|
|
|
|
#if ENABLED(STEALTHCHOP_Z)
|
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
,
|
|
|
|
#if ENABLED(STEALTHCHOP_E)
|
|
|
|
true
|
|
|
|
#else
|
|
|
|
false
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-10-03 07:48:49 +00:00
|
|
|
#if AXIS_IS_TMC(X)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(X, STEALTH_AXIS_XY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(X2)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(X2, STEALTH_AXIS_XY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Y)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(Y, STEALTH_AXIS_XY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Y2)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(Y2, STEALTH_AXIS_XY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Z)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(Z, STEALTH_AXIS_Z);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Z2)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(Z2, STEALTH_AXIS_Z);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(Z3)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(Z3, STEALTH_AXIS_Z);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E0)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E0, STEALTH_AXIS_E);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E1)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E1, STEALTH_AXIS_E);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E2)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E2, STEALTH_AXIS_E);
|
2018-03-19 00:01:42 +00:00
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
#if AXIS_IS_TMC(E3)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E3, STEALTH_AXIS_E);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E4)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E4, STEALTH_AXIS_E);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_IS_TMC(E5)
|
2019-05-25 23:22:12 +00:00
|
|
|
_TMC_INIT(E5, STEALTH_AXIS_E);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
|
2018-10-07 20:37:44 +00:00
|
|
|
#if USE_SENSORLESS
|
2018-10-03 07:48:49 +00:00
|
|
|
#if X_SENSORLESS
|
|
|
|
#if AXIS_HAS_STALLGUARD(X)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperX.homing_threshold(X_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_HAS_STALLGUARD(X2)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperX2.homing_threshold(X_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if Y_SENSORLESS
|
|
|
|
#if AXIS_HAS_STALLGUARD(Y)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperY.homing_threshold(Y_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_HAS_STALLGUARD(Y2)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperY2.homing_threshold(Y_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if Z_SENSORLESS
|
|
|
|
#if AXIS_HAS_STALLGUARD(Z)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperZ.homing_threshold(Z_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_HAS_STALLGUARD(Z2)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperZ2.homing_threshold(Z_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#if AXIS_HAS_STALLGUARD(Z3)
|
2019-06-20 20:47:50 +00:00
|
|
|
stepperZ3.homing_threshold(Z_STALL_SENSITIVITY);
|
2018-10-03 07:48:49 +00:00
|
|
|
#endif
|
|
|
|
#endif
|
2018-03-19 00:01:42 +00:00
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
|
2018-03-19 00:01:42 +00:00
|
|
|
#ifdef TMC_ADV
|
|
|
|
TMC_ADV()
|
|
|
|
#endif
|
2018-10-03 07:48:49 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
#if HAS_TRINAMIC
|
|
|
|
stepper.set_directions();
|
|
|
|
#endif
|
2018-03-19 00:01:42 +00:00
|
|
|
}
|
|
|
|
|
2016-11-07 20:46:01 +00:00
|
|
|
//
|
2015-02-27 11:43:23 +00:00
|
|
|
// L6470 Driver objects and inits
|
2016-11-07 20:46:01 +00:00
|
|
|
//
|
2018-07-14 11:13:06 +00:00
|
|
|
#if HAS_DRIVER(L6470)
|
2016-11-07 20:46:01 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
// create stepper objects
|
2015-02-27 11:43:23 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
#define _L6470_DEFINE(ST) L6470 stepper##ST((const int)L6470_CHAIN_SS_PIN)
|
2017-03-07 05:00:43 +00:00
|
|
|
|
2016-11-07 20:46:01 +00:00
|
|
|
// L6470 Stepper objects
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(X);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X2(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(X2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(Y);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y2(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(Y2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(Z);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z2(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(Z2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z3(L6470)
|
2018-06-19 16:55:49 +00:00
|
|
|
_L6470_DEFINE(Z3);
|
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E0(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(E0);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E1(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(E1);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E2(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(E2);
|
2015-07-31 05:28:11 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E3(L6470)
|
2017-03-07 05:00:43 +00:00
|
|
|
_L6470_DEFINE(E3);
|
2015-10-03 06:08:58 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E4(L6470)
|
2017-04-09 08:23:05 +00:00
|
|
|
_L6470_DEFINE(E4);
|
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E5(L6470)
|
2018-09-17 04:57:50 +00:00
|
|
|
_L6470_DEFINE(E5);
|
|
|
|
#endif
|
2016-11-07 20:46:01 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
// not using L6470 library's init command because it
|
|
|
|
// briefly sends power to the steppers
|
|
|
|
|
|
|
|
#define _L6470_INIT_CHIP(Q) do{ \
|
|
|
|
stepper##Q.resetDev(); \
|
|
|
|
stepper##Q.softFree(); \
|
|
|
|
stepper##Q.SetParam(L6470_CONFIG, CONFIG_PWM_DIV_1 \
|
|
|
|
| CONFIG_PWM_MUL_2 \
|
|
|
|
| CONFIG_SR_290V_us \
|
|
|
|
| CONFIG_OC_SD_DISABLE \
|
|
|
|
| CONFIG_VS_COMP_DISABLE \
|
|
|
|
| CONFIG_SW_HARD_STOP \
|
|
|
|
| CONFIG_INT_16MHZ); \
|
|
|
|
stepper##Q.SetParam(L6470_KVAL_RUN, 0xFF); \
|
|
|
|
stepper##Q.SetParam(L6470_KVAL_ACC, 0xFF); \
|
|
|
|
stepper##Q.SetParam(L6470_KVAL_DEC, 0xFF); \
|
|
|
|
stepper##Q.setMicroSteps(Q##_MICROSTEPS); \
|
|
|
|
stepper##Q.setOverCurrent(Q##_OVERCURRENT); \
|
|
|
|
stepper##Q.setStallCurrent(Q##_STALLCURRENT); \
|
|
|
|
stepper##Q.SetParam(L6470_KVAL_HOLD, Q##_MAX_VOLTAGE); \
|
|
|
|
stepper##Q.SetParam(L6470_ABS_POS, 0); \
|
|
|
|
stepper##Q.getStatus(); \
|
2017-06-15 20:17:41 +00:00
|
|
|
}while(0)
|
2016-11-07 20:46:01 +00:00
|
|
|
|
2019-01-24 01:06:54 +00:00
|
|
|
void L6470_Marlin::init_to_defaults() {
|
|
|
|
#if AXIS_DRIVER_TYPE_X(L6470)
|
|
|
|
_L6470_INIT_CHIP(X);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_X2(L6470)
|
|
|
|
_L6470_INIT_CHIP(X2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y(L6470)
|
|
|
|
_L6470_INIT_CHIP(Y);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Y2(L6470)
|
|
|
|
_L6470_INIT_CHIP(Y2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z(L6470)
|
|
|
|
_L6470_INIT_CHIP(Z);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z2(L6470)
|
|
|
|
_L6470_INIT_CHIP(Z2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_Z3(L6470)
|
|
|
|
_L6470_INIT_CHIP(Z3);
|
2018-06-19 16:55:49 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E0(L6470)
|
|
|
|
_L6470_INIT_CHIP(E0);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E1(L6470)
|
|
|
|
_L6470_INIT_CHIP(E1);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E2(L6470)
|
|
|
|
_L6470_INIT_CHIP(E2);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E3(L6470)
|
|
|
|
_L6470_INIT_CHIP(E3);
|
2016-11-07 20:46:01 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E4(L6470)
|
|
|
|
_L6470_INIT_CHIP(E4);
|
2017-04-09 08:23:05 +00:00
|
|
|
#endif
|
2019-01-24 01:06:54 +00:00
|
|
|
#if AXIS_DRIVER_TYPE_E5(L6470)
|
|
|
|
_L6470_INIT_CHIP(E5);
|
2018-09-17 04:57:50 +00:00
|
|
|
#endif
|
2016-11-07 20:46:01 +00:00
|
|
|
}
|
|
|
|
|
2018-07-14 11:13:06 +00:00
|
|
|
#endif // L6470
|