add flush queue for emergency stop

This commit is contained in:
Michael Moon 2010-10-18 18:43:03 +11:00
parent 6169dadae7
commit d0c3744f92
3 changed files with 19 additions and 0 deletions

View File

@ -106,3 +106,18 @@ void print_queue() {
serial_writechar('E'); serial_writechar('E');
serial_writechar('\n'); serial_writechar('\n');
} }
void queue_flush() {
// save interrupt flag
uint8_t sreg = SREG;
// disable interrupts
cli();
// flush queue
mb_tail = mb_head;
movebuffer[mb_head].live = 0;
// restore interrupt flag
SREG = sreg;
}

View File

@ -33,4 +33,7 @@ void next_move(void) __attribute__ ((hot));
// print queue status // print queue status
void print_queue(void); void print_queue(void);
// flush the queue for eg; emergency stop
void queue_flush(void);
#endif /* _DDA_QUEUE */ #endif /* _DDA_QUEUE */

View File

@ -249,6 +249,7 @@ void process_gcode_command() {
// M112- immediate stop // M112- immediate stop
case 112: case 112:
disableTimerInterrupt(); disableTimerInterrupt();
queue_flush();
power_off(); power_off();
break; break;
// M113- extruder PWM // M113- extruder PWM