Skip to content

Commit 3e78c46

Browse files
ci(pre-commit): Apply automatic fixes
1 parent 84da5d8 commit 3e78c46

File tree

3 files changed

+32
-36
lines changed

3 files changed

+32
-36
lines changed

cores/esp32/HardwareSerial.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -623,7 +623,7 @@ bool HardwareSerial::setClockSource(SerialClkSrc clkSrc) {
623623
log_e("No Clock Source change was done. This function must be called before beginning UART%d.", _uart_nr);
624624
return false;
625625
}
626-
return uartSetClockSource(_uart_nr, (uart_sclk_t) clkSrc);
626+
return uartSetClockSource(_uart_nr, (uart_sclk_t)clkSrc);
627627
}
628628
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
629629
// LP UART has FIFO of 16 bytes

cores/esp32/HardwareSerial.h

+10-9
Original file line numberDiff line numberDiff line change
@@ -96,26 +96,26 @@ typedef enum {
9696
UART_PARITY_ERROR
9797
} hardwareSerial_error_t;
9898

99-
typedef enum {
100-
UART_CLK_SRC_DEFAULT = UART_SCLK_DEFAULT,
99+
typedef enum {
100+
UART_CLK_SRC_DEFAULT = UART_SCLK_DEFAULT,
101101
#if SOC_UART_SUPPORT_APB_CLK
102-
UART_CLK_SRC_APB = UART_SCLK_APB,
102+
UART_CLK_SRC_APB = UART_SCLK_APB,
103103
#endif
104104
#if SOC_UART_SUPPORT_PLL_F40M_CLK
105-
UART_CLK_SRC_PLL = UART_SCLK_PLL_F40M,
105+
UART_CLK_SRC_PLL = UART_SCLK_PLL_F40M,
106106
#elif SOC_UART_SUPPORT_PLL_F80M_CLK
107-
UART_CLK_SRC_PLL = UART_SCLK_PLL_F80M,
107+
UART_CLK_SRC_PLL = UART_SCLK_PLL_F80M,
108108
#elif CONFIG_IDF_TARGET_ESP32H2
109-
UART_CLK_SRC_PLL = UART_SCLK_PLL_F48M,
109+
UART_CLK_SRC_PLL = UART_SCLK_PLL_F48M,
110110
#endif
111111
#if SOC_UART_SUPPORT_XTAL_CLK
112-
UART_CLK_SRC_XTAL = UART_SCLK_XTAL,
112+
UART_CLK_SRC_XTAL = UART_SCLK_XTAL,
113113
#endif
114114
#if SOC_UART_SUPPORT_RTC_CLK
115-
UART_CLK_SRC_RTC = UART_SCLK_RTC,
115+
UART_CLK_SRC_RTC = UART_SCLK_RTC,
116116
#endif
117117
#if SOC_UART_SUPPORT_REF_TICK
118-
UART_CLK_SRC_REF_TICK = UART_SCLK_REF_TICK,
118+
UART_CLK_SRC_REF_TICK = UART_SCLK_REF_TICK,
119119
#endif
120120
} SerialClkSrc;
121121

@@ -380,6 +380,7 @@ class HardwareSerial : public Stream {
380380
bool setClockSource(SerialClkSrc clkSrc);
381381
size_t setRxBufferSize(size_t new_size);
382382
size_t setTxBufferSize(size_t new_size);
383+
383384
protected:
384385
uint8_t _uart_nr;
385386
uart_t *_uart;

cores/esp32/esp32-hal-uart.c

+21-26
Original file line numberDiff line numberDiff line change
@@ -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.
11381138
bool 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

Comments
 (0)