From 4bdf3a555ea17b543bbd9c91bd105e512703ab7b Mon Sep 17 00:00:00 2001 From: Liu Zhongwei Date: Tue, 5 Nov 2024 09:36:06 +0800 Subject: [PATCH] Upload to the ESP Registry and support to build on the esp-idf --- .codespellrc | 2 + .flake8 | 141 ++++++++++++++++++ ...heck_versions.sh => check_lib_versions.sh} | 46 +++--- .github/workflows/build_test.yml | 4 +- ...ck_versions.yml => check_lib_versions.yml} | 7 +- .github/workflows/issue_comment.yml | 24 +++ .github/workflows/new_issues.yml | 24 +++ .github/workflows/new_prs.yml | 29 ++++ .github/workflows/pre-commit.yml | 2 +- .github/workflows/upload_component.yml | 20 +++ .pre-commit-config.yaml | 95 +++++++++--- CHANGELOG.md | 7 + README.md | 24 ++- check_copyright_config.yaml | 11 +- idf_component.yml | 7 + library.properties | 2 +- src/base/esp_io_expander.h | 6 +- src/chip/HT8574.h | 2 +- src/chip/TCA95xx_16bit.h | 4 +- src/chip/TCA95xx_8bit.h | 4 +- test_apps/CMakeLists.txt | 3 +- test_apps/main/CMakeLists.txt | 2 +- test_apps/main/idf_component.yml | 8 +- ...t_ESP_IOExpander.cpp => test_app_main.cpp} | 0 test_apps/pytest_esp_io_expander.py | 11 -- test_apps/sdkconfig.defaults | 2 +- 26 files changed, 407 insertions(+), 80 deletions(-) create mode 100644 .codespellrc create mode 100644 .flake8 rename .github/scripts/{check_versions.sh => check_lib_versions.sh} (89%) mode change 100644 => 100755 rename .github/workflows/{check_versions.yml => check_lib_versions.yml} (84%) create mode 100644 .github/workflows/issue_comment.yml create mode 100644 .github/workflows/new_issues.yml create mode 100644 .github/workflows/new_prs.yml create mode 100644 .github/workflows/upload_component.yml create mode 100644 idf_component.yml rename test_apps/main/{test_ESP_IOExpander.cpp => test_app_main.cpp} (100%) delete mode 100644 test_apps/pytest_esp_io_expander.py diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..0a3c74d --- /dev/null +++ b/.codespellrc @@ -0,0 +1,2 @@ +[codespell] +skip = ./src/touch/base/esp_lcd_touch_xpt2046.c diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..648e169 --- /dev/null +++ b/.flake8 @@ -0,0 +1,141 @@ +[flake8] + +select = + # Full lists are given in order to suppress all errors from other plugins + # Full list of pyflakes error codes: + F401, # module imported but unused + F402, # import module from line N shadowed by loop variable + F403, # 'from module import *' used; unable to detect undefined names + F404, # future import(s) name after other statements + F405, # name may be undefined, or defined from star imports: module + F406, # 'from module import *' only allowed at module level + F407, # an undefined __future__ feature name was imported + F601, # dictionary key name repeated with different values + F602, # dictionary key variable name repeated with different values + F621, # too many expressions in an assignment with star-unpacking + F622, # two or more starred expressions in an assignment (a, *b, *c = d) + F631, # assertion test is a tuple, which are always True + F701, # a break statement outside of a while or for loop + F702, # a continue statement outside of a while or for loop + F703, # a continue statement in a finally block in a loop + F704, # a yield or yield from statement outside of a function + F705, # a return statement with arguments inside a generator + F706, # a return statement outside of a function/method + F707, # an except: block as not the last exception handler + F721, F722, # doctest syntax error syntax error in forward type annotation + F811, # redefinition of unused name from line N + F812, # list comprehension redefines name from line N + F821, # undefined name name + F822, # undefined name name in __all__ + F823, # local variable name referenced before assignment + F831, # duplicate argument name in function definition + F841, # local variable name is assigned to but never used + F901, # raise NotImplemented should be raise NotImplementedError + + # Full list of pycodestyle violations: + E101, # indentation contains mixed spaces and tabs + E111, # indentation is not a multiple of four + E112, # expected an indented block + E113, # unexpected indentation + E114, # indentation is not a multiple of four (comment) + E115, # expected an indented block (comment) + E116, # unexpected indentation (comment) + E121, # continuation line under-indented for hanging indent + E122, # continuation line missing indentation or outdented + E123, # closing bracket does not match indentation of opening bracket's line + E124, # closing bracket does not match visual indentation + E125, # continuation line with same indent as next logical line + E126, # continuation line over-indented for hanging indent + E127, # continuation line over-indented for visual indent + E128, # continuation line under-indented for visual indent + E129, # visually indented line with same indent as next logical line + E131, # continuation line unaligned for hanging indent + E133, # closing bracket is missing indentation + E201, # whitespace after '(' + E202, # whitespace before ')' + E203, # whitespace before ':' + E211, # whitespace before '(' + E221, # multiple spaces before operator + E222, # multiple spaces after operator + E223, # tab before operator + E224, # tab after operator + E225, # missing whitespace around operator + E226, # missing whitespace around arithmetic operator + E227, # missing whitespace around bitwise or shift operator + E228, # missing whitespace around modulo operator + E231, # missing whitespace after ',', ';', or ':' + E241, # multiple spaces after ',' + E242, # tab after ',' + E251, # unexpected spaces around keyword / parameter equals + E261, # at least two spaces before inline comment + E262, # inline comment should start with '# ' + E265, # block comment should start with '# ' + E266, # too many leading '#' for block comment + E271, # multiple spaces after keyword + E272, # multiple spaces before keyword + E273, # tab after keyword + E274, # tab before keyword + E275, # missing whitespace after keyword + E301, # expected 1 blank line, found 0 + E302, # expected 2 blank lines, found 0 + E303, # too many blank lines + E304, # blank lines found after function decorator + E305, # expected 2 blank lines after end of function or class + E306, # expected 1 blank line before a nested definition + E401, # multiple imports on one line + E402, # module level import not at top of file + E501, # line too long (82 > 79 characters) + E502, # the backslash is redundant between brackets + E701, # multiple statements on one line (colon) + E702, # multiple statements on one line (semicolon) + E703, # statement ends with a semicolon + E704, # multiple statements on one line (def) + E711, # comparison to None should be 'if cond is None:' + E712, # comparison to True should be 'if cond is True:' or 'if cond:' + E713, # test for membership should be 'not in' + E714, # test for object identity should be 'is not' + E721, # do not compare types, use 'isinstance()' + E722, # do not use bare except, specify exception instead + E731, # do not assign a lambda expression, use a def + E741, # do not use variables named 'l', 'O', or 'I' + E742, # do not define classes named 'l', 'O', or 'I' + E743, # do not define functions named 'l', 'O', or 'I' + E901, # SyntaxError or IndentationError + E902, # IOError + W191, # indentation contains tabs + W291, # trailing whitespace + W292, # no newline at end of file + W293, # blank line contains whitespace + W391, # blank line at end of file + W503, # line break before binary operator + W504, # line break after binary operator + W505, # doc line too long (82 > 79 characters) + W601, # .has_key() is deprecated, use 'in' + W602, # deprecated form of raising exception + W603, # '<>' is deprecated, use '!=' + W604, # backticks are deprecated, use 'repr()' + W605, # invalid escape sequence 'x' + W606, # 'async' and 'await' are reserved keywords starting with Python 3.7 + + # Full list of flake8 violations + E999, # failed to compile a file into an Abstract Syntax Tree for the plugins that require it + + # Full list of mccabe violations + C901 # complexity value provided by the user + +ignore = + E221, # multiple spaces before operator + E231, # missing whitespace after ',', ';', or ':' + E241, # multiple spaces after ',' + W503, # line break before binary operator + W504 # line break after binary operator + +max-line-length = 160 + +show_source = True + +statistics = True + +exclude = + .git, + __pycache__, diff --git a/.github/scripts/check_versions.sh b/.github/scripts/check_lib_versions.sh old mode 100644 new mode 100755 similarity index 89% rename from .github/scripts/check_versions.sh rename to .github/scripts/check_lib_versions.sh index d458178..cdfe6d8 --- a/.github/scripts/check_versions.sh +++ b/.github/scripts/check_lib_versions.sh @@ -13,26 +13,6 @@ check_version_format() { return 0 } -if [ $# -lt 1 ]; then - latest_version="0.0.0" - echo "Don't get the lastest version, use \"0.0.0\" as default" -else - # Get the first input parameter as the version to be compared - latest_version="$1" - # Check the version format - check_version_format "${latest_version}" - result=$? - if [ ${result} -ne 0 ]; then - echo "The latest release version (${latest_version}) format is incorrect." - exit 1 - fi -fi - -# Specify the directory path -target_directory="./" - -echo "Checking directory: ${target_directory}" - # Function: Check if a file exists # Input parameters: $1 The file to check # Return value: 0 if the file exists, 1 if the file does not exist @@ -68,6 +48,32 @@ compare_versions() { return 0 } +# Get the latest release version +latest_version="v0.0.0" +for i in "$@"; do + case $i in + --latest_version=*) + latest_version="${i#*=}" + shift + ;; + *) + ;; + esac +done +# Check the version format +check_version_format "${latest_version}" +result=$? +if [ ${result} -ne 0 ]; then + echo "The latest release version (${latest_version}) format is incorrect." + exit 1 +fi +echo "Get the latest release version: ${latest_version}" + +# Specify the directory path +target_directory="./" + +echo "Checking directory: ${target_directory}" + echo "Checking file: library.properties" # Check if "library.properties" file exists check_file_exists "${target_directory}/library.properties" diff --git a/.github/workflows/build_test.yml b/.github/workflows/build_test.yml index 9f1f2e9..61831e0 100644 --- a/.github/workflows/build_test.yml +++ b/.github/workflows/build_test.yml @@ -9,7 +9,7 @@ jobs: build: strategy: matrix: - idf_ver: ["v4.4.5", "v5.0", "v5.1"] + idf_ver: ["release-v5.1", "release-v5.2", "release-v5.3"] idf_target: ["esp32", "esp32s2", "esp32c3", "esp32s3"] runs-on: ubuntu-20.04 container: espressif/idf:${{ matrix.idf_ver }} @@ -25,4 +25,4 @@ jobs: export PEDANTIC_FLAGS="-DIDF_CI_BUILD -Werror -Werror=deprecated-declarations -Werror=unused-variable -Werror=unused-but-set-variable -Werror=unused-function" export EXTRA_CFLAGS="${PEDANTIC_FLAGS} -Wstrict-prototypes" export EXTRA_CXXFLAGS="${PEDANTIC_FLAGS}" - idf.py build \ No newline at end of file + idf.py build diff --git a/.github/workflows/check_versions.yml b/.github/workflows/check_lib_versions.yml similarity index 84% rename from .github/workflows/check_versions.yml rename to .github/workflows/check_lib_versions.yml index eb2d116..48a4899 100644 --- a/.github/workflows/check_versions.yml +++ b/.github/workflows/check_lib_versions.yml @@ -1,11 +1,11 @@ -name: Check Versions +name: Check Library Versions on: pull_request: types: [opened, reopened, synchronize] jobs: - check_versions: + check_lib_versions: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 @@ -26,5 +26,4 @@ jobs: echo "prerelease: ${{ steps.last_release.outputs.prerelease }}" echo "url: ${{ steps.last_release.outputs.url }}" - name: Check & Compare versions - run: bash ./.github/scripts/check_versions.sh ${{ steps.last_release.outputs.tag_name }} - + run: bash ./.github/scripts/check_lib_versions.sh --latest_version=${{ steps.last_release.outputs.tag_name }} diff --git a/.github/workflows/issue_comment.yml b/.github/workflows/issue_comment.yml new file mode 100644 index 0000000..3b6fcc1 --- /dev/null +++ b/.github/workflows/issue_comment.yml @@ -0,0 +1,24 @@ +name: Sync issue comments to JIRA + +# This workflow will be triggered when new issue comment is created (including PR comments) +on: issue_comment + +# Limit to single concurrent run for workflows which can create Jira issues. +# Same concurrency group is used in new_issues.yml +concurrency: jira_issues + +jobs: + sync_issue_comments_to_jira: + name: Sync Issue Comments to Jira + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Sync issue comments to JIRA + uses: espressif/github-actions/sync_issues_to_jira@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JIRA_PASS: ${{ secrets.JIRA_PASS }} + JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} + JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }} + JIRA_URL: ${{ secrets.JIRA_URL }} + JIRA_USER: ${{ secrets.JIRA_USER }} diff --git a/.github/workflows/new_issues.yml b/.github/workflows/new_issues.yml new file mode 100644 index 0000000..f0fa402 --- /dev/null +++ b/.github/workflows/new_issues.yml @@ -0,0 +1,24 @@ +name: Sync issues to Jira + +# This workflow will be triggered when a new issue is opened +on: issues + +# Limit to single concurrent run for workflows which can create Jira issues. +# Same concurrency group is used in issue_comment.yml +concurrency: jira_issues + +jobs: + sync_issues_to_jira: + name: Sync issues to Jira + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Sync GitHub issues to Jira project + uses: espressif/github-actions/sync_issues_to_jira@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JIRA_PASS: ${{ secrets.JIRA_PASS }} + JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} + JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }} + JIRA_URL: ${{ secrets.JIRA_URL }} + JIRA_USER: ${{ secrets.JIRA_USER }} diff --git a/.github/workflows/new_prs.yml b/.github/workflows/new_prs.yml new file mode 100644 index 0000000..01d7fe2 --- /dev/null +++ b/.github/workflows/new_prs.yml @@ -0,0 +1,29 @@ +name: Sync remain PRs to Jira + +# This workflow will be triggered every hour, to sync remaining PRs (i.e. PRs with zero comment) to Jira project +# Note that, PRs can also get synced when new PR comment is created +on: + schedule: + - cron: "0 * * * *" + +# Limit to single concurrent run for workflows which can create Jira issues. +# Same concurrency group is used in issue_comment.yml +concurrency: jira_issues + +jobs: + sync_prs_to_jira: + name: Sync PRs to Jira + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Sync PRs to Jira project + uses: espressif/github-actions/sync_issues_to_jira@master + with: + cron_job: true + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + JIRA_PASS: ${{ secrets.JIRA_PASS }} + JIRA_PROJECT: ${{ secrets.JIRA_PROJECT }} + JIRA_COMPONENT: ${{ secrets.JIRA_COMPONENT }} + JIRA_URL: ${{ secrets.JIRA_URL }} + JIRA_USER: ${{ secrets.JIRA_USER }} diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 51f77cd..7111ea9 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -11,4 +11,4 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: pre-commit/action@v2.0.3 \ No newline at end of file + - uses: pre-commit/action@v2.0.3 diff --git a/.github/workflows/upload_component.yml b/.github/workflows/upload_component.yml new file mode 100644 index 0000000..45e9b78 --- /dev/null +++ b/.github/workflows/upload_component.yml @@ -0,0 +1,20 @@ +name: Push components to Espressif Component Service + +on: + workflow_dispatch: + release: + types: [published] + +jobs: + upload_components: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@master + with: + submodules: 'recursive' + - name: Upload components to component service + uses: espressif/upload-components-ci-action@v1 + with: + name: "ESP32_IO_Expander" + namespace: "espressif" + api_token: ${{ secrets.IDF_COMPONENT_API_TOKEN }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8bb4083..9100936 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,25 +1,82 @@ +# See https://pre-commit.com for more information +# See https://pre-commit.com/hooks.html for more hooks + +exclude: 'libraries/ui/' repos: -- repo: https://github.com/igrr/astyle_py.git - rev: master + - repo: https://github.com/igrr/astyle_py.git + rev: v1.0.5 hooks: - - id: astyle_py + - id: astyle_py args: ['--style=otbs', '--attach-namespaces', '--attach-classes', '--indent=spaces=4', '--convert-tabs', '--align-pointer=name', '--align-reference=name', '--keep-one-line-statements', '--pad-header', '--pad-oper'] -- repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.3.0 + - repo: https://github.com/espressif/check-copyright/ + rev: v1.0.3 + hooks: + - id: check-copyright + args: ['--config', 'check_copyright_config.yaml'] + + - repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + types: [python] + args: ['--config=.flake8', '--tee', '--benchmark'] + + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 hooks: - - id: trailing-whitespace - types_or: [c, c++] - - id: end-of-file-fixer - types_or: [c, c++] - - id: check-merge-conflict - - id: mixed-line-ending - types_or: [c, c++] - args: ['--fix=lf'] - description: Forces to replace line ending by the UNIX 'lf' character + - id: trailing-whitespace + # note: whitespace exclusions use multiline regex, see https://pre-commit.com/#regular-expressions + # items are: + # 1 - some file extensions + # 2 - any file matching *test*/*expected* (for host tests, if possible use this naming pattern always) + # 3 - any file with known-warnings in the name + # 4 - any directory named 'testdata' + # 5 - protobuf auto-generated files + exclude: &whitespace_excludes | + (?x)^( + .+\.(md|rst|map|bin)| + .+test.*\/.*expected.*| + .+known-warnings.*| + .+\/testdata\/.+| + .*_pb2.py| + .*.pb-c.h| + .*.pb-c.c| + .*.yuv + )$ + - id: end-of-file-fixer + exclude: *whitespace_excludes + - id: check-executables-have-shebangs + - id: check-shebang-scripts-are-executable + - id: mixed-line-ending + args: ['-f=lf'] + - id: double-quote-string-fixer + - id: no-commit-to-branch + name: Do not use more than one slash in the branch name + args: ['--pattern', '^[^/]*/[^/]*/'] + - id: no-commit-to-branch + name: Do not use uppercase letters in the branch name + args: ['--pattern', '^[^A-Z]*[A-Z]'] -- repo: https://github.com/espressif/check-copyright/ - rev: v1.0.3 - hooks: - - id: check-copyright - args: ['--config', 'check_copyright_config.yaml'] \ No newline at end of file + - repo: https://github.com/espressif/conventional-precommit-linter + rev: v1.8.0 + hooks: + - id: conventional-precommit-linter + stages: [commit-msg] + args: + - --subject-min-length=15 + - --body-max-line-length=200 + + - repo: https://github.com/codespell-project/codespell + rev: v2.3.0 + hooks: + - id: codespell + args: ['-w' , '--config', '.codespellrc'] + + - repo: local + hooks: + - id: check-library-versions + name: Check library versions + entry: ./.github/scripts/check_lib_versions.sh + language: system + files: '(idf_component.yml|library.properties)' diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c4e4d1..a7ec7f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # ChangeLog +## v0.1.0 - 2024-11-05 + +### Enhancements: + +* Upload to the ESP Registry and support to build on the esp-idf +* Update pre-commit configuration + ## v0.0.4 - 2024-10-18 ### Enhancements: diff --git a/README.md b/README.md index fe8ae4c..81ccad3 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,21 @@ [![Arduino Lint](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/arduino_lint.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/arduino_lint.yml) [![pre-commit](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/pre-commit.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/pre-commit.yml) [![Build Test Apps](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/build_test.yml/badge.svg)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/actions/workflows/build_test.yml) +**Latest Arduino Library Version**: [![GitHub Release](https://img.shields.io/github/v/release/esp-arduino-libs/ESP32_IO_Expander)](https://github.com/esp-arduino-libs/ESP32_IO_Expander/releases) + +**Latest Espressif Component Version**: [![Espressif Release](https://components.espressif.com/components/espressif/ESP32_IO_Expander/badge.svg)](https://components.espressif.com/components/espressif/ESP32_IO_Expander) + # ESP32_IO_Expander -ESP32_IO_Expander is an Arduino library designed for driving [IO expander chips](#supported-drivers) using ESP32 SoCs. +ESP32_IO_Expander is a library designed for driving [IO expander chips](#supported-drivers) using ESP32 SoCs. -ESP32_IO_Expander encapsulates various components from the [Espressif Components Registry](https://components.espressif.com/). It is developed based on [arduino-esp32](https://github.com/espressif/arduino-esp32) and can be easily downloaded and integrated into the Arduino IDE. +ESP32_IO_Expander encapsulates various components from the [Espressif Components Registry](https://components.espressif.com/). It is developed based on [arduino-esp32](https://github.com/espressif/arduino-esp32) or [esp-idf](https://github.com/espressif/esp-idf), and can be easily downloaded and integrated into the Arduino IDE. ## Features * Supports various IO expander chips. * Supports controlling individual IO pin (using pinMode(), digitalRead(), and digitalWrite() functions). * Supports controlling multiple IO pins simultaneously. +* Supports building on the Arduino IDE and the ESP-IDF framework. ## Supported Drivers @@ -24,9 +29,17 @@ ESP32_IO_Expander encapsulates various components from the [Espressif Components ## Dependencies Version +### Arduino + | **Name** | **Version** | | ----------------------------------------------------------- | ----------- | -| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v2.0.9 | +| [arduino-esp32](https://github.com/espressif/arduino-esp32) | >= v3.0.0 | + +### ESP-IDF + +| **Name** | **Version** | +| ----------------------------------------------- | ----------- | +| [esp-idf](https://github.com/espressif/esp-idf) | >= v5.1 | ## How to Use @@ -35,15 +48,18 @@ For information on how to use the library in the Arduino IDE, please refer to th ### Examples * [Test Functions](examples/TestFunctions): Demonstrates how to use ESP32_IO_Expander and test all functions. +* [Test CH422G](examples/TestCH422G): Demonstrates how to use ESP32_IO_Expander with the CH422G chip. ### Detailed Usage ```cpp #include -// Create an ESP_IOExpander object according to the chip type +// Create and initialize an ESP_IOExpander object according to the chip type ESP_IOExpander *expander = new ESP_IOExpander_TCA95xx_8bit(EXAMPLE_I2C_NUM_0, ESP_IO_EXPANDER_I2C_TCA9554_ADDRESS_000, EXAMPLE_I2C_SCL_PIN, EXAMPLE_I2C_SDA_PIN); +expander->init(); +expander->begin(); // Control a single pin (0-31) expander->pinMode(0, OUTPUT); diff --git a/check_copyright_config.yaml b/check_copyright_config.yaml index d0c1e09..78761a6 100644 --- a/check_copyright_config.yaml +++ b/check_copyright_config.yaml @@ -7,6 +7,7 @@ DEFAULT: # when setting this option in a section, you need to list all the allowed licenses allowed_licenses: - Apache-2.0 + - MIT license_for_new_files: Apache-2.0 # license to be used when inserting a new copyright notice new_notice_c: | # notice for new C, CPP, H, HPP and LD files /* @@ -28,14 +29,14 @@ DEFAULT: # You can create your own rules for files or group of files examples_and_unit_tests: include: - - 'test_apps/' + - 'test_apps/' + - 'examples/' allowed_licenses: - Apache-2.0 - Unlicense - CC0-1.0 license_for_new_files: CC0-1.0 -ignore: # You can also select ignoring files here - perform_check: no # Don't check files from that block - include: - - 'examples/' \ No newline at end of file +# ignore: # You can also select ignoring files here +# perform_check: no # Don't check files from that block +# include: diff --git a/idf_component.yml b/idf_component.yml new file mode 100644 index 0000000..c503891 --- /dev/null +++ b/idf_component.yml @@ -0,0 +1,7 @@ +version: "0.1.0" +description: ESP32_IO_Expander is a library designed for driving IO expander chips using ESP32 SoCs +url: https://github.com/esp-arduino-libs/ESP32_IO_Expander +repository: https://github.com/esp-arduino-libs/ESP32_IO_Expander.git +issues: https://github.com/esp-arduino-libs/ESP32_IO_Expander/issues +dependencies: + idf: ">=5.1" diff --git a/library.properties b/library.properties index cc76fb7..3ff246e 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=ESP32_IO_Expander -version=0.0.4 +version=0.1.0 author=espressif maintainer=espressif sentence=ESP32_IO_Expander is a library designed for driving IO expander chips using ESP32 SoCs diff --git a/src/base/esp_io_expander.h b/src/base/esp_io_expander.h index bd6d71c..da6e121 100644 --- a/src/base/esp_io_expander.h +++ b/src/base/esp_io_expander.h @@ -69,7 +69,7 @@ typedef enum { */ typedef enum { IO_EXPANDER_INPUT, /*!< Input direction */ - IO_EXPANDER_OUTPUT, /*!< Output dircetion */ + IO_EXPANDER_OUTPUT, /*!< Output direction */ } esp_io_expander_dir_t; /** @@ -134,7 +134,7 @@ struct esp_io_expander_s { /** * @brief Write value to direction register (mandatory) * - * @note The value represents the diection of IO + * @note The value represents the direction of IO * @note If there are multiple input registers in the device, their values should be spliced together in order to form the `value`. * * @param handle: IO Expander handle @@ -215,7 +215,7 @@ esp_err_t esp_io_expander_set_dir(esp_io_expander_handle_t handle, uint32_t pin_ esp_err_t esp_io_expander_set_level(esp_io_expander_handle_t handle, uint32_t pin_num_mask, uint8_t level); /** - * @brief Get the intput level of a set of target IOs + * @brief Get the input level of a set of target IOs * * @note This function can be called whenever target IOs are in input mode or output mode * diff --git a/src/chip/HT8574.h b/src/chip/HT8574.h index 54f8840..00ef52e 100644 --- a/src/chip/HT8574.h +++ b/src/chip/HT8574.h @@ -76,7 +76,7 @@ class ESP_IOExpander_HT8574: public ESP_IOExpander { * | 0 | 1 | 1 | 1 | A2 | A1 | A0 | R/W | * └─────┘─────┘─────┘─────┘─────┘─────┘─────┘─────┘ * └────────┯────────┘ └─────┯──────┘ - * (Fixed) (Hareware Selectable) + * (Fixed) (Hardware Selectable) * * And the 7-bit slave address is the most important data for users. * For example, if a chip's A0,A1,A2 are connected to GND, it's 7-bit slave address is 0111000b(0x38). diff --git a/src/chip/TCA95xx_16bit.h b/src/chip/TCA95xx_16bit.h index 795f2b4..e3e110d 100644 --- a/src/chip/TCA95xx_16bit.h +++ b/src/chip/TCA95xx_16bit.h @@ -76,7 +76,7 @@ class ESP_IOExpander_TCA95xx_16bit: public ESP_IOExpander { * | 1 | 1 | 1 | 0 | 1 | A1 | A0 | R/W | * └─────┘─────┘─────┘─────┘─────┘─────┘─────┘─────┘ * └────────┯──────────────┘ └──┯──┘ - * (Fixed) (Hareware Selectable) + * (Fixed) (Hardware Selectable) * * The 8-bit address format for the TCA9555 is as follows: * @@ -86,7 +86,7 @@ class ESP_IOExpander_TCA95xx_16bit: public ESP_IOExpander { * | 0 | 1 | 0 | 0 | A2 | A1 | A0 | R/W | * └─────┘─────┘─────┘─────┘─────┘─────┘─────┘─────┘ * └────────┯────────┘ └─────┯──────┘ - * (Fixed) (Hareware Selectable) + * (Fixed) (Hardware Selectable) * * And the 7-bit slave address is the most important data for users. * For example, if a TCA9555 chip's A0,A1,A2 are connected to GND, it's 7-bit slave address is 0b0100000. diff --git a/src/chip/TCA95xx_8bit.h b/src/chip/TCA95xx_8bit.h index db061b5..bab368a 100644 --- a/src/chip/TCA95xx_8bit.h +++ b/src/chip/TCA95xx_8bit.h @@ -76,7 +76,7 @@ class ESP_IOExpander_TCA95xx_8bit: public ESP_IOExpander { * | 0 | 1 | 0 | 0 | A2 | A1 | A0 | R/W | * └─────┘─────┘─────┘─────┘─────┘─────┘─────┘─────┘ * └────────┯────────┘ └─────┯──────┘ - * (Fixed) (Hareware Selectable) + * (Fixed) (Hardware Selectable) * * And the 7-bit slave address is the most important data for users. * For example, if a chip's A0,A1,A2 are connected to GND, it's 7-bit slave address is 0100000b(0x20). @@ -103,7 +103,7 @@ class ESP_IOExpander_TCA95xx_8bit: public ESP_IOExpander { * | 0 | 1 | 1 | 1 | A2 | A1 | A0 | R/W | * └─────┘─────┘─────┘─────┘─────┘─────┘─────┘─────┘ * └────────┯────────┘ └─────┯──────┘ - * (Fixed) (Hareware Selectable) + * (Fixed) (Hardware Selectable) * * And the 7-bit slave address is the most important data for users. * For example, if a chip's A0,A1,A2 are connected to GND, it's 7-bit slave address is 0111000b(0x38). diff --git a/test_apps/CMakeLists.txt b/test_apps/CMakeLists.txt index 19ad7fd..6850cc5 100644 --- a/test_apps/CMakeLists.txt +++ b/test_apps/CMakeLists.txt @@ -1,6 +1,5 @@ # The following lines of boilerplate have to be in your project's CMakeLists # in this exact order for cmake to work correctly cmake_minimum_required(VERSION 3.5) -set(EXTRA_COMPONENT_DIRS "$ENV{IDF_PATH}/tools/unit-test-app/components" "../") include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(panel_io_3wire_spi_test) \ No newline at end of file +project(io_expander_test) diff --git a/test_apps/main/CMakeLists.txt b/test_apps/main/CMakeLists.txt index e06a302..d833001 100644 --- a/test_apps/main/CMakeLists.txt +++ b/test_apps/main/CMakeLists.txt @@ -1,3 +1,3 @@ -idf_component_register(SRCS "test_ESP_IOExpander.cpp") +idf_component_register(SRCS "test_app_main.cpp") target_compile_options(${COMPONENT_LIB} PRIVATE -Wno-missing-field-initializers) diff --git a/test_apps/main/idf_component.yml b/test_apps/main/idf_component.yml index 29cf227..c6e36a8 100644 --- a/test_apps/main/idf_component.yml +++ b/test_apps/main/idf_component.yml @@ -1,3 +1,9 @@ ## IDF Component Manager Manifest File dependencies: - idf: ">=4.4" \ No newline at end of file + test_utils: + path: ${IDF_PATH}/tools/unit-test-app/components/test_utils + test_driver_utils: + path: ${IDF_PATH}/components/driver/test_apps/components/test_driver_utils + ESP32_IO_Expander: + version: "*" + override_path: "../../../ESP32_IO_Expander" diff --git a/test_apps/main/test_ESP_IOExpander.cpp b/test_apps/main/test_app_main.cpp similarity index 100% rename from test_apps/main/test_ESP_IOExpander.cpp rename to test_apps/main/test_app_main.cpp diff --git a/test_apps/pytest_esp_io_expander.py b/test_apps/pytest_esp_io_expander.py deleted file mode 100644 index 7c39966..0000000 --- a/test_apps/pytest_esp_io_expander.py +++ /dev/null @@ -1,11 +0,0 @@ -# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: CC0-1.0 - -import pytest -from pytest_embedded import Dut - -@pytest.mark.target('esp32s3') -@pytest.mark.env('esp32_s3_lcd_ev_board') -def test_usb_stream(dut: Dut)-> None: - dut.run_all_single_board_cases() - diff --git a/test_apps/sdkconfig.defaults b/test_apps/sdkconfig.defaults index 1e8cdb8..f61533c 100644 --- a/test_apps/sdkconfig.defaults +++ b/test_apps/sdkconfig.defaults @@ -7,4 +7,4 @@ CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096 # For IDF4.4 CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y -CONFIG_ESP_TASK_WDT=n \ No newline at end of file +CONFIG_ESP_TASK_WDT=n