EasyManuals Logo

Espressif ESP32-S2 User Manual

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
Page #484 background imageLoading...
Page #484 background image
Chapter 2. API Reference
esp_err_t uart_set_tx_empty_threshold(uart_port_t uart_num, int threshold)
Set uart threshold values for TX fifo empty.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
ESP_ERR_INVALID_STATE Driver is not installed
Parameters
uart_num: UART_NUM_0, UART_NUM_1 or UART_NUM_2
threshold: Threshold value below which TX fifo empty interrupt is generated
esp_err_t uart_set_rx_timeout(uart_port_t uart_num, const uint8_t tout_thresh)
UART set threshold timeout for TOUT feature.
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
ESP_ERR_INVALID_STATE Driver is not installed
Parameters
uart_num: Uart number to configure, the max port number is (UART_NUM_MAX -1).
tout_thresh: This parameter defines timeout threshold in uart symbol periods. The maximum
value of threshold is 126. tout_thresh = 1, defines TOUT interrupt timeout equal to transmission time
of one symbol (~11 bit) on current baudrate. If the time is expired the UART_RXFIFO_TOUT_INT
interrupt is triggered. If tout_thresh == 0, the TOUT feature is disabled.
esp_err_t uart_get_collision_flag(uart_port_t uart_num, bool *collision_flag)
Returns collision detection flag for RS485 mode Function returns the collision detection flag into variable
pointed by collision_flag. *collision_flag = true, if collision detected else it is equal to false. This function
should be executed when actual transmission is completed (after uart_write_bytes()).
Return
ESP_OK Success
ESP_ERR_INVALID_ARG Parameter error
Parameters
uart_num: Uart number to configure the max port number is (UART_NUM_MAX -1).
collision_flag: Pointer to variable of type bool to return collision flag.
esp_err_t uart_set_wakeup_threshold(uart_port_t uart_num, int wakeup_threshold)
Set the number of RX pin signal edges for light sleep wakeup.
UART can be used to wake up the system from light sleep. This feature works by counting the number of
positive edges on RX pin and comparing the count to the threshold. When the count exceeds the threshold,
system is woken up from light sleep. This function allows setting the threshold value.
Stop bit and parity bits (if enabled) also contribute to the number of edges. For example, letter awith
ASCII code 97 is encoded as 0100001101 on the wire (with 8n1 configuration), start and stop bits included.
This sequence has 3 positive edges (transitions from 0 to 1). Therefore, to wake up the system when ais
sent, set wakeup_threshold=3.
The character that triggers wakeup is not received by UART (i.e. it can not be obtained from UART FIFO).
Depending on the baud rate, a few characters after that will also not be received. Note that when the chip enters
and exits light sleep mode, APB frequency will be changing. To make sure that UART has correct baud rate
all the time, select REF_TICK as UART clock source, by setting use_ref_tick field in uart_config_t to true.
Note in ESP32, the wakeup signal can only be input via IO_MUX (i.e. GPIO3 should be configured as
function_1 to wake up UART0, GPIO9 should be configured as function_5 to wake up UART1), UART2
does not support light sleep wakeup feature.
Return
ESP_OK on success
ESP_ERR_INVALID_ARG if uart_num is incorrect or wakeup_threshold is outside of [3, 0x3ff]
range.
Parameters
uart_num: UART number, the max port number is (UART_NUM_MAX -1).
Espressif Systems 473
Submit Document Feedback
Release v4.4

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Espressif ESP32-S2 and is the answer not in the manual?

Espressif ESP32-S2 Specifications

General IconGeneral
BrandEspressif
ModelESP32-S2
CategorySingle board computers
LanguageEnglish