8000 Merge branch 'master' into pr-fix-3.2.0-pin-remapping · espressif/arduino-esp32@f34a256 · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit f34a256

Browse files
authored
Merge branch 'master' into pr-fix-3.2.0-pin-remapping
2 parents cf179dd + 8d121e0 commit f34a256

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+958
-422
lines changed

.codespellrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[codespell]
22
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/spell-check/.codespellrc
33
# In the event of a false positive, add the problematic word, in all lowercase, to a comma-separated list here:
4-
ignore-words-list = ba,licence,ot,dout,als,exten
4+
ignore-words-list = ba,licence,ot,dout,als,exten,emac
55
skip = ./.git,./.licenses,__pycache__,.clang-format,.codespellrc,.editorconfig,.flake8,.prettierignore,.yamllint.yml,.gitignore,boards.txt,platform.txt,programmers.txt
66
builtin = clear,informal,en-GB_to_en-US
77
check-filenames =

.github/ISSUE_TEMPLATE/Feature-request.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ body:
55
- type: markdown
66
attributes:
77
value: |
8+
* 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.
89
* We welcome any ideas or feature requests! It is helpful if you can explain exactly why the feature would be useful.
910
* 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.
1011
* If you would like to contribute, please read the [contributions guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/contributing.html).

.github/ISSUE_TEMPLATE/Issue-report.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ body:
55
- type: markdown
66
attributes:
77
value: |
8+
* 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.
89
* Before reporting a new issue please check and search in [List of existing issues](https://github.com/espressif/arduino-esp32/issues?q=is%3Aissue)
910
* Please check [Online Documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/index.html)
1011
* Take a look on [Troubleshooting guide](https://docs.espressif.com/projects/arduino-esp32/en/latest/troubleshooting.html)
@@ -39,8 +40,11 @@ body:
3940
label: Version
4041
description: What version of Arduino ESP32 are you running? If possible, consider updating to the latest version.
4142
options:
42-
- latest master (checkout manually)
43+
- latest stable Release (if not listed below)
4344
- latest development Release Candidate (RC-X)
45+
- latest master (checkout manually)
46+
- v3.2.0
47+
- v3.1.3
4448
- v3.1.2
4549
- v3.1.1
4650
- v3.1.0

.github/scripts/on-push-idf.sh

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
CHECK_REQUIREMENTS="./components/arduino-esp32/.github/scripts/sketch_utils.sh check_requirements"
6+
7+
# Export IDF environment
8+
. ${IDF_PATH}/export.sh
9+
10+
# Find all examples in ./components/arduino-esp32/idf_component_examples
11+
idf_component_examples=$(find ./components/arduino-esp32/idf_component_examples -mindepth 1 -maxdepth 1 -type d)
12+
13+
for example in $idf_component_examples; do
14+
if [ -f "$example"/ci.json ]; then
15+
# If the target is listed as false, skip the sketch. Otherwise, include it.
16+
is_target=$(jq -r --arg target "$IDF_TARGET" '.targets[$target]' "$example"/ci.json)
17+
if [[ "$is_target" == "false" ]]; then
18+
printf "\n\033[93mSkipping %s for target %s\033[0m\n\n" "$example" "$IDF_TARGET"
19+
continue
20+
fi
21+
fi
22+
23+
idf.py -C "$example" set-target "$IDF_TARGET"
24+
25+
has_requirements=$(${CHECK_REQUIREMENTS} "$example" "$example/sdkconfig")
26+
if [ "$has_requirements" -eq 0 ]; then
27+
printf "\n\033[93m%s does not meet the requirements for %s. Skipping...\033[0m\n\n"< 1241 /span> "$example" "$IDF_TARGET"
28+
continue
29+
fi
30+
31+
printf "\n\033[95mBuilding %s\033[0m\n\n" "$example"
32+
idf.py -C "$example" -DEXTRA_COMPONENT_DIRS="$PWD/components" build
33+
done

.github/scripts/on-release.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ PACKAGE_JSON_MERGE="$GITHUB_WORKSPACE/.github/scripts/merge_packages.py"
3535
PACKAGE_JSON_TEMPLATE="$GITHUB_WORKSPACE/package/package_esp32_index.template.json"
3636
PACKAGE_JSON_DEV="package_esp32_dev_index.json"
3737
PACKAGE_JSON_REL="package_esp32_index.json"
38+
PACKAGE_JSON_DEV_CN="package_esp32_dev_index_cn.json"
39+
PACKAGE_JSON_REL_CN="package_esp32_index_cn.json"
3840

3941
echo "Event: $GITHUB_EVENT_NAME, Repo: $GITHUB_REPOSITORY, Path: $GITHUB_WORKSPACE, Ref: $GITHUB_REF"
4042
echo "Action: $action, Branch: $RELEASE_BRANCH, ID: $RELEASE_ID"
@@ -339,9 +341,13 @@ jq_arg=".packages[0].platforms[0].version = \"$RELEASE_TAG\" | \
339341
# Generate package JSONs
340342
echo "Generating $PACKAGE_JSON_DEV ..."
341343
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
344+
# On MacOS the sed command won't skip the first match. Use gsed instead.
345+
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"
342346
if [ "$RELEASE_PRE" == "false" ]; then
343347
echo "Generating $PACKAGE_JSON_REL ..."
344348
cat "$PACKAGE_JSON_TEMPLATE" | jq "$jq_arg" > "$OUTPUT_DIR/$PACKAGE_JSON_REL"
349+
# On MacOS the sed command won't skip the first match. Use gsed instead.
350+
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"
345351
fi
346352

347353
# Figure out the last release or pre-release
@@ -373,12 +379,14 @@ echo
373379
if [ -n "$prev_any_release" ] && [ "$prev_any_release" != "null" ]; then
374380
echo "Merging with JSON from $prev_any_release ..."
375381
merge_package_json "$prev_any_release/$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV"
382+
merge_package_json "$prev_any_release/$PACKAGE_JSON_DEV_CN" "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN"
376383
fi
377384

378385
if [ "$RELEASE_PRE" == "false" ]; then
379386
if [ -n "$prev_release" ] && [ "$prev_release" != "null" ]; then
380387
echo "Merging with JSON from $prev_release ..."
381388
merge_package_json "$prev_release/$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL"
389+
merge_package_json "$prev_release/$PACKAGE_JSON_REL_CN" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN"
382390
fi
383391
fi
384392

@@ -388,6 +396,8 @@ echo "Installing arduino-cli ..."
388396
export PATH="/home/runner/bin:$PATH"
389397
source "${SCRIPTS_DIR}/install-arduino-cli.sh"
390398

399+
# For the Chinese mirror, we can't test the package JSONs as the Chinese mirror might not be updated yet.
400+
391401
echo "Testing $PACKAGE_JSON_DEV install ..."
392402

393403
echo "Installing esp32 ..."
@@ -445,11 +455,15 @@ fi
445455
echo "Uploading $PACKAGE_JSON_DEV ..."
446456
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
447457
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV")"
458+
echo "Download CN URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN")"
459+
echo "Pages CN URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_DEV" "$OUTPUT_DIR/$PACKAGE_JSON_DEV_CN")"
448460
echo
449461
if [ "$RELEASE_PRE" == "false" ]; then
450462
echo "Uploading $PACKAGE_JSON_REL ..."
451463
echo "Download URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
452464
echo "Pages URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL")"
465+
echo "Download CN URL: $(git_safe_upload_asset "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN")"
466+
echo "Pages CN URL: $(git_safe_upload_to_pages "$PACKAGE_JSON_REL" "$OUTPUT_DIR/$PACKAGE_JSON_REL_CN")"
453467
echo
454468
fi
455469

