-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy path_tmc_com_spi_ftdi.py
More file actions
47 lines (34 loc) · 1.22 KB
/
_tmc_com_spi_ftdi.py
File metadata and controls
47 lines (34 loc) · 1.22 KB
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
# pylint: disable=unused-import
# pylint: disable=too-few-public-methods
"""TmcComSpiFtdi stepper driver spi module."""
from pyftdi.spi import SpiPort
from .._tmc_exceptions import TmcComException, TmcDriverException
from ._tmc_com_spi_base import TmcComSpiBase, TmcLogger
class TmcComSpiFtdi(TmcComSpiBase):
"""TmcComSpiFtdi.
this class is used to communicate with the TMC via SPI via FT232H
USB adapter it can be used to change the settings of the TMC. like
the current or the microsteppingmode
"""
def __init__(self, spi_port: SpiPort):
"""constructor.
Args:
spi_port (SpiPort): pyftdi SpiPort object
"""
super().__init__()
self.spi = spi_port
def init(self):
"""Init - SPI port is already configured via pyftdi."""
def __del__(self):
"""Destructor."""
self.deinit()
def deinit(self):
"""Destructor."""
def _spi_transfer(self, data: list) -> list:
"""Perform SPI transfer using pyftdi.
Args:
data: Data to send
Returns:
Received data
"""
return list(self.spi.exchange(bytes(data), duplex=True))