VSF Documented
driver_uart_port.c File Reference
#include "../vsf_espidf_cfg.h"
#include "driver/uart.h"
#include "../vsf_espidf.h"
#include "kernel/vsf_kernel.h"
#include "hal/driver/driver.h"
#include "service/heap/vsf_heap.h"
#include "service/simple_stream/vsf_simple_stream.h"
#include "FreeRTOS.h"
#include "semphr.h"
#include "queue.h"
#include "task.h"
#include <string.h>

Data Structures

struct  uart_port_state_t
 

Macros

#define __VSF_SIMPLE_STREAM_CLASS_INHERIT__
 
#define __UART_DEFAULT_TX_BUF_SIZE   256
 
#define __stream_rx(__s)
 
#define __stream_tx(__s)
 

Typedefs

typedef struct uart_port_state_t uart_port_state_t
 

Functions

void vsf_espidf_uart_init (const vsf_espidf_uart_cfg_t *cfg)
 
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_input (uart_port_t uart_num)
 
esp_err_t uart_flush (uart_port_t uart_num)
 
esp_err_t uart_wait_tx_done (uart_port_t uart_num, TickType_t ticks_to_wait)
 
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)
 

Macro Definition Documentation

◆ __VSF_SIMPLE_STREAM_CLASS_INHERIT__

#define __VSF_SIMPLE_STREAM_CLASS_INHERIT__

◆ __UART_DEFAULT_TX_BUF_SIZE

#define __UART_DEFAULT_TX_BUF_SIZE   256

◆ __stream_rx

#define __stream_rx ( __s)
Value:
((vsf_stream_t *)(__s)->stream_rx)
Definition vsf_simple_stream.h:254

◆ __stream_tx

#define __stream_tx ( __s)
Value:
((vsf_stream_t *)(__s)->stream_tx)

Typedef Documentation

◆ uart_port_state_t

typedef struct uart_port_state_t uart_port_state_t

Function Documentation

◆ vsf_espidf_uart_init()

void vsf_espidf_uart_init ( const vsf_espidf_uart_cfg_t * cfg)
extern

◆ uart_driver_install()

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 )

Install the UART driver and allocate internal resources.

Parameters
uart_numUART port number (index into the cfg pool).
rx_buffer_sizeRX ring buffer size in bytes. Must be > UART_HW_FIFO_LEN.
tx_buffer_sizeTX ring buffer size (0 = blocking write mode).
queue_sizeUART event queue depth. 0 = no event queue.
uart_queue[out] If non-NULL, receives the event queue handle.
intr_alloc_flagsIgnored by VSF (interrupt allocation is internal).
Returns
ESP_OK on success, ESP_ERR_INVALID_ARG / ESP_ERR_NO_MEM / ESP_FAIL.

◆ uart_driver_delete()

esp_err_t uart_driver_delete ( uart_port_t uart_num)

Delete the UART driver and free all resources.

◆ uart_is_driver_installed()

bool uart_is_driver_installed ( uart_port_t uart_num)

Check whether the UART driver is installed.

◆ uart_param_config()

esp_err_t uart_param_config ( uart_port_t uart_num,
const uart_config_t * uart_config )

Apply a full configuration (baud, data bits, parity, stop, flow control).

◆ uart_set_baudrate()

esp_err_t uart_set_baudrate ( uart_port_t uart_num,
uint32_t baudrate )

◆ uart_get_baudrate()

esp_err_t uart_get_baudrate ( uart_port_t uart_num,
uint32_t * baudrate )

◆ uart_set_word_length()

esp_err_t uart_set_word_length ( uart_port_t uart_num,
uart_word_length_t data_bit )

◆ uart_get_word_length()

esp_err_t uart_get_word_length ( uart_port_t uart_num,
uart_word_length_t * data_bit )

◆ uart_set_stop_bits()

esp_err_t uart_set_stop_bits ( uart_port_t uart_num,
uart_stop_bits_t stop_bits )

◆ uart_get_stop_bits()

esp_err_t uart_get_stop_bits ( uart_port_t uart_num,
uart_stop_bits_t * stop_bits )

◆ uart_set_parity()

esp_err_t uart_set_parity ( uart_port_t uart_num,
uart_parity_t parity_mode )

◆ uart_get_parity()

esp_err_t uart_get_parity ( uart_port_t uart_num,
uart_parity_t * parity_mode )

◆ uart_set_hw_flow_ctrl()

esp_err_t uart_set_hw_flow_ctrl ( uart_port_t uart_num,
uart_hw_flowcontrol_t flow_ctrl,
uint8_t rx_thresh )

◆ uart_get_hw_flow_ctrl()

esp_err_t uart_get_hw_flow_ctrl ( uart_port_t uart_num,
uart_hw_flowcontrol_t * flow_ctrl )

◆ uart_write_bytes()

int uart_write_bytes ( uart_port_t uart_num,
const void * src,
size_t size )

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 )

Write data followed by a BREAK signal.

Returns
Number of bytes written, or -1 on error.

◆ uart_read_bytes()

int uart_read_bytes ( uart_port_t uart_num,
void * buf,
uint32_t length,
TickType_t ticks_to_wait )

Read data from the UART RX buffer.

Parameters
ticks_to_waitMaximum time to block (FreeRTOS ticks).
Returns
Number of bytes read, or -1 on error.

◆ uart_get_buffered_data_len()

esp_err_t uart_get_buffered_data_len ( uart_port_t uart_num,
size_t * size )

Get the number of bytes buffered in the RX ring buffer.

◆ uart_get_tx_buffer_free_size()

esp_err_t uart_get_tx_buffer_free_size ( uart_port_t uart_num,
size_t * size )

Get the free space in the TX ring buffer.

◆ uart_flush_input()

esp_err_t uart_flush_input ( uart_port_t uart_num)

Discard all data in the RX ring buffer.

◆ uart_flush()

esp_err_t uart_flush ( uart_port_t uart_num)

Discard all data in the RX ring buffer (same as uart_flush_input).

◆ uart_wait_tx_done()

esp_err_t uart_wait_tx_done ( uart_port_t uart_num,
TickType_t ticks_to_wait )

Wait until TX FIFO is empty (best-effort via status polling).

Parameters
ticks_to_waitMaximum wait time in FreeRTOS ticks.
Returns
ESP_OK or ESP_ERR_TIMEOUT.

◆ 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 )

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()

esp_err_t uart_set_mode ( uart_port_t uart_num,
uart_mode_t mode )

Set UART mode (normal / RS-485 / IrDA).

◆ uart_set_rx_timeout()

esp_err_t uart_set_rx_timeout ( uart_port_t uart_num,
uint8_t tout )

Set RX timeout threshold (in UART symbol periods).

Variable Documentation

◆ is_inited

bool is_inited

◆ pool

vsf_usart_t* const* pool

◆ pool_count

uint16_t pool_count

◆ ports

heap array [pool_count]

Generated from commit: vsfteam/vsf@c8a7591