.github/scripts/sketch_utils.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function check_requirements { # check_requirements <sketchdir> <sdkconfig_path>
1616
local requirements_or
1717

1818
if [ ! -f "$sdkconfig_path" ] || [ ! -f "$sketchdir/ci.json" ]; then
19-
echo "ERROR: sdkconfig or ci.json not found" 1>&2
19+
echo "WARNING: sdkconfig or ci.json not found. Assuming requirements are met." 1>&2
2020
# Return 1 on error to force the sketch to be built and fail. This way the
2121
# CI will fail and the user will know that the sketch has a problem.
2222
else

.github/workflows/push.yml

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ on:
3131
- "!libraries/**.properties"
3232
- "!libraries/**.py"
3333
- "package/**"
34+
- "idf_component_examples/**"
3435
- "tools/**.py"
3536
- "platform.txt"
3637
- "programmers.txt"
@@ -45,7 +46,6 @@ on:
4546
- "!.github/scripts/tests_*"
4647
- "!.github/scripts/upload_*"
4748
- "variants/esp32/**/*"
48-
- "variants/esp32c2/**/*"
4949
- "variants/esp32c3/**/*"
5050
- "variants/esp32c6/**/*"
5151
- "variants/esp32h2/**/*"
@@ -124,7 +124,7 @@ jobs:
124124
- 'idf_component.yml'
125125
- 'Kconfig.projbuild'
126126
- 'CMakeLists.txt'
127-
- "variants/esp32c2/**/*"
127+
- "idf_component_examples/**"
128128
129129
- name: Set chunks
130130
id: set-chunks
@@ -267,15 +267,23 @@ jobs:
267267
submodules: recursive
268268
path: components/arduino-esp32
269269

270+
- name: Setup jq
271+
uses: dcarbone/install-jq-action@e397bd87438d72198f81efd21f876461183d383a # v3.0.1
272+
270273
- name: Build
271274
env:
272275
IDF_TARGET: ${{ matrix.idf_target }}
273276
shell: bash
274277
run: |
275-
. ${IDF_PATH}/export.sh
276-
idf.py create-project test
277-
echo CONFIG_FREERTOS_HZ=1000 > test/sdkconfig.defaults
278-
idf.py -C test -DEXTRA_COMPONENT_DIRS=$PWD/components build
278+
chmod a+x ./components/arduino-esp32/.github/scripts/*
279+
./components/arduino-esp32/.github/scripts/on-push-idf.sh
280+
281+
- name: Upload generated sdkconfig files for debugging
282+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
283+
if: always()
284+
with:
285+
name: sdkconfig-${{ matrix.idf_target }}
286+
path: ./components/arduino-esp32/idf_component_examples/**/sdkconfig
279287

280288
# Save artifacts to gh-pages
281289
save-master-artifacts:

.pre-commit-config.yaml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ default_language_version:
1212

1313
repos:
1414
- repo: https://github.com/pre-commit/pre-commit-hooks
15-
rev: "v5.0.0"
15+
rev: "cef0300fd0fc4d2a87a85fa2093c6b283ea36f4b" # v5.0.0
1616
hooks:
1717
# Generic checks
1818
- id: check-case-conflict
@@ -39,31 +39,24 @@ repos:
3939
^package\/.*$
4040
)
4141
42-
- repo: https://github.com/codespell-project/codespell
43-
rev: "v2.3.0"
44-
hooks:
45-
# Spell checking
46-
- id: codespell
47-
exclude: ^.*\.(svd|SVD)$
48-
4942
- repo: https://github.com/pre-commit/mirrors-clang-format
50-
rev: "v18.1.3"
43+
rev: "f6446549e5e97ec9665b9b03e75b87b445857f9a" # v18.1.3
5144
hooks:
5245
# C/C++ formatting
5346
- id: clang-format
5447
types_or: [c, c++]
5548
exclude: ^.*\/build_opt\.h$
5649

5750
- repo: https://github.com/psf/black-pre-commit-mirror
58-
rev: "24.10.0"
51+
rev: "a4920527036bb9a3f3e6055d595849d67d0da066" # 25.1.0
5952
hooks:
6053
# Python formatting
6154
- id: black
6255
types_or: [python]
6356
args: [--line-length=120] #From the arduino code style. Add as argument rather than creating a new config file.
6457

6558
- repo: https://github.com/PyCQA/flake8
66-
rev: "7.1.1"
59+
rev: "16f5f28a384f0781bebb37a08aa45e65b9526c50" # 7.2.0
6760
hooks:
6861
# Python linting
6962
- id: flake8
@@ -74,37 +67,44 @@ repos:
7467
- flake8-simplify
7568

7669
- repo: https://github.com/pre-commit/mirrors-prettier
77-
rev: "v3.1.0"
70+
rev: "ffb6a759a979008c0e6dff86e39f4745a2d9eac4" # v3.1.0
7871
hooks:
7972
# YAML formatting
8073
- id: prettier
8174
types_or: [yaml]
8275

76+
- repo: https://github.com/codespell-project/codespell
77+
rev: "63c8f8312b7559622c0d82815639671ae42132ac" # v2.4.1
78+
hooks:
79+
# Spell checking
80+
- id: codespell
81+
exclude: ^.*\.(svd|SVD)$
82+
8383
- repo: https://github.com/shellcheck-py/shellcheck-py
84-
rev: "v0.10.0.1"
84+
rev: "a23f6b85d0fdd5bb9d564e2579e678033debbdff" # v0.10.0.1
8585
hooks:
8686
# Bash linting
8787
- id: shellcheck
8888
types: [shell]
8989

