From 480cc40618fb02da8d1ff382fff436570b05d8ca Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Tue, 6 Dec 2016 19:08:30 +0100 Subject: [PATCH] DDA, dda_start(): don't pass mb_tail_dda as parameter. Instead, read the global variable directly. The idea is that reading the global variable directly removes the effort to build up a parameter stack, making things faster. Actually, binary size increases by 4 bytes and the slowest step takes 3 clock cycles longer. D'oh. ATmega sizes '168 '328(P) '644(P) '1280 Program: 19274 bytes 135% 63% 31% 15% Data: 2179 bytes 213% 107% 54% 27% EEPROM: 32 bytes 4% 2% 2% 1% short-moves.gcode statistics: LED on occurences: 888. LED on time minimum: 218 clock cycles. LED on time maximum: 398 clock cycles. LED on time average: 249.111 clock cycles. smooth-curves.gcode statistics: LED on occurences: 23648. LED on time minimum: 237 clock cycles. LED on time maximum: 441 clock cycles. LED on time average: 272.222 clock cycles. triangle-odd.gcode statistics: LED on occurences: 1636. LED on time minimum: 237 clock cycles. LED on time maximum: 398 clock cycles. LED on time average: 262.576 clock cycles. --- dda.c | 5 ++--- dda.h | 2 +- dda_queue.c | 4 ++-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/dda.c b/dda.c index 9ca1fe6..15f13e2 100644 --- a/dda.c +++ b/dda.c @@ -482,7 +482,6 @@ void dda_create(DDA *dda, const TARGET *target) { } /*! Start a prepared DDA - \param *dda pointer to entry in dda_queue to start This function actually begins the move described by the passed DDA entry. @@ -492,8 +491,8 @@ void dda_create(DDA *dda, const TARGET *target) { Called both inside and outside of interrupts. */ -void dda_start(DDA *dda) { - // called from interrupt context: keep it simple! +void dda_start() { + DDA *dda = mb_tail_dda; if (DEBUG_DDA && (debug_flags & DEBUG_DDA)) sersendf_P(PSTR("Start: X %lq Y %lq Z %lq F %lu\n"), diff --git a/dda.h b/dda.h index 48edefe..49c7c0b 100644 --- a/dda.h +++ b/dda.h @@ -187,7 +187,7 @@ void dda_new_startpoint(void); void dda_create(DDA *dda, const TARGET *target); // start a created DDA (called from timer interrupt) -void dda_start(DDA *dda); +void dda_start(void); // DDA takes one step (called from timer interrupt) void dda_step(DDA *dda); diff --git a/dda_queue.c b/dda_queue.c index 7f987c5..4db4f12 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -71,7 +71,7 @@ void queue_step() { if (mb_tail != mb_head) { mb_tail = MB_NEXT(mb_tail); mb_tail_dda = &(movebuffer[mb_tail]); - dda_start(mb_tail_dda); + dda_start(); } else { mb_tail_dda = NULL; @@ -123,7 +123,7 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) { timer_reset(); mb_tail = mb_head; // Valid ONLY if the queue was empty before! mb_tail_dda = new_movebuffer; // Dito! - dda_start(mb_tail_dda); + dda_start(); // Compensate for the cli() in timer_set(). sei(); }