tmc: Configure "intpol" field from TMCMicrostepHelper

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
Kevin O'Connor 2019-06-25 12:01:47 -04:00 committed by KevinOConnor
parent 7947dc3389
commit 4df78cd843
7 changed files with 7 additions and 12 deletions

View File

@ -48,10 +48,9 @@ class FieldHelper:
new_value = (reg_value & ~mask) | ((field_value << ffs(mask)) & mask) new_value = (reg_value & ~mask) | ((field_value << ffs(mask)) & mask)
self.registers[reg_name] = new_value self.registers[reg_name] = new_value
return 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 # 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] reg_name = self.field_to_register[field_name]
mask = self.all_fields[reg_name][field_name] mask = self.all_fields[reg_name][field_name]
maxval = mask >> ffs(mask) maxval = mask >> ffs(mask)
@ -248,6 +247,7 @@ class TMCMicrostepHelper:
'8': 5, '4': 6, '2': 7, '1': 8} '8': 5, '4': 6, '2': 7, '1': 8}
mres = config.getchoice('microsteps', steps) mres = config.getchoice('microsteps', steps)
self.fields.set_field("MRES", mres) self.fields.set_field("MRES", mres)
self.fields.set_field("intpol", config.getboolean("interpolate", True))
def get_microsteps(self): def get_microsteps(self):
return 256 >> self.fields.get_field("MRES") return 256 >> self.fields.get_field("MRES")
def get_phase(self): def get_phase(self):

View File

@ -226,7 +226,6 @@ class TMC2130:
set_config_field(config, "hstrt", 0) set_config_field(config, "hstrt", 0)
set_config_field(config, "hend", 7) set_config_field(config, "hend", 7)
set_config_field(config, "TBL", 1) set_config_field(config, "TBL", 1)
set_config_field(config, "intpol", True, "interpolate")
set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "IHOLDDELAY", 8)
set_config_field(config, "TPOWERDOWN", 0) set_config_field(config, "TPOWERDOWN", 0)
set_config_field(config, "PWM_AMPL", 128) set_config_field(config, "PWM_AMPL", 128)

View File

@ -207,7 +207,6 @@ class TMC2208:
set_config_field(config, "hstrt", 5) set_config_field(config, "hstrt", 5)
set_config_field(config, "hend", 0) set_config_field(config, "hend", 0)
set_config_field(config, "TBL", 2) set_config_field(config, "TBL", 2)
set_config_field(config, "intpol", True, "interpolate")
set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "IHOLDDELAY", 8)
set_config_field(config, "TPOWERDOWN", 20) set_config_field(config, "TPOWERDOWN", 20)
set_config_field(config, "PWM_OFS", 36) set_config_field(config, "PWM_OFS", 36)

View File

@ -79,7 +79,6 @@ class TMC2209:
set_config_field(config, "hstrt", 5) set_config_field(config, "hstrt", 5)
set_config_field(config, "hend", 0) set_config_field(config, "hend", 0)
set_config_field(config, "TBL", 2) set_config_field(config, "TBL", 2)
set_config_field(config, "intpol", True, "interpolate")
set_config_field(config, "IHOLDDELAY", 8) set_config_field(config, "IHOLDDELAY", 8)
set_config_field(config, "TPOWERDOWN", 20) set_config_field(config, "TPOWERDOWN", 20)
set_config_field(config, "PWM_OFS", 36) set_config_field(config, "PWM_OFS", 36)

View File

@ -19,7 +19,7 @@ Fields = {}
Fields["DRVCTRL"] = { Fields["DRVCTRL"] = {
"MRES": 0x0f, "MRES": 0x0f,
"DEDGE": 0x01 << 8, "DEDGE": 0x01 << 8,
"INTPOL": 0x01 << 9, "intpol": 0x01 << 9,
} }
Fields["CHOPCONF"] = { Fields["CHOPCONF"] = {
@ -100,7 +100,7 @@ FieldFormatters = {
"MRES": (lambda v: "%d(%dusteps)" % (v, 0x100 >> v)), "MRES": (lambda v: "%d(%dusteps)" % (v, 0x100 >> v)),
"DEDGE": (lambda v: "DEDGE": (lambda v:
"1(Both Edges Active)" if v else "0(Only Rising Edge active)"), "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!)"), "toff": (lambda v: ("%d" % v) if v else "0(Driver Disabled!)"),
"CHM": (lambda v: "1(constant toff)" if v else "0(spreadCycle)"), "CHM": (lambda v: "1(constant toff)" if v else "0(spreadCycle)"),
"SFILT": (lambda v: "1(Filtered mode)" if v else "0(Standard mode)"), "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) mh = tmc.TMCMicrostepHelper(config, self.mcu_tmc)
self.get_microsteps = mh.get_microsteps self.get_microsteps = mh.get_microsteps
self.get_phase = mh.get_phase self.get_phase = mh.get_phase
set_config_field = self.fields.set_config_field
set_config_field(config, "INTPOL", True, 'interpolate')
# CHOPCONF # CHOPCONF
set_config_field = self.fields.set_config_field
set_config_field(config, "TBL", 2) set_config_field(config, "TBL", 2)
set_config_field(config, "RNDTF", 0) set_config_field(config, "RNDTF", 0)
set_config_field(config, "HDEC", 0) set_config_field(config, "HDEC", 0)

View File

@ -314,7 +314,6 @@ class TMC5160:
set_config_field(config, "vhighfs", 0) set_config_field(config, "vhighfs", 0)
set_config_field(config, "vhighchm", 0) set_config_field(config, "vhighchm", 0)
set_config_field(config, "tpfd", 4) set_config_field(config, "tpfd", 4)
set_config_field(config, "intpol", True, "interpolate")
set_config_field(config, "diss2g", 0) set_config_field(config, "diss2g", 0)
set_config_field(config, "diss2vs", 0) set_config_field(config, "diss2vs", 0)
# COOLCONF # COOLCONF

View File

@ -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_y FIELD=intpol VALUE=0
SET_TMC_FIELD STEPPER=stepper_y1 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_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