9090
- repo: https://github.com/openstack/bashate
91-
rev: "2.1.1"
91+
rev: "fbd7c2534c2701351c603ff700ddf08202430a31" # 2.1.1
9292
hooks:
9393
# Bash formatting
9494
- id: bashate
9595
types: [shell]
9696
args: ["-i", "E006"] # Ignore E006: Line too long
9797

9898
- repo: https://github.com/errata-ai/vale
99-
rev: "v3.9.1"
99+
rev: "dc4c47923788a413fb5677de6e3370d514aecb78" # v3.11.2
100100
hooks:
101101
# Sync vale styles and lint markdown and reStructuredText
102102
- id: vale
103103
name: vale-sync
104-
language_version: "1.21.6"
104+
language_version: "1.23.2"
105105
pass_filenames: false
106106
args: [sync]
107107
types_or: [markdown, rst]
108108
- id: vale
109-
language_version: "1.21.6"
109+
language_version: "1.23.2"
110110
types_or: [markdown, rst]

CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,7 @@ set(ARDUINO_LIBRARY_Zigbee_SRCS
300300
libraries/Zigbee/src/ep/ZigbeeGateway.cpp
301301
libraries/Zigbee/src/ep/ZigbeeWindSpeedSensor.cpp
302302
libraries/Zigbee/src/ep/ZigbeeIlluminanceSensor.cpp
303+
libraries/Zigbee/src/ep/ZigbeePM25Sensor.cpp
303304
)
304305

305306
set(ARDUINO_LIBRARY_BLE_SRCS

boards.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6007,12 +6007,12 @@ twatchs3.menu.UploadMode.cdc=USB-OTG CDC (TinyUSB)
60076007
twatchs3.menu.UploadMode.cdc.upload.use_1200bps_touch=true
60086008
twatchs3.menu.UploadMode.cdc.upload.wait_for_upload_port=true
60096009

6010-
twatchs3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
6011-
twatchs3.menu.PartitionScheme.fatflash.build.partitions=ffat
6012-
twatchs3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
60136010
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB=16M Flash (3MB APP/9.9MB FATFS)
60146011
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.build.partitions=app3M_fat9M_16MB
60156012
twatchs3.menu.PartitionScheme.app3M_fat9M_16MB.upload.maximum_size=3145728
6013+
twatchs3.menu.PartitionScheme.fatflash=16M Flash (2MB APP/12.5MB FATFS)
6014+
twatchs3.menu.PartitionScheme.fatflash.build.partitions=ffat
6015+
twatchs3.menu.PartitionScheme.fatflash.upload.maximum_size=2097152
60166016
twatchs3.menu.PartitionScheme.rainmaker=RainMaker
60176017
twatchs3.menu.PartitionScheme.rainmaker.build.partitions=rainmaker
60186018
twatchs3.menu.PartitionScheme.rainmaker.upload.maximum_size=1966080
@@ -6076,6 +6076,10 @@ twatchs3.menu.Revision.Radio_SX1280=Radio-SX1280
60766076
twatchs3.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
60776077
twatchs3.menu.Revision.Radio_CC1101=Radio-CC1101
60786078
twatchs3.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
6079+
twatchs3.menu.Revision.Radio_LR1121=Radio-LR1121
6080+
twatchs3.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
6081+
twatchs3.menu.Revision.Radio_SI4432=Radio-SI4432
6082+
twatchs3.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
60796083

60806084
##############################################################
60816085

@@ -6231,13 +6235,16 @@ twatch_ultra.menu.EraseFlash.none.upload.erase_cmd=
62316235
twatch_ultra.menu.EraseFlash.all=Enabled
62326236
twatch_ultra.menu.EraseFlash.all.upload.erase_cmd=-e
62336237

6234-
twatch_ultra.menu.Revision.Radio_SX1280=Radio-SX1280
6235-
twatch_ultra.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
62366238
twatch_ultra.menu.Revision.Radio_SX1262=Radio-SX1262
62376239
twatch_ultra.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262
6240+
twatch_ultra.menu.Revision.Radio_SX1280=Radio-SX1280
6241+
twatch_ultra.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
62386242
twatch_ultra.menu.Revision.Radio_CC1101=Radio-CC1101
62396243
twatch_ultra.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
6240-
6244+
twatch_ultra.menu.Revision.Radio_LR1121=Radio-LR1121
6245+
twatch_ultra.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
6246+
twatch_ultra.menu.Revision.Radio_SI4432=Radio-SI4432
6247+
twatch_ultra.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
62416248

62426249
##############################################################
62436250

@@ -6393,12 +6400,16 @@ tlora_pager.menu.EraseFlash.all=Enabled
63936400
tlora_pager.menu.EraseFlash.all.upload.erase_cmd=-e
63946401

63956402

6396-
tlora_pager.menu.Revision.Radio_SX1280=Radio-SX1280
6397-
tlora_pager.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
63986403
tlora_pager.menu.Revision.Radio_SX1262=Radio-SX1262
63996404
tlora_pager.menu.Revision.Radio_SX1262.build.board=LILYGO_LORA_SX1262
6405+
tlora_pager.menu.Revision.Radio_SX1280=Radio-SX1280
6406+
tlora_pager.menu.Revision.Radio_SX1280.build.board=LILYGO_LORA_SX1280
64006407
tlora_pager.menu.Revision.Radio_CC1101=Radio-CC1101
64016408
tlora_pager.menu.Revision.Radio_CC1101.build.board=LILYGO_LORA_CC1101
6409+
tlora_pager.menu.Revision.Radio_LR1121=Radio-LR1121
6410+
tlora_pager.menu.Revision.Radio_LR1121.build.board=LILYGO_LORA_LR1121
6411+
tlora_pager.menu.Revision.Radio_SI4432=Radio-SI4432
6412+
tlora_pager.menu.Revision.Radio_SI4432.build.board=LILYGO_LORA_SI4432
64026413

64036414
##############################################################
64046415

cores/esp32/HWCDC.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,7 @@ void HWCDC::setDebugOutput(bool en) {
603603
} else {
604604
ets_install_putc2(NULL);
605605
}
606+
ets_install_putc1(NULL); // closes UART log output
606607
}
607608

