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:
parent
1433c517cf
commit
2bc42669e8
@ -54,6 +54,11 @@ int HardwareSerial::read(void)
|
||||
return serialRead();
|
||||
}
|
||||
|
||||
void HardwareSerial::flush()
|
||||
{
|
||||
serialFlush();
|
||||
}
|
||||
|
||||
void HardwareSerial::print(char c)
|
||||
{
|
||||
printByte(c);
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user