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:
parent
9e6366a01e
commit
39dbd49874
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user