Skip to content

Commit 4441190

Browse files
committed
And fixed the remaining things
1 parent f948c78 commit 4441190

File tree

1 file changed

+18
-19
lines changed

1 file changed

+18
-19
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -369,22 +369,21 @@ uint32_t uartAvailableForWrite(uart_t* uart)
369369
}
370370

371371
void uartRxFifoToQueue(uart_t* uart)
372-
{
373-
uint8_t c;
374-
UART_MUTEX_LOCK();
375-
//disable interrupts
376-
uart->dev->int_ena.val = 0;
377-
uart->dev->int_clr.val = 0xffffffff;
378-
while (uart->dev->status.rxfifo_cnt || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
379-
c = uart->dev->fifo.rw_byte;
380-
xQueueSend(uart->queue, &c, 0);
381-
}
382-
//enable interrupts
383-
uart->dev->int_ena.rxfifo_full = 1;
384-
uart->dev->int_ena.frm_err = 1;
385-
uart->dev->int_ena.rxfifo_tout = 1;
386-
uart->dev->int_clr.val = 0xffffffff;
387-
UART_MUTEX_UNLOCK();
372+
{
373+
uint8_t c;
374+
UART_MUTEX_LOCK();
375+
//disable interrupts
376+
uart->dev->int_ena.val = 0;
377+
uart->dev->int_clr.val = 0xffffffff;
378+
while (uart->dev->status.rxfifo_cnt || (uart->dev->mem_rx_status.wr_addr != uart->dev->mem_rx_status.rd_addr)) {
379+
c = uart->dev->fifo.rw_byte;
380+
xQueueSend(uart->queue, &c, 0);
381+
}
382+
//enable interrupts
383+
uart->dev->int_ena.rxfifo_full = 1;
384+
uart->dev->int_ena.frm_err = 1;
385+
uart->dev->int_ena.rxfifo_tout = 1;
386+
uart->dev->int_clr.val = 0xffffffff;
388387
}
389388

390389
uint8_t uartRead(uart_t* uart)
@@ -395,7 +394,7 @@ uint8_t uartRead(uart_t* uart)
395394
uint8_t c;
396395
if ((uxQueueMessagesWaiting(uart->queue) == 0) && (uart->dev->status.rxfifo_cnt > 0))
397396
{
398-
uartRxFifoToQueue(uart);
397+
uartRxFifoToQueue(uart);
399398
}
400399
if(xQueueReceive(uart->queue, &c, 0)) {
401400
return c;
@@ -411,7 +410,7 @@ uint8_t uartPeek(uart_t* uart)
411410
uint8_t c;
412411
if ((uxQueueMessagesWaiting(uart->queue) == 0) && (uart->dev->status.rxfifo_cnt > 0))
413412
{
414-
uartRxFifoToQueue(uart);
413+
uartRxFifoToQueue(uart);
415414
}
416415
if(xQueuePeek(uart->queue, &c, 0)) {
417416
return c;
@@ -688,7 +687,7 @@ uartDetectBaudrate(uart_t *uart)
688687
static const unsigned long default_rates[] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400};
689688

690689
size_t i;
691-
for (i = 1; i < sizeof(default_rates) / sizeof(default_rates[0]) - 1; i++) // find the nearest real baudrate
690+
for (i = 1; i < sizeof(default_rates) / sizeof(default_rates[0]) - 1; i++) // find the nearest real baudrate
692691
{
693692
if (baudrate <= default_rates[i])
694693
{

0 commit comments

Comments
 (0)