File tree Expand file tree Collapse file tree 1 file changed +6
-0
lines changed
hardware/arduino/avr/cores/arduino Expand file tree Collapse file tree 1 file changed +6
-0
lines changed Original file line number Diff line number Diff line change @@ -218,8 +218,11 @@ size_t HardwareSerial::write(uint8_t c)
218218 // significantly improve the effective datarate at high (>
219219 // 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
220220 if (_tx_buffer_head == _tx_buffer_tail && bit_is_set (*_ucsra, UDRE0)) {
221+ uint8_t oldSREG = SREG;
222+ cli ();
221223 *_udr = c;
222224 sbi (*_ucsra, TXC0);
225+ SREG = oldSREG;
223226 return 1 ;
224227 }
225228 tx_buffer_index_t i = (_tx_buffer_head + 1 ) % SERIAL_TX_BUFFER_SIZE;
@@ -240,9 +243,12 @@ size_t HardwareSerial::write(uint8_t c)
240243 }
241244
242245 _tx_buffer[_tx_buffer_head] = c;
246+ uint8_t oldSREG = SREG;
247+ cli ();
243248 _tx_buffer_head = i;
244249
245250 sbi (*_ucsrb, UDRIE0);
251+ SREG = oldSREG;
246252
247253 return 1 ;
248254}
You can’t perform that action at this time.
0 commit comments