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 )
217
217
// if irq is Transmitter Holding Register
218
218
else if (uart_irq_tx_ready (CONFIG_UART_CONSOLE_INDEX))
219
219
{
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;
223
226
}
224
227
else
225
228
{
Original file line number Diff line number Diff line change @@ -352,6 +352,8 @@ unsigned char uart_poll_out(
352
352
*
353
353
* uart_fifo_fill - fill FIFO with data
354
354
*
355
+ * It is up to the caller to make sure that FIFO capcity is not exceeded
356
+ *
355
357
* RETURNS: number of bytes sent
356
358
*/
357
359
@@ -362,8 +364,8 @@ int uart_fifo_fill(int which, /* UART on which to send */
362
364
{
363
365
int i ;
364
366
365
- for (i = 0 ; i < size && ( INBYTE ( LSR ( which )) &
366
- LSR_BOTH_EMPTY ) != 0 ; i ++ ) {
367
+ for (i = 0 ; i < size ; i ++ )
368
+ {
367
369
OUTBYTE (THR (which ), txData [i ]);
368
370
}
369
371
return i ;
Original file line number Diff line number Diff line change @@ -54,6 +54,9 @@ extern "C" {
54
54
/* options for uart init */
55
55
#define UART_OPTION_AFCE 0x01
56
56
57
+ /* Size of the FIFO in bytes */
58
+ #define UART_FIFO_SIZE 16
59
+
57
60
/* generic UART info structure */
58
61
struct uart_init_info {
59
62
int baud_rate ;
You can’t perform that action at this time.
0 commit comments