diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-06-01 12:43:58 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-06-02 17:52:05 -0400 |
commit | d68cb264c421be687c53066df91c7ffb661ab2d9 (patch) | |
tree | 51b1f0a6c8cc4826ef9e724468a6821922ba5f8c /src | |
parent | 45ba03efa3596dc12989ddc47cdd3c242a1869f2 (diff) | |
download | kutter-d68cb264c421be687c53066df91c7ffb661ab2d9.tar.gz kutter-d68cb264c421be687c53066df91c7ffb661ab2d9.tar.xz kutter-d68cb264c421be687c53066df91c7ffb661ab2d9.zip |
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 <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/stepper.c | 19 |
1 files 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); |