tmc2240: Adding UART interface support to tmc2240 (#6305)

Signed-off-by:  Christoph Frei <fryakatkop@gmail.com>
This commit is contained in:
FrY Sennberg 2023-09-10 20:41:59 +02:00 committed by GitHub
parent 8f178b892a
commit 2acfa28294
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 4 deletions

View File

@ -3442,7 +3442,7 @@ run_current:
### [tmc2240]
Configure a TMC2240 stepper motor driver via SPI bus. To use this
Configure a TMC2240 stepper motor driver via SPI bus or UART. To use this
feature, define a config section with a "tmc2240" prefix followed by
the name of the corresponding stepper config section (for example,
"[tmc2240 stepper_x]").
@ -3460,6 +3460,9 @@ cs_pin:
#spi_software_miso_pin:
# See the "common SPI settings" section for a description of the
# above parameters.
#uart_pin:
# The pin connected to the TMC2240 DIAG1/SW line. If this parameter
# is provided UART communication is used rather then SPI.
#chain_position:
#chain_length:
# These parameters configure an SPI daisy chain. The two parameters

View File

@ -5,7 +5,7 @@
#
# This file may be distributed under the terms of the GNU GPLv3 license.
import math, logging
from . import bus, tmc, tmc2130
from . import bus, tmc, tmc2130, tmc_uart
TMC_FREQUENCY=12500000.
@ -343,6 +343,12 @@ class TMC2240:
def __init__(self, config):
# Setup mcu communication
self.fields = tmc.FieldHelper(Fields, SignedFields, FieldFormatters)
if config.get("uart_pin", None) is not None:
# use UART for communication
self.mcu_tmc = tmc_uart.MCU_TMC_uart(config, Registers, self.fields,
3, TMC_FREQUENCY)
else:
# Use SPI bus for communication
self.mcu_tmc = tmc2130.MCU_TMC_SPI(config, Registers, self.fields,
TMC_FREQUENCY)
# Allow virtual pins to be created