From 4df78cd84399d6f475b207302110226ae07129c5 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Tue, 25 Jun 2019 12:01:47 -0400 Subject: [PATCH] tmc: Configure "intpol" field from TMCMicrostepHelper Signed-off-by: Kevin O'Connor --- klippy/extras/tmc.py | 6 +++--- klippy/extras/tmc2130.py | 1 - klippy/extras/tmc2208.py | 1 - klippy/extras/tmc2209.py | 1 - klippy/extras/tmc2660.py | 7 +++---- klippy/extras/tmc5160.py | 1 - test/klippy/tmc.test | 2 +- 7 files changed, 7 insertions(+), 12 deletions(-) diff --git a/klippy/extras/tmc.py b/klippy/extras/tmc.py index 5b606e26..8afc972b 100644 --- a/klippy/extras/tmc.py +++ b/klippy/extras/tmc.py @@ -48,10 +48,9 @@ class FieldHelper: new_value = (reg_value & ~mask) | ((field_value << ffs(mask)) & mask) self.registers[reg_name] = new_value return new_value - def set_config_field(self, config, field_name, default, config_name=None): + def set_config_field(self, config, field_name, default): # Allow a field to be set from the config file - if config_name is None: - config_name = "driver_" + field_name.upper() + config_name = "driver_" + field_name.upper() reg_name = self.field_to_register[field_name] mask = self.all_fields[reg_name][field_name] maxval = mask >> ffs(mask) @@ -248,6 +247,7 @@ class TMCMicrostepHelper: '8': 5, '4': 6, '2': 7, '1': 8} mres = config.getchoice('microsteps', steps) self.fields.set_field("MRES", mres) + self.fields.set_field("intpol", config.getboolean("interpolate", True)) def get_microsteps(self): return 256 >> self.fields.get_field("MRES") def get_phase(self): diff --git a/klippy/extras/tmc2130.py b/klippy/extras/tmc2130.py index aa31f90b..e6a27a43 100644 --- a/klippy/extras/tmc2130.py +++ b/klippy/extras/tmc2130.py @@ -226,7 +226,6 @@ class TMC2130: set_config_field(config, "hstrt", 0) set_config_field(config, "hend", 7) set_config_field(config, "TBL", 1) - set_config_field(config, "intpol", True, "interpolate") set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "TPOWERDOWN", 0) set_config_field(config, "PWM_AMPL", 128) diff --git a/klippy/extras/tmc2208.py b/klippy/extras/tmc2208.py index 6b004fb1..93a4aee9 100644 --- a/klippy/extras/tmc2208.py +++ b/klippy/extras/tmc2208.py @@ -207,7 +207,6 @@ class TMC2208: set_config_field(config, "hstrt", 5) set_config_field(config, "hend", 0) set_config_field(config, "TBL", 2) - set_config_field(config, "intpol", True, "interpolate") set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "TPOWERDOWN", 20) set_config_field(config, "PWM_OFS", 36) diff --git a/klippy/extras/tmc2209.py b/klippy/extras/tmc2209.py index 02ff3c7e..45072446 100644 --- a/klippy/extras/tmc2209.py +++ b/klippy/extras/tmc2209.py @@ -79,7 +79,6 @@ class TMC2209: set_config_field(config, "hstrt", 5) set_config_field(config, "hend", 0) set_config_field(config, "TBL", 2) - set_config_field(config, "intpol", True, "interpolate") set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "TPOWERDOWN", 20) set_config_field(config, "PWM_OFS", 36) diff --git a/klippy/extras/tmc2660.py b/klippy/extras/tmc2660.py index e1dd7531..056ccfe1 100644 --- a/klippy/extras/tmc2660.py +++ b/klippy/extras/tmc2660.py @@ -19,7 +19,7 @@ Fields = {} Fields["DRVCTRL"] = { "MRES": 0x0f, "DEDGE": 0x01 << 8, - "INTPOL": 0x01 << 9, + "intpol": 0x01 << 9, } Fields["CHOPCONF"] = { @@ -100,7 +100,7 @@ FieldFormatters = { "MRES": (lambda v: "%d(%dusteps)" % (v, 0x100 >> v)), "DEDGE": (lambda v: "1(Both Edges Active)" if v else "0(Only Rising Edge active)"), - "INTPOL": (lambda v: "1(On)" if v else "0(Off)"), + "intpol": (lambda v: "1(On)" if v else "0(Off)"), "toff": (lambda v: ("%d" % v) if v else "0(Driver Disabled!)"), "CHM": (lambda v: "1(constant toff)" if v else "0(spreadCycle)"), "SFILT": (lambda v: "1(Filtered mode)" if v else "0(Standard mode)"), @@ -252,9 +252,8 @@ class TMC2660: mh = tmc.TMCMicrostepHelper(config, self.mcu_tmc) self.get_microsteps = mh.get_microsteps self.get_phase = mh.get_phase - set_config_field = self.fields.set_config_field - set_config_field(config, "INTPOL", True, 'interpolate') # CHOPCONF + set_config_field = self.fields.set_config_field set_config_field(config, "TBL", 2) set_config_field(config, "RNDTF", 0) set_config_field(config, "HDEC", 0) diff --git a/klippy/extras/tmc5160.py b/klippy/extras/tmc5160.py index 48158e2a..9102f4b8 100644 --- a/klippy/extras/tmc5160.py +++ b/klippy/extras/tmc5160.py @@ -314,7 +314,6 @@ class TMC5160: set_config_field(config, "vhighfs", 0) set_config_field(config, "vhighchm", 0) set_config_field(config, "tpfd", 4) - set_config_field(config, "intpol", True, "interpolate") set_config_field(config, "diss2g", 0) set_config_field(config, "diss2vs", 0) # COOLCONF diff --git a/test/klippy/tmc.test b/test/klippy/tmc.test index 79a42685..44053463 100644 --- a/test/klippy/tmc.test +++ b/test/klippy/tmc.test @@ -42,4 +42,4 @@ SET_TMC_FIELD STEPPER=stepper_x1 FIELD=intpol VALUE=0 SET_TMC_FIELD STEPPER=stepper_y FIELD=intpol VALUE=0 SET_TMC_FIELD STEPPER=stepper_y1 FIELD=intpol VALUE=0 SET_TMC_FIELD STEPPER=stepper_z FIELD=intpol VALUE=0 -SET_TMC_FIELD STEPPER=stepper_z1 FIELD=INTPOL VALUE=0 +SET_TMC_FIELD STEPPER=stepper_z1 FIELD=intpol VALUE=0