@@ -94,7 +94,7 @@ extern "C" {
9494 * the int can be left enabled while the flash cache is disabled.
9595 *
9696 * @return ESP_ERR_INVALID_ARG if cpu or intno is invalid
97- * ESP_OK otherwise
97+ * ESP_OK on success
9898 */
9999esp_err_t esp_intr_mark_shared (int intno , int cpu , bool is_in_iram );
100100
@@ -108,7 +108,7 @@ esp_err_t esp_intr_mark_shared(int intno, int cpu, bool is_in_iram);
108108 * @param cpu CPU on which the interrupt should be marked as shared (0 or 1)
109109 *
110110 * @return ESP_ERR_INVALID_ARG if cpu or intno is invalid
111- * ESP_OK otherwise
111+ * ESP_OK on success
112112 */
113113esp_err_t esp_intr_reserve (int intno , int cpu );
114114
@@ -131,9 +131,10 @@ esp_err_t esp_intr_reserve(int intno, int cpu);
131131 * @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
132132 * choice of interrupts that this routine can choose from. If this value
133133 * is 0, it will default to allocating a non-shared interrupt of level
134- * 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared
135- * interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
136- * from this function with the interrupt disabled.
134+ * 1, 2 or 3. If ESP_INTR_FLAG_SHARED mask is provided, a shared interrupt of
135+ * the given level will be allocated (or level 1 if not specified).
136+ * Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with the
137+ * interrupt disabled.
137138 * @param handler The interrupt handler. Must be NULL when an interrupt of level >3
138139 * is requested, because these types of interrupts aren't C-callable.
139140 * @param arg Optional argument for passed to the interrupt handler
@@ -143,13 +144,13 @@ esp_err_t esp_intr_reserve(int intno, int cpu);
143144 *
144145 * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
145146 * ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
146- * ESP_OK otherwise
147+ * ESP_OK on success
147148 */
148149esp_err_t esp_intr_alloc (int source , int flags , intr_handler_t handler , void * arg , intr_handle_t * ret_handle );
149150
150151
151152/**
152- * @brief Allocate an interrupt with the given parameters.
153+ * @brief Allocate an interrupt with the given parameters, including an interrupt status register .
153154 *
154155 *
155156 * This essentially does the same as esp_intr_alloc, but allows specifying a register and mask
@@ -165,9 +166,10 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar
165166 * @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
166167 * choice of interrupts that this routine can choose from. If this value
167168 * is 0, it will default to allocating a non-shared interrupt of level
168- * 1, 2 or 3. If this is ESP_INTR_FLAG_SHARED, it will allocate a shared
169- * interrupt of level 1. Setting ESP_INTR_FLAG_INTRDISABLED will return
170- * from this function with the interrupt disabled.
169+ * 1, 2 or 3. If ESP_INTR_FLAG_SHARED mask is provided, a shared interrupt of
170+ * the given level will be allocated (or level 1 if not specified).
171+ * Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with the
172+ * interrupt disabled.
171173 * @param intrstatusreg The address of an interrupt status register
172174 * @param intrstatusmask A mask. If a read of address intrstatusreg has any of the bits
173175 * that are 1 in the mask set, the ISR will be called. If not, it will be
@@ -181,11 +183,92 @@ esp_err_t esp_intr_alloc(int source, int flags, intr_handler_t handler, void *ar
181183 *
182184 * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
183185 * ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
184- * ESP_OK otherwise
186+ * ESP_OK on success
185187 */
186188esp_err_t esp_intr_alloc_intrstatus (int source , int flags , uint32_t intrstatusreg , uint32_t intrstatusmask , intr_handler_t handler , void * arg , intr_handle_t * ret_handle );
187189
188190
191+ /**
192+ * @brief Allocate an interrupt with the given parameters that can be bound to an existing interrupt handler.
193+ *
194+ *
195+ * This function does the same as esp_intr_alloc, but allows specifying a previously allocated handler as
196+ * the interrupt to share with the given source. This can be very handy to treat two pre-determined interrupt
197+ * sources in the same interrupt handler. The interrupt will be allocated on the same core as the given
198+ * `shared_handle`. Moreover, make sure to specify the same interrupt level as the one being used by `shared_handle`
199+ * to prevent any failure from this function.
200+ *
201+ * @param source The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux
202+ * sources, as defined in soc/soc.h, or one of the internal
203+ * ETS_INTERNAL_*_INTR_SOURCE sources as defined in this header.
204+ * @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
205+ * choice of interrupts that this routine can choose from. If this value
206+ * is 0, it will default to allocating a non-shared interrupt of level
207+ * 1, 2 or 3. If ESP_INTR_FLAG_SHARED mask is provided, a shared interrupt of
208+ * the given level will be allocated (or level 1 if not specified).
209+ * Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with the
210+ * interrupt disabled.
211+ * @param handler The interrupt handler. Must be NULL when an interrupt of level >3
212+ * is requested, because these types of interrupts aren't C-callable.
213+ * @param arg Optional argument for passed to the interrupt handler
214+ * @param shared_handle Previously allocated interrupt to share the CPU interrupt line with. If NULL,
215+ * calling this function equivalent to esp_intr_alloc, else, ESP_INTR_FLAG_SHARED must
216+ * be provided in the flags parameter.
217+ * @param ret_handle Pointer to an intr_handle_t to store a handle that can later be
218+ * used to request details or free the interrupt. Can be NULL if no handle
219+ * is required.
220+ *
221+ * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
222+ * ESP_ERR_NOT_FOUND No free interrupt found with the specified flasg or the given level is different
223+ * from the one assigned to the share_handle parameter.
224+ * ESP_OK on success
225+ */
226+ esp_err_t esp_intr_alloc_bind (int source , int flags , intr_handler_t handler , void * arg , intr_handle_t shared_handle , intr_handle_t * ret_handle );
227+
228+
229+ /**
230+ * @brief Allocate an interrupt with the given parameters, including an interrupt status register, that can
231+ * be bound to an existing interrupt handler
232+ *
233+ *
234+ * This function does the same as esp_intr_alloc_intrstatus, but allows specifying a previously allocated handler as
235+ * the interrupt to share with the given source. This can be very handy to treat two pre-determined interrupt
236+ * sources in the same interrupt handler. The interrupt will be allocated on the same core as the given
237+ * `shared_handle`. Moreover, make sure to specify the same interrupt level as the one being used by `shared_handle`
238+ * to prevent any failure from this function.
239+ *
240+ * @param source The interrupt source. One of the ETS_*_INTR_SOURCE interrupt mux
241+ * sources, as defined in soc/soc.h, or one of the internal
242+ * ETS_INTERNAL_*_INTR_SOURCE sources as defined in this header.
243+ * @param flags An ORred mask of the ESP_INTR_FLAG_* defines. These restrict the
244+ * choice of interrupts that this routine can choose from. If this value
245+ * is 0, it will default to allocating a non-shared interrupt of level
246+ * 1, 2 or 3. If ESP_INTR_FLAG_SHARED mask is provided, a shared interrupt of
247+ * the given level will be allocated (or level 1 if not specified).
248+ * Setting ESP_INTR_FLAG_INTRDISABLED will return from this function with the
249+ * interrupt disabled.
250+ * @param intrstatusreg The address of an interrupt status register
251+ * @param intrstatusmask A mask. If a read of address intrstatusreg has any of the bits
252+ * that are 1 in the mask set, the ISR will be called. If not, it will be
253+ * skipped.
254+ * @param handler The interrupt handler. Must be NULL when an interrupt of level >3
255+ * is requested, because these types of interrupts aren't C-callable.
256+ * @param arg Optional argument for passed to the interrupt handler
257+ * @param shared_handle Previously allocated interrupt to share the CPU interrupt line with. If NULL,
258+ * calling this function equivalent to esp_intr_alloc, else, ESP_INTR_FLAG_SHARED must
259+ * be provided in the flags parameter.
260+ * @param ret_handle Pointer to an intr_handle_t to store a handle that can later be
261+ * used to request details or free the interrupt. Can be NULL if no handle
262+ * is required.
263+ *
264+ * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
265+ * ESP_ERR_NOT_FOUND No free interrupt found with the specified flasg or the given level is different
266+ * from the one assigned to the share_handle parameter.
267+ * ESP_OK on success
268+ */
269+ esp_err_t esp_intr_alloc_intrstatus_bind (int source , int flags , uint32_t intrstatusreg , uint32_t intrstatusmask , intr_handler_t handler ,
270+ void * arg , intr_handle_t shared_handle , intr_handle_t * ret_handle );
271+
189272/**
190273 * @brief Disable and free an interrupt.
191274 *
@@ -202,7 +285,7 @@ esp_err_t esp_intr_alloc_intrstatus(int source, int flags, uint32_t intrstatusre
202285 *
203286 * @return ESP_ERR_INVALID_ARG the handle is NULL
204287 * ESP_FAIL failed to release this handle
205- * ESP_OK otherwise
288+ * ESP_OK on success
206289 */
207290esp_err_t esp_intr_free (intr_handle_t handle );
208291
@@ -239,7 +322,7 @@ int esp_intr_get_intno(intr_handle_t handle);
239322 * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
240323 *
241324 * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
242- * ESP_OK otherwise
325+ * ESP_OK on success
243326 */
244327esp_err_t esp_intr_disable (intr_handle_t handle );
245328
@@ -252,7 +335,7 @@ esp_err_t esp_intr_disable(intr_handle_t handle);
252335 * @param handle The handle, as obtained by esp_intr_alloc or esp_intr_alloc_intrstatus
253336 *
254337 * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
255- * ESP_OK otherwise
338+ * ESP_OK on success
256339 */
257340esp_err_t esp_intr_enable (intr_handle_t handle );
258341
@@ -266,7 +349,7 @@ esp_err_t esp_intr_enable(intr_handle_t handle);
266349 * Handlers residing in IRAM can be called when cache is disabled.
267350 *
268351 * @return ESP_ERR_INVALID_ARG if the combination of arguments is invalid.
269- * ESP_OK otherwise
352+ * ESP_OK on success
270353 */
271354esp_err_t esp_intr_set_in_iram (intr_handle_t handle , bool is_in_iram );
272355
0 commit comments