Skip to content

Commit bcc9ece

Browse files
authored
Apply suggestions from code review
1 parent 47ff617 commit bcc9ece

File tree

1 file changed

+6
-17
lines changed

1 file changed

+6
-17
lines changed

Diff for: cores/esp32/esp32-hal-uart.c

+6-17
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static uart_t _uart_bus_array[] = {
8383
#endif
8484

8585
// Negative Pin Number will keep it unmodified, thus this function can detach individual pins
86-
// This function will also unset the pins in the Peripheral Manager and set the pin to -1 after detaching
86+
// This function will set the pin to -1 after detaching
8787
static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
8888
{
8989
if(uart_num >= SOC_UART_NUM) {
@@ -96,7 +96,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
9696
//log_v("detaching UART%d pins: prev,pin RX(%d,%d) TX(%d,%d) CTS(%d,%d) RTS(%d,%d)", uart_num,
9797
// uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10);
9898

99-
// detaches pins and sets Peripheral Manager and UART information
99+
// detaches pins and sets UART information
100100
if (rxPin >= 0 && uart->_rxPin == rxPin) {
101101
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rxPin], PIN_FUNC_GPIO);
102102
// avoids causing BREAK in the UART line
@@ -126,7 +126,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
126126
}
127127

128128
// Attach function for UART
129-
// connects the IO Pad, set Paripheral Manager and internal UART structure data
129+
// connects the IO Pad, set internal UART structure data
130130
static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin)
131131
{
132132
if(uart_num >= SOC_UART_NUM) {
@@ -307,7 +307,7 @@ bool _testUartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t
307307
return false; // no new driver has to be installed
308308
}
309309
uart_t* uart = &_uart_bus_array[uart_nr];
310-
// verify if is necessary to restart the UART driver
310+
// verify if it is necessary to restart the UART driver
311311
if (uart_is_driver_installed(uart_nr)) {
312312
// some parameters can't be changed unless we end the UART driver
313313
if ( uart->_rx_buffer_size != rx_buffer_size || uart->_tx_buffer_size != tx_buffer_size || uart->_inverted != inverted || uart->_rxfifo_full_thrhd != rxfifo_full_thrhd) {
@@ -333,7 +333,7 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
333333
if(uart->lock == NULL) {
334334
uart->lock = xSemaphoreCreateMutex();
335335
if(uart->lock == NULL) {
336-
log_e("HAL LOCK error.");
336+
log_e("Lock (Mutex) creation error.");
337337
return NULL; // no new driver was installed
338338
}
339339
}
@@ -447,8 +447,6 @@ uart_t* uartBegin(uint8_t uart_nr, uint32_t baudrate, uint32_t config, int8_t rx
447447
uart->_rxfifo_full_thrhd = rxfifo_full_thrhd;
448448
uart->_rx_buffer_size = rx_buffer_size;
449449
uart->_tx_buffer_size = tx_buffer_size;
450-
uart->_ctsPin = -1;
451-
uart->_rtsPin = -1;
452450
uart->has_peek = false;
453451
uart->peek_byte = 0;
454452
}
@@ -722,8 +720,6 @@ void uartSetBaudRate(uart_t* uart, uint32_t baud_rate)
722720

723721
uint32_t uartGetBaudRate(uart_t* uart)
724722
{
725-
uint32_t baud_rate = 0;
726-
727723
if(uart == NULL) {
728724
return 0;
729725
}
@@ -837,15 +833,8 @@ int log_printfv(const char *format, va_list arg)
837833
}
838834
#endif
839835
*/
840-
//#if CONFIG_IDF_TARGET_ESP32C3
841836
vsnprintf(temp, len+1, format, arg);
842837
ets_printf("%s", temp);
843-
//#else
844-
// int wlen = vsnprintf(temp, len+1, format, arg);
845-
// for (int i = 0; i < wlen; i++) {
846-
// ets_write_char_uart(temp[i]);
847-
// }
848-
//#endif
849838
/*
850839
// This causes dead locks with logging and also with constructors that may send logs
851840
#if !CONFIG_DISABLE_HAL_LOCKS
@@ -857,7 +846,7 @@ int log_printfv(const char *format, va_list arg)
857846
if(len >= sizeof(loc_buf)){
858847
free(temp);
859848
}
860-
// flushes TX - make sure that the log message is completely sent.
849+
// flushes TX - try to assure that the log message is completely sent.
861850
if(s_uart_debug_nr != -1) while(!uart_ll_is_tx_idle(UART_LL_GET_HW(s_uart_debug_nr)));
862851
return len;
863852
}

0 commit comments

Comments
 (0)