Compare commits
No commits in common. "master" and "wipper-3.2.0-idf-5.4" have entirely different histories.
master
...
wipper-3.2
493 changed files with 5733 additions and 29431 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
[codespell]
|
[codespell]
|
||||||
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
|
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
|
||||||
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
|
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
|
||||||
ignore-words-list = ba,licence,ot,dout,als,exten,emac
|
ignore-words-list = ba,licence,ot,dout,als,exten
|
||||||
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore,boards.txt,platform.txt,programmers.txt
|
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore,boards.txt,platform.txt,programmers.txt
|
||||||
builtin = clear,informal,en-GB_to_en-US
|
builtin = clear,informal,en-GB_to_en-US
|
||||||
check-filenames =
|
check-filenames =
|
||||||
|
|
|
||||||
81
.github/CODEOWNERS
vendored
81
.github/CODEOWNERS
vendored
|
|
@ -1,81 +0,0 @@
|
||||||
# CODEOWNERS for ESP32 Arduino Core
|
|
||||||
|
|
||||||
# This file is used to specify the code owners for the ESP32 Arduino Core.
|
|
||||||
# Read more about CODEOWNERS:
|
|
||||||
# https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners
|
|
||||||
# Note that order matters. The last matching pattern will be used.
|
|
||||||
|
|
||||||
# The default owners are the active developers of the ESP32 Arduino Core.
|
|
||||||
# Refrain from using @espressif/arduino-esp32 to avoid spamming non-developers with review requests.
|
|
||||||
* @espressif/arduino-devs
|
|
||||||
|
|
||||||
# CI
|
|
||||||
/.github/ @lucasssvaz @me-no-dev @P-R-O-C-H-Y
|
|
||||||
/.github/codeql/ @lucasssvaz
|
|
||||||
/.gitlab/ @lucasssvaz
|
|
||||||
/tests/ @lucasssvaz @P-R-O-C-H-Y
|
|
||||||
|
|
||||||
# Tools
|
|
||||||
/tools/ @me-no-dev
|
|
||||||
/tools/pre-commit/ @lucasssvaz
|
|
||||||
/tools/add_lib.sh @P-R-O-C-H-Y
|
|
||||||
|
|
||||||
# Pre-commit
|
|
||||||
/.* @lucasssvaz # Files in root directory that start with a dot.
|
|
||||||
|
|
||||||
# Git Files
|
|
||||||
/.gitignore @espressif/arduino-devs
|
|
||||||
/.gitmodules @espressif/arduino-devs
|
|
||||||
|
|
||||||
# Documentation
|
|
||||||
/docs/ @pedrominatel
|
|
||||||
/.github/ISSUE_TEMPLATE/ @pedrominatel
|
|
||||||
/.github/PULL_REQUEST_TEMPLATE.md @pedrominatel
|
|
||||||
/.readthedocs.yaml @pedrominatel
|
|
||||||
/*.md @pedrominatel
|
|
||||||
|
|
||||||
# Boards
|
|
||||||
/variants/ @P-R-O-C-H-Y
|
|
||||||
/boards.txt @P-R-O-C-H-Y
|
|
||||||
|
|
||||||
# Arduino as Component
|
|
||||||
/idf_component_examples/ @SuGlider
|
|
||||||
/idf_component.yml @SuGlider @me-no-dev
|
|
||||||
/CMakeLists.txt @SuGlider @me-no-dev
|
|
||||||
/Kconfig.projbuild @SuGlider @me-no-dev
|
|
||||||
|
|
||||||
# Build System
|
|
||||||
/package.json @me-no-dev
|
|
||||||
/platform.txt @me-no-dev
|
|
||||||
/programmers.txt @me-no-dev
|
|
||||||
/package/ @me-no-dev
|
|
||||||
|
|
||||||
# Libraries
|
|
||||||
/libraries/ArduinoOTA/ @me-no-dev
|
|
||||||
/libraries/AsyncUDP/ @me-no-dev
|
|
||||||
/libraries/BLE/ @lucasssvaz @SuGlider
|
|
||||||
/libraries/ESP_I2S/ @me-no-dev
|
|
||||||
/libraries/ESP_NOW/ @P-R-O-C-H-Y @lucasssvaz
|
|
||||||
/libraries/ESP_SR/ @me-no-dev
|
|
||||||
/libraries/ESPmDNS/ @me-no-dev
|
|
||||||
/libraries/Ethernet/ @me-no-dev
|
|
||||||
/libraries/Matter/ @SuGlider
|
|
||||||
/libraries/NetBIOS/ @me-no-dev
|
|
||||||
/libraries/Network/ @me-no-dev
|
|
||||||
/libraries/OpenThread/ @SuGlider
|
|
||||||
/libraries/PPP/ @me-no-dev
|
|
||||||
/libraries/SPI/ @me-no-dev
|
|
||||||
/libraries/Update/ @me-no-dev
|
|
||||||
/libraries/USB/ @SuGlider @me-no-dev
|
|
||||||
/libraries/WiFi/ @me-no-dev
|
|
||||||
/libraries/WiFiProv/ @me-no-dev
|
|
||||||
/libraries/Wire/ @me-no-dev
|
|
||||||
/libraries/Zigbee/ @P-R-O-C-H-Y
|
|
||||||
|
|
||||||
# CI JSON
|
|
||||||
# Keep this after other libraries and tests to avoid being overridden.
|
|
||||||
**/ci.json @lucasssvaz
|
|
||||||
|
|
||||||
# The CODEOWNERS file should be owned by the developers of the ESP32 Arduino Core.
|
|
||||||
# Leave this entry as the last one to avoid being overridden.
|
|
||||||
/.github/CODEOWNERS @espressif/arduino-devs
|
|
||||||
1
.github/ISSUE_TEMPLATE/Feature-request.yml
vendored
1
.github/ISSUE_TEMPLATE/Feature-request.yml
vendored
|
|
@ -5,7 +5,6 @@ body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
* Please note that we can only process feature requests reported in English to ensure effective communication and support. Feature requests written in other languages will be closed, with a request to rewrite them in English.
|
|
||||||
* We welcome any ideas or feature requests! It is helpful if you can explain exactly why the feature would be useful.
|
* We welcome any ideas or feature requests! It is helpful if you can explain exactly why the feature would be useful.
|
||||||
* There are usually some outstanding feature requests in the [existing issues list](https://github.com/espressif/arduino-esp32/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature+request%22), feel free to add comments to them.
|
* There are usually some outstanding feature requests in the [existing issues list](https://github.com/espressif/arduino-esp32/issues?q=is%3Aopen+is%3Aissue+label%3A%22Type%3A+Feature+request%22), feel free to add comments to them.
|
||||||
* If you would like to contribute, please read the [contributions guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html).
|
* If you would like to contribute, please read the [contributions guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html).
|
||||||
|
|
|
||||||
19
.github/ISSUE_TEMPLATE/Issue-report.yml
vendored
19
.github/ISSUE_TEMPLATE/Issue-report.yml
vendored
|
|
@ -5,7 +5,6 @@ body:
|
||||||
- type: markdown
|
- type: markdown
|
||||||
attributes:
|
attributes:
|
||||||
value: |
|
value: |
|
||||||
* Please note that we can only process issues reported in English to ensure effective communication and support. Issues written in other languages will be closed, with a request to rewrite them in English.
|
|
||||||
* Before reporting a new issue please check and search in [List of existing issues](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue)
|
* Before reporting a new issue please check and search in [List of existing issues](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue)
|
||||||
* Please check [Online Documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/index.html)
|
* Please check [Online Documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/index.html)
|
||||||
* Take a look on [Troubleshooting guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
|
* Take a look on [Troubleshooting guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
|
||||||
|
|
@ -40,13 +39,8 @@ body:
|
||||||
label: Version
|
label: Version
|
||||||
description: What version of Arduino ESP32 are you running? If possible, consider updating to the latest version.
|
description: What version of Arduino ESP32 are you running? If possible, consider updating to the latest version.
|
||||||
options:
|
options:
|
||||||
- latest stable Release (if not listed below)
|
|
||||||
- latest development Release Candidate (RC-X)
|
|
||||||
- latest master (checkout manually)
|
- latest master (checkout manually)
|
||||||
- v3.3.0
|
- latest development Release Candidate (RC-X)
|
||||||
- v3.2.1
|
|
||||||
- v3.2.0
|
|
||||||
- v3.1.3
|
|
||||||
- v3.1.2
|
- v3.1.2
|
||||||
- v3.1.1
|
- v3.1.1
|
||||||
- v3.1.0
|
- v3.1.0
|
||||||
|
|
@ -80,17 +74,6 @@ body:
|
||||||
- other
|
- other
|
||||||
validations:
|
validations:
|
||||||
required: true
|
required: true
|
||||||
- type: dropdown
|
|
||||||
id: type
|
|
||||||
attributes:
|
|
||||||
label: Type
|
|
||||||
description: How would you define the type of the issue? Please select from the types below.
|
|
||||||
options:
|
|
||||||
- Task
|
|
||||||
- Bug
|
|
||||||
- Question
|
|
||||||
validations:
|
|
||||||
required: true
|
|
||||||
- type: input
|
- type: input
|
||||||
id: IDE
|
id: IDE
|
||||||
attributes:
|
attributes:
|
||||||
|
|
|
||||||
3
.github/ISSUE_TEMPLATE/config.yml
vendored
3
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -3,3 +3,6 @@ contact_links:
|
||||||
- name: Arduino Core for Espressif Discord Server
|
- name: Arduino Core for Espressif Discord Server
|
||||||
url: https://discord.gg/8xY6e9crwv
|
url: https://discord.gg/8xY6e9crwv
|
||||||
about: Community Discord server for questions and help
|
about: Community Discord server for questions and help
|
||||||
|
- name: ESP32 Forum - Arduino
|
||||||
|
url: https://esp32.com/viewforum.php?f=19
|
||||||
|
about: Official Forum for questions
|
||||||
|
|
|
||||||
26
.github/codeql/codeql-config.yml
vendored
26
.github/codeql/codeql-config.yml
vendored
|
|
@ -1,26 +0,0 @@
|
||||||
name: "CodeQL config"
|
|
||||||
|
|
||||||
packs:
|
|
||||||
- trailofbits/cpp-queries
|
|
||||||
- githubsecuritylab/codeql-cpp-queries
|
|
||||||
- githubsecuritylab/codeql-python-queries
|
|
||||||
|
|
||||||
queries:
|
|
||||||
- uses: security-extended
|
|
||||||
- uses: security-and-quality
|
|
||||||
|
|
||||||
query-filters:
|
|
||||||
- exclude:
|
|
||||||
query path:
|
|
||||||
- /^experimental\/.*/
|
|
||||||
- exclude:
|
|
||||||
tags contain:
|
|
||||||
- experimental
|
|
||||||
- exclude:
|
|
||||||
problem.severity:
|
|
||||||
- recommendation
|
|
||||||
- exclude:
|
|
||||||
id: tob/cpp/use-of-legacy-algorithm
|
|
||||||
|
|
||||||
paths-ignore:
|
|
||||||
- tests/**
|
|
||||||
16
.github/scripts/merge_packages.py
vendored
16
.github/scripts/merge_packages.py
vendored
|
|
@ -4,7 +4,6 @@
|
||||||
# Usage:
|
# Usage:
|
||||||
# python merge_packages.py package_esp8266com_index.json version/new/package_esp8266com_index.json
|
# python merge_packages.py package_esp8266com_index.json version/new/package_esp8266com_index.json
|
||||||
# Written by Ivan Grokhotkov, 2015
|
# Written by Ivan Grokhotkov, 2015
|
||||||
# Updated by lucasssvaz to handle Chinese version sorting, 2025
|
|
||||||
#
|
#
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
@ -37,19 +36,20 @@ def merge_objects(versions, obj):
|
||||||
|
|
||||||
|
|
||||||
# Normalize ESP release version string (x.x.x) by adding '-rc<MAXINT>' (x.x.x-rc9223372036854775807)
|
# Normalize ESP release version string (x.x.x) by adding '-rc<MAXINT>' (x.x.x-rc9223372036854775807)
|
||||||
# to ensure having REL above any RC. CN version will be sorted after the official version if they happen
|
# to ensure having REL above any RC
|
||||||
# to be mixed (normally, CN and non-CN versions should not be mixed)
|
|
||||||
# Dummy approach, functional anyway for current ESP package versioning
|
# Dummy approach, functional anyway for current ESP package versioning
|
||||||
# (unlike NormalizedVersion/LooseVersion/StrictVersion & similar crap)
|
# (unlike NormalizedVersion/LooseVersion/StrictVersion & similar crap)
|
||||||
def pkgVersionNormalized(versionString):
|
def pkgVersionNormalized(versionString):
|
||||||
verStr = str(versionString).replace("-cn", "")
|
|
||||||
|
verStr = str(versionString)
|
||||||
verParts = re.split(r"\.|-rc|-alpha", verStr, flags=re.IGNORECASE)
|
verParts = re.split(r"\.|-rc|-alpha", verStr, flags=re.IGNORECASE)
|
||||||
|
|
||||||
if len(verParts) == 3:
|
if len(verParts) == 3:
|
||||||
if "-cn" in str(versionString):
|
if sys.version_info > (3, 0): # Python 3
|
||||||
verStr = verStr + "-rc" + str(sys.maxsize // 2)
|
verStr = str(versionString) + "-rc" + str(sys.maxsize)
|
||||||
else:
|
else: # Python 2
|
||||||
verStr = verStr + "-rc" + str(sys.maxsize)
|
verStr = str(versionString) + "-rc" + str(sys.maxint)
|
||||||
|
|
||||||
elif len(verParts) != 4:
|
elif len(verParts) != 4:
|
||||||
print("pkgVersionNormalized WARNING: unexpected version format: {0})".format(verStr), file=sys.stderr)
|
print("pkgVersionNormalized WARNING: unexpected version format: {0})".format(verStr), file=sys.stderr)
|
||||||
|
|
||||||
|
|
|
||||||
33
.github/scripts/on-push-idf.sh
vendored
33
.github/scripts/on-push-idf.sh
vendored
|
|
@ -1,33 +0,0 @@
|
||||||
#!/bin/bash
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
CHECK_REQUIREMENTS="./components/arduino-esp32/.github/scripts/sketch_utils.sh check_requirements"
|
|
||||||
|
|
||||||
# Export IDF environment
|
|
||||||
. ${IDF_PATH}/export.sh
|
|
||||||
|
|
||||||
# Find all examples in ./components/arduino-esp32/idf_component_examples
|
|
||||||
idf_component_examples=$(find ./components/arduino-esp32/idf_component_examples -mindepth 1 -maxdepth 1 -type d)
|
|
||||||
|
|
||||||
for example in $idf_component_examples; do
|
|
||||||
if [ -f "$example"/ci.json ]; then
|
|
||||||
# If the target is listed as false, skip the sketch. Otherwise, include it.
|
|
||||||
is_target=$(jq -r --arg target "$IDF_TARGET" '.targets[$target]' "$example"/ci.json)
|
|
||||||
if [[ "$is_target" == "false" ]]; then
|
|
||||||
printf "\n\033[93mSkipping %s for target %s\033[0m\n\n" "$example" "$IDF_TARGET"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
idf.py -C "$example" set-target "$IDF_TARGET"
|
|
||||||
|
|
||||||
has_requirements=$(${CHECK_REQUIREMENTS} "$example" "$example/sdkconfig")
|
|
||||||
if [ "$has_requirements" -eq 0 ]; then
|
|
||||||
printf "\n\033[93m%s does not meet the requirements for %s. Skipping...\033[0m\n\n" "$example" "$IDF_TARGET"
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
|
|
||||||
printf "\n\033[95mBuilding %s\033[0m\n\n" "$example"
|
|
||||||
idf.py -C "$example" -DEXTRA_COMPONENT_DIRS="$PWD/components" build
|
|
||||||
done
|
|
||||||
1
.github/scripts/on-push.sh
vendored
1
.github/scripts/on-push.sh
vendored
|
|
@ -90,7 +90,6 @@ if [ "$BUILD_LOG" -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#build sketches for different targets
|
#build sketches for different targets
|
||||||
build "esp32c5" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
|
||||||
build "esp32p4" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
build "esp32p4" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
||||||
build "esp32s3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
build "esp32s3" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
||||||
build "esp32s2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
build "esp32s2" "$CHUNK_INDEX" "$CHUNKS_CNT" "$BUILD_LOG" "$LOG_LEVEL" "$SKETCHES_FILE" "${SKETCHES_ESP32[@]}"
|
||||||
|
|
|
||||||
16
.github/scripts/on-release.sh
vendored
16
.github/scripts/on-release.sh
vendored
|
|
@ -35,8 +35,6 @@ PACKAGE_JSON_MERGE="$GITHUB_WORKSPACE/.github/scripts/merge_packages.py"
|
||||||
PACKAGE_JSON_TEMPLATE="$GITHUB_WORKSPACE/package/package_esp32_index.template.json"
|
PACKAGE_JSON_TEMPLATE="$GITHUB_WORKSPACE/package/package_esp32_index.template.json"
|
||||||
PACKAGE_JSON_DEV="package_esp32_dev_index.json"
|
PACKAGE_JSON_DEV="package_esp32_dev_index.json"
|
||||||
PACKAGE_JSON_REL="package_esp32_index.json"
|
PACKAGE_JSON_REL="package_esp32_index.json"
|
||||||
PACKAGE_JSON_DEV_CN="package_esp32_dev_index_cn.json"
|
|
||||||
PACKAGE_JSON_REL_CN="package_esp32_index_cn.json"
|
|
||||||
|
|
||||||
echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF"
|
echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF"
|
||||||
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
|
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
|
||||||
|
|
@ -341,15 +339,9 @@ jq_arg=".packages[0].platforms[0].version = \"$RELEASE_TAG\" | \
|
||||||
# Generate package JSONs
|
# Generate package JSONs
|
||||||
echo "Generating $PACKAGE_JSON_DEV ..."
|
echo "Generating $PACKAGE_JSON_DEV ..."
|
||||||
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
|
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
|
||||||
# On MacOS the sed command won't skip the first match. Use gsed instead.
|
|
||||||
sed '0,/github\.com\//!s|github\.com/|dl.espressif.cn/github_assets/|g' "$OUTPUT_DIR/$PACKAGE_JSON_DEV" > "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN"
|
|
||||||
python "$SCRIPTS_DIR/release_append_cn.py" "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN"
|
|
||||||
if [ "$RELEASE_PRE" == "false" ]; then
|
if [ "$RELEASE_PRE" == "false" ]; then
|
||||||
echo "Generating $PACKAGE_JSON_REL ..."
|
echo "Generating $PACKAGE_JSON_REL ..."
|
||||||
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
||||||
# On MacOS the sed command won't skip the first match. Use gsed instead.
|
|
||||||
sed '0,/github\.com\//!s|github\.com/|dl.espressif.cn/github_assets/|g' "$OUTPUT_DIR/$PACKAGE_JSON_REL" > "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN"
|
|
||||||
python "$SCRIPTS_DIR/release_append_cn.py" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Figure out the last release or pre-release
|
# Figure out the last release or pre-release
|
||||||
|
|
@ -381,14 +373,12 @@ echo
|
||||||
if [ -n "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
|
if [ -n "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
|
||||||
echo "Merging with JSON from $prev_any_release ..."
|
echo "Merging with JSON from $prev_any_release ..."
|
||||||
merge_package_json "$prev_any_release/$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
|
merge_package_json "$prev_any_release/$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
|
||||||
merge_package_json "$prev_any_release/$PACKAGE_JSON_DEV_CN" "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$RELEASE_PRE" == "false" ]; then
|
if [ "$RELEASE_PRE" == "false" ]; then
|
||||||
if [ -n "$prev_release" ] && [ "$prev_release" != "null" ]; then
|
if [ -n "$prev_release" ] && [ "$prev_release" != "null" ]; then
|
||||||
echo "Merging with JSON from $prev_release ..."
|
echo "Merging with JSON from $prev_release ..."
|
||||||
merge_package_json "$prev_release/$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
merge_package_json "$prev_release/$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL"
|
||||||
merge_package_json "$prev_release/$PACKAGE_JSON_REL_CN" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
@ -398,8 +388,6 @@ echo "Installing arduino-cli ..."
|
||||||
export PATH="/home/runner/bin:$PATH"
|
export PATH="/home/runner/bin:$PATH"
|
||||||
source "${SCRIPTS_DIR}/install-arduino-cli.sh"
|
source "${SCRIPTS_DIR}/install-arduino-cli.sh"
|
||||||
|
|
||||||
# For the Chinese mirror, we can't test the package JSONs as the Chinese mirror might not be updated yet.
|
|
||||||
|
|
||||||
echo "Testing $PACKAGE_JSON_DEV install ..."
|
echo "Testing $PACKAGE_JSON_DEV install ..."
|
||||||
|
|
||||||
echo "Installing esp32 ..."
|
echo "Installing esp32 ..."
|
||||||
|
|
@ -457,15 +445,11 @@ fi
|
||||||
echo "Uploading $PACKAGE_JSON_DEV ..."
|
echo "Uploading $PACKAGE_JSON_DEV ..."
|
||||||
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
|
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
|
||||||
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
|
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
|
||||||
echo "Download CN URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN")"
|
|
||||||
echo "Pages CN URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_DEV_CN" "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN")"
|
|
||||||
echo
|
echo
|
||||||
if [ "$RELEASE_PRE" == "false" ]; then
|
if [ "$RELEASE_PRE" == "false" ]; then
|
||||||
echo "Uploading $PACKAGE_JSON_REL ..."
|
echo "Uploading $PACKAGE_JSON_REL ..."
|
||||||
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
|
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
|
||||||
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
|
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
|
||||||
echo "Download CN URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN")"
|
|
||||||
echo "Pages CN URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_REL_CN" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN")"
|
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
||||||
57
.github/scripts/release_append_cn.py
vendored
57
.github/scripts/release_append_cn.py
vendored
|
|
@ -1,57 +0,0 @@
|
||||||
|
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# Arduino IDE provides by default a package file for the ESP32. This causes version conflicts
|
|
||||||
# when the user tries to use the JSON file with the Chinese mirrors.
|
|
||||||
#
|
|
||||||
# The downside is that the Arduino IDE will always warn the user that updates are available as it
|
|
||||||
# will consider the version from the Chinese mirrors as a pre-release version.
|
|
||||||
#
|
|
||||||
# This script is used to append "-cn" to all versions in the package_esp32_index_cn.json file so that
|
|
||||||
# the user can select the Chinese mirrors without conflicts.
|
|
||||||
#
|
|
||||||
# If Arduino ever stops providing the package_esp32_index.json file by default,
|
|
||||||
# this script can be removed and the tags reverted.
|
|
||||||
|
|
||||||
import json
|
|
||||||
|
|
||||||
def append_cn_to_versions(obj):
|
|
||||||
if isinstance(obj, dict):
|
|
||||||
# Skip tools that are not from the esp32 package
|
|
||||||
packager = obj.get("packager")
|
|
||||||
if packager is not None and packager != "esp32":
|
|
||||||
return
|
|
||||||
|
|
||||||
for key, value in obj.items():
|
|
||||||
if key == "version" and isinstance(value, str):
|
|
||||||
if not value.endswith("-cn"):
|
|
||||||
obj[key] = value + "-cn"
|
|
||||||
else:
|
|
||||||
append_cn_to_versions(value)
|
|
||||||
|
|
||||||
elif isinstance(obj, list):
|
|
||||||
for item in obj:
|
|
||||||
append_cn_to_versions(item)
|
|
||||||
|
|
||||||
def process_json_file(input_path, output_path=None):
|
|
||||||
with open(input_path, "r", encoding="utf-8") as f:
|
|
||||||
data = json.load(f)
|
|
||||||
|
|
||||||
append_cn_to_versions(data)
|
|
||||||
|
|
||||||
if output_path is None:
|
|
||||||
output_path = input_path
|
|
||||||
|
|
||||||
with open(output_path, "w", encoding="utf-8") as f:
|
|
||||||
json.dump(data, f, indent=2)
|
|
||||||
|
|
||||||
print(f"Updated JSON written to {output_path}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
import sys
|
|
||||||
if len(sys.argv) < 2:
|
|
||||||
print("Usage: python release_append_cn.py input.json [output.json]")
|
|
||||||
else:
|
|
||||||
input_file = sys.argv[1]
|
|
||||||
output_file = sys.argv[2] if len(sys.argv) > 2 else None
|
|
||||||
process_json_file(input_file, output_file)
|
|
||||||
7
.github/scripts/sketch_utils.sh
vendored
7
.github/scripts/sketch_utils.sh
vendored
|
|
@ -16,7 +16,7 @@ function check_requirements { # check_requirements <sketchdir> <sdkconfig_path>
|
||||||
local requirements_or
|
local requirements_or
|
||||||
|
|
||||||
if [ ! -f "$sdkconfig_path" ] || [ ! -f "$sketchdir/ci.json" ]; then
|
if [ ! -f "$sdkconfig_path" ] || [ ! -f "$sketchdir/ci.json" ]; then
|
||||||
echo "WARNING: sdkconfig or ci.json not found. Assuming requirements are met." 1>&2
|
echo "ERROR: sdkconfig or ci.json not found" 1>&2
|
||||||
# Return 1 on error to force the sketch to be built and fail. This way the
|
# Return 1 on error to force the sketch to be built and fail. This way the
|
||||||
# CI will fail and the user will know that the sketch has a problem.
|
# CI will fail and the user will know that the sketch has a problem.
|
||||||
else
|
else
|
||||||
|
|
@ -156,7 +156,6 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
|
||||||
esp32c6_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
esp32c6_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
||||||
esp32h2_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
esp32h2_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
||||||
esp32p4_opts=$(echo "PSRAM=enabled,USBMode=default,$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
esp32p4_opts=$(echo "PSRAM=enabled,USBMode=default,$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
||||||
esp32c5_opts=$(echo "$debug_level,$fqbn_append" | sed 's/^,*//;s/,*$//;s/,\{2,\}/,/g')
|
|
||||||
|
|
||||||
# Select the common part of the FQBN based on the target. The rest will be
|
# Select the common part of the FQBN based on the target. The rest will be
|
||||||
# appended depending on the passed options.
|
# appended depending on the passed options.
|
||||||
|
|
@ -192,10 +191,6 @@ function build_sketch { # build_sketch <ide_path> <user_path> <path-to-ino> [ext
|
||||||
[ -n "${options:-$esp32p4_opts}" ] && opt=":${options:-$esp32p4_opts}"
|
[ -n "${options:-$esp32p4_opts}" ] && opt=":${options:-$esp32p4_opts}"
|
||||||
fqbn="espressif:esp32:esp32p4$opt"
|
fqbn="espressif:esp32:esp32p4$opt"
|
||||||
;;
|
;;
|
||||||
"esp32c5")
|
|
||||||
[ -n "${options:-$esp32c5_opts}" ] && opt=":${options:-$esp32c5_opts}"
|
|
||||||
fqbn="espressif:esp32:esp32c5$opt"
|
|
||||||
;;
|
|
||||||
*)
|
*)
|
||||||
echo "ERROR: Invalid chip: $target"
|
echo "ERROR: Invalid chip: $target"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
19
.github/scripts/update-version.sh
vendored
19
.github/scripts/update-version.sh
vendored
|
|
@ -1,5 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Disable shellcheck warning about using 'cat' to read a file.
|
|
||||||
# shellcheck disable=SC2002
|
# shellcheck disable=SC2002
|
||||||
|
|
||||||
# For reference: add tools for all boards by replacing one line in each board
|
# For reference: add tools for all boards by replacing one line in each board
|
||||||
|
|
@ -24,15 +23,7 @@ ESP_ARDUINO_VERSION_MINOR="$2"
|
||||||
ESP_ARDUINO_VERSION_PATCH="$3"
|
ESP_ARDUINO_VERSION_PATCH="$3"
|
||||||
ESP_ARDUINO_VERSION="$ESP_ARDUINO_VERSION_MAJOR.$ESP_ARDUINO_VERSION_MINOR.$ESP_ARDUINO_VERSION_PATCH"
|
ESP_ARDUINO_VERSION="$ESP_ARDUINO_VERSION_MAJOR.$ESP_ARDUINO_VERSION_MINOR.$ESP_ARDUINO_VERSION_PATCH"
|
||||||
|
|
||||||
# Get ESP-IDF version from push.yml (this way we can ensure that the version is correct even if the local libs are not up to date)
|
|
||||||
ESP_IDF_VERSION=$(grep "idf_ver:" .github/workflows/push.yml | sed 's/.*release-v\([^"]*\).*/\1/')
|
|
||||||
if [ -z "$ESP_IDF_VERSION" ]; then
|
|
||||||
echo "Error: ESP-IDF version not found in push.yml" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "New Arduino Version: $ESP_ARDUINO_VERSION"
|
echo "New Arduino Version: $ESP_ARDUINO_VERSION"
|
||||||
echo "ESP-IDF Version: $ESP_IDF_VERSION"
|
|
||||||
|
|
||||||
echo "Updating platform.txt..."
|
echo "Updating platform.txt..."
|
||||||
cat platform.txt | sed "s/version=.*/version=$ESP_ARDUINO_VERSION/g" > __platform.txt && mv __platform.txt platform.txt
|
cat platform.txt | sed "s/version=.*/version=$ESP_ARDUINO_VERSION/g" > __platform.txt && mv __platform.txt platform.txt
|
||||||
|
|
@ -40,16 +31,6 @@ cat platform.txt | sed "s/version=.*/version=$ESP_ARDUINO_VERSION/g" > __platfor
|
||||||
echo "Updating package.json..."
|
echo "Updating package.json..."
|
||||||
cat package.json | sed "s/.*\"version\":.*/ \"version\": \"$ESP_ARDUINO_VERSION\",/g" > __package.json && mv __package.json package.json
|
cat package.json | sed "s/.*\"version\":.*/ \"version\": \"$ESP_ARDUINO_VERSION\",/g" > __package.json && mv __package.json package.json
|
||||||
|
|
||||||
echo "Updating docs/conf_common.py..."
|
|
||||||
cat docs/conf_common.py | \
|
|
||||||
sed "s/.. |version| replace:: .*/.. |version| replace:: $ESP_ARDUINO_VERSION/g" | \
|
|
||||||
sed "s/.. |idf_version| replace:: .*/.. |idf_version| replace:: $ESP_IDF_VERSION/g" > docs/__conf_common.py && mv docs/__conf_common.py docs/conf_common.py
|
|
||||||
|
|
||||||
echo "Updating .gitlab/workflows/common.yml..."
|
|
||||||
cat .gitlab/workflows/common.yml | \
|
|
||||||
sed "s/ESP_IDF_VERSION:.*/ESP_IDF_VERSION: \"$ESP_IDF_VERSION\"/g" | \
|
|
||||||
sed "s/ESP_ARDUINO_VERSION:.*/ESP_ARDUINO_VERSION: \"$ESP_ARDUINO_VERSION\"/g" > .gitlab/workflows/__common.yml && mv .gitlab/workflows/__common.yml .gitlab/workflows/common.yml
|
|
||||||
|
|
||||||
echo "Updating cores/esp32/esp_arduino_version.h..."
|
echo "Updating cores/esp32/esp_arduino_version.h..."
|
||||||
cat cores/esp32/esp_arduino_version.h | \
|
cat cores/esp32/esp_arduino_version.h | \
|
||||||
sed "s/#define ESP_ARDUINO_VERSION_MAJOR.*/#define ESP_ARDUINO_VERSION_MAJOR $ESP_ARDUINO_VERSION_MAJOR/g" | \
|
sed "s/#define ESP_ARDUINO_VERSION_MAJOR.*/#define ESP_ARDUINO_VERSION_MAJOR $ESP_ARDUINO_VERSION_MAJOR/g" | \
|
||||||
|
|
|
||||||
236
.github/scripts/update_esptool.py
vendored
236
.github/scripts/update_esptool.py
vendored
|
|
@ -1,236 +0,0 @@
|
||||||
#!/usr/bin/env python3
|
|
||||||
|
|
||||||
# This script is used to re-package the esptool if needed and update the JSON file
|
|
||||||
# for the Arduino ESP32 platform.
|
|
||||||
#
|
|
||||||
# The script has only been tested on macOS.
|
|
||||||
#
|
|
||||||
# For regular esptool releases, the generated packages already contain the correct permissions,
|
|
||||||
# extensions and are uploaded to the GitHub release assets. In this case, the script will only
|
|
||||||
# update the JSON file with the information from the GitHub release.
|
|
||||||
#
|
|
||||||
# The script can be used in two modes:
|
|
||||||
# 1. Local build: The build artifacts must be already downloaded and extracted in the base_folder.
|
|
||||||
# This is useful for esptool versions that are not yet released and that are grabbed from the
|
|
||||||
# GitHub build artifacts.
|
|
||||||
# 2. Release build: The script will get the release information from GitHub and update the JSON file.
|
|
||||||
# This is useful for esptool versions that are already released and that are uploaded to the
|
|
||||||
# GitHub release assets.
|
|
||||||
#
|
|
||||||
# For local build, the artifacts must be already downloaded and extracted in the base_folder
|
|
||||||
# set with the -l option.
|
|
||||||
# For example, a base folder "esptool" should contain the following folders extracted directly
|
|
||||||
# from the GitHub build artifacts:
|
|
||||||
# esptool/esptool-linux-aarch64
|
|
||||||
# esptool/esptool-linux-amd64
|
|
||||||
# esptool/esptool-linux-armv7
|
|
||||||
# esptool/esptool-macos-amd64
|
|
||||||
# esptool/esptool-macos-arm64
|
|
||||||
# esptool/esptool-windows-amd64
|
|
||||||
|
|
||||||
import argparse
|
|
||||||
import json
|
|
||||||
import os
|
|
||||||
import shutil
|
|
||||||
import stat
|
|
||||||
import tarfile
|
|
||||||
import zipfile
|
|
||||||
import hashlib
|
|
||||||
import requests
|
|
||||||
from pathlib import Path
|
|
||||||
|
|
||||||
def compute_sha256(filepath):
|
|
||||||
sha256 = hashlib.sha256()
|
|
||||||
with open(filepath, "rb") as f:
|
|
||||||
for block in iter(lambda: f.read(4096), b""):
|
|
||||||
sha256.update(block)
|
|
||||||
return f"SHA-256:{sha256.hexdigest()}"
|
|
||||||
|
|
||||||
def get_file_size(filepath):
|
|
||||||
return os.path.getsize(filepath)
|
|
||||||
|
|
||||||
def update_json_for_host(tmp_json_path, version, host, url, archiveFileName, checksum, size):
|
|
||||||
with open(tmp_json_path) as f:
|
|
||||||
data = json.load(f)
|
|
||||||
|
|
||||||
for pkg in data.get("packages", []):
|
|
||||||
for tool in pkg.get("tools", []):
|
|
||||||
if tool.get("name") == "esptool_py":
|
|
||||||
tool["version"] = version
|
|
||||||
|
|
||||||
if url is None:
|
|
||||||
# If the URL is not set, we need to find the old URL and update it
|
|
||||||
for system in tool.get("systems", []):
|
|
||||||
if system.get("host") == host:
|
|
||||||
url = system.get("url").replace(system.get("archiveFileName"), archiveFileName)
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
print(f"No old URL found for host {host}. Using empty URL.")
|
|
||||||
url = ""
|
|
||||||
|
|
||||||
# Preserve existing systems order and update or append the new system
|
|
||||||
systems = tool.get("systems", [])
|
|
||||||
system_updated = False
|
|
||||||
for i, system in enumerate(systems):
|
|
||||||
if system.get("host") == host:
|
|
||||||
systems[i] = {
|
|
||||||
"host": host,
|
|
||||||
"url": url,
|
|
||||||
"archiveFileName": archiveFileName,
|
|
||||||
"checksum": checksum,
|
|
||||||
"size": str(size),
|
|
||||||
}
|
|
||||||
system_updated = True
|
|
||||||
break
|
|
||||||
|
|
||||||
if not system_updated:
|
|
||||||
systems.append({
|
|
||||||
"host": host,
|
|
||||||
"url": url,
|
|
||||||
"archiveFileName": archiveFileName,
|
|
||||||
"checksum": checksum,
|
|
||||||
"size": str(size),
|
|
||||||
})
|
|
||||||
tool["systems"] = systems
|
|
||||||
|
|
||||||
with open(tmp_json_path, "w") as f:
|
|
||||||
json.dump(data, f, indent=2, sort_keys=False, ensure_ascii=False)
|
|
||||||
f.write("\n")
|
|
||||||
|
|
||||||
def update_tools_dependencies(tmp_json_path, version):
|
|
||||||
with open(tmp_json_path) as f:
|
|
||||||
data = json.load(f)
|
|
||||||
|
|
||||||
for pkg in data.get("packages", []):
|
|
||||||
for platform in pkg.get("platforms", []):
|
|
||||||
for dep in platform.get("toolsDependencies", []):
|
|
||||||
if dep.get("name") == "esptool_py":
|
|
||||||
dep["version"] = version
|
|
||||||
|
|
||||||
with open(tmp_json_path, "w") as f:
|
|
||||||
json.dump(data, f, indent=2, sort_keys=False, ensure_ascii=False)
|
|
||||||
f.write("\n")
|
|
||||||
|
|
||||||
def create_archives(version, base_folder):
|
|
||||||
archive_files = []
|
|
||||||
|
|
||||||
for dirpath in Path(base_folder).glob("esptool-*"):
|
|
||||||
if not dirpath.is_dir():
|
|
||||||
continue
|
|
||||||
|
|
||||||
base = dirpath.name[len("esptool-"):]
|
|
||||||
|
|
||||||
if "windows" in dirpath.name:
|
|
||||||
zipfile_name = f"esptool-v{version}-{base}.zip"
|
|
||||||
print(f"Creating {zipfile_name} from {dirpath} ...")
|
|
||||||
with zipfile.ZipFile(zipfile_name, "w", zipfile.ZIP_DEFLATED) as zipf:
|
|
||||||
for root, _, files in os.walk(dirpath):
|
|
||||||
for file in files:
|
|
||||||
full_path = os.path.join(root, file)
|
|
||||||
zipf.write(full_path, os.path.relpath(full_path, start=dirpath))
|
|
||||||
archive_files.append(zipfile_name)
|
|
||||||
else:
|
|
||||||
tarfile_name = f"esptool-v{version}-{base}.tar.gz"
|
|
||||||
print(f"Creating {tarfile_name} from {dirpath} ...")
|
|
||||||
for root, dirs, files in os.walk(dirpath):
|
|
||||||
for name in dirs + files:
|
|
||||||
os.chmod(os.path.join(root, name), stat.S_IRUSR | stat.S_IWUSR | stat.S_IXUSR |
|
|
||||||
stat.S_IRGRP | stat.S_IXGRP |
|
|
||||||
stat.S_IROTH | stat.S_IXOTH)
|
|
||||||
with tarfile.open(tarfile_name, "w:gz") as tar:
|
|
||||||
tar.add(dirpath, arcname=dirpath.name)
|
|
||||||
archive_files.append(tarfile_name)
|
|
||||||
|
|
||||||
return archive_files
|
|
||||||
|
|
||||||
def determine_hosts(archive_name):
|
|
||||||
if "linux-amd64" in archive_name:
|
|
||||||
return ["x86_64-pc-linux-gnu"]
|
|
||||||
elif "linux-armv7" in archive_name:
|
|
||||||
return ["arm-linux-gnueabihf"]
|
|
||||||
elif "linux-aarch64" in archive_name:
|
|
||||||
return ["aarch64-linux-gnu"]
|
|
||||||
elif "macos-amd64" in archive_name:
|
|
||||||
return ["x86_64-apple-darwin"]
|
|
||||||
elif "macos-arm64" in archive_name:
|
|
||||||
return ["arm64-apple-darwin"]
|
|
||||||
elif "windows-amd64" in archive_name:
|
|
||||||
return ["x86_64-mingw32", "i686-mingw32"]
|
|
||||||
else:
|
|
||||||
return []
|
|
||||||
|
|
||||||
def update_json_from_local_build(tmp_json_path, version, base_folder, archive_files):
|
|
||||||
for archive in archive_files:
|
|
||||||
print(f"Processing archive: {archive}")
|
|
||||||
hosts = determine_hosts(archive)
|
|
||||||
if not hosts:
|
|
||||||
print(f"Skipping unknown archive type: {archive}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
archive_path = Path(archive)
|
|
||||||
checksum = compute_sha256(archive_path)
|
|
||||||
size = get_file_size(archive_path)
|
|
||||||
|
|
||||||
for host in hosts:
|
|
||||||
update_json_for_host(tmp_json_path, version, host, None, archive_path.name, checksum, size)
|
|
||||||
|
|
||||||
def update_json_from_release(tmp_json_path, version, release_info):
|
|
||||||
assets = release_info.get("assets", [])
|
|
||||||
for asset in assets:
|
|
||||||
if (asset.get("name").endswith(".tar.gz") or asset.get("name").endswith(".zip")) and "esptool" in asset.get("name"):
|
|
||||||
asset_fname = asset.get("name")
|
|
||||||
print(f"Processing asset: {asset_fname}")
|
|
||||||
hosts = determine_hosts(asset_fname)
|
|
||||||
if not hosts:
|
|
||||||
print(f"Skipping unknown archive type: {asset_fname}")
|
|
||||||
continue
|
|
||||||
|
|
||||||
asset_url = asset.get("browser_download_url")
|
|
||||||
asset_checksum = asset.get("digest").replace("sha256:", "SHA-256:")
|
|
||||||
asset_size = asset.get("size")
|
|
||||||
if asset_checksum is None:
|
|
||||||
asset_checksum = ""
|
|
||||||
print(f"Asset {asset_fname} has no checksum. Please set the checksum in the JSON file.")
|
|
||||||
|
|
||||||
for host in hosts:
|
|
||||||
update_json_for_host(tmp_json_path, version, host, asset_url, asset_fname, asset_checksum, asset_size)
|
|
||||||
|
|
||||||
def get_release_info(version):
|
|
||||||
url = f"https://api.github.com/repos/espressif/esptool/releases/tags/v{version}"
|
|
||||||
response = requests.get(url)
|
|
||||||
response.raise_for_status()
|
|
||||||
return response.json()
|
|
||||||
|
|
||||||
def main():
|
|
||||||
parser = argparse.ArgumentParser(description="Repack esptool and update JSON metadata.")
|
|
||||||
parser.add_argument("version", help="Version of the esptool (e.g. 5.0.dev1)")
|
|
||||||
parser.add_argument("-l", "--local", dest="base_folder", help="Enable local build mode and set the base folder with unpacked artifacts")
|
|
||||||
args = parser.parse_args()
|
|
||||||
|
|
||||||
script_dir = Path(__file__).resolve().parent
|
|
||||||
json_path = (script_dir / "../../package/package_esp32_index.template.json").resolve()
|
|
||||||
tmp_json_path = Path(str(json_path) + ".tmp")
|
|
||||||
shutil.copy(json_path, tmp_json_path)
|
|
||||||
|
|
||||||
local_build = args.base_folder is not None
|
|
||||||
|
|
||||||
if local_build:
|
|
||||||
os.chdir(args.base_folder)
|
|
||||||
os.environ['COPYFILE_DISABLE'] = 'true' # this disables including resource forks in tar files on macOS
|
|
||||||
# Clear any existing archive files
|
|
||||||
for file in Path(args.base_folder).glob("esptool-*.*"):
|
|
||||||
file.unlink()
|
|
||||||
archive_files = create_archives(args.version, args.base_folder)
|
|
||||||
update_json_from_local_build(tmp_json_path, args.version, args.base_folder, archive_files)
|
|
||||||
else:
|
|
||||||
release_info = get_release_info(args.version)
|
|
||||||
update_json_from_release(tmp_json_path, args.version, release_info)
|
|
||||||
|
|
||||||
print(f"Updating esptool version fields to {args.version}")
|
|
||||||
update_tools_dependencies(tmp_json_path, args.version)
|
|
||||||
|
|
||||||
shutil.move(tmp_json_path, json_path)
|
|
||||||
print(f"Done. JSON updated at {json_path}")
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
31
.github/workflows/codeql_actions.yml
vendored
31
.github/workflows/codeql_actions.yml
vendored
|
|
@ -1,31 +0,0 @@
|
||||||
name: CodeQL Actions Analysis
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- ".github/workflows/*.yml"
|
|
||||||
- ".github/workflows/*.yaml"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
codeql-analysis:
|
|
||||||
name: CodeQL Actions Analysis
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
|
||||||
with:
|
|
||||||
languages: actions
|
|
||||||
config-file: ./.github/codeql/codeql-config.yml
|
|
||||||
|
|
||||||
- name: Run CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
|
||||||
with:
|
|
||||||
category: "Analysis: Actions"
|
|
||||||
30
.github/workflows/codeql_python.yml
vendored
30
.github/workflows/codeql_python.yml
vendored
|
|
@ -1,30 +0,0 @@
|
||||||
name: CodeQL Python Analysis
|
|
||||||
|
|
||||||
on:
|
|
||||||
workflow_dispatch:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- master
|
|
||||||
pull_request:
|
|
||||||
paths:
|
|
||||||
- "**/*.py"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
codeql-analysis:
|
|
||||||
name: CodeQL Python Analysis
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- name: Checkout repository
|
|
||||||
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
|
|
||||||
|
|
||||||
- name: Initialize CodeQL
|
|
||||||
uses: github/codeql-action/init@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
|
||||||
with:
|
|
||||||
languages: python
|
|
||||||
config-file: ./.github/codeql/codeql-config.yml
|
|
||||||
|
|
||||||
- name: Run CodeQL Analysis
|
|
||||||
uses: github/codeql-action/analyze@181d5eefc20863364f96762470ba6f862bdef56b # v3.29.2
|
|
||||||
with:
|
|
||||||
category: "Analysis: Python"
|
|
||||||
1
.github/workflows/dangerjs.yml
vendored
1
.github/workflows/dangerjs.yml
vendored
|
|
@ -24,5 +24,4 @@ jobs:
|
||||||
instructions-cla-link: "https://cla-assistant.io/espressif/arduino-esp32"
|
instructions-cla-link: "https://cla-assistant.io/espressif/arduino-esp32"
|
||||||
instructions-contributions-file: "docs/en/contributing.rst"
|
instructions-contributions-file: "docs/en/contributing.rst"
|
||||||
rule-max-commits: "false"
|
rule-max-commits: "false"
|
||||||
rule-target-branch: "false"
|
|
||||||
commit-messages-min-summary-length: "10"
|
commit-messages-min-summary-length: "10"
|
||||||
|
|
|
||||||
3
.github/workflows/lib.json
vendored
3
.github/workflows/lib.json
vendored
|
|
@ -9,8 +9,7 @@
|
||||||
{
|
{
|
||||||
"name": "ArduinoBLE",
|
"name": "ArduinoBLE",
|
||||||
"exclude_targets": [
|
"exclude_targets": [
|
||||||
"esp32s2",
|
"esp32s2"
|
||||||
"esp32p4"
|
|
||||||
],
|
],
|
||||||
"sketch_path": [
|
"sketch_path": [
|
||||||
"~/Arduino/libraries/ArduinoBLE/examples/Central/Scan/Scan.ino"
|
"~/Arduino/libraries/ArduinoBLE/examples/Central/Scan/Scan.ino"
|
||||||
|
|
|
||||||
11
.github/workflows/publishsizes.yml
vendored
11
.github/workflows/publishsizes.yml
vendored
|
|
@ -44,17 +44,16 @@ jobs:
|
||||||
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
|
gh api "$artifacts_url" -q '.artifacts[] | [.name, .archive_download_url] | @tsv' | while read artifact
|
||||||
do
|
do
|
||||||
IFS=$'\t' read name url <<< "$artifact"
|
IFS=$'\t' read name url <<< "$artifact"
|
||||||
# Only process pr_number and pr_cli_compile artifacts
|
|
||||||
if [[ "$name" == "pr_number" || "$name" =~ ^pr_cli_compile_[0-9]+$ ]]; then
|
|
||||||
gh api $url > "$name.zip"
|
gh api $url > "$name.zip"
|
||||||
unzip -o -j "$name.zip" -d "temp_$name"
|
unzip -j "$name.zip" -d "temp_$name"
|
||||||
if [[ "$name" == "pr_number" ]]; then
|
if [[ "$name" == "pr_number" ]]; then
|
||||||
mv "temp_$name"/* sizes-report
|
mv "temp_$name"/* sizes-report
|
||||||
elif [[ "$name" =~ ^pr_cli_compile_[0-9]+$ ]]; then
|
elif [[ "$name" == "pr_cli"* ]]; then
|
||||||
mv "temp_$name"/* sizes-report/pr
|
mv "temp_$name"/* sizes-report/pr
|
||||||
|
else
|
||||||
|
mv "temp_$name"/* sizes-report
|
||||||
fi
|
fi
|
||||||
rm -r "temp_$name"
|
rm -r "temp_$name"
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
echo "Contents of parent directory:"
|
echo "Contents of parent directory:"
|
||||||
ls -R ..
|
ls -R ..
|
||||||
|
|
@ -66,7 +65,7 @@ jobs:
|
||||||
path: ./artifacts/sizes-report/pr_num.txt
|
path: ./artifacts/sizes-report/pr_num.txt
|
||||||
|
|
||||||
- name: Report results
|
- name: Report results
|
||||||
uses: P-R-O-C-H-Y/report-size-deltas@bea91d2c99ca80c88a883b39b1c4012f00ec3d09 # sizes_v2
|
uses: P-R-O-C-H-Y/report-size-deltas@2043188c68f483a7b50527c4eacf609d05bb67a5 # sizes_v2
|
||||||
with:
|
with:
|
||||||
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
|
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
|
||||||
github-token: ${{ env.GITHUB_TOKEN }}
|
github-token: ${{ env.GITHUB_TOKEN }}
|
||||||
|
|
|
||||||
23
.github/workflows/push.yml
vendored
23
.github/workflows/push.yml
vendored
|
|
@ -31,7 +31,6 @@ on:
|
||||||
- "!libraries/**.properties"
|
- "!libraries/**.properties"
|
||||||
- "!libraries/**.py"
|
- "!libraries/**.py"
|
||||||
- "package/**"
|
- "package/**"
|
||||||
- "idf_component_examples/**"
|
|
||||||
- "tools/**.py"
|
- "tools/**.py"
|
||||||
- "platform.txt"
|
- "platform.txt"
|
||||||
- "programmers.txt"
|
- "programmers.txt"
|
||||||
|
|
@ -46,8 +45,8 @@ on:
|
||||||
- "!.github/scripts/tests_*"
|
- "!.github/scripts/tests_*"
|
||||||
- "!.github/scripts/upload_*"
|
- "!.github/scripts/upload_*"
|
||||||
- "variants/esp32/**/*"
|
- "variants/esp32/**/*"
|
||||||
|
- "variants/esp32c2/**/*"
|
||||||
- "variants/esp32c3/**/*"
|
- "variants/esp32c3/**/*"
|
||||||
- "variants/esp32c5/**/*"
|
|
||||||
- "variants/esp32c6/**/*"
|
- "variants/esp32c6/**/*"
|
||||||
- "variants/esp32h2/**/*"
|
- "variants/esp32h2/**/*"
|
||||||
- "variants/esp32p4/**/*"
|
- "variants/esp32p4/**/*"
|
||||||
|
|
@ -125,7 +124,7 @@ jobs:
|
||||||
- 'idf_component.yml'
|
- 'idf_component.yml'
|
||||||
- 'Kconfig.projbuild'
|
- 'Kconfig.projbuild'
|
||||||
- 'CMakeLists.txt'
|
- 'CMakeLists.txt'
|
||||||
- "idf_component_examples/**"
|
- "variants/esp32c2/**/*"
|
||||||
|
|
||||||
- name: Set chunks
|
- name: Set chunks
|
||||||
id: set-chunks
|
id: set-chunks
|
||||||
|
|
@ -248,7 +247,7 @@ jobs:
|
||||||
# See https://hub.docker.com/r/espressif/idf/tags and
|
# See https://hub.docker.com/r/espressif/idf/tags and
|
||||||
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
|
# https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-docker-image.html
|
||||||
# for details.
|
# for details.
|
||||||
idf_ver: ["release-v5.3","release-v5.4","release-v5.5"]
|
idf_ver: ["release-v5.4"]
|
||||||
idf_target:
|
idf_target:
|
||||||
[
|
[
|
||||||
"esp32",
|
"esp32",
|
||||||
|
|
@ -268,23 +267,15 @@ jobs:
|
||||||
submodules: recursive
|
submodules: recursive
|
||||||
path: components/arduino-esp32
|
path: components/arduino-esp32
|
||||||
|
|
||||||
- name: Setup jq
|
|
||||||
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1
|
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
env:
|
env:
|
||||||
IDF_TARGET: ${{ matrix.idf_target }}
|
IDF_TARGET: ${{ matrix.idf_target }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
chmod a+x ./components/arduino-esp32/.github/scripts/*
|
. ${IDF_PATH}/export.sh
|
||||||
./components/arduino-esp32/.github/scripts/on-push-idf.sh
|
idf.py create-project test
|
||||||
|
echo CONFIG_FREERTOS_HZ=1000 > test/sdkconfig.defaults
|
||||||
- name: Upload generated sdkconfig files for debugging
|
idf.py -C test -DEXTRA_COMPONENT_DIRS=$PWD/components build
|
||||||
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
|
|
||||||
if: always()
|
|
||||||
with:
|
|
||||||
name: sdkconfig-${{ matrix.idf_ver }}-${{ matrix.idf_target }}
|
|
||||||
path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig
|
|
||||||
|
|
||||||
# Save artifacts to gh-pages
|
# Save artifacts to gh-pages
|
||||||
save-master-artifacts:
|
save-master-artifacts:
|
||||||
|
|
|
||||||
|
|
@ -1,25 +0,0 @@
|
||||||
workflow:
|
|
||||||
rules:
|
|
||||||
# Disable those non-protected push triggered pipelines
|
|
||||||
- if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^\d+\.\d+(\.\d+)?($|-)/ && $CI_PIPELINE_SOURCE == "push"'
|
|
||||||
when: never
|
|
||||||
# when running merged result pipelines, CI_COMMIT_SHA represents the temp commit it created.
|
|
||||||
# Please use PIPELINE_COMMIT_SHA at all places that require a commit sha of the original commit.
|
|
||||||
- if: $CI_OPEN_MERGE_REQUESTS != null
|
|
||||||
variables:
|
|
||||||
PIPELINE_COMMIT_SHA: $CI_MERGE_REQUEST_SOURCE_BRANCH_SHA
|
|
||||||
IS_MR_PIPELINE: 1
|
|
||||||
- if: $CI_OPEN_MERGE_REQUESTS == null
|
|
||||||
variables:
|
|
||||||
PIPELINE_COMMIT_SHA: $CI_COMMIT_SHA
|
|
||||||
IS_MR_PIPELINE: 0
|
|
||||||
- if: '$CI_PIPELINE_SOURCE == "schedule"'
|
|
||||||
variables:
|
|
||||||
IS_SCHEDULED_RUN: "true"
|
|
||||||
- when: always
|
|
||||||
|
|
||||||
# Place the default settings in `.gitlab/workflows/common.yml` instead
|
|
||||||
|
|
||||||
include:
|
|
||||||
- ".gitlab/workflows/common.yml"
|
|
||||||
- ".gitlab/workflows/sample.yml"
|
|
||||||
|
|
@ -1,26 +0,0 @@
|
||||||
#####################
|
|
||||||
# Default Variables #
|
|
||||||
#####################
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- pre_check
|
|
||||||
- build
|
|
||||||
- test
|
|
||||||
- result
|
|
||||||
|
|
||||||
variables:
|
|
||||||
ESP_IDF_VERSION: "5.5"
|
|
||||||
ESP_ARDUINO_VERSION: "3.3.0"
|
|
||||||
|
|
||||||
#############
|
|
||||||
# `default` #
|
|
||||||
#############
|
|
||||||
|
|
||||||
default:
|
|
||||||
retry:
|
|
||||||
max: 2
|
|
||||||
when:
|
|
||||||
# In case of a runner failure we could hop to another one, or a network error could go away.
|
|
||||||
- runner_system_failure
|
|
||||||
# Job execution timeout may be caused by a network issue.
|
|
||||||
- job_execution_timeout
|
|
||||||
|
|
@ -1,6 +0,0 @@
|
||||||
hello-world:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- echo "Hello, World from GitLab CI!"
|
|
||||||
rules:
|
|
||||||
- if: $CI_PIPELINE_SOURCE == "push"
|
|
||||||
|
|
@ -12,7 +12,7 @@ default_language_version:
|
||||||
|
|
||||||
repos:
|
repos:
|
||||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||||
rev: "cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b" # v5.0.0
|
rev: "v5.0.0"
|
||||||
hooks:
|
hooks:
|
||||||
# Generic checks
|
# Generic checks
|
||||||
- id: check-case-conflict
|
- id: check-case-conflict
|
||||||
|
|
@ -39,8 +39,15 @@ repos:
|
||||||
^package\/.*$
|
^package\/.*$
|
||||||
)
|
)
|
||||||
|
|
||||||
|
- repo: https://github.com/codespell-project/codespell
|
||||||
|
rev: "v2.3.0"
|
||||||
|
hooks:
|
||||||
|
# Spell checking
|
||||||
|
- id: codespell
|
||||||
|
exclude: ^.*\.(svd|SVD)$
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-clang-format
|
- repo: https://github.com/pre-commit/mirrors-clang-format
|
||||||
rev: "f6446549e5e97ec9665b9b03e75b87b445857f9a" # v18.1.3
|
rev: "v18.1.3"
|
||||||
hooks:
|
hooks:
|
||||||
# C/C++ formatting
|
# C/C++ formatting
|
||||||
- id: clang-format
|
- id: clang-format
|
||||||
|
|
@ -48,7 +55,7 @@ repos:
|
||||||
exclude: ^.*\/build_opt\.h$
|
exclude: ^.*\/build_opt\.h$
|
||||||
|
|
||||||
- repo: https://github.com/psf/black-pre-commit-mirror
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
||||||
rev: "a4920527036bb9a3f3e6055d595849d67d0da066" # 25.1.0
|
rev: "24.10.0"
|
||||||
hooks:
|
hooks:
|
||||||
# Python formatting
|
# Python formatting
|
||||||
- id: black
|
- id: black
|
||||||
|
|
@ -56,7 +63,7 @@ repos:
|
||||||
args: [--line-length=120] #From the arduino code style. Add as argument rather than creating a new config file.
|
args: [--line-length=120] #From the arduino code style. Add as argument rather than creating a new config file.
|
||||||
|
|
||||||
- repo: https://github.com/PyCQA/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: "16f5f28a384f0781bebb37a08aa45e65b9526c50" # 7.2.0
|
rev: "7.1.1"
|
||||||
hooks:
|
hooks:
|
||||||
# Python linting
|
# Python linting
|
||||||
- id: flake8
|
- id: flake8
|
||||||
|
|
@ -67,28 +74,21 @@ repos:
|
||||||
- flake8-simplify
|
- flake8-simplify
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||||
rev: "ffb6a759a979008c0e6dff86e39f4745a2d9eac4" # v3.1.0
|
rev: "v3.1.0"
|
||||||
hooks:
|
hooks:
|
||||||
# YAML formatting
|
# YAML formatting
|
||||||
- id: prettier
|
- id: prettier
|
||||||
types_or: [yaml]
|
types_or: [yaml]
|
||||||
|
|
||||||
- repo: https://github.com/codespell-project/codespell
|
|
||||||
rev: "63c8f8312b7559622c0d82815639671ae42132ac" # v2.4.1
|
|
||||||
hooks:
|
|
||||||
# Spell checking
|
|
||||||
- id: codespell
|
|
||||||
exclude: ^.*\.(svd|SVD)$
|
|
||||||
|
|
||||||
- repo: https://github.com/shellcheck-py/shellcheck-py
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
||||||
rev: "a23f6b85d0fdd5bb9d564e2579e678033debbdff" # v0.10.0.1
|
rev: "v0.10.0.1"
|
||||||
hooks:
|
hooks:
|
||||||
# Bash linting
|
# Bash linting
|
||||||
- id: shellcheck
|
- id: shellcheck
|
||||||
types: [shell]
|
types: [shell]
|
||||||
|
|
||||||
- repo: https://github.com/openstack/bashate
|
- repo: https://github.com/openstack/bashate
|
||||||
rev: "fbd7c2534c2701351c603ff700ddf08202430a31" # 2.1.1
|
rev: "2.1.1"
|
||||||
hooks:
|
hooks:
|
||||||
# Bash formatting
|
# Bash formatting
|
||||||
- id: bashate
|
- id: bashate
|
||||||
|
|
@ -96,15 +96,15 @@ repos:
|
||||||
args: ["-i", "E006"] # Ignore E006: Line too long
|
args: ["-i", "E006"] # Ignore E006: Line too long
|
||||||
|
|
||||||
- repo: https://github.com/errata-ai/vale
|
- repo: https://github.com/errata-ai/vale
|
||||||
rev: "dc4c47923788a413fb5677de6e3370d514aecb78" # v3.11.2
|
rev: "v3.9.1"
|
||||||
hooks:
|
hooks:
|
||||||
# Sync vale styles and lint markdown and reStructuredText
|
# Sync vale styles and lint markdown and reStructuredText
|
||||||
- id: vale
|
- id: vale
|
||||||
name: vale-sync
|
name: vale-sync
|
||||||
language_version: "1.23.2"
|
language_version: "1.21.6"
|
||||||
pass_filenames: false
|
pass_filenames: false
|
||||||
args: [sync]
|
args: [sync]
|
||||||
types_or: [markdown, rst]
|
types_or: [markdown, rst]
|
||||||
- id: vale
|
- id: vale
|
||||||
language_version: "1.23.2"
|
language_version: "1.21.6"
|
||||||
types_or: [markdown, rst]
|
types_or: [markdown, rst]
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
# idf.py build
|
# idf.py build
|
||||||
|
|
||||||
set(min_supported_idf_version "5.3.0")
|
set(min_supported_idf_version "5.3.0")
|
||||||
set(max_supported_idf_version "5.5.99")
|
set(max_supported_idf_version "5.4.99")
|
||||||
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
|
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
|
||||||
|
|
||||||
if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
|
if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
|
||||||
|
|
@ -165,7 +165,6 @@ set(ARDUINO_LIBRARY_LittleFS_SRCS libraries/LittleFS/src/LittleFS.cpp)
|
||||||
set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp)
|
set(ARDUINO_LIBRARY_NetBIOS_SRCS libraries/NetBIOS/src/NetBIOS.cpp)
|
||||||
|
|
||||||
set(ARDUINO_LIBRARY_OpenThread_SRCS
|
set(ARDUINO_LIBRARY_OpenThread_SRCS
|
||||||
libraries/OpenThread/src/OThread.cpp
|
|
||||||
libraries/OpenThread/src/OThreadCLI.cpp
|
libraries/OpenThread/src/OThreadCLI.cpp
|
||||||
libraries/OpenThread/src/OThreadCLI_Util.cpp)
|
libraries/OpenThread/src/OThreadCLI_Util.cpp)
|
||||||
|
|
||||||
|
|
@ -184,8 +183,7 @@ set(ARDUINO_LIBRARY_Matter_SRCS
|
||||||
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp
|
libraries/Matter/src/MatterEndpoints/MatterOccupancySensor.cpp
|
||||||
libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp
|
libraries/Matter/src/MatterEndpoints/MatterOnOffPlugin.cpp
|
||||||
libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp
|
libraries/Matter/src/MatterEndpoints/MatterThermostat.cpp
|
||||||
libraries/Matter/src/Matter.cpp
|
libraries/Matter/src/Matter.cpp)
|
||||||
libraries/Matter/src/MatterEndPoint.cpp)
|
|
||||||
|
|
||||||
set(ARDUINO_LIBRARY_PPP_SRCS
|
set(ARDUINO_LIBRARY_PPP_SRCS
|
||||||
libraries/PPP/src/PPP.cpp
|
libraries/PPP/src/PPP.cpp
|
||||||
|
|
@ -302,11 +300,6 @@ set(ARDUINO_LIBRARY_Zigbee_SRCS
|
||||||
libraries/Zigbee/src/ep/ZigbeeGateway.cpp
|
libraries/Zigbee/src/ep/ZigbeeGateway.cpp
|
||||||
libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp
|
libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp
|
||||||
libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.cpp
|
libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.cpp
|
||||||
libraries/Zigbee/src/ep/ZigbeePM25Sensor.cpp
|
|
||||||
libraries/Zigbee/src/ep/ZigbeeElectricalMeasurement.cpp
|
|
||||||
libraries/Zigbee/src/ep/ZigbeeBinary.cpp
|
|
||||||
libraries/Zigbee/src/ep/ZigbeePowerOutlet.cpp
|
|
||||||
libraries/Zigbee/src/ep/ZigbeeFanControl.cpp
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(ARDUINO_LIBRARY_BLE_SRCS
|
set(ARDUINO_LIBRARY_BLE_SRCS
|
||||||
|
|
@ -362,13 +355,13 @@ endforeach()
|
||||||
set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRARIES_INCLUDEDIRS})
|
set(includedirs variants/${CONFIG_ARDUINO_VARIANT}/ cores/esp32/ ${ARDUINO_LIBRARIES_INCLUDEDIRS})
|
||||||
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
|
set(srcs ${CORE_SRCS} ${ARDUINO_LIBRARIES_SRCS})
|
||||||
set(priv_includes cores/esp32/libb64)
|
set(priv_includes cores/esp32/libb64)
|
||||||
set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_ringbuf esp_driver_gptimer esp_driver_usb_serial_jtag driver esp_http_client esp_https_ota)
|
set(requires spi_flash esp_partition mbedtls wpa_supplicant esp_adc esp_eth http_parser esp_ringbuf esp_driver_gptimer esp_driver_usb_serial_jtag driver)
|
||||||
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES})
|
set(priv_requires fatfs nvs_flash app_update spiffs bootloader_support bt esp_hid usb esp_psram ${ARDUINO_LIBRARIES_REQUIRES})
|
||||||
|
|
||||||
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_OpenThread)
|
if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_OpenThread)
|
||||||
#if(CONFIG_SOC_IEEE802154_SUPPORTED) # Does not work!
|
#if(CONFIG_SOC_IEEE802154_SUPPORTED) # Does not work!
|
||||||
#if(CONFIG_OPENTHREAD_ENABLED) # Does not work!
|
#if(CONFIG_OPENTHREAD_ENABLED) # Does not work!
|
||||||
if(IDF_TARGET STREQUAL "esp32c6" OR IDF_TARGET STREQUAL "esp32h2" OR IDF_TARGET STREQUAL "esp32c5") # Sadly only this works
|
if(IDF_TARGET STREQUAL "esp32c6" OR IDF_TARGET STREQUAL "esp32h2") # Sadly only this works
|
||||||
list(APPEND requires openthread)
|
list(APPEND requires openthread)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
2469
boards.txt
2469
boards.txt
File diff suppressed because it is too large
Load diff
|
|
@ -41,6 +41,7 @@
|
||||||
#include "extra_attr.h"
|
#include "extra_attr.h"
|
||||||
|
|
||||||
#include "pins_arduino.h"
|
#include "pins_arduino.h"
|
||||||
|
#include "io_pin_remap.h"
|
||||||
#include "esp32-hal.h"
|
#include "esp32-hal.h"
|
||||||
|
|
||||||
#define PI 3.1415926535897932384626433832795
|
#define PI 3.1415926535897932384626433832795
|
||||||
|
|
@ -250,8 +251,4 @@ void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
|
||||||
void noTone(uint8_t _pin);
|
void noTone(uint8_t _pin);
|
||||||
|
|
||||||
#endif /* __cplusplus */
|
#endif /* __cplusplus */
|
||||||
|
|
||||||
// must be applied last as it overrides some of the above
|
|
||||||
#include "io_pin_remap.h"
|
|
||||||
|
|
||||||
#endif /* _ESP32_CORE_ARDUINO_H_ */
|
#endif /* _ESP32_CORE_ARDUINO_H_ */
|
||||||
|
|
|
||||||
|
|
@ -119,10 +119,10 @@ espHsvColor_t espRgbColorToHsvColor(espRgbColor_t rgb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
espRgbColor_t espXYColorToRgbColor(uint8_t Level, espXyColor_t xy) {
|
espRgbColor_t espXYColorToRgbColor(uint8_t Level, espXyColor_t xy) {
|
||||||
return espXYToRgbColor(Level, xy.x, xy.y, true);
|
return espXYToRgbColor(Level, xy.x, xy.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, bool addXYZScaling) {
|
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y) {
|
||||||
// convert xyY color space to RGB
|
// convert xyY color space to RGB
|
||||||
|
|
||||||
// https://www.easyrgb.com/en/math.php
|
// https://www.easyrgb.com/en/math.php
|
||||||
|
|
@ -156,11 +156,9 @@ espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t curren
|
||||||
// X, Y and Z input refer to a D65/2° standard illuminant.
|
// X, Y and Z input refer to a D65/2° standard illuminant.
|
||||||
// sR, sG and sB (standard RGB) output range = 0 ÷ 255
|
// sR, sG and sB (standard RGB) output range = 0 ÷ 255
|
||||||
// convert XYZ to RGB - CIE XYZ to sRGB
|
// convert XYZ to RGB - CIE XYZ to sRGB
|
||||||
if (addXYZScaling) {
|
|
||||||
X = X / 100.0f;
|
X = X / 100.0f;
|
||||||
Y = Y / 100.0f;
|
Y = Y / 100.0f;
|
||||||
Z = Z / 100.0f;
|
Z = Z / 100.0f;
|
||||||
}
|
|
||||||
|
|
||||||
r = (X * 3.2406f) - (Y * 1.5372f) - (Z * 0.4986f);
|
r = (X * 3.2406f) - (Y * 1.5372f) - (Z * 0.4986f);
|
||||||
g = -(X * 0.9689f) + (Y * 1.8758f) + (Z * 0.0415f);
|
g = -(X * 0.9689f) + (Y * 1.8758f) + (Z * 0.0415f);
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -50,7 +49,7 @@ typedef struct HsvColor_t espHsvColor_t;
|
||||||
typedef struct XyColor_t espXyColor_t;
|
typedef struct XyColor_t espXyColor_t;
|
||||||
typedef struct CtColor_t espCtColor_t;
|
typedef struct CtColor_t espCtColor_t;
|
||||||
|
|
||||||
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y, bool addXYZScaling);
|
espRgbColor_t espXYToRgbColor(uint8_t Level, uint16_t current_X, uint16_t current_Y);
|
||||||
espRgbColor_t espXYColorToRgb(uint8_t Level, espXyColor_t xy);
|
espRgbColor_t espXYColorToRgb(uint8_t Level, espXyColor_t xy);
|
||||||
espXyColor_t espRgbColorToXYColor(espRgbColor_t rgb);
|
espXyColor_t espRgbColorToXYColor(espRgbColor_t rgb);
|
||||||
espXyColor_t espRgbToXYColor(uint8_t r, uint8_t g, uint8_t b);
|
espXyColor_t espRgbToXYColor(uint8_t r, uint8_t g, uint8_t b);
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@
|
||||||
#include "Esp.h"
|
#include "Esp.h"
|
||||||
#include "esp_sleep.h"
|
#include "esp_sleep.h"
|
||||||
#include "spi_flash_mmap.h"
|
#include "spi_flash_mmap.h"
|
||||||
#include "esp_idf_version.h"
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <soc/soc.h>
|
#include <soc/soc.h>
|
||||||
#include <esp_partition.h>
|
#include <esp_partition.h>
|
||||||
|
|
@ -64,9 +63,6 @@ extern "C" {
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/spi_flash.h"
|
#include "esp32p4/rom/spi_flash.h"
|
||||||
#define ESP_FLASH_IMAGE_BASE 0x2000 // Esp32p4 is located at 0x2000
|
#define ESP_FLASH_IMAGE_BASE 0x2000 // Esp32p4 is located at 0x2000
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/spi_flash.h"
|
|
||||||
#define ESP_FLASH_IMAGE_BASE 0x2000 // Esp32c5 is located at 0x2000
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -305,11 +301,6 @@ const char *EspClass::getChipModel(void) {
|
||||||
case CHIP_ESP32C6: return "ESP32-C6";
|
case CHIP_ESP32C6: return "ESP32-C6";
|
||||||
case CHIP_ESP32H2: return "ESP32-H2";
|
case CHIP_ESP32H2: return "ESP32-H2";
|
||||||
case CHIP_ESP32P4: return "ESP32-P4";
|
case CHIP_ESP32P4: return "ESP32-P4";
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
|
||||||
case CHIP_ESP32C5: return "ESP32-C5";
|
|
||||||
case CHIP_ESP32C61: return "ESP32-C61";
|
|
||||||
case CHIP_ESP32H21: return "ESP32-H21";
|
|
||||||
#endif
|
|
||||||
default: return "UNKNOWN";
|
default: return "UNKNOWN";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -603,7 +603,6 @@ void HWCDC::setDebugOutput(bool en) {
|
||||||
} else {
|
} else {
|
||||||
ets_install_putc2(NULL);
|
ets_install_putc2(NULL);
|
||||||
}
|
}
|
||||||
ets_install_putc1(NULL); // closes UART log output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected
|
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,6 @@
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include "Stream.h"
|
#include "Stream.h"
|
||||||
#include <functional>
|
|
||||||
|
|
||||||
class HardwareI2C : public Stream {
|
class HardwareI2C : public Stream {
|
||||||
public:
|
public:
|
||||||
|
|
@ -37,7 +36,6 @@ public:
|
||||||
virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit) = 0;
|
virtual size_t requestFrom(uint8_t address, size_t len, bool stopBit) = 0;
|
||||||
virtual size_t requestFrom(uint8_t address, size_t len) = 0;
|
virtual size_t requestFrom(uint8_t address, size_t len) = 0;
|
||||||
|
|
||||||
// Update base class to use std::function
|
virtual void onReceive(void (*)(int)) = 0;
|
||||||
virtual void onReceive(const std::function<void(int)> &) = 0;
|
virtual void onRequest(void (*)(void)) = 0;
|
||||||
virtual void onRequest(const std::function<void()> &) = 0;
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -607,24 +607,6 @@ bool HardwareSerial::setMode(SerialMode mode) {
|
||||||
return uartSetMode(_uart, mode);
|
return uartSetMode(_uart, mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sets the UART Clock Source based on the compatible SoC options
|
|
||||||
// This method must be called before starting UART using begin(), otherwise it won't have any effect.
|
|
||||||
// Clock Source Options are:
|
|
||||||
// UART_CLK_SRC_DEFAULT :: any SoC - it will set whatever IDF defines as the default UART Clock Source
|
|
||||||
// UART_CLK_SRC_APB :: ESP32, ESP32-S2, ESP32-C3 and ESP32-S3
|
|
||||||
// UART_CLK_SRC_PLL :: ESP32-C2, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_XTAL :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_RTC :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_REF_TICK :: ESP32 and ESP32-S2
|
|
||||||
// Note: CLK_SRC_PLL Freq depends on the SoC - ESP32-C2 has 40MHz, ESP32-H2 has 48MHz and ESP32-C5, C6, C61 and P4 has 80MHz
|
|
||||||
// Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only RTC_FAST or XTAL/2 as Clock Source
|
|
||||||
bool HardwareSerial::setClockSource(SerialClkSrc clkSrc) {
|
|
||||||
if (_uart) {
|
|
||||||
log_e("No Clock Source change was done. This function must be called before beginning UART%d.", _uart_nr);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return uartSetClockSource(_uart_nr, (uart_sclk_t)clkSrc);
|
|
||||||
}
|
|
||||||
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
|
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
|
||||||
// LP UART has FIFO of 16 bytes
|
// LP UART has FIFO of 16 bytes
|
||||||
size_t HardwareSerial::setRxBufferSize(size_t new_size) {
|
size_t HardwareSerial::setRxBufferSize(size_t new_size) {
|
||||||
|
|
|
||||||
|
|
@ -96,29 +96,6 @@ typedef enum {
|
||||||
UART_PARITY_ERROR
|
UART_PARITY_ERROR
|
||||||
} hardwareSerial_error_t;
|
} hardwareSerial_error_t;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
UART_CLK_SRC_DEFAULT = UART_SCLK_DEFAULT,
|
|
||||||
#if SOC_UART_SUPPORT_APB_CLK
|
|
||||||
UART_CLK_SRC_APB = UART_SCLK_APB,
|
|
||||||
#endif
|
|
||||||
#if SOC_UART_SUPPORT_PLL_F40M_CLK
|
|
||||||
UART_CLK_SRC_PLL = UART_SCLK_PLL_F40M,
|
|
||||||
#elif SOC_UART_SUPPORT_PLL_F80M_CLK
|
|
||||||
UART_CLK_SRC_PLL = UART_SCLK_PLL_F80M,
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32H2
|
|
||||||
UART_CLK_SRC_PLL = UART_SCLK_PLL_F48M,
|
|
||||||
#endif
|
|
||||||
#if SOC_UART_SUPPORT_XTAL_CLK
|
|
||||||
UART_CLK_SRC_XTAL = UART_SCLK_XTAL,
|
|
||||||
#endif
|
|
||||||
#if SOC_UART_SUPPORT_RTC_CLK
|
|
||||||
UART_CLK_SRC_RTC = UART_SCLK_RTC,
|
|
||||||
#endif
|
|
||||||
#if SOC_UART_SUPPORT_REF_TICK
|
|
||||||
UART_CLK_SRC_REF_TICK = UART_SCLK_REF_TICK,
|
|
||||||
#endif
|
|
||||||
} SerialClkSrc;
|
|
||||||
|
|
||||||
#ifndef ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
|
#ifndef ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
|
||||||
#ifndef CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
|
#ifndef CONFIG_ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE
|
||||||
#define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048
|
#define ARDUINO_SERIAL_EVENT_TASK_STACK_SIZE 2048
|
||||||
|
|
@ -162,8 +139,6 @@ typedef enum {
|
||||||
#define SOC_RX0 (gpio_num_t)23
|
#define SOC_RX0 (gpio_num_t)23
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define SOC_RX0 (gpio_num_t)38
|
#define SOC_RX0 (gpio_num_t)38
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#define SOC_RX0 (gpio_num_t)12
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -182,8 +157,6 @@ typedef enum {
|
||||||
#define SOC_TX0 (gpio_num_t)24
|
#define SOC_TX0 (gpio_num_t)24
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define SOC_TX0 (gpio_num_t)37
|
#define SOC_TX0 (gpio_num_t)37
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#define SOC_TX0 (gpio_num_t)11
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -207,8 +180,6 @@ typedef enum {
|
||||||
#define RX1 (gpio_num_t)0
|
#define RX1 (gpio_num_t)0
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define RX1 (gpio_num_t)11
|
#define RX1 (gpio_num_t)11
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#define RX1 (gpio_num_t)4
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -229,8 +200,6 @@ typedef enum {
|
||||||
#define TX1 (gpio_num_t)1
|
#define TX1 (gpio_num_t)1
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#define TX1 (gpio_num_t)10
|
#define TX1 (gpio_num_t)10
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#define TX1 (gpio_num_t)5
|
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif /* SOC_UART_HP_NUM > 1 */
|
#endif /* SOC_UART_HP_NUM > 1 */
|
||||||
|
|
@ -375,17 +344,6 @@ public:
|
||||||
// UART_MODE_RS485_COLLISION_DETECT = 0x03 mode: RS485 collision detection UART mode (used for test purposes)
|
// UART_MODE_RS485_COLLISION_DETECT = 0x03 mode: RS485 collision detection UART mode (used for test purposes)
|
||||||
// UART_MODE_RS485_APP_CTRL = 0x04 mode: application control RS485 UART mode (used for test purposes)
|
// UART_MODE_RS485_APP_CTRL = 0x04 mode: application control RS485 UART mode (used for test purposes)
|
||||||
bool setMode(SerialMode mode);
|
bool setMode(SerialMode mode);
|
||||||
// Used to set the UART clock source mode. It must be set before calling begin(), otherwise it won't have any effect.
|
|
||||||
// Not all clock source are available to every SoC. The compatible option are listed here:
|
|
||||||
// UART_CLK_SRC_DEFAULT :: any SoC - it will set whatever IDF defines as the default UART Clock Source
|
|
||||||
// UART_CLK_SRC_APB :: ESP32, ESP32-S2, ESP32-C3 and ESP32-S3
|
|
||||||
// UART_CLK_SRC_PLL :: ESP32-C2, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_XTAL :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_RTC :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_CLK_SRC_REF_TICK :: ESP32 and ESP32-S2
|
|
||||||
// Note: CLK_SRC_PLL Freq depends on the SoC - ESP32-C2 has 40MHz, ESP32-H2 has 48MHz and ESP32-C5, C6, C61 and P4 has 80MHz
|
|
||||||
// Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only RTC_FAST or XTAL/2 as Clock Source
|
|
||||||
bool setClockSource(SerialClkSrc clkSrc);
|
|
||||||
size_t setRxBufferSize(size_t new_size);
|
size_t setRxBufferSize(size_t new_size);
|
||||||
size_t setTxBufferSize(size_t new_size);
|
size_t setTxBufferSize(size_t new_size);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,7 +100,6 @@ static bool tinyusb_device_suspended = false;
|
||||||
void tud_mount_cb(void) {
|
void tud_mount_cb(void) {
|
||||||
tinyusb_device_mounted = true;
|
tinyusb_device_mounted = true;
|
||||||
arduino_usb_event_data_t p;
|
arduino_usb_event_data_t p;
|
||||||
p.suspend.remote_wakeup_en = 0;
|
|
||||||
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STARTED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STARTED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +107,6 @@ void tud_mount_cb(void) {
|
||||||
void tud_umount_cb(void) {
|
void tud_umount_cb(void) {
|
||||||
tinyusb_device_mounted = false;
|
tinyusb_device_mounted = false;
|
||||||
arduino_usb_event_data_t p;
|
arduino_usb_event_data_t p;
|
||||||
p.suspend.remote_wakeup_en = 0;
|
|
||||||
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STOPPED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_STOPPED_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -125,7 +123,6 @@ void tud_suspend_cb(bool remote_wakeup_en) {
|
||||||
void tud_resume_cb(void) {
|
void tud_resume_cb(void) {
|
||||||
tinyusb_device_suspended = false;
|
tinyusb_device_suspended = false;
|
||||||
arduino_usb_event_data_t p;
|
arduino_usb_event_data_t p;
|
||||||
p.suspend.remote_wakeup_en = 0;
|
|
||||||
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_RESUME_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
arduino_usb_event_post(ARDUINO_USB_EVENTS, ARDUINO_USB_RESUME_EVENT, &p, sizeof(arduino_usb_event_data_t), portMAX_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -455,7 +455,6 @@ void USBCDC::setDebugOutput(bool en) {
|
||||||
} else {
|
} else {
|
||||||
ets_install_putc2(NULL);
|
ets_install_putc2(NULL);
|
||||||
}
|
}
|
||||||
ets_install_putc1(NULL); // closes UART log output
|
|
||||||
}
|
}
|
||||||
|
|
||||||
USBCDC::operator bool() const {
|
USBCDC::operator bool() const {
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
||||||
if (maxStrLen < sizeof(sso.buff) - 1) {
|
if (maxStrLen < sizeof(sso.buff) - 1) {
|
||||||
if (isSSO() || !buffer()) {
|
if (isSSO() || !buffer()) {
|
||||||
// Already using SSO, nothing to do
|
// Already using SSO, nothing to do
|
||||||
size_t oldLen = len();
|
uint16_t oldLen = len();
|
||||||
setSSO(true);
|
setSSO(true);
|
||||||
setLen(oldLen);
|
setLen(oldLen);
|
||||||
} else { // if bufptr && !isSSO()
|
} else { // if bufptr && !isSSO()
|
||||||
|
|
@ -188,7 +188,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
||||||
char temp[sizeof(sso.buff)];
|
char temp[sizeof(sso.buff)];
|
||||||
memcpy(temp, buffer(), maxStrLen);
|
memcpy(temp, buffer(), maxStrLen);
|
||||||
free(wbuffer());
|
free(wbuffer());
|
||||||
size_t oldLen = len();
|
uint16_t oldLen = len();
|
||||||
setSSO(true);
|
setSSO(true);
|
||||||
memcpy(wbuffer(), temp, maxStrLen);
|
memcpy(wbuffer(), temp, maxStrLen);
|
||||||
setLen(oldLen);
|
setLen(oldLen);
|
||||||
|
|
@ -201,7 +201,7 @@ bool String::changeBuffer(unsigned int maxStrLen) {
|
||||||
if (newSize > CAPACITY_MAX) {
|
if (newSize > CAPACITY_MAX) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
size_t oldLen = len();
|
uint16_t oldLen = len();
|
||||||
char *newbuffer = (char *)realloc(isSSO() ? nullptr : wbuffer(), newSize);
|
char *newbuffer = (char *)realloc(isSSO() ? nullptr : wbuffer(), newSize);
|
||||||
if (newbuffer) {
|
if (newbuffer) {
|
||||||
size_t oldSize = capacity() + 1; // include NULL.
|
size_t oldSize = capacity() + 1; // include NULL.
|
||||||
|
|
|
||||||
|
|
@ -67,10 +67,6 @@ static void printPkgVersion(void) {
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_RD_MAC_SYS_2_REG, EFUSE_PKG_VERSION);
|
uint32_t pkg_ver = REG_GET_FIELD(EFUSE_RD_MAC_SYS_2_REG, EFUSE_PKG_VERSION);
|
||||||
chip_report_printf("%lu", pkg_ver);
|
chip_report_printf("%lu", pkg_ver);
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
// ToDo: Update this line when EFUSE_PKG_VERSION is available again for ESP32-C5
|
|
||||||
uint32_t pkg_ver = 0; //REG_GET_FIELD(EFUSE_RD_MAC_SYS2_REG, EFUSE_PKG_VERSION);
|
|
||||||
chip_report_printf("%lu", pkg_ver);
|
|
||||||
#else
|
#else
|
||||||
chip_report_printf("Unknown");
|
chip_report_printf("Unknown");
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -92,11 +88,6 @@ static void printChipInfo(void) {
|
||||||
case CHIP_ESP32C6: chip_report_printf("ESP32-C6\n"); break;
|
case CHIP_ESP32C6: chip_report_printf("ESP32-C6\n"); break;
|
||||||
case CHIP_ESP32H2: chip_report_printf("ESP32-H2\n"); break;
|
case CHIP_ESP32H2: chip_report_printf("ESP32-H2\n"); break;
|
||||||
case CHIP_ESP32P4: chip_report_printf("ESP32-P4\n"); break;
|
case CHIP_ESP32P4: chip_report_printf("ESP32-P4\n"); break;
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
|
||||||
case CHIP_ESP32C5: chip_report_printf("ESP32-C5\n"); break;
|
|
||||||
case CHIP_ESP32C61: chip_report_printf("ESP32-C61\n"); break;
|
|
||||||
case CHIP_ESP32H21: chip_report_printf("ESP32-H21\n"); break;
|
|
||||||
#endif
|
|
||||||
default: chip_report_printf("Unknown %d\n", info.model); break;
|
default: chip_report_printf("Unknown %d\n", info.model); break;
|
||||||
}
|
}
|
||||||
printPkgVersion();
|
printPkgVersion();
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@
|
||||||
#include "esp32-hal-bt.h"
|
#include "esp32-hal-bt.h"
|
||||||
|
|
||||||
#if SOC_BT_SUPPORTED
|
#if SOC_BT_SUPPORTED
|
||||||
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && __has_include("esp_bt.h")
|
#ifdef CONFIG_BT_ENABLED
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
bool btInUse() {
|
bool btInUse() {
|
||||||
|
|
@ -116,7 +116,7 @@ bool btStop() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // !__has_include("esp_bt.h") || !(defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED))
|
#else // CONFIG_BT_ENABLED
|
||||||
bool btStarted() {
|
bool btStarted() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -129,6 +129,6 @@ bool btStop() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* !__has_include("esp_bt.h") || !(defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) */
|
#endif /* CONFIG_BT_ENABLED */
|
||||||
|
|
||||||
#endif /* SOC_BT_SUPPORTED */
|
#endif /* SOC_BT_SUPPORTED */
|
||||||
|
|
|
||||||
|
|
@ -19,16 +19,13 @@
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_log.h"
|
#include "esp_log.h"
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) \
|
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4)
|
||||||
&& !defined(CONFIG_IDF_TARGET_ESP32C5)
|
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/syscon_reg.h"
|
#include "soc/syscon_reg.h"
|
||||||
#endif
|
#endif
|
||||||
#include "soc/efuse_reg.h"
|
#include "soc/efuse_reg.h"
|
||||||
#include "esp32-hal.h"
|
#include "esp32-hal.h"
|
||||||
#include "esp32-hal-cpu.h"
|
#include "esp32-hal-cpu.h"
|
||||||
#include "hal/timer_ll.h"
|
|
||||||
#include "esp_private/systimer.h"
|
|
||||||
|
|
||||||
#include "esp_system.h"
|
#include "esp_system.h"
|
||||||
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
|
#ifdef ESP_IDF_VERSION_MAJOR // IDF 4+
|
||||||
|
|
@ -51,8 +48,6 @@
|
||||||
#include "esp32h2/rom/rtc.h"
|
#include "esp32h2/rom/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/rtc.h"
|
#include "esp32p4/rom/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/rtc.h"
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -178,15 +173,13 @@ static uint32_t calculateApb(rtc_cpu_freq_config_t *conf) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_IDF_TARGET_ESP32) && !defined(LACT_MODULE) && !defined(LACT_TICKS_PER_US)
|
|
||||||
void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us); //private in IDF
|
void esp_timer_impl_update_apb_freq(uint32_t apb_ticks_per_us); //private in IDF
|
||||||
#endif
|
|
||||||
|
|
||||||
bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
|
bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
|
||||||
rtc_cpu_freq_config_t conf, cconf;
|
rtc_cpu_freq_config_t conf, cconf;
|
||||||
uint32_t capb, apb;
|
uint32_t capb, apb;
|
||||||
//Get XTAL Frequency and calculate min CPU MHz
|
//Get XTAL Frequency and calculate min CPU MHz
|
||||||
#if (!defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) && !defined(CONFIG_IDF_TARGET_ESP32C5))
|
#if (!defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4))
|
||||||
rtc_xtal_freq_t xtal = rtc_clk_xtal_freq_get();
|
rtc_xtal_freq_t xtal = rtc_clk_xtal_freq_get();
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
|
@ -202,7 +195,7 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if (!defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) && !defined(CONFIG_IDF_TARGET_ESP32C5))
|
#if (!defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4))
|
||||||
if (cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 120 && cpu_freq_mhz != 80) {
|
if (cpu_freq_mhz > xtal && cpu_freq_mhz != 240 && cpu_freq_mhz != 160 && cpu_freq_mhz != 120 && cpu_freq_mhz != 80) {
|
||||||
if (xtal >= RTC_XTAL_FREQ_40M) {
|
if (xtal >= RTC_XTAL_FREQ_40M) {
|
||||||
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal / 2, xtal / 4);
|
log_e("Bad frequency: %u MHz! Options are: 240, 160, 120, 80, %u, %u and %u MHz", cpu_freq_mhz, xtal, xtal / 2, xtal / 4);
|
||||||
|
|
@ -253,13 +246,7 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
|
||||||
//Update APB Freq REG
|
//Update APB Freq REG
|
||||||
rtc_clk_apb_freq_update(apb);
|
rtc_clk_apb_freq_update(apb);
|
||||||
//Update esp_timer divisor
|
//Update esp_timer divisor
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
|
||||||
#if defined(LACT_MODULE) && defined(LACT_TICKS_PER_US)
|
|
||||||
timer_ll_set_lact_clock_prescale(TIMER_LL_GET_HW(LACT_MODULE), apb / MHZ / LACT_TICKS_PER_US);
|
|
||||||
#else
|
|
||||||
esp_timer_impl_update_apb_freq(apb / MHZ);
|
esp_timer_impl_update_apb_freq(apb / MHZ);
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
//Update FreeRTOS Tick Divisor
|
//Update FreeRTOS Tick Divisor
|
||||||
|
|
@ -278,12 +265,6 @@ bool setCpuFrequencyMhz(uint32_t cpu_freq_mhz) {
|
||||||
(conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_APLL) ? "APLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "8M")),
|
(conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_APLL) ? "APLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "8M")),
|
||||||
conf.source_freq_mhz, conf.div, conf.freq_mhz, apb
|
conf.source_freq_mhz, conf.div, conf.freq_mhz, apb
|
||||||
);
|
);
|
||||||
#elif defined(CONFIG_IDF_TARGET_ESP32C5)
|
|
||||||
log_d(
|
|
||||||
"%s: %u / %u = %u Mhz, APB: %u Hz",
|
|
||||||
(conf.source == SOC_CPU_CLK_SRC_PLL_F240M || conf.source == SOC_CPU_CLK_SRC_PLL_F160M) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "8M"),
|
|
||||||
conf.source_freq_mhz, conf.div, conf.freq_mhz, apb
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
log_d(
|
log_d(
|
||||||
"%s: %u / %u = %u Mhz, APB: %u Hz", (conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "17.5M"),
|
"%s: %u / %u = %u Mhz, APB: %u Hz", (conf.source == SOC_CPU_CLK_SRC_PLL) ? "PLL" : ((conf.source == SOC_CPU_CLK_SRC_XTAL) ? "XTAL" : "17.5M"),
|
||||||
|
|
|
||||||
|
|
@ -185,7 +185,7 @@ extern int ARDUINO_ISR_ATTR __digitalRead(uint8_t pin) {
|
||||||
#endif // RGB_BUILTIN
|
#endif // RGB_BUILTIN
|
||||||
// This work when the pin is set as GPIO and in INPUT mode. For all other pin functions, it may return inconsistent response
|
// This work when the pin is set as GPIO and in INPUT mode. For all other pin functions, it may return inconsistent response
|
||||||
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) {
|
if (perimanGetPinBus(pin, ESP32_BUS_TYPE_GPIO) == NULL) {
|
||||||
log_w("IO %i is not set as GPIO. digitalRead() may return an inconsistent value.", pin);
|
log_w("IO %i is not set as GPIO. digitalRead() may return an inconsistent value.");
|
||||||
}
|
}
|
||||||
return gpio_get_level((gpio_num_t)pin);
|
return gpio_get_level((gpio_num_t)pin);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,13 +56,6 @@ static bool i2cDetachBus(void *bus_i2c_num) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void *i2cBusHandle(uint8_t i2c_num) {
|
|
||||||
if (i2c_num >= SOC_I2C_NUM) {
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
return bus[i2c_num].bus_handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool i2cIsInit(uint8_t i2c_num) {
|
bool i2cIsInit(uint8_t i2c_num) {
|
||||||
if (i2c_num >= SOC_I2C_NUM) {
|
if (i2c_num >= SOC_I2C_NUM) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -43,10 +43,7 @@
|
||||||
#include "soc/i2c_struct.h"
|
#include "soc/i2c_struct.h"
|
||||||
#include "soc/periph_defs.h"
|
#include "soc/periph_defs.h"
|
||||||
#include "hal/i2c_ll.h"
|
#include "hal/i2c_ll.h"
|
||||||
#include "hal/i2c_types.h"
|
|
||||||
#ifndef CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "hal/clk_gate_ll.h"
|
#include "hal/clk_gate_ll.h"
|
||||||
#endif
|
|
||||||
#include "esp32-hal-log.h"
|
#include "esp32-hal-log.h"
|
||||||
#include "esp32-hal-i2c-slave.h"
|
#include "esp32-hal-i2c-slave.h"
|
||||||
#include "esp32-hal-periman.h"
|
#include "esp32-hal-periman.h"
|
||||||
|
|
@ -328,7 +325,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
|
||||||
frequency = 100000L;
|
frequency = 100000L;
|
||||||
}
|
}
|
||||||
frequency = (frequency * 5) / 4;
|
frequency = (frequency * 5) / 4;
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32P4) && !defined(CONFIG_IDF_TARGET_ESP32C5)
|
#if !defined(CONFIG_IDF_TARGET_ESP32P4)
|
||||||
if (i2c->num == 0) {
|
if (i2c->num == 0) {
|
||||||
periph_ll_enable_clk_clear_rst(PERIPH_I2C0_MODULE);
|
periph_ll_enable_clk_clear_rst(PERIPH_I2C0_MODULE);
|
||||||
#if SOC_HP_I2C_NUM > 1
|
#if SOC_HP_I2C_NUM > 1
|
||||||
|
|
@ -338,18 +335,11 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
|
||||||
}
|
}
|
||||||
#endif // !defined(CONFIG_IDF_TARGET_ESP32P4)
|
#endif // !defined(CONFIG_IDF_TARGET_ESP32P4)
|
||||||
|
|
||||||
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)) || (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 5, 0)) \
|
i2c_ll_slave_init(i2c->dev);
|
||||||
|| (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 3, 3) && ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 4, 0))
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||||
i2c_ll_set_mode(i2c->dev, I2C_BUS_MODE_SLAVE);
|
|
||||||
i2c_ll_enable_pins_open_drain(i2c->dev, true);
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
|
||||||
i2c_ll_enable_fifo_mode(i2c->dev, true);
|
i2c_ll_enable_fifo_mode(i2c->dev, true);
|
||||||
#else
|
#else
|
||||||
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
|
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
i2c_ll_slave_init(i2c->dev);
|
|
||||||
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
|
|
||||||
#endif
|
#endif
|
||||||
i2c_ll_set_slave_addr(i2c->dev, slaveID, false);
|
i2c_ll_set_slave_addr(i2c->dev, slaveID, false);
|
||||||
i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT);
|
i2c_ll_set_tout(i2c->dev, I2C_LL_MAX_TIMEOUT);
|
||||||
|
|
@ -371,7 +361,7 @@ esp_err_t i2cSlaveInit(uint8_t num, int sda, int scl, uint16_t slaveID, uint32_t
|
||||||
|
|
||||||
i2c_ll_disable_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
|
i2c_ll_disable_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
|
||||||
i2c_ll_clear_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
|
i2c_ll_clear_intr_mask(i2c->dev, I2C_LL_INTR_MASK);
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 2)
|
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
||||||
i2c_ll_enable_fifo_mode(i2c->dev, true);
|
i2c_ll_enable_fifo_mode(i2c->dev, true);
|
||||||
#else
|
#else
|
||||||
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
|
i2c_ll_slave_set_fifo_mode(i2c->dev, true);
|
||||||
|
|
@ -566,9 +556,6 @@ static bool i2c_slave_set_frequency(i2c_slave_struct_t *i2c, uint32_t clk_speed)
|
||||||
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_APB); /*!< I2C source clock from APB, 80M*/
|
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_APB); /*!< I2C source clock from APB, 80M*/
|
||||||
}
|
}
|
||||||
#elif SOC_I2C_SUPPORT_XTAL
|
#elif SOC_I2C_SUPPORT_XTAL
|
||||||
#ifndef XTAL_CLK_FREQ
|
|
||||||
#define XTAL_CLK_FREQ APB_CLK_FREQ
|
|
||||||
#endif
|
|
||||||
i2c_ll_master_cal_bus_clk(XTAL_CLK_FREQ, clk_speed, &clk_cal);
|
i2c_ll_master_cal_bus_clk(XTAL_CLK_FREQ, clk_speed, &clk_cal);
|
||||||
I2C_CLOCK_SRC_ATOMIC() {
|
I2C_CLOCK_SRC_ATOMIC() {
|
||||||
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_XTAL); /*!< I2C source clock from XTAL, 40M */
|
i2c_ll_set_source_clk(i2c->dev, SOC_MOD_CLK_XTAL); /*!< I2C source clock from XTAL, 40M */
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,6 @@
|
||||||
|
|
||||||
#include "soc/soc_caps.h"
|
#include "soc/soc_caps.h"
|
||||||
#if SOC_I2C_SUPPORTED
|
#if SOC_I2C_SUPPORTED
|
||||||
#include "esp_idf_version.h"
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -40,10 +39,6 @@ esp_err_t i2cWriteReadNonStop(
|
||||||
);
|
);
|
||||||
bool i2cIsInit(uint8_t i2c_num);
|
bool i2cIsInit(uint8_t i2c_num);
|
||||||
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
|
||||||
void *i2cBusHandle(uint8_t i2c_num);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,6 @@
|
||||||
#include "soc/gpio_sig_map.h"
|
#include "soc/gpio_sig_map.h"
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "hal/ledc_ll.h"
|
#include "hal/ledc_ll.h"
|
||||||
#if SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED
|
|
||||||
#include <math.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||||
#define LEDC_CHANNELS (SOC_LEDC_CHANNEL_NUM << 1)
|
#define LEDC_CHANNELS (SOC_LEDC_CHANNEL_NUM << 1)
|
||||||
|
|
@ -48,96 +45,6 @@ typedef struct {
|
||||||
|
|
||||||
ledc_periph_t ledc_handle = {0};
|
ledc_periph_t ledc_handle = {0};
|
||||||
|
|
||||||
// Helper function to find a timer with matching frequency and resolution
|
|
||||||
static bool find_matching_timer(uint8_t speed_mode, uint32_t freq, uint8_t resolution, uint8_t *timer_num) {
|
|
||||||
log_d("Searching for timer with freq=%u, resolution=%u", freq, resolution);
|
|
||||||
// Check all channels to find one with matching frequency and resolution
|
|
||||||
for (uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++) {
|
|
||||||
if (!perimanPinIsValid(i)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
peripheral_bus_type_t type = perimanGetPinBusType(i);
|
|
||||||
if (type == ESP32_BUS_TYPE_LEDC) {
|
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(i, ESP32_BUS_TYPE_LEDC);
|
|
||||||
if (bus != NULL && (bus->channel / SOC_LEDC_CHANNEL_NUM) == speed_mode && bus->freq_hz == freq && bus->channel_resolution == resolution) {
|
|
||||||
log_d("Found matching timer %u for freq=%u, resolution=%u", bus->timer_num, freq, resolution);
|
|
||||||
*timer_num = bus->timer_num;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log_d("No matching timer found for freq=%u, resolution=%u", freq, resolution);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to find an unused timer
|
|
||||||
static bool find_free_timer(uint8_t speed_mode, uint8_t *timer_num) {
|
|
||||||
// Check which timers are in use
|
|
||||||
uint8_t used_timers = 0;
|
|
||||||
for (uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++) {
|
|
||||||
if (!perimanPinIsValid(i)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
peripheral_bus_type_t type = perimanGetPinBusType(i);
|
|
||||||
if (type == ESP32_BUS_TYPE_LEDC) {
|
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(i, ESP32_BUS_TYPE_LEDC);
|
|
||||||
if (bus != NULL && (bus->channel / SOC_LEDC_CHANNEL_NUM) == speed_mode) {
|
|
||||||
log_d("Timer %u is in use by channel %u", bus->timer_num, bus->channel);
|
|
||||||
used_timers |= (1 << bus->timer_num);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifndef SOC_LEDC_TIMER_NUM
|
|
||||||
#define SOC_LEDC_TIMER_NUM 4
|
|
||||||
#endif
|
|
||||||
// Find first unused timer
|
|
||||||
for (uint8_t i = 0; i < SOC_LEDC_TIMER_NUM; i++) {
|
|
||||||
if (!(used_timers & (1 << i))) {
|
|
||||||
log_d("Found free timer %u", i);
|
|
||||||
*timer_num = i;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
log_e("No free timers available");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Helper function to remove a channel from a timer and clear timer if no channels are using it
|
|
||||||
static void remove_channel_from_timer(uint8_t speed_mode, uint8_t timer_num, uint8_t channel) {
|
|
||||||
log_d("Removing channel %u from timer %u in speed_mode %u", channel, timer_num, speed_mode);
|
|
||||||
|
|
||||||
// Check if any other channels are using this timer
|
|
||||||
bool timer_in_use = false;
|
|
||||||
for (uint8_t i = 0; i < SOC_GPIO_PIN_COUNT; i++) {
|
|
||||||
if (!perimanPinIsValid(i)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
peripheral_bus_type_t type = perimanGetPinBusType(i);
|
|
||||||
if (type == ESP32_BUS_TYPE_LEDC) {
|
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(i, ESP32_BUS_TYPE_LEDC);
|
|
||||||
if (bus != NULL && (bus->channel / SOC_LEDC_CHANNEL_NUM) == speed_mode && bus->timer_num == timer_num && bus->channel != channel) {
|
|
||||||
log_d("Timer %u is still in use by channel %u", timer_num, bus->channel);
|
|
||||||
timer_in_use = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!timer_in_use) {
|
|
||||||
log_d("No other channels using timer %u, deconfiguring timer", timer_num);
|
|
||||||
// Stop the timer
|
|
||||||
ledc_timer_pause(speed_mode, timer_num);
|
|
||||||
// Deconfigure the timer
|
|
||||||
ledc_timer_config_t ledc_timer;
|
|
||||||
memset((void *)&ledc_timer, 0, sizeof(ledc_timer_config_t));
|
|
||||||
ledc_timer.speed_mode = speed_mode;
|
|
||||||
ledc_timer.timer_num = timer_num;
|
|
||||||
ledc_timer.deconfigure = true;
|
|
||||||
ledc_timer_config(&ledc_timer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool fade_initialized = false;
|
static bool fade_initialized = false;
|
||||||
|
|
||||||
static ledc_clk_cfg_t clock_source = LEDC_DEFAULT_CLK;
|
static ledc_clk_cfg_t clock_source = LEDC_DEFAULT_CLK;
|
||||||
|
|
@ -174,8 +81,6 @@ static bool ledcDetachBus(void *bus) {
|
||||||
}
|
}
|
||||||
pinMatrixOutDetach(handle->pin, false, false);
|
pinMatrixOutDetach(handle->pin, false, false);
|
||||||
if (!channel_found) {
|
if (!channel_found) {
|
||||||
uint8_t group = (handle->channel / SOC_LEDC_CHANNEL_NUM);
|
|
||||||
remove_channel_from_timer(group, handle->timer_num, handle->channel % SOC_LEDC_CHANNEL_NUM);
|
|
||||||
ledc_handle.used_channels &= ~(1UL << handle->channel);
|
ledc_handle.used_channels &= ~(1UL << handle->channel);
|
||||||
}
|
}
|
||||||
free(handle);
|
free(handle);
|
||||||
|
|
@ -212,59 +117,32 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t group = (channel / SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (channel / 8), timer = ((channel / 2) % 4);
|
||||||
uint8_t timer = 0;
|
|
||||||
bool channel_used = ledc_handle.used_channels & (1UL << channel);
|
bool channel_used = ledc_handle.used_channels & (1UL << channel);
|
||||||
|
|
||||||
if (channel_used) {
|
if (channel_used) {
|
||||||
log_i("Channel %u is already set up, given frequency and resolution will be ignored", channel);
|
log_i("Channel %u is already set up, given frequency and resolution will be ignored", channel);
|
||||||
if (ledc_set_pin(pin, group, channel % SOC_LEDC_CHANNEL_NUM) != ESP_OK) {
|
if (ledc_set_pin(pin, group, channel % 8) != ESP_OK) {
|
||||||
log_e("Attaching pin to already used channel failed!");
|
log_e("Attaching pin to already used channel failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Find a timer with matching frequency and resolution, or a free timer
|
ledc_timer_config_t ledc_timer = {.speed_mode = group, .timer_num = timer, .duty_resolution = resolution, .freq_hz = freq, .clk_cfg = clock_source};
|
||||||
if (!find_matching_timer(group, freq, resolution, &timer)) {
|
|
||||||
if (!find_free_timer(group, &timer)) {
|
|
||||||
log_w("No free timers available for speed mode %u", group);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the timer if we're using a new one
|
|
||||||
ledc_timer_config_t ledc_timer;
|
|
||||||
memset((void *)&ledc_timer, 0, sizeof(ledc_timer_config_t));
|
|
||||||
ledc_timer.speed_mode = group;
|
|
||||||
ledc_timer.timer_num = timer;
|
|
||||||
ledc_timer.duty_resolution = resolution;
|
|
||||||
ledc_timer.freq_hz = freq;
|
|
||||||
ledc_timer.clk_cfg = clock_source;
|
|
||||||
|
|
||||||
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
||||||
log_e("ledc setup failed!");
|
log_e("ledc setup failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t duty = ledc_get_duty(group, (channel % SOC_LEDC_CHANNEL_NUM));
|
uint32_t duty = ledc_get_duty(group, (channel % 8));
|
||||||
|
|
||||||
ledc_channel_config_t ledc_channel;
|
|
||||||
memset((void *)&ledc_channel, 0, sizeof(ledc_channel_config_t));
|
|
||||||
ledc_channel.speed_mode = group;
|
|
||||||
ledc_channel.channel = (channel % SOC_LEDC_CHANNEL_NUM);
|
|
||||||
ledc_channel.timer_sel = timer;
|
|
||||||
ledc_channel.intr_type = LEDC_INTR_DISABLE;
|
|
||||||
ledc_channel.gpio_num = pin;
|
|
||||||
ledc_channel.duty = duty;
|
|
||||||
ledc_channel.hpoint = 0;
|
|
||||||
|
|
||||||
|
ledc_channel_config_t ledc_channel = {
|
||||||
|
.speed_mode = group, .channel = (channel % 8), .timer_sel = timer, .intr_type = LEDC_INTR_DISABLE, .gpio_num = pin, .duty = duty, .hpoint = 0
|
||||||
|
};
|
||||||
ledc_channel_config(&ledc_channel);
|
ledc_channel_config(&ledc_channel);
|
||||||
}
|
}
|
||||||
|
|
||||||
ledc_channel_handle_t *handle = (ledc_channel_handle_t *)malloc(sizeof(ledc_channel_handle_t));
|
ledc_channel_handle_t *handle = (ledc_channel_handle_t *)malloc(sizeof(ledc_channel_handle_t));
|
||||||
handle->pin = pin;
|
handle->pin = pin;
|
||||||
handle->channel = channel;
|
handle->channel = channel;
|
||||||
handle->timer_num = timer;
|
|
||||||
handle->freq_hz = freq;
|
|
||||||
#ifndef SOC_LEDC_SUPPORT_FADE_STOP
|
#ifndef SOC_LEDC_SUPPORT_FADE_STOP
|
||||||
handle->lock = NULL;
|
handle->lock = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -280,7 +158,7 @@ bool ledcAttachChannel(uint8_t pin, uint32_t freq, uint8_t resolution, uint8_t c
|
||||||
ledc_handle.used_channels |= 1UL << channel;
|
ledc_handle.used_channels |= 1UL << channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!perimanSetPinBus(pin, ESP32_BUS_TYPE_LEDC, (void *)handle, channel, timer)) {
|
if (!perimanSetPinBus(pin, ESP32_BUS_TYPE_LEDC, (void *)handle, group, channel)) {
|
||||||
ledcDetachBus((void *)handle);
|
ledcDetachBus((void *)handle);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -297,40 +175,14 @@ bool ledcAttach(uint8_t pin, uint32_t freq, uint8_t resolution) {
|
||||||
}
|
}
|
||||||
uint8_t channel = __builtin_ctz(free_channel); // Convert the free_channel bit to channel number
|
uint8_t channel = __builtin_ctz(free_channel); // Convert the free_channel bit to channel number
|
||||||
|
|
||||||
// Try the first available channel
|
return ledcAttachChannel(pin, freq, resolution, channel);
|
||||||
if (ledcAttachChannel(pin, freq, resolution, channel)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
|
||||||
// If first attempt failed and HS mode is supported, try to find a free channel in group 1
|
|
||||||
if ((channel / SOC_LEDC_CHANNEL_NUM) == 0) { // First attempt was in group 0
|
|
||||||
log_d("LEDC: Group 0 channel %u failed, trying to find a free channel in group 1", channel);
|
|
||||||
// Find free channels specifically in group 1
|
|
||||||
uint32_t group1_mask = ((1UL << SOC_LEDC_CHANNEL_NUM) - 1) << SOC_LEDC_CHANNEL_NUM;
|
|
||||||
int group1_free_channel = (~ledc_handle.used_channels) & group1_mask;
|
|
||||||
if (group1_free_channel != 0) {
|
|
||||||
uint8_t group1_channel = __builtin_ctz(group1_free_channel);
|
|
||||||
if (ledcAttachChannel(pin, freq, resolution, group1_channel)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
log_e(
|
|
||||||
"No free timers available for freq=%u, resolution=%u. To attach a new channel, use the same frequency and resolution as an already attached channel to "
|
|
||||||
"share its timer.",
|
|
||||||
freq, resolution
|
|
||||||
);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ledcWrite(uint8_t pin, uint32_t duty) {
|
bool ledcWrite(uint8_t pin, uint32_t duty) {
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
|
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
|
||||||
if (bus != NULL) {
|
if (bus != NULL) {
|
||||||
|
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM), channel = (bus->channel % SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), channel = (bus->channel % 8);
|
||||||
|
|
||||||
//Fixing if all bits in resolution is set = LEDC FULL ON
|
//Fixing if all bits in resolution is set = LEDC FULL ON
|
||||||
uint32_t max_duty = (1 << bus->channel_resolution) - 1;
|
uint32_t max_duty = (1 << bus->channel_resolution) - 1;
|
||||||
|
|
@ -339,14 +191,8 @@ bool ledcWrite(uint8_t pin, uint32_t duty) {
|
||||||
duty = max_duty + 1;
|
duty = max_duty + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ledc_set_duty(group, channel, duty) != ESP_OK) {
|
ledc_set_duty(group, channel, duty);
|
||||||
log_e("ledc_set_duty failed");
|
ledc_update_duty(group, channel);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ledc_update_duty(group, channel) != ESP_OK) {
|
|
||||||
log_e("ledc_update_duty failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -359,11 +205,7 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty) {
|
||||||
log_e("Channel %u is not available (maximum %u) or not used!", channel, LEDC_CHANNELS);
|
log_e("Channel %u is not available (maximum %u) or not used!", channel, LEDC_CHANNELS);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
uint8_t group = (channel / SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (channel / 8), timer = ((channel / 2) % 4);
|
||||||
ledc_timer_t timer;
|
|
||||||
|
|
||||||
// Get the actual timer being used by this channel
|
|
||||||
ledc_ll_get_channel_timer(LEDC_LL_GET_HW(), group, (channel % SOC_LEDC_CHANNEL_NUM), &timer);
|
|
||||||
|
|
||||||
//Fixing if all bits in resolution is set = LEDC FULL ON
|
//Fixing if all bits in resolution is set = LEDC FULL ON
|
||||||
uint32_t resolution = 0;
|
uint32_t resolution = 0;
|
||||||
|
|
@ -375,14 +217,8 @@ bool ledcWriteChannel(uint8_t channel, uint32_t duty) {
|
||||||
duty = max_duty + 1;
|
duty = max_duty + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ledc_set_duty(group, channel, duty) != ESP_OK) {
|
ledc_set_duty(group, channel, duty);
|
||||||
log_e("ledc_set_duty failed");
|
ledc_update_duty(group, channel);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (ledc_update_duty(group, channel) != ESP_OK) {
|
|
||||||
log_e("ledc_update_duty failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -391,7 +227,7 @@ uint32_t ledcRead(uint8_t pin) {
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
|
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
|
||||||
if (bus != NULL) {
|
if (bus != NULL) {
|
||||||
|
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM), channel = (bus->channel % SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), channel = (bus->channel % 8);
|
||||||
return ledc_get_duty(group, channel);
|
return ledc_get_duty(group, channel);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -403,8 +239,8 @@ uint32_t ledcReadFreq(uint8_t pin) {
|
||||||
if (!ledcRead(pin)) {
|
if (!ledcRead(pin)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), timer = ((bus->channel / 2) % 4);
|
||||||
return ledc_get_freq(group, bus->timer_num);
|
return ledc_get_freq(group, timer);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -418,15 +254,9 @@ uint32_t ledcWriteTone(uint8_t pin, uint32_t freq) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), timer = ((bus->channel / 2) % 4);
|
||||||
|
|
||||||
ledc_timer_config_t ledc_timer;
|
ledc_timer_config_t ledc_timer = {.speed_mode = group, .timer_num = timer, .duty_resolution = 10, .freq_hz = freq, .clk_cfg = clock_source};
|
||||||
memset((void *)&ledc_timer, 0, sizeof(ledc_timer_config_t));
|
|
||||||
ledc_timer.speed_mode = group;
|
|
||||||
ledc_timer.timer_num = bus->timer_num;
|
|
||||||
ledc_timer.duty_resolution = 10;
|
|
||||||
ledc_timer.freq_hz = freq;
|
|
||||||
ledc_timer.clk_cfg = clock_source;
|
|
||||||
|
|
||||||
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
||||||
log_e("ledcWriteTone configuration failed!");
|
log_e("ledcWriteTone configuration failed!");
|
||||||
|
|
@ -434,7 +264,7 @@ uint32_t ledcWriteTone(uint8_t pin, uint32_t freq) {
|
||||||
}
|
}
|
||||||
bus->channel_resolution = 10;
|
bus->channel_resolution = 10;
|
||||||
|
|
||||||
uint32_t res_freq = ledc_get_freq(group, bus->timer_num);
|
uint32_t res_freq = ledc_get_freq(group, timer);
|
||||||
ledcWrite(pin, 0x1FF);
|
ledcWrite(pin, 0x1FF);
|
||||||
return res_freq;
|
return res_freq;
|
||||||
}
|
}
|
||||||
|
|
@ -475,22 +305,16 @@ uint32_t ledcChangeFrequency(uint8_t pin, uint32_t freq, uint8_t resolution) {
|
||||||
log_e("LEDC pin %u - resolution is zero or it is too big (maximum %u)", pin, LEDC_MAX_BIT_WIDTH);
|
log_e("LEDC pin %u - resolution is zero or it is too big (maximum %u)", pin, LEDC_MAX_BIT_WIDTH);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), timer = ((bus->channel / 2) % 4);
|
||||||
|
|
||||||
ledc_timer_config_t ledc_timer;
|
ledc_timer_config_t ledc_timer = {.speed_mode = group, .timer_num = timer, .duty_resolution = resolution, .freq_hz = freq, .clk_cfg = clock_source};
|
||||||
memset((void *)&ledc_timer, 0, sizeof(ledc_timer_config_t));
|
|
||||||
ledc_timer.speed_mode = group;
|
|
||||||
ledc_timer.timer_num = bus->timer_num;
|
|
||||||
ledc_timer.duty_resolution = resolution;
|
|
||||||
ledc_timer.freq_hz = freq;
|
|
||||||
ledc_timer.clk_cfg = clock_source;
|
|
||||||
|
|
||||||
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
if (ledc_timer_config(&ledc_timer) != ESP_OK) {
|
||||||
log_e("ledcChangeFrequency failed!");
|
log_e("ledcChangeFrequency failed!");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
bus->channel_resolution = resolution;
|
bus->channel_resolution = resolution;
|
||||||
return ledc_get_freq(group, bus->timer_num);
|
return ledc_get_freq(group, timer);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -501,14 +325,12 @@ bool ledcOutputInvert(uint8_t pin, bool out_invert) {
|
||||||
gpio_set_level(pin, out_invert);
|
gpio_set_level(pin, out_invert);
|
||||||
|
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||||
esp_rom_gpio_connect_out_signal(pin, LEDC_LS_SIG_OUT_PAD_OUT0_IDX + ((bus->channel) % SOC_LEDC_CHANNEL_NUM), out_invert, 0);
|
esp_rom_gpio_connect_out_signal(pin, LEDC_LS_SIG_OUT_PAD_OUT0_IDX + ((bus->channel) % 8), out_invert, 0);
|
||||||
#else
|
#else
|
||||||
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
#ifdef SOC_LEDC_SUPPORT_HS_MODE
|
||||||
esp_rom_gpio_connect_out_signal(
|
esp_rom_gpio_connect_out_signal(pin, ((bus->channel / 8 == 0) ? LEDC_HS_SIG_OUT0_IDX : LEDC_LS_SIG_OUT0_IDX) + ((bus->channel) % 8), out_invert, 0);
|
||||||
pin, ((bus->channel / SOC_LEDC_CHANNEL_NUM == 0) ? LEDC_HS_SIG_OUT0_IDX : LEDC_LS_SIG_OUT0_IDX) + ((bus->channel) % SOC_LEDC_CHANNEL_NUM), out_invert, 0
|
|
||||||
);
|
|
||||||
#else
|
#else
|
||||||
esp_rom_gpio_connect_out_signal(pin, LEDC_LS_SIG_OUT0_IDX + ((bus->channel) % SOC_LEDC_CHANNEL_NUM), out_invert, 0);
|
esp_rom_gpio_connect_out_signal(pin, LEDC_LS_SIG_OUT0_IDX + ((bus->channel) % 8), out_invert, 0);
|
||||||
#endif
|
#endif
|
||||||
#endif // ifdef CONFIG_IDF_TARGET_ESP32P4
|
#endif // ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -555,7 +377,7 @@ static bool ledcFadeConfig(uint8_t pin, uint32_t start_duty, uint32_t target_dut
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM), channel = (bus->channel % SOC_LEDC_CHANNEL_NUM);
|
uint8_t group = (bus->channel / 8), channel = (bus->channel % 8);
|
||||||
|
|
||||||
// Initialize fade service.
|
// Initialize fade service.
|
||||||
if (!fade_initialized) {
|
if (!fade_initialized) {
|
||||||
|
|
@ -612,161 +434,6 @@ bool ledcFadeWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_
|
||||||
return ledcFadeConfig(pin, start_duty, target_duty, max_fade_time_ms, userFunc, arg);
|
return ledcFadeConfig(pin, start_duty, target_duty, max_fade_time_ms, userFunc, arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED
|
|
||||||
// Default gamma factor for gamma correction (common value for LEDs)
|
|
||||||
static float ledcGammaFactor = 2.8;
|
|
||||||
// Gamma correction LUT support
|
|
||||||
static const float *ledcGammaLUT = NULL;
|
|
||||||
static uint16_t ledcGammaLUTSize = 0;
|
|
||||||
// Global variable to store current resolution for gamma callback
|
|
||||||
static uint8_t ledcGammaResolution = 13;
|
|
||||||
|
|
||||||
bool ledcSetGammaTable(const float *gamma_table, uint16_t size) {
|
|
||||||
if (gamma_table == NULL || size == 0) {
|
|
||||||
log_e("Invalid gamma table or size");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
ledcGammaLUT = gamma_table;
|
|
||||||
ledcGammaLUTSize = size;
|
|
||||||
log_i("Custom gamma LUT set with %u entries", size);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ledcClearGammaTable(void) {
|
|
||||||
ledcGammaLUT = NULL;
|
|
||||||
ledcGammaLUTSize = 0;
|
|
||||||
log_i("Gamma LUT cleared, using mathematical calculation");
|
|
||||||
}
|
|
||||||
|
|
||||||
void ledcSetGammaFactor(float factor) {
|
|
||||||
ledcGammaFactor = factor;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gamma correction calculator function
|
|
||||||
static uint32_t ledcGammaCorrection(uint32_t duty) {
|
|
||||||
if (duty == 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t max_duty = (1U << ledcGammaResolution) - 1;
|
|
||||||
if (duty >= (1U << ledcGammaResolution)) {
|
|
||||||
return max_duty;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Use LUT if provided, otherwise use mathematical calculation
|
|
||||||
if (ledcGammaLUT != NULL && ledcGammaLUTSize > 0) {
|
|
||||||
// LUT-based gamma correction
|
|
||||||
uint32_t lut_index = (duty * (ledcGammaLUTSize - 1)) / max_duty;
|
|
||||||
if (lut_index >= ledcGammaLUTSize) {
|
|
||||||
lut_index = ledcGammaLUTSize - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
float corrected_normalized = ledcGammaLUT[lut_index];
|
|
||||||
return (uint32_t)(corrected_normalized * max_duty);
|
|
||||||
} else {
|
|
||||||
// Mathematical gamma correction
|
|
||||||
double normalized = (double)duty / (1U << ledcGammaResolution);
|
|
||||||
double corrected = pow(normalized, ledcGammaFactor);
|
|
||||||
return (uint32_t)(corrected * (1U << ledcGammaResolution));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool ledcFadeGammaConfig(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void *), void *arg) {
|
|
||||||
ledc_channel_handle_t *bus = (ledc_channel_handle_t *)perimanGetPinBus(pin, ESP32_BUS_TYPE_LEDC);
|
|
||||||
if (bus != NULL) {
|
|
||||||
|
|
||||||
#ifndef SOC_LEDC_SUPPORT_FADE_STOP
|
|
||||||
#if !CONFIG_DISABLE_HAL_LOCKS
|
|
||||||
if (bus->lock == NULL) {
|
|
||||||
bus->lock = xSemaphoreCreateBinary();
|
|
||||||
if (bus->lock == NULL) {
|
|
||||||
log_e("xSemaphoreCreateBinary failed");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
xSemaphoreGive(bus->lock);
|
|
||||||
}
|
|
||||||
//acquire lock
|
|
||||||
if (xSemaphoreTake(bus->lock, 0) != pdTRUE) {
|
|
||||||
log_e("LEDC Fade is still running on pin %u! SoC does not support stopping fade.", pin);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
uint8_t group = (bus->channel / SOC_LEDC_CHANNEL_NUM), channel = (bus->channel % SOC_LEDC_CHANNEL_NUM);
|
|
||||||
|
|
||||||
// Initialize fade service.
|
|
||||||
if (!fade_initialized) {
|
|
||||||
ledc_fade_func_install(0);
|
|
||||||
fade_initialized = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bus->fn = (voidFuncPtr)userFunc;
|
|
||||||
bus->arg = arg;
|
|
||||||
|
|
||||||
ledc_cbs_t callbacks = {.fade_cb = ledcFnWrapper};
|
|
||||||
ledc_cb_register(group, channel, &callbacks, (void *)bus);
|
|
||||||
|
|
||||||
// Prepare gamma curve fade parameters
|
|
||||||
ledc_fade_param_config_t fade_params[SOC_LEDC_GAMMA_CURVE_FADE_RANGE_MAX];
|
|
||||||
uint32_t actual_fade_ranges = 0;
|
|
||||||
|
|
||||||
// Use a moderate number of linear segments for smooth gamma curve
|
|
||||||
const uint32_t linear_fade_segments = 12;
|
|
||||||
|
|
||||||
// Set the global resolution for gamma correction
|
|
||||||
ledcGammaResolution = bus->channel_resolution;
|
|
||||||
|
|
||||||
// Fill multi-fade parameter list using ESP-IDF API
|
|
||||||
esp_err_t err = ledc_fill_multi_fade_param_list(
|
|
||||||
group, channel, start_duty, target_duty, linear_fade_segments, max_fade_time_ms, ledcGammaCorrection, SOC_LEDC_GAMMA_CURVE_FADE_RANGE_MAX, fade_params,
|
|
||||||
&actual_fade_ranges
|
|
||||||
);
|
|
||||||
|
|
||||||
if (err != ESP_OK) {
|
|
||||||
log_e("ledc_fill_multi_fade_param_list failed: %s", esp_err_to_name(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Apply the gamma-corrected start duty
|
|
||||||
uint32_t gamma_start_duty = ledcGammaCorrection(start_duty);
|
|
||||||
|
|
||||||
// Set multi-fade parameters
|
|
||||||
err = ledc_set_multi_fade(group, channel, gamma_start_duty, fade_params, actual_fade_ranges);
|
|
||||||
if (err != ESP_OK) {
|
|
||||||
log_e("ledc_set_multi_fade failed: %s", esp_err_to_name(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the gamma curve fade
|
|
||||||
err = ledc_fade_start(group, channel, LEDC_FADE_NO_WAIT);
|
|
||||||
if (err != ESP_OK) {
|
|
||||||
log_e("ledc_fade_start failed: %s", esp_err_to_name(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
log_d("Gamma curve fade started on pin %u: %u -> %u over %dms", pin, start_duty, target_duty, max_fade_time_ms);
|
|
||||||
|
|
||||||
} else {
|
|
||||||
log_e("Pin %u is not attached to LEDC. Call ledcAttach first!", pin);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ledcFadeGamma(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms) {
|
|
||||||
return ledcFadeGammaConfig(pin, start_duty, target_duty, max_fade_time_ms, NULL, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ledcFadeGammaWithInterrupt(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, voidFuncPtr userFunc) {
|
|
||||||
return ledcFadeGammaConfig(pin, start_duty, target_duty, max_fade_time_ms, (voidFuncPtrArg)userFunc, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ledcFadeGammaWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void *), void *arg) {
|
|
||||||
return ledcFadeGammaConfig(pin, start_duty, target_duty, max_fade_time_ms, userFunc, arg);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED */
|
|
||||||
|
|
||||||
static uint8_t analog_resolution = 8;
|
static uint8_t analog_resolution = 8;
|
||||||
static int analog_frequency = 1000;
|
static int analog_frequency = 1000;
|
||||||
void analogWrite(uint8_t pin, int value) {
|
void analogWrite(uint8_t pin, int value) {
|
||||||
|
|
|
||||||
|
|
@ -51,8 +51,6 @@ typedef struct {
|
||||||
uint8_t pin; // Pin assigned to channel
|
uint8_t pin; // Pin assigned to channel
|
||||||
uint8_t channel; // Channel number
|
uint8_t channel; // Channel number
|
||||||
uint8_t channel_resolution; // Resolution of channel
|
uint8_t channel_resolution; // Resolution of channel
|
||||||
uint8_t timer_num; // Timer number used by this channel
|
|
||||||
uint32_t freq_hz; // Frequency configured for this channel
|
|
||||||
voidFuncPtr fn;
|
voidFuncPtr fn;
|
||||||
void *arg;
|
void *arg;
|
||||||
#ifndef SOC_LEDC_SUPPORT_FADE_STOP
|
#ifndef SOC_LEDC_SUPPORT_FADE_STOP
|
||||||
|
|
@ -232,85 +230,6 @@ bool ledcFadeWithInterrupt(uint8_t pin, uint32_t start_duty, uint32_t target_dut
|
||||||
*/
|
*/
|
||||||
bool ledcFadeWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void *), void *arg);
|
bool ledcFadeWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void *), void *arg);
|
||||||
|
|
||||||
//Gamma Curve Fade functions - only available on supported chips
|
|
||||||
#ifdef SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set a custom gamma correction lookup table for gamma curve fading.
|
|
||||||
* The LUT should contain normalized values (0.0 to 1.0) representing
|
|
||||||
* the gamma-corrected brightness curve.
|
|
||||||
*
|
|
||||||
* @param gamma_table Pointer to array of float values (0.0 to 1.0)
|
|
||||||
* @param size Number of entries in the lookup table
|
|
||||||
*
|
|
||||||
* @return true if gamma table was successfully set, false otherwise.
|
|
||||||
*
|
|
||||||
* @note The LUT array must remain valid for as long as gamma fading is used.
|
|
||||||
* Larger tables provide smoother transitions but use more memory.
|
|
||||||
*/
|
|
||||||
bool ledcSetGammaTable(const float *gamma_table, uint16_t size);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Clear the current gamma correction lookup table.
|
|
||||||
* After calling this, gamma correction will use mathematical
|
|
||||||
* calculation with the default gamma factor (2.8).
|
|
||||||
*/
|
|
||||||
void ledcClearGammaTable(void);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Set the gamma factor for gamma correction.
|
|
||||||
*
|
|
||||||
* @param factor Gamma factor to use for gamma correction.
|
|
||||||
*/
|
|
||||||
void ledcSetGammaFactor(float factor);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup and start a gamma curve fade on a given LEDC pin.
|
|
||||||
* Gamma correction makes LED brightness changes appear more gradual to human eyes.
|
|
||||||
*
|
|
||||||
* @param pin GPIO pin
|
|
||||||
* @param start_duty initial duty cycle of the fade
|
|
||||||
* @param target_duty target duty cycle of the fade
|
|
||||||
* @param max_fade_time_ms maximum fade time in milliseconds
|
|
||||||
*
|
|
||||||
* @return true if gamma fade was successfully set and started, false otherwise.
|
|
||||||
*
|
|
||||||
* @note This function is only available on ESP32 variants that support gamma curve fading.
|
|
||||||
*/
|
|
||||||
bool ledcFadeGamma(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup and start a gamma curve fade on a given LEDC pin with a callback function.
|
|
||||||
*
|
|
||||||
* @param pin GPIO pin
|
|
||||||
* @param start_duty initial duty cycle of the fade
|
|
||||||
* @param target_duty target duty cycle of the fade
|
|
||||||
* @param max_fade_time_ms maximum fade time in milliseconds
|
|
||||||
* @param userFunc callback function to be called after fade is finished
|
|
||||||
*
|
|
||||||
* @return true if gamma fade was successfully set and started, false otherwise.
|
|
||||||
*
|
|
||||||
* @note This function is only available on ESP32 variants that support gamma curve fading.
|
|
||||||
*/
|
|
||||||
bool ledcFadeGammaWithInterrupt(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void));
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Setup and start a gamma curve fade on a given LEDC pin with a callback function and argument.
|
|
||||||
*
|
|
||||||
* @param pin GPIO pin
|
|
||||||
* @param start_duty initial duty cycle of the fade
|
|
||||||
* @param target_duty target duty cycle of the fade
|
|
||||||
* @param max_fade_time_ms maximum fade time in milliseconds
|
|
||||||
* @param userFunc callback function to be called after fade is finished
|
|
||||||
* @param arg argument to be passed to the callback function
|
|
||||||
*
|
|
||||||
* @return true if gamma fade was successfully set and started, false otherwise.
|
|
||||||
*
|
|
||||||
* @note This function is only available on ESP32 variants that support gamma curve fading.
|
|
||||||
*/
|
|
||||||
bool ledcFadeGammaWithInterruptArg(uint8_t pin, uint32_t start_duty, uint32_t target_duty, int max_fade_time_ms, void (*userFunc)(void *), void *arg);
|
|
||||||
#endif // SOC_LEDC_GAMMA_CURVE_FADE_SUPPORTED
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -34,8 +34,6 @@
|
||||||
#include "esp32h2/rom/gpio.h"
|
#include "esp32h2/rom/gpio.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/gpio.h"
|
#include "esp32p4/rom/gpio.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/gpio.h"
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -25,13 +25,12 @@
|
||||||
#include "esp_ota_ops.h"
|
#include "esp_ota_ops.h"
|
||||||
#endif //CONFIG_APP_ROLLBACK_ENABLE
|
#endif //CONFIG_APP_ROLLBACK_ENABLE
|
||||||
#include "esp_private/startup_internal.h"
|
#include "esp_private/startup_internal.h"
|
||||||
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && SOC_BT_SUPPORTED && __has_include("esp_bt.h")
|
#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED
|
||||||
#include "esp_bt.h"
|
#include "esp_bt.h"
|
||||||
#endif
|
#endif //CONFIG_BT_ENABLED
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4) \
|
#if !defined(CONFIG_IDF_TARGET_ESP32C2) && !defined(CONFIG_IDF_TARGET_ESP32C6) && !defined(CONFIG_IDF_TARGET_ESP32H2) && !defined(CONFIG_IDF_TARGET_ESP32P4)
|
||||||
&& !defined(CONFIG_IDF_TARGET_ESP32C5)
|
|
||||||
#include "soc/rtc_cntl_reg.h"
|
#include "soc/rtc_cntl_reg.h"
|
||||||
#include "soc/syscon_reg.h"
|
#include "soc/syscon_reg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -57,8 +56,6 @@
|
||||||
#include "esp32h2/rom/rtc.h"
|
#include "esp32h2/rom/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/rtc.h"
|
#include "esp32p4/rom/rtc.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/rtc.h"
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
|
|
@ -246,7 +243,7 @@ bool verifyRollbackLater() {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)
|
#ifdef CONFIG_BT_ENABLED
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
//overwritten in esp32-hal-bt.c
|
//overwritten in esp32-hal-bt.c
|
||||||
bool btInUse() __attribute__((weak));
|
bool btInUse() __attribute__((weak));
|
||||||
|
|
@ -308,7 +305,7 @@ void initArduino() {
|
||||||
if (err) {
|
if (err) {
|
||||||
log_e("Failed to initialize NVS! Error: %u", err);
|
log_e("Failed to initialize NVS! Error: %u", err);
|
||||||
}
|
}
|
||||||
#if (defined(CONFIG_BLUEDROID_ENABLED) || defined(CONFIG_NIMBLE_ENABLED)) && SOC_BT_SUPPORTED
|
#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED
|
||||||
if (!btInUse()) {
|
if (!btInUse()) {
|
||||||
esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);
|
esp_bt_controller_mem_release(ESP_BT_MODE_BTDM);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@
|
||||||
#include "esp32s3/rom/cache.h"
|
#include "esp32s3/rom/cache.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/cache.h"
|
#include "esp32p4/rom/cache.h"
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/cache.h"
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -206,8 +206,7 @@ bool rmtSetCarrier(int pin, bool carrier_en, bool carrier_level, uint32_t freque
|
||||||
log_w("GPIO %d - RMT Carrier must be a float percentage from 0 to 1. Setting to 50%.", pin);
|
log_w("GPIO %d - RMT Carrier must be a float percentage from 0 to 1. Setting to 50%.", pin);
|
||||||
duty_percent = 0.5;
|
duty_percent = 0.5;
|
||||||
}
|
}
|
||||||
rmt_carrier_config_t carrier_cfg;
|
rmt_carrier_config_t carrier_cfg = {0};
|
||||||
memset((void *)&carrier_cfg, 0, sizeof(rmt_carrier_config_t));
|
|
||||||
carrier_cfg.duty_cycle = duty_percent; // duty cycle
|
carrier_cfg.duty_cycle = duty_percent; // duty cycle
|
||||||
carrier_cfg.frequency_hz = carrier_en ? frequency_Hz : 0; // carrier frequency in Hz
|
carrier_cfg.frequency_hz = carrier_en ? frequency_Hz : 0; // carrier frequency in Hz
|
||||||
carrier_cfg.flags.polarity_active_low = carrier_level; // carrier modulation polarity level
|
carrier_cfg.flags.polarity_active_low = carrier_level; // carrier modulation polarity level
|
||||||
|
|
@ -314,8 +313,7 @@ static bool _rmtWrite(int pin, rmt_data_t *data, size_t num_rmt_symbols, bool bl
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
rmt_transmit_config_t transmit_cfg; // loop mode disabled
|
rmt_transmit_config_t transmit_cfg = {0}; // loop mode disabled
|
||||||
memset((void *)&transmit_cfg, 0, sizeof(rmt_transmit_config_t));
|
|
||||||
bool retCode = true;
|
bool retCode = true;
|
||||||
|
|
||||||
RMT_MUTEX_LOCK(bus);
|
RMT_MUTEX_LOCK(bus);
|
||||||
|
|
@ -382,7 +380,6 @@ static bool _rmtRead(int pin, rmt_data_t *data, size_t *num_rmt_symbols, bool wa
|
||||||
|
|
||||||
// request reading RMT Channel Data
|
// request reading RMT Channel Data
|
||||||
rmt_receive_config_t receive_config;
|
rmt_receive_config_t receive_config;
|
||||||
memset((void *)&receive_config, 0, sizeof(rmt_receive_config_t));
|
|
||||||
receive_config.signal_range_min_ns = bus->signal_range_min_ns;
|
receive_config.signal_range_min_ns = bus->signal_range_min_ns;
|
||||||
receive_config.signal_range_max_ns = bus->signal_range_max_ns;
|
receive_config.signal_range_max_ns = bus->signal_range_max_ns;
|
||||||
|
|
||||||
|
|
@ -533,7 +530,6 @@ bool rmtInit(int pin, rmt_ch_dir_t channel_direction, rmt_reserve_memsize_t mem_
|
||||||
if (channel_direction == RMT_TX_MODE) {
|
if (channel_direction == RMT_TX_MODE) {
|
||||||
// TX Channel
|
// TX Channel
|
||||||
rmt_tx_channel_config_t tx_cfg;
|
rmt_tx_channel_config_t tx_cfg;
|
||||||
memset((void *)&tx_cfg, 0, sizeof(rmt_tx_channel_config_t));
|
|
||||||
tx_cfg.gpio_num = pin;
|
tx_cfg.gpio_num = pin;
|
||||||
// CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F80M for C6 -- CLK_XTAL for H2
|
// CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F80M for C6 -- CLK_XTAL for H2
|
||||||
tx_cfg.clk_src = RMT_CLK_SRC_DEFAULT;
|
tx_cfg.clk_src = RMT_CLK_SRC_DEFAULT;
|
||||||
|
|
@ -563,7 +559,6 @@ bool rmtInit(int pin, rmt_ch_dir_t channel_direction, rmt_reserve_memsize_t mem_
|
||||||
} else {
|
} else {
|
||||||
// RX Channel
|
// RX Channel
|
||||||
rmt_rx_channel_config_t rx_cfg;
|
rmt_rx_channel_config_t rx_cfg;
|
||||||
memset((void *)&rx_cfg, 0, sizeof(rmt_rx_channel_config_t));
|
|
||||||
rx_cfg.gpio_num = pin;
|
rx_cfg.gpio_num = pin;
|
||||||
// CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F80M for C6 -- CLK_XTAL for H2
|
// CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F80M for C6 -- CLK_XTAL for H2
|
||||||
rx_cfg.clk_src = RMT_CLK_SRC_DEFAULT;
|
rx_cfg.clk_src = RMT_CLK_SRC_DEFAULT;
|
||||||
|
|
@ -590,8 +585,7 @@ bool rmtInit(int pin, rmt_ch_dir_t channel_direction, rmt_reserve_memsize_t mem_
|
||||||
}
|
}
|
||||||
|
|
||||||
// allocate memory for the RMT Copy encoder
|
// allocate memory for the RMT Copy encoder
|
||||||
rmt_copy_encoder_config_t copy_encoder_config;
|
rmt_copy_encoder_config_t copy_encoder_config = {};
|
||||||
memset((void *)©_encoder_config, 0, sizeof(rmt_copy_encoder_config_t));
|
|
||||||
if (rmt_new_copy_encoder(©_encoder_config, &bus->rmt_copy_encoder_h) != ESP_OK) {
|
if (rmt_new_copy_encoder(©_encoder_config, &bus->rmt_copy_encoder_h) != ESP_OK) {
|
||||||
log_e("GPIO %d - RMT Encoder Memory Allocation error.", pin);
|
log_e("GPIO %d - RMT Encoder Memory Allocation error.", pin);
|
||||||
goto Err;
|
goto Err;
|
||||||
|
|
|
||||||
|
|
@ -26,9 +26,7 @@
|
||||||
#include "soc/io_mux_reg.h"
|
#include "soc/io_mux_reg.h"
|
||||||
#include "soc/gpio_sig_map.h"
|
#include "soc/gpio_sig_map.h"
|
||||||
#include "soc/rtc.h"
|
#include "soc/rtc.h"
|
||||||
#ifndef CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "hal/clk_gate_ll.h"
|
#include "hal/clk_gate_ll.h"
|
||||||
#endif
|
|
||||||
#include "esp32-hal-periman.h"
|
#include "esp32-hal-periman.h"
|
||||||
#include "esp_private/periph_ctrl.h"
|
#include "esp_private/periph_ctrl.h"
|
||||||
|
|
||||||
|
|
@ -62,10 +60,6 @@
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
#include "esp32p4/rom/ets_sys.h"
|
#include "esp32p4/rom/ets_sys.h"
|
||||||
#include "esp32p4/rom/gpio.h"
|
#include "esp32p4/rom/gpio.h"
|
||||||
#include "hal/spi_ll.h"
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
#include "esp32c5/rom/ets_sys.h"
|
|
||||||
#include "esp32c5/rom/gpio.h"
|
|
||||||
#else
|
#else
|
||||||
#error Target CONFIG_IDF_TARGET is not supported
|
#error Target CONFIG_IDF_TARGET is not supported
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -80,20 +74,20 @@ struct spi_struct_t {
|
||||||
int8_t miso;
|
int8_t miso;
|
||||||
int8_t mosi;
|
int8_t mosi;
|
||||||
int8_t ss;
|
int8_t ss;
|
||||||
bool ss_invert;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2
|
#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
// ESP32S2
|
// ESP32S2
|
||||||
#define SPI_COUNT (2)
|
#define SPI_COUNT (3)
|
||||||
|
|
||||||
#define SPI_CLK_IDX(p) ((p == 0) ? FSPICLK_OUT_MUX_IDX : ((p == 1) ? SPI3_CLK_OUT_MUX_IDX : 0))
|
#define SPI_CLK_IDX(p) ((p == 0) ? SPICLK_OUT_MUX_IDX : ((p == 1) ? FSPICLK_OUT_MUX_IDX : ((p == 2) ? SPI3_CLK_OUT_MUX_IDX : 0)))
|
||||||
#define SPI_MISO_IDX(p) ((p == 0) ? FSPIQ_OUT_IDX : ((p == 1) ? SPI3_Q_OUT_IDX : 0))
|
#define SPI_MISO_IDX(p) ((p == 0) ? SPIQ_OUT_IDX : ((p == 1) ? FSPIQ_OUT_IDX : ((p == 2) ? SPI3_Q_OUT_IDX : 0)))
|
||||||
#define SPI_MOSI_IDX(p) ((p == 0) ? FSPID_IN_IDX : ((p == 1) ? SPI3_D_IN_IDX : 0))
|
#define SPI_MOSI_IDX(p) ((p == 0) ? SPID_IN_IDX : ((p == 1) ? FSPID_IN_IDX : ((p == 2) ? SPI3_D_IN_IDX : 0)))
|
||||||
|
|
||||||
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : 0)))
|
#define SPI_SPI_SS_IDX(n) ((n == 0) ? SPICS0_OUT_IDX : ((n == 1) ? SPICS1_OUT_IDX : 0))
|
||||||
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : 0)))
|
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : SPI3_CS0_OUT_IDX)))
|
||||||
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))
|
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : FSPICS0_OUT_IDX)))
|
||||||
|
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_SPI_SS_IDX(n) : ((p == 1) ? SPI_SPI_SS_IDX(n) : ((p == 2) ? SPI_HSPI_SS_IDX(n) : 0)))
|
||||||
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
// ESP32S3
|
// ESP32S3
|
||||||
|
|
@ -103,8 +97,8 @@ struct spi_struct_t {
|
||||||
#define SPI_MISO_IDX(p) ((p == 0) ? FSPIQ_OUT_IDX : ((p == 1) ? SPI3_Q_OUT_IDX : 0))
|
#define SPI_MISO_IDX(p) ((p == 0) ? FSPIQ_OUT_IDX : ((p == 1) ? SPI3_Q_OUT_IDX : 0))
|
||||||
#define SPI_MOSI_IDX(p) ((p == 0) ? FSPID_IN_IDX : ((p == 1) ? SPI3_D_IN_IDX : 0))
|
#define SPI_MOSI_IDX(p) ((p == 0) ? FSPID_IN_IDX : ((p == 1) ? SPI3_D_IN_IDX : 0))
|
||||||
|
|
||||||
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : 0)))
|
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : 0))
|
||||||
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : 0)))
|
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : 0))
|
||||||
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))
|
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))
|
||||||
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
#elif CONFIG_IDF_TARGET_ESP32P4
|
||||||
|
|
@ -125,7 +119,7 @@ struct spi_struct_t {
|
||||||
|
|
||||||
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))
|
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))
|
||||||
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5
|
#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
|
||||||
// ESP32C3
|
// ESP32C3
|
||||||
#define SPI_COUNT (1)
|
#define SPI_COUNT (1)
|
||||||
|
|
||||||
|
|
@ -156,20 +150,24 @@ struct spi_struct_t {
|
||||||
#define SPI_MUTEX_UNLOCK()
|
#define SPI_MUTEX_UNLOCK()
|
||||||
// clang-format off
|
// clang-format off
|
||||||
static spi_t _spi_bus_array[] = {
|
static spi_t _spi_bus_array[] = {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 ||CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
|
#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 0, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 1, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 1, -1, -1, -1, -1},
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 2, -1, -1, -1, -1}
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1},
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 1, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5
|
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
|
||||||
{(spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
|
{(spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1}
|
||||||
#else
|
#else
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), 0, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), 0, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 1, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 1, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 2, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 2, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 3, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 3, -1, -1, -1, -1}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
// clang-format on
|
// clang-format on
|
||||||
|
|
@ -180,19 +178,23 @@ static spi_t _spi_bus_array[] = {
|
||||||
#define SPI_MUTEX_UNLOCK() xSemaphoreGive(spi->lock)
|
#define SPI_MUTEX_UNLOCK() xSemaphoreGive(spi->lock)
|
||||||
|
|
||||||
static spi_t _spi_bus_array[] = {
|
static spi_t _spi_bus_array[] = {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
|
#if CONFIG_IDF_TARGET_ESP32S2
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}, {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 1, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 0, -1, -1, -1, -1},
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 1, -1, -1, -1, -1},
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 2, -1, -1, -1, -1}
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 1, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C2
|
#elif CONFIG_IDF_TARGET_ESP32C2
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C3
|
#elif CONFIG_IDF_TARGET_ESP32C3
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5
|
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2
|
||||||
{(spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
|
{(spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1}
|
||||||
#else
|
#else
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), NULL, 0, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), NULL, 0, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 1, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 1, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 2, -1, -1, -1, -1, false},
|
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 2, -1, -1, -1, -1},
|
||||||
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 3, -1, -1, -1, -1, false}
|
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 3, -1, -1, -1, -1}
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -363,7 +365,7 @@ bool spiAttachSS(spi_t *spi, uint8_t ss_num, int8_t ss) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
pinMode(ss, OUTPUT);
|
pinMode(ss, OUTPUT);
|
||||||
pinMatrixOutAttach(ss, SPI_SS_IDX(spi->num, ss_num), spi->ss_invert, false);
|
pinMatrixOutAttach(ss, SPI_SS_IDX(spi->num, ss_num), false, false);
|
||||||
spiEnableSSPins(spi, (1 << ss_num));
|
spiEnableSSPins(spi, (1 << ss_num));
|
||||||
spi->ss = ss;
|
spi->ss = ss;
|
||||||
if (!perimanSetPinBus(ss, ESP32_BUS_TYPE_SPI_MASTER_SS, (void *)(spi->num + 1), spi->num, -1)) {
|
if (!perimanSetPinBus(ss, ESP32_BUS_TYPE_SPI_MASTER_SS, (void *)(spi->num + 1), spi->num, -1)) {
|
||||||
|
|
@ -433,12 +435,6 @@ void spiSSDisable(spi_t *spi) {
|
||||||
SPI_MUTEX_UNLOCK();
|
SPI_MUTEX_UNLOCK();
|
||||||
}
|
}
|
||||||
|
|
||||||
void spiSSInvert(spi_t *spi, bool invert) {
|
|
||||||
if (spi) {
|
|
||||||
spi->ss_invert = invert;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void spiSSSet(spi_t *spi) {
|
void spiSSSet(spi_t *spi) {
|
||||||
if (!spi) {
|
if (!spi) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -618,7 +614,6 @@ void spiStopBus(spi_t *spi) {
|
||||||
|
|
||||||
spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder) {
|
spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder) {
|
||||||
if (spi_num >= SPI_COUNT) {
|
if (spi_num >= SPI_COUNT) {
|
||||||
log_e("SPI bus index %d is out of range", spi_num);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -645,6 +640,9 @@ spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t
|
||||||
} else if (spi_num == HSPI) {
|
} else if (spi_num == HSPI) {
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI3_CLK_EN);
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI3_CLK_EN);
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI3_RST);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI3_RST);
|
||||||
|
} else {
|
||||||
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI01_CLK_EN);
|
||||||
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI01_RST);
|
||||||
}
|
}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S3
|
#elif CONFIG_IDF_TARGET_ESP32S3
|
||||||
if (spi_num == FSPI) {
|
if (spi_num == FSPI) {
|
||||||
|
|
@ -665,31 +663,6 @@ spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t
|
||||||
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI01_CLK_EN);
|
DPORT_SET_PERI_REG_MASK(DPORT_PERIP_CLK_EN_REG, DPORT_SPI01_CLK_EN);
|
||||||
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI01_RST);
|
DPORT_CLEAR_PERI_REG_MASK(DPORT_PERIP_RST_EN_REG, DPORT_SPI01_RST);
|
||||||
}
|
}
|
||||||
#elif CONFIG_IDF_TARGET_ESP32P4
|
|
||||||
#pragma GCC diagnostic push
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-variable"
|
|
||||||
if (spi_num == FSPI) {
|
|
||||||
PERIPH_RCC_ACQUIRE_ATOMIC(PERIPH_GPSPI2_MODULE, ref_count) {
|
|
||||||
if (ref_count == 0) {
|
|
||||||
PERIPH_RCC_ATOMIC() {
|
|
||||||
spi_ll_enable_bus_clock(SPI2_HOST, true);
|
|
||||||
spi_ll_reset_register(SPI2_HOST);
|
|
||||||
spi_ll_enable_clock(SPI2_HOST, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (spi_num == HSPI) {
|
|
||||||
PERIPH_RCC_ACQUIRE_ATOMIC(PERIPH_GPSPI3_MODULE, ref_count) {
|
|
||||||
if (ref_count == 0) {
|
|
||||||
PERIPH_RCC_ATOMIC() {
|
|
||||||
spi_ll_enable_bus_clock(SPI3_HOST, true);
|
|
||||||
spi_ll_reset_register(SPI3_HOST);
|
|
||||||
spi_ll_enable_clock(SPI3_HOST, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#pragma GCC diagnostic pop
|
|
||||||
#elif defined(__PERIPH_CTRL_ALLOW_LEGACY_API)
|
#elif defined(__PERIPH_CTRL_ALLOW_LEGACY_API)
|
||||||
periph_ll_reset(PERIPH_SPI2_MODULE);
|
periph_ll_reset(PERIPH_SPI2_MODULE);
|
||||||
periph_ll_enable_clk_clear_rst(PERIPH_SPI2_MODULE);
|
periph_ll_enable_clk_clear_rst(PERIPH_SPI2_MODULE);
|
||||||
|
|
@ -712,7 +685,7 @@ spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t
|
||||||
spi->dev->user.doutdin = 1;
|
spi->dev->user.doutdin = 1;
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 16; i++) {
|
for (i = 0; i < 16; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = 0x00000000;
|
spi->dev->data_buf[i].val = 0x00000000;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = 0x00000000;
|
spi->dev->data_buf[i] = 0x00000000;
|
||||||
|
|
@ -760,7 +733,7 @@ void spiWrite(spi_t *spi, const uint32_t *data, uint8_t len) {
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i];
|
spi->dev->data_buf[i].val = data[i];
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i];
|
spi->dev->data_buf[i] = data[i];
|
||||||
|
|
@ -787,7 +760,7 @@ void spiTransfer(spi_t *spi, uint32_t *data, uint8_t len) {
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = (len * 32) - 1;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = (len * 32) - 1;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = (len * 32) - 1;
|
spi->dev->miso_dlen.usr_miso_dbitlen = (len * 32) - 1;
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i];
|
spi->dev->data_buf[i].val = data[i];
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i];
|
spi->dev->data_buf[i] = data[i];
|
||||||
|
|
@ -800,7 +773,7 @@ void spiTransfer(spi_t *spi, uint32_t *data, uint8_t len) {
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data[i] = spi->dev->data_buf[i].val;
|
data[i] = spi->dev->data_buf[i].val;
|
||||||
#else
|
#else
|
||||||
data[i] = spi->dev->data_buf[i];
|
data[i] = spi->dev->data_buf[i];
|
||||||
|
|
@ -818,7 +791,7 @@ void spiWriteByte(spi_t *spi, uint8_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -840,7 +813,7 @@ uint8_t spiTransferByte(spi_t *spi, uint8_t data) {
|
||||||
SPI_MUTEX_LOCK();
|
SPI_MUTEX_LOCK();
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 7;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 7;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 7;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 7;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -851,7 +824,7 @@ uint8_t spiTransferByte(spi_t *spi, uint8_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val & 0xFF;
|
data = spi->dev->data_buf[0].val & 0xFF;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0] & 0xFF;
|
data = spi->dev->data_buf[0] & 0xFF;
|
||||||
|
|
@ -881,7 +854,7 @@ void spiWriteWord(spi_t *spi, uint16_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -905,7 +878,7 @@ uint16_t spiTransferWord(spi_t *spi, uint16_t data) {
|
||||||
SPI_MUTEX_LOCK();
|
SPI_MUTEX_LOCK();
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 15;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 15;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 15;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 15;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -916,7 +889,7 @@ uint16_t spiTransferWord(spi_t *spi, uint16_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val;
|
data = spi->dev->data_buf[0].val;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0];
|
data = spi->dev->data_buf[0];
|
||||||
|
|
@ -940,7 +913,7 @@ void spiWriteLong(spi_t *spi, uint32_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -964,7 +937,7 @@ uint32_t spiTransferLong(spi_t *spi, uint32_t data) {
|
||||||
SPI_MUTEX_LOCK();
|
SPI_MUTEX_LOCK();
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 31;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 31;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 31;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 31;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -975,7 +948,7 @@ uint32_t spiTransferLong(spi_t *spi, uint32_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val;
|
data = spi->dev->data_buf[0].val;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0];
|
data = spi->dev->data_buf[0];
|
||||||
|
|
@ -1014,7 +987,7 @@ static void __spiTransferBytes(spi_t *spi, const uint8_t *data, uint8_t *out, ui
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = ((bytes * 8) - 1);
|
spi->dev->miso_dlen.usr_miso_dbitlen = ((bytes * 8) - 1);
|
||||||
|
|
||||||
for (i = 0; i < words; i++) {
|
for (i = 0; i < words; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = wordsBuf[i]; //copy buffer to spi fifo
|
spi->dev->data_buf[i].val = wordsBuf[i]; //copy buffer to spi fifo
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = wordsBuf[i]; //copy buffer to spi fifo
|
spi->dev->data_buf[i] = wordsBuf[i]; //copy buffer to spi fifo
|
||||||
|
|
@ -1031,7 +1004,7 @@ static void __spiTransferBytes(spi_t *spi, const uint8_t *data, uint8_t *out, ui
|
||||||
|
|
||||||
if (out) {
|
if (out) {
|
||||||
for (i = 0; i < words; i++) {
|
for (i = 0; i < words; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
wordsBuf[i] = spi->dev->data_buf[i].val; //copy spi fifo to buffer
|
wordsBuf[i] = spi->dev->data_buf[i].val; //copy spi fifo to buffer
|
||||||
#else
|
#else
|
||||||
wordsBuf[i] = spi->dev->data_buf[i]; //copy spi fifo to buffer
|
wordsBuf[i] = spi->dev->data_buf[i]; //copy spi fifo to buffer
|
||||||
|
|
@ -1172,7 +1145,7 @@ void ARDUINO_ISR_ATTR spiWriteByteNL(spi_t *spi, uint8_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1191,7 +1164,7 @@ uint8_t spiTransferByteNL(spi_t *spi, uint8_t data) {
|
||||||
}
|
}
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 7;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 7;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 7;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 7;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1202,7 +1175,7 @@ uint8_t spiTransferByteNL(spi_t *spi, uint8_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val & 0xFF;
|
data = spi->dev->data_buf[0].val & 0xFF;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0] & 0xFF;
|
data = spi->dev->data_buf[0] & 0xFF;
|
||||||
|
|
@ -1221,7 +1194,7 @@ void ARDUINO_ISR_ATTR spiWriteShortNL(spi_t *spi, uint16_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1243,7 +1216,7 @@ uint16_t spiTransferShortNL(spi_t *spi, uint16_t data) {
|
||||||
}
|
}
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 15;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 15;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 15;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 15;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1254,7 +1227,7 @@ uint16_t spiTransferShortNL(spi_t *spi, uint16_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val & 0xFFFF;
|
data = spi->dev->data_buf[0].val & 0xFFFF;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0] & 0xFFFF;
|
data = spi->dev->data_buf[0] & 0xFFFF;
|
||||||
|
|
@ -1276,7 +1249,7 @@ void ARDUINO_ISR_ATTR spiWriteLongNL(spi_t *spi, uint32_t data) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1298,7 +1271,7 @@ uint32_t spiTransferLongNL(spi_t *spi, uint32_t data) {
|
||||||
}
|
}
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = 31;
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = 31;
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 31;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 31;
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1309,7 +1282,7 @@ uint32_t spiTransferLongNL(spi_t *spi, uint32_t data) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val;
|
data = spi->dev->data_buf[0].val;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0];
|
data = spi->dev->data_buf[0];
|
||||||
|
|
@ -1340,7 +1313,7 @@ void spiWriteNL(spi_t *spi, const void *data_in, uint32_t len) {
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
spi->dev->miso_dlen.usr_miso_dbitlen = 0;
|
||||||
#endif
|
#endif
|
||||||
for (size_t i = 0; i < c_longs; i++) {
|
for (size_t i = 0; i < c_longs; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i];
|
spi->dev->data_buf[i].val = data[i];
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i];
|
spi->dev->data_buf[i] = data[i];
|
||||||
|
|
@ -1379,7 +1352,7 @@ void spiTransferBytesNL(spi_t *spi, const void *data_in, uint8_t *data_out, uint
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = (c_len * 8) - 1;
|
spi->dev->miso_dlen.usr_miso_dbitlen = (c_len * 8) - 1;
|
||||||
if (data) {
|
if (data) {
|
||||||
for (size_t i = 0; i < c_longs; i++) {
|
for (size_t i = 0; i < c_longs; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i];
|
spi->dev->data_buf[i].val = data[i];
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i];
|
spi->dev->data_buf[i] = data[i];
|
||||||
|
|
@ -1387,7 +1360,7 @@ void spiTransferBytesNL(spi_t *spi, const void *data_in, uint8_t *data_out, uint
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < c_longs; i++) {
|
for (size_t i = 0; i < c_longs; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = 0xFFFFFFFF;
|
spi->dev->data_buf[i].val = 0xFFFFFFFF;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = 0xFFFFFFFF;
|
spi->dev->data_buf[i] = 0xFFFFFFFF;
|
||||||
|
|
@ -1403,13 +1376,13 @@ void spiTransferBytesNL(spi_t *spi, const void *data_in, uint8_t *data_out, uint
|
||||||
if (result) {
|
if (result) {
|
||||||
if (c_len & 3) {
|
if (c_len & 3) {
|
||||||
for (size_t i = 0; i < (c_longs - 1); i++) {
|
for (size_t i = 0; i < (c_longs - 1); i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
result[i] = spi->dev->data_buf[i].val;
|
result[i] = spi->dev->data_buf[i].val;
|
||||||
#else
|
#else
|
||||||
result[i] = spi->dev->data_buf[i];
|
result[i] = spi->dev->data_buf[i];
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
uint32_t last_data = spi->dev->data_buf[c_longs - 1].val;
|
uint32_t last_data = spi->dev->data_buf[c_longs - 1].val;
|
||||||
#else
|
#else
|
||||||
uint32_t last_data = spi->dev->data_buf[c_longs - 1];
|
uint32_t last_data = spi->dev->data_buf[c_longs - 1];
|
||||||
|
|
@ -1421,7 +1394,7 @@ void spiTransferBytesNL(spi_t *spi, const void *data_in, uint8_t *data_out, uint
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (size_t i = 0; i < c_longs; i++) {
|
for (size_t i = 0; i < c_longs; i++) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
result[i] = spi->dev->data_buf[i].val;
|
result[i] = spi->dev->data_buf[i].val;
|
||||||
#else
|
#else
|
||||||
result[i] = spi->dev->data_buf[i];
|
result[i] = spi->dev->data_buf[i];
|
||||||
|
|
@ -1463,7 +1436,7 @@ void spiTransferBitsNL(spi_t *spi, uint32_t data, uint32_t *out, uint8_t bits) {
|
||||||
|
|
||||||
spi->dev->mosi_dlen.usr_mosi_dbitlen = (bits - 1);
|
spi->dev->mosi_dlen.usr_mosi_dbitlen = (bits - 1);
|
||||||
spi->dev->miso_dlen.usr_miso_dbitlen = (bits - 1);
|
spi->dev->miso_dlen.usr_miso_dbitlen = (bits - 1);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[0].val = data;
|
spi->dev->data_buf[0].val = data;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[0] = data;
|
spi->dev->data_buf[0] = data;
|
||||||
|
|
@ -1474,7 +1447,7 @@ void spiTransferBitsNL(spi_t *spi, uint32_t data, uint32_t *out, uint8_t bits) {
|
||||||
#endif
|
#endif
|
||||||
spi->dev->cmd.usr = 1;
|
spi->dev->cmd.usr = 1;
|
||||||
while (spi->dev->cmd.usr);
|
while (spi->dev->cmd.usr);
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
data = spi->dev->data_buf[0].val;
|
data = spi->dev->data_buf[0].val;
|
||||||
#else
|
#else
|
||||||
data = spi->dev->data_buf[0];
|
data = spi->dev->data_buf[0];
|
||||||
|
|
@ -1515,27 +1488,27 @@ void ARDUINO_ISR_ATTR spiWritePixelsNL(spi_t *spi, const void *data_in, uint32_t
|
||||||
if (msb) {
|
if (msb) {
|
||||||
if (l_bytes && i == (c_longs - 1)) {
|
if (l_bytes && i == (c_longs - 1)) {
|
||||||
if (l_bytes == 2) {
|
if (l_bytes == 2) {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
MSB_16_SET(spi->dev->data_buf[i].val, data[i]);
|
MSB_16_SET(spi->dev->data_buf[i].val, data[i]);
|
||||||
#else
|
#else
|
||||||
MSB_16_SET(spi->dev->data_buf[i], data[i]);
|
MSB_16_SET(spi->dev->data_buf[i], data[i]);
|
||||||
#endif
|
#endif
|
||||||
} else {
|
} else {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i] & 0xFF;
|
spi->dev->data_buf[i].val = data[i] & 0xFF;
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i] & 0xFF;
|
spi->dev->data_buf[i] = data[i] & 0xFF;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
MSB_PIX_SET(spi->dev->data_buf[i].val, data[i]);
|
MSB_PIX_SET(spi->dev->data_buf[i].val, data[i]);
|
||||||
#else
|
#else
|
||||||
MSB_PIX_SET(spi->dev->data_buf[i], data[i]);
|
MSB_PIX_SET(spi->dev->data_buf[i], data[i]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
spi->dev->data_buf[i].val = data[i];
|
spi->dev->data_buf[i].val = data[i];
|
||||||
#else
|
#else
|
||||||
spi->dev->data_buf[i] = data[i];
|
spi->dev->data_buf[i] = data[i];
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,19 @@ extern "C" {
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define SPI_HAS_TRANSACTION
|
#define SPI_HAS_TRANSACTION
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32
|
|
||||||
|
#ifdef CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
#define FSPI 1 //SPI 1 bus. ESP32S2: for external memory only (can use the same data lines but different SS)
|
||||||
|
#define HSPI 2 //SPI 2 bus. ESP32S2: external memory or device - it can be matrixed to any pins
|
||||||
|
#define SPI2 2 // Another name for ESP32S2 SPI 2
|
||||||
|
#define SPI3 3 //SPI 3 bus. ESP32S2: device only - it can be matrixed to any pins
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32
|
||||||
#define FSPI 1 //SPI 1 bus attached to the flash (can use the same data lines but different SS)
|
#define FSPI 1 //SPI 1 bus attached to the flash (can use the same data lines but different SS)
|
||||||
#define HSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins
|
#define HSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins
|
||||||
#define VSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins
|
#define VSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins
|
||||||
#else
|
#else
|
||||||
#define FSPI 0 // ESP32C2, C3, C6, H2, S2, S3, P4 - SPI 2 bus
|
#define FSPI 0
|
||||||
#define HSPI 1 // ESP32S2, S3, P4 - SPI 3 bus
|
#define HSPI 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// This defines are not representing the real Divider of the ESP32
|
// This defines are not representing the real Divider of the ESP32
|
||||||
|
|
@ -91,8 +97,6 @@ void spiSSSet(spi_t *spi);
|
||||||
void spiSSClear(spi_t *spi);
|
void spiSSClear(spi_t *spi);
|
||||||
|
|
||||||
void spiWaitReady(spi_t *spi);
|
void spiWaitReady(spi_t *spi);
|
||||||
//invert hardware SS
|
|
||||||
void spiSSInvert(spi_t *spi, bool invert);
|
|
||||||
|
|
||||||
uint32_t spiGetClockDiv(spi_t *spi);
|
uint32_t spiGetClockDiv(spi_t *spi);
|
||||||
uint8_t spiGetDataMode(spi_t *spi);
|
uint8_t spiGetDataMode(spi_t *spi);
|
||||||
|
|
|
||||||
|
|
@ -22,12 +22,6 @@
|
||||||
#include "esp_clk_tree.h"
|
#include "esp_clk_tree.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
#define TIMER_IRAM IRAM_ATTR
|
|
||||||
#else
|
|
||||||
#define TIMER_IRAM
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef void (*voidFuncPtr)(void);
|
typedef void (*voidFuncPtr)(void);
|
||||||
typedef void (*voidFuncPtrArg)(void *);
|
typedef void (*voidFuncPtrArg)(void *);
|
||||||
|
|
||||||
|
|
@ -42,11 +36,9 @@ struct timer_struct_t {
|
||||||
bool timer_started;
|
bool timer_started;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline TIMER_IRAM uint64_t timerRead(hw_timer_t *timer) {
|
inline uint64_t timerRead(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
uint64_t value;
|
uint64_t value;
|
||||||
|
|
@ -54,21 +46,17 @@ inline TIMER_IRAM uint64_t timerRead(hw_timer_t *timer) {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIMER_IRAM timerWrite(hw_timer_t *timer, uint64_t val) {
|
void timerWrite(hw_timer_t *timer, uint64_t val) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_set_raw_count(timer->timer_handle, val);
|
gptimer_set_raw_count(timer->timer_handle, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIMER_IRAM timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
|
void timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autoreload, uint64_t reload_count) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
esp_err_t err = ESP_OK;
|
esp_err_t err = ESP_OK;
|
||||||
|
|
@ -79,9 +67,7 @@ void TIMER_IRAM timerAlarm(hw_timer_t *timer, uint64_t alarm_value, bool autorel
|
||||||
};
|
};
|
||||||
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
|
err = gptimer_set_alarm_action(timer->timer_handle, &alarm_cfg);
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer Alarm Write failed, error num=%d", err);
|
log_e("Timer Alarm Write failed, error num=%d", err);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -94,33 +80,27 @@ uint32_t timerGetFrequency(hw_timer_t *timer) {
|
||||||
return frequency;
|
return frequency;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIMER_IRAM timerStart(hw_timer_t *timer) {
|
void timerStart(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_start(timer->timer_handle);
|
gptimer_start(timer->timer_handle);
|
||||||
timer->timer_started = true;
|
timer->timer_started = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIMER_IRAM timerStop(hw_timer_t *timer) {
|
void timerStop(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_stop(timer->timer_handle);
|
gptimer_stop(timer->timer_handle);
|
||||||
timer->timer_started = false;
|
timer->timer_started = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TIMER_IRAM timerRestart(hw_timer_t *timer) {
|
void timerRestart(hw_timer_t *timer) {
|
||||||
if (timer == NULL) {
|
if (timer == NULL) {
|
||||||
#ifndef CONFIG_GPTIMER_CTRL_FUNC_IN_IRAM
|
|
||||||
log_e("Timer handle is NULL");
|
log_e("Timer handle is NULL");
|
||||||
#endif
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gptimer_set_raw_count(timer->timer_handle, 0);
|
gptimer_set_raw_count(timer->timer_handle, 0);
|
||||||
|
|
|
||||||
|
|
@ -466,6 +466,9 @@ __attribute__((weak)) int32_t tud_msc_write10_cb(uint8_t lun, uint32_t lba, uint
|
||||||
__attribute__((weak)) int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, uint16_t bufsize) {
|
__attribute__((weak)) int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cmd[16], void *buffer, uint16_t bufsize) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
__attribute__((weak)) bool tud_msc_is_writable_cb(uint8_t lun) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
#if CFG_TUD_NCM
|
#if CFG_TUD_NCM
|
||||||
__attribute__((weak)) bool tud_network_recv_cb(const uint8_t *src, uint16_t size) {
|
__attribute__((weak)) bool tud_network_recv_cb(const uint8_t *src, uint16_t size) {
|
||||||
|
|
|
||||||
|
|
@ -32,11 +32,10 @@
|
||||||
#include "driver/gpio.h"
|
#include "driver/gpio.h"
|
||||||
#include "hal/gpio_hal.h"
|
#include "hal/gpio_hal.h"
|
||||||
#include "esp_rom_gpio.h"
|
#include "esp_rom_gpio.h"
|
||||||
#include "esp_private/gpio.h"
|
|
||||||
|
|
||||||
#include "driver/rtc_io.h"
|
#include "driver/rtc_io.h"
|
||||||
#include "driver/lp_io.h"
|
#include "driver/lp_io.h"
|
||||||
#include "soc/uart_pins.h"
|
#include "soc/uart_periph.h"
|
||||||
#include "esp_private/uart_share_hw_ctrl.h"
|
#include "esp_private/uart_share_hw_ctrl.h"
|
||||||
|
|
||||||
static int s_uart_debug_nr = 0; // UART number for debug output
|
static int s_uart_debug_nr = 0; // UART number for debug output
|
||||||
|
|
@ -59,7 +58,6 @@ struct uart_struct_t {
|
||||||
uint16_t _rx_buffer_size, _tx_buffer_size; // UART RX and TX buffer sizes
|
uint16_t _rx_buffer_size, _tx_buffer_size; // UART RX and TX buffer sizes
|
||||||
bool _inverted; // UART inverted signal
|
bool _inverted; // UART inverted signal
|
||||||
uint8_t _rxfifo_full_thrhd; // UART RX FIFO full threshold
|
uint8_t _rxfifo_full_thrhd; // UART RX FIFO full threshold
|
||||||
int8_t _uart_clock_source; // UART Clock Source used when it is started using uartBegin()
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#if CONFIG_DISABLE_HAL_LOCKS
|
#if CONFIG_DISABLE_HAL_LOCKS
|
||||||
|
|
@ -68,21 +66,21 @@ struct uart_struct_t {
|
||||||
#define UART_MUTEX_UNLOCK()
|
#define UART_MUTEX_UNLOCK()
|
||||||
|
|
||||||
static uart_t _uart_bus_array[] = {
|
static uart_t _uart_bus_array[] = {
|
||||||
{0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#if SOC_UART_NUM > 1
|
#if SOC_UART_NUM > 1
|
||||||
{1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 2
|
#if SOC_UART_NUM > 2
|
||||||
{2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 3
|
#if SOC_UART_NUM > 3
|
||||||
{3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 4
|
#if SOC_UART_NUM > 4
|
||||||
{4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 5
|
#if SOC_UART_NUM > 5
|
||||||
{5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -97,21 +95,21 @@ static uart_t _uart_bus_array[] = {
|
||||||
xSemaphoreGive(uart->lock)
|
xSemaphoreGive(uart->lock)
|
||||||
|
|
||||||
static uart_t _uart_bus_array[] = {
|
static uart_t _uart_bus_array[] = {
|
||||||
{NULL, 0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 0, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#if SOC_UART_NUM > 1
|
#if SOC_UART_NUM > 1
|
||||||
{NULL, 1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 1, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 2
|
#if SOC_UART_NUM > 2
|
||||||
{NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 2, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 3
|
#if SOC_UART_NUM > 3
|
||||||
{NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 3, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 4
|
#if SOC_UART_NUM > 4
|
||||||
{NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 4, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
#if SOC_UART_NUM > 5
|
#if SOC_UART_NUM > 5
|
||||||
{NULL, 5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0, -1},
|
{NULL, 5, false, 0, NULL, -1, -1, -1, -1, 0, 0, 0, 0, false, 0},
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -208,14 +206,6 @@ static bool lpuartCheckPins(int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rt
|
||||||
}
|
}
|
||||||
#endif // SOC_UART_LP_NUM >= 1
|
#endif // SOC_UART_LP_NUM >= 1
|
||||||
|
|
||||||
#ifndef GPIO_FUNC_IN_LOW
|
|
||||||
#define GPIO_FUNC_IN_LOW GPIO_MATRIX_CONST_ZERO_INPUT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef GPIO_FUNC_IN_HIGH
|
|
||||||
#define GPIO_FUNC_IN_HIGH GPIO_MATRIX_CONST_ONE_INPUT
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Negative Pin Number will keep it unmodified, thus this function can detach individual pins
|
// Negative Pin Number will keep it unmodified, thus this function can detach individual pins
|
||||||
// This function will also unset the pins in the Peripheral Manager and set the pin to -1 after detaching
|
// This function will also unset the pins in the Peripheral Manager and set the pin to -1 after detaching
|
||||||
static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) {
|
static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) {
|
||||||
|
|
@ -231,8 +221,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
|
|
||||||
// detaches HP and LP pins and sets Peripheral Manager and UART information
|
// detaches HP and LP pins and sets Peripheral Manager and UART information
|
||||||
if (rxPin >= 0 && uart->_rxPin == rxPin && perimanGetPinBusType(rxPin) == ESP32_BUS_TYPE_UART_RX) {
|
if (rxPin >= 0 && uart->_rxPin == rxPin && perimanGetPinBusType(rxPin) == ESP32_BUS_TYPE_UART_RX) {
|
||||||
//gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rxPin], PIN_FUNC_GPIO);
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rxPin], PIN_FUNC_GPIO);
|
||||||
esp_rom_gpio_pad_select_gpio(rxPin);
|
|
||||||
// avoids causing BREAK in the UART line
|
// avoids causing BREAK in the UART line
|
||||||
if (uart->_inverted) {
|
if (uart->_inverted) {
|
||||||
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), false);
|
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), false);
|
||||||
|
|
@ -246,8 +235,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (txPin >= 0 && uart->_txPin == txPin && perimanGetPinBusType(txPin) == ESP32_BUS_TYPE_UART_TX) {
|
if (txPin >= 0 && uart->_txPin == txPin && perimanGetPinBusType(txPin) == ESP32_BUS_TYPE_UART_TX) {
|
||||||
//gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[txPin], PIN_FUNC_GPIO);
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[txPin], PIN_FUNC_GPIO);
|
||||||
esp_rom_gpio_pad_select_gpio(txPin);
|
|
||||||
esp_rom_gpio_connect_out_signal(txPin, SIG_GPIO_OUT_IDX, false, false);
|
esp_rom_gpio_connect_out_signal(txPin, SIG_GPIO_OUT_IDX, false, false);
|
||||||
uart->_txPin = -1; // -1 means unassigned/detached
|
uart->_txPin = -1; // -1 means unassigned/detached
|
||||||
if (!perimanClearPinBus(txPin)) {
|
if (!perimanClearPinBus(txPin)) {
|
||||||
|
|
@ -256,8 +244,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (ctsPin >= 0 && uart->_ctsPin == ctsPin && perimanGetPinBusType(ctsPin) == ESP32_BUS_TYPE_UART_CTS) {
|
if (ctsPin >= 0 && uart->_ctsPin == ctsPin && perimanGetPinBusType(ctsPin) == ESP32_BUS_TYPE_UART_CTS) {
|
||||||
//gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[ctsPin], PIN_FUNC_GPIO);
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[ctsPin], PIN_FUNC_GPIO);
|
||||||
esp_rom_gpio_pad_select_gpio(ctsPin);
|
|
||||||
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), false);
|
esp_rom_gpio_connect_in_signal(GPIO_FUNC_IN_LOW, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), false);
|
||||||
uart->_ctsPin = -1; // -1 means unassigned/detached
|
uart->_ctsPin = -1; // -1 means unassigned/detached
|
||||||
if (!perimanClearPinBus(ctsPin)) {
|
if (!perimanClearPinBus(ctsPin)) {
|
||||||
|
|
@ -266,8 +253,7 @@ static bool _uartDetachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (rtsPin >= 0 && uart->_rtsPin == rtsPin && perimanGetPinBusType(rtsPin) == ESP32_BUS_TYPE_UART_RTS) {
|
if (rtsPin >= 0 && uart->_rtsPin == rtsPin && perimanGetPinBusType(rtsPin) == ESP32_BUS_TYPE_UART_RTS) {
|
||||||
//gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rtsPin], PIN_FUNC_GPIO);
|
gpio_hal_iomux_func_sel(GPIO_PIN_MUX_REG[rtsPin], PIN_FUNC_GPIO);
|
||||||
esp_rom_gpio_pad_select_gpio(rtsPin);
|
|
||||||
esp_rom_gpio_connect_out_signal(rtsPin, SIG_GPIO_OUT_IDX, false, false);
|
esp_rom_gpio_connect_out_signal(rtsPin, SIG_GPIO_OUT_IDX, false, false);
|
||||||
uart->_rtsPin = -1; // -1 means unassigned/detached
|
uart->_rtsPin = -1; // -1 means unassigned/detached
|
||||||
if (!perimanClearPinBus(rtsPin)) {
|
if (!perimanClearPinBus(rtsPin)) {
|
||||||
|
|
@ -307,147 +293,6 @@ static bool _uartDetachBus_RTS(void *busptr) {
|
||||||
return _uartDetachPins(bus->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, bus->_rtsPin);
|
return _uartDetachPins(bus->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, bus->_rtsPin);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool _uartTrySetIomuxPin(uart_port_t uart_num, int io_num, uint32_t idx) {
|
|
||||||
// Store a pointer to the default pin, to optimize access to its fields.
|
|
||||||
const uart_periph_sig_t *upin = &uart_periph_signal[uart_num].pins[idx];
|
|
||||||
|
|
||||||
// In theory, if default_gpio is -1, iomux_func should also be -1, but let's be safe and test both.
|
|
||||||
if (upin->iomux_func == -1 || upin->default_gpio == -1 || upin->default_gpio != io_num) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Assign the correct function to the GPIO.
|
|
||||||
if (upin->iomux_func == -1) {
|
|
||||||
log_e("IO#%d has bad IOMUX internal information. Switching to GPIO Matrix UART function.", io_num);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (uart_num < SOC_UART_HP_NUM) {
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 5, 0)
|
|
||||||
if (upin->input) {
|
|
||||||
gpio_iomux_input(io_num, upin->iomux_func, upin->signal);
|
|
||||||
} else {
|
|
||||||
gpio_iomux_output(io_num, upin->iomux_func);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
gpio_iomux_out(io_num, upin->iomux_func, false);
|
|
||||||
// If the pin is input, we also have to redirect the signal, in order to bypass the GPIO matrix.
|
|
||||||
if (upin->input) {
|
|
||||||
gpio_iomux_in(io_num, upin->signal);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#if (SOC_UART_LP_NUM >= 1) && (SOC_RTCIO_PIN_COUNT >= 1)
|
|
||||||
else {
|
|
||||||
if (upin->input) {
|
|
||||||
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
} else {
|
|
||||||
rtc_gpio_set_direction(io_num, RTC_GPIO_MODE_OUTPUT_ONLY);
|
|
||||||
}
|
|
||||||
rtc_gpio_init(io_num);
|
|
||||||
rtc_gpio_iomux_func_sel(io_num, upin->iomux_func);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static esp_err_t _uartInternalSetPin(uart_port_t uart_num, int tx_io_num, int rx_io_num, int rts_io_num, int cts_io_num) {
|
|
||||||
// Since an IO cannot route peripheral signals via IOMUX and GPIO matrix at the same time,
|
|
||||||
// if tx and rx share the same IO, both signals need to be routed to IOs through GPIO matrix
|
|
||||||
bool tx_rx_same_io = (tx_io_num == rx_io_num);
|
|
||||||
|
|
||||||
// In the following statements, if the io_num is negative, no need to configure anything.
|
|
||||||
if (tx_io_num >= 0) {
|
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
|
||||||
// In such case, IOs are going to switch to sleep configuration (isolate) when entering sleep for power saving reason
|
|
||||||
// But TX IO in isolate state could write garbled data to the other end
|
|
||||||
// Therefore, we should disable the switch of the TX pin to sleep configuration
|
|
||||||
gpio_sleep_sel_dis(tx_io_num);
|
|
||||||
#endif
|
|
||||||
if (tx_rx_same_io || !_uartTrySetIomuxPin(uart_num, tx_io_num, SOC_UART_TX_PIN_IDX)) {
|
|
||||||
if (uart_num < SOC_UART_HP_NUM) {
|
|
||||||
gpio_func_sel(tx_io_num, PIN_FUNC_GPIO);
|
|
||||||
esp_rom_gpio_connect_out_signal(tx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_TX_PIN_IDX), 0, 0);
|
|
||||||
// output enable is set inside esp_rom_gpio_connect_out_signal func after the signal is connected
|
|
||||||
// (output enabled too early may cause unnecessary level change at the pad)
|
|
||||||
}
|
|
||||||
#if SOC_LP_GPIO_MATRIX_SUPPORTED
|
|
||||||
else {
|
|
||||||
rtc_gpio_init(tx_io_num); // set as a LP_GPIO pin
|
|
||||||
lp_gpio_connect_out_signal(tx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_TX_PIN_IDX), 0, 0);
|
|
||||||
// output enable is set inside lp_gpio_connect_out_signal func after the signal is connected
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rx_io_num >= 0) {
|
|
||||||
#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND || CONFIG_PM_SLP_DISABLE_GPIO
|
|
||||||
// In such case, IOs are going to switch to sleep configuration (isolate) when entering sleep for power saving reason
|
|
||||||
// But RX IO in isolate state could receive garbled data into FIFO, which is not desired
|
|
||||||
// Therefore, we should disable the switch of the RX pin to sleep configuration
|
|
||||||
gpio_sleep_sel_dis(rx_io_num);
|
|
||||||
#endif
|
|
||||||
if (tx_rx_same_io || !_uartTrySetIomuxPin(uart_num, rx_io_num, SOC_UART_RX_PIN_IDX)) {
|
|
||||||
if (uart_num < SOC_UART_HP_NUM) {
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
|
||||||
gpio_input_enable(rx_io_num);
|
|
||||||
#else
|
|
||||||
gpio_func_sel(rx_io_num, PIN_FUNC_GPIO);
|
|
||||||
gpio_ll_input_enable(&GPIO, rx_io_num);
|
|
||||||
#endif
|
|
||||||
esp_rom_gpio_connect_in_signal(rx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), 0);
|
|
||||||
}
|
|
||||||
#if SOC_LP_GPIO_MATRIX_SUPPORTED
|
|
||||||
else {
|
|
||||||
rtc_gpio_mode_t mode = (tx_rx_same_io ? RTC_GPIO_MODE_INPUT_OUTPUT : RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_set_direction(rx_io_num, mode);
|
|
||||||
if (!tx_rx_same_io) { // set the same pin again as a LP_GPIO will overwrite connected out_signal, not desired, so skip
|
|
||||||
rtc_gpio_init(rx_io_num); // set as a LP_GPIO pin
|
|
||||||
}
|
|
||||||
lp_gpio_connect_in_signal(rx_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RX_PIN_IDX), 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rts_io_num >= 0 && !_uartTrySetIomuxPin(uart_num, rts_io_num, SOC_UART_RTS_PIN_IDX)) {
|
|
||||||
if (uart_num < SOC_UART_HP_NUM) {
|
|
||||||
gpio_func_sel(rts_io_num, PIN_FUNC_GPIO);
|
|
||||||
esp_rom_gpio_connect_out_signal(rts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RTS_PIN_IDX), 0, 0);
|
|
||||||
// output enable is set inside esp_rom_gpio_connect_out_signal func after the signal is connected
|
|
||||||
}
|
|
||||||
#if SOC_LP_GPIO_MATRIX_SUPPORTED
|
|
||||||
else {
|
|
||||||
rtc_gpio_init(rts_io_num); // set as a LP_GPIO pin
|
|
||||||
lp_gpio_connect_out_signal(rts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_RTS_PIN_IDX), 0, 0);
|
|
||||||
// output enable is set inside lp_gpio_connect_out_signal func after the signal is connected
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
if (cts_io_num >= 0 && !_uartTrySetIomuxPin(uart_num, cts_io_num, SOC_UART_CTS_PIN_IDX)) {
|
|
||||||
if (uart_num < SOC_UART_HP_NUM) {
|
|
||||||
#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 4, 0)
|
|
||||||
gpio_pullup_en(cts_io_num);
|
|
||||||
gpio_input_enable(cts_io_num);
|
|
||||||
#else
|
|
||||||
gpio_func_sel(cts_io_num, PIN_FUNC_GPIO);
|
|
||||||
gpio_set_pull_mode(cts_io_num, GPIO_PULLUP_ONLY);
|
|
||||||
gpio_set_direction(cts_io_num, GPIO_MODE_INPUT);
|
|
||||||
#endif
|
|
||||||
esp_rom_gpio_connect_in_signal(cts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), 0);
|
|
||||||
}
|
|
||||||
#if SOC_LP_GPIO_MATRIX_SUPPORTED
|
|
||||||
else {
|
|
||||||
rtc_gpio_set_direction(cts_io_num, RTC_GPIO_MODE_INPUT_ONLY);
|
|
||||||
rtc_gpio_init(cts_io_num); // set as a LP_GPIO pin
|
|
||||||
lp_gpio_connect_in_signal(cts_io_num, UART_PERIPH_SIGNAL(uart_num, SOC_UART_CTS_PIN_IDX), 0);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Attach function for UART
|
// Attach function for UART
|
||||||
// connects the IO Pad, set Paripheral Manager and internal UART structure data
|
// connects the IO Pad, set Paripheral Manager and internal UART structure data
|
||||||
static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) {
|
static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t ctsPin, int8_t rtsPin) {
|
||||||
|
|
@ -460,7 +305,7 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
//log_v("attaching UART%d pins: prev,new RX(%d,%d) TX(%d,%d) CTS(%d,%d) RTS(%d,%d)", uart_num,
|
//log_v("attaching UART%d pins: prev,new RX(%d,%d) TX(%d,%d) CTS(%d,%d) RTS(%d,%d)", uart_num,
|
||||||
// uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10);
|
// uart->_rxPin, rxPin, uart->_txPin, txPin, uart->_ctsPin, ctsPin, uart->_rtsPin, rtsPin); vTaskDelay(10);
|
||||||
|
|
||||||
// IDF _uartInternalSetPin() checks if the pin is used within LP UART and if it is a valid RTC IO pin
|
// IDF uart_set_pin() checks if the pin is used within LP UART and if it is a valid RTC IO pin
|
||||||
// No need for Arduino Layer to check it again
|
// No need for Arduino Layer to check it again
|
||||||
bool retCode = true;
|
bool retCode = true;
|
||||||
if (rxPin >= 0) {
|
if (rxPin >= 0) {
|
||||||
|
|
@ -469,7 +314,7 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
perimanClearPinBus(rxPin);
|
perimanClearPinBus(rxPin);
|
||||||
}
|
}
|
||||||
// connect RX Pad
|
// connect RX Pad
|
||||||
bool ret = ESP_OK == _uartInternalSetPin(uart->num, UART_PIN_NO_CHANGE, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, rxPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
ret &= lp_uart_config_io(uart->num, rxPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_RX_PIN_IDX);
|
ret &= lp_uart_config_io(uart->num, rxPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_RX_PIN_IDX);
|
||||||
|
|
@ -492,7 +337,7 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
perimanClearPinBus(txPin);
|
perimanClearPinBus(txPin);
|
||||||
}
|
}
|
||||||
// connect TX Pad
|
// connect TX Pad
|
||||||
bool ret = ESP_OK == _uartInternalSetPin(uart->num, txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
bool ret = ESP_OK == uart_set_pin(uart->num, txPin, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE);
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
ret &= lp_uart_config_io(uart->num, txPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_TX_PIN_IDX);
|
ret &= lp_uart_config_io(uart->num, txPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_TX_PIN_IDX);
|
||||||
|
|
@ -515,7 +360,7 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
perimanClearPinBus(ctsPin);
|
perimanClearPinBus(ctsPin);
|
||||||
}
|
}
|
||||||
// connect CTS Pad
|
// connect CTS Pad
|
||||||
bool ret = ESP_OK == _uartInternalSetPin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, ctsPin);
|
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, ctsPin);
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
ret &= lp_uart_config_io(uart->num, ctsPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_CTS_PIN_IDX);
|
ret &= lp_uart_config_io(uart->num, ctsPin, RTC_GPIO_MODE_INPUT_ONLY, SOC_UART_CTS_PIN_IDX);
|
||||||
|
|
@ -538,7 +383,7 @@ static bool _uartAttachPins(uint8_t uart_num, int8_t rxPin, int8_t txPin, int8_t
|
||||||
perimanClearPinBus(rtsPin);
|
perimanClearPinBus(rtsPin);
|
||||||
}
|
}
|
||||||
// connect RTS Pad
|
// connect RTS Pad
|
||||||
bool ret = ESP_OK == _uartInternalSetPin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, rtsPin, UART_PIN_NO_CHANGE);
|
bool ret = ESP_OK == uart_set_pin(uart->num, UART_PIN_NO_CHANGE, UART_PIN_NO_CHANGE, rtsPin, UART_PIN_NO_CHANGE);
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (ret && uart_num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
ret &= lp_uart_config_io(uart->num, rtsPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_RTS_PIN_IDX);
|
ret &= lp_uart_config_io(uart->num, rtsPin, RTC_GPIO_MODE_OUTPUT_ONLY, SOC_UART_RTS_PIN_IDX);
|
||||||
|
|
@ -820,20 +665,11 @@ uart_t *uartBegin(
|
||||||
uart_config.baud_rate = baudrate;
|
uart_config.baud_rate = baudrate;
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (uart_nr >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (uart_nr >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
if (uart->_uart_clock_source > 0) {
|
|
||||||
uart_config.lp_source_clk = (soc_periph_lp_uart_clk_src_t)uart->_uart_clock_source; // use user defined LP UART clock
|
|
||||||
log_v("Setting UART%d to user defined LP clock source (%d) ", uart_nr, uart->_uart_clock_source);
|
|
||||||
} else {
|
|
||||||
uart_config.lp_source_clk = LP_UART_SCLK_DEFAULT; // use default LP clock
|
uart_config.lp_source_clk = LP_UART_SCLK_DEFAULT; // use default LP clock
|
||||||
log_v("Setting UART%d to Default LP clock source", uart_nr);
|
log_v("Setting UART%d to use LP clock", uart_nr);
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
#endif // SOC_UART_LP_NUM >= 1
|
#endif
|
||||||
{
|
{
|
||||||
if (uart->_uart_clock_source >= 0) {
|
|
||||||
uart_config.source_clk = (soc_module_clk_t)uart->_uart_clock_source; // use user defined HP UART clock
|
|
||||||
log_v("Setting UART%d to user defined HP clock source (%d) ", uart_nr, uart->_uart_clock_source);
|
|
||||||
} else {
|
|
||||||
// there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
|
// there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
|
||||||
// therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
|
// therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
|
||||||
#if SOC_UART_SUPPORT_XTAL_CLK
|
#if SOC_UART_SUPPORT_XTAL_CLK
|
||||||
|
|
@ -848,11 +684,10 @@ uart_t *uartBegin(
|
||||||
log_v("Setting UART%d to use APB clock", uart_nr);
|
log_v("Setting UART%d to use APB clock", uart_nr);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6|P4
|
// Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6
|
||||||
uart_config.source_clk = UART_SCLK_DEFAULT; // baudrate may change with the APB Frequency!
|
uart_config.source_clk = UART_SCLK_DEFAULT; // baudrate may change with the APB Frequency!
|
||||||
log_v("Setting UART%d to use DEFAULT clock", uart_nr);
|
log_v("Setting UART%d to use DEFAULT clock", uart_nr);
|
||||||
#endif // SOC_UART_SUPPORT_XTAL_CLK
|
#endif
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UART_MUTEX_LOCK();
|
UART_MUTEX_LOCK();
|
||||||
|
|
@ -881,14 +716,6 @@ uart_t *uartBegin(
|
||||||
uart->_tx_buffer_size = tx_buffer_size;
|
uart->_tx_buffer_size = tx_buffer_size;
|
||||||
uart->has_peek = false;
|
uart->has_peek = false;
|
||||||
uart->peek_byte = 0;
|
uart->peek_byte = 0;
|
||||||
#if SOC_UART_LP_NUM >= 1
|
|
||||||
if (uart_nr >= SOC_UART_HP_NUM) {
|
|
||||||
uart->_uart_clock_source = uart_config.lp_source_clk;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
uart->_uart_clock_source = uart_config.source_clk;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
UART_MUTEX_UNLOCK();
|
UART_MUTEX_UNLOCK();
|
||||||
|
|
||||||
|
|
@ -981,7 +808,7 @@ void uartSetRxInvert(uart_t *uart, bool invert) {
|
||||||
if (uart == NULL) {
|
if (uart == NULL) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4 || CONFIG_IDF_TARGET_ESP32C5
|
#if CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32P4
|
||||||
// POTENTIAL ISSUE :: original code only set/reset rxd_inv bit
|
// POTENTIAL ISSUE :: original code only set/reset rxd_inv bit
|
||||||
// IDF or LL set/reset the whole inv_mask!
|
// IDF or LL set/reset the whole inv_mask!
|
||||||
// if (invert)
|
// if (invert)
|
||||||
|
|
@ -1148,52 +975,22 @@ bool uartSetBaudRate(uart_t *uart, uint32_t baud_rate) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
bool retCode = true;
|
bool retCode = true;
|
||||||
soc_module_clk_t newClkSrc = UART_SCLK_DEFAULT;
|
UART_MUTEX_LOCK();
|
||||||
int8_t previousClkSrc = uart->_uart_clock_source;
|
#if SOC_UART_SUPPORT_XTAL_CLK // ESP32-S3, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-H2 and ESP32-P4
|
||||||
|
soc_module_clk_t newClkSrc = UART_SCLK_XTAL;
|
||||||
#if SOC_UART_LP_NUM >= 1
|
#if SOC_UART_LP_NUM >= 1
|
||||||
if (uart->num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
if (uart->num >= SOC_UART_HP_NUM) { // it is a LP UART NUM
|
||||||
if (uart->_uart_clock_source > 0) {
|
|
||||||
newClkSrc = (soc_periph_lp_uart_clk_src_t)uart->_uart_clock_source; // use user defined LP UART clock
|
|
||||||
log_v("Setting UART%d to user defined LP clock source (%d) ", uart->num, newClkSrc);
|
|
||||||
} else {
|
|
||||||
newClkSrc = LP_UART_SCLK_DEFAULT; // use default LP clock
|
newClkSrc = LP_UART_SCLK_DEFAULT; // use default LP clock
|
||||||
log_v("Setting UART%d to Default LP clock source", uart->num);
|
|
||||||
}
|
}
|
||||||
} else
|
#endif
|
||||||
#endif // SOC_UART_LP_NUM >= 1
|
// ESP32-P4 demands an atomic operation for setting the clock source
|
||||||
{
|
|
||||||
if (uart->_uart_clock_source >= 0) {
|
|
||||||
newClkSrc = (soc_module_clk_t)uart->_uart_clock_source; // use user defined HP UART clock
|
|
||||||
log_v("Setting UART%d to use HP clock source (%d) ", uart->num, newClkSrc);
|
|
||||||
} else {
|
|
||||||
// there is an issue when returning from light sleep with the C6 and H2: the uart baud rate is not restored
|
|
||||||
// therefore, uart clock source will set to XTAL for all SoC that support it. This fix solves the C6|H2 issue.
|
|
||||||
#if SOC_UART_SUPPORT_XTAL_CLK
|
|
||||||
newClkSrc = UART_SCLK_XTAL; // valid for C2, S3, C3, C6, H2 and P4
|
|
||||||
log_v("Setting UART%d to use XTAL clock", uart->num);
|
|
||||||
#elif SOC_UART_SUPPORT_REF_TICK
|
|
||||||
if (baud_rate <= REF_TICK_BAUDRATE_LIMIT) {
|
|
||||||
newClkSrc = UART_SCLK_REF_TICK; // valid for ESP32, S2 - MAX supported baud rate is 250 Kbps
|
|
||||||
log_v("Setting UART%d to use REF_TICK clock", uart->num);
|
|
||||||
} else {
|
|
||||||
newClkSrc = UART_SCLK_APB; // baudrate may change with the APB Frequency!
|
|
||||||
log_v("Setting UART%d to use APB clock", uart->num);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Default CLK Source: CLK_APB for ESP32|S2|S3|C3 -- CLK_PLL_F40M for C2 -- CLK_PLL_F48M for H2 -- CLK_PLL_F80M for C6|P4
|
|
||||||
// using newClkSrc = UART_SCLK_DEFAULT as defined in the variable declaration
|
|
||||||
log_v("Setting UART%d to use DEFAULT clock", uart->num);
|
|
||||||
#endif // SOC_UART_SUPPORT_XTAL_CLK
|
|
||||||
}
|
|
||||||
}
|
|
||||||
UART_MUTEX_LOCK();
|
|
||||||
// if necessary, set the correct UART Clock Source before changing the baudrate
|
|
||||||
if (previousClkSrc < 0 || previousClkSrc != newClkSrc) {
|
|
||||||
HP_UART_SRC_CLK_ATOMIC() {
|
HP_UART_SRC_CLK_ATOMIC() {
|
||||||
uart_ll_set_sclk(UART_LL_GET_HW(uart->num), newClkSrc);
|
uart_ll_set_sclk(UART_LL_GET_HW(uart->num), newClkSrc);
|
||||||
}
|
}
|
||||||
uart->_uart_clock_source = newClkSrc;
|
#else // ESP32, ESP32-S2
|
||||||
}
|
soc_module_clk_t newClkSrc = baud_rate <= REF_TICK_BAUDRATE_LIMIT ? SOC_MOD_CLK_REF_TICK : SOC_MOD_CLK_APB;
|
||||||
|
uart_ll_set_sclk(UART_LL_GET_HW(uart->num), newClkSrc);
|
||||||
|
#endif
|
||||||
if (uart_set_baudrate(uart->num, baud_rate) == ESP_OK) {
|
if (uart_set_baudrate(uart->num, baud_rate) == ESP_OK) {
|
||||||
log_v("Setting UART%d baud rate to %ld.", uart->num, baud_rate);
|
log_v("Setting UART%d baud rate to %ld.", uart->num, baud_rate);
|
||||||
uart->_baudrate = baud_rate;
|
uart->_baudrate = baud_rate;
|
||||||
|
|
@ -1287,35 +1084,6 @@ bool uartSetMode(uart_t *uart, uart_mode_t mode) {
|
||||||
return retCode;
|
return retCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this function will set the uart clock source
|
|
||||||
// it must be called before uartBegin(), otherwise it won't change any thing.
|
|
||||||
bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc) {
|
|
||||||
if (uartNum >= SOC_UART_NUM) {
|
|
||||||
log_e("UART%d is invalid. This device has %d UARTs, from 0 to %d.", uartNum, SOC_UART_NUM, SOC_UART_NUM - 1);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
uart_t *uart = &_uart_bus_array[uartNum];
|
|
||||||
#if SOC_UART_LP_NUM >= 1
|
|
||||||
if (uart->num >= SOC_UART_HP_NUM) {
|
|
||||||
switch (clkSrc) {
|
|
||||||
case UART_SCLK_XTAL: uart->_uart_clock_source = LP_UART_SCLK_XTAL_D2; break;
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32C5
|
|
||||||
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_RC_FAST; break;
|
|
||||||
#else
|
|
||||||
case UART_SCLK_RTC: uart->_uart_clock_source = LP_UART_SCLK_LP_FAST; break;
|
|
||||||
#endif
|
|
||||||
case UART_SCLK_DEFAULT:
|
|
||||||
default: uart->_uart_clock_source = LP_UART_SCLK_DEFAULT;
|
|
||||||
}
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
uart->_uart_clock_source = clkSrc;
|
|
||||||
}
|
|
||||||
//log_i("UART%d set clock source to %d", uart->num, uart->_uart_clock_source);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void uartSetDebug(uart_t *uart) {
|
void uartSetDebug(uart_t *uart) {
|
||||||
// LP UART is not supported for debug
|
// LP UART is not supported for debug
|
||||||
if (uart == NULL || uart->num >= SOC_UART_HP_NUM) {
|
if (uart == NULL || uart->num >= SOC_UART_HP_NUM) {
|
||||||
|
|
@ -1352,8 +1120,16 @@ int log_printfv(const char *format, va_list arg) {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
#if (ARDUINO_USB_CDC_ON_BOOT == 1 && ARDUINO_USB_MODE == 0) || CONFIG_IDF_TARGET_ESP32C3 \
|
||||||
|
|| ((CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32P4) && ARDUINO_USB_CDC_ON_BOOT == 1)
|
||||||
vsnprintf(temp, len + 1, format, arg);
|
vsnprintf(temp, len + 1, format, arg);
|
||||||
ets_printf("%s", temp);
|
ets_printf("%s", temp);
|
||||||
|
#else
|
||||||
|
int wlen = vsnprintf(temp, len + 1, format, arg);
|
||||||
|
for (int i = 0; i < wlen; i++) {
|
||||||
|
ets_write_char_uart(temp[i]);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
/*
|
/*
|
||||||
// This causes dead locks with logging and also with constructors that may send logs
|
// This causes dead locks with logging and also with constructors that may send logs
|
||||||
#if !CONFIG_DISABLE_HAL_LOCKS
|
#if !CONFIG_DISABLE_HAL_LOCKS
|
||||||
|
|
@ -1541,10 +1317,40 @@ unsigned long uartDetectBaudrate(uart_t *uart) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These functions are for testing purposes only and can be used in Arduino Sketches.
|
These functions are for testing purpose only and can be used in Arduino Sketches
|
||||||
* They are utilized in the UART examples and CI.
|
Those are used in the UART examples
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
This is intended to make an internal loopback connection using IOMUX
|
||||||
|
The function uart_internal_loopback() shall be used right after Arduino Serial.begin(...)
|
||||||
|
This code "replaces" the physical wiring for connecting TX <--> RX in a loopback
|
||||||
|
*/
|
||||||
|
|
||||||
|
// gets the right TX or RX SIGNAL, based on the UART number from gpio_sig_map.h
|
||||||
|
#ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||||
|
#define UART_TX_SIGNAL(uartNumber) \
|
||||||
|
(uartNumber == UART_NUM_0 \
|
||||||
|
? UART0_TXD_PAD_OUT_IDX \
|
||||||
|
: (uartNumber == UART_NUM_1 \
|
||||||
|
? UART1_TXD_PAD_OUT_IDX \
|
||||||
|
: (uartNumber == UART_NUM_2 ? UART2_TXD_PAD_OUT_IDX : (uartNumber == UART_NUM_3 ? UART3_TXD_PAD_OUT_IDX : UART4_TXD_PAD_OUT_IDX))))
|
||||||
|
#define UART_RX_SIGNAL(uartNumber) \
|
||||||
|
(uartNumber == UART_NUM_0 \
|
||||||
|
? UART0_RXD_PAD_IN_IDX \
|
||||||
|
: (uartNumber == UART_NUM_1 \
|
||||||
|
? UART1_RXD_PAD_IN_IDX \
|
||||||
|
: (uartNumber == UART_NUM_2 ? UART2_RXD_PAD_IN_IDX : (uartNumber == UART_NUM_3 ? UART3_RXD_PAD_IN_IDX : UART4_RXD_PAD_IN_IDX))))
|
||||||
|
#else
|
||||||
|
#if SOC_UART_HP_NUM > 2
|
||||||
|
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : (uartNumber == UART_NUM_1 ? U1TXD_OUT_IDX : U2TXD_OUT_IDX))
|
||||||
|
#define UART_RX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : (uartNumber == UART_NUM_1 ? U1RXD_IN_IDX : U2RXD_IN_IDX))
|
||||||
|
#else
|
||||||
|
#define UART_TX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0TXD_OUT_IDX : U1TXD_OUT_IDX)
|
||||||
|
#define UART_RX_SIGNAL(uartNumber) (uartNumber == UART_NUM_0 ? U0RXD_IN_IDX : U1RXD_IN_IDX)
|
||||||
|
#endif
|
||||||
|
#endif // ifdef CONFIG_IDF_TARGET_ESP32P4
|
||||||
|
|
||||||
/*
|
/*
|
||||||
This function internally binds defined UARTs TX signal with defined RX pin of any UART (same or different).
|
This function internally binds defined UARTs TX signal with defined RX pin of any UART (same or different).
|
||||||
This creates a loop that lets us receive anything we send on the UART without external wires.
|
This creates a loop that lets us receive anything we send on the UART without external wires.
|
||||||
|
|
@ -1555,14 +1361,7 @@ void uart_internal_loopback(uint8_t uartNum, int8_t rxPin) {
|
||||||
log_e("UART%d is not supported for loopback or RX pin %d is invalid.", uartNum, rxPin);
|
log_e("UART%d is not supported for loopback or RX pin %d is invalid.", uartNum, rxPin);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#if 0 // leave this code here for future reference and need
|
esp_rom_gpio_connect_out_signal(rxPin, UART_TX_SIGNAL(uartNum), false, false);
|
||||||
// forces rxPin to use GPIO Matrix and setup the pin to receive UART TX Signal - IDF 5.4.1 Change with uart_release_pin()
|
|
||||||
gpio_func_sel((gpio_num_t)rxPin, PIN_FUNC_GPIO);
|
|
||||||
gpio_pullup_en((gpio_num_t)rxPin);
|
|
||||||
gpio_input_enable((gpio_num_t)rxPin);
|
|
||||||
esp_rom_gpio_connect_in_signal(rxPin, uart_periph_signal[uartNum].pins[SOC_UART_RX_PIN_IDX].signal, false);
|
|
||||||
#endif
|
|
||||||
esp_rom_gpio_connect_out_signal(rxPin, uart_periph_signal[uartNum].pins[SOC_UART_TX_PIN_IDX].signal, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -97,19 +97,6 @@ bool uartSetHwFlowCtrlMode(uart_t *uart, uart_hw_flowcontrol_t mode, uint8_t thr
|
||||||
// UART_MODE_RS485_APP_CTRL = 0x04 mode: application control RS485 UART mode (used for test purposes)
|
// UART_MODE_RS485_APP_CTRL = 0x04 mode: application control RS485 UART mode (used for test purposes)
|
||||||
bool uartSetMode(uart_t *uart, uart_mode_t mode);
|
bool uartSetMode(uart_t *uart, uart_mode_t mode);
|
||||||
|
|
||||||
// Used to set the UART clock source mode. It must be set before calling uartBegin(), otherwise it won't have any effect.
|
|
||||||
// Not all clock source are available to every SoC. The compatible option are listed here:
|
|
||||||
// UART_SCLK_DEFAULT :: any SoC - it will set whatever IDF defines as the default UART Clock Source
|
|
||||||
// UART_SCLK_APB :: ESP32, ESP32-S2, ESP32-C3 and ESP32-S3
|
|
||||||
// UART_SCLK_PLL_F80M :: ESP32-C5, ESP32-C6, ESP32-C61 and ESP32-P4
|
|
||||||
// UART_SCLK_PLL_F40M :: ESP32-C2
|
|
||||||
// UART_SCLK_PLL_F48M :: ESP32-H2
|
|
||||||
// UART_SCLK_XTAL :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_SCLK_RTC :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
|
|
||||||
// UART_SCLK_REF_TICK :: ESP32 and ESP32-S2
|
|
||||||
// Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only LP_UART_SCLK_LP_FAST (RTC_FAST) or LP_UART_SCLK_XTAL_D2 (XTAL/2) as Clock Source
|
|
||||||
bool uartSetClockSource(uint8_t uartNum, uart_sclk_t clkSrc);
|
|
||||||
|
|
||||||
void uartStartDetectBaudrate(uart_t *uart);
|
void uartStartDetectBaudrate(uart_t *uart);
|
||||||
unsigned long uartDetectBaudrate(uart_t *uart);
|
unsigned long uartDetectBaudrate(uart_t *uart);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ extern "C" {
|
||||||
/** Major version number (X.x.x) */
|
/** Major version number (X.x.x) */
|
||||||
#define ESP_ARDUINO_VERSION_MAJOR 3
|
#define ESP_ARDUINO_VERSION_MAJOR 3
|
||||||
/** Minor version number (x.X.x) */
|
/** Minor version number (x.X.x) */
|
||||||
#define ESP_ARDUINO_VERSION_MINOR 3
|
#define ESP_ARDUINO_VERSION_MINOR 2
|
||||||
/** Patch version number (x.x.X) */
|
/** Patch version number (x.x.X) */
|
||||||
#define ESP_ARDUINO_VERSION_PATCH 0
|
#define ESP_ARDUINO_VERSION_PATCH 0
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,6 @@
|
||||||
|
|
||||||
from esp_docs.conf_docs import * # noqa: F403,F401
|
from esp_docs.conf_docs import * # noqa: F403,F401
|
||||||
|
|
||||||
# Used for substituting variables in the documentation
|
|
||||||
rst_prolog = """
|
|
||||||
.. |version| replace:: 3.3.0
|
|
||||||
.. |idf_version| replace:: 5.5
|
|
||||||
"""
|
|
||||||
|
|
||||||
languages = ["en"]
|
languages = ["en"]
|
||||||
|
|
||||||
# idf_targets = [
|
# idf_targets = [
|
||||||
|
|
@ -33,7 +27,6 @@ html_static_path = ["../_static"]
|
||||||
extensions += [ # noqa: F405
|
extensions += [ # noqa: F405
|
||||||
"sphinx_copybutton",
|
"sphinx_copybutton",
|
||||||
"sphinx_tabs.tabs",
|
"sphinx_tabs.tabs",
|
||||||
"sphinx_substitution_extensions", # For allowing substitutions inside code blocks
|
|
||||||
"esp_docs.esp_extensions.dummy_build_system",
|
"esp_docs.esp_extensions.dummy_build_system",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -347,147 +347,20 @@ This function will return ``true`` if the peripheral was initialized correctly.
|
||||||
onReceive
|
onReceive
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|
||||||
The ``onReceive`` function is used to define the callback for data received from the master device.
|
The ``onReceive`` function is used to define the callback for the data received from the master.
|
||||||
|
|
||||||
.. code-block:: arduino
|
.. code-block:: arduino
|
||||||
|
|
||||||
void onReceive(const std::function<void(int)>& callback);
|
void onReceive( void (*)(int) );
|
||||||
|
|
||||||
**Function Signature:**
|
|
||||||
|
|
||||||
The callback function must have the signature ``void(int numBytes)`` where ``numBytes`` indicates how many bytes were received from the master.
|
|
||||||
|
|
||||||
**Usage Examples:**
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
// Method 1: Regular function
|
|
||||||
void handleReceive(int numBytes) {
|
|
||||||
Serial.printf("Received %d bytes: ", numBytes);
|
|
||||||
while (Wire.available()) {
|
|
||||||
char c = Wire.read();
|
|
||||||
Serial.print(c);
|
|
||||||
}
|
|
||||||
Serial.println();
|
|
||||||
}
|
|
||||||
Wire.onReceive(handleReceive);
|
|
||||||
|
|
||||||
// Method 2: Lambda function
|
|
||||||
Wire.onReceive([](int numBytes) {
|
|
||||||
Serial.printf("Master sent %d bytes\n", numBytes);
|
|
||||||
while (Wire.available()) {
|
|
||||||
uint8_t data = Wire.read();
|
|
||||||
// Process received data
|
|
||||||
Serial.printf("Data: 0x%02X\n", data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Method 3: Lambda with capture (for accessing variables)
|
|
||||||
int deviceId = 42;
|
|
||||||
Wire.onReceive([deviceId](int numBytes) {
|
|
||||||
Serial.printf("Device %d received %d bytes\n", deviceId, numBytes);
|
|
||||||
// Process data...
|
|
||||||
});
|
|
||||||
|
|
||||||
// Method 4: Using std::function variable
|
|
||||||
std::function<void(int)> receiveHandler = [](int bytes) {
|
|
||||||
Serial.printf("Handling %d received bytes\n", bytes);
|
|
||||||
};
|
|
||||||
Wire.onReceive(receiveHandler);
|
|
||||||
|
|
||||||
// Method 5: Class member function (using lambda wrapper)
|
|
||||||
class I2CDevice {
|
|
||||||
private:
|
|
||||||
int deviceAddress;
|
|
||||||
public:
|
|
||||||
I2CDevice(int addr) : deviceAddress(addr) {}
|
|
||||||
|
|
||||||
void handleReceive(int numBytes) {
|
|
||||||
Serial.printf("Device 0x%02X received %d bytes\n", deviceAddress, numBytes);
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Wire.onReceive([this](int bytes) {
|
|
||||||
this->handleReceive(bytes);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
The ``onReceive`` callback is triggered when the I2C master sends data to this slave device.
|
|
||||||
Use ``Wire.available()`` and ``Wire.read()`` inside the callback to retrieve the received data.
|
|
||||||
|
|
||||||
onRequest
|
onRequest
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
|
|
||||||
The ``onRequest`` function is used to define the callback for responding to master read requests.
|
The ``onRequest`` function is used to define the callback for the data to be send to the master.
|
||||||
|
|
||||||
.. code-block:: arduino
|
.. code-block:: arduino
|
||||||
|
|
||||||
void onRequest(const std::function<void()>& callback);
|
void onRequest( void (*)(void) );
|
||||||
|
|
||||||
**Function Signature:**
|
|
||||||
|
|
||||||
The callback function must have the signature ``void()`` with no parameters. This callback is triggered when the master requests data from this slave device.
|
|
||||||
|
|
||||||
**Usage Examples:**
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
// Method 1: Regular function
|
|
||||||
void handleRequest() {
|
|
||||||
static int counter = 0;
|
|
||||||
Wire.printf("Response #%d", counter++);
|
|
||||||
}
|
|
||||||
Wire.onRequest(handleRequest);
|
|
||||||
|
|
||||||
// Method 2: Lambda function
|
|
||||||
Wire.onRequest([]() {
|
|
||||||
// Send sensor data to master
|
|
||||||
int sensorValue = analogRead(A0);
|
|
||||||
Wire.write(sensorValue >> 8); // High byte
|
|
||||||
Wire.write(sensorValue & 0xFF); // Low byte
|
|
||||||
});
|
|
||||||
|
|
||||||
// Method 3: Lambda with capture (for accessing variables)
|
|
||||||
int deviceStatus = 1;
|
|
||||||
String deviceName = "Sensor1";
|
|
||||||
Wire.onRequest([&deviceStatus, &deviceName]() {
|
|
||||||
Wire.write(deviceStatus);
|
|
||||||
Wire.write(deviceName.c_str(), deviceName.length());
|
|
||||||
});
|
|
||||||
|
|
||||||
// Method 4: Using std::function variable
|
|
||||||
std::function<void()> requestHandler = []() {
|
|
||||||
Wire.write("Hello Master!");
|
|
||||||
};
|
|
||||||
Wire.onRequest(requestHandler);
|
|
||||||
|
|
||||||
// Method 5: Class member function (using lambda wrapper)
|
|
||||||
class TemperatureSensor {
|
|
||||||
private:
|
|
||||||
float temperature;
|
|
||||||
public:
|
|
||||||
void updateTemperature() {
|
|
||||||
temperature = 25.5; // Read from actual sensor
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendTemperature() {
|
|
||||||
// Convert float to bytes and send
|
|
||||||
uint8_t* tempBytes = (uint8_t*)&temperature;
|
|
||||||
Wire.write(tempBytes, sizeof(float));
|
|
||||||
}
|
|
||||||
|
|
||||||
void setup() {
|
|
||||||
Wire.onRequest([this]() {
|
|
||||||
this->sendTemperature();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
The ``onRequest`` callback is triggered when the I2C master requests data from this slave device.
|
|
||||||
Use ``Wire.write()`` inside the callback to send response data back to the master.
|
|
||||||
|
|
||||||
slaveWrite
|
slaveWrite
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,6 @@ Before Contributing
|
||||||
|
|
||||||
Before sending us a Pull Request, please consider this:
|
Before sending us a Pull Request, please consider this:
|
||||||
|
|
||||||
* All contributions must be written in English to ensure effective communication and support.
|
|
||||||
Pull Requests written in other languages will be closed, with a request to rewrite them in English.
|
|
||||||
|
|
||||||
* Is the contribution entirely your own work, or is it already licensed under an LGPL 2.1 compatible Open Source License?
|
* Is the contribution entirely your own work, or is it already licensed under an LGPL 2.1 compatible Open Source License?
|
||||||
If not, cannot accept it.
|
If not, cannot accept it.
|
||||||
|
|
||||||
|
|
@ -222,7 +219,7 @@ Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
If you are contributing to the documentation, please follow the instructions described in the
|
If you are contributing to the documentation, please follow the instructions described in the
|
||||||
`documentation guidelines <guides/docs_contributing.html>`_ to properly format and test your changes.
|
`documentation guidelines <guides/docs_contributing>`_ to properly format and test your changes.
|
||||||
|
|
||||||
Testing and CI
|
Testing and CI
|
||||||
--------------
|
--------------
|
||||||
|
|
@ -435,7 +432,7 @@ Documentation Checks
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
The CI also checks the documentation for any compilation errors. This is important to ensure that the documentation layout is not broken.
|
The CI also checks the documentation for any compilation errors. This is important to ensure that the documentation layout is not broken.
|
||||||
To build the documentation locally, please refer to the `documentation guidelines <guides/docs_contributing.html>`_.
|
To build the documentation locally, please refer to the `documentation guidelines <guides/docs_contributing>`_.
|
||||||
|
|
||||||
Code Style Checks
|
Code Style Checks
|
||||||
^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,9 @@ For a simplified method, see `Installing using Boards Manager <https://docs.espr
|
||||||
If you plan to use these modified settings multiple times, for different projects and targets, you can recompile the Arduino core with the new settings using the Arduino Static Library Builder.
|
If you plan to use these modified settings multiple times, for different projects and targets, you can recompile the Arduino core with the new settings using the Arduino Static Library Builder.
|
||||||
For more information, see the `Lib Builder documentation <lib_builder.html>`_.
|
For more information, see the `Lib Builder documentation <lib_builder.html>`_.
|
||||||
|
|
||||||
.. note:: Latest Arduino Core ESP32 version (|version|) is now compatible with ESP-IDF v\ |idf_version|\ . Please consider this compatibility when using Arduino as a component in ESP-IDF.
|
.. note:: Latest Arduino Core ESP32 version (3.0.X) is now compatible with `ESP-IDF v5.1 <https://github.com/espressif/esp-idf/tree/release/v5.1>`_. Please consider this compatibility when using Arduino as a component in ESP-IDF.
|
||||||
|
|
||||||
For easiest use of Arduino framework as a ESP-IDF component, you can use the `IDF Component Manager <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html>`_ to add the Arduino component to your project.
|
For easiest use of Arduino framework as a ESP-IDF component, you can use the `IDF Component Manager <https://docs.espressif.com/projects/esp-idf/en/v5.1.4/esp32/api-guides/tools/idf-component-manager.html>`_ to add the Arduino component to your project.
|
||||||
This will automatically clone the repository and its submodules. You can find the Arduino component in the `ESP Registry <https://components.espressif.com/components/espressif/arduino-esp32>`_ together with dependencies list and examples.
|
This will automatically clone the repository and its submodules. You can find the Arduino component in the `ESP Registry <https://components.espressif.com/components/espressif/arduino-esp32>`_ together with dependencies list and examples.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
|
|
@ -32,16 +32,14 @@ Installing using IDF Component Manager
|
||||||
To add the Arduino component to your project using the IDF Component Manager, run the following command in your project directory:
|
To add the Arduino component to your project using the IDF Component Manager, run the following command in your project directory:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
idf.py add-dependency "espressif/arduino-esp32^|version|"
|
idf.py add-dependency "espressif/arduino-esp32^3.0.2"
|
||||||
|
|
||||||
Or you can start a new project from a template with the Arduino component:
|
Or you can start a new project from a template with the Arduino component:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
idf.py create-project-from-example "espressif/arduino-esp32^|version|:hello_world"
|
idf.py create-project-from-example "espressif/arduino-esp32^3.0.2:hello_world"
|
||||||
|
|
||||||
Manual installation of Arduino framework
|
Manual installation of Arduino framework
|
||||||
****************************************
|
****************************************
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ Welcome to the compatibility guide for library developers aiming to support mult
|
||||||
Code Adaptations
|
Code Adaptations
|
||||||
----------------
|
----------------
|
||||||
|
|
||||||
To ensure compatibility with both versions of the ESP32 Arduino core, developers should utilize conditional compilation directives in their code. Below is an example of how to conditionally include code based on the ESP32 Arduino core version:
|
To ensure compatibility with both versions of the ESP32 Arduino core, developers should utilize conditional compilation directives in their code. Below is an example of how to conditionally include code based on the ESP32 Arduino core version::
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
|
@ -26,7 +26,7 @@ To ensure compatibility with both versions of the ESP32 Arduino core, developers
|
||||||
Version Print
|
Version Print
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
To easily print the ESP32 Arduino core version at runtime, developers can use the `ESP_ARDUINO_VERSION_STR` macro. Below is an example of how to print the ESP32 Arduino core version:
|
To easily print the ESP32 Arduino core version at runtime, developers can use the `ESP_ARDUINO_VERSION_STR` macro. Below is an example of how to print the ESP32 Arduino core version::
|
||||||
|
|
||||||
.. code-block:: cpp
|
.. code-block:: cpp
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -49,11 +49,11 @@ Before starting your collaboration, you need to get the documentation source cod
|
||||||
Requirements
|
Requirements
|
||||||
************
|
************
|
||||||
|
|
||||||
To build the documentation properly, you need to install some packages in your system. Note that depending on
|
To properly work with the documentation, you need to install some packages in your system.
|
||||||
your system, you may need to use a virtual environment to install the packages.
|
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
|
pip install -U Sphinx
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
||||||
The requirements file is under the ``docs`` folder.
|
The requirements file is under the ``docs`` folder.
|
||||||
|
|
@ -62,14 +62,17 @@ Using Visual Studio Code
|
||||||
************************
|
************************
|
||||||
|
|
||||||
If you are using the Visual Studio Code, you can install some extensions to help you while writing documentation.
|
If you are using the Visual Studio Code, you can install some extensions to help you while writing documentation.
|
||||||
For reStructuredText, you can install the `reStructuredText Pack <https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext-pack>`_ extension.
|
|
||||||
|
|
||||||
We also recommend you to install some grammar check extension to help you to review English grammar.
|
`reStructuredText Pack <https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext-pack>`_
|
||||||
|
|
||||||
|
We also recommend you install to grammar check extension to help you to review English grammar.
|
||||||
|
|
||||||
|
`Grammarly <https://marketplace.visualstudio.com/items?itemName=znck.grammarly>`_
|
||||||
|
|
||||||
Building
|
Building
|
||||||
********
|
********
|
||||||
|
|
||||||
To build the documentation and generate the HTML files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the ``_build/en/generic/html`` folder.
|
To build the documentation and generate the HTML files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the `_build/en/generic/html` folder.
|
||||||
|
|
||||||
.. code-block::
|
.. code-block::
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,6 @@ Welcome to ESP32 Arduino Core's documentation
|
||||||
#############################################
|
#############################################
|
||||||
|
|
||||||
Here you will find all the relevant information about the project.
|
Here you will find all the relevant information about the project.
|
||||||
This documentation is valid for the Arduino Core for ESP32 version |version| based on ESP-IDF |idf_version|.
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
This is a work in progress documentation and we will appreciate your help! We are looking for contributors!
|
This is a work in progress documentation and we will appreciate your help! We are looking for contributors!
|
||||||
|
|
|
||||||
|
|
@ -10,11 +10,6 @@ Before Installing
|
||||||
We recommend you install the support using your favorite IDE, but other options are available depending on your operating system.
|
We recommend you install the support using your favorite IDE, but other options are available depending on your operating system.
|
||||||
To install Arduino-ESP32 support, you can use one of the following options.
|
To install Arduino-ESP32 support, you can use one of the following options.
|
||||||
|
|
||||||
.. note::
|
|
||||||
Users in China might have troubles with connection and download speeds using GitHub. Please use our Jihulab mirror as the repository source:
|
|
||||||
|
|
||||||
``https://jihulab.com/esp-mirror/espressif/arduino-esp32.git``
|
|
||||||
|
|
||||||
Installing using Arduino IDE
|
Installing using Arduino IDE
|
||||||
----------------------------
|
----------------------------
|
||||||
|
|
||||||
|
|
@ -37,16 +32,6 @@ This is the way to install Arduino-ESP32 directly from the Arduino IDE.
|
||||||
https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
|
https://espressif.github.io/arduino-esp32/package_esp32_dev_index.json
|
||||||
|
|
||||||
|
|
||||||
Users in China might have troubles with connection and download speeds using the links above. Please use our Jihulab mirror:
|
|
||||||
|
|
||||||
- Stable release link::
|
|
||||||
|
|
||||||
https://jihulab.com/esp-mirror/espressif/arduino-esp32/-/raw/gh-pages/package_esp32_index_cn.json
|
|
||||||
|
|
||||||
- Development release link::
|
|
||||||
|
|
||||||
https://jihulab.com/esp-mirror/espressif/arduino-esp32/-/raw/gh-pages/package_esp32_dev_index_cn.json
|
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Starting with the Arduino IDE version 1.6.4, Arduino allows installation of third-party platform
|
Starting with the Arduino IDE version 1.6.4, Arduino allows installation of third-party platform
|
||||||
packages using Boards Manager. We have packages available for Windows, macOS, and Linux.
|
packages using Boards Manager. We have packages available for Windows, macOS, and Linux.
|
||||||
|
|
@ -70,8 +55,6 @@ To start the installation process using the Boards Manager, follow these steps:
|
||||||
:figclass: align-center
|
:figclass: align-center
|
||||||
|
|
||||||
- Open Boards Manager from Tools > Board menu and install *esp32* platform (and do not forget to select your ESP32 board from Tools > Board menu after installation).
|
- Open Boards Manager from Tools > Board menu and install *esp32* platform (and do not forget to select your ESP32 board from Tools > Board menu after installation).
|
||||||
Users in China must select the package version with the "-cn" suffix and perform updates manually.
|
|
||||||
Automatic updates are not supported in this region, as they target the default package without the "-cn" suffix, resulting in download failures.
|
|
||||||
|
|
||||||
.. figure:: ../_static/install_guide_boards_manager_esp32.png
|
.. figure:: ../_static/install_guide_boards_manager_esp32.png
|
||||||
:align: center
|
:align: center
|
||||||
|
|
|
||||||
|
|
@ -293,9 +293,8 @@ You have two options to run the Docker image to build the libraries. Manually or
|
||||||
To run the Docker image manually, use the following command from the root of the ``arduino-esp32`` repository:
|
To run the Docker image manually, use the following command from the root of the ``arduino-esp32`` repository:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
docker run --rm -it -v $PWD:/arduino-esp32 -e TERM=xterm-256color espressif/esp32-arduino-lib-builder:release-v|idf_version|
|
docker run --rm -it -v $PWD:/arduino-esp32 -e TERM=xterm-256color espressif/esp32-arduino-lib-builder:release-v5.1
|
||||||
|
|
||||||
This will start the Lib Builder UI for compiling the libraries. The above command explained:
|
This will start the Lib Builder UI for compiling the libraries. The above command explained:
|
||||||
|
|
||||||
|
|
@ -305,7 +304,7 @@ This will start the Lib Builder UI for compiling the libraries. The above comman
|
||||||
- ``-t`` Allocate a pseudo-TTY;
|
- ``-t`` Allocate a pseudo-TTY;
|
||||||
- ``-e TERM=xterm-256color``: Optional. Sets the terminal type to ``xterm-256color`` to display colors correctly;
|
- ``-e TERM=xterm-256color``: Optional. Sets the terminal type to ``xterm-256color`` to display colors correctly;
|
||||||
- ``-v $PWD:/arduino-esp32``: Optional. Mounts the current folder at ``/arduino-esp32`` inside the container. If not provided, the container will not copy the compiled libraries to the host machine;
|
- ``-v $PWD:/arduino-esp32``: Optional. Mounts the current folder at ``/arduino-esp32`` inside the container. If not provided, the container will not copy the compiled libraries to the host machine;
|
||||||
- :substitution-code:`espressif/esp32-arduino-lib-builder:release-v|idf_version|`: uses Docker image ``espressif/esp32-arduino-lib-builder`` with tag :substitution-code:`release-v|idf_version|`.
|
- ``espressif/esp32-arduino-lib-builder:release-v5.1``: uses Docker image ``espressif/esp32-arduino-lib-builder`` with tag ``release-v5.1``.
|
||||||
The ``latest`` tag is implicitly added by Docker when no tag is specified. It is recommended to use a specific version tag to ensure reproducibility of the build process.
|
The ``latest`` tag is implicitly added by Docker when no tag is specified. It is recommended to use a specific version tag to ensure reproducibility of the build process.
|
||||||
|
|
||||||
.. warning::
|
.. warning::
|
||||||
|
|
@ -325,27 +324,24 @@ By default the docker container will run the user interface script. If you want
|
||||||
For example, to run a terminal inside the container, you can run:
|
For example, to run a terminal inside the container, you can run:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
docker run -it espressif/esp32-arduino-lib-builder:release-v|idf_version| /bin/bash
|
docker run -it espressif/esp32-arduino-lib-builder:release-v5.1 /bin/bash
|
||||||
|
|
||||||
Running the Docker image using the provided run script will depend on the host OS.
|
Running the Docker image using the provided run script will depend on the host OS.
|
||||||
Use the following command from the root of the ``arduino-esp32`` repository to execute the image in a Linux or macOS environment for
|
Use the following command from the root of the ``arduino-esp32`` repository to execute the image in a Linux or macOS environment for
|
||||||
the :substitution-code:`release-v|idf_version|` tag:
|
the ``release-v5.1`` tag:
|
||||||
|
|
||||||
.. code-block:: bash
|
.. code-block:: bash
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
curl -LJO https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v|idf_version|/tools/docker/run.sh
|
curl -LJO https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v5.1/tools/docker/run.sh
|
||||||
chmod +x run.sh
|
chmod +x run.sh
|
||||||
./run.sh $PWD
|
./run.sh $PWD
|
||||||
|
|
||||||
For Windows, use the following command in PowerShell from the root of the ``arduino-esp32`` repository:
|
For Windows, use the following command in PowerShell from the root of the ``arduino-esp32`` repository:
|
||||||
|
|
||||||
.. code-block:: powershell
|
.. code-block:: powershell
|
||||||
:substitutions:
|
|
||||||
|
|
||||||
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v|idf_version|/tools/docker/run.ps1" -OutFile "run.ps1"
|
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v5.1/tools/docker/run.ps1" -OutFile "run.ps1"
|
||||||
.\run.ps1 $pwd
|
.\run.ps1 $pwd
|
||||||
|
|
||||||
As the script is unsigned, you may need to change the execution policy of the current session before running the script.
|
As the script is unsigned, you may need to change the execution policy of the current session before running the script.
|
||||||
|
|
|
||||||
|
|
@ -91,15 +91,3 @@ The Arduino ESP32 offers some unique APIs, described in this section:
|
||||||
:glob:
|
:glob:
|
||||||
|
|
||||||
api/*
|
api/*
|
||||||
|
|
||||||
Zigbee APIs
|
|
||||||
-----------
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
:glob:
|
|
||||||
|
|
||||||
zigbee/zigbee
|
|
||||||
zigbee/zigbee_core
|
|
||||||
zigbee/zigbee_ep
|
|
||||||
zigbee/ep_*
|
|
||||||
|
|
|
||||||
|
|
@ -14,23 +14,6 @@ Installing
|
||||||
|
|
||||||
Here are the common issues during the installation.
|
Here are the common issues during the installation.
|
||||||
|
|
||||||
Slow or unstable downloads
|
|
||||||
**************************
|
|
||||||
|
|
||||||
Users in China might have troubles with connection and download speeds using GitHub. Please use our Jihulab mirror as the repository source:
|
|
||||||
|
|
||||||
`https://jihulab.com/esp-mirror/espressif/arduino-esp32.git <https://jihulab.com/esp-mirror/espressif/arduino-esp32.git>`_
|
|
||||||
|
|
||||||
JSON files for the boards manager are available here:
|
|
||||||
|
|
||||||
- Stable release::
|
|
||||||
|
|
||||||
https://jihulab.com/esp-mirror/espressif/arduino-esp32/-/raw/gh-pages/package_esp32_index_cn.json
|
|
||||||
|
|
||||||
- Development release::
|
|
||||||
|
|
||||||
https://jihulab.com/esp-mirror/espressif/arduino-esp32/-/raw/gh-pages/package_esp32_dev_index_cn.json
|
|
||||||
|
|
||||||
Building
|
Building
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,280 +0,0 @@
|
||||||
############
|
|
||||||
ZigbeeAnalog
|
|
||||||
############
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeAnalog`` class provides analog input and output endpoints for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for analog signal processing and control.
|
|
||||||
Analog Input (AI) is meant to be used for sensors that provide an analog signal, such as temperature, humidity, pressure to be sent to the coordinator.
|
|
||||||
Analog Output (AO) is meant to be used for actuators that require an analog signal, such as dimmers, valves, etc. to be controlled by the coordinator.
|
|
||||||
|
|
||||||
|
|
||||||
Common API
|
|
||||||
----------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeAnalog
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee analog endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeAnalog(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Cluster Management
|
|
||||||
******************
|
|
||||||
|
|
||||||
addAnalogInput
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds analog input cluster to the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addAnalogInput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
addAnalogOutput
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds analog output cluster to the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addAnalogOutput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Analog Input API
|
|
||||||
----------------
|
|
||||||
|
|
||||||
Configuration Methods
|
|
||||||
*********************
|
|
||||||
|
|
||||||
setAnalogInputApplication
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the application type for the analog input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInputApplication(uint32_t application_type);
|
|
||||||
|
|
||||||
* ``application_type`` - Application type constant (see esp_zigbee_zcl_analog_input.h for values)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogInputDescription
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a custom description for the analog input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInputDescription(const char *description);
|
|
||||||
|
|
||||||
* ``description`` - Description string
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogInputResolution
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the resolution for the analog input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInputResolution(float resolution);
|
|
||||||
|
|
||||||
* ``resolution`` - Resolution value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogInputMinMax
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum values for the analog input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInputMinMax(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum value
|
|
||||||
* ``max`` - Maximum value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Value Control
|
|
||||||
*************
|
|
||||||
|
|
||||||
setAnalogInput
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the analog input value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInput(float analog);
|
|
||||||
|
|
||||||
* ``analog`` - Analog input value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Reporting Methods
|
|
||||||
*****************
|
|
||||||
|
|
||||||
setAnalogInputReporting
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for analog input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogInputReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in value to trigger a report
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportAnalogInput
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current analog input value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportAnalogInput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Analog Output API
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Configuration Methods
|
|
||||||
*********************
|
|
||||||
|
|
||||||
setAnalogOutputApplication
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the application type for the analog output.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogOutputApplication(uint32_t application_type);
|
|
||||||
|
|
||||||
* ``application_type`` - Application type constant (see esp_zigbee_zcl_analog_output.h for values)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogOutputDescription
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a custom description for the analog output.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogOutputDescription(const char *description);
|
|
||||||
|
|
||||||
* ``description`` - Description string
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogOutputResolution
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the resolution for the analog output.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogOutputResolution(float resolution);
|
|
||||||
|
|
||||||
* ``resolution`` - Resolution value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setAnalogOutputMinMax
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum values for the analog output.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogOutputMinMax(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum value
|
|
||||||
* ``max`` - Maximum value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Value Control
|
|
||||||
*************
|
|
||||||
|
|
||||||
setAnalogOutput
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the analog output value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setAnalogOutput(float analog);
|
|
||||||
|
|
||||||
* ``analog`` - Analog output value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
getAnalogOutput
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current analog output value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
float getAnalogOutput();
|
|
||||||
|
|
||||||
This function will return current analog output value.
|
|
||||||
|
|
||||||
Reporting Methods
|
|
||||||
*****************
|
|
||||||
|
|
||||||
reportAnalogOutput
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current analog output value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportAnalogOutput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onAnalogOutputChange
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the analog output value changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onAnalogOutputChange(void (*callback)(float analog));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when analog output changes
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Analog Input/Output
|
|
||||||
*******************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Analog_Input_Output/Zigbee_Analog_Input_Output.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,137 +0,0 @@
|
||||||
############
|
|
||||||
ZigbeeBinary
|
|
||||||
############
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeBinary`` class provides an endpoint for binary input/output sensors in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for binary sensors, supporting various application types for HVAC, security, and general binary sensing.
|
|
||||||
Binary Input (BI) is meant to be used for sensors that provide a binary signal, such as door/window sensors, motion detectors, etc. to be sent to the network.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Binary Output (BO) is not supported yet.
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeBinary
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee binary sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeBinary(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Binary Input Application Types
|
|
||||||
******************************
|
|
||||||
|
|
||||||
HVAC Application Types
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_BOILER_STATUS 0x00000003
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_CHILLER_STATUS 0x00000013
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_OCCUPANCY 0x00000031
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_FAN_STATUS 0x00000035
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_FILTER_STATUS 0x00000036
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_HEATING_ALARM 0x0000003E
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_COOLING_ALARM 0x0000001D
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_UNIT_ENABLE 0x00000090
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_HVAC_OTHER 0x0000FFFF
|
|
||||||
|
|
||||||
Security Application Types
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_GLASS_BREAKAGE_DETECTION_0 0x01000000
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_INTRUSION_DETECTION 0x01000001
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_MOTION_DETECTION 0x01000002
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_GLASS_BREAKAGE_DETECTION_1 0x01000003
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_ZONE_ARMED 0x01000004
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_GLASS_BREAKAGE_DETECTION_2 0x01000005
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_SMOKE_DETECTION 0x01000006
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_CARBON_DIOXIDE_DETECTION 0x01000007
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_HEAT_DETECTION 0x01000008
|
|
||||||
#define BINARY_INPUT_APPLICATION_TYPE_SECURITY_OTHER 0x0100FFFF
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
addBinaryInput
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds a binary input cluster to the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addBinaryInput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setBinaryInputApplication
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the application type for the binary input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setBinaryInputApplication(uint32_t application_type);
|
|
||||||
|
|
||||||
* ``application_type`` - Application type constant (see above)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setBinaryInputDescription
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a custom description for the binary input.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setBinaryInputDescription(const char *description);
|
|
||||||
|
|
||||||
* ``description`` - Description string
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setBinaryInput
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the binary input value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setBinaryInput(bool input);
|
|
||||||
|
|
||||||
* ``input`` - Binary value (true/false)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportBinaryInput
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current binary input value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportBinaryInput();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Binary Input Implementation
|
|
||||||
****************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Binary_Input/Zigbee_Binary_Input.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,105 +0,0 @@
|
||||||
#########################
|
|
||||||
ZigbeeCarbonDioxideSensor
|
|
||||||
#########################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeCarbonDioxideSensor`` class provides a CO2 sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for carbon dioxide measurement devices.
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeCarbonDioxideSensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee CO2 sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeCarbonDioxideSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setCarbonDioxide
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the CO2 concentration measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setCarbonDioxide(float carbon_dioxide);
|
|
||||||
|
|
||||||
* ``carbon_dioxide`` - CO2 concentration value in ppm
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum CO2 concentration value in ppm
|
|
||||||
* ``max`` - Maximum CO2 concentration value in ppm
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(float tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in ppm
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for CO2 measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, uint16_t delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in ppm
|
|
||||||
|
|
||||||
**Note:** Delta reporting is currently not supported by the carbon dioxide sensor.
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current CO2 concentration value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
CO2 Sensor Implementation
|
|
||||||
*************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_CarbonDioxide_Sensor/Zigbee_CarbonDioxide_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,223 +0,0 @@
|
||||||
########################
|
|
||||||
ZigbeeColorDimmableLight
|
|
||||||
########################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeColorDimmableLight`` class provides an endpoint for color dimmable lights in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for color lighting devices, supporting RGB color control, dimming, and scene management.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* On/off control
|
|
||||||
* Brightness level control (0-100%)
|
|
||||||
* RGB color control
|
|
||||||
* HSV color support
|
|
||||||
* Scene and group support
|
|
||||||
* Automatic state restoration
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Smart RGB light bulbs
|
|
||||||
* Color-changing LED strips
|
|
||||||
* Mood lighting systems
|
|
||||||
* Entertainment lighting
|
|
||||||
* Architectural lighting
|
|
||||||
* Smart home color lighting
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeColorDimmableLight
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee color dimmable light endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeColorDimmableLight(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Callback Functions
|
|
||||||
******************
|
|
||||||
|
|
||||||
onLightChange
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the callback function for light state changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onLightChange(void (*callback)(bool, uint8_t, uint8_t, uint8_t, uint8_t));
|
|
||||||
|
|
||||||
* ``callback`` - Function pointer to the light change callback (state, red, green, blue, level)
|
|
||||||
|
|
||||||
Control Methods
|
|
||||||
***************
|
|
||||||
|
|
||||||
setLightState
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the light on/off state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightState(bool state);
|
|
||||||
|
|
||||||
* ``state`` - Light state (true = on, false = off)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLightLevel
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the light brightness level.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightLevel(uint8_t level);
|
|
||||||
|
|
||||||
* ``level`` - Brightness level (0-100, where 0 is off, 100 is full brightness)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLightColor (RGB)
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the light color using RGB values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightColor(uint8_t red, uint8_t green, uint8_t blue);
|
|
||||||
bool setLightColor(espRgbColor_t rgb_color);
|
|
||||||
|
|
||||||
* ``red`` - Red component (0-255)
|
|
||||||
* ``green`` - Green component (0-255)
|
|
||||||
* ``blue`` - Blue component (0-255)
|
|
||||||
* ``rgb_color`` - RGB color structure
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLightColor (HSV)
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the light color using HSV values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightColor(espHsvColor_t hsv_color);
|
|
||||||
|
|
||||||
* ``hsv_color`` - HSV color structure
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLight
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Sets all light parameters at once.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLight(bool state, uint8_t level, uint8_t red, uint8_t green, uint8_t blue);
|
|
||||||
|
|
||||||
* ``state`` - Light state (true/false)
|
|
||||||
* ``level`` - Brightness level (0-100)
|
|
||||||
* ``red`` - Red component (0-255)
|
|
||||||
* ``green`` - Green component (0-255)
|
|
||||||
* ``blue`` - Blue component (0-255)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
State Retrieval Methods
|
|
||||||
***********************
|
|
||||||
|
|
||||||
getLightState
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current light state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getLightState();
|
|
||||||
|
|
||||||
This function will return current light state (true = on, false = off).
|
|
||||||
|
|
||||||
getLightLevel
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current brightness level.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getLightLevel();
|
|
||||||
|
|
||||||
This function will return current brightness level (0-100).
|
|
||||||
|
|
||||||
getLightColor
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current RGB color.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
espRgbColor_t getLightColor();
|
|
||||||
|
|
||||||
This function will return current RGB color structure.
|
|
||||||
|
|
||||||
getLightRed
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current red component.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getLightRed();
|
|
||||||
|
|
||||||
This function will return current red component (0-255).
|
|
||||||
|
|
||||||
getLightGreen
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current green component.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getLightGreen();
|
|
||||||
|
|
||||||
This function will return current green component (0-255).
|
|
||||||
|
|
||||||
getLightBlue
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current blue component.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getLightBlue();
|
|
||||||
|
|
||||||
This function will return current blue component (0-255).
|
|
||||||
|
|
||||||
Utility Methods
|
|
||||||
***************
|
|
||||||
|
|
||||||
restoreLight
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Restores the light to its last known state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void restoreLight();
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Color Dimmable Light Implementation
|
|
||||||
***********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Color_Dimmable_Light/Zigbee_Color_Dimmable_Light.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,186 +0,0 @@
|
||||||
#######################
|
|
||||||
ZigbeeColorDimmerSwitch
|
|
||||||
#######################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeColorDimmerSwitch`` class provides a color dimmer switch endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for advanced lighting control switches that can control both dimming and color of lights.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* On/off control for bound lights
|
|
||||||
* Brightness level control (0-100%)
|
|
||||||
* Color control (RGB, HSV)
|
|
||||||
* Color temperature control
|
|
||||||
* Scene and group support
|
|
||||||
* Special effects and timed operations
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Smart lighting switches
|
|
||||||
* Color control remotes
|
|
||||||
* Advanced lighting controllers
|
|
||||||
* Smart home lighting automation
|
|
||||||
* Entertainment lighting control
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeColorDimmerSwitch
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee color dimmer switch endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeColorDimmerSwitch(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Basic Control Commands
|
|
||||||
**********************
|
|
||||||
|
|
||||||
lightToggle
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Toggles the state of bound lights (on to off, or off to on).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightToggle();
|
|
||||||
void lightToggle(uint16_t group_addr);
|
|
||||||
void lightToggle(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
lightOn
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Turns on bound lights.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOn();
|
|
||||||
void lightOn(uint16_t group_addr);
|
|
||||||
void lightOn(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
lightOff
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Turns off bound lights.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOff();
|
|
||||||
void lightOff(uint16_t group_addr);
|
|
||||||
void lightOff(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
Dimmer Control Commands
|
|
||||||
***********************
|
|
||||||
|
|
||||||
setLightLevel
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the brightness level of bound lights.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setLightLevel(uint8_t level);
|
|
||||||
void setLightLevel(uint8_t level, uint16_t group_addr);
|
|
||||||
void setLightLevel(uint8_t level, uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void setLightLevel(uint8_t level, uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``level`` - Brightness level (0-100, where 0 is off, 100 is full brightness)
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
Color Control Commands
|
|
||||||
**********************
|
|
||||||
|
|
||||||
setLightColor
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the color of bound lights using RGB values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setLightColor(uint8_t red, uint8_t green, uint8_t blue);
|
|
||||||
void setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint16_t group_addr);
|
|
||||||
void setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void setLightColor(uint8_t red, uint8_t green, uint8_t blue, uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``red`` - Red component (0-255)
|
|
||||||
* ``green`` - Green component (0-255)
|
|
||||||
* ``blue`` - Blue component (0-255)
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
Advanced Control Commands
|
|
||||||
*************************
|
|
||||||
|
|
||||||
lightOffWithEffect
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns off lights with a specific effect.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOffWithEffect(uint8_t effect_id, uint8_t effect_variant);
|
|
||||||
|
|
||||||
* ``effect_id`` - Effect identifier
|
|
||||||
* ``effect_variant`` - Effect variant
|
|
||||||
|
|
||||||
lightOnWithTimedOff
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns on lights with automatic turn-off after specified time.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOnWithTimedOff(uint8_t on_off_control, uint16_t time_on, uint16_t time_off);
|
|
||||||
|
|
||||||
* ``on_off_control`` - Control byte
|
|
||||||
* ``time_on`` - Time to stay on (in 1/10th seconds)
|
|
||||||
* ``time_off`` - Time to stay off (in 1/10th seconds)
|
|
||||||
|
|
||||||
lightOnWithSceneRecall
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns on lights with scene recall.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOnWithSceneRecall();
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Color Dimmer Switch Implementation
|
|
||||||
**********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Color_Dimmer_Switch/Zigbee_Color_Dimmer_Switch.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
###################
|
|
||||||
ZigbeeContactSwitch
|
|
||||||
###################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeContactSwitch`` class provides a contact switch endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for door/window contact sensors and other binary contact devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Contact state detection (open/closed)
|
|
||||||
* Configurable application types
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Door and window sensors
|
|
||||||
* Security system contacts
|
|
||||||
* Cabinet and drawer sensors
|
|
||||||
* Industrial contact monitoring
|
|
||||||
* Smart home security applications
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeContactSwitch
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee contact switch endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeContactSwitch(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setClosed
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the contact switch to closed state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setClosed();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setOpen
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the contact switch to open state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setOpen();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setIASClientEndpoint
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the IAS Client endpoint number (default is 1).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setIASClientEndpoint(uint8_t ep_number);
|
|
||||||
|
|
||||||
* ``ep_number`` - IAS Client endpoint number
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current contact state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Contact Switch Implementation
|
|
||||||
*****************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Contact_Switch/Zigbee_Contact_Switch.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,138 +0,0 @@
|
||||||
###################
|
|
||||||
ZigbeeDimmableLight
|
|
||||||
###################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeDimmableLight`` class provides a dimmable light endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for dimmable lighting control with both on/off and brightness level control.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* On/off control
|
|
||||||
* Brightness level control (0-100%)
|
|
||||||
* State and level change callbacks
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Dimmable smart bulbs
|
|
||||||
* LED strips with brightness control
|
|
||||||
* Any device requiring both on/off and dimming functionality
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeDimmableLight
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee dimmable light endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeDimmableLight(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Light Control
|
|
||||||
*************
|
|
||||||
|
|
||||||
setLightState
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets only the light state (on or off) without changing the brightness level.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightState(bool state);
|
|
||||||
|
|
||||||
* ``state`` - ``true`` to turn on, ``false`` to turn off
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLightLevel
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets only the brightness level (0-100) without changing the on/off state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLightLevel(uint8_t level);
|
|
||||||
|
|
||||||
* ``level`` - Brightness level (0-100, where 0 is off, 100 is full brightness)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLight
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Sets both the light state and brightness level simultaneously.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLight(bool state, uint8_t level);
|
|
||||||
|
|
||||||
* ``state`` - ``true`` to turn on, ``false`` to turn off
|
|
||||||
* ``level`` - Brightness level (0-100)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
getLightState
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current light state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getLightState();
|
|
||||||
|
|
||||||
This function will return current light state (``true`` = on, ``false`` = off).
|
|
||||||
|
|
||||||
getLightLevel
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current brightness level.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getLightLevel();
|
|
||||||
|
|
||||||
This function will return current brightness level (0-100).
|
|
||||||
|
|
||||||
restoreLight
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Restores the light state and triggers any registered callbacks.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void restoreLight();
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onLightChange
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the light state or level changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onLightChange(void (*callback)(bool, uint8_t));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when light state or level changes
|
|
||||||
|
|
||||||
**Callback Parameters:**
|
|
||||||
* ``bool state`` - New light state (true = on, false = off)
|
|
||||||
* ``uint8_t level`` - New brightness level (0-100)
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Dimmable Light Implementation
|
|
||||||
*****************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Dimmable_Light/Zigbee_Dimmable_Light.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,95 +0,0 @@
|
||||||
######################
|
|
||||||
ZigbeeDoorWindowHandle
|
|
||||||
######################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeDoorWindowHandle`` class provides a door/window handle endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for handle position sensors and other handle-related devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Handle position detection
|
|
||||||
* Multiple position states support
|
|
||||||
* Configurable application types
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeDoorWindowHandle
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee door/window handle endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeDoorWindowHandle(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setClosed
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the door/window handle to closed position.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setClosed();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setOpen
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the door/window handle to open position.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setOpen();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTilted
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the door/window handle to tilted position.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTilted();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setIASClientEndpoint
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the IAS Client endpoint number (default is 1).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setIASClientEndpoint(uint8_t ep_number);
|
|
||||||
|
|
||||||
* ``ep_number`` - IAS Client endpoint number
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current handle position.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
*To be added*
|
|
||||||
|
|
@ -1,254 +0,0 @@
|
||||||
###########################
|
|
||||||
ZigbeeElectricalMeasurement
|
|
||||||
###########################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeElectricalMeasurement`` class provides an endpoint for electrical measurement devices in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for power monitoring and electrical measurement.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* AC and DC electrical measurements
|
|
||||||
* Voltage, current, and power monitoring
|
|
||||||
* Power factor measurement
|
|
||||||
* Multi-phase support
|
|
||||||
* Configurable measurement ranges
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Smart power monitoring
|
|
||||||
* Energy monitoring systems
|
|
||||||
* Solar panel monitoring
|
|
||||||
* Battery monitoring systems
|
|
||||||
* Electrical load monitoring
|
|
||||||
|
|
||||||
Common API
|
|
||||||
----------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeElectricalMeasurement
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee electrical measurement endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeElectricalMeasurement(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
DC Electrical Measurement
|
|
||||||
*************************
|
|
||||||
|
|
||||||
addDCMeasurement
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds a DC measurement type to the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addDCMeasurement(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setDCMeasurement
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the DC measurement value for a specific measurement type.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setDCMeasurement(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type, int16_t value);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
* ``value`` - Measurement value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setDCMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum values for a DC measurement type.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setDCMinMaxValue(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type, int16_t min, int16_t max);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
* ``min`` - Minimum value
|
|
||||||
* ``max`` - Maximum value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setDCMultiplierDivisor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the multiplier and divisor for scaling DC measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setDCMultiplierDivisor(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type, uint16_t multiplier, uint16_t divisor);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
* ``multiplier`` - Multiplier value
|
|
||||||
* ``divisor`` - Divisor value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setDCReporting
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for DC measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setDCReporting(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type, uint16_t min_interval, uint16_t max_interval, int16_t delta);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportDC
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports a DC measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportDC(ZIGBEE_DC_MEASUREMENT_TYPE measurement_type);
|
|
||||||
|
|
||||||
* ``measurement_type`` - DC measurement type constant (ZIGBEE_DC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_DC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_DC_MEASUREMENT_TYPE_POWER)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
AC Electrical Measurement
|
|
||||||
*************************
|
|
||||||
|
|
||||||
addACMeasurement
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds an AC measurement type for a specific phase.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addACMeasurement(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, ZIGBEE_AC_PHASE_TYPE phase_type);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setACMeasurement
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the AC measurement value for a specific measurement type and phase.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setACMeasurement(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, ZIGBEE_AC_PHASE_TYPE phase_type, int32_t value);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
* ``value`` - Measurement value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setACMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum values for an AC measurement type and phase.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setACMinMaxValue(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, ZIGBEE_AC_PHASE_TYPE phase_type, int32_t min, int32_t max);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
* ``min`` - Minimum value
|
|
||||||
* ``max`` - Maximum value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setACMultiplierDivisor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the multiplier and divisor for scaling AC measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setACMultiplierDivisor(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, uint16_t multiplier, uint16_t divisor);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``multiplier`` - Multiplier value
|
|
||||||
* ``divisor`` - Divisor value
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setACPowerFactor
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the power factor for a specific phase.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setACPowerFactor(ZIGBEE_AC_PHASE_TYPE phase_type, int8_t power_factor);
|
|
||||||
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
* ``power_factor`` - Power factor value (-100 to 100)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setACReporting
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for AC measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setACReporting(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, ZIGBEE_AC_PHASE_TYPE phase_type, uint16_t min_interval, uint16_t max_interval, int32_t delta);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportAC
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports an AC measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportAC(ZIGBEE_AC_MEASUREMENT_TYPE measurement_type, ZIGBEE_AC_PHASE_TYPE phase_type);
|
|
||||||
|
|
||||||
* ``measurement_type`` - AC measurement type constant (ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_MEASUREMENT_TYPE_POWER_FACTOR, ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY)
|
|
||||||
* ``phase_type`` - Phase type constant (ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, ZIGBEE_AC_PHASE_TYPE_A, ZIGBEE_AC_PHASE_TYPE_B, ZIGBEE_AC_PHASE_TYPE_C)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
DC Electrical Measurement
|
|
||||||
*************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Electrical_DC_Sensor/Zigbee_Electrical_DC_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
||||||
AC Electrical Measurement
|
|
||||||
*************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor_MultiPhase/Zigbee_Electrical_AC_Sensor_MultiPhase.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
||||||
################
|
|
||||||
ZigbeeFanControl
|
|
||||||
################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeFanControl`` class provides a Zigbee endpoint for controlling fan devices in a Home Automation (HA) network. This endpoint implements the Fan Control cluster and allows for controlling fan modes and sequences.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Fan mode control (OFF, LOW, MEDIUM, HIGH, ON, AUTO, SMART)
|
|
||||||
* Fan mode sequence configuration
|
|
||||||
* State change callbacks
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Smart ceiling fans
|
|
||||||
* HVAC system fans
|
|
||||||
* Exhaust fans
|
|
||||||
* Any device requiring fan speed control
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeFanControl
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee fan control endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeFanControl(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Fan Mode Enums
|
|
||||||
**************
|
|
||||||
|
|
||||||
ZigbeeFanMode
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Available fan modes for controlling the fan speed and operation.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
enum ZigbeeFanMode {
|
|
||||||
FAN_MODE_OFF, // Fan is off
|
|
||||||
FAN_MODE_LOW, // Low speed
|
|
||||||
FAN_MODE_MEDIUM, // Medium speed
|
|
||||||
FAN_MODE_HIGH, // High speed
|
|
||||||
FAN_MODE_ON, // Fan is on (full speed)
|
|
||||||
FAN_MODE_AUTO, // Automatic mode
|
|
||||||
FAN_MODE_SMART, // Smart mode
|
|
||||||
};
|
|
||||||
|
|
||||||
ZigbeeFanModeSequence
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Available fan mode sequences that define which modes are available for the fan.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
enum ZigbeeFanModeSequence {
|
|
||||||
FAN_MODE_SEQUENCE_LOW_MED_HIGH, // Low -> Medium -> High
|
|
||||||
FAN_MODE_SEQUENCE_LOW_HIGH, // Low -> High
|
|
||||||
FAN_MODE_SEQUENCE_LOW_MED_HIGH_AUTO, // Low -> Medium -> High -> Auto
|
|
||||||
FAN_MODE_SEQUENCE_LOW_HIGH_AUTO, // Low -> High -> Auto
|
|
||||||
FAN_MODE_SEQUENCE_ON_AUTO, // On -> Auto
|
|
||||||
};
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setFanModeSequence
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the fan mode sequence and initializes the fan control.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setFanModeSequence(ZigbeeFanModeSequence sequence);
|
|
||||||
|
|
||||||
* ``sequence`` - The fan mode sequence to set
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
getFanMode
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current fan mode.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeFanMode getFanMode();
|
|
||||||
|
|
||||||
This function will return current fan mode.
|
|
||||||
|
|
||||||
getFanModeSequence
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current fan mode sequence.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeFanModeSequence getFanModeSequence();
|
|
||||||
|
|
||||||
This function will return current fan mode sequence.
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onFanModeChange
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the fan mode changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onFanModeChange(void (*callback)(ZigbeeFanMode mode));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when fan mode changes
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Fan Control Implementation
|
|
||||||
**************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Fan_Control/Zigbee_Fan_Control.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
################
|
|
||||||
ZigbeeFlowSensor
|
|
||||||
################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeFlowSensor`` class provides a flow sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for liquid and gas flow measurement devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Flow rate measurement in m³/h
|
|
||||||
* Configurable measurement range
|
|
||||||
* Tolerance and reporting configuration
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Water flow monitoring
|
|
||||||
* Gas flow measurement
|
|
||||||
* Industrial process monitoring
|
|
||||||
* Smart home water management
|
|
||||||
* HVAC system flow monitoring
|
|
||||||
* Agricultural irrigation systems
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeFlowSensor
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee flow sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeFlowSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setFlow
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the flow rate measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setFlow(float value);
|
|
||||||
|
|
||||||
* ``value`` - Flow rate value in 0.1 m³/h
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum flow rate value in 0.1 m³/h
|
|
||||||
* ``max`` - Maximum flow rate value in 0.1 m³/h
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(float tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in 0.01 m³/h
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for flow rate measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in 0.1 m³/h
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current flow rate value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Flow + PressureSensor Implementation
|
|
||||||
************************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/Zigbee_Pressure_Flow_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,35 +0,0 @@
|
||||||
#############
|
|
||||||
ZigbeeGateway
|
|
||||||
#############
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeGateway`` class provides a gateway endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for network coordination and gateway functionality.
|
|
||||||
Gateway is a device that can be used to bridge Zigbee network to other networks (e.g. Wi-Fi, Ethernet, etc.).
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeGateway
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee gateway endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeGateway(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Gateway Implementation
|
|
||||||
**********************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Gateway/Zigbee_Gateway.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
#######################
|
|
||||||
ZigbeeIlluminanceSensor
|
|
||||||
#######################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeIlluminanceSensor`` class provides an endpoint for illuminance sensors in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for light level measurement devices, supporting ambient light monitoring.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Illuminance measurement in lux
|
|
||||||
* Configurable measurement range
|
|
||||||
* Tolerance and reporting configuration
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeIlluminanceSensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee illuminance sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeIlluminanceSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setIlluminance
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the illuminance measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setIlluminance(uint16_t value);
|
|
||||||
|
|
||||||
* ``value`` - Illuminance value in lux
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(uint16_t min, uint16_t max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum illuminance value in lux
|
|
||||||
* ``max`` - Maximum illuminance value in lux
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(uint16_t tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in lux
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for illuminance measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, uint16_t delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in lux
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current illuminance value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Illuminance Sensor Implementation
|
|
||||||
*********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Illuminance_Sensor/Zigbee_Illuminance_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
###########
|
|
||||||
ZigbeeLight
|
|
||||||
###########
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeLight`` class provides a simple on/off light endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for basic lighting control.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Simple on/off control
|
|
||||||
* State change callbacks
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeLight
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee light endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeLight(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Light Control
|
|
||||||
*************
|
|
||||||
|
|
||||||
setLight
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Sets the light state (on or off).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLight(bool state);
|
|
||||||
|
|
||||||
* ``state`` - ``true`` to turn on, ``false`` to turn off
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
getLightState
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current light state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getLightState();
|
|
||||||
|
|
||||||
This function will return current light state (``true`` = on, ``false`` = off).
|
|
||||||
|
|
||||||
restoreLight
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Restores the light state and triggers any registered callbacks.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void restoreLight();
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onLightChange
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the light state changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onLightChange(void (*callback)(bool));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when light state changes
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Basic Light Implementation
|
|
||||||
**************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_On_Off_Light/Zigbee_On_Off_Light.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,81 +0,0 @@
|
||||||
#####################
|
|
||||||
ZigbeeOccupancySensor
|
|
||||||
#####################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeOccupancySensor`` class provides an endpoint for occupancy sensors in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for occupancy detection devices, supporting various sensor types for detecting presence.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Occupancy detection (occupied/unoccupied)
|
|
||||||
* Multiple sensor type support (PIR, ultrasonic, etc.)
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeOccupancySensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee occupancy sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeOccupancySensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setOccupancy
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the occupancy state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setOccupancy(bool occupied);
|
|
||||||
|
|
||||||
* ``occupied`` - Occupancy state (true = occupied, false = unoccupied)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setSensorType
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the sensor type.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setSensorType(uint8_t sensor_type);
|
|
||||||
|
|
||||||
* ``sensor_type`` - Sensor type identifier (see esp_zb_zcl_occupancy_sensing_occupancy_sensor_type_t)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current occupancy state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Occupancy Sensor Implementation
|
|
||||||
*******************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Occupancy_Sensor/Zigbee_Occupancy_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
################
|
|
||||||
ZigbeePM25Sensor
|
|
||||||
################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeePM25Sensor`` class provides a PM2.5 air quality sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for particulate matter measurement devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* PM2.5 concentration measurement in μg/m³
|
|
||||||
* Configurable measurement range
|
|
||||||
* Tolerance and reporting configuration
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeePM25Sensor
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee PM2.5 sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeePM25Sensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setPM25
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the PM2.5 concentration measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setPM25(float pm25);
|
|
||||||
|
|
||||||
* ``pm25`` - PM2.5 concentration value in 0.1 μg/m³
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum PM2.5 concentration value in 0.1 μg/m³
|
|
||||||
* ``max`` - Maximum PM2.5 concentration value in 0.1 μg/m³
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(float tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in 0.1 μg/m³
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for PM2.5 measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in 0.1 μg/m³
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current PM2.5 concentration value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
PM2.5 Sensor Implementation
|
|
||||||
***************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_PM25_Sensor/Zigbee_PM25_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,88 +0,0 @@
|
||||||
#################
|
|
||||||
ZigbeePowerOutlet
|
|
||||||
#################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeePowerOutlet`` class provides a smart power outlet endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for power control, allowing remote on/off control of electrical devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* On/off power control
|
|
||||||
* State change callbacks
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeePowerOutlet
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee power outlet endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeePowerOutlet(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Power Control
|
|
||||||
*************
|
|
||||||
|
|
||||||
setState
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Sets the power outlet state (on or off).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setState(bool state);
|
|
||||||
|
|
||||||
* ``state`` - ``true`` to turn on, ``false`` to turn off
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
getPowerOutletState
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current power outlet state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getPowerOutletState();
|
|
||||||
|
|
||||||
This function will return current power state (``true`` = on, ``false`` = off).
|
|
||||||
|
|
||||||
restoreState
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Restores the power outlet state and triggers any registered callbacks.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void restoreState();
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onPowerOutletChange
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the power outlet state changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onPowerOutletChange(void (*callback)(bool));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when power outlet state changes
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Smart Power Outlet Implementation
|
|
||||||
*********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Power_Outlet/Zigbee_Power_Outlet.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
||||||
####################
|
|
||||||
ZigbeePressureSensor
|
|
||||||
####################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeePressureSensor`` class provides an endpoint for pressure sensors in Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for pressure measurement devices, supporting atmospheric pressure, barometric pressure, and other pressure measurements.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Pressure measurement in hPa (hectopascals)
|
|
||||||
* Configurable measurement range
|
|
||||||
* Tolerance and reporting configuration
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeePressureSensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee pressure sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeePressureSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setPressure
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the pressure measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setPressure(int16_t value);
|
|
||||||
|
|
||||||
* ``value`` - Pressure value in hPa
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(int16_t min, int16_t max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum pressure value in hPa
|
|
||||||
* ``max`` - Maximum pressure value in hPa
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(uint16_t tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in hPa
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for pressure measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, uint16_t delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in hPa
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current pressure value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Pressure + Flow Sensor Implementation
|
|
||||||
*************************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Pressure_Flow_Sensor/Zigbee_Pressure_Flow_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
||||||
###################
|
|
||||||
ZigbeeRangeExtender
|
|
||||||
###################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeRangeExtender`` class provides a range extender endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for range extender devices that help extend the coverage of Zigbee networks by acting as repeaters.
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeRangeExtender
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee range extender endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeRangeExtender(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Range Extender Implementation
|
|
||||||
*****************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Range_Extender/Zigbee_Range_Extender.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,136 +0,0 @@
|
||||||
############
|
|
||||||
ZigbeeSwitch
|
|
||||||
############
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeSwitch`` class provides a switch endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for controlling other devices (typically lights) through on/off commands.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* On/off control commands for bound devices
|
|
||||||
* Group control support
|
|
||||||
* Direct device addressing
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeSwitch
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee switch endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeSwitch(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Basic Control Commands
|
|
||||||
**********************
|
|
||||||
|
|
||||||
lightToggle
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Toggles the state of bound lights (on to off, or off to on).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightToggle();
|
|
||||||
void lightToggle(uint16_t group_addr);
|
|
||||||
void lightToggle(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightToggle(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
lightOn
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Turns on bound lights.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOn();
|
|
||||||
void lightOn(uint16_t group_addr);
|
|
||||||
void lightOn(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightOn(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
lightOff
|
|
||||||
^^^^^^^^
|
|
||||||
|
|
||||||
Turns off bound lights.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOff();
|
|
||||||
void lightOff(uint16_t group_addr);
|
|
||||||
void lightOff(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
void lightOff(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to control (optional)
|
|
||||||
* ``endpoint`` - Target device endpoint (optional)
|
|
||||||
* ``short_addr`` - Target device short address (optional)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (optional)
|
|
||||||
|
|
||||||
Advanced Control Commands
|
|
||||||
*************************
|
|
||||||
|
|
||||||
lightOffWithEffect
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns off lights with a specific effect.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOffWithEffect(uint8_t effect_id, uint8_t effect_variant);
|
|
||||||
|
|
||||||
* ``effect_id`` - Effect identifier
|
|
||||||
* ``effect_variant`` - Effect variant
|
|
||||||
|
|
||||||
lightOnWithTimedOff
|
|
||||||
^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns on lights with automatic turn-off after specified time.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOnWithTimedOff(uint8_t on_off_control, uint16_t time_on, uint16_t time_off);
|
|
||||||
|
|
||||||
* ``on_off_control`` - Control byte
|
|
||||||
* ``time_on`` - Time to stay on (in 1/10th seconds)
|
|
||||||
* ``time_off`` - Time to stay off (in 1/10th seconds)
|
|
||||||
|
|
||||||
lightOnWithSceneRecall
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Turns on lights by recalling a scene.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void lightOnWithSceneRecall();
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Basic Switch Implementation
|
|
||||||
***************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_On_Off_Switch/Zigbee_On_Off_Switch.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
||||||
Multi Switch Implementation
|
|
||||||
***************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_On_Off_MultiSwitch/Zigbee_On_Off_MultiSwitch.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,184 +0,0 @@
|
||||||
################
|
|
||||||
ZigbeeTempSensor
|
|
||||||
################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeTempSensor`` class provides a temperature and humidity sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for environmental monitoring with configurable reporting intervals and thresholds.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Temperature measurement and reporting
|
|
||||||
* Optional humidity measurement
|
|
||||||
* Configurable reporting intervals
|
|
||||||
* Min/max value and tolerance settings
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeTempSensor
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee temperature sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeTempSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Temperature Control
|
|
||||||
*******************
|
|
||||||
|
|
||||||
setTemperature
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the temperature value in 0.01°C resolution.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTemperature(float value);
|
|
||||||
|
|
||||||
* ``value`` - Temperature value in degrees Celsius
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum temperature values for the sensor.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum temperature value in degrees Celsius
|
|
||||||
* ``max`` - Maximum temperature value in degrees Celsius
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for temperature reporting.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(float tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in degrees Celsius
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting interval for temperature measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in temperature to trigger report (in 0.01°C)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportTemperature
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current temperature value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportTemperature();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Humidity Control (Optional)
|
|
||||||
***************************
|
|
||||||
|
|
||||||
addHumiditySensor
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds humidity measurement capability to the temperature sensor.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void addHumiditySensor(float min, float max, float tolerance);
|
|
||||||
|
|
||||||
* ``min`` - Minimum humidity value in percentage
|
|
||||||
* ``max`` - Maximum humidity value in percentage
|
|
||||||
* ``tolerance`` - Tolerance value in percentage
|
|
||||||
|
|
||||||
setHumidity
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the humidity value in 0.01% resolution.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setHumidity(float value);
|
|
||||||
|
|
||||||
* ``value`` - Humidity value in percentage (0-100)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setHumidityReporting
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting interval for humidity measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setHumidityReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in humidity to trigger report (in 0.01%)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportHumidity
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current humidity value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportHumidity();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Combined Reporting
|
|
||||||
******************
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Reports both temperature and humidity values if humidity sensor is enabled.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool report();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Temperature Sensor Implementation
|
|
||||||
*********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Temperature_Sensor/Zigbee_Temperature_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
||||||
Temperature + Humidity Sleepy Sensor Implementation
|
|
||||||
***************************************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Temp_Hum_Sensor_Sleepy/Zigbee_Temp_Hum_Sensor_Sleepy.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,238 +0,0 @@
|
||||||
################
|
|
||||||
ZigbeeThermostat
|
|
||||||
################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeThermostat`` class provides a thermostat endpoint for Zigbee networks that receives temperature data from temperature sensors. This endpoint implements the Zigbee Home Automation (HA) standard for thermostats that can bind to temperature sensors and receive temperature readings.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Automatic discovery and binding to temperature sensors
|
|
||||||
* Temperature data reception from bound sensors
|
|
||||||
* Configurable temperature reporting intervals
|
|
||||||
* Sensor settings retrieval (min/max temperature, tolerance)
|
|
||||||
* Multiple addressing modes (group, specific endpoint, IEEE address)
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeThermostat
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee thermostat endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeThermostat(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onTempReceive
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function for receiving temperature data.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onTempReceive(void (*callback)(float temperature));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when temperature data is received
|
|
||||||
* ``temperature`` - Temperature value in degrees Celsius
|
|
||||||
|
|
||||||
onTempReceiveWithSource
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function for receiving temperature data with source information.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onTempReceiveWithSource(void (*callback)(float temperature, uint8_t src_endpoint, esp_zb_zcl_addr_t src_address));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when temperature data is received
|
|
||||||
* ``temperature`` - Temperature value in degrees Celsius
|
|
||||||
* ``src_endpoint`` - Source endpoint that sent the temperature data
|
|
||||||
* ``src_address`` - Source address information
|
|
||||||
|
|
||||||
onConfigReceive
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function for receiving sensor configuration data.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onConfigReceive(void (*callback)(float min_temp, float max_temp, float tolerance));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when sensor configuration is received
|
|
||||||
* ``min_temp`` - Minimum temperature supported by the sensor
|
|
||||||
* ``max_temp`` - Maximum temperature supported by the sensor
|
|
||||||
* ``tolerance`` - Temperature tolerance of the sensor
|
|
||||||
|
|
||||||
Temperature Data Retrieval
|
|
||||||
**************************
|
|
||||||
|
|
||||||
getTemperature
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests temperature data from all bound sensors.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getTemperature();
|
|
||||||
|
|
||||||
getTemperature (Group)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests temperature data from a specific group.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getTemperature(uint16_t group_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to send the request to
|
|
||||||
|
|
||||||
getTemperature (Endpoint + Short Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests temperature data from a specific endpoint using short address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getTemperature(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``short_addr`` - Short address of the target device
|
|
||||||
|
|
||||||
getTemperature (Endpoint + IEEE Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests temperature data from a specific endpoint using IEEE address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getTemperature(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``ieee_addr`` - IEEE address of the target device
|
|
||||||
|
|
||||||
Sensor Settings Retrieval
|
|
||||||
*************************
|
|
||||||
|
|
||||||
getSensorSettings
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests sensor settings from all bound sensors.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getSensorSettings();
|
|
||||||
|
|
||||||
getSensorSettings (Group)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests sensor settings from a specific group.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getSensorSettings(uint16_t group_addr);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to send the request to
|
|
||||||
|
|
||||||
getSensorSettings (Endpoint + Short Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests sensor settings from a specific endpoint using short address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getSensorSettings(uint8_t endpoint, uint16_t short_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``short_addr`` - Short address of the target device
|
|
||||||
|
|
||||||
getSensorSettings (Endpoint + IEEE Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests sensor settings from a specific endpoint using IEEE address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void getSensorSettings(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``ieee_addr`` - IEEE address of the target device
|
|
||||||
|
|
||||||
Temperature Reporting Configuration
|
|
||||||
***********************************
|
|
||||||
|
|
||||||
setTemperatureReporting
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Configures temperature reporting for all bound sensors.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setTemperatureReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in temperature to trigger a report
|
|
||||||
|
|
||||||
setTemperatureReporting (Group)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Configures temperature reporting for a specific group.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setTemperatureReporting(uint16_t group_addr, uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``group_addr`` - Group address to configure
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in temperature to trigger a report
|
|
||||||
|
|
||||||
setTemperatureReporting (Endpoint + Short Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Configures temperature reporting for a specific endpoint using short address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setTemperatureReporting(uint8_t endpoint, uint16_t short_addr, uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``short_addr`` - Short address of the target device
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in temperature to trigger a report
|
|
||||||
|
|
||||||
setTemperatureReporting (Endpoint + IEEE Address)
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Configures temperature reporting for a specific endpoint using IEEE address.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setTemperatureReporting(uint8_t endpoint, esp_zb_ieee_addr_t ieee_addr, uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``ieee_addr`` - IEEE address of the target device
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change in temperature to trigger a report
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Thermostat Implementation
|
|
||||||
*************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Thermostat/Zigbee_Thermostat.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,87 +0,0 @@
|
||||||
#####################
|
|
||||||
ZigbeeVibrationSensor
|
|
||||||
#####################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeVibrationSensor`` class provides a vibration sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for vibration detection devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Vibration detection and measurement
|
|
||||||
* Configurable sensitivity levels
|
|
||||||
* Multiple detection modes
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Security system vibration detection
|
|
||||||
* Industrial equipment monitoring
|
|
||||||
* Structural health monitoring
|
|
||||||
* Smart home security applications
|
|
||||||
* Machine condition monitoring
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeVibrationSensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee vibration sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeVibrationSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setVibration
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the vibration detection state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setVibration(bool sensed);
|
|
||||||
|
|
||||||
* ``sensed`` - Vibration state (true = sensed, false = not sensed)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setIASClientEndpoint
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the IAS Client endpoint number (default is 1).
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setIASClientEndpoint(uint8_t ep_number);
|
|
||||||
|
|
||||||
* ``ep_number`` - IAS Client endpoint number
|
|
||||||
|
|
||||||
report
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current vibration state.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void report();
|
|
||||||
|
|
||||||
This function does not return a value.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Vibration Sensor Implementation
|
|
||||||
*******************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Vibration_Sensor/Zigbee_Vibration_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,119 +0,0 @@
|
||||||
#####################
|
|
||||||
ZigbeeWindSpeedSensor
|
|
||||||
#####################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeWindSpeedSensor`` class provides a wind speed sensor endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for wind speed measurement devices.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Wind speed measurement in m/s
|
|
||||||
* Configurable measurement range
|
|
||||||
* Tolerance and reporting configuration
|
|
||||||
* Automatic reporting capabilities
|
|
||||||
* Integration with common endpoint features (binding, OTA, etc.)
|
|
||||||
* Zigbee HA standard compliance
|
|
||||||
|
|
||||||
**Use Cases:**
|
|
||||||
* Weather stations
|
|
||||||
* Wind turbine monitoring
|
|
||||||
* Agricultural weather monitoring
|
|
||||||
* Marine applications
|
|
||||||
* Smart home weather systems
|
|
||||||
* Industrial wind monitoring
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeWindSpeedSensor
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee wind speed sensor endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeWindSpeedSensor(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
API Methods
|
|
||||||
***********
|
|
||||||
|
|
||||||
setWindSpeed
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the wind speed measurement value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setWindSpeed(float value);
|
|
||||||
|
|
||||||
* ``value`` - Wind speed value in 0.01 m/s
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMinMaxValue
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the minimum and maximum measurement values.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMinMaxValue(float min, float max);
|
|
||||||
|
|
||||||
* ``min`` - Minimum wind speed value in 0.01 m/s
|
|
||||||
* ``max`` - Maximum wind speed value in 0.01 m/s
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTolerance
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the tolerance value for measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTolerance(float tolerance);
|
|
||||||
|
|
||||||
* ``tolerance`` - Tolerance value in 0.01 m/s
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setReporting
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the reporting configuration for wind speed measurements.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setReporting(uint16_t min_interval, uint16_t max_interval, float delta);
|
|
||||||
|
|
||||||
* ``min_interval`` - Minimum reporting interval in seconds
|
|
||||||
* ``max_interval`` - Maximum reporting interval in seconds
|
|
||||||
* ``delta`` - Minimum change required to trigger a report in 0.01 m/s
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportWindSpeed
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Manually reports the current wind speed value.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportWindSpeed();
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Wind Speed Sensor Implementation
|
|
||||||
********************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Wind_Speed_Sensor/Zigbee_Wind_Speed_Sensor.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,233 +0,0 @@
|
||||||
####################
|
|
||||||
ZigbeeWindowCovering
|
|
||||||
####################
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeWindowCovering`` class provides a window covering endpoint for Zigbee networks. This endpoint implements the Zigbee Home Automation (HA) standard for motorized blinds, shades, and other window coverings.
|
|
||||||
|
|
||||||
**Features:**
|
|
||||||
* Position control (lift and tilt)
|
|
||||||
* Multiple window covering types support
|
|
||||||
* Configurable operation modes and limits
|
|
||||||
* Status reporting and callbacks
|
|
||||||
* Safety features and limits
|
|
||||||
|
|
||||||
**Supported Window Covering Types:**
|
|
||||||
* ROLLERSHADE - Lift support
|
|
||||||
* ROLLERSHADE_2_MOTOR - Lift support
|
|
||||||
* ROLLERSHADE_EXTERIOR - Lift support
|
|
||||||
* ROLLERSHADE_EXTERIOR_2_MOTOR - Lift support
|
|
||||||
* DRAPERY - Lift support
|
|
||||||
* AWNING - Lift support
|
|
||||||
* SHUTTER - Tilt support
|
|
||||||
* BLIND_TILT_ONLY - Tilt support
|
|
||||||
* BLIND_LIFT_AND_TILT - Lift and Tilt support
|
|
||||||
* PROJECTOR_SCREEN - Lift support
|
|
||||||
|
|
||||||
API Reference
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Constructor
|
|
||||||
***********
|
|
||||||
|
|
||||||
ZigbeeWindowCovering
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Creates a new Zigbee window covering endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
ZigbeeWindowCovering(uint8_t endpoint);
|
|
||||||
|
|
||||||
* ``endpoint`` - Endpoint number (1-254)
|
|
||||||
|
|
||||||
Position Control
|
|
||||||
****************
|
|
||||||
|
|
||||||
setLiftPosition
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering lift position.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLiftPosition(uint16_t lift_position);
|
|
||||||
|
|
||||||
* ``lift_position`` - Lift position
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLiftPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering lift position as a percentage.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLiftPercentage(uint8_t lift_percentage);
|
|
||||||
|
|
||||||
* ``lift_percentage`` - Lift percentage (0-100, where 0 is fully closed, 100 is fully open)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTiltPosition
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering tilt position in degrees.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTiltPosition(uint16_t tilt_position);
|
|
||||||
|
|
||||||
* ``tilt_position`` - Tilt position in degrees
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTiltPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering tilt position as a percentage.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTiltPercentage(uint8_t tilt_percentage);
|
|
||||||
|
|
||||||
* ``tilt_percentage`` - Tilt percentage (0-100)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Configuration
|
|
||||||
*************
|
|
||||||
|
|
||||||
setCoveringType
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering type.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setCoveringType(ZigbeeWindowCoveringType covering_type);
|
|
||||||
|
|
||||||
* ``covering_type`` - Window covering type (see supported types above)
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setConfigStatus
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering configuration status.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setConfigStatus(bool operational, bool online, bool commands_reversed, bool lift_closed_loop, bool tilt_closed_loop, bool lift_encoder_controlled, bool tilt_encoder_controlled);
|
|
||||||
|
|
||||||
* ``operational`` - Operational status
|
|
||||||
* ``online`` - Online status
|
|
||||||
* ``commands_reversed`` - Commands reversed flag
|
|
||||||
* ``lift_closed_loop`` - Lift closed loop flag
|
|
||||||
* ``tilt_closed_loop`` - Tilt closed loop flag
|
|
||||||
* ``lift_encoder_controlled`` - Lift encoder controlled flag
|
|
||||||
* ``tilt_encoder_controlled`` - Tilt encoder controlled flag
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setMode
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the window covering operation mode.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setMode(bool motor_reversed, bool calibration_mode, bool maintenance_mode, bool leds_on);
|
|
||||||
|
|
||||||
* ``motor_reversed`` - Motor reversed flag
|
|
||||||
* ``calibration_mode`` - Calibration mode flag
|
|
||||||
* ``maintenance_mode`` - Maintenance mode flag
|
|
||||||
* ``leds_on`` - LEDs on flag
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
setLimits
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the motion limits for the window covering.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setLimits(uint16_t installed_open_limit_lift, uint16_t installed_closed_limit_lift, uint16_t installed_open_limit_tilt, uint16_t installed_closed_limit_tilt);
|
|
||||||
|
|
||||||
* ``installed_open_limit_lift`` - Installed open limit for lift
|
|
||||||
* ``installed_closed_limit_lift`` - Installed closed limit for lift
|
|
||||||
* ``installed_open_limit_tilt`` - Installed open limit for tilt
|
|
||||||
* ``installed_closed_limit_tilt`` - Installed closed limit for tilt
|
|
||||||
|
|
||||||
This function will return ``true`` if successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onOpen
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the window covering opens.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onOpen(void (*callback)());
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when window covering opens
|
|
||||||
|
|
||||||
onClose
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when the window covering closes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onClose(void (*callback)());
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when window covering closes
|
|
||||||
|
|
||||||
onGoToLiftPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when lift percentage changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onGoToLiftPercentage(void (*callback)(uint8_t));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when lift percentage changes
|
|
||||||
|
|
||||||
onGoToTiltPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when tilt percentage changes.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onGoToTiltPercentage(void (*callback)(uint8_t));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when tilt percentage changes
|
|
||||||
|
|
||||||
onStop
|
|
||||||
^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function to be called when window covering stops.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onStop(void (*callback)());
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when window covering stops
|
|
||||||
|
|
||||||
Example
|
|
||||||
-------
|
|
||||||
|
|
||||||
Window Covering Implementation
|
|
||||||
******************************
|
|
||||||
|
|
||||||
.. literalinclude:: ../../../libraries/Zigbee/examples/Zigbee_Window_Covering/Zigbee_Window_Covering.ino
|
|
||||||
:language: arduino
|
|
||||||
|
|
@ -1,159 +0,0 @@
|
||||||
######
|
|
||||||
Zigbee
|
|
||||||
######
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The Zigbee library provides support for creating Zigbee 3.0 compatible devices including:
|
|
||||||
|
|
||||||
* Support for different Zigbee roles (Coordinator, Router, End Device)
|
|
||||||
* Network management (scanning, joining, commissioning)
|
|
||||||
* Multiple endpoint types for various device categories
|
|
||||||
* OTA (Over-The-Air) update support
|
|
||||||
* Power management for battery-powered devices
|
|
||||||
* Time synchronization
|
|
||||||
* Advanced binding and group management
|
|
||||||
|
|
||||||
The Zigbee library is built on top of `ESP-ZIGBEE-SDK <https://github.com/espressif/esp-zigbee-sdk>`_ and provides a high-level Arduino-style interface for creating Zigbee devices.
|
|
||||||
|
|
||||||
Zigbee Network Topology
|
|
||||||
***********************
|
|
||||||
|
|
||||||
.. code-block:: text
|
|
||||||
|
|
||||||
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
|
|
||||||
│ Coordinator │◄─────►│ Router │◄─────►│ Router │
|
|
||||||
│ (Gateway) │ │ (Repeater) │ │ (Thermostat) │
|
|
||||||
└─────────────────┘ └─────────────────┘ └─────────────────┘
|
|
||||||
│ │ │
|
|
||||||
│ ▼ │
|
|
||||||
│ ┌─────────────────┐ │
|
|
||||||
│ │ End Device │ │
|
|
||||||
│ │ (Sensor) │ │
|
|
||||||
│ └─────────────────┘ │
|
|
||||||
│ │
|
|
||||||
▼ ▼
|
|
||||||
┌─────────────────┐ ┌─────────────────┐
|
|
||||||
│ End Device │ │ End Device │
|
|
||||||
│ (Sensor) │ │ (Sensor) │
|
|
||||||
└─────────────────┘ └─────────────────┘
|
|
||||||
|
|
||||||
|
|
||||||
**Device Roles**
|
|
||||||
|
|
||||||
* **Coordinator**: Forms and manages the network, stores network information
|
|
||||||
* **Router**: Extends network range, routes messages, mains powered devices (typically lights, switches, etc.)
|
|
||||||
* **End Device**: Battery-powered devices that can sleep for extended periods (typically sensors)
|
|
||||||
|
|
||||||
Zigbee Library Structure
|
|
||||||
------------------------
|
|
||||||
|
|
||||||
**The library is split into three main components:**
|
|
||||||
|
|
||||||
* ``ZigbeeCore``: The main class that manages the Zigbee network
|
|
||||||
* ``ZigbeeEP``: The base class for all Zigbee endpoints, which provides common functionality for all endpoint types
|
|
||||||
* ``Specific endpoint classes``: The classes for all Zigbee endpoints, which provides the specific functionality for each endpoint type
|
|
||||||
|
|
||||||
ZigbeeCore
|
|
||||||
**********
|
|
||||||
|
|
||||||
The ``ZigbeeCore`` class is the main entry point for all Zigbee operations. It serves as the central coordinator that manages:
|
|
||||||
|
|
||||||
* **Network Operations**: Starting, stopping, and managing the Zigbee network
|
|
||||||
* **Device Role Management**: Configuring the device as Coordinator, Router, or End Device
|
|
||||||
* **Endpoint Management**: Adding and managing multiple device endpoints
|
|
||||||
* **Network Discovery**: Scanning for and joining existing networks
|
|
||||||
* **OTA Updates**: Managing over-the-air firmware updates
|
|
||||||
* **Power Management**: Configuring sleep modes for battery-powered devices
|
|
||||||
|
|
||||||
The ``ZigbeeCore`` class is implemented as a singleton, meaning there's only one instance available globally. You access it directly as ``Zigbee`` without creating an instance.
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 3
|
|
||||||
|
|
||||||
zigbee_core
|
|
||||||
|
|
||||||
ZigbeeEP
|
|
||||||
********
|
|
||||||
|
|
||||||
The ``ZigbeeEP`` class is the base class for all Zigbee endpoints. It provides common functionality for all endpoint types.
|
|
||||||
|
|
||||||
* **Device Information**: Every endpoint can be configured with manufacturer and model information that helps identify the device on the network
|
|
||||||
* **Binding Management**: Binding allows endpoints to establish direct communication links with other devices. This enables automatic command transmission without requiring manual addressing
|
|
||||||
* **Power Management**: Endpoints can report their power source type and battery status, which helps the network optimize communication patterns
|
|
||||||
* **Time Synchronization**: Endpoints can synchronize with network time, enabling time-based operations and scheduling
|
|
||||||
* **OTA Support**: Endpoints can receive over-the-air firmware updates to add new features or fix bugs
|
|
||||||
* **Device Discovery**: Endpoints can read manufacturer and model information from other devices on the network
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 2
|
|
||||||
|
|
||||||
zigbee_ep
|
|
||||||
|
|
||||||
Specific endpoint classes
|
|
||||||
*************************
|
|
||||||
|
|
||||||
Library provides the following endpoint classes from lights, switches, sensors, etc. Each endpoint class provides the specific functionality for each endpoint type and inherits from the ``ZigbeeEP`` class.
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
:glob:
|
|
||||||
|
|
||||||
ep_*
|
|
||||||
|
|
||||||
|
|
||||||
Common Problems and Issues
|
|
||||||
--------------------------
|
|
||||||
|
|
||||||
Troubleshooting
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Common Issues
|
|
||||||
*************
|
|
||||||
|
|
||||||
**Device won't join network**
|
|
||||||
* Ensure the coordinator is in pairing mode
|
|
||||||
* Check that the device is configured with the correct role
|
|
||||||
* Verify the channel mask includes the coordinator's channel
|
|
||||||
|
|
||||||
**OTA updates fail**
|
|
||||||
* Ensure the OTA server is properly configured
|
|
||||||
* Check that the device has sufficient memory for the update
|
|
||||||
* Verify network connectivity
|
|
||||||
|
|
||||||
**Battery devices not working**
|
|
||||||
* Ensure proper power source configuration
|
|
||||||
* Check sleep/wake timing settings
|
|
||||||
* Verify parent device (router/coordinator) is always powered
|
|
||||||
|
|
||||||
**Binding issues**
|
|
||||||
* Check that both devices support the required clusters
|
|
||||||
* Verify that binding is enabled on both devices
|
|
||||||
* Ensure devices are on the same network
|
|
||||||
|
|
||||||
**Network connectivity problems**
|
|
||||||
* Check that devices are within range
|
|
||||||
* Verify that routers are properly configured
|
|
||||||
* Check for interference from other 2.4 GHz devices
|
|
||||||
|
|
||||||
Factory Reset
|
|
||||||
*************
|
|
||||||
|
|
||||||
If you have problems with connecting to the network, you can try to factory reset the device. This will erase all the network settings and act as brand new device.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
Zigbee.factoryReset(true); // true = restart after reset
|
|
||||||
|
|
||||||
Debug Mode
|
|
||||||
**********
|
|
||||||
|
|
||||||
For better debugging, you can enable debug mode to get detailed information about network operations. Call debug mode before starting Zigbee.
|
|
||||||
Also selecting zigbee mode with *debug* suffix is recommended.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
Zigbee.setDebugMode(true);
|
|
||||||
// Start Zigbee with debug output
|
|
||||||
Zigbee.begin();
|
|
||||||
|
|
@ -1,388 +0,0 @@
|
||||||
##########
|
|
||||||
ZigbeeCore
|
|
||||||
##########
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeCore`` class is the main entry point for all Zigbee operations. It serves as the central class that manages:
|
|
||||||
|
|
||||||
* **Network Operations**: Starting, stopping, and managing the Zigbee network
|
|
||||||
* **Device Role Management**: Configuring the device as Coordinator, Router, or End Device
|
|
||||||
* **Endpoint Management**: Adding and managing multiple device endpoints
|
|
||||||
* **Network Discovery**: Scanning for and joining existing networks
|
|
||||||
|
|
||||||
ZigbeeCore APIs
|
|
||||||
---------------
|
|
||||||
|
|
||||||
Network Initialization
|
|
||||||
**********************
|
|
||||||
|
|
||||||
begin
|
|
||||||
^^^^^
|
|
||||||
|
|
||||||
Initializes the Zigbee stack and starts the network.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool begin(zigbee_role_t role = ZIGBEE_END_DEVICE, bool erase_nvs = false);
|
|
||||||
bool begin(esp_zb_cfg_t *role_cfg, bool erase_nvs = false);
|
|
||||||
|
|
||||||
* ``role`` - Device role (default: ``ZIGBEE_END_DEVICE``)
|
|
||||||
* ``role_cfg`` - Custom role configuration structure
|
|
||||||
* ``erase_nvs`` - Whether to erase NVS storage (default: ``false``)
|
|
||||||
|
|
||||||
This function will return ``true`` if initialization successful, ``false`` otherwise.
|
|
||||||
|
|
||||||
**Available Roles:**
|
|
||||||
|
|
||||||
* **ZIGBEE_COORDINATOR**: Network coordinator, forms and manages the network
|
|
||||||
* **ZIGBEE_ROUTER**: Network router, connects to existing network and extends network range and routes messages (if device is mains powered, always use this role)
|
|
||||||
* **ZIGBEE_END_DEVICE**: End device, connects to existing network (typically battery-powered which can sleep)
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
Depending on the Zigbee role, proper Zigbee mode and partition scheme must be set in the Arduino IDE.
|
|
||||||
|
|
||||||
* **ZIGBEE_COORDINATOR** and **ZIGBEE_ROUTER**:
|
|
||||||
* Zigbee mode to ``Zigbee ZCZR (coordinator/router)``.
|
|
||||||
* Partition scheme to ``Zigbee ZCZR xMB with spiffs`` (where ``x`` is the number of MB of selected flash size).
|
|
||||||
* **ZIGBEE_END_DEVICE**:
|
|
||||||
* Zigbee mode to ``Zigbee ED (end device)``.
|
|
||||||
* Partition scheme to ``Zigbee xMB with spiffs`` (where ``x`` is the number of MB of selected flash size).
|
|
||||||
|
|
||||||
Network Status
|
|
||||||
**************
|
|
||||||
|
|
||||||
started
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Checks if the Zigbee stack has been started.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool started();
|
|
||||||
|
|
||||||
This function will return ``true`` if Zigbee stack is running, ``false`` otherwise.
|
|
||||||
|
|
||||||
connected
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Checks if the device is connected to a Zigbee network.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool connected();
|
|
||||||
|
|
||||||
This function will return ``true`` if connected to network, ``false`` otherwise.
|
|
||||||
|
|
||||||
getRole
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Gets the current Zigbee device role.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
zigbee_role_t getRole();
|
|
||||||
|
|
||||||
This function will return current device role (``ZIGBEE_COORDINATOR``, ``ZIGBEE_ROUTER``, ``ZIGBEE_END_DEVICE``).
|
|
||||||
|
|
||||||
Endpoint Management
|
|
||||||
*******************
|
|
||||||
|
|
||||||
addEndpoint
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds an endpoint to the Zigbee network.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addEndpoint(ZigbeeEP *ep);
|
|
||||||
|
|
||||||
* ``ep`` - Pointer to the endpoint object to add
|
|
||||||
|
|
||||||
This function will return ``true`` if endpoint added successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
Network Configuration
|
|
||||||
*********************
|
|
||||||
|
|
||||||
setPrimaryChannelMask
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the primary channel mask for network scanning and joining.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setPrimaryChannelMask(uint32_t mask);
|
|
||||||
|
|
||||||
* ``mask`` - Channel mask (default: all channels 11-26, mask 0x07FFF800)
|
|
||||||
|
|
||||||
setScanDuration
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the scan duration for network discovery.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setScanDuration(uint8_t duration);
|
|
||||||
|
|
||||||
* ``duration`` - Scan duration (1-4, where 1 is fastest, 4 is slowest)
|
|
||||||
|
|
||||||
getScanDuration
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current scan duration setting.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getScanDuration();
|
|
||||||
|
|
||||||
This function will return current scan duration (1-4).
|
|
||||||
|
|
||||||
Power Management
|
|
||||||
****************
|
|
||||||
|
|
||||||
setRxOnWhenIdle
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets whether the device keeps its receiver on when idle.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setRxOnWhenIdle(bool rx_on_when_idle);
|
|
||||||
|
|
||||||
* ``rx_on_when_idle`` - ``true`` to keep receiver on, ``false`` to allow sleep
|
|
||||||
|
|
||||||
getRxOnWhenIdle
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current receiver idle setting.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getRxOnWhenIdle();
|
|
||||||
|
|
||||||
This function will return current receiver idle setting.
|
|
||||||
|
|
||||||
setTimeout
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the timeout for network operations.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setTimeout(uint32_t timeout);
|
|
||||||
|
|
||||||
* ``timeout`` - Timeout in milliseconds (default: 30000 ms)
|
|
||||||
|
|
||||||
Network Discovery
|
|
||||||
*****************
|
|
||||||
|
|
||||||
scanNetworks
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Scans for available Zigbee networks.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void scanNetworks(uint32_t channel_mask = ESP_ZB_TRANSCEIVER_ALL_CHANNELS_MASK, uint8_t scan_duration = 5);
|
|
||||||
|
|
||||||
* ``channel_mask`` - Channels to scan (default: all channels)
|
|
||||||
* ``scan_duration`` - Scan duration (default: 5)
|
|
||||||
|
|
||||||
scanComplete
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Checks if network scanning is complete.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
int16_t scanComplete();
|
|
||||||
|
|
||||||
This function will return:
|
|
||||||
* ``-2``: Scan failed or not started
|
|
||||||
* ``-1``: Scan running
|
|
||||||
* ``0``: No networks found
|
|
||||||
* ``>0``: Number of networks found
|
|
||||||
|
|
||||||
getScanResult
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the scan results.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
zigbee_scan_result_t *getScanResult();
|
|
||||||
|
|
||||||
This function will return pointer to scan results, or ``NULL`` if no results.
|
|
||||||
|
|
||||||
scanDelete
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Deletes the scan results from memory.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void scanDelete();
|
|
||||||
|
|
||||||
Network Management (Coordinator only)
|
|
||||||
*************************************
|
|
||||||
|
|
||||||
setRebootOpenNetwork
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Opens the network for joining after reboot for a specified time.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setRebootOpenNetwork(uint8_t time);
|
|
||||||
|
|
||||||
* ``time`` - Time in seconds to keep network open after reboot
|
|
||||||
|
|
||||||
openNetwork
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Opens the network for device joining for a specified time.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void openNetwork(uint8_t time);
|
|
||||||
|
|
||||||
* ``time`` - Time in seconds to keep network open for device joining
|
|
||||||
|
|
||||||
closeNetwork
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Closes the network to prevent new devices from joining.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void closeNetwork();
|
|
||||||
|
|
||||||
Radio Configuration
|
|
||||||
*******************
|
|
||||||
|
|
||||||
setRadioConfig
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the radio configuration.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setRadioConfig(esp_zb_radio_config_t config);
|
|
||||||
|
|
||||||
* ``config`` - Radio configuration structure
|
|
||||||
|
|
||||||
getRadioConfig
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current radio configuration.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
esp_zb_radio_config_t getRadioConfig();
|
|
||||||
|
|
||||||
This function will return current radio configuration.
|
|
||||||
|
|
||||||
Host Configuration
|
|
||||||
******************
|
|
||||||
|
|
||||||
setHostConfig
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the host configuration.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setHostConfig(esp_zb_host_config_t config);
|
|
||||||
|
|
||||||
* ``config`` - Host configuration structure
|
|
||||||
|
|
||||||
getHostConfig
|
|
||||||
^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current host configuration.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
esp_zb_host_config_t getHostConfig();
|
|
||||||
|
|
||||||
This function will return current host configuration.
|
|
||||||
|
|
||||||
Debug and Utilities
|
|
||||||
*******************
|
|
||||||
|
|
||||||
setDebugMode
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Enables or disables debug mode.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setDebugMode(bool debug);
|
|
||||||
|
|
||||||
* ``debug`` - ``true`` to enable debug output, ``false`` to disable
|
|
||||||
|
|
||||||
getDebugMode
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the current debug mode setting.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool getDebugMode();
|
|
||||||
|
|
||||||
This function will return current debug mode setting.
|
|
||||||
|
|
||||||
factoryReset
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Performs a factory reset, clearing all network settings.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void factoryReset(bool restart = true);
|
|
||||||
|
|
||||||
* ``restart`` - ``true`` to restart after reset (default: ``true``)
|
|
||||||
|
|
||||||
onGlobalDefaultResponse
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a global callback for default response messages.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onGlobalDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status, uint8_t endpoint, uint16_t cluster));
|
|
||||||
|
|
||||||
* ``callback`` - Function pointer to the callback function
|
|
||||||
|
|
||||||
This callback will be called for all endpoints when a default response is received.
|
|
||||||
|
|
||||||
Utility Functions
|
|
||||||
*****************
|
|
||||||
|
|
||||||
formatIEEEAddress
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Formats an IEEE address for display.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
static const char *formatIEEEAddress(const esp_zb_ieee_addr_t addr);
|
|
||||||
|
|
||||||
* ``addr`` - IEEE address to format
|
|
||||||
|
|
||||||
This function will return formatted address string.
|
|
||||||
|
|
||||||
formatShortAddress
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Formats a short address for display.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
static const char *formatShortAddress(uint16_t addr);
|
|
||||||
|
|
||||||
* ``addr`` - Short address to format
|
|
||||||
|
|
||||||
This function will return formatted address string.
|
|
||||||
|
|
@ -1,370 +0,0 @@
|
||||||
########
|
|
||||||
ZigbeeEP
|
|
||||||
########
|
|
||||||
|
|
||||||
About
|
|
||||||
-----
|
|
||||||
|
|
||||||
The ``ZigbeeEP`` class is the base class for all Zigbee endpoints. It provides common functionality for all endpoint types.
|
|
||||||
|
|
||||||
* **Device Information**: Every endpoint can be configured with manufacturer and model information that helps identify the device on the network
|
|
||||||
* **Binding Management**: Binding allows endpoints to establish direct communication links with other devices. This enables automatic command transmission without requiring manual addressing
|
|
||||||
* **Power Management**: Endpoints can report their power source type and battery status, which helps the network optimize communication patterns
|
|
||||||
* **Time Synchronization**: Endpoints can synchronize with network time, enabling time-based operations and scheduling
|
|
||||||
* **OTA Support**: Endpoints can receive over-the-air firmware updates to add new features or fix bugs
|
|
||||||
* **Device Discovery**: Endpoints can read manufacturer and model information from other devices on the network
|
|
||||||
|
|
||||||
|
|
||||||
ZigbeeEP APIs
|
|
||||||
-------------
|
|
||||||
|
|
||||||
Device Information
|
|
||||||
******************
|
|
||||||
|
|
||||||
setManufacturerAndModel
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the manufacturer name and model identifier for the device.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setManufacturerAndModel(const char *name, const char *model);
|
|
||||||
|
|
||||||
* ``name`` - Manufacturer name (max 32 characters)
|
|
||||||
* ``model`` - Model identifier (max 32 characters)
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
getEndpoint
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the endpoint number assigned to this device.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
uint8_t getEndpoint();
|
|
||||||
|
|
||||||
This function will return the endpoint number (1-254).
|
|
||||||
|
|
||||||
Binding Management
|
|
||||||
******************
|
|
||||||
|
|
||||||
bound
|
|
||||||
^^^^^
|
|
||||||
|
|
||||||
Checks if the endpoint has any bound devices.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool bound();
|
|
||||||
|
|
||||||
This function will return ``true`` if the endpoint has bound devices, ``false`` otherwise.
|
|
||||||
|
|
||||||
getBoundDevices
|
|
||||||
^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the list of devices bound to this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
std::vector<esp_zb_binding_info_t> getBoundDevices();
|
|
||||||
|
|
||||||
This function will return list of bound device parameters.
|
|
||||||
|
|
||||||
printBoundDevices
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Prints information about bound devices to Serial or a custom Print object.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void printBoundDevices(Print &print = Serial);
|
|
||||||
|
|
||||||
* ``print`` - Custom Print object (optional, defaults to Serial)
|
|
||||||
|
|
||||||
allowMultipleBinding
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Enables or disables multiple device binding for this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void allowMultipleBinding(bool bind);
|
|
||||||
|
|
||||||
* ``bind`` - ``true`` to allow multiple bindings, ``false`` for single binding only
|
|
||||||
|
|
||||||
setManualBinding
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Enables or disables manual binding mode. Manual binding mode is supposed to be used when using ZHA or Z2M where you bind devices manually.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void setManualBinding(bool bind);
|
|
||||||
|
|
||||||
* ``bind`` - ``true`` for manual binding, ``false`` for automatic binding (default)
|
|
||||||
|
|
||||||
clearBoundDevices
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Removes all bound devices from this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void clearBoundDevices();
|
|
||||||
|
|
||||||
Binding Status
|
|
||||||
**************
|
|
||||||
|
|
||||||
epAllowMultipleBinding
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets whether multiple device binding is allowed for this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool epAllowMultipleBinding();
|
|
||||||
|
|
||||||
This function will return ``true`` if multiple bindings are allowed, ``false`` otherwise.
|
|
||||||
|
|
||||||
epUseManualBinding
|
|
||||||
^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets whether manual binding mode is enabled for this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool epUseManualBinding();
|
|
||||||
|
|
||||||
This function will return ``true`` if manual binding is enabled, ``false`` otherwise.
|
|
||||||
|
|
||||||
Power Management
|
|
||||||
****************
|
|
||||||
|
|
||||||
setPowerSource
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the power source type for the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setPowerSource(uint8_t source, uint8_t percentage = 0xff, uint8_t voltage = 0xff);
|
|
||||||
|
|
||||||
* ``source`` - Power source type (``ZB_POWER_SOURCE_MAINS``, ``ZB_POWER_SOURCE_BATTERY``, etc.)
|
|
||||||
* ``percentage`` - Battery percentage (0-100, default: 0xff)
|
|
||||||
* ``voltage`` - Battery voltage in 100 mV units (default: 0xff)
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
setBatteryPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the current battery percentage.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setBatteryPercentage(uint8_t percentage);
|
|
||||||
|
|
||||||
* ``percentage`` - Battery percentage (0-100)
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
setBatteryVoltage
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the battery voltage.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setBatteryVoltage(uint8_t voltage);
|
|
||||||
|
|
||||||
* ``voltage`` - Battery voltage in 100 mV units (e.g., 35 for 3.5 V)
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
reportBatteryPercentage
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Reports the current battery percentage to the network.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool reportBatteryPercentage();
|
|
||||||
|
|
||||||
This function will return ``true`` if reported successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
Time Synchronization
|
|
||||||
********************
|
|
||||||
|
|
||||||
addTimeCluster
|
|
||||||
^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds time synchronization cluster to the endpoint. When you want to add a server cluster (have the time and GMT offset) fill the time structure with the current time and GMT offset.
|
|
||||||
For client cluster (get the time and GMT offset) keep the default parameters.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addTimeCluster(tm time = {}, int32_t gmt_offset = 0);
|
|
||||||
|
|
||||||
* ``time`` - Current time structure (default: empty)
|
|
||||||
* ``gmt_offset`` - GMT offset in seconds (default: 0)
|
|
||||||
|
|
||||||
This function will return ``true`` if added successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTime
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Sets the current time for the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTime(tm time);
|
|
||||||
|
|
||||||
* ``time`` - Time structure to set
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
setTimezone
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets the timezone offset for the endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool setTimezone(int32_t gmt_offset);
|
|
||||||
|
|
||||||
* ``gmt_offset`` - GMT offset in seconds
|
|
||||||
|
|
||||||
This function will return ``true`` if set successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
getTime
|
|
||||||
^^^^^^^
|
|
||||||
|
|
||||||
Gets the current network time.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
struct tm getTime(uint8_t endpoint = 1, int32_t short_addr = 0x0000, esp_zb_ieee_addr_t ieee_addr = {});
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint (default: 1)
|
|
||||||
* ``short_addr`` - Target device short address (default: 0x0000)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (default: empty)
|
|
||||||
|
|
||||||
This function will return network time structure.
|
|
||||||
|
|
||||||
getTimezone
|
|
||||||
^^^^^^^^^^^
|
|
||||||
|
|
||||||
Gets the timezone offset.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
int32_t getTimezone(uint8_t endpoint = 1, int32_t short_addr = 0x0000, esp_zb_ieee_addr_t ieee_addr = {});
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint (default: 1)
|
|
||||||
* ``short_addr`` - Target device short address (default: 0x0000)
|
|
||||||
* ``ieee_addr`` - Target device IEEE address (default: empty)
|
|
||||||
|
|
||||||
This function will return GMT offset in seconds.
|
|
||||||
|
|
||||||
OTA Support
|
|
||||||
***********
|
|
||||||
|
|
||||||
addOTAClient
|
|
||||||
^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Adds OTA client to the endpoint for firmware updates.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
bool addOTAClient(uint32_t file_version, uint32_t downloaded_file_ver, uint16_t hw_version, uint16_t manufacturer = 0x1001, uint16_t image_type = 0x1011, uint8_t max_data_size = 223);
|
|
||||||
|
|
||||||
* ``file_version`` - Current firmware version
|
|
||||||
* ``downloaded_file_ver`` - Downloaded file version
|
|
||||||
* ``hw_version`` - Hardware version
|
|
||||||
* ``manufacturer`` - Manufacturer code (default: 0x1001)
|
|
||||||
* ``image_type`` - Image type code (default: 0x1011)
|
|
||||||
* ``max_data_size`` - Maximum data size for OTA transfer (default: 223)
|
|
||||||
|
|
||||||
This function will return ``true`` if added successfully, ``false`` otherwise.
|
|
||||||
|
|
||||||
requestOTAUpdate
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Requests OTA update from the server.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void requestOTAUpdate();
|
|
||||||
|
|
||||||
Device Discovery
|
|
||||||
****************
|
|
||||||
|
|
||||||
readManufacturer
|
|
||||||
^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Reads the manufacturer name from a remote device.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
char *readManufacturer(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``short_addr`` - Target device short address
|
|
||||||
* ``ieee_addr`` - Target device IEEE address
|
|
||||||
|
|
||||||
This function will return pointer to manufacturer string, or ``NULL`` if read failed.
|
|
||||||
|
|
||||||
readModel
|
|
||||||
^^^^^^^^^
|
|
||||||
|
|
||||||
Reads the model identifier from a remote device.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
char *readModel(uint8_t endpoint, uint16_t short_addr, esp_zb_ieee_addr_t ieee_addr);
|
|
||||||
|
|
||||||
* ``endpoint`` - Target endpoint number
|
|
||||||
* ``short_addr`` - Target device short address
|
|
||||||
* ``ieee_addr`` - Target device IEEE address
|
|
||||||
|
|
||||||
This function will return pointer to model string, or ``NULL`` if read failed.
|
|
||||||
|
|
||||||
Event Handling
|
|
||||||
**************
|
|
||||||
|
|
||||||
onIdentify
|
|
||||||
^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback function for identify events.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onIdentify(void (*callback)(uint16_t));
|
|
||||||
|
|
||||||
* ``callback`` - Function to call when identify event occurs
|
|
||||||
* ``time`` - Identify time in seconds
|
|
||||||
|
|
||||||
onDefaultResponse
|
|
||||||
^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
Sets a callback for default response messages for this endpoint.
|
|
||||||
|
|
||||||
.. code-block:: arduino
|
|
||||||
|
|
||||||
void onDefaultResponse(void (*callback)(zb_cmd_type_t resp_to_cmd, esp_zb_zcl_status_t status));
|
|
||||||
|
|
||||||
* ``callback`` - Function pointer to the callback function
|
|
||||||
|
|
||||||
This callback will be called when a default response is received for this specific endpoint.
|
|
||||||
|
|
||||||
Supported Endpoints
|
|
||||||
-------------------
|
|
||||||
|
|
||||||
The Zigbee library provides specialized endpoint classes for different device types. Each endpoint type includes specific clusters and functionality relevant to that device category.
|
|
||||||
|
|
||||||
.. toctree::
|
|
||||||
:maxdepth: 1
|
|
||||||
:glob:
|
|
||||||
|
|
||||||
ep_*
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
sphinx==4.5.0
|
|
||||||
esp-docs>=1.4.0
|
esp-docs>=1.4.0
|
||||||
sphinx-copybutton==0.5.0
|
sphinx-copybutton==0.5.0
|
||||||
sphinx-tabs==3.2.0
|
sphinx-tabs==3.2.0
|
||||||
numpydoc==1.5.0
|
numpydoc==1.5.0
|
||||||
standard-imghdr==3.13.0
|
standard-imghdr==3.13.0
|
||||||
Sphinx-Substitution-Extensions==2022.2.16
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,6 @@ targets:
|
||||||
- esp32c6
|
- esp32c6
|
||||||
- esp32h2
|
- esp32h2
|
||||||
- esp32p4
|
- esp32p4
|
||||||
- esp32c5
|
|
||||||
tags:
|
tags:
|
||||||
- arduino
|
- arduino
|
||||||
files:
|
files:
|
||||||
|
|
@ -23,7 +22,6 @@ files:
|
||||||
- "variants/esp32c6/**/*"
|
- "variants/esp32c6/**/*"
|
||||||
- "variants/esp32h2/**/*"
|
- "variants/esp32h2/**/*"
|
||||||
- "variants/esp32p4/**/*"
|
- "variants/esp32p4/**/*"
|
||||||
- "variants/esp32c5/**/*"
|
|
||||||
exclude:
|
exclude:
|
||||||
- "docs/"
|
- "docs/"
|
||||||
- "docs/**/*"
|
- "docs/**/*"
|
||||||
|
|
@ -46,7 +44,7 @@ files:
|
||||||
- "platform.txt"
|
- "platform.txt"
|
||||||
- "programmers.txt"
|
- "programmers.txt"
|
||||||
dependencies:
|
dependencies:
|
||||||
idf: ">=5.3,<5.6"
|
idf: ">=5.3,<5.5"
|
||||||
# mdns 1.2.1 is necessary to build H2 with no WiFi
|
# mdns 1.2.1 is necessary to build H2 with no WiFi
|
||||||
espressif/mdns:
|
espressif/mdns:
|
||||||
version: "^1.2.3"
|
version: "^1.2.3"
|
||||||
|
|
@ -54,12 +52,12 @@ dependencies:
|
||||||
espressif/esp_modem:
|
espressif/esp_modem:
|
||||||
version: "^1.1.0"
|
version: "^1.1.0"
|
||||||
espressif/esp-zboss-lib:
|
espressif/esp-zboss-lib:
|
||||||
version: "==1.6.4" # compatible with esp-zigbee-lib 1.6.6
|
version: "==1.6.3"
|
||||||
require: public
|
require: public
|
||||||
rules:
|
rules:
|
||||||
- if: "target not in [esp32c2, esp32p4]"
|
- if: "target not in [esp32c2, esp32p4]"
|
||||||
espressif/esp-zigbee-lib:
|
espressif/esp-zigbee-lib:
|
||||||
version: "==1.6.6"
|
version: "==1.6.3"
|
||||||
require: public
|
require: public
|
||||||
rules:
|
rules:
|
||||||
- if: "target not in [esp32c2, esp32p4]"
|
- if: "target not in [esp32c2, esp32p4]"
|
||||||
|
|
@ -70,8 +68,6 @@ dependencies:
|
||||||
# RainMaker Start (Fixed versions, because Matter supports only Insights 1.0.1)
|
# RainMaker Start (Fixed versions, because Matter supports only Insights 1.0.1)
|
||||||
espressif/network_provisioning:
|
espressif/network_provisioning:
|
||||||
version: "1.0.2"
|
version: "1.0.2"
|
||||||
rules:
|
|
||||||
- if: "target != esp32c2"
|
|
||||||
espressif/esp_rainmaker:
|
espressif/esp_rainmaker:
|
||||||
version: "1.5.2"
|
version: "1.5.2"
|
||||||
rules:
|
rules:
|
||||||
|
|
@ -107,11 +103,11 @@ dependencies:
|
||||||
rules:
|
rules:
|
||||||
- if: "target in [esp32s3]"
|
- if: "target in [esp32s3]"
|
||||||
espressif/esp_hosted:
|
espressif/esp_hosted:
|
||||||
version: "^2.0.12"
|
version: "^0.0.25"
|
||||||
rules:
|
rules:
|
||||||
- if: "target == esp32p4"
|
- if: "target == esp32p4"
|
||||||
espressif/esp_wifi_remote:
|
espressif/esp_wifi_remote:
|
||||||
version: "^0.13.0"
|
version: "^0.4.1"
|
||||||
rules:
|
rules:
|
||||||
- if: "target == esp32p4"
|
- if: "target == esp32p4"
|
||||||
espressif/libsodium:
|
espressif/libsodium:
|
||||||
|
|
|
||||||
4
idf_component_examples/.gitignore
vendored
4
idf_component_examples/.gitignore
vendored
|
|
@ -1,4 +0,0 @@
|
||||||
build/
|
|
||||||
managed_components/
|
|
||||||
dependencies.lock
|
|
||||||
sdkconfig
|
|
||||||
|
|
@ -8,7 +8,6 @@ set(PROJECT_VER_NUMBER 1)
|
||||||
# This should be done before using the IDF_TARGET variable.
|
# This should be done before using the IDF_TARGET variable.
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
|
|
||||||
idf_build_set_property(MINIMAL_BUILD ON)
|
|
||||||
project(arduino_managed_component_light)
|
project(arduino_managed_component_light)
|
||||||
|
|
||||||
# WARNING: This is just an example for using key for decrypting the encrypted OTA image
|
# WARNING: This is just an example for using key for decrypting the encrypted OTA image
|
||||||
|
|
@ -21,7 +20,7 @@ if(CONFIG_IDF_TARGET_ESP32C2)
|
||||||
include(relinker)
|
include(relinker)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++2a;-Os;-DCHIP_HAVE_CONFIG_H" APPEND)
|
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND)
|
||||||
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
|
idf_build_set_property(C_COMPILE_OPTIONS "-Os" APPEND)
|
||||||
# For RISCV chips, project_include.cmake sets -Wno-format, but does not clear various
|
# For RISCV chips, project_include.cmake sets -Wno-format, but does not clear various
|
||||||
# flags that depend on -Wformat
|
# flags that depend on -Wformat
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue