TMCStepper
Library supporting Trinamic Stepper Drivers for Arduino platforms
Loading...
Searching...
No Matches
TMC2240_bitfields.h
Go to the documentation of this file.
1
15#pragma once
16#pragma pack(push, 1)
17
18namespace TMC2240_n {
19 // 0x00 GCONF: Global Configuration Flags (RW)
20 struct GCONF_t {
21 constexpr static uint8_t address = 0x00;
22 union {
23 uint32_t sr;
24 struct {
25 bool : 1, // unused
27 en_pwm_mode : 1, // (spreadCycle)
29 shaft : 1,
36 : 1, // unused
42 uint16_t : 15; // unused
43 };
44 };
45 };
46
47 // 0x01 GSTAT: Global Status Flags (RO)
48 // Write 1 to clear a flag
49 struct GSTAT_t {
50 constexpr static uint8_t address = 0x01;
51 union {
52 uint8_t sr;
53 struct {
54 bool reset : 1,
56 uv_cp : 1,
59 : 3; // unused
60 };
61 };
62 };
63
64 // 0x03 NODECONF: Node Configuration (RW)
65 // Write 0 to reset values
66 struct NODECONF_t {
67 constexpr static uint8_t address = 0x03;
68 union {
69 uint16_t sr;
70 struct {
71 uint8_t nodeaddr : 8,
73 : 4; // unused
74 };
75 };
76 };
77
78 // 0x04 IOIN: I/O In (RO, mostly)
79 // Read the state of all input pins and return IC revision in high byte
80 // Write 1 to 'output' to reset
81 struct IOIN_t {
82 constexpr static uint8_t address = 0x04;
83 union {
84 uint32_t sr;
85 struct {
86 bool step : 1,
87 dir : 1,
88 encb : 1,
89 enca : 1,
91 encn : 1,
93 : 1, // reserved
94 comp_a : 1,
95 comp_b : 1,
98 output : 1, // RW
102 uint8_t silicon_rv : 3,
103 : 5, // unused
105 };
106 };
107 };
108
109 // 0x0A DRV_CONF: Driver Configuration (RW)
110 // Write 0 to "reset" values
111 struct DRV_CONF_t {
112 constexpr static uint8_t address = 0x0A;
113 union {
114 uint8_t sr;
115 struct {
116 uint8_t current_range : 2,
117 : 2, // unused
119 : 2; // unused
120 };
121 };
122 };
123
124 // 0x0B GLOBAL_SCALER: Global Scaler (RW)
125 // Write 0 to reset
127 constexpr static uint8_t address = 0x0B;
128 union {
129 uint8_t sr;
130 struct {
131 uint8_t GLOBALSCALER : 8;
132 };
133 };
134 };
135
136 // 0x10 IHOLD_IRUN: Motor Current Control (RW)
138 constexpr static uint8_t address = 0x10;
139 union {
140 uint32_t sr;
141 struct {
142 uint8_t ihold : 5,
143 : 3, // unused
144 irun : 5,
145 : 3, // unused
147 : 4, // unused
149 : 4; // unused
150 };
151 };
152 };
153
154 // 0x11 TPOWERDOWN: Motor Power Down Time (RW)
156 constexpr static uint8_t address = 0x11;
157 union {
158 uint8_t sr;
159 struct {
160 uint8_t TPOWERDOWN;
161 };
162 };
163 };
164
165 // 0x12 TSTEP: Actual Step Frequency (RO)
166 struct TSTEP_t {
167 constexpr static uint8_t address = 0x12;
168 union {
169 uint32_t sr;
170 struct {
171 uint32_t tstep : 20;
172 uint16_t : 12; // unused
173 };
174 };
175 };
176
177 // 0x13 TPWMTHRS: StealthChop Threshold (RW)
178 struct TPWMTHRS_t {
179 constexpr static uint8_t address = 0x13;
180 union {
181 uint32_t sr;
182 struct {
183 uint32_t tpwmthrs : 20;
184 uint16_t : 12; // unused
185 };
186 };
187 };
188
189 // 0x14 TCOOLTHRS: CoolStep Threshold (RW)
190 struct TCOOLTHRS_t {
191 constexpr static uint8_t address = 0x14;
192 union {
193 uint32_t sr;
194 struct {
195 uint32_t tcoolthrs : 20;
196 uint16_t : 12; // unused
197 };
198 };
199 };
200
201 // 0x15 THIGH: High Velocity Mode Threshold (RW)
202 struct THIGH_t {
203 constexpr static uint8_t address = 0x15;
204 union {
205 uint32_t sr;
206 struct {
207 uint32_t thigh : 20;
208 uint16_t : 12; // unused
209 };
210 };
211 };
212
213 // 0x50 ADC_VSUPPLY_AIN: Supply & AIN ADC (RO)
215 constexpr static uint8_t address = 0x50;
216 union {
217 uint32_t sr;
218 struct {
219 uint16_t adc_vsupply : 13;
220 uint16_t adc_ain : 13;
221 uint8_t : 6; // reserved / padding
222 };
223 };
224 };
225
226 // 0x51 ADC_TEMP: Temperature ADC (RO)
227 struct ADC_TEMP_t {
228 constexpr static uint8_t address = 0x51;
229 union {
230 uint32_t sr;
231 struct {
232 uint16_t adc_temp : 13;
233 uint32_t : 19; // reserved
234 };
235 };
236 };
237
238 // 0x52 OTW_OV_VTH: Overtemp/Overvoltage Thresholds (RW)
240 constexpr static uint8_t address = 0x52;
241 union {
242 uint32_t sr;
243 struct {
244 uint16_t overvoltage_vth : 13;
245 uint8_t : 3;
246 uint16_t overtemp_prewarn_vth : 13;
247 uint8_t : 3;
248 };
249 };
250 };
251
252 // 0x60 MSLUT0: Microstep Lookup Table 0 (RW)
253 struct MSLUT0_t {
254 constexpr static uint8_t address = 0x60;
255 uint32_t sr; // 0xAAAAB554
256 };
257
258 // 0x61 MSLUT1: Microstep Lookup Table 1 (RW)
259 struct MSLUT1_t {
260 constexpr static uint8_t address = 0x61;
261 uint32_t sr; // 0x4A9554AA
262 };
263
264 // 0x62 MSLUT2: Microstep Lookup Table 2 (RW)
265 struct MSLUT2_t {
266 constexpr static uint8_t address = 0x62;
267 uint32_t sr; // 0x24492929
268 };
269
270 // 0x63 MSLUT3: Microstep Lookup Table 3 (RW)
271 struct MSLUT3_t {
272 constexpr static uint8_t address = 0x63;
273 uint32_t sr; // 0x10104222
274 };
275
276 // 0x64 MSLUT4: Microstep Lookup Table 4 (RW)
277 struct MSLUT4_t {
278 constexpr static uint8_t address = 0x64;
279 uint32_t sr; // 0xFBFFFFFF
280 };
281
282 // 0x65 MSLUT5: Microstep Lookup Table 5 (RW)
283 struct MSLUT5_t {
284 constexpr static uint8_t address = 0x65;
285 uint32_t sr; // 0xB5BB777D
286 };
287
288 // 0x66 MSLUT6: Microstep Lookup Table 6 (RW)
289 struct MSLUT6_t {
290 constexpr static uint8_t address = 0x66;
291 uint32_t sr; // 0x49295556
292 };
293
294 // 0x67 MSLUT7: Microstep Lookup Table 7 (RW)
295 struct MSLUT7_t {
296 constexpr static uint8_t address = 0x67;
297 uint32_t sr; // 0x00404222
298 };
299
300 // 0x68 MSLUTSEL: Microstep Lookup Table Selector (RW)
301 struct MSLUTSEL_t {
302 constexpr static uint8_t address = 0x68;
303 union {
304 uint32_t sr; // 0xFFFF8056
305 struct {
306 uint8_t w0 : 2, // %10
307 w1 : 2, // %01
308 w2 : 2, // %01
309 w3 : 2, // %01
310 x1 : 8, // 128
311 x2 : 8, // 255
312 x3 : 8; // 255
313 };
314 };
315 };
316
317 // 0x69 MSLUTSTART: Microstep Lookup Table Start (RW)
319 constexpr static uint8_t address = 0x69;
320 union {
321 uint32_t sr; // 0x00F70000
322 struct {
323 uint8_t start_sin : 8, // 0
324 : 8,
325 start_sin90 : 8; // 247
326 int8_t offset_sin90 : 8; // 0
327 };
328 };
329 };
330
331 // 0x69 MSCURACT: Actual Microstep Current (RO)
332 struct MSCURACT_t {
333 constexpr static uint8_t address = 0x6B;
334 union {
335 uint32_t sr;
336 struct {
337 int16_t cur_b : 9,
338 : 7, // unused
339 cur_a : 9,
340 : 7; // unused
341 };
342 };
343 };
344
345 // 0x6C CHOPCONF: Chopper Configuration (RW)
346 struct CHOPCONF_t {
347 constexpr static uint8_t address = 0x6C;
348 union {
349 uint32_t sr;
350 struct {
351 uint8_t toff : 4,
352 hstrt : 3,
353 hend : 4;
354 bool fd3 : 1,
356 : 1, // unused
357 chm : 1;
358 uint8_t TBL : 2;
359 bool : 1, // unused
362 uint8_t tpfd : 4,
363 mres : 4;
364 bool intpol : 1,
365 dedge : 1,
368 };
369 };
370 };
371
372 // 0x6D COOLCONF: CoolStep Configuration (RW)
373 struct COOLCONF_t {
374 constexpr static uint8_t address = 0x6D;
375 union {
376 uint32_t sr;
377 struct {
378 uint8_t semin : 4;
379 bool : 1;
380 uint8_t seup : 2;
381 bool : 1;
382 uint8_t semax : 4;
383 bool : 1;
384 uint8_t sedn : 2;
385 bool seimin : 1;
386 int8_t sgt : 7,
387 : 1; // unused
388 bool sfilt : 1;
389 uint8_t : 7; // unused
390 };
391 };
392 };
393
394 // 0x6F DRV_STATUS: Driver Status Flags (RO)
396 constexpr static uint8_t address = 0x6F;
397 union {
398 uint32_t sr;
399 struct {
400 uint16_t SG_RESULT : 10;
401 uint8_t : 2; // unused
402 uint8_t s2vsa : 1,
403 s2vsb : 1,
406 uint16_t CS_ACTUAL : 5;
407 uint8_t : 3; // unused
408 bool stallguard : 1,
409 ot : 1,
410 otpw : 1,
411 s2ga : 1,
412 s2gb : 1,
413 ola : 1,
414 olb : 1,
415 stst : 1;
416 };
417 };
418 };
419
420 // 0x70 PWMCONF: PWM Configuration (RW)
421 struct PWMCONF_t {
422 constexpr static uint8_t address = 0x70;
423 union {
424 uint32_t sr; // 0xC40C1E1D
425 struct {
426 uint8_t pwm_ofs : 8, // 29
427 pwm_grad : 8, // 30
428 pwm_freq : 2; // 0
429 bool pwm_autoscale : 1, // true
430 pwm_autograd : 1; // true
431 uint8_t freewheel : 2; // 0
432 bool pwm_meas_sd_enable : 1, // false
433 pwm_dis_reg_stst : 1; // false
434 uint8_t pwm_reg : 4, // 4
435 pwm_lim : 4; // 12
436 };
437 };
438 };
439
440 // 0x71 PWM_SCALE: PWM Amplitude (RO)
441 struct PWM_SCALE_t {
442 constexpr static uint8_t address = 0x71;
443 union {
444 uint32_t sr;
445 struct {
446 uint16_t pwm_scale_sum : 10;
447 uint8_t : 6; // unused
448 int16_t pwm_scale_auto : 9;
449 uint8_t : 7; // unused
450 };
451 };
452 };
453
454 // 0x72 PWM_AUTO: PWM Automatic Scaling (RO)
455 struct PWM_AUTO_t {
456 constexpr static uint8_t address = 0x72;
457 union {
458 uint32_t sr;
459 struct {
460 uint8_t pwm_ofs_auto : 8,
461 : 8, // unused
463 : 8; // unused
464 };
465 };
466 };
467
468 // 0x74 SG4_THRS: StallGuard4 Threshold (RW)
469 struct SG4_THRS_t {
470 constexpr static uint8_t address = 0x74;
471 union {
472 uint32_t sr;
473 struct {
474 uint8_t sg4_thrs;
475 bool sg4_filt_en : 1;
476 uint8_t sg4_angle_offset : 1;
477 uint32_t : 22; // unused
478 };
479 };
480 };
481
482 // 0x75 SG4_RESULT: StallGuard4 Result (RO)
484 constexpr static uint8_t address = 0x75;
485 union {
486 uint32_t sr;
487 struct {
488 uint16_t sg4_result : 10;
489 uint32_t : 22; // unused
490 };
491 };
492 };
493
494 // 0x76 SG4_IND: StallGuard4 Indicators (RO)
495 struct SG4_IND_t {
496 constexpr static uint8_t address = 0x76;
497 union {
498 uint32_t sr;
499 struct {
501 };
502 };
503 };
504
505} // TMC2240_n
506
507#pragma pack(pop)
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address
static constexpr uint8_t address