dda_queue.c/.h: eliminate queue_empty().

This is no longer needed, because mb_tail_dda gives the same
information, just faster. Wanted side effect: better encapsulation.

No stepping performance improvement, but binary size 36 bytes
smaller:

  ATmega sizes               '168   '328(P)   '644(P)     '1280
  Program:  19398 bytes      136%       64%       31%       16%
     Data:   2179 bytes      213%      107%       54%       27%
   EEPROM:     32 bytes        4%        2%        2%        1%
This commit is contained in:
Markus Hitter 2016-11-27 20:23:12 +01:00
parent 2e13d2bc9d
commit 81cffde4e9
3 changed files with 5 additions and 19 deletions

View File

@ -51,17 +51,6 @@ uint8_t queue_full() {
return MB_NEXT(mb_head) == mb_tail; return MB_NEXT(mb_head) == mb_tail;
} }
/// check if the queue is completely empty
uint8_t queue_empty() {
uint8_t result;
ATOMIC_START
result = (mb_tail == mb_head && movebuffer[mb_tail].live == 0);
ATOMIC_END
return result;
}
/// Return the current movement, or NULL, if there's no movement going on. /// Return the current movement, or NULL, if there's no movement going on.
DDA *queue_current_movement() { DDA *queue_current_movement() {
DDA* current; DDA* current;
@ -132,16 +121,13 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
mb_head. Also kick off movements if it's the first movement after a pause. mb_head. Also kick off movements if it's the first movement after a pause.
*/ */
if ( ! new_movebuffer->nullmove) { if ( ! new_movebuffer->nullmove) {
// Remember if the queue was empty before we complete the queueing.
uint8_t isdead = queue_empty();
// make certain all writes to global memory // make certain all writes to global memory
// are flushed before modifying mb_head. // are flushed before modifying mb_head.
MEMORY_BARRIER(); MEMORY_BARRIER();
mb_head = h; mb_head = h;
if (isdead) { if (mb_tail_dda == NULL) {
/** /**
Go to the next move. Go to the next move.
@ -161,7 +147,8 @@ void enqueue_home(TARGET *t, uint8_t endstop_check, uint8_t endstop_stop_cond) {
/// DEBUG - print queue. /// DEBUG - print queue.
/// Qt/hs format, t is tail, h is head, s is F/full, E/empty or neither /// Qt/hs format, t is tail, h is head, s is F/full, E/empty or neither
void print_queue() { void print_queue() {
sersendf_P(PSTR("Queue: %d/%d%c\n"), mb_tail, mb_head, (queue_full()?'F':(queue_empty()?'E':' '))); sersendf_P(PSTR("Queue: %d/%d%c\n"), mb_tail, mb_head,
(queue_full() ? 'F' : (mb_tail_dda ? ' ' : 'E')));
} }
/// dump queue for emergency stop. /// dump queue for emergency stop.
@ -178,6 +165,6 @@ void queue_flush() {
/// wait for queue to empty /// wait for queue to empty
void queue_wait() { void queue_wait() {
while (queue_empty() == 0) while (mb_tail_dda)
clock(); clock();
} }

View File

@ -22,7 +22,6 @@ extern DDA *mb_tail_dda;
// queue status methods // queue status methods
uint8_t queue_full(void); uint8_t queue_full(void);
uint8_t queue_empty(void);
DDA *queue_current_movement(void); DDA *queue_current_movement(void);
// take one step // take one step

View File

@ -101,7 +101,7 @@ uint8_t serial_rxchars(void) {
if (gcode_fd) return 1; if (gcode_fd) return 1;
// No more gcode data; wait for DDA queue to drain // No more gcode data; wait for DDA queue to drain
if (queue_empty()) { if (mb_tail_dda == NULL) {
sim_info("Gcode processing completed."); sim_info("Gcode processing completed.");
exit(0); exit(0);
} }