Make XON/XOFF flow control compile.
This commit is contained in:
parent
548b79f3d6
commit
b2e1cfd8b5
17
dda_queue.c
17
dda_queue.c
|
|
@ -3,6 +3,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
|
|
||||||
|
#include "machine.h" // for XONXOFF
|
||||||
#include "timer.h"
|
#include "timer.h"
|
||||||
#include "serial.h"
|
#include "serial.h"
|
||||||
#include "sermsg.h"
|
#include "sermsg.h"
|
||||||
|
|
@ -70,9 +71,9 @@ void enqueue(TARGET *t) {
|
||||||
mb_head = h;
|
mb_head = h;
|
||||||
|
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
// if queue is full, stop transmition
|
// if queue is full, stop transmission
|
||||||
if (queue_full())
|
if (queue_full())
|
||||||
xoff();
|
xoff();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fire up in case we're not running yet
|
// fire up in case we're not running yet
|
||||||
|
|
@ -104,9 +105,9 @@ void enqueue_temp_wait() {
|
||||||
mb_head = h;
|
mb_head = h;
|
||||||
|
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
// if queue is full, stop transmition
|
// if queue is full, stop transmission
|
||||||
if (queue_full())
|
if (queue_full())
|
||||||
xoff();
|
xoff();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// fire up in case we're not running yet
|
// fire up in case we're not running yet
|
||||||
|
|
@ -126,8 +127,8 @@ void next_move() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
// restart transmission
|
// restart transmission
|
||||||
xon();
|
xon();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
gcode.c
4
gcode.c
|
|
@ -414,7 +414,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
|
||||||
// G4 - Dwell
|
// G4 - Dwell
|
||||||
case 4:
|
case 4:
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
xoff();
|
xoff();
|
||||||
#endif
|
#endif
|
||||||
// wait for all moves to complete
|
// wait for all moves to complete
|
||||||
for (;queue_empty() == 0;)
|
for (;queue_empty() == 0;)
|
||||||
|
|
@ -422,7 +422,7 @@ void process_gcode_command(GCODE_COMMAND *gcmd) {
|
||||||
// delay
|
// delay
|
||||||
delay_ms(gcmd->P);
|
delay_ms(gcmd->P);
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
xon();
|
xon();
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -60,7 +60,9 @@
|
||||||
// this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts
|
// this should help immensely with dropped serial characters, but may also make debugging infuriating due to the complexities arising from nested interrupts
|
||||||
#define STEP_INTERRUPT_INTERRUPTIBLE 1
|
#define STEP_INTERRUPT_INTERRUPTIBLE 1
|
||||||
|
|
||||||
// Xon/Xoff flow control. Should be redundant
|
// Xon/Xoff flow control. Redundant when using RepRap Host for sending GCode,
|
||||||
|
// but mandatory when sending GCode files with a plain terminal emulator,
|
||||||
|
// like GtkTerm (Linux), CoolTerm (Mac) or HyperTerminal (Windows).
|
||||||
// #define XONXOFF
|
// #define XONXOFF
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
47
serial.c
47
serial.c
|
|
@ -45,11 +45,14 @@ volatile uint8_t txbuf[BUFSIZE];
|
||||||
data = buf[tail++]; tail &= (BUFSIZE - 1);
|
data = buf[tail++]; tail &= (BUFSIZE - 1);
|
||||||
*/
|
*/
|
||||||
|
|
||||||
volatile uint8_t flowflags = 0;
|
#ifdef XONXOFF
|
||||||
#define FLOWFLAG_SEND_XOFF 1
|
#define FLOWFLAG_SEND_XON 1
|
||||||
#define FLOWFLAG_SEND_XON 2
|
#define FLOWFLAG_SEND_XOFF 2
|
||||||
#define FLOWFLAG_SENT_XOFF 4
|
#define FLOWFLAG_SENT_XON 4
|
||||||
#define FLOWFLAG_SENT_XON 8
|
#define FLOWFLAG_SENT_XOFF 8
|
||||||
|
// initially, send an XON
|
||||||
|
volatile uint8_t flowflags = FLOWFLAG_SEND_XON;
|
||||||
|
#endif
|
||||||
|
|
||||||
void serial_init()
|
void serial_init()
|
||||||
{
|
{
|
||||||
|
|
@ -82,15 +85,15 @@ ISR(USART_RX_vect)
|
||||||
|
|
||||||
ISR(USART_UDRE_vect)
|
ISR(USART_UDRE_vect)
|
||||||
{
|
{
|
||||||
#if XONXOFF
|
#ifdef XONXOFF
|
||||||
if (flowflags & FLOWFLAG_SEND_XOFF) {
|
if (flowflags & FLOWFLAG_SEND_XON) {
|
||||||
UDR0 = ASCII_XOFF;
|
|
||||||
flowflags = (flowflags & ~FLOWFLAG_SEND_XOFF) | FLOWFLAG_SENT_XOFF;
|
|
||||||
}
|
|
||||||
else if (flowflags & FLOWFLAG_SEND_XON) {
|
|
||||||
UDR0 = ASCII_XON;
|
UDR0 = ASCII_XON;
|
||||||
flowflags = (flowflags & ~FLOWFLAG_SEND_XON) | FLOWFLAG_SENT_XON;
|
flowflags = (flowflags & ~FLOWFLAG_SEND_XON) | FLOWFLAG_SENT_XON;
|
||||||
}
|
}
|
||||||
|
else if (flowflags & FLOWFLAG_SEND_XOFF) {
|
||||||
|
UDR0 = ASCII_XOFF;
|
||||||
|
flowflags = (flowflags & ~FLOWFLAG_SEND_XOFF) | FLOWFLAG_SENT_XOFF;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
if (buf_canread(tx))
|
if (buf_canread(tx))
|
||||||
|
|
@ -189,16 +192,16 @@ void serial_writestr_P(PGM_P data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
void xon() {
|
void xon() {
|
||||||
if (flowflags & FLOWFLAG_SENT_XOFF)
|
if (flowflags & FLOWFLAG_SENT_XOFF)
|
||||||
flowflags = FLOWFLAG_SEND_XON;
|
flowflags = FLOWFLAG_SEND_XON;
|
||||||
// enable TX interrupt so we can send this character
|
// enable TX interrupt so we can send this character
|
||||||
UCSR0B |= MASK(UDRIE0);
|
UCSR0B |= MASK(UDRIE0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void xoff() {
|
void xoff() {
|
||||||
flowflags = FLOWFLAG_SEND_XOFF;
|
flowflags = FLOWFLAG_SEND_XOFF;
|
||||||
// enable TX interrupt so we can send this character
|
// enable TX interrupt so we can send this character
|
||||||
UCSR0B |= MASK(UDRIE0);
|
UCSR0B |= MASK(UDRIE0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
8
serial.h
8
serial.h
|
|
@ -5,6 +5,8 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
|
#include "machine.h" // for XONXOFF
|
||||||
|
|
||||||
// initialise serial subsystem
|
// initialise serial subsystem
|
||||||
void serial_init(void);
|
void serial_init(void);
|
||||||
|
|
||||||
|
|
@ -28,9 +30,9 @@ void serial_writeblock_P(PGM_P data, int datalen);
|
||||||
void serial_writestr_P(PGM_P data);
|
void serial_writestr_P(PGM_P data);
|
||||||
|
|
||||||
#ifdef XONXOFF
|
#ifdef XONXOFF
|
||||||
// XON/XOFF flow control
|
// XON/XOFF flow control
|
||||||
void xoff(void);
|
void xon(void);
|
||||||
void xon(void);
|
void xoff(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* _SERIAL_H */
|
#endif /* _SERIAL_H */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue