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 #847 background imageLoading...
Page #847 background image
Chapter 2. API Reference
(continued from previous page)
...
// 5. Unregistering an unneeded handler
esp_event_handler_unregister_with(loop_handle, MY_EVENT_BASE, MY_EVENT_ID, run_
,on_event);
...
// 6. Deleting an unneeded event loop
esp_event_loop_delete(loop_handle);
}
Declaring and defining events
As mentioned previously, events consists of two-part identifers: the event base and the event ID. The event base
identifies an independent group of events; the event ID identifies the event within that group. Think of the event base
and event ID as a persons last name and first name, respectively. A last name identifies a family, and the first name
identifies a person within that family.
The event loop library provides macros to declare and define the event base easily.
Event base declaration:
ESP_EVENT_DECLARE_BASE(EVENT_BASE)
Event base definition:
ESP_EVENT_DEFINE_BASE(EVENT_BASE)
Note: In IDF, the base identifiers for system events are uppercase and are postfixed with _EVENT. For example,
the base for wifi events is declared and defined as WIFI_EVENT, the ethernet event base ETHERNET_EVENT, and
so on. The purpose is to have event bases look like constants (although they are global variables considering the
defintions of macros ESP_EVENT_DECLARE_BASE and ESP_EVENT_DEFINE_BASE).
For event IDs, declaring them as enumerations is recommended. Once again, for visibility, these are typically
placed in public header files.
Event ID:
enum {
EVENT_ID_1,
EVENT_ID_2,
EVENT_ID_3,
...
}
Default Event Loop
The default event loop is a special type of loop used for system events (WiFi events, for example). The handle for
this loop is hidden from the user. The creation, deletion, handler registration/unregistration and posting of events is
done through a variant of the APIs for user event loops. The table below enumerates those variants, and the user
event loops equivalent.
Espressif Systems 836
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