tmc: Implement high_velocity_threshold for drivers that support it
Signed-off-by: Alex Voinea <voinea.dragos.alexandru@gmail.com>
This commit is contained in:
committed by
KevinOConnor
parent
5249d955bb
commit
ed8dca8df0
@@ -632,3 +632,20 @@ def TMCVcoolthrsHelper(config, mcu_tmc):
|
||||
tcoolthrs = TMCtstepHelper(step_dist, mres,
|
||||
mcu_tmc.get_tmc_frequency(), velocity)
|
||||
fields.set_field("tcoolthrs", tcoolthrs)
|
||||
|
||||
# Helper to configure StallGuard and CoolStep maximum velocity and
|
||||
# SpreadCycle-FullStepping (High velocity) mode threshold.
|
||||
def TMCVhighHelper(config, mcu_tmc):
|
||||
fields = mcu_tmc.get_fields()
|
||||
velocity = config.getfloat('high_velocity_threshold', None, minval=0.)
|
||||
thigh = 0
|
||||
|
||||
if velocity is not None:
|
||||
stepper_name = " ".join(config.get_name().split()[1:])
|
||||
sconfig = config.getsection(stepper_name)
|
||||
rotation_dist, steps_per_rotation = stepper.parse_step_distance(sconfig)
|
||||
step_dist = rotation_dist / steps_per_rotation
|
||||
mres = fields.get_field("mres")
|
||||
thigh = TMCtstepHelper(step_dist, mres,
|
||||
mcu_tmc.get_tmc_frequency(), velocity)
|
||||
fields.set_field("thigh", thigh)
|
||||
|
||||
@@ -298,6 +298,7 @@ class TMC2130:
|
||||
tmc.TMCWaveTableHelper(config, self.mcu_tmc)
|
||||
tmc.TMCStealthchopHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVcoolthrsHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVhighHelper(config, self.mcu_tmc)
|
||||
# Allow other registers to be set from the config
|
||||
set_config_field = self.fields.set_config_field
|
||||
# CHOPCONF
|
||||
|
||||
@@ -366,6 +366,7 @@ class TMC2240:
|
||||
self.fields.set_config_field(config, "offset_sin90", 0)
|
||||
tmc.TMCStealthchopHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVcoolthrsHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVhighHelper(config, self.mcu_tmc)
|
||||
# Allow other registers to be set from the config
|
||||
set_config_field = self.fields.set_config_field
|
||||
# GCONF
|
||||
|
||||
@@ -242,6 +242,9 @@ Fields["TCOOLTHRS"] = {
|
||||
Fields["TSTEP"] = {
|
||||
"tstep": 0xfffff << 0
|
||||
}
|
||||
Fields["THIGH"] = {
|
||||
"thigh": 0xfffff << 0
|
||||
}
|
||||
|
||||
SignedFields = ["cur_a", "cur_b", "sgt", "xactual", "vactual", "pwm_scale_auto"]
|
||||
|
||||
@@ -337,6 +340,7 @@ class TMC5160:
|
||||
tmc.TMCWaveTableHelper(config, self.mcu_tmc)
|
||||
tmc.TMCStealthchopHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVcoolthrsHelper(config, self.mcu_tmc)
|
||||
tmc.TMCVhighHelper(config, self.mcu_tmc)
|
||||
# Allow other registers to be set from the config
|
||||
set_config_field = self.fields.set_config_field
|
||||
# GCONF
|
||||
|
||||
Reference in New Issue
Block a user