From f06b013179d1a946b71d33376a5f0e8ea25a1a0b Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 2 Sep 2012 19:24:15 +0200 Subject: [PATCH] clock.c: introduce clock(). This simplifies calls to clock_10ms() a bit and saves 18 bytes binary size. --- clock.c | 13 ++++++++++++- clock.h | 1 + dda_queue.c | 7 ++----- gcode_process.c | 4 +--- mendel.c | 4 +--- 5 files changed, 17 insertions(+), 12 deletions(-) diff --git a/clock.c b/clock.c index 26c9641..495af6e 100644 --- a/clock.c +++ b/clock.c @@ -65,7 +65,7 @@ void clock_250ms() { /*! do stuff every 10 milliseconds - call from ifclock(CLOCK_FLAG_10MS) in busy loops + called from clock(), do not call directly */ void clock_10ms() { // reset watchdog @@ -78,3 +78,14 @@ void clock_10ms() { } } +/*! do reoccuring stuff + + call it occasionally in busy loops +*/ +void clock() { + ifclock(clock_flag_10ms) { + clock_10ms(); + } +} + + diff --git a/clock.h b/clock.h index daf4023..b2dd456 100644 --- a/clock.h +++ b/clock.h @@ -3,5 +3,6 @@ void clock_250ms(void); void clock_10ms(void); +void clock(void); #endif /* _CLOCK_H */ diff --git a/dda_queue.c b/dda_queue.c index 784b54f..889012a 100644 --- a/dda_queue.c +++ b/dda_queue.c @@ -198,9 +198,6 @@ void queue_flush() { /// wait for queue to empty void queue_wait() { - for (;queue_empty() == 0;) { - ifclock(clock_flag_10ms) { - clock_10ms(); - } - } + while (queue_empty() == 0) + clock(); } diff --git a/gcode_process.c b/gcode_process.c index b6e70ea..be5fd6c 100644 --- a/gcode_process.c +++ b/gcode_process.c @@ -155,9 +155,7 @@ void process_gcode_command() { // delay if (next_target.seen_P) { for (;next_target.P > 0;next_target.P--) { - ifclock(clock_flag_10ms) { - clock_10ms(); - } + clock(); delay_ms(1); } } diff --git a/mendel.c b/mendel.c index fdc034e..5997b0b 100644 --- a/mendel.c +++ b/mendel.c @@ -323,8 +323,6 @@ int main (void) gcode_parse_char(c); } - ifclock(clock_flag_10ms) { - clock_10ms(); - } + clock(); } }