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 #469 background imageLoading...
Page #469 background image
Chapter 2. API Reference
enum twai_state_t
TWAI driver states.
Values:
TWAI_STATE_STOPPED
Stopped state. The TWAI controller will not participate in any TWAI bus activities
TWAI_STATE_RUNNING
Running state. The TWAI controller can transmit and receive messages
TWAI_STATE_BUS_OFF
Bus-off state. The TWAI controller cannot participate in bus activities until it has recovered
TWAI_STATE_RECOVERING
Recovering state. The TWAI controller is undergoing bus recovery
2.2.23 Universal Asynchronous Receiver/Transmitter (UART)
Overview
A Universal Asynchronous Receiver/Transmitter (UART) is a hardware feature that handles communication (i.e.,
timing requirements and data framing) using widely-adopted asynchronous serial communication interfaces, such as
RS232, RS422, RS485. A UART provides a widely adopted and cheap method to realize full-duplex or half-duplex
data exchange among different devices.
The ESP32-S2 chip has two UART controllers (UART0 and UART1), each featuring an identical set of registers to
simplify programming and for more flexibility.
Each UART controller is independently configurable with parameters such as baud rate, data bit length, bit ordering,
number of stop bits, parity bit etc. All the controllers are compatible with UART-enabled devices from various
manufacturers and can also support Infrared Data Association protocols (IrDA).
Functional Overview
The following overview describes how to establish communication between an ESP32-S2 and other UART devices
using the functions and data types of the UART driver. The overview reflects a typical programming workflow and
is broken down into the sections provided below:
1. Setting Communication Parameters - Setting baud rate, data bits, stop bits, etc.
2. Setting Communication Pins - Assigning pins for connection to a device.
3. Driver Installation - Allocating ESP32-S2s resources for the UART driver.
4. Running UART Communication - Sending / receiving data
5. Using Interrupts - Triggering interrupts on specific communication events
6. Deleting a Driver - Freeing allocated resources if a UART communication is no longer required
Steps 1 to 3 comprise the configuration stage. Step 4 is where the UART starts operating. Steps 5 and 6 are optional.
The UART drivers functions identify each of the UART controllers using uart_port_t. This identication is
needed for all the following function calls.
Setting Communication Parameters UART communication parameters can be configured all in a single step or
individually in multiple steps.
Single Step Call the function uart_param_config() and pass to it a uart_config_t structure. The
uart_config_t structure should contain all the required parameters. See the example below.
Espressif Systems 458
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