Skip to content

Commit 0532c88

Browse files
committed
fix uartWriteBuf and uartDetectBaudrate
1 parent 344c76d commit 0532c88

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

cores/esp32/esp32-hal-uart.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -323,10 +323,9 @@ void uartWriteBuf(uart_t* uart, const uint8_t * data, size_t len)
323323
}
324324
UART_MUTEX_LOCK();
325325
while(len) {
326-
while(len && uart->dev->status.txfifo_cnt < 0x7F) {
327-
uart->dev->fifo.rw_byte = *data++;
328-
len--;
329-
}
326+
while(uart->dev->status.txfifo_cnt == 0x7F);
327+
uart->dev->fifo.rw_byte = *data++;
328+
len--;
330329
}
331330
UART_MUTEX_UNLOCK();
332331
}
@@ -540,7 +539,7 @@ uartDetectBaudrate(uart_t *uart)
540539
uart->dev->auto_baud.en = 0;
541540
uartStateDetectingBaudrate = false; // Initialize for the next round
542541

543-
unsigned long baudrate = UART_CLK_FREQ / divisor;
542+
unsigned long baudrate = getApbFrequency() / divisor;
544543

545544
static const unsigned long default_rates[] = {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400, 256000, 460800, 921600, 1843200, 3686400};
546545

0 commit comments

Comments
 (0)