Merge branch 'master' into release/v3.3.x

This commit is contained in:
Me No Dev 2025-04-29 10:55:47 +03:00 committed by GitHub
commit c9efce6342
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 442 additions and 378 deletions

33
.github/scripts/on-push-idf.sh vendored Normal file
View file

@ -0,0 +1,33 @@
#!/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

View file

@ -35,6 +35,8 @@ 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"
@ -339,9 +341,13 @@ 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\/espressif\//!s|github\.com/espressif/|dl.espressif.cn/github_assets/espressif/|g' "$OUTPUT_DIR/$PACKAGE_JSON_DEV" > "$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\/espressif\//!s|github\.com/espressif/|dl.espressif.cn/github_assets/espressif/|g' "$OUTPUT_DIR/$PACKAGE_JSON_REL" > "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN"
fi fi
# Figure out the last release or pre-release # Figure out the last release or pre-release
@ -373,12 +379,14 @@ 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
@ -388,6 +396,8 @@ 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 ..."
@ -445,11 +455,15 @@ 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" "$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" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN")"
echo echo
fi fi

View file

@ -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 "ERROR: sdkconfig or ci.json not found" 1>&2 echo "WARNING: sdkconfig or ci.json not found. Assuming requirements are met." 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

View file

@ -31,6 +31,7 @@ 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"
@ -45,7 +46,6 @@ 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/esp32c5/**/*"
- "variants/esp32c6/**/*" - "variants/esp32c6/**/*"
@ -125,7 +125,7 @@ jobs:
- 'idf_component.yml' - 'idf_component.yml'
- 'Kconfig.projbuild' - 'Kconfig.projbuild'
- 'CMakeLists.txt' - 'CMakeLists.txt'
- "variants/esp32c2/**/*" - "idf_component_examples/**"
- name: Set chunks - name: Set chunks
id: set-chunks id: set-chunks
@ -268,15 +268,23 @@ 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: |
. ${IDF_PATH}/export.sh chmod a+x ./components/arduino-esp32/.github/scripts/*
idf.py create-project test ./components/arduino-esp32/.github/scripts/on-push-idf.sh
echo CONFIG_FREERTOS_HZ=1000 > test/sdkconfig.defaults
idf.py -C test -DEXTRA_COMPONENT_DIRS=$PWD/components build - name: Upload generated sdkconfig files for debugging
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
if: always()
with:
name: sdkconfig-${{ 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:

View file

@ -6218,12 +6218,12 @@ twatchs3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
twatchs3.menu.UploadMode.cdc.upload.use_1200bps_touch=true twatchs3.menu.UploadMode.cdc.upload.use_1200bps_touch=true
twatchs3.menu.UploadMode.cdc.upload.wait_for_upload_port=true twatchs3.menu.UploadMode.cdc.upload.wait_for_upload_port=true
twatchs3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
twatchs3.menu.PartitionScheme.fatflash.build.partitions=ffat
twatchs3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS) twatchs3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS)
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728 twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
twatchs3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
twatchs3.menu.PartitionScheme.fatflash.build.partitions=ffat
twatchs3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
twatchs3.menu.PartitionScheme.rainmaker=RainMaker twatchs3.menu.PartitionScheme.rainmaker=RainMaker
twatchs3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker twatchs3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
twatchs3.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080 twatchs3.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080
@ -6287,6 +6287,10 @@ twatchs3.menu.Revision.Radio_SX1280=Radio-SX1280
twatchs3.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280 twatchs3.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
twatchs3.menu.Revision.Radio_CC1101=Radio-CC1101 twatchs3.menu.Revision.Radio_CC1101=Radio-CC1101
twatchs3.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101 twatchs3.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
twatchs3.menu.Revision.Radio_LR1121=Radio-LR1121
twatchs3.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
twatchs3.menu.Revision.Radio_SI4432=Radio-SI4432
twatchs3.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
############################################################## ##############################################################
@ -6442,13 +6446,16 @@ twatch_ultra.menu.EraseFlash.none.upload.erase_cmd=
twatch_ultra.menu.EraseFlash.all=Enabled twatch_ultra.menu.EraseFlash.all=Enabled
twatch_ultra.menu.EraseFlash.all.upload.erase_cmd=-e twatch_ultra.menu.EraseFlash.all.upload.erase_cmd=-e
twatch_ultra.menu.Revision.Radio_SX1280=Radio-SX1280
twatch_ultra.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
twatch_ultra.menu.Revision.Radio_SX1262=Radio-SX1262 twatch_ultra.menu.Revision.Radio_SX1262=Radio-SX1262
twatch_ultra.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262 twatch_ultra.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262
twatch_ultra.menu.Revision.Radio_SX1280=Radio-SX1280
twatch_ultra.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
twatch_ultra.menu.Revision.Radio_CC1101=Radio-CC1101 twatch_ultra.menu.Revision.Radio_CC1101=Radio-CC1101
twatch_ultra.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101 twatch_ultra.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
twatch_ultra.menu.Revision.Radio_LR1121=Radio-LR1121
twatch_ultra.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
twatch_ultra.menu.Revision.Radio_SI4432=Radio-SI4432
twatch_ultra.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
############################################################## ##############################################################
@ -6604,12 +6611,16 @@ tlora_pager.menu.EraseFlash.all=Enabled
tlora_pager.menu.EraseFlash.all.upload.erase_cmd=-e tlora_pager.menu.EraseFlash.all.upload.erase_cmd=-e
tlora_pager.menu.Revision.Radio_SX1280=Radio-SX1280
tlora_pager.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
tlora_pager.menu.Revision.Radio_SX1262=Radio-SX1262 tlora_pager.menu.Revision.Radio_SX1262=Radio-SX1262
tlora_pager.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262 tlora_pager.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262
tlora_pager.menu.Revision.Radio_SX1280=Radio-SX1280
tlora_pager.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
tlora_pager.menu.Revision.Radio_CC1101=Radio-CC1101 tlora_pager.menu.Revision.Radio_CC1101=Radio-CC1101
tlora_pager.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101 tlora_pager.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
tlora_pager.menu.Revision.Radio_LR1121=Radio-LR1121
tlora_pager.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
tlora_pager.menu.Revision.Radio_SI4432=Radio-SI4432
tlora_pager.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
############################################################## ##############################################################
@ -43477,20 +43488,22 @@ alfredo-nou3.menu.EraseFlash.all=Enabled
alfredo-nou3.menu.EraseFlash.all.upload.erase_cmd=-e alfredo-nou3.menu.EraseFlash.all.upload.erase_cmd=-e
############################################################## ##############################################################
codecell.name=CodeCell codecell.name=CodeCell C3
codecell.vid.0=0x303a
codecell.pid.0=0x1002
codecell.upload_port.0.vid=0x303a
codecell.upload_port.0.pid=0x1002
codecell.bootloader.tool=esptool_py codecell.bootloader.tool=esptool_py
codecell.bootloader.tool.default=esptool_py
codecell.upload.tool=esptool_py codecell.upload.tool=esptool_py
codecell.upload.maximum_size=4194304 codecell.upload.tool.default=esptool_py
codecell.upload.tool.network=esp_ota
codecell.upload.maximum_size=1310720
codecell.upload.maximum_data_size=327680 codecell.upload.maximum_data_size=327680
codecell.upload.flags=
codecell.upload.extra_flags=
codecell.upload.use_1200bps_touch=false codecell.upload.use_1200bps_touch=false
codecell.upload.wait_for_upload_port=false codecell.upload.wait_for_upload_port=false
codecell.upload.speed=921600
codecell.serial.disableDTR=false codecell.serial.disableDTR=false
codecell.serial.disableRTS=false codecell.serial.disableRTS=false
@ -43499,8 +43512,9 @@ codecell.build.target=esp
codecell.build.mcu=esp32c3 codecell.build.mcu=esp32c3
codecell.build.core=esp32 codecell.build.core=esp32
codecell.build.variant=codecell codecell.build.variant=codecell
codecell.build.board=ESP32C3_DEV codecell.build.board=CODECELLC3
codecell.build.bootloader_addr=0x0 codecell.build.bootloader_addr=0x0
codecell.build.cdc_on_boot=1 codecell.build.cdc_on_boot=1
codecell.build.f_cpu=160000000L codecell.build.f_cpu=160000000L
codecell.build.flash_size=4MB codecell.build.flash_size=4MB
@ -43508,13 +43522,118 @@ codecell.build.flash_freq=80m
codecell.build.flash_mode=qio codecell.build.flash_mode=qio
codecell.build.boot=qio codecell.build.boot=qio
codecell.build.partitions=default codecell.build.partitions=default
codecell.build.defines=
codecell.menu.JTAGAdapter.default=Disabled
codecell.menu.JTAGAdapter.default.build.copy_jtag_files=0
codecell.menu.JTAGAdapter.builtin=Integrated USB JTAG
codecell.menu.JTAGAdapter.builtin.build.openocdscript=esp32c3-builtin.cfg
codecell.menu.JTAGAdapter.builtin.build.copy_jtag_files=1
codecell.menu.JTAGAdapter.external=FTDI Adapter
codecell.menu.JTAGAdapter.external.build.openocdscript=esp32c3-ftdi.cfg
codecell.menu.JTAGAdapter.external.build.copy_jtag_files=1
codecell.menu.JTAGAdapter.bridge=ESP USB Bridge
codecell.menu.JTAGAdapter.bridge.build.openocdscript=esp32c3-bridge.cfg
codecell.menu.JTAGAdapter.bridge.build.copy_jtag_files=1
codecell.menu.CDCOnBoot.default=Enabled
codecell.menu.CDCOnBoot.default.build.cdc_on_boot=0
codecell.menu.CDCOnBoot.cdc=Enabled
codecell.menu.CDCOnBoot.cdc.build.cdc_on_boot=1
codecell.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS) codecell.menu.PartitionScheme.default=Default 4MB with spiffs (1.2MB APP/1.5MB SPIFFS)
codecell.menu.CPUFreq.160=160MHz codecell.menu.PartitionScheme.default.build.partitions=default
codecell.menu.PartitionScheme.defaultffat=Default 4MB with ffat (1.2MB APP/1.5MB FATFS)
codecell.menu.PartitionScheme.defaultffat.build.partitions=default_ffat
codecell.menu.PartitionScheme.minimal=Minimal (1.3MB APP/700KB SPIFFS)
codecell.menu.PartitionScheme.minimal.build.partitions=minimal
codecell.menu.PartitionScheme.no_fs=No FS 4MB (2MB APP x2)
codecell.menu.PartitionScheme.no_fs.build.partitions=no_fs
codecell.menu.PartitionScheme.no_fs.upload.maximum_size=2031616
codecell.menu.PartitionScheme.no_ota=No OTA (2MB APP/2MB SPIFFS)
codecell.menu.PartitionScheme.no_ota.build.partitions=no_ota
codecell.menu.PartitionScheme.no_ota.upload.maximum_size=2097152
codecell.menu.PartitionScheme.noota_3g=No OTA (1MB APP/3MB SPIFFS)
codecell.menu.PartitionScheme.noota_3g.build.partitions=noota_3g
codecell.menu.PartitionScheme.noota_3g.upload.maximum_size=1048576
codecell.menu.PartitionScheme.noota_ffat=No OTA (2MB APP/2MB FATFS)
codecell.menu.PartitionScheme.noota_ffat.build.partitions=noota_ffat
codecell.menu.PartitionScheme.noota_ffat.upload.maximum_size=2097152
codecell.menu.PartitionScheme.noota_3gffat=No OTA (1MB APP/3MB FATFS)
codecell.menu.PartitionScheme.noota_3gffat.build.partitions=noota_3gffat
codecell.menu.PartitionScheme.noota_3gffat.upload.maximum_size=1048576
codecell.menu.PartitionScheme.huge_app=Huge APP (3MB No OTA/1MB SPIFFS)
codecell.menu.PartitionScheme.huge_app.build.partitions=huge_app
codecell.menu.PartitionScheme.huge_app.upload.maximum_size=3145728
codecell.menu.PartitionScheme.min_spiffs=Minimal SPIFFS (1.9MB APP with OTA/190KB SPIFFS)
codecell.menu.PartitionScheme.min_spiffs.build.partitions=min_spiffs
codecell.menu.PartitionScheme.min_spiffs.upload.maximum_size=1966080
codecell.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
codecell.menu.PartitionScheme.fatflash.build.partitions=ffat
codecell.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
codecell.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS)
codecell.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
codecell.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
codecell.menu.PartitionScheme.rainmaker=RainMaker 4MB
codecell.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
codecell.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080
codecell.menu.PartitionScheme.rainmaker_4MB=RainMaker 4MB No OTA
codecell.menu.PartitionScheme.rainmaker_4MB.build.partitions=rainmaker_4MB_no_ota
codecell.menu.PartitionScheme.rainmaker_4MB.upload.maximum_size=4038656
codecell.menu.PartitionScheme.rainmaker_8MB=RainMaker 8MB
codecell.menu.PartitionScheme.rainmaker_8MB.build.partitions=rainmaker_8MB
codecell.menu.PartitionScheme.rainmaker_8MB.upload.maximum_size=4116480
codecell.menu.PartitionScheme.zigbee_zczr=Zigbee ZCZR 4MB with spiffs
codecell.menu.PartitionScheme.zigbee_zczr.build.partitions=zigbee_zczr
codecell.menu.PartitionScheme.zigbee_zczr.upload.maximum_size=1310720
codecell.menu.PartitionScheme.zigbee_zczr_8MB=Zigbee ZCZR 8MB with spiffs
codecell.menu.PartitionScheme.zigbee_zczr_8MB.build.partitions=zigbee_zczr_8MB
codecell.menu.PartitionScheme.zigbee_zczr_8MB.upload.maximum_size=3407872
codecell.menu.PartitionScheme.custom=Custom
codecell.menu.PartitionScheme.custom.build.partitions=
codecell.menu.PartitionScheme.custom.upload.maximum_size=16777216
codecell.menu.CPUFreq.160=160MHz (WiFi)
codecell.menu.CPUFreq.160.build.f_cpu=160000000L
codecell.menu.CPUFreq.80=80MHz (WiFi)
codecell.menu.CPUFreq.80.build.f_cpu=80000000L
codecell.menu.CPUFreq.40=40MHz
codecell.menu.CPUFreq.40.build.f_cpu=40000000L
codecell.menu.CPUFreq.20=20MHz
codecell.menu.CPUFreq.20.build.f_cpu=20000000L
codecell.menu.CPUFreq.10=10MHz
codecell.menu.CPUFreq.10.build.f_cpu=10000000L
codecell.menu.FlashMode.qio=QIO codecell.menu.FlashMode.qio=QIO
codecell.menu.FlashMode.qio.build.flash_mode=dio
codecell.menu.FlashMode.qio.build.boot=qio
codecell.menu.FlashMode.dio=DIO
codecell.menu.FlashMode.dio.build.flash_mode=dio
codecell.menu.FlashMode.dio.build.boot=dio
codecell.menu.FlashFreq.80=80MHz codecell.menu.FlashFreq.80=80MHz
codecell.menu.FlashFreq.80.build.flash_freq=80m
codecell.menu.FlashFreq.40=40MHz
codecell.menu.FlashFreq.40.build.flash_freq=40m
codecell.menu.FlashSize.4M=4MB (32Mb) codecell.menu.FlashSize.4M=4MB (32Mb)
codecell.menu.FlashSize.4M.build.flash_size=4MB
codecell.menu.UploadSpeed.921600=921600 codecell.menu.UploadSpeed.921600=921600
codecell.menu.UploadSpeed.921600.upload.speed=921600
codecell.menu.UploadSpeed.115200=115200
codecell.menu.UploadSpeed.115200.upload.speed=115200
codecell.menu.UploadSpeed.256000.windows=256000
codecell.menu.UploadSpeed.256000.upload.speed=256000
codecell.menu.UploadSpeed.230400.windows.upload.speed=256000
codecell.menu.UploadSpeed.230400=230400
codecell.menu.UploadSpeed.230400.upload.speed=230400
codecell.menu.UploadSpeed.460800.linux=460800
codecell.menu.UploadSpeed.460800.macosx=460800
codecell.menu.UploadSpeed.460800.upload.speed=460800
codecell.menu.UploadSpeed.512000.windows=512000
codecell.menu.UploadSpeed.512000.upload.speed=512000
codecell.menu.DebugLevel.none=None codecell.menu.DebugLevel.none=None
codecell.menu.DebugLevel.none.build.code_debug=0 codecell.menu.DebugLevel.none.build.code_debug=0
@ -43534,6 +43653,12 @@ codecell.menu.EraseFlash.none.upload.erase_cmd=
codecell.menu.EraseFlash.all=Enabled codecell.menu.EraseFlash.all=Enabled
codecell.menu.EraseFlash.all.upload.erase_cmd=-e codecell.menu.EraseFlash.all.upload.erase_cmd=-e
codecell.menu.ZigbeeMode.default=Disabled
codecell.menu.ZigbeeMode.default.build.zigbee_mode=
codecell.menu.ZigbeeMode.default.build.zigbee_libs=
codecell.menu.ZigbeeMode.zczr=Zigbee ZCZR (coordinator/router)
codecell.menu.ZigbeeMode.zczr.build.zigbee_mode=-DZIGBEE_MODE_ZCZR
codecell.menu.ZigbeeMode.zczr.build.zigbee_libs=-lesp_zb_api.zczr -lzboss_stack.zczr -lzboss_port.remote
############################################################## ##############################################################
jczn_2432s028r.name=ESP32-2432S028R CYD jczn_2432s028r.name=ESP32-2432S028R CYD

View file

@ -41,7 +41,6 @@
#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
@ -251,4 +250,8 @@ 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_ */

View file

@ -79,6 +79,7 @@ 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
@ -156,23 +157,23 @@ struct spi_struct_t {
// clang-format off // clang-format off
static spi_t _spi_bus_array[] = { static spi_t _spi_bus_array[] = {
#if CONFIG_IDF_TARGET_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S2
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 0, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 1, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 1, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 2, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 2, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4 #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_SPI2_BASE), 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 1, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 1, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C2 #elif CONFIG_IDF_TARGET_ESP32C2
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5 #elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5
{(spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1} {(spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false}
#else #else
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), 0, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI0_BASE), 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 1, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 1, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 2, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 2, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 3, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 3, -1, -1, -1, -1, false}
#endif #endif
}; };
// clang-format on // clang-format on
@ -184,22 +185,22 @@ static spi_t _spi_bus_array[] = {
static spi_t _spi_bus_array[] = { static spi_t _spi_bus_array[] = {
#if CONFIG_IDF_TARGET_ESP32S2 #if CONFIG_IDF_TARGET_ESP32S2
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 0, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 1, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 1, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 2, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 2, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4 #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} {(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}
#elif CONFIG_IDF_TARGET_ESP32C2 #elif CONFIG_IDF_TARGET_ESP32C2
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C3 #elif CONFIG_IDF_TARGET_ESP32C3
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5 #elif CONFIG_IDF_TARGET_ESP32C6 || CONFIG_IDF_TARGET_ESP32H2 || CONFIG_IDF_TARGET_ESP32C5
{(spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1} {(spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
#else #else
{(volatile spi_dev_t *)(DR_REG_SPI0_BASE), NULL, 0, -1, -1, -1, -1}, {(volatile spi_dev_t *)(DR_REG_SPI0_BASE), NULL, 0, -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_SPI1_BASE), NULL, 1, -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_SPI2_BASE), NULL, 2, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 3, -1, -1, -1, -1} {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 3, -1, -1, -1, -1, false}
#endif #endif
}; };
#endif #endif
@ -370,7 +371,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), false, false); pinMatrixOutAttach(ss, SPI_SS_IDX(spi->num, ss_num), spi->ss_invert, 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)) {
@ -440,6 +441,12 @@ 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;

View file

@ -97,6 +97,8 @@ 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);

