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 #493 background imageLoading...
Page #493 background image
Chapter 2. API Reference
Name of CDC device if it is On
Serial number
If you want to use own descriptors with extended modification, you can define them during the driver installation
process
Install Driver
To initialize the driver, users should call tinyusb_driver_install(). The drivers configuration is specified
in a tinyusb_config_t structure that is passed as an argument to tinyusb_driver_install().
Note that the tinyusb_config_t structure can be zero initialized (e.g. tinyusb_config_t
tusb_cfg = { 0 }) or partially (as shown below). For any member that is initialized to 0 or NULL,
the driver will use its default configuration values for that member (see example below)
tinyusb_config_t partial_init = {
.descriptor = NULL; //Uses default descriptor specified in Menuconfig
.string_descriptor = NULL; //Uses default string specified in Menuconfig
.external_phy = false;
}
USB Serial Device (CDC-ACM)
If the CDC option is enabled in Menuconfig, the USB Serial Device could be initialized with
tusb_cdc_acm_init() according to the settings from tinyusb_config_cdcacm_t (see example
below).
tinyusb_config_cdcacm_t amc_cfg = {
.usb_dev = TINYUSB_USBDEV_0,
.cdc_port = TINYUSB_CDC_ACM_0,
.rx_unread_buf_sz = 64,
.callback_rx = NULL,
.callback_rx_wanted_char = NULL,
.callback_line_state_changed = NULL,
.callback_line_coding_changed = NULL
};
tusb_cdc_acm_init(&amc_cfg);
To specify callbacks you can either set the pointer to your tusb_cdcacm_callback_t function in the configu-
ration structure or call tinyusb_cdcacm_register_callback() after initialization.
USB Serial Console The driver allows to redirect all standard application strings (stdin/out/err) to the USB Serial
Device and return them to UART using esp_tusb_init_console()/esp_tusb_deinit_console()
functions.
Application Examples
The table below describes the code examples available in the directory peripherals/usb/.
Code Example Description
peripherals/usb/tusb_console How to set up ESP32-S2 chip to get log output via Serial Device connec-
tion
peripherals/usb/tusb_sample_descriptor How to set up ESP32-S2 chip to work as a Generic USB Device with a
user-defined descriptor
peripherals/usb/tusb_serial_device How to set up ESP32-S2 chip to work as a USB Serial Device
Espressif Systems 482
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