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 @@ -218,9 +218,12 @@ void UARTClass::IrqHandler( void )
218218 // if irq is Transmitter Holding Register
219219 else if (uart_irq_tx_ready (CONFIG_UART_CONSOLE_INDEX))
220220 {
221- if (_tx_buffer->_iTail != _tx_buffer->_iHead ) {
222- uart_poll_out (CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer [_tx_buffer->_iTail ]);
223- _tx_buffer->_iTail = (unsigned int )(_tx_buffer->_iTail + 1 ) % SERIAL_BUFFER_SIZE;
221+ if (_tx_buffer->_iTail != _tx_buffer->_iHead )
222+ {
223+ int end = (_tx_buffer->_iTail < _tx_buffer->_iHead ) ? _tx_buffer->_iHead :SERIAL_BUFFER_SIZE;
224+ int l = min (end - _tx_buffer->_iTail , UART_FIFO_SIZE);
225+ uart_fifo_fill (CONFIG_UART_CONSOLE_INDEX, _tx_buffer->_aucBuffer +_tx_buffer->_iTail , l);
226+ _tx_buffer->_iTail = (_tx_buffer->_iTail +l)%SERIAL_BUFFER_SIZE;
224227 }
225228 else
226229 {
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