EasyManua.ls Logo

Espressif ESP32-S2 - Page 475

Espressif ESP32-S2
1695 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
Chapter 2. API Reference
Application Examples
The table below describes the code examples available in the directory peripherals/uart/.
Code Example Description
peripherals/uart/uart_echo Configuring UART settings, installing the UART driver, and read-
ing/writing over the UART1 interface.
peripherals/uart/uart_events Reporting various communication events, using pattern detection inter-
rupts.
peripherals/uart/uart_async_rxtxtasks Transmitting and receiving data in two separate FreeRTOS tasks over the
same UART.
peripherals/uart/uart_select Using synchronous I/O multiplexing for UART file descriptors.
peripherals/uart/uart_echo_rs485 Setting up UART driver to communicate over RS485 interface in half-
duplex mode. This example is similar to peripherals/uart/uart_echo but
allows communication through an RS485 interface chip connected to
ESP32-S2 pins.
peripherals/uart/nmea0183_parser Obtaining GPS information by parsing NMEA0183 statements received
from GPS via the UART peripheral.
API Reference
Header File
components/driver/include/driver/uart.h
Functions
esp_err_t uart_driver_install(uart_port_t uart_num, int rx_buer_size, int tx_buer_size, int
queue_size, QueueHandle_t *uart_queue, int intr_alloc_flags)
Install UART driver and set the UART to the default configuration.
UART ISR handler will be attached to the same CPU core that this function is running on.
Note Rx_buffer_size should be greater than UART_FIFO_LEN. Tx_buffer_size should be either zero or
greater than UART_FIFO_LEN.
Return
ESP_OK Success
ESP_FAIL Parameter error
Parameters
uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
rx_buffer_size: UART RX ring buffer size.
tx_buffer_size: UART TX ring buffer size. If set to zero, driver will not use TX buffer, TX
function will block task until all data have been sent out.
queue_size: UART event queue size/depth.
uart_queue: UART event queue handle (out param). On success, a new queue handle is written
here to provide access to UART events. If set to NULL, driver will not use an event queue.
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. Do not set
ESP_INTR_FLAG_IRAM here (the drivers ISR handler is not located in IRAM)
esp_err_t uart_driver_delete(uart_port_t uart_num)
Uninstall UART driver.
Return
ESP_OK Success
ESP_FAIL Parameter error
Parameters
uart_num: UART port number, the max port number is (UART_NUM_MAX -1).
bool uart_is_driver_installed(uart_port_t uart_num)
Checks whether the driver is installed or not.
Espressif Systems 464
Submit Document Feedback
Release v4.4

Table of Contents