PyTmcStepper 0.15.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- pytmcstepper-0.15.0.dist-info/METADATA +338 -0
- pytmcstepper-0.15.0.dist-info/RECORD +56 -0
- pytmcstepper-0.15.0.dist-info/WHEEL +5 -0
- pytmcstepper-0.15.0.dist-info/licenses/LICENSE +683 -0
- pytmcstepper-0.15.0.dist-info/top_level.txt +1 -0
- tmc_driver/__init__.py +96 -0
- tmc_driver/_tmc_exceptions.py +21 -0
- tmc_driver/_tmc_math.py +122 -0
- tmc_driver/_tmc_stallguard.py +340 -0
- tmc_driver/_tmc_stepperdriver.py +210 -0
- tmc_driver/_tmc_validation.py +29 -0
- tmc_driver/_tmc_xxxx.py +489 -0
- tmc_driver/com/__init__.py +64 -0
- tmc_driver/com/_tmc_com.py +148 -0
- tmc_driver/com/_tmc_com_spi.py +81 -0
- tmc_driver/com/_tmc_com_spi_base.py +159 -0
- tmc_driver/com/_tmc_com_spi_ftdi.py +48 -0
- tmc_driver/com/_tmc_com_spi_micropython.py +99 -0
- tmc_driver/com/_tmc_com_uart.py +113 -0
- tmc_driver/com/_tmc_com_uart_base.py +386 -0
- tmc_driver/com/_tmc_com_uart_micropython.py +115 -0
- tmc_driver/enable_control/__init__.py +55 -0
- tmc_driver/enable_control/_tmc_ec.py +59 -0
- tmc_driver/enable_control/_tmc_ec_pin.py +48 -0
- tmc_driver/enable_control/_tmc_ec_toff.py +30 -0
- tmc_driver/motion_control/__init__.py +111 -0
- tmc_driver/motion_control/_tmc_mc.py +280 -0
- tmc_driver/motion_control/_tmc_mc_int_ramp_generator.py +218 -0
- tmc_driver/motion_control/_tmc_mc_step_dir.py +415 -0
- tmc_driver/motion_control/_tmc_mc_step_pwm_dir.py +78 -0
- tmc_driver/motion_control/_tmc_mc_step_reg.py +36 -0
- tmc_driver/motion_control/_tmc_mc_vactual.py +221 -0
- tmc_driver/platform_utils.py +13 -0
- tmc_driver/reg/__init__.py +0 -0
- tmc_driver/reg/_tmc2209_reg.py +55 -0
- tmc_driver/reg/_tmc220x_reg.py +261 -0
- tmc_driver/reg/_tmc224x_reg.py +414 -0
- tmc_driver/reg/_tmc5160_reg.py +526 -0
- tmc_driver/reg/_tmc_reg.py +202 -0
- tmc_driver/reg/_tmc_shared_regs.py +314 -0
- tmc_driver/tmc_2208.py +17 -0
- tmc_driver/tmc_2209.py +75 -0
- tmc_driver/tmc_220x.py +383 -0
- tmc_driver/tmc_2240.py +340 -0
- tmc_driver/tmc_5160.py +344 -0
- tmc_driver/tmc_gpio/__init__.py +101 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_base.py +106 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_ftdi.py +162 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_gpiozero.py +135 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_micropython.py +108 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_periphery.py +87 -0
- tmc_driver/tmc_gpio/_tmc_gpio_board_rpi_gpio.py +182 -0
- tmc_driver/tmc_logger/__init__.py +15 -0
- tmc_driver/tmc_logger/_tmc_logger_base.py +111 -0
- tmc_driver/tmc_logger/_tmc_logger_cpython.py +155 -0
- tmc_driver/tmc_logger/_tmc_logger_micropython.py +52 -0
|
@@ -0,0 +1,526 @@
|
|
|
1
|
+
# pylint: disable=too-many-instance-attributes
|
|
2
|
+
"""
|
|
3
|
+
Register module
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
import math
|
|
7
|
+
from ._tmc_reg import TmcRegField
|
|
8
|
+
from . import _tmc_shared_regs as shared
|
|
9
|
+
from .._tmc_exceptions import TmcDriverException
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class GConf(shared.GConf):
|
|
13
|
+
"""GCONF register class"""
|
|
14
|
+
|
|
15
|
+
ADDR = 0x0
|
|
16
|
+
|
|
17
|
+
direct_mode: bool
|
|
18
|
+
stop_enable: bool
|
|
19
|
+
small_hysteresis: bool
|
|
20
|
+
diag1_pushpull: bool
|
|
21
|
+
diag0_pushpull: bool
|
|
22
|
+
diag1_steps_skipped: bool
|
|
23
|
+
diag1_onstate: bool
|
|
24
|
+
diag1_index: bool
|
|
25
|
+
diag1_stall: bool
|
|
26
|
+
diag0_stall: bool
|
|
27
|
+
diag0_otpw: bool
|
|
28
|
+
diag0_error: bool
|
|
29
|
+
shaft: bool
|
|
30
|
+
multistep_filt: bool
|
|
31
|
+
en_pwm_mode: bool
|
|
32
|
+
fast_standstill: bool
|
|
33
|
+
recalibrate: bool
|
|
34
|
+
_REG_MAP = (
|
|
35
|
+
TmcRegField("direct_mode", 16, 0x1, bool, None, ""),
|
|
36
|
+
TmcRegField("stop_enable", 15, 0x1, bool, None, ""),
|
|
37
|
+
TmcRegField("small_hysteresis", 14, 0x1, bool, None, ""),
|
|
38
|
+
TmcRegField("diag1_pushpull", 13, 0x1, bool, None, ""),
|
|
39
|
+
TmcRegField("diag0_pushpull", 12, 0x1, bool, None, ""),
|
|
40
|
+
TmcRegField("diag1_steps_skipped", 11, 0x1, bool, None, ""),
|
|
41
|
+
TmcRegField("diag1_onstate", 10, 0x1, bool, None, ""),
|
|
42
|
+
TmcRegField("diag1_index", 9, 0x1, bool, None, ""),
|
|
43
|
+
TmcRegField("diag1_stall", 8, 0x1, bool, None, ""),
|
|
44
|
+
TmcRegField("diag0_stall", 7, 0x1, bool, None, ""),
|
|
45
|
+
TmcRegField("diag0_otpw", 6, 0x1, bool, None, ""),
|
|
46
|
+
TmcRegField("diag0_error", 5, 0x1, bool, None, ""),
|
|
47
|
+
TmcRegField("shaft", 4, 0x1, bool, None, ""),
|
|
48
|
+
TmcRegField("multistep_filt", 3, 0x1, bool, None, ""),
|
|
49
|
+
TmcRegField("en_pwm_mode", 2, 0x1, bool, None, ""),
|
|
50
|
+
TmcRegField("fast_standstill", 1, 0x1, bool, None, ""),
|
|
51
|
+
TmcRegField("recalibrate", 0, 0x1, bool, None, ""),
|
|
52
|
+
)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
class GStat(shared.GStat):
|
|
56
|
+
"""GSTAT register class"""
|
|
57
|
+
|
|
58
|
+
ADDR = 0x1
|
|
59
|
+
|
|
60
|
+
uv_cp: bool
|
|
61
|
+
drv_err: bool
|
|
62
|
+
reset: bool
|
|
63
|
+
_REG_MAP = (
|
|
64
|
+
TmcRegField("uv_cp", 2, 0x1, bool, None, "", 1),
|
|
65
|
+
TmcRegField("drv_err", 1, 0x1, bool, None, "", 1),
|
|
66
|
+
TmcRegField("reset", 0, 0x1, bool, None, "", 1),
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
def check(self):
|
|
70
|
+
"""check if the driver is ok"""
|
|
71
|
+
self.read()
|
|
72
|
+
if self.uv_cp:
|
|
73
|
+
raise TmcDriverException("TMC224X: Charge Pump undervoltage detected")
|
|
74
|
+
if self.drv_err:
|
|
75
|
+
raise TmcDriverException("TMC224X: driver error detected")
|
|
76
|
+
if self.reset:
|
|
77
|
+
raise TmcDriverException("TMC224X: reset detected")
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class IfCnt(shared.IfCnt):
|
|
81
|
+
"""IFCNT register class"""
|
|
82
|
+
|
|
83
|
+
ADDR = 0x2
|
|
84
|
+
|
|
85
|
+
ifcnt: int
|
|
86
|
+
_REG_MAP = (TmcRegField("ifcnt", 0, 0xFF, int, None, ""),)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class Ioin(shared.Ioin):
|
|
90
|
+
"""IOIN register class"""
|
|
91
|
+
|
|
92
|
+
ADDR = 0x4
|
|
93
|
+
DRIVER_NAME = "TMC5160"
|
|
94
|
+
|
|
95
|
+
version: int
|
|
96
|
+
sw_comp_in: bool
|
|
97
|
+
sd_mode: bool
|
|
98
|
+
encn: bool
|
|
99
|
+
enn: bool
|
|
100
|
+
enca: bool
|
|
101
|
+
encb: bool
|
|
102
|
+
dir: bool
|
|
103
|
+
step: bool
|
|
104
|
+
_REG_MAP = (
|
|
105
|
+
TmcRegField("version", 24, 0xFF, int, None, ""),
|
|
106
|
+
TmcRegField("sw_comp_in", 7, 0x1, bool, None, ""),
|
|
107
|
+
TmcRegField("sd_mode", 6, 0x1, bool, None, ""),
|
|
108
|
+
TmcRegField("encn", 5, 0x1, bool, None, ""),
|
|
109
|
+
TmcRegField("enn", 4, 0x1, bool, None, ""),
|
|
110
|
+
TmcRegField("enca", 3, 0x1, bool, None, ""),
|
|
111
|
+
TmcRegField("encb", 2, 0x1, bool, None, ""),
|
|
112
|
+
TmcRegField("dir", 1, 0x1, bool, None, ""),
|
|
113
|
+
TmcRegField("step", 0, 0x1, bool, None, ""),
|
|
114
|
+
)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
class DrvConf(shared.DrvConf):
|
|
118
|
+
"""DRV_CONF register class"""
|
|
119
|
+
|
|
120
|
+
ADDR = 0xA
|
|
121
|
+
|
|
122
|
+
filt_isense: int
|
|
123
|
+
drvstrength: int
|
|
124
|
+
otselect: int
|
|
125
|
+
bbmclks: int
|
|
126
|
+
bbmtime: int
|
|
127
|
+
_REG_MAP = (
|
|
128
|
+
TmcRegField("filt_isense", 20, 0x3, int, None, ""),
|
|
129
|
+
TmcRegField("drvstrength", 18, 0x3, int, None, ""),
|
|
130
|
+
TmcRegField("otselect", 16, 0x3, int, None, ""),
|
|
131
|
+
TmcRegField("bbmclks", 8, 0xF, int, None, ""),
|
|
132
|
+
TmcRegField("bbmtime", 0, 0x1F, int, None, ""),
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
class GlobalScaler(shared.GlobalScaler):
|
|
137
|
+
"""GLOBAL_SCALER register class"""
|
|
138
|
+
|
|
139
|
+
ADDR = 0xB
|
|
140
|
+
|
|
141
|
+
global_scaler: int
|
|
142
|
+
_REG_MAP = (TmcRegField("global_scaler", 0, 0xFF, int, None, ""),)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class IHoldIRun(shared.IHoldIRun):
|
|
146
|
+
"""IHOLD_IRUN register class"""
|
|
147
|
+
|
|
148
|
+
ADDR = 0x10
|
|
149
|
+
|
|
150
|
+
iholddelay: int
|
|
151
|
+
irun: int
|
|
152
|
+
ihold: int
|
|
153
|
+
_REG_MAP = (
|
|
154
|
+
TmcRegField("iholddelay", 16, 0xF, int, None, ""),
|
|
155
|
+
TmcRegField("irun", 8, 0x1F, int, None, ""),
|
|
156
|
+
TmcRegField("ihold", 0, 0x1F, int, None, ""),
|
|
157
|
+
)
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
class TPowerDown(shared.TPowerDown):
|
|
161
|
+
"""TPOWERDOWN register class"""
|
|
162
|
+
|
|
163
|
+
ADDR = 0x11
|
|
164
|
+
|
|
165
|
+
tpowerdown: int
|
|
166
|
+
_REG_MAP = (TmcRegField("tpowerdown", 0, 0xFF, int, None, ""),)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class TStep(shared.TStep):
|
|
170
|
+
"""TSTEP register class"""
|
|
171
|
+
|
|
172
|
+
ADDR = 0x12
|
|
173
|
+
|
|
174
|
+
tstep: int
|
|
175
|
+
_REG_MAP = (TmcRegField("tstep", 0, 0xFFFFF, int, None, ""),)
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
class TPwmThrs(shared.TPwmThrs):
|
|
179
|
+
"""TCOOLTHRS register class"""
|
|
180
|
+
|
|
181
|
+
ADDR = 0x13
|
|
182
|
+
|
|
183
|
+
tpwmthrs: int
|
|
184
|
+
_REG_MAP = (TmcRegField("tpwmthrs", 0, 0xFFFFF, int, None, ""),)
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
class TCoolThrs(shared.TCoolThrs):
|
|
188
|
+
"""TCOOLTHRS register class"""
|
|
189
|
+
|
|
190
|
+
ADDR = 0x14
|
|
191
|
+
|
|
192
|
+
tcoolthrs: int
|
|
193
|
+
_REG_MAP = (TmcRegField("tcoolthrs", 0, 0xFFFFF, int, None, ""),)
|
|
194
|
+
|
|
195
|
+
|
|
196
|
+
class THigh(shared.THigh):
|
|
197
|
+
"""THIGH register class"""
|
|
198
|
+
|
|
199
|
+
ADDR = 0x15
|
|
200
|
+
|
|
201
|
+
thigh: int
|
|
202
|
+
_REG_MAP = (TmcRegField("thigh", 0, 0xFFFFF, int, None, ""),)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
class VDcMin(shared.VDcMin):
|
|
206
|
+
"""VDCMIN register class"""
|
|
207
|
+
|
|
208
|
+
ADDR = 0x33
|
|
209
|
+
|
|
210
|
+
vdcmin: int
|
|
211
|
+
_REG_MAP = (TmcRegField("vdcmin", 0, 0xFFFFF, int, None, ""),)
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
class RampMode(shared.RampMode):
|
|
215
|
+
"""RAMPMODE register class"""
|
|
216
|
+
|
|
217
|
+
ADDR = 0x20
|
|
218
|
+
|
|
219
|
+
rampmode: int
|
|
220
|
+
_REG_MAP = (TmcRegField("rampmode", 0, 0xFFFFF, int, None, ""),)
|
|
221
|
+
|
|
222
|
+
|
|
223
|
+
class XActual(shared.XActual):
|
|
224
|
+
"""XACTUAL register class - Actual motor position (signed)"""
|
|
225
|
+
|
|
226
|
+
ADDR = 0x21
|
|
227
|
+
|
|
228
|
+
xactual: int
|
|
229
|
+
_REG_MAP = (TmcRegField("xactual", 0, 0xFFFFFFFF, int, None, "", signed=True),)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
class VActual(shared.VActual):
|
|
233
|
+
"""VACTUAL register class - Actual motor velocity (signed)"""
|
|
234
|
+
|
|
235
|
+
ADDR = 0x22
|
|
236
|
+
|
|
237
|
+
vactual: int
|
|
238
|
+
_REG_MAP = (TmcRegField("vactual", 0, 0xFFFFFF, int, None, "", signed=True),)
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
class VStart(shared.VStart):
|
|
242
|
+
"""VSTART register class"""
|
|
243
|
+
|
|
244
|
+
ADDR = 0x23
|
|
245
|
+
|
|
246
|
+
vstart: int
|
|
247
|
+
_REG_MAP = (TmcRegField("vstart", 0, 0xFFFFF, int, None, ""),)
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
class A1(shared.A1):
|
|
251
|
+
"""A1 register class"""
|
|
252
|
+
|
|
253
|
+
ADDR = 0x24
|
|
254
|
+
|
|
255
|
+
a1: int
|
|
256
|
+
_REG_MAP = (TmcRegField("a1", 0, 0xFFFFF, int, None, ""),)
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
class V1(shared.V1):
|
|
260
|
+
"""V1 register class"""
|
|
261
|
+
|
|
262
|
+
ADDR = 0x25
|
|
263
|
+
|
|
264
|
+
v1: int
|
|
265
|
+
_REG_MAP = (TmcRegField("v1", 0, 0xFFFFF, int, None, ""),)
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
class AMax(shared.AMax):
|
|
269
|
+
"""AMAX register class"""
|
|
270
|
+
|
|
271
|
+
ADDR = 0x26
|
|
272
|
+
|
|
273
|
+
amax: int
|
|
274
|
+
_REG_MAP = (TmcRegField("amax", 0, 0xFFFFF, int, None, ""),)
|
|
275
|
+
|
|
276
|
+
|
|
277
|
+
class VMax(shared.VMax):
|
|
278
|
+
"""VMAX register class"""
|
|
279
|
+
|
|
280
|
+
ADDR = 0x27
|
|
281
|
+
|
|
282
|
+
vmax: int
|
|
283
|
+
_REG_MAP = (TmcRegField("vmax", 0, 0xFFFFF, int, None, ""),)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
class DMax(shared.DMax):
|
|
287
|
+
"""DMAX register class"""
|
|
288
|
+
|
|
289
|
+
ADDR = 0x28
|
|
290
|
+
|
|
291
|
+
dmax: int
|
|
292
|
+
_REG_MAP = (TmcRegField("dmax", 0, 0xFFFFF, int, None, ""),)
|
|
293
|
+
|
|
294
|
+
|
|
295
|
+
class D1(shared.D1):
|
|
296
|
+
"""D1 register class"""
|
|
297
|
+
|
|
298
|
+
ADDR = 0x2A
|
|
299
|
+
|
|
300
|
+
d1: int
|
|
301
|
+
_REG_MAP = (TmcRegField("d1", 0, 0xFFFFF, int, None, ""),)
|
|
302
|
+
|
|
303
|
+
|
|
304
|
+
class VStop(shared.VStop):
|
|
305
|
+
"""VSTOP register class"""
|
|
306
|
+
|
|
307
|
+
ADDR = 0x2B
|
|
308
|
+
|
|
309
|
+
vstop: int
|
|
310
|
+
_REG_MAP = (TmcRegField("vstop", 0, 0xFFFFF, int, None, ""),)
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+
class TZeroWait(shared.TZeroWait):
|
|
314
|
+
"""TZEROWAIT register class"""
|
|
315
|
+
|
|
316
|
+
ADDR = 0x2C
|
|
317
|
+
|
|
318
|
+
tzerowait: int
|
|
319
|
+
_REG_MAP = (TmcRegField("tzerowait", 0, 0xFFFFF, int, None, ""),)
|
|
320
|
+
|
|
321
|
+
|
|
322
|
+
class XTarget(shared.XTarget):
|
|
323
|
+
"""XTARGET register class - Target position for ramp mode (signed)"""
|
|
324
|
+
|
|
325
|
+
ADDR = 0x2D
|
|
326
|
+
|
|
327
|
+
xtarget: int
|
|
328
|
+
_REG_MAP = (TmcRegField("xtarget", 0, 0xFFFFFFFF, int, None, "", signed=True),)
|
|
329
|
+
|
|
330
|
+
|
|
331
|
+
class SWMode(shared.SWMode):
|
|
332
|
+
"""SW_MODE register class"""
|
|
333
|
+
|
|
334
|
+
ADDR = 0x34
|
|
335
|
+
|
|
336
|
+
en_softstop: bool
|
|
337
|
+
sg_stop: bool
|
|
338
|
+
en_latch_encoder: bool
|
|
339
|
+
latch_r_inactive: bool
|
|
340
|
+
latch_r_active: bool
|
|
341
|
+
latch_l_inactive: bool
|
|
342
|
+
latch_l_active: bool
|
|
343
|
+
swap_lr: bool
|
|
344
|
+
pol_stop_r: bool
|
|
345
|
+
pol_stop_l: bool
|
|
346
|
+
stop_r_enable: bool
|
|
347
|
+
stop_l_enable: bool
|
|
348
|
+
_REG_MAP = (
|
|
349
|
+
TmcRegField("en_softstop", 11, 0x1, bool, None, ""),
|
|
350
|
+
TmcRegField("sg_stop", 10, 0x1, bool, None, ""),
|
|
351
|
+
TmcRegField("en_latch_encoder", 9, 0x1, bool, None, ""),
|
|
352
|
+
TmcRegField("latch_r_inactive", 8, 0x1, bool, None, ""),
|
|
353
|
+
TmcRegField("latch_r_active", 7, 0x1, bool, None, ""),
|
|
354
|
+
TmcRegField("latch_l_inactive", 6, 0x1, bool, None, ""),
|
|
355
|
+
TmcRegField("latch_l_active", 5, 0x1, bool, None, ""),
|
|
356
|
+
TmcRegField("swap_lr", 4, 0x1, bool, None, ""),
|
|
357
|
+
TmcRegField("pol_stop_r", 3, 0x1, bool, None, ""),
|
|
358
|
+
TmcRegField("pol_stop_l", 2, 0x1, bool, None, ""),
|
|
359
|
+
TmcRegField("stop_r_enable", 1, 0x1, bool, None, ""),
|
|
360
|
+
TmcRegField("stop_l_enable", 0, 0x1, bool, None, ""),
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
class RampStat(shared.RampStat):
|
|
365
|
+
"""RAMP_STAT register class"""
|
|
366
|
+
|
|
367
|
+
ADDR = 0x35
|
|
368
|
+
|
|
369
|
+
status_sg: bool
|
|
370
|
+
second_move: bool
|
|
371
|
+
t_zerowait_active: bool
|
|
372
|
+
vzero: bool
|
|
373
|
+
position_reached: bool
|
|
374
|
+
velocity_reached: bool
|
|
375
|
+
event_stop_sg: bool
|
|
376
|
+
event_stop_r: bool
|
|
377
|
+
event_stop_l: bool
|
|
378
|
+
status_latch_r: bool
|
|
379
|
+
status_latch_l: bool
|
|
380
|
+
status_stop_r: bool
|
|
381
|
+
status_stop_l: bool
|
|
382
|
+
_REG_MAP = (
|
|
383
|
+
TmcRegField("status_sg", 13, 0x1, bool, None, ""),
|
|
384
|
+
TmcRegField("second_move", 12, 0x1, bool, None, "", 1),
|
|
385
|
+
TmcRegField("t_zerowait_active", 11, 0x1, bool, None, ""),
|
|
386
|
+
TmcRegField("vzero", 10, 0x1, bool, None, ""),
|
|
387
|
+
TmcRegField("position_reached", 9, 0x1, bool, None, ""),
|
|
388
|
+
TmcRegField("velocity_reached", 8, 0x1, bool, None, ""),
|
|
389
|
+
TmcRegField("event_pos_reached", 7, 0x1, bool, None, "", 1),
|
|
390
|
+
TmcRegField("event_stop_sg", 6, 0x1, bool, None, "", 1),
|
|
391
|
+
TmcRegField("event_stop_r", 5, 0x1, bool, None, ""),
|
|
392
|
+
TmcRegField("event_stop_l", 4, 0x1, bool, None, ""),
|
|
393
|
+
TmcRegField("status_latch_r", 3, 0x1, bool, None, "", 1),
|
|
394
|
+
TmcRegField("status_latch_l", 2, 0x1, bool, None, "", 1),
|
|
395
|
+
TmcRegField("status_stop_r", 1, 0x1, bool, None, ""),
|
|
396
|
+
TmcRegField("status_stop_l", 0, 0x1, bool, None, ""),
|
|
397
|
+
)
|
|
398
|
+
|
|
399
|
+
|
|
400
|
+
class MsCnt(shared.MsCnt):
|
|
401
|
+
"""MSCNT register class"""
|
|
402
|
+
|
|
403
|
+
ADDR = 0x6A
|
|
404
|
+
|
|
405
|
+
mscnt: int
|
|
406
|
+
_REG_MAP = (TmcRegField("mscnt", 0, 0xFF, int, None, ""),)
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
class ChopConf(shared.ChopConf):
|
|
410
|
+
"""CHOPCONF register class"""
|
|
411
|
+
|
|
412
|
+
ADDR = 0x6C
|
|
413
|
+
|
|
414
|
+
diss2vs: bool
|
|
415
|
+
diss2g: bool
|
|
416
|
+
dedge: bool
|
|
417
|
+
intpol: bool
|
|
418
|
+
mres: int
|
|
419
|
+
tpfd: int
|
|
420
|
+
vhighchm: bool
|
|
421
|
+
vhighfs: bool
|
|
422
|
+
tbl: int
|
|
423
|
+
chm: int
|
|
424
|
+
disfdcc: bool
|
|
425
|
+
fd3: bool
|
|
426
|
+
hend_offset: int
|
|
427
|
+
hstrt_tfd210: int
|
|
428
|
+
toff: int
|
|
429
|
+
_REG_MAP = (
|
|
430
|
+
TmcRegField("diss2vs", 31, 0x1, bool, None, ""),
|
|
431
|
+
TmcRegField("diss2g", 30, 0x1, bool, None, ""),
|
|
432
|
+
TmcRegField("dedge", 29, 0x1, bool, None, ""),
|
|
433
|
+
TmcRegField("intpol", 28, 0x1, bool, None, ""),
|
|
434
|
+
TmcRegField("mres", 24, 0xF, int, "mres_ms", "mStep"),
|
|
435
|
+
TmcRegField("tpfd", 20, 0xF, int, None, ""),
|
|
436
|
+
TmcRegField("vhighchm", 19, 0x1, bool, None, ""),
|
|
437
|
+
TmcRegField("vhighfs", 18, 0x1, bool, None, ""),
|
|
438
|
+
TmcRegField("tbl", 15, 0x3, int, None, ""),
|
|
439
|
+
TmcRegField("chm", 14, 0x3, int, None, ""),
|
|
440
|
+
TmcRegField("disfdcc", 12, 0x1, bool, None, ""),
|
|
441
|
+
TmcRegField("fd3", 11, 0x1, bool, None, ""),
|
|
442
|
+
TmcRegField("hend_offset", 7, 0xF, int, None, ""),
|
|
443
|
+
TmcRegField("hstrt_tfd210", 4, 0x7, int, None, ""),
|
|
444
|
+
TmcRegField("toff", 0, 0xF, int, None, ""),
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
@property
|
|
448
|
+
def mres_ms(self) -> int:
|
|
449
|
+
"""return µstep resolution"""
|
|
450
|
+
return int(math.pow(2, 8 - self.mres))
|
|
451
|
+
|
|
452
|
+
@mres_ms.setter
|
|
453
|
+
def mres_ms(self, mres: int):
|
|
454
|
+
"""set µstep resolution"""
|
|
455
|
+
mres_bit = int(math.log2(mres))
|
|
456
|
+
mres_bit = 8 - mres_bit
|
|
457
|
+
self.mres = mres_bit
|
|
458
|
+
|
|
459
|
+
|
|
460
|
+
class CoolConf(shared.CoolConf):
|
|
461
|
+
"""COOLCONF register class"""
|
|
462
|
+
|
|
463
|
+
ADDR = 0x6D
|
|
464
|
+
|
|
465
|
+
sfilt: bool
|
|
466
|
+
sgt: int
|
|
467
|
+
seimin: bool
|
|
468
|
+
sedn: int
|
|
469
|
+
semax: int
|
|
470
|
+
seup: int
|
|
471
|
+
semin: int
|
|
472
|
+
_REG_MAP = (
|
|
473
|
+
TmcRegField("sfilt", 24, 0x1, bool, None, ""),
|
|
474
|
+
TmcRegField("sgt", 16, 0x7F, int, None, "", signed=True),
|
|
475
|
+
TmcRegField("seimin", 15, 0x1, bool, None, ""),
|
|
476
|
+
TmcRegField("sedn", 13, 0x3, int, None, ""),
|
|
477
|
+
TmcRegField("semax", 8, 0xF, int, None, ""),
|
|
478
|
+
TmcRegField("seup", 5, 0x3, int, None, ""),
|
|
479
|
+
TmcRegField("semin", 0, 0xF, int, None, ""),
|
|
480
|
+
)
|
|
481
|
+
|
|
482
|
+
|
|
483
|
+
class DrvStatus(shared.DrvStatus):
|
|
484
|
+
"""DRVSTATUS register class"""
|
|
485
|
+
|
|
486
|
+
ADDR = 0x6F
|
|
487
|
+
|
|
488
|
+
stst: bool
|
|
489
|
+
olb: bool
|
|
490
|
+
ola: bool
|
|
491
|
+
s2gb: bool
|
|
492
|
+
s2ga: bool
|
|
493
|
+
otpw: bool
|
|
494
|
+
ot: bool
|
|
495
|
+
stallguard: bool
|
|
496
|
+
cs_actual: int
|
|
497
|
+
fsactive: bool
|
|
498
|
+
stealth: bool
|
|
499
|
+
s2vsb: bool
|
|
500
|
+
s2vsa: bool
|
|
501
|
+
sgresult: int
|
|
502
|
+
_REG_MAP = (
|
|
503
|
+
TmcRegField("stst", 31, 0x1, bool, None, ""),
|
|
504
|
+
TmcRegField("olb", 30, 0x1, bool, None, ""),
|
|
505
|
+
TmcRegField("ola", 29, 0x1, bool, None, ""),
|
|
506
|
+
TmcRegField("s2gb", 28, 0x1, bool, None, ""),
|
|
507
|
+
TmcRegField("s2ga", 27, 0x1, bool, None, ""),
|
|
508
|
+
TmcRegField("otpw", 26, 0x1, bool, None, ""),
|
|
509
|
+
TmcRegField("ot", 25, 0x1, bool, None, ""),
|
|
510
|
+
TmcRegField("stallguard", 24, 0x1, bool, None, ""),
|
|
511
|
+
TmcRegField("cs_actual", 16, 0x1F, int, None, ""),
|
|
512
|
+
TmcRegField("fsactive", 15, 0x1, bool, None, ""),
|
|
513
|
+
TmcRegField("stealth", 14, 0x1, bool, None, ""),
|
|
514
|
+
TmcRegField("s2vsb", 13, 0x1, bool, None, ""),
|
|
515
|
+
TmcRegField("s2vsa", 12, 0x1, bool, None, ""),
|
|
516
|
+
TmcRegField("sgresult", 0, 0x3FF, int, None, ""),
|
|
517
|
+
)
|
|
518
|
+
|
|
519
|
+
|
|
520
|
+
class LostSteps(shared.LostSteps):
|
|
521
|
+
"""LOST_STEPS register class"""
|
|
522
|
+
|
|
523
|
+
ADDR = 0x73
|
|
524
|
+
|
|
525
|
+
lost_steps: int
|
|
526
|
+
_REG_MAP = (TmcRegField("lost_steps", 0, 0xFFFFF, int, None, ""),)
|