diff --git a/.gitignore b/.gitignore index cc516db..ca0bf62 100644 --- a/.gitignore +++ b/.gitignore @@ -1,107 +1,111 @@ -# ---> C -# Prerequisites -*.d - -# Object files +.config *.o -*.ko -*.obj -*.elf +*.pyc -# Linker output -*.ilk -*.map -*.exp +# gtags +GTAGS +GRTAGS +GPATH -# Precompiled Headers -*.gch -*.pch +# emacs +.dir-locals.el -# Libraries -*.lib -*.a -*.la -*.lo +# emacs temp file suffixes +*~ +.#* +\#*# -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib +# eclipse setting +.settings -# Executables -*.exe -*.out -*.app -*.i*86 -*.x86_64 -*.hex +# MacOS directory files +.DS_Store -# Debug files -*.dSYM/ -*.su -*.idb -*.pdb +# cache dir +.cache/ -# Kernel Module Compile Results -*.mod* -*.cmd -.tmp_versions/ -modules.order -Module.symvers -Mkfile.old -dkms.conf +# Doc build artifacts +docs/_build/ +docs/doxygen_sqlite3.db -# ---> C++ -# Prerequisites -*.d +# Downloaded font files +docs/_static/DejaVuSans.ttf +docs/_static/NotoSansSC-Regular.otf -# Compiled Object files -*.slo -*.lo -*.o -*.obj +# Components Unit Test Apps files +components/**/build/ +components/**/build_*_*/ +components/**/sdkconfig +components/**/sdkconfig.old -# Precompiled Headers -*.gch -*.pch +# Example project files +examples/**/build/ +examples/**/build_*_*/ +examples/**/sdkconfig +examples/**/sdkconfig.old -# Compiled Dynamic libraries -*.so -*.dylib -*.dll +# Unit test app files +tools/unit-test-app/build +tools/unit-test-app/build_*_*/ +tools/unit-test-app/sdkconfig +tools/unit-test-app/sdkconfig.old -# Fortran module files -*.mod -*.smod +# test application build files +tools/test_apps/**/build/ +tools/test_apps/**/build_*_*/ +tools/test_apps/**/sdkconfig +tools/test_apps/**/sdkconfig.old -# Compiled Static libraries -*.lai -*.la -*.a -*.lib +TEST_LOGS/ +build_summary_*.xml -# Executables -*.exe -*.out -*.app +# gcov coverage reports +*.gcda +*.gcno +coverage.info +coverage_report/ -# ---> CMake -CMakeLists.txt.user -CMakeCache.txt -CMakeFiles -CMakeScripts -Testing -Makefile -cmake_install.cmake -install_manifest.txt -compile_commands.json -CTestTestfile.cmake -_deps -CMakeUserPresets.json +test_multi_heap_host -# Build directory +# VS Code Settings +.vscode/ + +# VIM files +*.swp +*.swo + +# Sublime Text files +*.sublime-project +*.sublime-workspace + +# Clion IDE CMake build & config +.idea/ +cmake-build-*/ + +# Results for the checking of the Python coding style and static analysis +.mypy_cache +flake8_output.txt + +# ESP-IDF default build directory name build -# unity-app directory -unity-app \ No newline at end of file +# lock files for examples and components +dependencies.lock + +# managed_components for examples +managed_components + +# pytest log +pytest-embedded/ +# legacy one +pytest_embedded_log/ +list_job*.txt +size_info*.txt +XUNIT_RESULT*.xml +.manifest_sha + +# clang config (for LSP) +.clangd + +# Vale +.vale/styles/* \ No newline at end of file diff --git a/src/relay_chn.c b/src/relay_chn.c index 64f28ed..eb882d0 100644 --- a/src/relay_chn.c +++ b/src/relay_chn.c @@ -15,6 +15,7 @@ #include #include #include "esp_err.h" +#include "esp_check.h" #include "esp_log.h" #include "esp_task.h" #include "driver/gpio.h" @@ -320,14 +321,14 @@ esp_err_t relay_chn_create(const gpio_num_t* gpio_map, uint8_t gpio_count) // Initialize the GPIOs ret = gpio_reset_pin(forward_pin); - ret |= gpio_set_direction(forward_pin, GPIO_MODE_OUTPUT); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO forward pin for channel %d", i); + ret = gpio_set_direction(forward_pin, GPIO_MODE_OUTPUT); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set GPIO direction for forward pin for channel %d", i); - ret |= gpio_reset_pin(reverse_pin); - ret |= gpio_set_direction(reverse_pin, GPIO_MODE_OUTPUT); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize GPIOs relay channel %d!", i); - return ret; - } + ret = gpio_reset_pin(reverse_pin); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to reset GPIO reverse pin for channel %d", i); + ret = gpio_set_direction(reverse_pin, GPIO_MODE_OUTPUT); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to set GPIO direction for reverse pin for channel %d", i); // Initialize the GPIOs // Initialize the relay channel @@ -339,22 +340,22 @@ esp_err_t relay_chn_create(const gpio_num_t* gpio_map, uint8_t gpio_count) relay_chn->state = RELAY_CHN_STATE_FREE; relay_chn->pending_cmd = RELAY_CHN_CMD_NONE; relay_chn->run_info.last_run_cmd = RELAY_CHN_CMD_NONE; - ret |= relay_chn_init_timer(relay_chn); // Create direction change inertia timer + ret = relay_chn_init_timer(relay_chn); // Create direction change inertia timer + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to create relay channel timer for channel %d", i); #if RELAY_CHN_ENABLE_TILTING == 1 - ret |= relay_chn_init_tilt_control(relay_chn); + ret = relay_chn_init_tilt_control(relay_chn); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize tilt control for channel %d", i); #endif - if (ret != ESP_OK) { - ESP_LOGE(TAG, "Failed to initialize relay channel %d!", i); - return ret; - } } // Create relay channel command event loop - ret |= relay_chn_create_event_loop(); + ret = relay_chn_create_event_loop(); + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to create relay channel event loop"); #if RELAY_CHN_ENABLE_TILTING == 1 // Must call after the event loop is initialized - ret |= relay_chn_tilt_init(); // Initialize tilt feature + ret = relay_chn_tilt_init(); // Initialize tilt feature + ESP_RETURN_ON_ERROR(ret, TAG, "Failed to initialize tilt feature"); #endif // Init the state listener manager