Skip to content

Commit 766ac46

Browse files
committed
Fixed flush so that it actually is sure to flush all outstanding data.
1 parent 2c95abf commit 766ac46

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cores/arduino/UARTClass.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,12 @@ void UARTClass::end( void )
7979
// clear any received data
8080
_rx_buffer->_iHead = _rx_buffer->_iTail ;
8181

82-
while (_tx_buffer->_iHead != _tx_buffer->_iTail); //wait for transmit data to be sent
82+
// Wait for any outstanding data to be sent
83+
flush();
8384

8485
// Disable UART interrupt in NVIC
8586
NVIC_DisableIRQ( _dwIrq ) ;
8687

87-
// Wait for any outstanding data to be sent
88-
flush();
89-
9088
pmc_disable_periph_clk( _dwId ) ;
9189
}
9290

@@ -134,6 +132,7 @@ int UARTClass::read( void )
134132

135133
void UARTClass::flush( void )
136134
{
135+
while (_tx_buffer->_iHead != _tx_buffer->_iTail); //wait for transmit data to be sent
137136
// Wait for transmission to complete
138137
while ((_pUart->UART_SR & UART_SR_TXRDY) != UART_SR_TXRDY)
139138
;

0 commit comments

Comments
 (0)