Skip to content

Commit 05337af

Browse files
authored
fix(uart): using uart number as argument instead
1 parent 25b0326 commit 05337af

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

cores/esp32/HardwareSerial.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,12 @@ bool HardwareSerial::setMode(SerialMode mode) {
619619
// Note: CLK_SRC_PLL Freq depends on the SoC - ESP32-C2 has 40MHz, ESP32-H2 has 48MHz and ESP32-C5, C6, C61 and P4 has 80MHz
620620
// Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only RTC_FAST or XTAL/2 as Clock Source
621621
bool HardwareSerial::setClockSource(SerialClkSrc clkSrc) {
622-
return uartSetClockSource(_uart, (uart_sclk_t) clkSrc);
622+
if (_uart) {
623+
log_e("No Clock Source change was done. This function must be called before beginning UART%d.", _uart_nr);
624+
return false;
625+
}
626+
return uartSetClockSource(_uart_nr, (uart_sclk_t) clkSrc);
623627
}
624-
625628
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
626629
// LP UART has FIFO of 16 bytes
627630
size_t HardwareSerial::setRxBufferSize(size_t new_size) {

0 commit comments

Comments
 (0)