@@ -665,23 +665,23 @@ uart_t *uartBegin(
665
665
rxfifo_full_thrhd = uart_config .rx_flow_ctrl_thresh ; // makes sure that it will be set correctly in the struct
666
666
uart_config .baud_rate = baudrate ;
667
667
#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
669
669
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
671
671
log_v ("Setting UART%d to user defined LP clock source (%d) " , uart_nr , uart -> _uart_clock_source );
672
672
} else {
673
673
uart_config .lp_source_clk = LP_UART_SCLK_DEFAULT ; // use default LP clock
674
674
log_v ("Setting UART%d to Default LP clock source" , uart_nr );
675
675
}
676
676
} else
677
- #endif // SOC_UART_LP_NUM >= 1
677
+ #endif // SOC_UART_LP_NUM >= 1
678
678
{
679
679
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
681
681
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.
685
685
#if SOC_UART_SUPPORT_XTAL_CLK
686
686
uart_config .source_clk = UART_SCLK_XTAL ; // valid for C2, S3, C3, C6, H2 and P4
687
687
log_v ("Setting UART%d to use XTAL clock" , uart_nr );
@@ -697,7 +697,7 @@ uart_t *uartBegin(
697
697
// 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
698
698
uart_config .source_clk = UART_SCLK_DEFAULT ; // baudrate may change with the APB Frequency!
699
699
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
701
701
}
702
702
}
703
703
@@ -997,23 +997,23 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
997
997
soc_module_clk_t newClkSrc = UART_SCLK_DEFAULT ;
998
998
int8_t previousClkSrc = uart -> _uart_clock_source ;
999
999
#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
1001
1001
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
1003
1003
log_v ("Setting UART%d to user defined LP clock source (%d) " , uart -> num , newClkSrc );
1004
1004
} else {
1005
1005
newClkSrc = LP_UART_SCLK_DEFAULT ; // use default LP clock
1006
1006
log_v ("Setting UART%d to Default LP clock source" , uart -> num );
1007
1007
}
1008
- } else
1009
- #endif // SOC_UART_LP_NUM >= 1
1008
+ } else
1009
+ #endif // SOC_UART_LP_NUM >= 1
1010
1010
{
1011
1011
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
1013
1013
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.
1017
1017
#if SOC_UART_SUPPORT_XTAL_CLK
1018
1018
newClkSrc = UART_SCLK_XTAL ; // valid for C2, S3, C3, C6, H2 and P4
1019
1019
log_v ("Setting UART%d to use XTAL clock" , uart -> num );
@@ -1029,7 +1029,7 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
1029
1029
// 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
1030
1030
// using newClkSrc = UART_SCLK_DEFAULT as defined in the variable declaration
1031
1031
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
1033
1033
}
1034
1034
}
1035
1035
UART_MUTEX_LOCK ();
@@ -1133,7 +1133,7 @@ bool uartSetMode(uart_t *uart, uart_mode_t mode) {
1133
1133
return retCode ;
1134
1134
}
1135
1135
1136
- // this function will set the uart clock source
1136
+ // this function will set the uart clock source
1137
1137
// it must be called before uartBegin(), otherwise it won't change any thing.
1138
1138
bool uartSetClockSource (uint8_t uartNum , uart_sclk_t clkSrc ) {
1139
1139
if (uartNum >= SOC_UART_NUM ) {
@@ -1144,15 +1144,10 @@ bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc) {
1144
1144
#if SOC_UART_LP_NUM >= 1
1145
1145
if (uart -> num >= SOC_UART_HP_NUM ) {
1146
1146
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 ;
1153
1149
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 ;
1156
1151
}
1157
1152
} else
1158
1153
#endif
0 commit comments