Skip to content

Commit 39dbd49

Browse files
faxe1008kartben
authored andcommitted
drivers: stepper: step_dir: Fix actual position increment
Address issue where the timing source is not stopped upon step completion and not adjusting the actual position after performing a step. Signed-off-by: Fabian Blatz <[email protected]>
1 parent 9e6366a commit 39dbd49

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

drivers/stepper/step_dir/step_dir_stepper_common.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ static inline int step_dir_stepper_perform_step(const struct device *dev)
4444
}
4545
}
4646

47+
if (data->direction == STEPPER_DIRECTION_POSITIVE) {
48+
data->actual_position++;
49+
} else {
50+
data->actual_position--;
51+
}
52+
4753
return 0;
4854
}
4955

@@ -105,12 +111,15 @@ static void stepper_work_event_handler(struct k_work *work)
105111

106112
static void update_remaining_steps(struct step_dir_stepper_common_data *data)
107113
{
114+
const struct step_dir_stepper_common_config *config = data->dev->config;
115+
108116
if (data->step_count > 0) {
109117
data->step_count--;
110118
} else if (data->step_count < 0) {
111119
data->step_count++;
112120
} else {
113121
stepper_trigger_callback(data->dev, STEPPER_EVENT_STEPS_COMPLETED);
122+
config->timing_source->stop(data->dev);
114123
}
115124
}
116125

0 commit comments

Comments
 (0)