Skip to content

Commit c7b5cc7

Browse files
author
Owen
authored
Merge pull request #139 from sparkfun/decrease_RX_ISR_Overhead
Increase performance of UART RX.
2 parents 78e70c3 + 863328c commit c7b5cc7

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

cores/arduino/ard_sup/ap3_uart.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ SOFTWARE.
3030
#include "RingBuffer.h"
3131

3232
#ifndef AP3_UART_RINGBUFF_SIZE
33-
#define AP3_UART_RINGBUFF_SIZE 256
33+
#define AP3_UART_RINGBUFF_SIZE 256 * 16
3434
#endif
3535

3636
#ifndef AP3_UART_LINBUFF_SIZE
37-
#define AP3_UART_LINBUFF_SIZE 256
37+
#define AP3_UART_LINBUFF_SIZE 256 * 16
3838
#endif
3939

4040
typedef RingBufferN<AP3_UART_RINGBUFF_SIZE> AP3UartRingBuffer;
@@ -78,7 +78,7 @@ class Uart : public HardwareSerial
7878
operator bool() { return true; } // todo: wait for a serial terminal to be open... probably depends on RTS or CTS...
7979

8080
private:
81-
public: //temporary
81+
public: //temporary
8282
AP3UartRingBuffer _rx_buffer; // These buffers guarantee the lifespan of the data to transmit
8383
AP3UartRingBuffer _tx_buffer; // to allow for asynchronous tranfsers
8484

cores/arduino/ard_sup/uart/ap3_uart.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -543,19 +543,16 @@ inline void Uart::uart_isr(void)
543543
{
544544
.ui32Direction = AM_HAL_UART_READ,
545545
.pui8Data = (uint8_t *)&rx_c,
546-
.ui32NumBytes = 1,
546+
.ui32NumBytes = sizeof(rx_c),
547547
.ui32TimeoutMs = 0,
548548
.pui32BytesTransferred = &ui32BytesRead,
549549
};
550550

551-
do
551+
am_hal_uart_transfer(_handle, &sRead);
552+
if (ui32BytesRead)
552553
{
553-
am_hal_uart_transfer(_handle, &sRead);
554-
if (ui32BytesRead)
555-
{
556-
_rx_buffer.store_char(rx_c);
557-
}
558-
} while (ui32BytesRead);
554+
_rx_buffer.store_char(rx_c);
555+
}
559556
}
560557
}
561558

0 commit comments

Comments
 (0)