File tree Expand file tree Collapse file tree 3 files changed +13
-5
lines changed
system/libarc32_arduino101/drivers Expand file tree Collapse file tree 3 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -217,9 +217,12 @@ void UARTClass::IrqHandler( void )
217217 // if irq is Transmitter Holding Register
218218 else if (uart_irq_tx_ready (CONFIG_UART_CONSOLE_INDEX))
219219 {
220- if (_tx_buffer->_iTail != _tx_buffer->_iHead ) {
221- uart_poll_out (CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer [_tx_buffer->_iTail ]);
222- _tx_buffer->_iTail = (unsigned int )(_tx_buffer->_iTail + 1 ) % UART_BUFFER_SIZE;
220+ if (_tx_buffer->_iTail != _tx_buffer->_iHead )
221+ {
222+ int end = (_tx_buffer->_iTail < _tx_buffer->_iHead ) ? _tx_buffer->_iHead :SERIAL_BUFFER_SIZE;
223+ int l = min (end - _tx_buffer->_iTail , UART_FIFO_SIZE);
224+ uart_fifo_fill (CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer +_tx_buffer->_iTail , l);
225+ _tx_buffer->_iTail = (_tx_buffer->_iTail +l)%UART_BUFFER_SIZE;
223226 }
224227 else
225228 {
Original file line number Diff line number Diff line change @@ -352,6 +352,8 @@ unsigned char uart_poll_out(
352352*
353353* uart_fifo_fill - fill FIFO with data
354354*
355+ * It is up to the caller to make sure that FIFO capcity is not exceeded
356+ *
355357* RETURNS: number of bytes sent
356358*/
357359
@@ -362,8 +364,8 @@ int uart_fifo_fill(int which, /* UART on which to send */
362364{
363365 int i ;
364366
365- for (i = 0 ; i < size && ( INBYTE ( LSR ( which )) &
366- LSR_BOTH_EMPTY ) != 0 ; i ++ ) {
367+ for (i = 0 ; i < size ; i ++ )
368+ {
367369 OUTBYTE (THR (which ), txData [i ]);
368370 }
369371 return i ;
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ extern "C" {
5454/* options for uart init */
5555#define UART_OPTION_AFCE 0x01
5656
57+ /* Size of the FIFO in bytes */
58+ #define UART_FIFO_SIZE 16
59+
5760/* generic UART info structure */
5861struct uart_init_info {
5962 int baud_rate ;
You can’t perform that action at this time.
0 commit comments