File tree 1 file changed +6
-0
lines changed
hardware/arduino/avr/cores/arduino
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)
218
218
// significantly improve the effective datarate at high (>
219
219
// 500kbit/s) bitrates, where interrupt overhead becomes a slowdown.
220
220
if (_tx_buffer_head == _tx_buffer_tail && bit_is_set (*_ucsra, UDRE0)) {
221
+ uint8_t oldSREG = SREG;
222
+ cli ();
221
223
*_udr = c;
222
224
sbi (*_ucsra, TXC0);
225
+ SREG = oldSREG;
223
226
return 1 ;
224
227
}
225
228
tx_buffer_index_t i = (_tx_buffer_head + 1 ) % SERIAL_TX_BUFFER_SIZE;
@@ -240,9 +243,12 @@ size_t HardwareSerial::write(uint8_t c)
240
243
}
241
244
242
245
_tx_buffer[_tx_buffer_head] = c;
246
+ uint8_t oldSREG = SREG;
247
+ cli ();
243
248
_tx_buffer_head = i;
244
249
245
250
sbi (*_ucsrb, UDRIE0);
251
+ SREG = oldSREG;
246
252
247
253
return 1 ;
248
254
}
You can’t perform that action at this time.
0 commit comments