mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Remove tracking of whether write() was called.
Tracking _written was required on AVR devices to work around a hardware limitation when implementing flush(). The ESP8266 doesn't have the same issue, so we can remove the tracking and make write() more lightweight. The cost is a minor increase in work done in flush() when write() was not previously called, but this should be much rarer than individual character writes.
This commit is contained in:
parent
2375fb0f86
commit
bc9493e690
@ -485,7 +485,7 @@ int uart_get_debug() {
|
||||
// ####################################################################################################
|
||||
|
||||
HardwareSerial::HardwareSerial(int uart_nr) :
|
||||
_uart_nr(uart_nr), _uart(0), _tx_buffer(0), _rx_buffer(0), _written(false) {
|
||||
_uart_nr(uart_nr), _uart(0), _tx_buffer(0), _rx_buffer(0) {
|
||||
}
|
||||
|
||||
void HardwareSerial::begin(unsigned long baud, byte config, byte mode) {
|
||||
@ -519,7 +519,6 @@ void HardwareSerial::begin(unsigned long baud, byte config, byte mode) {
|
||||
_uart->txEnabled = false;
|
||||
}
|
||||
}
|
||||
_written = false;
|
||||
delay(1);
|
||||
|
||||
uart_finish_init(_uart);
|
||||
@ -626,8 +625,6 @@ void HardwareSerial::flush() {
|
||||
return;
|
||||
if(!_uart->txEnabled)
|
||||
return;
|
||||
if(!_written)
|
||||
return;
|
||||
|
||||
const int uart_nr = _uart->uart_nr;
|
||||
while(true) {
|
||||
@ -643,13 +640,11 @@ void HardwareSerial::flush() {
|
||||
}
|
||||
yield();
|
||||
}
|
||||
_written = false;
|
||||
}
|
||||
|
||||
size_t HardwareSerial::write(uint8_t c) {
|
||||
if(_uart == 0 || !_uart->txEnabled)
|
||||
return 0;
|
||||
_written = true;
|
||||
|
||||
bool tx_now = false;
|
||||
const int uart_nr = _uart->uart_nr;
|
||||
|
@ -117,7 +117,6 @@ class HardwareSerial: public Stream {
|
||||
uart_t* _uart;
|
||||
cbuf* _tx_buffer;
|
||||
cbuf* _rx_buffer;
|
||||
bool _written;
|
||||
};
|
||||
|
||||
extern HardwareSerial Serial;
|
||||
|
Loading…
x
Reference in New Issue
Block a user