UART port number, the max port number is (UART_NUM_MAX -1).
tx_io_num
int
UART TX pin GPIO number.
rx_io_num
int
UART RX pin GPIO number.
rts_io_num
int
UART RTS pin GPIO number.
cts_io_num
int
UART CTS pin GPIO number.
Return value
- ESP_OK Success - ESP_FAIL Parameter error
Notes
If the GPIO number configured for a UART signal matches one of the IOMUX signals for that GPIO, the signal will be connected directly via the IOMUX. Otherwise the GPIO and signal will be connected via the GPIO Matrix. For example, if on an ESP32 the call `uart_set_pin(0, 1, 3, -1, -1)` is performed, as GPIO1 is UART0's default TX pin and GPIO3 is UART0's default RX pin, both will be connected to respectively U0TXD and U0RXD through the IOMUX, totally bypassing the GPIO matrix. The check is performed on a per-pin basis. Thus, it is possible to have RX pin binded to a GPIO through the GPIO matrix, whereas TX is binded to its GPIO through the IOMUX. It is possible to configure TX and RX to share the same IO (single wire mode), but please be aware of output conflict, which could damage the pad. Apply open-drain and pull-up to the pad ahead of time as a protection, or the upper layer protocol must guarantee no output from two ends at the same time.
Examples
uart_set_pin() is referenced by 19 libraries and example projects: