diff --git a/hardware/arduino/esp8266/cores/esp8266/HardwareSerial.cpp b/hardware/arduino/esp8266/cores/esp8266/HardwareSerial.cpp index 1e638b0a7..515b7e270 100644 --- a/hardware/arduino/esp8266/cores/esp8266/HardwareSerial.cpp +++ b/hardware/arduino/esp8266/cores/esp8266/HardwareSerial.cpp @@ -299,9 +299,10 @@ void ICACHE_FLASH_ATTR HardwareSerial::flush() { if (!_written) return; - uart0_flush(_uart); - _tx_buffer->flush(); - _rx_buffer->flush(); + + while (_tx_buffer->getSize() || uart0_get_tx_fifo_room() < UART_TX_FIFO_SIZE) + yield(); + _written = false; }