Chapter 2. API Reference
Functions
esp_err_t
esp_intr_mark_shared(int intno, int cpu, bool is_in_iram)
Mark an interrupt as a shared interrupt.
This will mark a certain interrupt on the specified CPU as an interrupt that can be used to hook shared interrupt
handlers to.
Return ESP_ERR_INVALID_ARG if cpu or intno is invalid ESP_OK otherwise
Parameters
• intno: The number of the interrupt (0-31)
• cpu: CPU on which the interrupt should be marked as shared (0 or 1)
• is_in_iram: Shared interrupt is for handlers that reside in IRAM and the int can be left enabled
while the flash cache is disabled.
esp_err_t
esp_intr_reserve(int intno, int cpu)
Reserve an interrupt to be used outside of this framework.
This will mark a certain interrupt on the specified CPU as reserved, not to be allocated for any reason.
Return ESP_ERR_INVALID_ARG if cpu or intno is invalid ESP_OK otherwise
Parameters
• intno: The number of the interrupt (0-31)
• cpu: CPU on which the interrupt should be marked as shared (0 or 1)
esp_err_t
esp_intr_alloc(int source, int flags,
Allocate an interrupt with the given parameters.
This finds an interrupt that matches the restrictions as given in the flags parameter, maps the given interrupt
source to it and hooks up the given interrupt handler (with optional argument) as well. If needed, it can return
a handle for the interrupt as well.
The interrupt will always be allocated on the core that runs this function.
If ESP_INTR_FLAG_IRAM flag is used, and handler address is not in IRAM or RTC_FAST_MEM, then
ESP_ERR_INVALID_ARG is returned.
Return ESP_ERR_INVALID_ARG if the combination of arguments is invalid. ESP_ERR_NOT_FOUND
No free interrupt found with the specified flags ESP_OK otherwise
Parameters
• source: The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux sources, as
defined in soc/soc.h, or one of the internal ETS_INTERNAL_*_INTR_SOURCE sources as defined
in this header.
• flags: An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the choice of inter-
rupts that this routine can choose from. If this value is 0, it will default to allocating a non-shared
interrupt of level 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared inter-
rupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with
the interrupt disabled.
• handler: The interrupt handler. Must be NULL when an interrupt of level >3 is requested,
because these types of interrupts aren't C-callable.
• arg: Optional argument for passed to the interrupt handler
• ret_handle: Pointer to an intr_handle_t to store a handle that can later be used to request details
or free the interrupt. Can be NULL if no handle is required.
esp_err_t
esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusreg, uint32_t intrsta-
Allocate an interrupt with the given parameters.
This essentially does the same as esp_intr_alloc, but allows specifying a register and mask combo. For shared
interrupts, the handler is only called if a read from the specified register, ANDed with the mask, returns non-
zero. By passing an interrupt status register address and a fitting mask, this can be used to accelerate interrupt
handling in the case a shared interrupt is triggered; by checking the interrupt statuses first, the code can decide
which ISRs can be skipped
Espressif Systems
intr_handler_t
*ret_handle)
tusmask,
intr_handler_t
*ret_handle)
1002
Submit Document Feedback
handler, void *arg,
intr_handle_t
handler, void *arg,
intr_handle_t
Release v4.4
Need help?
Do you have a question about the ESP32-S2 and is the answer not in the manual?
Questions and answers