mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-21 15:54:39 +01:00
Saving some bytes in HardwareSerial::write
This commit is contained in:
parent
f735e10908
commit
cd9d30a8fe
@ -213,6 +213,7 @@ void HardwareSerial::flush()
|
|||||||
|
|
||||||
size_t HardwareSerial::write(uint8_t c)
|
size_t HardwareSerial::write(uint8_t c)
|
||||||
{
|
{
|
||||||
|
_written = true;
|
||||||
// If the buffer and the data register is empty, just write the byte
|
// If the buffer and the data register is empty, just write the byte
|
||||||
// to the data register and be done. This shortcut helps
|
// to the data register and be done. This shortcut helps
|
||||||
// significantly improve the effective datarate at high (>
|
// significantly improve the effective datarate at high (>
|
||||||
@ -220,7 +221,6 @@ size_t HardwareSerial::write(uint8_t c)
|
|||||||
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
|
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set(*_ucsra, UDRE0)) {
|
||||||
*_udr = c;
|
*_udr = c;
|
||||||
sbi(*_ucsra, TXC0);
|
sbi(*_ucsra, TXC0);
|
||||||
_written = true;
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
|
tx_buffer_index_t i = (_tx_buffer_head + 1) % SERIAL_TX_BUFFER_SIZE;
|
||||||
@ -244,10 +244,8 @@ size_t HardwareSerial::write(uint8_t c)
|
|||||||
_tx_buffer_head = i;
|
_tx_buffer_head = i;
|
||||||
|
|
||||||
sbi(*_ucsrb, UDRIE0);
|
sbi(*_ucsrb, UDRIE0);
|
||||||
_written = true;
|
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif // whole file
|
#endif // whole file
|
||||||
|
Loading…
x
Reference in New Issue
Block a user