@@ -491,15 +491,21 @@ esp_err_t gpio_isr_handler_remove(gpio_num_t gpio_num)
491
491
492
492
void gpio_uninstall_isr_service (void )
493
493
{
494
+ gpio_isr_func_t * gpio_isr_func_free = NULL ;
495
+ gpio_isr_handle_t gpio_isr_handle_free = NULL ;
496
+ portENTER_CRITICAL (& gpio_context .gpio_spinlock );
494
497
if (gpio_context .gpio_isr_func == NULL ) {
498
+ portEXIT_CRITICAL (& gpio_context .gpio_spinlock );
495
499
return ;
496
500
}
497
- portENTER_CRITICAL (& gpio_context .gpio_spinlock );
498
- esp_intr_free (gpio_context .gpio_isr_handle );
499
- free (gpio_context .gpio_isr_func );
501
+ gpio_isr_func_free = gpio_context .gpio_isr_func ;
500
502
gpio_context .gpio_isr_func = NULL ;
503
+ gpio_isr_handle_free = gpio_context .gpio_isr_handle ;
504
+ gpio_context .gpio_isr_handle = NULL ;
501
505
gpio_context .isr_core_id = GPIO_ISR_CORE_ID_UNINIT ;
502
506
portEXIT_CRITICAL (& gpio_context .gpio_spinlock );
507
+ esp_intr_free (gpio_isr_handle_free );
508
+ free (gpio_isr_func_free );
503
509
return ;
504
510
}
505
511
@@ -532,7 +538,12 @@ esp_err_t gpio_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags,
532
538
#else /* CONFIG_FREERTOS_UNICORE */
533
539
ret = esp_ipc_call_blocking (gpio_context .isr_core_id , gpio_isr_register_on_core_static , (void * )& p );
534
540
#endif /* !CONFIG_FREERTOS_UNICORE */
535
- if (ret != ESP_OK || p .ret != ESP_OK ) {
541
+ if (ret != ESP_OK ) {
542
+ ESP_LOGE (GPIO_TAG , "esp_ipc_call_blocking failed (0x%x)" , ret );
543
+ return ESP_ERR_NOT_FOUND ;
544
+ }
545
+ if (p .ret != ESP_OK ) {
546
+ ESP_LOGE (GPIO_TAG , "esp_intr_alloc failed (0x%x)" , p .ret );
536
547
return ESP_ERR_NOT_FOUND ;
537
548
}
538
549
return ESP_OK ;
0 commit comments