From 89a6a8b0194846e8d68024bed4d3587fca92045d Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 25 Apr 2024 14:07:38 -0700 Subject: [PATCH] Add silent timeout macro for ESP32 debug error check (#801) --- src/internal/NeoUtil.h | 18 ++++++++++++++++++ src/internal/methods/NeoEsp32RmtMethod.h | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/internal/NeoUtil.h b/src/internal/NeoUtil.h index 575f9fc..8f69c42 100644 --- a/src/internal/NeoUtil.h +++ b/src/internal/NeoUtil.h @@ -26,6 +26,24 @@ License along with NeoPixel. If not, see #pragma once +#ifdef ARDUINO_ARCH_ESP32 +#if defined NDEBUG || defined CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT +#define ESP_ERROR_CHECK_WITHOUT_ABORT_SILENT_TIMEOUT(x) ({ \ + esp_err_t err_rc_ = (x); \ + err_rc_; \ + }) +#else +#define ESP_ERROR_CHECK_WITHOUT_ABORT_SILENT_TIMEOUT(x) ({ \ + esp_err_t err_rc_ = (x); \ + if (unlikely(err_rc_ != ESP_OK && err_rc_ != ESP_ERR_TIMEOUT)) { \ + _esp_error_check_failed_without_abort(err_rc_, __FILE__, __LINE__, \ + __ASSERT_FUNC, #x); \ + } \ + err_rc_; \ + }) +#endif // NDEBUG +#endif // ARDUINO_ARCH_ESP32 + // some platforms do not come with STL or properly defined one, specifically functional // if you see... // undefined reference to `std::__throw_bad_function_call()' diff --git a/src/internal/methods/NeoEsp32RmtMethod.h b/src/internal/methods/NeoEsp32RmtMethod.h index 5c27b1a..a15f4fa 100644 --- a/src/internal/methods/NeoEsp32RmtMethod.h +++ b/src/internal/methods/NeoEsp32RmtMethod.h @@ -594,10 +594,9 @@ public: free(_dataSending); } - bool IsReadyToUpdate() const { - return (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT(rmt_wait_tx_done(_channel.RmtChannelNumber, 0))); + return (ESP_OK == ESP_ERROR_CHECK_WITHOUT_ABORT_SILENT_TIMEOUT(rmt_wait_tx_done(_channel.RmtChannelNumber, 0))); } void Initialize()