From d184d9fd9179c8823d67cba1be9a9fae80c70e8c Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 15 Mar 2021 00:19:57 -0400 Subject: [PATCH] tmc: Move clear_gstat check for tmc2130 to within TMCErrorCheck class Signed-off-by: Kevin O'Connor --- klippy/extras/tmc.py | 12 +++++++----- klippy/extras/tmc2130.py | 3 +-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index 8ac22ae7..04170afc 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -81,14 +81,14 @@ class FieldHelper: ###################################################################### class TMCErrorCheck: - def __init__(self, config, mcu_tmc, clear_gstat=True): + def __init__(self, config, mcu_tmc): self.printer = config.get_printer() - self.stepper_name = ' '.join(config.get_name().split()[1:]) + name_parts = config.get_name().split() + self.stepper_name = ' '.join(name_parts[1:]) self.mcu_tmc = mcu_tmc self.fields = mcu_tmc.get_fields() self.check_timer = None # Setup for GSTAT query - self.clear_gstat = clear_gstat reg_name = self.fields.lookup_register("drv_err") if reg_name is not None: self.gstat_reg_info = [0, reg_name, 0xffffffff, 0xffffffff] @@ -105,6 +105,8 @@ class TMCErrorCheck: if f in err_fields: err_mask |= self.fields.all_fields[reg_name][f] self.drv_status_reg_info = [0, reg_name, mask, err_mask] + # Driver quirks + self.clear_gstat = (name_parts[0] != 'tmc2130') def _query_register(self, reg_info, try_clear=False): last_value, reg_name, mask, err_mask = reg_info count = 0 @@ -162,13 +164,13 @@ class TMCErrorCheck: ###################################################################### class TMCCommandHelper: - def __init__(self, config, mcu_tmc, current_helper, clear_gstat=True): + def __init__(self, config, mcu_tmc, current_helper): self.printer = config.get_printer() self.stepper_name = ' '.join(config.get_name().split()[1:]) self.name = config.get_name().split()[-1] self.mcu_tmc = mcu_tmc self.current_helper = current_helper - self.echeck_helper = TMCErrorCheck(config, mcu_tmc, clear_gstat) + self.echeck_helper = TMCErrorCheck(config, mcu_tmc) self.fields = mcu_tmc.get_fields() self.read_registers = self.read_translate = None self.toff = None diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index bb57aea3..e789301a 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -257,8 +257,7 @@ class TMC2130: tmc.TMCVirtualPinHelper(config, self.mcu_tmc) # Register commands current_helper = TMCCurrentHelper(config, self.mcu_tmc) - cmdhelper = tmc.TMCCommandHelper(config, self.mcu_tmc, current_helper, - clear_gstat=False) + cmdhelper = tmc.TMCCommandHelper(config, self.mcu_tmc, current_helper) cmdhelper.setup_register_dump(ReadRegisters) # Setup basic register values mh = tmc.TMCMicrostepHelper(config, self.mcu_tmc)