1
0
mirror of https://github.com/arduino/Arduino.git synced 2025-01-18 07:52:14 +01:00

Fixing race condition in Serial write (Brian Cook).

This commit is contained in:
David A. Mellis 2011-03-06 11:47:18 -05:00
parent 10ecfa8bea
commit 1bef2990b6

View File

@ -367,7 +367,6 @@ void HardwareSerial::flush()
void HardwareSerial::write(uint8_t c)
{
bool empty = (_tx_buffer->head == _tx_buffer->tail);
int i = (_tx_buffer->head + 1) % SERIAL_BUFFER_SIZE;
// If the output buffer is full, there's nothing for it other than to
@ -378,11 +377,7 @@ void HardwareSerial::write(uint8_t c)
_tx_buffer->buffer[_tx_buffer->head] = c;
_tx_buffer->head = i;
if (empty) {
// The buffer was empty, so enable interrupt on
// USART Data Register empty. The interrupt handler will take it from there
sbi(*_ucsrb, _udrie);
}
}
// Preinstantiate Objects //////////////////////////////////////////////////////