mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-21 10:26:06 +03:00
Re-enable interrupts before directly enqueuing characters in the UART FIFO.
Not sure why, but this reduces the occurrence rate of an occasional ~3.25 or ~7μs intercharacter delay, which was interfering with use of the UART to generate precise timing pulses (such as driving WS2812 LEDs).
This commit is contained in:
parent
4b90db41fe
commit
e147314f97
@ -627,12 +627,13 @@ size_t HardwareSerial::write(uint8_t c) {
|
|||||||
return 0;
|
return 0;
|
||||||
_written = true;
|
_written = true;
|
||||||
|
|
||||||
|
bool tx_now = false;
|
||||||
while(true) {
|
while(true) {
|
||||||
{
|
{
|
||||||
InterruptLock il;
|
InterruptLock il;
|
||||||
if(_tx_buffer->empty()) {
|
if(_tx_buffer->empty()) {
|
||||||
if(uart_get_tx_fifo_room(_uart) > 0) {
|
if(uart_get_tx_fifo_room(_uart) > 0) {
|
||||||
uart_transmit_char(_uart, c);
|
tx_now = true;
|
||||||
} else {
|
} else {
|
||||||
_tx_buffer->write(c);
|
_tx_buffer->write(c);
|
||||||
uart_arm_tx_interrupt(_uart);
|
uart_arm_tx_interrupt(_uart);
|
||||||
@ -644,6 +645,9 @@ size_t HardwareSerial::write(uint8_t c) {
|
|||||||
}
|
}
|
||||||
yield();
|
yield();
|
||||||
}
|
}
|
||||||
|
if (tx_now) {
|
||||||
|
uart_transmit_char(_uart, c);
|
||||||
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user