From 2acfa282942c13c725af6a2cb3ea314edf53406f Mon Sep 17 00:00:00 2001 From: FrY Sennberg Date: Sun, 10 Sep 2023 20:41:59 +0200 Subject: tmc2240: Adding UART interface support to tmc2240 (#6305) Signed-off-by: Christoph Frei --- klippy/extras/tmc2240.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'klippy/extras/tmc2240.py') diff --git a/klippy/extras/tmc2240.py b/klippy/extras/tmc2240.py index 19e62ab7..aef2280f 100644 --- a/klippy/extras/tmc2240.py +++ b/klippy/extras/tmc2240.py @@ -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,8 +343,14 @@ class TMC2240: def __init__(self, config): # Setup mcu communication self.fields = tmc.FieldHelper(Fields, SignedFields, FieldFormatters) - self.mcu_tmc = tmc2130.MCU_TMC_SPI(config, Registers, self.fields, - TMC_FREQUENCY) + 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 tmc.TMCVirtualPinHelper(config, self.mcu_tmc) # Register commands -- cgit v1.2.3-70-g09d2