| 372 | } |
| 373 | |
| 374 | inline int enable_handler(const isr_handle_t& handle) FL_NOEXCEPT { |
| 375 | if (!handle.is_valid() || handle.platform_id != ESP32_PLATFORM_ID) { |
| 376 | ESP_LOGW(ESP32_ISR_TAG, "enableHandler: invalid handle"); |
| 377 | return -1; // Invalid handle |
| 378 | } |
| 379 | |
| 380 | esp32_isr_handle_data* handle_data = static_cast<esp32_isr_handle_data*>(handle.platform_handle); |
| 381 | if (!handle_data) { |
| 382 | ESP_LOGW(ESP32_ISR_TAG, "enableHandler: null handle data"); |
| 383 | return -1; // Invalid handle |
| 384 | } |
| 385 | |
| 386 | if (handle_data->is_timer && handle_data->timer_handle) { |
| 387 | esp_err_t ret = gptimer_start(handle_data->timer_handle); |
| 388 | if (ret != ESP_OK && ret != ESP_ERR_INVALID_STATE) { |
| 389 | ESP_LOGW(ESP32_ISR_TAG, "enableHandler: gptimer_start failed: %s", esp_err_to_name(ret)); |
| 390 | return -12; // Enable failed |
| 391 | } |
| 392 | handle_data->is_enabled = true; |
| 393 | } else if (!handle_data->is_timer && handle_data->gpio_pin != 0xFF) { |
| 394 | esp_err_t ret = gpio_intr_enable(static_cast<gpio_num_t>(handle_data->gpio_pin)); |
| 395 | if (ret != ESP_OK) { |
| 396 | ESP_LOGW(ESP32_ISR_TAG, "enableHandler: gpio_intr_enable failed: %s", esp_err_to_name(ret)); |
| 397 | return -14; |
| 398 | } |
| 399 | handle_data->is_enabled = true; |
| 400 | } |
| 401 | |
| 402 | return 0; // Success |
| 403 | } |
| 404 | |
| 405 | inline int disable_handler(const isr_handle_t& handle) FL_NOEXCEPT { |
| 406 | if (!handle.is_valid() || handle.platform_id != ESP32_PLATFORM_ID) { |
nothing calls this directly
no test coverage detected