1
0
mirror of https://github.com/arduino/Arduino.git synced 2024-11-29 10:24:12 +01:00

Adding Serial.flush() command.

This commit is contained in:
David A. Mellis 2006-12-25 18:00:30 +00:00
parent 1433c517cf
commit 2bc42669e8
4 changed files with 17 additions and 0 deletions

View File

@ -54,6 +54,11 @@ int HardwareSerial::read(void)
return serialRead();
}
void HardwareSerial::flush()
{
serialFlush();
}
void HardwareSerial::print(char c)
{
printByte(c);

View File

@ -38,6 +38,7 @@ class HardwareSerial
void begin(long);
uint8_t available(void);
int read(void);
void flush(void);
void print(char);
void print(char[]);
void print(uint8_t);

View File

@ -306,6 +306,16 @@ int serialRead()
}
}
void serialFlush()
{
// don't reverse this or there may be problems if the RX interrupt
// occurs after reading the value of rx_buffer_head but before writing
// the value to rx_buffer_tail; the previous value of rx_buffer_head
// may be written to rx_buffer_tail, making it appear as if the buffer
// were full, not empty.
rx_buffer_head = rx_buffer_tail;
}
#if defined(__AVR_ATmega168__)
SIGNAL(SIG_USART_RECV)
#else

View File

@ -76,6 +76,7 @@ void beginSerial(long);
void serialWrite(unsigned char);
int serialAvailable();
int serialRead();
void serialFlush();
void printMode(int);
void printByte(unsigned char c);
void printNewline();