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 <fabianblatz@gmail.com>
This commit is contained in:
Fabian Blatz 2024-12-28 12:17:04 +01:00 committed by Benjamin Cabé
parent 9e6366a01e
commit 39dbd49874

View File

@ -44,6 +44,12 @@ static inline int step_dir_stepper_perform_step(const struct device *dev)
}
}
if (data->direction == STEPPER_DIRECTION_POSITIVE) {
data->actual_position++;
} else {
data->actual_position--;
}
return 0;
}
@ -105,12 +111,15 @@ static void stepper_work_event_handler(struct k_work *work)
static void update_remaining_steps(struct step_dir_stepper_common_data *data)
{
const struct step_dir_stepper_common_config *config = data->dev->config;
if (data->step_count > 0) {
data->step_count--;
} else if (data->step_count < 0) {
data->step_count++;
} else {
stepper_trigger_callback(data->dev, STEPPER_EVENT_STEPS_COMPLETED);
config->timing_source->stop(data->dev);
}
}