View file

@ -10,6 +10,11 @@ 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
---------------------------- ----------------------------
@ -32,6 +37,16 @@ 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.

View file

@ -14,6 +14,23 @@ 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
-------- --------

4
idf_component_examples/.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
build/
managed_components/
dependencies.lock
sdkconfig

View file

@ -8,6 +8,7 @@ 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
@ -20,7 +21,7 @@ if(CONFIG_IDF_TARGET_ESP32C2)
include(relinker) include(relinker)
endif() endif()
idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++17;-Os;-DCHIP_HAVE_CONFIG_H" APPEND) idf_build_set_property(CXX_COMPILE_OPTIONS "-std=gnu++2a;-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

View file

@ -59,15 +59,22 @@ Use ESP-IDF 5.1.4 from https://github.com/espressif/esp-idf/tree/release/v5.1
This example has been tested with Arduino Core 3.0.4 This example has been tested with Arduino Core 3.0.4
The project will download all necessary components, including the Arduino Core. The project will download all necessary components, including the Arduino Core.
Run `idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.<SOC>.idf" -p <PORT> flash monitor` Execute this sequence:
`<remove build folder> using linux rm command or Windows rmdir command`
`idf.py set-target <SoC_Target>`
`idf.py -D SDKCONFIG_DEFAULTS="sdkconfig_file1;sdkconfig_file2;sdkconfig_fileX" -p <PORT> flash monitor`
Example for ESP32-S3/Linux | macOS: Example for ESP32-S3/Linux | macOS:
``` ```
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32s3" -p /dev/ttyACM0 flash monitor rm -rf build
idf.py set-target esp32s3
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults" -p /dev/ttyACM0 flash monitor
``` ```
Example for ESP32-C3/Windows: Example for ESP32-C3/Windows:
``` ```
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.esp32c3" -p com3 flash monitor rmdir /s/q build
idf.py set-target esp32c3
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults" -p com3 flash monitor
``` ```
It may be necessary to delete some folders and files before running `idf.py` It may be necessary to delete some folders and files before running `idf.py`
@ -95,11 +102,15 @@ In order to build the application that will use Thread Networking instead of Wi-
Example for ESP32-C6/Linux | macOS: Example for ESP32-C6/Linux | macOS:
``` ```
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.c6_thread" -p /dev/ttyACM0 flash monitor rm -rf build
idf.py set-target esp32c6
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.c6_thread" -p /dev/ttyACM0 flash monitor
``` ```
Example for ESP32-C6/Windows: Example for ESP32-C6/Windows:
``` ```
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults.c6_thread" -p com3 flash monitor rmdir /s/q build
idf.py set-targt esp32c6
idf.py -D SDKCONFIG_DEFAULTS="sdkconfig.defaults;sdkconfig.defaults.c6_thread" -p com3 flash monitor
``` ```
It may be necessary to delete some folders and files before running `idf.py` It may be necessary to delete some folders and files before running `idf.py`

View file

@ -0,0 +1,11 @@
{
"targets": {
"esp32c2": false,
"esp32s2": false
},
"requires": [
"CONFIG_SOC_WIFI_SUPPORTED=y",
"CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y",
"CONFIG_MBEDTLS_HKDF_C=y"
]
}

View file

@ -3,83 +3,32 @@ menu "Light Matter Accessory"
config BUTTON_PIN config BUTTON_PIN
int int
prompt "Button 1 GPIO" prompt "Button 1 GPIO"
default ENV_GPIO_BOOT_BUTTON default 9 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6
default 0
range -1 ENV_GPIO_IN_RANGE_MAX range -1 ENV_GPIO_IN_RANGE_MAX
help help
The GPIO pin for button that will be used to turn on/off the Matter Light. It shall be connected to a push button. It can use the BOOT button of the development board. The GPIO pin for button that will be used to turn on/off the Matter Light. It shall be connected to a push button. It can use the BOOT button of the development board.
endmenu endmenu
menu "LEDs" menu "LEDs"
config WS2812_PIN config WS2812_PIN
int int
prompt "WS2812 RGB LED GPIO" prompt "WS2812 RGB LED GPIO"
default ENV_GPIO_RGB_LED default 8 if IDF_TARGET_ESP32C3 || IDF_TARGET_ESP32C6
default 48
range -1 ENV_GPIO_OUT_RANGE_MAX range -1 ENV_GPIO_OUT_RANGE_MAX
help help
The GPIO pin for the Matter Light that will be driven by RMT. It shall be connected to one single WS2812 RGB LED. The GPIO pin for the Matter Light that will be driven by RMT. It shall be connected to one single WS2812 RGB LED.
endmenu endmenu
# TARGET CONFIGURATION
if IDF_TARGET_ESP32C3
config ENV_GPIO_RANGE_MIN
int
default 0
config ENV_GPIO_RANGE_MAX
int
default 19
# GPIOs 20/21 are always used by UART in examples
config ENV_GPIO_IN_RANGE_MAX
int
default ENV_GPIO_RANGE_MAX
config ENV_GPIO_OUT_RANGE_MAX
int
default ENV_GPIO_RANGE_MAX
config ENV_GPIO_BOOT_BUTTON
int
default 9
config ENV_GPIO_RGB_LED
int
default 8
endif
if IDF_TARGET_ESP32C6
config ENV_GPIO_RANGE_MIN
int
default 0
config ENV_GPIO_RANGE_MAX
int
default 30
# GPIOs 16/17 are always used by UART in examples
config ENV_GPIO_IN_RANGE_MAX
int
default ENV_GPIO_RANGE_MAX
config ENV_GPIO_OUT_RANGE_MAX
int
default ENV_GPIO_RANGE_MAX
config ENV_GPIO_BOOT_BUTTON
int
default 9
config ENV_GPIO_RGB_LED
int
default 8
endif
if IDF_TARGET_ESP32S3
config ENV_GPIO_RANGE_MIN config ENV_GPIO_RANGE_MIN
int int
default 0 default 0
config ENV_GPIO_RANGE_MAX config ENV_GPIO_RANGE_MAX
int int
default 19 if IDF_TARGET_ESP32C3
default 30 if IDF_TARGET_ESP32C6
default 48 default 48
config ENV_GPIO_IN_RANGE_MAX config ENV_GPIO_IN_RANGE_MAX
@ -90,13 +39,4 @@ menu "Light Matter Accessory"
int int
default ENV_GPIO_RANGE_MAX default ENV_GPIO_RANGE_MAX
config ENV_GPIO_BOOT_BUTTON
int
default 0
config ENV_GPIO_RGB_LED
int
default 48
endif
endmenu endmenu

View file

@ -1,9 +1,9 @@
dependencies: dependencies:
espressif/esp_matter: espressif/esp_matter:
version: "^1.3.0" version: ">=1.3.0"
# Adds Arduino Core from GitHub repository using main branch # Adds Arduino Core from GitHub repository using main branch
espressif/arduino-esp32: espressif/arduino-esp32:
version: "^3.0.5" version: ">=3.0.5"
override_path: "../../../" override_path: "../../../"
pre_release: true pre_release: true