608609
#if ARDUINO_USB_MODE && ARDUINO_USB_CDC_ON_BOOT // Hardware JTAG CDC selected

cores/esp32/HardwareSerial.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,24 @@ bool HardwareSerial::setMode(SerialMode mode) {
607607
return uartSetMode(_uart, mode);
608608
}
609609

610+
// Sets the UART Clock Source based on the compatible SoC options
611+
// This method must be called before starting UART using begin(), otherwise it won't have any effect.
612+
// Clock Source Options are:
613+
// UART_CLK_SRC_DEFAULT :: any SoC - it will set whatever IDF defines as the default UART Clock Source
614+
// UART_CLK_SRC_APB :: ESP32, ESP32-S2, ESP32-C3 and ESP32-S3
615+
// UART_CLK_SRC_PLL :: ESP32-C2, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2 and ESP32-P4
616+
// UART_CLK_SRC_XTAL :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
617+
// UART_CLK_SRC_RTC :: ESP32-C2, ESP32-C3, ESP32-C5, ESP32-C6, ESP32-C61, ESP32-H2, ESP32-S3 and ESP32-P4
618+
// UART_CLK_SRC_REF_TICK :: ESP32 and ESP32-S2
619+
// 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
620+
// Note: ESP32-C6, C61, ESP32-P4 and ESP32-C5 have LP UART that will use only RTC_FAST or XTAL/2 as Clock Source
621+
bool HardwareSerial::setClockSource(SerialClkSrc clkSrc) {
622+
if (_uart) {
623+
log_e("No Clock Source change was done. This function must be called before beginning UART%d.", _uart_nr);
624+
return false;
625+
}
626+
return uartSetClockSource(_uart_nr, (uart_sclk_t)clkSrc);
627+
}
610628
// minimum total RX Buffer size is the UART FIFO space (128 bytes for most SoC) + 1. IDF imposition.
611629
// LP UART has FIFO of 16 bytes
612630
size_t HardwareSerial::setRxBufferSize(size_t new_size) {

0 commit comments

Comments
 (0)
0