Function esp_idf_hal::sys::esp_intr_alloc
source · pub unsafe extern "C" fn esp_intr_alloc(
source: i32,
flags: i32,
handler: Option<unsafe extern "C" fn(_: *mut c_void)>,
arg: *mut c_void,
ret_handle: *mut *mut intr_handle_data_t,
) -> i32
Expand description
@brief 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.
@param 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_INTERNALINTR_SOURCE sources as defined in this header. @param flags An ORred mask of the ESP_INTR_FLAG* defines. These restrict the choice of interrupts 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 interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with the interrupt disabled. @param handler The interrupt handler. Must be NULL when an interrupt of level >3 is requested, because these types of interrupts aren’t C-callable. @param arg Optional argument for passed to the interrupt handler @param 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.
@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