mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-19 23:22:16 +03:00
Don't trip the WDT if interrupts are disabled during write() or flush().
Prior to this change, if interrupts were disabled during a call to HardwareSerial::write() when the circular buffer was full, or HardwareSerial::flush() when the circular buffer was non-empty, we would loop forever and trip a watchdog timeout.
This commit is contained in:
parent
c8772cfcd0
commit
4ef0466578
@ -636,6 +636,9 @@ void HardwareSerial::flush() {
|
||||
if(_tx_buffer->getSize() == 0 &&
|
||||
UART_GET_TX_FIFO_ROOM(uart_nr) >= UART_TX_FIFO_SIZE) {
|
||||
break;
|
||||
} else if(il.savedInterruptLevel() > 0) {
|
||||
_tx_empty_irq();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
yield();
|
||||
@ -663,6 +666,9 @@ size_t HardwareSerial::write(uint8_t c) {
|
||||
break;
|
||||
} else if(_tx_buffer->write(c)) {
|
||||
break;
|
||||
} else if(il.savedInterruptLevel() > 0) {
|
||||
_tx_empty_irq();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
yield();
|
||||
|
@ -31,6 +31,10 @@ public:
|
||||
xt_wsr_ps(_state);
|
||||
}
|
||||
|
||||
uint32_t savedInterruptLevel() const {
|
||||
return _state & 0x0f;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t _state;
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user