View file

@ -1,5 +1,3 @@
CONFIG_IDF_TARGET="esp32c3"
# Arduino Settings # Arduino Settings
CONFIG_FREERTOS_HZ=1000 CONFIG_FREERTOS_HZ=1000
CONFIG_AUTOSTART_ARDUINO=y CONFIG_AUTOSTART_ARDUINO=y

View file

@ -1,68 +1,5 @@
CONFIG_IDF_TARGET="esp32c6" CONFIG_IDF_TARGET="esp32c6"
# Arduino Settings
CONFIG_FREERTOS_HZ=1000
CONFIG_AUTOSTART_ARDUINO=y
# Log Levels
# Boot Messages - Log level
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
# Arduino Log Level
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
# IDF Log Level
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
# Default to 921600 baud when flashing and monitoring device
CONFIG_ESPTOOLPY_BAUD_921600B=y
CONFIG_ESPTOOLPY_BAUD=921600
CONFIG_ESPTOOLPY_COMPRESSED=y
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
#disable BT connection reattempt
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0xC000
# Disable chip shell
CONFIG_ENABLE_CHIP_SHELL=n
# Enable OTA Requester
CONFIG_ENABLE_OTA_REQUESTOR=n
#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
# disable softap by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
CONFIG_ENABLE_WIFI_STATION=y
CONFIG_ENABLE_WIFI_AP=n
# Disable DS Peripheral
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
# Use compact attribute storage mode
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6
# libsodium # libsodium
CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y

View file

@ -1,64 +0,0 @@
CONFIG_IDF_TARGET="esp32s3"
# Arduino Settings
CONFIG_FREERTOS_HZ=1000
CONFIG_AUTOSTART_ARDUINO=y
# Log Levels
# Boot Messages - Log level
CONFIG_BOOTLOADER_LOG_LEVEL_ERROR=y
# Arduino Log Level
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_INFO=y
# IDF Log Level
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y
# Default to 921600 baud when flashing and monitoring device
CONFIG_ESPTOOLPY_BAUD_921600B=y
CONFIG_ESPTOOLPY_BAUD=921600
CONFIG_ESPTOOLPY_COMPRESSED=y
CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y
CONFIG_ESPTOOLPY_MONITOR_BAUD=115200
CONFIG_ESPTOOLPY_FLASHSIZE_4MB=y
#enable BT
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
#disable BT connection reattempt
CONFIG_BT_NIMBLE_ENABLE_CONN_REATTEMPT=n
#enable lwip ipv6 autoconfig
CONFIG_LWIP_IPV6_AUTOCONFIG=y
# Use a custom partition table
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_FILENAME="partitions.csv"
CONFIG_PARTITION_TABLE_OFFSET=0xC000
# Disable chip shell
CONFIG_ENABLE_CHIP_SHELL=n
# Enable OTA Requester
CONFIG_ENABLE_OTA_REQUESTOR=n
#enable lwIP route hooks
CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT=y
CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT=y
# disable softap by default
CONFIG_ESP_WIFI_SOFTAP_SUPPORT=n
CONFIG_ENABLE_WIFI_STATION=y
CONFIG_ENABLE_WIFI_AP=n
# Disable DS Peripheral
CONFIG_ESP_SECURE_CERT_DS_PERIPHERAL=n
# Use compact attribute storage mode
CONFIG_ESP_MATTER_NVS_USE_COMPACT_ATTR_STORAGE=y
# Enable HKDF in mbedtls
CONFIG_MBEDTLS_HKDF_C=y
# Increase LwIP IPv6 address number to 6 (MAX_FABRIC + 1)
# unique local addresses for fabrics(MAX_FABRIC), a link local address(1)
CONFIG_LWIP_IPV6_NUM_ADDRESSES=6

View file

@ -5,4 +5,6 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
idf_build_set_property(MINIMAL_BUILD ON)
project(main) project(main)

View file

@ -9,4 +9,5 @@ include($ENV{IDF_PATH}/tools/cmake/project.cmake)
list(APPEND compile_definitions "ARDUINO_USB_CDC_ON_BOOT=1") list(APPEND compile_definitions "ARDUINO_USB_CDC_ON_BOOT=1")
list(APPEND compile_definitions "ARDUINO_USB_MODE=1") list(APPEND compile_definitions "ARDUINO_USB_MODE=1")
idf_build_set_property(MINIMAL_BUILD ON)
project(hw_cdc_hello_world) project(hw_cdc_hello_world)

View file

@ -0,0 +1,5 @@
{
"requires": [
"CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED=y"
]
}

View file

