@@ -329,7 +329,7 @@ bool uartSetPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, in
329
329
UART_MUTEX_UNLOCK ();
330
330
331
331
if (!retCode ) {
332
- log_e ("UART%d set pins failed." );
332
+ log_e ("UART%d set pins failed." , uart_num );
333
333
}
334
334
return retCode ;
335
335
}
@@ -958,7 +958,7 @@ unsigned long uartDetectBaudrate(uart_t *uart)
958
958
}
959
959
960
960
/*
961
- These functions are for testing puspose only and can be used in Arduino Sketches
961
+ These functions are for testing purpose only and can be used in Arduino Sketches
962
962
Those are used in the UART examples
963
963
*/
964
964
@@ -968,15 +968,17 @@ unsigned long uartDetectBaudrate(uart_t *uart)
968
968
This code "replaces" the physical wiring for connecting TX <--> RX in a loopback
969
969
*/
970
970
971
- // gets the right TX SIGNAL, based on the UART number
971
+ // gets the right TX or RX SIGNAL, based on the UART number from gpio_sig_map.h
972
972
#if SOC_UART_NUM > 2
973
- #define UART_TX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : (uartNumber == UART_NUM_1 ? U1TXD_OUT_IDX : U2TXD_OUT_IDX))
973
+ #define UART_TX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : (uartNumber == UART_NUM_1 ? U1TXD_OUT_IDX : U2TXD_OUT_IDX))
974
+ #define UART_RX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : (uartNumber == UART_NUM_1 ? U1RXD_IN_IDX : U2RXD_IN_IDX))
974
975
#else
975
- #define UART_TX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : U1TXD_OUT_IDX)
976
+ #define UART_TX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : U1TXD_OUT_IDX)
977
+ #define UART_RX_SIGNAL (uartNumber ) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : U1RXD_IN_IDX)
976
978
#endif
977
979
/*
978
- Make sure UART's RX signal is connected to TX pin
979
- This creates a loop that lets us receive anything we send on the UART
980
+ This function internally binds defined UARTs TX signal with defined RX pin of any UART (same or different).
981
+ This creates a loop that lets us receive anything we send on the UART without external wires.
980
982
*/
981
983
void uart_internal_loopback (uint8_t uartNum , int8_t rxPin )
982
984
{
@@ -1008,4 +1010,4 @@ int uart_send_msg_with_break(uint8_t uartNum, uint8_t *msg, size_t msgSize)
1008
1010
return uart_write_bytes_with_break (uartNum , (const void * )msg , msgSize , 12 );
1009
1011
}
1010
1012
1011
- #endif /* SOC_UART_SUPPORTED */
1013
+ #endif /* SOC_UART_SUPPORTED */
0 commit comments