-
Notifications
You must be signed in to change notification settings - Fork 0
/
Trinamic.h
167 lines (158 loc) · 5.77 KB
/
Trinamic.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
#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