Mister-Green/Repetier-Firmware 1.0.3/Repetier/Trinamic.h
2019-08-07 01:22:58 +02:00

168 lines
5.8 KiB
C

#include <TMC2130Stepper.h>
#define TMC2130_ON_X (TMC2130_X_CS_PIN > 0)
#define TMC2130_ON_Y (TMC2130_Y_CS_PIN > 0)
#define TMC2130_ON_Z (TMC2130_Z_CS_PIN > 0)
#define TMC2130_ON_EXT0 (TMC2130_EXT0_CS_PIN > 0)
#define TMC2130_ON_EXT1 (TMC2130_EXT1_CS_PIN > 0)
#define TMC2130_ON_EXT2 (TMC2130_EXT2_CS_PIN > 0)
/*
_TMC_COUNT determines the number of Trinamic chips to configure.
It counts how many ChipSelect pins were configured by the user.
*/
#define _TMC_COUNT ( TMC2130_ON_X + \
TMC2130_ON_Y + \
TMC2130_ON_Z + \
TMC2130_ON_EXT0 + \
TMC2130_ON_EXT1 + \
TMC2130_ON_EXT2 )
#if _TMC_COUNT < 1
#error "Trinamic TMC2130 support enabled but no CS pins defined."
#endif
#if STEPPER_CURRENT_CONTROL == CURRENT_CONTROL_MANUAL
#undef STEPPER_CURRENT_CONTROL
#else
#error "When using Trinamic drivers you can't enable another STEPPER_CURRENT_CONTROL method."
#endif
#define STEPPER_CURRENT_CONTROL CURRENT_CONTROL_TMC2130
#if !defined(MOTOR_CURRENT)
#error "When using Trinamic drivers you have to define MOTOR_CURRENT parameter."
#endif
/*
If user did not define axis specific values we use the global ones.
*/
#if !defined(TMC2130_STEALTHCHOP_X) && TMC2130_ON_X
#define TMC2130_STEALTHCHOP_X TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_X) && TMC2130_ON_X
#define TMC2130_INTERPOLATE_256_X TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_X) && TMC2130_ON_X
#define TMC2130_STALLGUARD_X TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_X) && TMC2130_ON_X
#define TMC2130_PWM_AMPL_X TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_X) && TMC2130_ON_X
#define TMC2130_PWM_GRAD_X TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_X) && TMC2130_ON_X
#define TMC2130_PWM_AUTOSCALE_X TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_X) && TMC2130_ON_X
#define TMC2130_PWM_FREQ_X TMC2130_PWM_FREQ
#endif
#if !defined(TMC2130_STEALTHCHOP_Y) && TMC2130_ON_Y
#define TMC2130_STEALTHCHOP_Y TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_Y) && TMC2130_ON_Y
#define TMC2130_INTERPOLATE_256_Y TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_Y) && TMC2130_ON_Y
#define TMC2130_STALLGUARD_Y TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_Y) && TMC2130_ON_Y
#define TMC2130_PWM_AMPL_Y TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_Y) && TMC2130_ON_Y
#define TMC2130_PWM_GRAD_Y TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_Y) && TMC2130_ON_Y
#define TMC2130_PWM_AUTOSCALE_Y TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_Y) && TMC2130_ON_Y
#define TMC2130_PWM_FREQ_Y TMC2130_PWM_FREQ
#endif
#if !defined(TMC2130_STEALTHCHOP_Z) && TMC2130_ON_Z
#define TMC2130_STEALTHCHOP_Z TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_Z) && TMC2130_ON_Z
#define TMC2130_INTERPOLATE_256_Z TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_Z) && TMC2130_ON_Z
#define TMC2130_STALLGUARD_Z TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_Z) && TMC2130_ON_Z
#define TMC2130_PWM_AMPL_Z TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_Z) && TMC2130_ON_Z
#define TMC2130_PWM_GRAD_Z TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_Z) && TMC2130_ON_Z
#define TMC2130_PWM_AUTOSCALE_Z TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_Z) && TMC2130_ON_Z
#define TMC2130_PWM_FREQ_Z TMC2130_PWM_FREQ
#endif
#if !defined(TMC2130_STEALTHCHOP_EXT0) && TMC2130_ON_EXT0
#define TMC2130_STEALTHCHOP_EXT0 TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_EXT0) && TMC2130_ON_EXT0
#define TMC2130_INTERPOLATE_256_EXT0 TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_EXT0) && TMC2130_ON_EXT0
#define TMC2130_STALLGUARD_EXT0 TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_EXT0) && TMC2130_ON_EXT0
#define TMC2130_PWM_AMPL_EXT0 TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_EXT0) && TMC2130_ON_EXT0
#define TMC2130_PWM_GRAD_EXT0 TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_EXT0) && TMC2130_ON_EXT0
#define TMC2130_PWM_AUTOSCALE_EXT0 TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_EXT0) && TMC2130_ON_EXT0
#define TMC2130_PWM_FREQ_EXT0 TMC2130_PWM_FREQ
#endif
#if !defined(TMC2130_STEALTHCHOP_EXT1) && TMC2130_ON_EXT1
#define TMC2130_STEALTHCHOP_EXT1 TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_EXT1) && TMC2130_ON_EXT1
#define TMC2130_INTERPOLATE_256_EXT1 TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_EXT1) && TMC2130_ON_EXT1
#define TMC2130_STALLGUARD_EXT1 TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_EXT1) && TMC2130_ON_EXT1
#define TMC2130_PWM_AMPL_EXT1 TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_EXT1) && TMC2130_ON_EXT1
#define TMC2130_PWM_GRAD_EXT1 TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_EXT1) && TMC2130_ON_EXT1
#define TMC2130_PWM_AUTOSCALE_EXT1 TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_EXT1) && TMC2130_ON_EXT1
#define TMC2130_PWM_FREQ_EXT1 TMC2130_PWM_FREQ
#endif
#if !defined(TMC2130_STEALTHCHOP_EXT2) && TMC2130_ON_EXT2
#define TMC2130_STEALTHCHOP_EXT2 TMC2130_STEALTHCHOP
#endif
#if !defined(TMC2130_INTERPOLATE_256_EXT2) && TMC2130_ON_EXT2
#define TMC2130_INTERPOLATE_256_EXT2 TMC2130_INTERPOLATE_256
#endif
#if !defined(TMC2130_STALLGUARD_EXT2) && TMC2130_ON_EXT2
#define TMC2130_STALLGUARD_EXT2 TMC2130_STALLGUARD
#endif
#if !defined(TMC2130_PWM_AMPL_EXT2) && TMC2130_ON_EXT2
#define TMC2130_PWM_AMPL_EXT2 TMC2130_PWM_AMPL
#endif
#if !defined(TMC2130_PWM_GRAD_EXT2) && TMC2130_ON_EXT2
#define TMC2130_PWM_GRAD_EXT2 TMC2130_PWM_GRAD
#endif
#if !defined(TMC2130_PWM_AUTOSCALE_EXT2) && TMC2130_ON_EXT2
#define TMC2130_PWM_AUTOSCALE_EXT2 TMC2130_PWM_AUTOSCALE
#endif
#if !defined(TMC2130_PWM_FREQ_EXT2) && TMC2130_ON_EXT2
#define TMC2130_PWM_FREQ_EXT2 TMC2130_PWM_FREQ
#endif