diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2020-05-25 00:32:12 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2020-05-31 14:57:06 -0400 |
commit | 98192d710f6379b28c8320bdc33ceaf6a524c2fd (patch) | |
tree | ab13d91194664b118134e9de24c9f24965617811 | |
parent | 835ec3513d07e0d1aa94c4a66e7763d369510d08 (diff) | |
download | kutter-98192d710f6379b28c8320bdc33ceaf6a524c2fd.tar.gz kutter-98192d710f6379b28c8320bdc33ceaf6a524c2fd.tar.xz kutter-98192d710f6379b28c8320bdc33ceaf6a524c2fd.zip |
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 <kevin@koconnor.net>
-rw-r--r-- | src/stepper.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 |