From d68cb264c421be687c53066df91c7ffb661ab2d9 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Wed, 1 Jun 2016 12:43:58 -0400 Subject: [PATCH] stepper: Use stepper_stop() instead of stepper_reset() in stepper_shutdown() The stepper_stop() function is equivalent to stepper_reset() during a shutdown event. Signed-off-by: Kevin O'Connor --- src/stepper.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/src/stepper.c b/src/stepper.c index 4679bf70..6ce847f1 100644 --- a/src/stepper.c +++ b/src/stepper.c @@ -164,23 +164,17 @@ stepper_get_position(struct stepper *s) return position; } -// Reset the internal state of a 'struct stepper' -static void -stepper_reset(struct stepper *s) -{ - s->position = stepper_get_position(s); - s->count = 0; - s->flags &= SF_INVERT_STEP; - gpio_out_write(s->dir_pin, 0); -} - // Stop all moves for a given stepper (used in end stop homing). IRQs // must be off. void stepper_stop(struct stepper *s) { sched_del_timer(&s->time); - stepper_reset(s); + s->position = stepper_get_position(s); + s->count = 0; + s->flags &= SF_INVERT_STEP; + gpio_out_write(s->dir_pin, 0); + gpio_out_write(s->step_pin, s->flags & SF_INVERT_STEP ? 1 : 0); while (s->first) { struct move *next = s->first->next; move_free(s->first); @@ -194,9 +188,8 @@ stepper_shutdown(void) uint8_t i; struct stepper *s; foreach_oid(i, s, command_config_stepper) { - stepper_reset(s); s->first = NULL; - gpio_out_write(s->step_pin, s->flags & SF_INVERT_STEP ? 1 : 0); + stepper_stop(s); } } DECL_SHUTDOWN(stepper_shutdown);