Serial buffers

This commit is contained in:
Mark Qvist 2020-06-01 13:45:26 +02:00
parent c95547b910
commit 66662866e2
4 changed files with 22 additions and 20 deletions

View file

@ -26,8 +26,8 @@ void serial_init(Serial *serial) {
serial->uart0 = uart0_fd;
serial->uart1 = uart1_fd;
fifo_init(&uart0FIFO, uart0Buf, sizeof(uart0Buf));
fifo_init(&uart1FIFO, uart1Buf, sizeof(uart1Buf));
fifo_init(&uart0FIFO, uart0Buf, CONFIG_UART0_BUFFER_SIZE);
fifo_init(&uart1FIFO, uart1Buf, CONFIG_UART1_BUFFER_SIZE);
}
@ -82,7 +82,7 @@ ISR(USART0_RX_vect) {
LED_COM_ON();
if (!fifo_isfull(&uart0FIFO)) {
char c = uart0_getchar_nowait();
fifo_push(&uart0FIFO, c);
fifo_push_locked(&uart0FIFO, c);
} else {
uart0_getchar_nowait();
}

View file

@ -15,10 +15,10 @@ typedef struct Serial {
} Serial;
FIFOBuffer uart0FIFO;
uint8_t uart0Buf[CONFIG_UART0_BUFFER_SIZE];
uint8_t uart0Buf[CONFIG_UART0_BUFFER_SIZE+1];
FIFOBuffer uart1FIFO;
uint8_t uart1Buf[CONFIG_UART1_BUFFER_SIZE];
uint8_t uart1Buf[CONFIG_UART1_BUFFER_SIZE+1];
void serial_init(Serial *serial);
bool serial_available(uint8_t index);