mirror of
				https://github.com/esp8266/Arduino.git
				synced 2025-11-03 14:33:37 +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:
		@@ -636,6 +636,9 @@ void HardwareSerial::flush() {
 | 
				
			|||||||
            if(_tx_buffer->getSize() == 0 &&
 | 
					            if(_tx_buffer->getSize() == 0 &&
 | 
				
			||||||
               UART_GET_TX_FIFO_ROOM(uart_nr) >= UART_TX_FIFO_SIZE) {
 | 
					               UART_GET_TX_FIFO_ROOM(uart_nr) >= UART_TX_FIFO_SIZE) {
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					            } else if(il.savedInterruptLevel() > 0) {
 | 
				
			||||||
 | 
					                _tx_empty_irq();
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        yield();
 | 
					        yield();
 | 
				
			||||||
@@ -663,6 +666,9 @@ size_t HardwareSerial::write(uint8_t c) {
 | 
				
			|||||||
                break;
 | 
					                break;
 | 
				
			||||||
            } else if(_tx_buffer->write(c)) {
 | 
					            } else if(_tx_buffer->write(c)) {
 | 
				
			||||||
                break;
 | 
					                break;
 | 
				
			||||||
 | 
					            } else if(il.savedInterruptLevel() > 0) {
 | 
				
			||||||
 | 
					                _tx_empty_irq();
 | 
				
			||||||
 | 
					                continue;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        yield();
 | 
					        yield();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -31,6 +31,10 @@ public:
 | 
				
			|||||||
        xt_wsr_ps(_state);
 | 
					        xt_wsr_ps(_state);
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    uint32_t savedInterruptLevel() const {
 | 
				
			||||||
 | 
					        return _state & 0x0f;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
protected:
 | 
					protected:
 | 
				
			||||||
    uint32_t _state;
 | 
					    uint32_t _state;
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user