Skip to content

Commit cd44435

Browse files
Alpaca233claude
andcommitted
fix(filter-wheel): reset all W/W2 homing-phase flags at HOME entry
A HOME command is dispatched even while a previous home is in progress (process_serial_message does not gate on mcu_cmd_execution_in_progress). Clearing only is_backing_off_W left a stale is_homing_W, so check_homing_w() could run alongside the new back-off phase and read a stale latch — the very failure this branch fixes. Reset is_homing_W(2) and is_preparing_for_homing_W(2) too, so a new home always starts the back_off -> prepare -> check sequence clean. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent d3698d4 commit cd44435

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

firmware/controller/src/commands/stage_commands.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,7 +673,14 @@ void callback_home_or_zero()
673673
tmc4361A_disableVirtualLimitSwitch(&tmc4361[w], -1);
674674
tmc4361A_disableVirtualLimitSwitch(&tmc4361[w], 1);
675675
homing_direction_W = buffer_rx[3];
676+
// Clear every W homing-phase flag so a new HOME starts the
677+
// back_off -> prepare -> check sequence from a clean state, even if
678+
// a prior W home was still in progress (commands are accepted while
679+
// mcu_cmd_execution_in_progress). Otherwise a stale is_homing_W lets
680+
// check_homing_w() run concurrently and read a stale latch.
676681
home_W_found = false;
682+
is_homing_W = false;
683+
is_preparing_for_homing_W = false;
677684
is_backing_off_W = false;
678685
if (homing_direction_W == HOME_NEGATIVE) // use the left limit switch for homing
679686
{
@@ -718,7 +725,11 @@ void callback_home_or_zero()
718725
tmc4361A_disableVirtualLimitSwitch(&tmc4361[w2], -1);
719726
tmc4361A_disableVirtualLimitSwitch(&tmc4361[w2], 1);
720727
homing_direction_W2 = buffer_rx[3];
728+
// Clear every W2 homing-phase flag for a clean state-machine start
729+
// (see the AXIS_W comment above).
721730
home_W2_found = false;
731+
is_homing_W2 = false;
732+
is_preparing_for_homing_W2 = false;
722733
is_backing_off_W2 = false;
723734
if (homing_direction_W2 == HOME_NEGATIVE) // use the left limit switch for homing
724735
{

0 commit comments

Comments
 (0)