|
@@ -64,13 +64,13 @@ class TMCStorage {
|
64
|
64
|
uint8_t otpw_count = 0,
|
65
|
65
|
error_count = 0;
|
66
|
66
|
bool flag_otpw = false;
|
67
|
|
- inline bool getOTPW() { return flag_otpw; }
|
68
|
|
- inline void clear_otpw() { flag_otpw = 0; }
|
|
67
|
+ bool getOTPW() { return flag_otpw; }
|
|
68
|
+ void clear_otpw() { flag_otpw = 0; }
|
69
|
69
|
#endif
|
70
|
70
|
|
71
|
|
- inline uint16_t getMilliamps() { return val_mA; }
|
|
71
|
+ uint16_t getMilliamps() { return val_mA; }
|
72
|
72
|
|
73
|
|
- inline void printLabel() {
|
|
73
|
+ void printLabel() {
|
74
|
74
|
SERIAL_CHAR(AXIS_LETTER);
|
75
|
75
|
if (DRIVER_ID > '0') SERIAL_CHAR(DRIVER_ID);
|
76
|
76
|
}
|
|
@@ -97,25 +97,31 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
97
|
97
|
TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t axis_chain_index) :
|
98
|
98
|
TMC(CS, RS, pinMOSI, pinMISO, pinSCK, axis_chain_index)
|
99
|
99
|
{}
|
100
|
|
- inline uint16_t rms_current() { return TMC::rms_current(); }
|
101
|
|
- inline void rms_current(uint16_t mA) {
|
|
100
|
+ uint16_t rms_current() { return TMC::rms_current(); }
|
|
101
|
+ void rms_current(uint16_t mA) {
|
102
|
102
|
this->val_mA = mA;
|
103
|
103
|
TMC::rms_current(mA);
|
104
|
104
|
}
|
105
|
|
- inline void rms_current(const uint16_t mA, const float mult) {
|
|
105
|
+ void rms_current(const uint16_t mA, const float mult) {
|
106
|
106
|
this->val_mA = mA;
|
107
|
107
|
TMC::rms_current(mA, mult);
|
108
|
108
|
}
|
109
|
|
- inline uint16_t get_microstep_counter() { return TMC::MSCNT(); }
|
|
109
|
+ uint16_t get_microstep_counter() { return TMC::MSCNT(); }
|
110
|
110
|
|
111
|
111
|
#if HAS_STEALTHCHOP
|
112
|
|
- inline bool get_stealthChop() { return this->en_pwm_mode(); }
|
113
|
|
- inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
114
|
|
- inline void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
|
115
|
|
- inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
116
|
|
- inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
|
112
|
+ bool get_stealthChop() { return this->en_pwm_mode(); }
|
|
113
|
+ bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
|
114
|
+ void refresh_stepping_mode() { this->en_pwm_mode(this->stored.stealthChop_enabled); }
|
|
115
|
+ void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
|
116
|
+ bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
117
|
117
|
#endif
|
118
|
118
|
|
|
119
|
+ void set_chopper_times(const chopper_timing_t &ct) {
|
|
120
|
+ TMC::toff(ct.toff);
|
|
121
|
+ TMC::hysteresis_end(ct.hend);
|
|
122
|
+ TMC::hysteresis_start(ct.hstrt);
|
|
123
|
+ }
|
|
124
|
+
|
119
|
125
|
#if ENABLED(HYBRID_THRESHOLD)
|
120
|
126
|
uint32_t get_pwm_thrs() {
|
121
|
127
|
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
|
|
@@ -127,7 +133,7 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
127
|
133
|
#endif
|
128
|
134
|
|
129
|
135
|
#if USE_SENSORLESS
|
130
|
|
- inline int16_t homing_threshold() { return TMC::sgt(); }
|
|
136
|
+ int16_t homing_threshold() { return TMC::sgt(); }
|
131
|
137
|
void homing_threshold(int16_t sgt_val) {
|
132
|
138
|
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
|
133
|
139
|
TMC::sgt(sgt_val);
|
|
@@ -139,13 +145,13 @@ class TMCMarlin : public TMC, public TMCStorage<AXIS_LETTER, DRIVER_ID> {
|
139
|
145
|
#endif
|
140
|
146
|
|
141
|
147
|
#if HAS_LCD_MENU
|
142
|
|
- inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
|
148
|
+ void refresh_stepper_current() { rms_current(this->val_mA); }
|
143
|
149
|
|
144
|
150
|
#if ENABLED(HYBRID_THRESHOLD)
|
145
|
|
- inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
|
151
|
+ void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
146
|
152
|
#endif
|
147
|
153
|
#if USE_SENSORLESS
|
148
|
|
- inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
|
154
|
+ void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
149
|
155
|
#endif
|
150
|
156
|
#endif
|
151
|
157
|
|
|
@@ -167,24 +173,30 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
|
167
|
173
|
{}
|
168
|
174
|
|
169
|
175
|
uint16_t rms_current() { return TMC2208Stepper::rms_current(); }
|
170
|
|
- inline void rms_current(const uint16_t mA) {
|
|
176
|
+ void rms_current(const uint16_t mA) {
|
171
|
177
|
this->val_mA = mA;
|
172
|
178
|
TMC2208Stepper::rms_current(mA);
|
173
|
179
|
}
|
174
|
|
- inline void rms_current(const uint16_t mA, const float mult) {
|
|
180
|
+ void rms_current(const uint16_t mA, const float mult) {
|
175
|
181
|
this->val_mA = mA;
|
176
|
182
|
TMC2208Stepper::rms_current(mA, mult);
|
177
|
183
|
}
|
178
|
|
- inline uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); }
|
|
184
|
+ uint16_t get_microstep_counter() { return TMC2208Stepper::MSCNT(); }
|
179
|
185
|
|
180
|
186
|
#if HAS_STEALTHCHOP
|
181
|
|
- inline bool get_stealthChop() { return !this->en_spreadCycle(); }
|
182
|
|
- inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
183
|
|
- inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
|
184
|
|
- inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
185
|
|
- inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
|
187
|
+ bool get_stealthChop() { return !this->en_spreadCycle(); }
|
|
188
|
+ bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
|
189
|
+ void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
|
|
190
|
+ void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
|
191
|
+ bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
186
|
192
|
#endif
|
187
|
193
|
|
|
194
|
+ void set_chopper_times(const chopper_timing_t &ct) {
|
|
195
|
+ TMC2208Stepper::toff(ct.toff);
|
|
196
|
+ TMC2208Stepper::hysteresis_end(ct.hend);
|
|
197
|
+ TMC2208Stepper::hysteresis_start(ct.hstrt);
|
|
198
|
+ }
|
|
199
|
+
|
188
|
200
|
#if ENABLED(HYBRID_THRESHOLD)
|
189
|
201
|
uint32_t get_pwm_thrs() {
|
190
|
202
|
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
|
|
@@ -196,10 +208,10 @@ class TMCMarlin<TMC2208Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
|
196
|
208
|
#endif
|
197
|
209
|
|
198
|
210
|
#if HAS_LCD_MENU
|
199
|
|
- inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
|
211
|
+ void refresh_stepper_current() { rms_current(this->val_mA); }
|
200
|
212
|
|
201
|
213
|
#if ENABLED(HYBRID_THRESHOLD)
|
202
|
|
- inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
|
214
|
+ void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
203
|
215
|
#endif
|
204
|
216
|
#endif
|
205
|
217
|
};
|
|
@@ -215,24 +227,30 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
|
215
|
227
|
{}
|
216
|
228
|
uint8_t get_address() { return slave_address; }
|
217
|
229
|
uint16_t rms_current() { return TMC2209Stepper::rms_current(); }
|
218
|
|
- inline void rms_current(const uint16_t mA) {
|
|
230
|
+ void rms_current(const uint16_t mA) {
|
219
|
231
|
this->val_mA = mA;
|
220
|
232
|
TMC2209Stepper::rms_current(mA);
|
221
|
233
|
}
|
222
|
|
- inline void rms_current(const uint16_t mA, const float mult) {
|
|
234
|
+ void rms_current(const uint16_t mA, const float mult) {
|
223
|
235
|
this->val_mA = mA;
|
224
|
236
|
TMC2209Stepper::rms_current(mA, mult);
|
225
|
237
|
}
|
226
|
|
- inline uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); }
|
|
238
|
+ uint16_t get_microstep_counter() { return TMC2209Stepper::MSCNT(); }
|
227
|
239
|
|
228
|
240
|
#if HAS_STEALTHCHOP
|
229
|
|
- inline bool get_stealthChop() { return !this->en_spreadCycle(); }
|
230
|
|
- inline bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
231
|
|
- inline void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
|
232
|
|
- inline void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
233
|
|
- inline bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
|
241
|
+ bool get_stealthChop() { return !this->en_spreadCycle(); }
|
|
242
|
+ bool get_stored_stealthChop() { return this->stored.stealthChop_enabled; }
|
|
243
|
+ void refresh_stepping_mode() { this->en_spreadCycle(!this->stored.stealthChop_enabled); }
|
|
244
|
+ void set_stealthChop(const bool stch) { this->stored.stealthChop_enabled = stch; refresh_stepping_mode(); }
|
|
245
|
+ bool toggle_stepping_mode() { set_stealthChop(!this->stored.stealthChop_enabled); return get_stealthChop(); }
|
234
|
246
|
#endif
|
235
|
247
|
|
|
248
|
+ void set_chopper_times(const chopper_timing_t &ct) {
|
|
249
|
+ TMC2209Stepper::toff(ct.toff);
|
|
250
|
+ TMC2209Stepper::hysteresis_end(ct.hend);
|
|
251
|
+ TMC2209Stepper::hysteresis_start(ct.hstrt);
|
|
252
|
+ }
|
|
253
|
+
|
236
|
254
|
#if ENABLED(HYBRID_THRESHOLD)
|
237
|
255
|
uint32_t get_pwm_thrs() {
|
238
|
256
|
return _tmc_thrs(this->microsteps(), this->TPWMTHRS(), planner.settings.axis_steps_per_mm[AXIS_ID]);
|
|
@@ -243,7 +261,7 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
|
243
|
261
|
}
|
244
|
262
|
#endif
|
245
|
263
|
#if USE_SENSORLESS
|
246
|
|
- inline int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); }
|
|
264
|
+ int16_t homing_threshold() { return TMC2209Stepper::SGTHRS(); }
|
247
|
265
|
void homing_threshold(int16_t sgt_val) {
|
248
|
266
|
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
|
249
|
267
|
TMC2209Stepper::SGTHRS(sgt_val);
|
|
@@ -252,13 +270,13 @@ class TMCMarlin<TMC2209Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC220
|
252
|
270
|
#endif
|
253
|
271
|
|
254
|
272
|
#if HAS_LCD_MENU
|
255
|
|
- inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
|
273
|
+ void refresh_stepper_current() { rms_current(this->val_mA); }
|
256
|
274
|
|
257
|
275
|
#if ENABLED(HYBRID_THRESHOLD)
|
258
|
|
- inline void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
|
276
|
+ void refresh_hybrid_thrs() { set_pwm_thrs(this->stored.hybrid_thrs); }
|
259
|
277
|
#endif
|
260
|
278
|
#if USE_SENSORLESS
|
261
|
|
- inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
|
279
|
+ void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
262
|
280
|
#endif
|
263
|
281
|
#endif
|
264
|
282
|
|
|
@@ -275,15 +293,21 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
|
275
|
293
|
TMCMarlin(const uint16_t CS, const float RS, const uint16_t pinMOSI, const uint16_t pinMISO, const uint16_t pinSCK, const uint8_t) :
|
276
|
294
|
TMC2660Stepper(CS, RS, pinMOSI, pinMISO, pinSCK)
|
277
|
295
|
{}
|
278
|
|
- inline uint16_t rms_current() { return TMC2660Stepper::rms_current(); }
|
279
|
|
- inline void rms_current(const uint16_t mA) {
|
|
296
|
+ uint16_t rms_current() { return TMC2660Stepper::rms_current(); }
|
|
297
|
+ void rms_current(const uint16_t mA) {
|
280
|
298
|
this->val_mA = mA;
|
281
|
299
|
TMC2660Stepper::rms_current(mA);
|
282
|
300
|
}
|
283
|
|
- inline uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); }
|
|
301
|
+ uint16_t get_microstep_counter() { return TMC2660Stepper::mstep(); }
|
|
302
|
+
|
|
303
|
+ void set_chopper_times(const chopper_timing_t &ct) {
|
|
304
|
+ TMC2660Stepper::toff(ct.toff);
|
|
305
|
+ TMC2660Stepper::hysteresis_end(ct.hend);
|
|
306
|
+ TMC2660Stepper::hysteresis_start(ct.hstrt);
|
|
307
|
+ }
|
284
|
308
|
|
285
|
309
|
#if USE_SENSORLESS
|
286
|
|
- inline int16_t homing_threshold() { return TMC2660Stepper::sgt(); }
|
|
310
|
+ int16_t homing_threshold() { return TMC2660Stepper::sgt(); }
|
287
|
311
|
void homing_threshold(int16_t sgt_val) {
|
288
|
312
|
sgt_val = (int16_t)constrain(sgt_val, sgt_min, sgt_max);
|
289
|
313
|
TMC2660Stepper::sgt(sgt_val);
|
|
@@ -292,10 +316,10 @@ class TMCMarlin<TMC2660Stepper, AXIS_LETTER, DRIVER_ID, AXIS_ID> : public TMC266
|
292
|
316
|
#endif
|
293
|
317
|
|
294
|
318
|
#if HAS_LCD_MENU
|
295
|
|
- inline void refresh_stepper_current() { rms_current(this->val_mA); }
|
|
319
|
+ void refresh_stepper_current() { rms_current(this->val_mA); }
|
296
|
320
|
|
297
|
321
|
#if USE_SENSORLESS
|
298
|
|
- inline void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
|
322
|
+ void refresh_homing_thrs() { homing_threshold(this->stored.homing_thrs); }
|
299
|
323
|
#endif
|
300
|
324
|
#endif
|
301
|
325
|
|