From 98192d710f6379b28c8320bdc33ceaf6a524c2fd Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Mon, 25 May 2020 00:32:12 -0400 Subject: [PATCH] stepper: Make toggling the step gpio after timer read conditional On the Linux mcu, toggling the pin after the time is read is not valid. Make that optimization dependent on CONFIG_HAVE_STRICT_TIMING. Signed-off-by: Kevin O'Connor --- src/stepper.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/stepper.c b/src/stepper.c index 2e93ccb9..e8dedaf9 100644 --- a/src/stepper.c +++ b/src/stepper.c @@ -154,9 +154,13 @@ stepper_event(struct timer *t) return stepper_event_nodelay(s); // Normal step code - schedule the unstep event + if (!CONFIG_HAVE_STRICT_TIMING) + gpio_out_toggle_noirq(s->step_pin); uint32_t step_delay = timer_from_us(CONFIG_STEP_DELAY); uint32_t min_next_time = timer_read_time() + step_delay; - gpio_out_toggle_noirq(s->step_pin); + if (CONFIG_HAVE_STRICT_TIMING) + // Toggling gpio after reading the time is a micro-optimization + gpio_out_toggle_noirq(s->step_pin); s->count--; if (likely(s->count & 1)) // Schedule unstep event