mirror of https://github.com/Desuuuu/klipper.git
tmc: Configure "intpol" field from TMCMicrostepHelper
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
7947dc3389
commit
4df78cd843
|
@ -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):
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue