Chapter 2. API Reference
Return
• ESP_OK Success
• ESP_FAIL Parameter error
Parameters
• uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
• enable: 1: enable; 0: disable
• thresh: Threshold of TX interrupt, 0 ~ UART_FIFO_LEN
esp_err_t uart_isr_register(uart_port_t uart_num, void (*fn))void *
, void *arg, int intr_alloc_flags, uart_isr_handle_t *handleRegister UART interrupt handler (ISR).
Note UART ISR handler will be attached to the same CPU core that this function is running on.
Return
• ESP_OK Success
• ESP_FAIL Parameter error
Parameters
• uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
• fn: Interrupt handler function.
• arg: parameter for handler function
• intr_alloc_flags: Flags used to allocate the interrupt. One or multiple (ORred)
ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
• handle: Pointer to return handle. If non-NULL, a handle for the interrupt will be returned here.
esp_err_t uart_isr_free(uart_port_t uart_num)
Free UART interrupt handler registered by uart_isr_register. Must be called on the same core as
uart_isr_register was called.
Return
• ESP_OK Success
• ESP_FAIL Parameter error
Parameters
• uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
esp_err_t uart_set_pin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int rts_io_num, int
cts_io_num)
Assign signals of a UART peripheral to GPIO pins.
Note 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.
Note Internal signal can be output to multiple GPIO pads. Only one GPIO pad can connect with input signal.
Return
• ESP_OK Success
• ESP_FAIL Parameter error
Parameters
• uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
• tx_io_num: UART TX pin GPIO number.
• rx_io_num: UART RX pin GPIO number.
• rts_io_num: UART RTS pin GPIO number.
• cts_io_num: UART CTS pin GPIO number.
esp_err_t uart_set_rts(uart_port_t uart_num, int level)
Manually set the UART RTS pin level.
Note UART must be configured with hardware flow control disabled.
Return
• ESP_OK Success
• ESP_FAIL Parameter error
Espressif Systems 468
Submit Document Feedback
Release v4.4