#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
Go to the source code of this file.
|
| enum | uart_word_length_t {
UART_DATA_5_BITS = 0
,
UART_DATA_6_BITS = 1
,
UART_DATA_7_BITS = 2
,
UART_DATA_8_BITS = 3
,
UART_DATA_BITS_MAX = 4
} |
| |
| enum | uart_stop_bits_t {
UART_STOP_BITS_1 = 1
,
UART_STOP_BITS_1_5 = 2
,
UART_STOP_BITS_2 = 3
,
UART_STOP_BITS_MAX = 4
} |
| |
| enum | uart_parity_t {
UART_PARITY_DISABLE = 0
,
UART_PARITY_EVEN = 2
,
UART_PARITY_ODD = 3
} |
| |
| enum | uart_hw_flowcontrol_t {
UART_HW_FLOWCTRL_DISABLE = 0
,
UART_HW_FLOWCTRL_RTS = 1
,
UART_HW_FLOWCTRL_CTS = 2
,
UART_HW_FLOWCTRL_CTS_RTS = 3
,
UART_HW_FLOWCTRL_MAX = 4
} |
| |
| enum | uart_mode_t {
UART_MODE_UART = 0
,
UART_MODE_RS485_HALF_DUPLEX = 1
,
UART_MODE_IRDA = 2
,
UART_MODE_RS485_COLLISION_DETECT = 3
,
UART_MODE_RS485_APP_CTRL = 4
} |
| |
| enum | uart_sclk_t {
UART_SCLK_DEFAULT = 0
,
UART_SCLK_APB = 1
,
UART_SCLK_XTAL = 2
,
UART_SCLK_RTC = 3
} |
| |
| enum | uart_event_type_t {
UART_DATA = 0
,
UART_BREAK = 1
,
UART_BUFFER_FULL = 2
,
UART_FIFO_OVF = 3
,
UART_FRAME_ERR = 4
,
UART_PARITY_ERR = 5
,
UART_DATA_BREAK = 6
,
UART_PATTERN_DET = 7
,
UART_EVENT_MAX = 8
} |
| |
|
| esp_err_t | uart_driver_install (uart_port_t uart_num, int rx_buffer_size, int tx_buffer_size, int queue_size, QueueHandle_t *uart_queue, int intr_alloc_flags) |
| |
| esp_err_t | uart_driver_delete (uart_port_t uart_num) |
| |
| bool | uart_is_driver_installed (uart_port_t uart_num) |
| |
| esp_err_t | uart_param_config (uart_port_t uart_num, const uart_config_t *uart_config) |
| |
| esp_err_t | uart_set_baudrate (uart_port_t uart_num, uint32_t baudrate) |
| |
| esp_err_t | uart_get_baudrate (uart_port_t uart_num, uint32_t *baudrate) |
| |
| esp_err_t | uart_set_word_length (uart_port_t uart_num, uart_word_length_t data_bit) |
| |
| esp_err_t | uart_get_word_length (uart_port_t uart_num, uart_word_length_t *data_bit) |
| |
| esp_err_t | uart_set_stop_bits (uart_port_t uart_num, uart_stop_bits_t stop_bits) |
| |
| esp_err_t | uart_get_stop_bits (uart_port_t uart_num, uart_stop_bits_t *stop_bits) |
| |
| esp_err_t | uart_set_parity (uart_port_t uart_num, uart_parity_t parity_mode) |
| |
| esp_err_t | uart_get_parity (uart_port_t uart_num, uart_parity_t *parity_mode) |
| |
| esp_err_t | uart_set_hw_flow_ctrl (uart_port_t uart_num, uart_hw_flowcontrol_t flow_ctrl, uint8_t rx_thresh) |
| |
| esp_err_t | uart_get_hw_flow_ctrl (uart_port_t uart_num, uart_hw_flowcontrol_t *flow_ctrl) |
| |
| int | uart_write_bytes (uart_port_t uart_num, const void *src, size_t size) |
| |
| int | uart_write_bytes_with_break (uart_port_t uart_num, const void *src, size_t size, int brk_len) |
| |
| int | uart_read_bytes (uart_port_t uart_num, void *buf, uint32_t length, TickType_t ticks_to_wait) |
| |
| esp_err_t | uart_get_buffered_data_len (uart_port_t uart_num, size_t *size) |
| |
| esp_err_t | uart_get_tx_buffer_free_size (uart_port_t uart_num, size_t *size) |
| |
| esp_err_t | uart_flush (uart_port_t uart_num) |
| |
| esp_err_t | uart_flush_input (uart_port_t uart_num) |
| |
| 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) |
| |
| esp_err_t | uart_set_mode (uart_port_t uart_num, uart_mode_t mode) |
| |
| esp_err_t | uart_set_rx_timeout (uart_port_t uart_num, uint8_t tout) |
| |
| esp_err_t | uart_wait_tx_done (uart_port_t uart_num, TickType_t ticks_to_wait) |
| |
◆ UART_PIN_NO_CHANGE
| #define UART_PIN_NO_CHANGE (-1) |
Symbolic value for uart_set_pin: "do not change this pin".
◆ UART_HW_FIFO_LEN
| #define UART_HW_FIFO_LEN (128) |
Default hardware FIFO depth (best-effort; actual depends on MCU).
◆ UART_NUM_0
Well-known port numbers. UART_NUM_MAX equals the pool size at runtime.
◆ UART_NUM_1
◆ UART_NUM_2
◆ UART_NUM_MAX
compile-time ceiling; real max = pool_count
◆ uart_port_t
UART port number (index into the cfg-injected vsf_usart_t pool).
◆ uart_word_length_t
UART word length.
| Enumerator |
|---|
| UART_DATA_5_BITS | 5-bit data
|
| UART_DATA_6_BITS | 6-bit data
|
| UART_DATA_7_BITS | 7-bit data
|
| UART_DATA_8_BITS | 8-bit data
|
| UART_DATA_BITS_MAX | |
◆ uart_stop_bits_t
UART stop bits.
| Enumerator |
|---|
| UART_STOP_BITS_1 | 1 stop bit
|
| UART_STOP_BITS_1_5 | 1.5 stop bits
|
| UART_STOP_BITS_2 | 2 stop bits
|
| UART_STOP_BITS_MAX | |
◆ uart_parity_t
UART parity mode.
| Enumerator |
|---|
| UART_PARITY_DISABLE | No parity
|
| UART_PARITY_EVEN | Even parity
|
| UART_PARITY_ODD | Odd parity
|
◆ uart_hw_flowcontrol_t
UART hardware flow control mode.
| Enumerator |
|---|
| UART_HW_FLOWCTRL_DISABLE | No HW flow control
|
| UART_HW_FLOWCTRL_RTS | RTS only
|
| UART_HW_FLOWCTRL_CTS | CTS only
|
| UART_HW_FLOWCTRL_CTS_RTS | Both CTS and RTS
|
| UART_HW_FLOWCTRL_MAX | |
◆ uart_mode_t
UART communication mode.
| Enumerator |
|---|
| UART_MODE_UART | Normal UART mode
|
| UART_MODE_RS485_HALF_DUPLEX | RS-485 half duplex
|
| UART_MODE_IRDA | IrDA (not supported in VSF shim)
|
| UART_MODE_RS485_COLLISION_DETECT | |
| UART_MODE_RS485_APP_CTRL | |
◆ uart_sclk_t
UART clock source (informational only; VSF manages clocking internally).
| Enumerator |
|---|
| UART_SCLK_DEFAULT | |
| UART_SCLK_APB | |
| UART_SCLK_XTAL | |
| UART_SCLK_RTC | |
◆ uart_event_type_t
UART event types posted to the user event queue.
| Enumerator |
|---|
| UART_DATA | Data ready in RX buffer
|
| UART_BREAK | BREAK detected
|
| UART_BUFFER_FULL | RX ring buffer full
|
| UART_FIFO_OVF | FIFO overflow
|
| UART_FRAME_ERR | Frame error
|
| UART_PARITY_ERR | Parity error
|
| UART_DATA_BREAK | TX data + BREAK sent
|
| UART_PATTERN_DET | Pattern detected (NOT_SUPPORTED)
|
| UART_EVENT_MAX | |
◆ uart_driver_install()
Install the UART driver and allocate internal resources.
- Parameters
-
| uart_num | UART port number (index into the cfg pool). |
| rx_buffer_size | RX ring buffer size in bytes. Must be > UART_HW_FIFO_LEN. |
| tx_buffer_size | TX ring buffer size (0 = blocking write mode). |
| queue_size | UART event queue depth. 0 = no event queue. |
| uart_queue | [out] If non-NULL, receives the event queue handle. |
| intr_alloc_flags | Ignored by VSF (interrupt allocation is internal). |
- Returns
- ESP_OK on success, ESP_ERR_INVALID_ARG / ESP_ERR_NO_MEM / ESP_FAIL.
◆ uart_driver_delete()
Delete the UART driver and free all resources.
◆ uart_is_driver_installed()
Check whether the UART driver is installed.
◆ uart_param_config()
Apply a full configuration (baud, data bits, parity, stop, flow control).
◆ uart_set_baudrate()
◆ uart_get_baudrate()
◆ uart_set_word_length()
◆ uart_get_word_length()
◆ uart_set_stop_bits()
◆ uart_get_stop_bits()
◆ uart_set_parity()
◆ uart_get_parity()
◆ uart_set_hw_flow_ctrl()
◆ uart_get_hw_flow_ctrl()
◆ uart_write_bytes()
Write data to the UART TX FIFO. Blocks until all bytes are queued.
- Returns
- Number of bytes written, or -1 on error.
◆ uart_write_bytes_with_break()
| int uart_write_bytes_with_break |
( |
uart_port_t |
uart_num, |
|
|
const void * |
src, |
|
|
size_t |
size, |
|
|
int |
brk_len |
|
) |
| |
|
extern |
Write data followed by a BREAK signal.
- Returns
- Number of bytes written, or -1 on error.
◆ uart_read_bytes()
Read data from the UART RX buffer.
- Parameters
-
| ticks_to_wait | Maximum time to block (FreeRTOS ticks). |
- Returns
- Number of bytes read, or -1 on error.
◆ uart_get_buffered_data_len()
Get the number of bytes buffered in the RX ring buffer.
◆ uart_get_tx_buffer_free_size()
Get the free space in the TX ring buffer.
◆ uart_flush()
Discard all data in the RX ring buffer (same as uart_flush_input).
◆ uart_flush_input()
Discard all data in the RX ring buffer.
◆ uart_set_pin()
| 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 |
|
) |
| |
|
extern |
Set UART pin assignment. NOT_SUPPORTED in this VSF shim – pin muxing is the responsibility of the board BSP / io_mapper.
- Returns
- ESP_ERR_NOT_SUPPORTED always.
◆ uart_set_mode()
Set UART mode (normal / RS-485 / IrDA).
◆ uart_set_rx_timeout()
Set RX timeout threshold (in UART symbol periods).
◆ uart_wait_tx_done()
Wait until TX FIFO is empty (best-effort via status polling).
- Parameters
-
| ticks_to_wait | Maximum wait time in FreeRTOS ticks. |
- Returns
- ESP_OK or ESP_ERR_TIMEOUT.