@@ -665,23 +665,23 @@ uart_t *uartBegin(
665665 rxfifo_full_thrhd = uart_config .rx_flow_ctrl_thresh ; // makes sure that it will be set correctly in the struct
666666 uart_config .baud_rate = baudrate ;
667667#if SOC_UART_LP_NUM >= 1
668- if (uart_nr >= SOC_UART_HP_NUM ) { // it is a LP UART NUM
668+ if (uart_nr >= SOC_UART_HP_NUM ) { // it is a LP UART NUM
669669 if (uart -> _uart_clock_source > 0 ) {
670- uart_config .lp_source_clk = (soc_periph_lp_uart_clk_src_t ) uart -> _uart_clock_source ; // use user defined LP UART clock
670+ uart_config .lp_source_clk = (soc_periph_lp_uart_clk_src_t )uart -> _uart_clock_source ; // use user defined LP UART clock
671671 log_v ("Setting UART%d to user defined LP clock source (%d) " , uart_nr , uart -> _uart_clock_source );
672672 } else {
673673 uart_config .lp_source_clk = LP_UART_SCLK_DEFAULT ; // use default LP clock
674674 log_v ("Setting UART%d to Default LP clock source" , uart_nr );
675675 }
676676 } else
677- #endif // SOC_UART_LP_NUM >= 1
677+ #endif // SOC_UART_LP_NUM >= 1
678678 {
679679 if (uart -> _uart_clock_source >= 0 ) {
680- uart_config .source_clk = (soc_module_clk_t ) uart -> _uart_clock_source ; // use user defined HP UART clock
680+ uart_config .source_clk = (soc_module_clk_t )uart -> _uart_clock_source ; // use user defined HP UART clock
681681 log_v ("Setting UART%d to user defined HP clock source (%d) " , uart_nr , uart -> _uart_clock_source );
682- } else {
683- // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
684- // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
682+ } else {
683+ // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
684+ // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
685685#if SOC_UART_SUPPORT_XTAL_CLK
686686 uart_config .source_clk = UART_SCLK_XTAL ; // valid for C2, S3, C3, C6, H2 and P4
687687 log_v ("Setting UART%d to use XTAL clock" , uart_nr );
@@ -697,7 +697,7 @@ uart_t *uartBegin(
697697 // Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6|P4
698698 uart_config .source_clk = UART_SCLK_DEFAULT ; // baudrate may change with the APB Frequency!
699699 log_v ("Setting UART%d to use DEFAULT clock" , uart_nr );
700- #endif // SOC_UART_SUPPORT_XTAL_CLK
700+ #endif // SOC_UART_SUPPORT_XTAL_CLK
701701 }
702702 }
703703
@@ -997,23 +997,23 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
997997 soc_module_clk_t newClkSrc = UART_SCLK_DEFAULT ;
998998 int8_t previousClkSrc = uart -> _uart_clock_source ;
999999#if SOC_UART_LP_NUM >= 1
1000- if (uart -> num >= SOC_UART_HP_NUM ) { // it is a LP UART NUM
1000+ if (uart -> num >= SOC_UART_HP_NUM ) { // it is a LP UART NUM
10011001 if (uart -> _uart_clock_source > 0 ) {
1002- newClkSrc = (soc_periph_lp_uart_clk_src_t ) uart -> _uart_clock_source ; // use user defined LP UART clock
1002+ newClkSrc = (soc_periph_lp_uart_clk_src_t )uart -> _uart_clock_source ; // use user defined LP UART clock
10031003 log_v ("Setting UART%d to user defined LP clock source (%d) " , uart -> num , newClkSrc );
10041004 } else {
10051005 newClkSrc = LP_UART_SCLK_DEFAULT ; // use default LP clock
10061006 log_v ("Setting UART%d to Default LP clock source" , uart -> num );
10071007 }
1008- } else
1009- #endif // SOC_UART_LP_NUM >= 1
1008+ } else
1009+ #endif // SOC_UART_LP_NUM >= 1
10101010 {
10111011 if (uart -> _uart_clock_source >= 0 ) {
1012- newClkSrc = (soc_module_clk_t ) uart -> _uart_clock_source ; // use user defined HP UART clock
1012+ newClkSrc = (soc_module_clk_t )uart -> _uart_clock_source ; // use user defined HP UART clock
10131013 log_v ("Setting UART%d to use HP clock source (%d) " , uart -> num , newClkSrc );
1014- } else {
1015- // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
1016- // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
1014+ } else {
1015+ // there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
1016+ // therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
10171017#if SOC_UART_SUPPORT_XTAL_CLK
10181018 newClkSrc = UART_SCLK_XTAL ; // valid for C2, S3, C3, C6, H2 and P4
10191019 log_v ("Setting UART%d to use XTAL clock" , uart -> num );
@@ -1029,7 +1029,7 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
10291029 // Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6|P4
10301030 // using newClkSrc = UART_SCLK_DEFAULT as defined in the variable declaration
10311031 log_v ("Setting UART%d to use DEFAULT clock" , uart -> num );
1032- #endif // SOC_UART_SUPPORT_XTAL_CLK
1032+ #endif // SOC_UART_SUPPORT_XTAL_CLK
10331033 }
10341034 }
10351035 UART_MUTEX_LOCK ();
@@ -1133,7 +1133,7 @@ bool uartSetMode(uart_t *uart, uart_mode_t mode) {
11331133 return retCode ;
11341134}
11351135
1136- // this function will set the uart clock source
1136+ // this function will set the uart clock source
11371137// it must be called before uartBegin(), otherwise it won't change any thing.
11381138bool uartSetClockSource (uint8_t uartNum , uart_sclk_t clkSrc ) {
11391139 if (uartNum >= SOC_UART_NUM ) {
@@ -1144,15 +1144,10 @@ bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc) {
11441144#if SOC_UART_LP_NUM >= 1
11451145 if (uart -> num >= SOC_UART_HP_NUM ) {
11461146 switch (clkSrc ) {
1147- case UART_SCLK_XTAL :
1148- uart -> _uart_clock_source = LP_UART_SCLK_XTAL_D2 ;
1149- break ;
1150- case UART_SCLK_RTC :
1151- uart -> _uart_clock_source = LP_UART_SCLK_LP_FAST ;
1152- break ;
1147+ case UART_SCLK_XTAL : uart -> _uart_clock_source = LP_UART_SCLK_XTAL_D2 ; break ;
1148+ case UART_SCLK_RTC : uart -> _uart_clock_source = LP_UART_SCLK_LP_FAST ; break ;
11531149 case UART_SCLK_DEFAULT :
1154- default :
1155- uart -> _uart_clock_source = LP_UART_SCLK_DEFAULT ;
1150+ default : uart -> _uart_clock_source = LP_UART_SCLK_DEFAULT ;
11561151 }
11571152 } else
11581153#endif
0 commit comments