Skip to content

Commit f8db03e

Browse files
committed
- Saving same bytes in HardwareSerial::write
1 parent ed331a8 commit f8db03e

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

hardware/arduino/avr/cores/arduino/HardwareSerial.cpp

+1-3
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,14 @@ void HardwareSerial::flush()
213213

214214
size_t HardwareSerial::write(uint8_t c)
215215
{
216+
_written = true;
216217
// If the buffer and the data register is empty, just write the byte
217218
// to the data register and be done. This shortcut helps
218219
// significantly improve the effective datarate at high (>
219220
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
220221
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
221222
*_udr = c;
222223
sbi(*_ucsra, TXC0);
223-
_written = true;
224224
return 1;
225225
}
226226
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
@@ -244,10 +244,8 @@ size_t HardwareSerial::write(uint8_t c)
244244
_tx_buffer_head = i;
245245

246246
sbi(*_ucsrb, UDRIE0);
247-
_written = true;
248247

249248
return 1;
250249
}
251250

252-
253251
#endif // whole file

0 commit comments

Comments
 (0)