Permalink
Browse files

Fixing race condition in Serial write (Brian Cook).

  • Loading branch information...
1 parent 10ecfa8 commit 1bef2990b68858e52c19a49f03405a3e2964b8e4 @damellis damellis committed Mar 6, 2011
Showing with 1 addition and 6 deletions.
  1. +1 −6 hardware/arduino/cores/arduino/HardwareSerial.cpp
View
7 hardware/arduino/cores/arduino/HardwareSerial.cpp
@@ -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);
- }
+ sbi(*_ucsrb, _udrie);
}
// Preinstantiate Objects //////////////////////////////////////////////////////

0 comments on commit 1bef299

Please sign in to comment.