@@ -607,6 +607,20 @@ bool HardwareSerial::setMode(SerialMode mode) {
607
607
return uartSetMode (_uart, mode);
608
608
}
609
609
610
+ // Sets the UART Clock Source based on the compatible SoC options
611
+ // This method must be called before starting UART using begin(), otherwise it won't have any effect.
612
+ // Clock Source Options are:
613
+ // UART_CLK_SRC_APB :: ESP32, ESP32-S2, ESP32-C3 and ESP32-S3
614
+ // UART_CLK_SRC_PLL :: ESP32-C2, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2 and ESP32-P4
615
+ // UART_CLK_SRC_XTAL :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
616
+ // UART_CLK_SRC_RTC_FAST :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
617
+ // UART_CLK_SRC_REF_TICK :: ESP32 and ESP32-S2
618
+ // 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
619
+ // Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only RTC_FAST or XTAL/2 as Clock Source
620
+ bool setClockSource (SerialClkSrc clkSrc) {
621
+ return uartSetClockSource (_uart, (uart_sclk_t ) clkSrc);
622
+ }
623
+
610
624
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
611
625
// LP UART has FIFO of 16 bytes
612
626
size_t HardwareSerial::setRxBufferSize (size_t new_size) {
0 commit comments