From 87e0030be8ea17f165e8efb7f474ed682733a906 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Hru=C5=A1ka?= Date: Sun, 20 Aug 2017 20:51:42 +0200 Subject: [PATCH] lowered fifo full threshold, seems the byte drop bug has improved --- user/uart_handler.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/user/uart_handler.c b/user/uart_handler.c index beca884..0ee95c9 100755 --- a/user/uart_handler.c +++ b/user/uart_handler.c @@ -21,7 +21,7 @@ static void uart0_rx_intr_handler(void *para); static void uart_recvTask(os_event_t *events); #define uart_recvTaskPrio 1 -#define uart_recvTaskQueueLen 10 +#define uart_recvTaskQueueLen 15 static os_event_t uart_recvTaskQueue[uart_recvTaskQueueLen]; /** Clear the fifos */ @@ -50,6 +50,8 @@ void ICACHE_FLASH_ATTR UART_Init(void) UART_ResetFifo(UART0); UART_SetWordLength(UART1, EIGHT_BITS); // debug (output only) UART_ResetFifo(UART1); + + // remainder is configured based on user settings in serial.c } /** Configure Rx on UART0 */ @@ -60,8 +62,8 @@ void ICACHE_FLASH_ATTR UART_SetupAsyncReceiver(void) // set handler ETS_UART_INTR_ATTACH((void *)uart0_rx_intr_handler, &(UartDev.rcv_buff)); // the buf will be used as an arg - // fifo threshold config - uint32_t conf = ((100 & UART_RXFIFO_FULL_THRHD) << UART_RXFIFO_FULL_THRHD_S); + // fifo threshold config (max: UART_RXFIFO_FULL_THRHD = 127) + uint32_t conf = ((60) << UART_RXFIFO_FULL_THRHD_S); conf |= ((0x10 & UART_TXFIFO_EMPTY_THRHD) << UART_TXFIFO_EMPTY_THRHD_S); // timeout config conf |= ((0x02 & UART_RX_TOUT_THRHD) << UART_RX_TOUT_THRHD_S); // timeout threshold @@ -104,10 +106,10 @@ void uart_rx_intr_enable(uint8 uart_no) void ICACHE_FLASH_ATTR UART_PollRx(void) { - uint8 fifo_len = UART_GetRxFifoCount(UART0); + uint8 fifo_len = (uint8) UART_GetRxFifoCount(UART0); for (uint8 idx = 0; idx < fifo_len; idx++) { - uint8 d_tmp = READ_PERI_REG(UART_FIFO(UART0)) & 0xFF; + uint8 d_tmp = (uint8) (READ_PERI_REG(UART_FIFO(UART0)) & 0xFF); UART_HandleRxByte(d_tmp); } }