@ -1,4 +1,4 @@
// Copyright 2023 Espressif Systems (Shanghai) PTE LTD // Copyright 2025 Espressif Systems (Shanghai) PTE LTD
// //
// Licensed under the Apache License, Version 2.0 (the "License"); // Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License. // you may not use this file except in compliance with the License.
@ -13,16 +13,16 @@
// limitations under the License. // limitations under the License.
/** /**
* @brief This example demonstrate how to use RMT to just blink a regular LED (GPIO) @brief This example demonstrate how to use RMT to just blink a regular LED (GPIO)
* It uses all the different RMT Writing APIs to blink the LED by hardware, not being It uses all the different RMT Writing APIs to blink the LED by hardware, not being
* necessary the regular Blink code in Arduino. necessary the regular Blink code in Arduino.
*
* The output is the Blinking LED in the GPIO and a serial output describing what is The output is the Blinking LED in the GPIO and a serial output describing what is
* going on, along the execution. going on, along the execution.
*
* The circuit is just a LED and a resistor of 270 ohms connected to the GPIO The circuit is just a LED and a resistor of 270 ohms connected to the GPIO
* GPIO ---> resistor 270 ohms ---> + LED - ---> GND GPIO ---> resistor 270 ohms ---> + LED - ---> GND
*/ */
#define BLINK_GPIO 2 #define BLINK_GPIO 2
@ -232,7 +232,7 @@ void RMT_Mixed_Write_Blink() {
Serial.println("===> rmtWrite() (Blocking Mode) to Blink the LED."); Serial.println("===> rmtWrite() (Blocking Mode) to Blink the LED.");
Serial.println("Blinking at 500ms on + 500ms off :: 4 blinks"); Serial.println("Blinking at 500ms on + 500ms off :: 4 blinks");
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
if (!rmtWrite(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 2, RMT_WAIT_FOR_EVER)) { if (!rmtWrite(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 1, RMT_WAIT_FOR_EVER)) {
Serial.println("===> rmtWrite Blink 0.5s Error!"); Serial.println("===> rmtWrite Blink 0.5s Error!");
} }
} }
@ -240,7 +240,7 @@ void RMT_Mixed_Write_Blink() {
Serial.println("===> rmtWriteAsync() (Non-Blocking Mode) to Blink the LED."); Serial.println("===> rmtWriteAsync() (Non-Blocking Mode) to Blink the LED.");
Serial.println("Blinking at 250ms on + 250ms off :: 5 blinks"); Serial.println("Blinking at 250ms on + 250ms off :: 5 blinks");
for (uint8_t i = 0; i < 5; i++) { for (uint8_t i = 0; i < 5; i++) {
if (!rmtWriteAsync(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 2)) { if (!rmtWriteAsync(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 1)) {
Serial.println("===> rmtWrite Blink 0.25s Error!"); Serial.println("===> rmtWrite Blink 0.25s Error!");
} }
// wait (blocks) until all the data is sent out // wait (blocks) until all the data is sent out
@ -267,9 +267,11 @@ void RMT_Loop_Write_Blink() {
Serial.println("===> rmtWriteLooping Blink 0.25s Error!"); Serial.println("===> rmtWriteLooping Blink 0.25s Error!");
} }
delay(5000); delay(5000);
Serial.println("Blinking OFF for 2 seconds"); Serial.println("Blinking OFF for 2 seconds");
if (!rmtWriteLooping(BLINK_GPIO, NULL, 0)) { rmt_data_t blink_STOP_rmt_data[] = {{0, 0, 0, 0}};
Serial.println("===> rmtWriteLooping Blink OFF Error!"); if (!rmtWrite(BLINK_GPIO, blink_STOP_rmt_data, RMT_SYMBOLS_OF(blink_STOP_rmt_data), RMT_WAIT_FOR_EVER)) {
Serial.println("===> rmtWrite Blink STOP Error!");
} }
delay(2000); delay(2000);
} }
@ -278,19 +280,19 @@ void RMT_Single_Write_Blocking_Blink() {
Serial.println("Using RMT Writing and its Completion to blink an LED."); Serial.println("Using RMT Writing and its Completion to blink an LED.");
Serial.println("Blinking at 1s on + 1s off :: 2 blinks"); Serial.println("Blinking at 1s on + 1s off :: 2 blinks");
for (uint8_t i = 0; i < 2; i++) { for (uint8_t i = 0; i < 2; i++) {
if (!rmtWrite(BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF(blink_1s_rmt_data) - 2, RMT_WAIT_FOR_EVER)) { if (!rmtWrite(BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF(blink_1s_rmt_data) - 1, RMT_WAIT_FOR_EVER)) {
Serial.println("===> rmtWrite Blink 1s Error!"); Serial.println("===> rmtWrite Blink 1s Error!");
} }
} }
Serial.println("Blinking at 500ms on + 500ms off :: 4 blinks"); Serial.println("Blinking at 500ms on + 500ms off :: 4 blinks");
for (uint8_t i = 0; i < 4; i++) { for (uint8_t i = 0; i < 4; i++) {
if (!rmtWrite(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 2, RMT_WAIT_FOR_EVER)) { if (!rmtWrite(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 1, RMT_WAIT_FOR_EVER)) {
Serial.println("===> rmtWrite Blink 0.5s Error!"); Serial.println("===> rmtWrite Blink 0.5s Error!");
} }
} }
Serial.println("Blinking at 250ms on + 250ms off :: 8 blinks"); Serial.println("Blinking at 250ms on + 250ms off :: 8 blinks");
for (uint8_t i = 0; i < 8; i++) { for (uint8_t i = 0; i < 8; i++) {
if (!rmtWrite(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 2, RMT_WAIT_FOR_EVER)) { if (!rmtWrite(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 1, RMT_WAIT_FOR_EVER)) {
Serial.println("===> rmtWrite Blink 0.25s Error!"); Serial.println("===> rmtWrite Blink 0.25s Error!");
} }
} }
@ -302,7 +304,7 @@ void RMT_Write_Aync_Non_Blocking_Blink() {
Serial.println("Using RMT Async Writing and its Completion to blink an LED."); Serial.println("Using RMT Async Writing and its Completion to blink an LED.");
Serial.println("Blinking at 1s on + 1s off :: 5 blinks"); Serial.println("Blinking at 1s on + 1s off :: 5 blinks");
for (uint8_t i = 0; i < 5; i++) { for (uint8_t i = 0; i < 5; i++) {
if (!rmtWriteAsync(BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF(blink_1s_rmt_data) - 2)) { if (!rmtWriteAsync(BLINK_GPIO, blink_1s_rmt_data, RMT_SYMBOLS_OF(blink_1s_rmt_data) - 1)) {
Serial.println("===> rmtWrite Blink 1s Error!"); Serial.println("===> rmtWrite Blink 1s Error!");
} }
// wait (blocks) until all the data is sent out // wait (blocks) until all the data is sent out
@ -310,7 +312,7 @@ void RMT_Write_Aync_Non_Blocking_Blink() {
} }
Serial.println("Blinking at 500ms on + 500ms off :: 5 blinks"); Serial.println("Blinking at 500ms on + 500ms off :: 5 blinks");
for (uint8_t i = 0; i < 5; i++) { for (uint8_t i = 0; i < 5; i++) {
if (!rmtWriteAsync(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 2)) { if (!rmtWriteAsync(BLINK_GPIO, blink_500ms_rmt_data, RMT_SYMBOLS_OF(blink_500ms_rmt_data) - 1)) {
Serial.println("===> rmtWrite Blink 0.5s Error!"); Serial.println("===> rmtWrite Blink 0.5s Error!");
} }
// wait (blocks) until all the data is sent out // wait (blocks) until all the data is sent out
@ -318,7 +320,7 @@ void RMT_Write_Aync_Non_Blocking_Blink() {
} }
Serial.println("Blinking at 250ms on + 250ms off :: 5 blinks"); Serial.println("Blinking at 250ms on + 250ms off :: 5 blinks");
for (uint8_t i = 0; i < 5; i++) { for (uint8_t i = 0; i < 5; i++) {
if (!rmtWriteAsync(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 2)) { if (!rmtWriteAsync(BLINK_GPIO, blink_250ms_rmt_data, RMT_SYMBOLS_OF(blink_250ms_rmt_data) - 1)) {
Serial.println("===> rmtWrite Blink 0.25s Error!"); Serial.println("===> rmtWrite Blink 0.25s Error!");
} }
// wait (blocks) until all the data is sent out // wait (blocks) until all the data is sent out
@ -345,7 +347,6 @@ void setup() {
RMT_Mixed_Write_Blink(); RMT_Mixed_Write_Blink();
Serial.println("End of Mixed Calls testing"); Serial.println("End of Mixed Calls testing");
delay(1000);
Serial.println("\n==============================="); Serial.println("\n===============================");
Serial.println("Starting a Blinking sequence..."); Serial.println("Starting a Blinking sequence...");

View file

@ -5,20 +5,20 @@
void HardwareSerial::onReceive(OnReceiveCb function, bool onlyOnTimeout = false) void HardwareSerial::onReceive(OnReceiveCb function, bool onlyOnTimeout = false)
It is possible to register an UART callback function that will be called It is possible to register an UART callback function that will be called
every time that UART receives data and an associated interrupt is generated. every time that UART receives data and an associated UART interrupt is generated.
In summary, HardwareSerial::onReceive() works like an RX Interrupt callback, that can be adjusted In summary, HardwareSerial::onReceive() works like an RX Interrupt callback, that
using HardwareSerial::setRxFIFOFull() and HardwareSerial::setRxTimeout(). can be adjusted using HardwareSerial::setRxFIFOFull() and HardwareSerial::setRxTimeout().
OnReceive will be called, while receiving a stream of data, when every 120 bytes are received (default FIFO Full), In case that <onlyOnTimeout> is not changed or it is set to <false>, the callback function is
which may not help in case that the application needs to get all data at once before processing it. executed whenever any event happens first (FIFO Full or RX Timeout).
Therefore, a way to make it work is by detecting the end of a stream transmission. This can be based on a protocol OnReceive will be called when every 120 bytes are received(default FIFO Full),
or based on timeout with the UART line in idle (no data received - this is the case of this example). or when RX Timeout occurs after 1 UART symbol by default.
In some cases, it is necessary to wait for receiving all the data before processing it and parsing the This example demonstrates a way to create a String with all data received from UART0 only
UART input. This example demonstrates a way to create a String with all data received from UART0 and after RX Timeout. This example uses an RX timeout of about 3.5 Symbols as a way to know
signaling it using a Mutex for another task to process it. This example uses a timeout of 500ms as a way to when the reception of data has finished.
know when the reception of data has finished. In order to achieve it, the sketch sets <onlyOnTimeout> to <true>.
The onReceive() callback is called whenever the RX ISR is triggered. The onReceive() callback is called whenever the RX ISR is triggered.
It can occur because of two possible events: It can occur because of two possible events:
@ -34,90 +34,73 @@
2- UART RX Timeout: it happens, based on a timeout equivalent to a number of symbols at 2- UART RX Timeout: it happens, based on a timeout equivalent to a number of symbols at
the current baud rate. If the UART line is idle for this timeout, it will raise an interrupt. the current baud rate. If the UART line is idle for this timeout, it will raise an interrupt.
This time can be changed by HardwareSerial::setRxTimeout(uint8_t rxTimeout) This time can be changed by HardwareSerial::setRxTimeout(uint8_t rxTimeout).
<rxTimeout> is bound to the clock source.
In order to use it properly, ESP32 and ESP32-S2 shall set the UART Clock Source to APB.
When any of those two interrupts occur, IDF UART driver will copy FIFO data to its internal When any of those two interrupts occur, IDF UART driver will copy FIFO data to its internal
RingBuffer and then Arduino can read such data. At the same time, Arduino Layer will execute RingBuffer and then Arduino can read such data. At the same time, Arduino Layer will execute
the callback function defined with HardwareSerial::onReceive(). the callback function defined with HardwareSerial::onReceive().
<bool onlyOnTimeout> parameter (default false) can be used by the application to tell Arduino to <bool onlyOnTimeout> parameter can be used by the application to tell Arduino to only execute
only execute the callback when the second event above happens (Rx Timeout). At this time all the callback when Rx Timeout happens, by setting it to <true>.
received data will be available to be read by the Arduino application. But if the number of At this time all received data will be available to be read by the Arduino application.
received bytes is higher than the FIFO space, it will generate an error of FIFO overflow. The application shall set an appropriate RX buffer size using
In order to avoid such problem, the application shall set an appropriate RX buffer size using
HardwareSerial::setRxBufferSize(size_t new_size) before executing begin() for the Serial port. HardwareSerial::setRxBufferSize(size_t new_size) before executing begin() for the Serial port.
*/
// this will make UART0 work in any case (using or not USB) MODBUS timeout of 3.5 symbol is based on these documents:
#if ARDUINO_USB_CDC_ON_BOOT https://www.automation.com/en-us/articles/2012-1/introduction-to-modbus
#define UART0 Serial0 https://minimalmodbus.readthedocs.io/en/stable/serialcommunication.html
#else */
#define UART0 Serial
#endif
// global variable to keep the results from onReceive() // global variable to keep the results from onReceive()
String uart_buffer = ""; String uart_buffer = "";
// a pause of a half second in the UART transmission is considered the end of transmission. // The Modbus RTU standard prescribes a silent period corresponding to 3.5 characters between each
const uint32_t communicationTimeout_ms = 500; // message, to be able to figure out where one message ends and the next one starts.
const uint32_t modbusRxTimeoutLimit = 4;
const uint32_t baudrate = 19200;
// Create a mutex for the access to uart_buffer // UART_RX_IRQ will be executed as soon as data is received by the UART and an RX Timeout occurs
// only one task can read/write it at a certain time // This is a callback function executed from a high priority monitor task
SemaphoreHandle_t uart_buffer_Mutex = NULL; // All data will be buffered into RX Buffer, which may have its size set to whatever necessary
// UART_RX_IRQ will be executed as soon as data is received by the UART
// This is a callback function executed from a high priority
// task created when onReceive() is used
void UART0_RX_CB() { void UART0_RX_CB() {
// take the mutex, waits forever until loop() finishes its processing while (Serial0.available()) {
if (xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) { uart_buffer += (char)Serial0.read();
uint32_t now = millis(); // tracks timeout
while ((millis() - now) < communicationTimeout_ms) {
if (UART0.available()) {
uart_buffer += (char)UART0.read();
now = millis(); // reset the timer
}
}
// releases the mutex for data processing
xSemaphoreGive(uart_buffer_Mutex);
} }
} }
// setup() and loop() are functions executed by a low priority task // setup() and loop() are functions executed by a low priority task
// Therefore, there are 2 tasks running when using onReceive() // Therefore, there are 2 tasks running when using onReceive()
void setup() { void setup() {
UART0.begin(115200); // Using Serial0 will work in any case (using or not USB CDC on Boot)
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2
// creates a mutex object to control access to uart_buffer // UART_CLK_SRC_APB will allow higher values of RX Timeout
uart_buffer_Mutex = xSemaphoreCreateMutex(); // default for ESP32 and ESP32-S2 is REF_TICK which limits the RX Timeout to 1
if (uart_buffer_Mutex == NULL) { // setClockSource() must be called before begin()
log_e("Error creating Mutex. Sketch will fail."); Serial0.setClockSource(UART_CLK_SRC_APB);
while (true) { #endif
UART0.println("Mutex error (NULL). Program halted."); // the amount of data received or waiting to be proessed shall not exceed this limit of 1024 bytes
delay(2000); Serial0.setRxBufferSize(1024); // default is 256 bytes
} Serial0.begin(baudrate); // default pins and default mode 8N1 (8 bits data, no parity bit, 1 stopbit)
} // set RX Timeout based on UART symbols ~ 3.5 symbols of 11 bits (MODBUS standard) ~= 2 ms at 19200
Serial0.setRxTimeout(modbusRxTimeoutLimit); // 4 symbols at 19200 8N1 is about 2.08 ms (40 bits)
UART0.onReceive(UART0_RX_CB); // sets the callback function // sets the callback function that will be executed only after RX Timeout
UART0.println("Send data to UART0 in order to activate the RX callback"); Serial0.onReceive(UART0_RX_CB, true);
Serial0.println("Send data using Serial Monitor in order to activate the RX callback");
} }
uint32_t counter = 0; uint32_t counter = 0;
void loop() { void loop() {
// String <uart_buffer> is filled by the UART Callback whenever data is received and RX Timeout occurs
if (uart_buffer.length() > 0) { if (uart_buffer.length() > 0) {
// signals that the onReceive function shall not change uart_buffer while processing // process the received data from Serial - example, just print it beside a counter
if (xSemaphoreTake(uart_buffer_Mutex, portMAX_DELAY)) { Serial0.print("[");
// process the received data from UART0 - example, just print it beside a counter Serial0.print(counter++);
UART0.print("["); Serial0.print("] [");
UART0.print(counter++); Serial0.print(uart_buffer.length());
UART0.print("] ["); Serial0.print(" bytes] ");
UART0.print(uart_buffer.length()); Serial0.println(uart_buffer);
UART0.print(" bytes] ");
UART0.println(uart_buffer);
uart_buffer = ""; // reset uart_buffer for the next UART reading uart_buffer = ""; // reset uart_buffer for the next UART reading
// releases the mutex for more data to be received
xSemaphoreGive(uart_buffer_Mutex);
} }
} delay(1);
UART0.println("Sleeping for 1 second...");
delay(1000);
} }

View file

@ -144,6 +144,12 @@ void SPIClass::setHwCs(bool use) {
_use_hw_ss = use; _use_hw_ss = use;
} }
void SPIClass::setSSInvert(bool invert) {
if (_spi) {
spiSSInvert(_spi, invert);
}
}
void SPIClass::setFrequency(uint32_t freq) { void SPIClass::setFrequency(uint32_t freq) {
SPI_PARAM_LOCK(); SPI_PARAM_LOCK();
//check if last freq changed //check if last freq changed

View file

@ -65,6 +65,7 @@ public:
void end(); void end();
void setHwCs(bool use); void setHwCs(bool use);
void setSSInvert(bool invert); //use before setHwCS for change to be used by setHwCs
void setBitOrder(uint8_t bitOrder); void setBitOrder(uint8_t bitOrder);
void setDataMode(uint8_t dataMode); void setDataMode(uint8_t dataMode);
void setFrequency(uint32_t freq); void setFrequency(uint32_t freq);

View file

@ -20,9 +20,9 @@
static const uint8_t TX = 43; static const uint8_t TX = 43;
static const uint8_t RX = 44; static const uint8_t RX = 44;
//BHI260,PCF85063,BQ25896,DRV2605L,ES8311 share I2C Bus // BHI260,PCF85063,BQ25896,DRV2605L,ES8311 share I2C Bus
static const uint8_t SDA = 2; static const uint8_t SDA = 3;
static const uint8_t SCL = 3; static const uint8_t SCL = 2;
// Default sd cs pin // Default sd cs pin
static const uint8_t SS = SD_CS; static const uint8_t SS = SD_CS;
@ -81,10 +81,12 @@ static const uint8_t SCK = 35;
#define EXPANDS_LORA_EN (3) #define EXPANDS_LORA_EN (3)
#define EXPANDS_GPS_EN (4) #define EXPANDS_GPS_EN (4)
#define EXPANDS_NFC_EN (5) #define EXPANDS_NFC_EN (5)
#define EXPANDS_DISP_RST (6)
#define EXPANDS_GPS_RST (7) #define EXPANDS_GPS_RST (7)
#define EXPANDS_KB_EN (8) #define EXPANDS_KB_EN (8)
#define EXPANDS_GPIO_EN (9) #define EXPANDS_GPIO_EN (9)
#define EXPANDS_SD_DET (10)
#define EXPANDS_SD_PULLEN (11)
#define EXPANDS_SD_EN (12)
// Peripheral definition exists // Peripheral definition exists
#define USING_AUDIO_CODEC #define USING_AUDIO_CODEC

View file

@ -44,7 +44,7 @@
static const uint8_t TX = 42; static const uint8_t TX = 42;
static const uint8_t RX = 41; static const uint8_t RX = 41;
//BHI260,PCF85063,AXP2101,DRV2605L,PN532 share I2C Bus // BMA423,PCF8563,AXP2101,DRV2605L share I2C Bus
static const uint8_t SDA = 10; static const uint8_t SDA = 10;
static const uint8_t SCL = 11; static const uint8_t SCL = 11;

View file

@ -22,6 +22,7 @@
#define DISP_D3 (45) #define DISP_D3 (45)
#define DISP_SCK (40) #define DISP_SCK (40)
#define DISP_CS (41) #define DISP_CS (41)
#define DISP_RST (37)
#define DISP_TE (6) #define DISP_TE (6)
// Interrupt IO port // Interrupt IO port
@ -47,9 +48,9 @@
static const uint8_t TX = 43; static const uint8_t TX = 43;
static const uint8_t RX = 44; static const uint8_t RX = 44;
//BHI260,PCF85063,AXP2101,DRV2605L,PN532 share I2C Bus // BHI260,PCF85063,AXP2101,DRV2605L share I2C Bus
static const uint8_t SDA = 2; static const uint8_t SDA = 3;
static const uint8_t SCL = 3; static const uint8_t SCL = 2;
// Default sd cs pin // Default sd cs pin
static const uint8_t SS = SD_CS; static const uint8_t SS = SD_CS;
@ -76,8 +77,8 @@ static const uint8_t SCK = 35;
// External expansion chip IO definition // External expansion chip IO definition
#define EXPANDS_DRV_EN (6) #define EXPANDS_DRV_EN (6)
#define EXPANDS_DISP_EN (7) #define EXPANDS_DISP_EN (7)
#define EXPANDS_TOUCH_RST (10) #define EXPANDS_TOUCH_RST (8)
#define EXPANDS_DISP_RST (11) #define EXPANDS_SD_DET (10)
// Peripheral definition exists // Peripheral definition exists
#define USING_XL9555_EXPANDS #define USING_XL9555_EXPANDS