tmc: Fix order of init during sensorless homing
With commit 53b10d3a
the setup of sensorless homing could occur before
the driver was enabled which would cause the reinitialization of the
driver settings to undo the sensorless homing setup.
Use set_field() when setting the sensorless homing registers so that
it wont conflict with a driver init.
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
36ca639e1f
commit
1b989b81e0
|
@ -347,26 +347,30 @@ class TMCVirtualPinHelper:
|
||||||
reg = self.fields.lookup_register("en_pwm_mode", None)
|
reg = self.fields.lookup_register("en_pwm_mode", None)
|
||||||
if reg is None:
|
if reg is None:
|
||||||
# On "stallguard4" drivers, "stealthchop" must be enabled
|
# On "stallguard4" drivers, "stealthchop" must be enabled
|
||||||
self.mcu_tmc.set_register("TPWMTHRS", 0)
|
tp_val = self.fields.set_field("TPWMTHRS", 0)
|
||||||
|
self.mcu_tmc.set_register("TPWMTHRS", tp_val)
|
||||||
val = self.fields.set_field("en_spreadCycle", 0)
|
val = self.fields.set_field("en_spreadCycle", 0)
|
||||||
else:
|
else:
|
||||||
# On earlier drivers, "stealthchop" must be disabled
|
# On earlier drivers, "stealthchop" must be disabled
|
||||||
self.fields.set_field("en_pwm_mode", 0)
|
self.fields.set_field("en_pwm_mode", 0)
|
||||||
val = self.fields.set_field(self.diag_pin_field, 1)
|
val = self.fields.set_field(self.diag_pin_field, 1)
|
||||||
self.mcu_tmc.set_register("GCONF", val)
|
self.mcu_tmc.set_register("GCONF", val)
|
||||||
self.mcu_tmc.set_register("TCOOLTHRS", 0xfffff)
|
tc_val = self.fields.set_field("TCOOLTHRS", 0xfffff)
|
||||||
|
self.mcu_tmc.set_register("TCOOLTHRS", tc_val)
|
||||||
def handle_homing_move_end(self, endstops):
|
def handle_homing_move_end(self, endstops):
|
||||||
if self.mcu_endstop not in endstops:
|
if self.mcu_endstop not in endstops:
|
||||||
return
|
return
|
||||||
reg = self.fields.lookup_register("en_pwm_mode", None)
|
reg = self.fields.lookup_register("en_pwm_mode", None)
|
||||||
if reg is None:
|
if reg is None:
|
||||||
self.mcu_tmc.set_register("TPWMTHRS", self.pwmthrs)
|
tp_val = self.fields.set_field("TPWMTHRS", self.pwmthrs)
|
||||||
|
self.mcu_tmc.set_register("TPWMTHRS", tp_val)
|
||||||
val = self.fields.set_field("en_spreadCycle", not self.en_pwm)
|
val = self.fields.set_field("en_spreadCycle", not self.en_pwm)
|
||||||
else:
|
else:
|
||||||
self.fields.set_field("en_pwm_mode", self.en_pwm)
|
self.fields.set_field("en_pwm_mode", self.en_pwm)
|
||||||
val = self.fields.set_field(self.diag_pin_field, 0)
|
val = self.fields.set_field(self.diag_pin_field, 0)
|
||||||
self.mcu_tmc.set_register("GCONF", val)
|
self.mcu_tmc.set_register("GCONF", val)
|
||||||
self.mcu_tmc.set_register("TCOOLTHRS", 0)
|
tc_val = self.fields.set_field("TCOOLTHRS", 0)
|
||||||
|
self.mcu_tmc.set_register("TCOOLTHRS", tc_val)
|
||||||
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
|
@ -208,6 +208,9 @@ Fields["TPOWERDOWN"] = {
|
||||||
Fields["TPWMTHRS"] = {
|
Fields["TPWMTHRS"] = {
|
||||||
"TPWMTHRS": 0xfffff << 0
|
"TPWMTHRS": 0xfffff << 0
|
||||||
}
|
}
|
||||||
|
Fields["TCOOLTHRS"] = {
|
||||||
|
"TCOOLTHRS": 0xfffff << 0
|
||||||
|
}
|
||||||
Fields["TSTEP"] = {
|
Fields["TSTEP"] = {
|
||||||
"TSTEP": 0xfffff << 0
|
"TSTEP": 0xfffff << 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue