Compare commits

..

779 Commits

Author SHA1 Message Date
feedc0de 6213a906c0 Allow the https server to request client certs only with OPTIONAL 2025-09-23 17:08:13 +02:00
Aditya Patwardhan 68b583f30c Merge branch 'docs/update_http_server_uri_fun_doc_regarding_thread_safe' into 'master'
Updated the http_server doc regarding thread safety

Closes IDFGH-15207

See merge request espressif/esp-idf!39587
2025-06-20 13:57:41 +05:30
Sudeep Mohanty 7023f5bf3c Merge branch 'contrib/github_pr_16040' into 'master'
refactor(xtensa): Rename specreg.h register macros (GitHub PR)

Closes IDFGH-11606 and IDFGH-15386

See merge request espressif/esp-idf!39649
2025-06-20 08:51:33 +02:00
Frantisek Hrbata 0afcc02c47 Merge branch 'fix/cmake_uninitialized_vars' into 'master'
fix(build): do not rely on uninitialized  variables and variables set in parent scope

See merge request espressif/esp-idf!39615
2025-06-20 08:30:30 +02:00
Wang Meng Yang c4bfb8adba Merge branch 'bugfix/auth_collision' into 'master'
fix(bt/controller): Fixed bugs on LMP legacy and secure authentication collision

See merge request espressif/esp-idf!39990
2025-06-20 14:25:17 +08:00
Frantisek Hrbata 7ee9e7e785 Merge branch 'docs/idf_size_flash_total_size' into 'master'
fix(docs/idf-size): add explicit note about total flash size

Closes IDF-13066

See merge request espressif/esp-idf!38891
2025-06-20 08:15:43 +02:00
Jiang Jiang Jian 4e8ad76602 Merge branch 'bugfix/fix_bt_avrcp_build_issue' into 'master'
fix(bt/bluedroid): Fix AVRCP build issue when disable Cover Art

Closes IDFGH-15516

See merge request espressif/esp-idf!39982
2025-06-20 14:02:10 +08:00
Kevin (Lao Kaiyao) c5a17106b6 Merge branch 'doc/fix_ext1_wakeup_cause' into 'master'
docs(sleep_mode): updated ext1 wakeup status

Closes IDF-9459 and IDF-9454

See merge request espressif/esp-idf!39968
2025-06-20 11:00:14 +08:00
Roland Dobai 8f570513ea Merge branch 'fix/idf_tools_install_tool_version' into 'master'
fix(tools): fixed command `idf_tools.py install tool@version`

Closes IDF-12845

See merge request espressif/esp-idf!39588
2025-06-19 15:46:16 +02:00
Gao Xu f638d5e075 Merge branch 'contrib/github_pr_16130' into 'master'
esp_adc: Release the peripheral after calibration (GitHub PR)

Closes IDFGH-15489

See merge request espressif/esp-idf!39895
2025-06-19 20:49:22 +08:00
liqigan b5d1c978b3 fix(bt/controller): Fixed bugs on LMP legacy and secure authentication collision 2025-06-19 20:30:35 +08:00
Chen Ji Chang d6a4c374c1 Merge branch 'test/add_parlio_bs_different_input_output_sizes_test' into 'master'
test(parlio_tx): add parlio_tx_bs different input output sizes test

Closes IDFGH-15481

See merge request espressif/esp-idf!39923
2025-06-19 20:27:40 +08:00
linruihao 4116e4f697 ci(bt/bluedroid): Add CI build test for A2DP Sink example with Caver Art disabled 2025-06-19 19:44:51 +08:00
laokaiyao 9b14f91478 change: remove the updated doc's list for c5 2025-06-19 16:57:43 +08:00
Armando (Dou Yiwen) 1571758b3d Merge branch 'feat/support_fallback_to_default_pattern_when_psram_id_not_match' into 'master'
psram: support fallback to use default driver pattern when id isn't match

Closes IDF-13387

See merge request espressif/esp-idf!39859
2025-06-19 08:32:43 +00:00
Guillaume Souchere fd9b2fab3a Merge branch 'fix/tcm-mem-not-considered-in-esp_ptr_eexecutable' into 'master'
fix(memory-utils): Check TCM in esp_ptr_internal and esp_ptr_byte_accessible

Closes IDFGH-15339 and IDFGH-15337

See merge request espressif/esp-idf!39388
2025-06-19 10:09:40 +02:00
Martin Vychodil 2aeec90f6c Merge branch 'feat/bump_littlefs_to_1.20.0' into 'master'
feat(storage): Bump LittleFS to 1.20.0 and fix storage readmes mentioning esptool

Closes IDF-13395

See merge request espressif/esp-idf!39905
2025-06-19 15:25:08 +08:00
laokaiyao 79a0958671 docs(sleep_mode): updated ext1 wakeup status 2025-06-19 15:00:55 +08:00
linruihao ffaf0819d5 fix(bt/bluedroid): Fix AVRCP build issue when disable Cover Art
Closes https://github.com/espressif/esp-idf/issues/16155
2025-06-19 14:48:12 +08:00
gaoxu afadb17ed8 fix(adc): fix P4 ADC2 oneshot error and refactor apb claim macor 2025-06-19 14:20:20 +08:00
hrushikesh.bhosale 8026e7acc7 docs(http_server): Updated the http_server doc regarding thread safety
Updated the http_server documentation mentioning that, APIs used in
http_server aren't thread safe

Closes https://github.com/espressif/esp-idf/issues/15877
2025-06-19 11:49:18 +05:30
Chen Jichang d93967009e test(parlio_tx): add parlio_tx_bs different input output sizes test
Closes https://github.com/espressif/esp-idf/issues/16122
2025-06-19 14:07:37 +08:00
Mahavir Jain 62723f532f Merge branch 'bugfix/fix_ds_rsa_sign_null_pointer_handling' into 'master'
fix(mbedtls): Handle NULL ctx in ds rsa sign

See merge request espressif/esp-idf!39954
2025-06-19 08:32:42 +05:30
Armando (Dou Yiwen) 807cbbf24b Merge branch 'refactor/remove_legacy_adc_driver' into 'master'
adc: removed the legacy adc driver and legacy adc calibration driver since v6.0

Closes IDF-13177

See merge request espressif/esp-idf!39478
2025-06-19 02:48:05 +00:00
C.S.M 35f2cca5f2 Merge branch 'refactor/update_locks' into 'master'
refactor(hw_support): Use esp_os_enter_critical instead of portENTER_CRITICAL_SAFE

Closes IDF-13397

See merge request espressif/esp-idf!39922
2025-06-19 10:45:51 +08:00
armando 954e88c92d feat(psram): support fallback to use default driver pattern when id isn't match 2025-06-19 09:31:48 +08:00
Roland Dobai dcd29e50c4 Merge branch 'ci/add-kconfig-pre-commit' into 'master'
docs:fix spelling/"casing" of the word "Kconfig"

Closes IDF-11284

See merge request espressif/esp-idf!39470
2025-06-18 19:20:50 +02:00
Jiang Jiang Jian cca744cd70 Merge branch 'bugfix/ag_data_callback_cleared_after_deinit' into 'master'
fix(bt): Fixed HFP AG data callback cleared after profile is re-initialized

Closes COEXQABR25-79

See merge request espressif/esp-idf!39786
2025-06-19 01:20:20 +08:00
Adam Múdry 5106b95910 fix(storage): Fix storage examples readmes mentioning espotool 2025-06-18 15:58:07 +02:00
Adam Múdry e326d533de feat(storage): Bump LittleFS to 1.20.0 2025-06-18 15:56:47 +02:00
Jiang Jiang Jian 9ddef27ed4 Merge branch 'test/bugfix/offchan_action_tx_failure_scan_rebase_master' into 'master'
feat(coex): support backgorund scan for coex, fix some issues of scan when connected

Closes WIFI-6729, WIFI-6730, WIFIBUG-740, and WIFIBUG-387

See merge request espressif/esp-idf!38413
2025-06-18 19:35:43 +08:00
Marek Fiala bd0873f9ec fix(tools): idf_tools.py uninstall decide based on preferred tool version
idf_tools.py uninstall now doesn't take only recommended version, but
makes the decision based on preferred installed versions.
2025-06-18 19:33:54 +08:00
Marek Fiala 335ba6b3c2 test(tools): Added test for installing supported tool version
Added test_export_supported_version_cmake in `test_idf_tools.py`,
that installs and exports supported version of tool - cmake.
2025-06-18 19:33:54 +08:00
Marek Fiala 79ebe0b306 fix(tools): idf_tools.py install tool@version 2025-06-18 19:33:54 +08:00
Rahul Tank 304b561f8a Merge branch 'fix/gatt_cache_peer_init_incl_svc' into 'master'
fix(nimble): Added parameter in peer_init for included service allocation

See merge request espressif/esp-idf!39822
2025-06-18 16:24:49 +05:30
Tan Yan Quan 8b2a1b4e37 Merge branch 'feat/ot_sleep_lock_type' into 'master'
feat(openthread): use apb_freq_max mode for esp_openthread_sleep pm lock

See merge request espressif/esp-idf!39800
2025-06-18 18:42:14 +08:00
Ashish Sharma 78af627857 fix(mbedtls): handle NULL ctx in ds rsa sign 2025-06-18 17:03:37 +08:00
Song Ruo Jing 570f9d3c82 Merge branch 'bugfix/cpu_clock_switch_after_sleep_c5' into 'master'
fix(sleep): Fix CPU clk src when restoring CPU frequency after wakeup for c5

See merge request espressif/esp-idf!39937
2025-06-18 16:27:44 +08:00
John Boiles d8c054c8c1 fix(memory-utils): Use esp_ptr_in_tcm to check TCM range 2025-06-18 10:09:40 +02:00
John Boiles b9f42e7bae fix(memory-utils): Check TCM in esp_ptr_internal and esp_ptr_byte_accessible
Modifies `esp_ptr_internal` and `esp_ptr_byte_accessible` to also check TCM
when `SOC_MEM_TCM_SUPPORTED`.
2025-06-18 10:09:40 +02:00
Jiang Jiang Jian 4a189516c7 Merge branch 'feat/chip_esp32c5_eco2_update_libphy' into 'master'
feat(phy): update phylib for esp32c5

See merge request espressif/esp-idf!39830
2025-06-18 14:56:22 +08:00
Tan Yan Quan 55f48c9c14 feat(openthread): use apb_freq_max mode for esp_openthread_sleep pm lock 2025-06-18 14:49:07 +08:00
armando 6abac38b9c refactor(adc): removed the legacy adc driver and legacy adc calibration calibration driver 2025-06-18 14:35:41 +08:00
morris 3041f332c2 feat(ci): ast-grep rules to forbid use freertos specific critical section APIs 2025-06-18 11:58:04 +08:00
C.S.M f76d50c279 refactor(system): Make it usable in tee build 2025-06-18 11:56:08 +08:00
C.S.M 4860379677 refactor(hw_support): Use esp_os_enter_critical instead of portENTER_CRITICAL_SAFE in esp_hw_support 2025-06-18 11:23:34 +08:00
yinqingzhao d0d3c1f84a feat(phy): update phylib for esp32c5 2025-06-18 11:18:58 +08:00
sibeibei 7191595d2a feat(coex): support backgorund scan for coex, fix some issues of scan when connected 2025-06-18 10:58:12 +08:00
Jiang Jiang Jian 22ae972229 Merge branch 'feat/resupport_esp32c61eco3_ble' into 'master'
change(ble): resupport ble for ESP32C61ECO3

Closes BLERP-1948, IDF-10360, IDF-10361, IDF-10363, IDF-10365, and IDF-10362

See merge request espressif/esp-idf!39601
2025-06-18 10:26:07 +08:00
Sergei Silnov ede834d775 Merge branch 'feat/ci-protected-environment' into 'master'
ci: Production as protected environment

Closes IDFCI-2939

See merge request espressif/esp-idf!39427
2025-06-17 13:53:35 -03:00
Wu Zheng Hui 8ab969db1c Merge branch 'bugfix/esp32c6_src_clk_label' into 'master'
clk: esp32c6: rename modem clock source selection

See merge request espressif/esp-idf!39756
2025-06-17 22:01:33 +08:00
morris 5f1ad2c18d Merge branch 'bugfix/onewire_internal_pullup' into 'master'
fix(rmt): enable internal pull-up resistor for onewire bus

See merge request espressif/esp-idf!39928
2025-06-17 21:50:39 +08:00
Nebojsa Cvetkovic d0ceef20f4 refactor(xtensa): Rename specreg.h register macros
This commit renames all registers in xtensa/specreg.h to by adding the
prefix XT_REG_. This is done to avoid naming collisions with similar
variable names. A new register file, viz., xt_specreg.h is created. The
previous names are still available to use but have been deprecated.

Closes https://github.com/espressif/esp-idf/issues/12723
Merges https://github.com/espressif/esp-idf/pull/16040
2025-06-17 15:37:33 +02:00
liuning 23f49324b2 fix(pm): reserve txqblocks when mac init at offchannels 2025-06-17 21:10:03 +08:00
liuning 7ab87012db fix(pm): fix ps none status check 2025-06-17 21:09:51 +08:00
Guillaume Souchere 2f4c5d278e Merge branch 'feat/remove-unecessray-condition-in-usj-read' into 'master'
fix(driver): remove unecessary if conditions in the read function

Closes IDF-13166

See merge request espressif/esp-idf!39523
2025-06-17 14:19:38 +02:00
Samuel Fialka 15d998cf3b ci: Production as protected environment 2025-06-17 11:24:47 +02:00
Song Ruo Jing d6c483a073 fix(sleep): Fix CPU clk src when restoring CPU frequency after wakeup for c5 2025-06-17 16:56:03 +08:00
David Čermák bc34abb201 Merge branch 'fix/esp_netif_reassign_static_ip' into 'master'
fix(esp_netif): Fix reasigning static IP after netif down -> up

Closes IDF-13024 and WIFIBUG-1228

See merge request espressif/esp-idf!39725
2025-06-17 16:45:08 +08:00
David Čermák ce6e136e70 Merge branch 'fix/esp_netif_ip_events' into 'master'
fix(esp_netif): Rename IP_EVENT_AP_STAIPASSIGNED to generic name

Closes IDFGH-14957

See merge request espressif/esp-idf!39425
2025-06-17 16:28:45 +08:00
David Čermák b6ea70c57b Merge branch 'feat/lwip_no_iram_config' into 'master'
feat(iperf): Add minimum IRAM test config

See merge request espressif/esp-idf!37704
2025-06-17 16:26:51 +08:00
morris ceb7f1d827 fix(rmt): enable internal pull-up resistor for onewire bus 2025-06-17 15:15:05 +08:00
Michael (XIAO Xufeng) 957a232259 Merge branch 'feat/call_start_in_flash' into 'master'
esp_system: move call_start_cpu* into flash to save IRAM

See merge request espressif/esp-idf!39094
2025-06-17 14:57:27 +08:00
Jan Beran 40314930a6 docs: Fix spelling of the word "Kconfig" 2025-06-17 08:52:37 +02:00
Astha Verma a82bdb87d3 fix(nimble): Added parameter in peer_init for included service allocation 2025-06-17 11:56:20 +05:30
Rahul Tank 069950761c Merge branch 'feat/auto_security_initiate' into 'master'
feat(nimble): Automatically initiate security if a GATT service request fails

See merge request espressif/esp-idf!39724
2025-06-17 11:38:54 +05:30
Armando (Dou Yiwen) 02be119399 Merge branch 'fix/fix_c3_c2_cache_freeze_soc_caps_issue' into 'master'
cache: fixed SOC_CACHE_FREEZE_SUPPORTED not defined on C3 / C2 issue

See merge request espressif/esp-idf!39881
2025-06-17 03:15:07 +00:00
Sergei Silnov 7f0d091f6e Merge branch 'feat/smaller_release_size' into 'master'
ci: Use new release-zips-action with shallow history

Closes IDFCI-2827

See merge request espressif/esp-idf!39877
2025-06-16 16:30:08 -03:00
Tomas Rezucha 32bee685d6 Merge branch 'docs/p4_eco1_usb_pins' into 'master'
docs(usb): Update ESP32-P4 USB pins to MP version

Closes IDFGH-15495

See merge request espressif/esp-idf!39901
2025-06-16 16:27:03 +02:00
Song Ruo Jing e6e629e475 Merge branch 'feature/esp32h21_clock_support' into 'master'
feat(clk): Add basic clock support for esp32h21

Closes IDF-11521, IDF-11906, and IDF-12114

See merge request espressif/esp-idf!39066
2025-06-16 21:48:36 +08:00
Jiang Jiang Jian d4f3bceb69 Merge branch 'fix/update_dfs_compensate_table' into 'master'
fix(esp_hw_support): update esp32 dfs table to make the timing drift always negative

Closes PM-437, WIFIBUG-1248, and PM-405

See merge request espressif/esp-idf!39838
2025-06-16 19:55:14 +08:00
Mahavir Jain 72cc5dee10 Merge branch 'bugfix/http_client_test_failure' into 'master'
fix: update root certificate for postman-echo endpoint

Closes IDFCI-2968 and IDFGH-15491

See merge request espressif/esp-idf!39828
2025-06-16 17:16:53 +05:30
Tomas Rezucha 025aec91c5 docs(usb): Update ESP32-P4 USB pins to MP version
Closes https://github.com/espressif/esp-idf/issues/16136
2025-06-16 13:32:51 +02:00
Sumeet Singh e928897801 feat(nimble): Added two GATT features:
1. Automatically initiate security if a GATT service request fails
2. Encryption, Authentication, and Authorization requirement on CCCD
2025-06-16 16:58:57 +05:30
harshal.patil 6fe38c7efd fix(mbedtls): re-include Comodo AAA Services root 2025-06-16 15:55:39 +05:30
Mahavir Jain 03433aad49 fix(mbedtls): re-include Starfield Class 2 CA
Some of the endpoints (e.g., httpbin.org) is still relying on the
Starfield Class 2 CA in the chain. Added this root certificate as
a temporary exception and shall be removed in future.
2025-06-16 15:55:36 +05:30
Mahavir Jain 068847e2af fix: update root certificate for postman-echo endpoint
The certificate chain for postman-echo endpoint has switched to
Let's Encrypt root CA

Closes https://github.com/espressif/esp-idf/issues/16132
2025-06-16 15:55:13 +05:30
Rahul Tank 5beacd1ad2 Merge branch 'fix/nimble_pr_issues' into 'master'
fix(nimble): Add fixes for compilation issues in nimble

See merge request espressif/esp-idf!39631
2025-06-16 15:33:20 +05:30
Wang Mengyang 0190ba0390 fix(bt): Fixed HFP AG data callback cleared after profile is re-initialized 2025-06-16 16:55:09 +08:00
C.S.M f4a45a30b5 Merge branch 'refactor/remove_tsens_legacy' into 'master'
refactor(temperature_sensor): Remove legacy temperature sensor driver

Closes IDF-12570 and IDF-13366

See merge request espressif/esp-idf!39840
2025-06-16 16:09:40 +08:00
Michael (XIAO Xufeng) 7549d083a4 feat(hw_support): move call_start_cpu0 into flash to save IRAM 2025-06-16 15:07:34 +08:00
Song Ruo Jing 6d293c8582 feat(clk): Add basic clock support for esp32h21 2025-06-16 15:05:32 +08:00
armando 1c5cadea13 fix(cache): fixed SOC_CACHE_FREEZE_SUPPORTED not defined on c3/c2 issue 2025-06-16 13:13:22 +08:00
morris 2fb938c7c3 Merge branch 'feature/utilize_rom_gpio_function' into 'master'
feat(gpio): esp_rom_gpio_connect_in/out_signal now has their hal implementation

Closes IDFGH-15397

See merge request espressif/esp-idf!39383
2025-06-16 12:17:40 +08:00
Gao Xu c81dc5a9c4 Merge branch 'fix/fix_adc_tsens_test_wrong_channel_c61' into 'master'
fix(adc): fix wrong adc channel on c61 adc/tsens test

See merge request espressif/esp-idf!39808
2025-06-16 11:46:03 +08:00
Chen Ji Chang 0da7604680 Merge branch 'feat/support_weight_arbitration_on_c61' into 'master'
feat(gdma): support gdma weighted arbitration on c61 v1.0

Closes IDF-12882, IDF-9310, and IDF-12090

See merge request espressif/esp-idf!39710
2025-06-16 11:12:22 +08:00
Shen Meng Jing 974f571251 Merge branch 'docs/translate_migration_guides' into 'master'
docs: Provide CN translation for two migration-guides docs

Closes DOC-11341

See merge request espressif/esp-idf!39858
2025-06-16 11:09:50 +08:00
C.S.M bdf4dafe56 fix(soc): Fix wrong efuse register on esp32c61 2025-06-16 10:58:53 +08:00
C.S.M caf1a18188 refactor(temperature_sensor): Move calibration function from efuse to hal 2025-06-16 10:58:11 +08:00
C.S.M d839ecbcf0 refactor(temperature_sensor): Remove legacy temperature sensor driver 2025-06-16 10:58:09 +08:00
Gao Xu 211238d6cd Merge branch 'ci/reenable_c5_adc_test' into 'master'
ci(adc): reenable c5 adc test and fix test val

Closes IDF-13061

See merge request espressif/esp-idf!39836
2025-06-16 10:40:04 +08:00
Kevin (Lao Kaiyao) 0fc082d87e Merge branch 'bugfix/fixed_touch_freq_unit_issue' into 'master'
fix(touch): fixed touch interval freq unit convert issue

See merge request espressif/esp-idf!39860
2025-06-16 09:47:56 +08:00
Alexey Lapshin a319aa902c Merge branch 'feature/change-orphan-handling-behavior-to-error' into 'master'
feat(build): change orphan-handling behavior to error

Closes IDF-9792 and DOC-11408

See merge request espressif/esp-idf!39566
2025-06-15 17:41:10 +04:00
Zhang Shuxian be87c12a74 docs(migration-guides): add CN translation for build-system.rst 2025-06-15 11:54:05 +07:00
Deomid rojer Ryabkov 2435ffd1c6 fix(esp_adc): Release the peripheral after calibration 2025-06-14 18:36:40 +03:00
Sergei Silnov 561f017ef7 ci: Use new release-zips-action with shallow history 2025-06-14 14:58:51 +02:00
Fu Hanxi a4037e2416 Merge branch 'fix/limit-idf-component-manager-version' into 'master'
fix: limit idf-component-manager version

See merge request espressif/esp-idf!39869
2025-06-13 15:06:44 +02:00
wuzhenghui 2d2aac017a change(bt): increase BTDM_MODEM_WAKE_UP_DELAY 2025-06-13 20:38:47 +08:00
wuzhenghui 12d2347e24 change(esp_timer): make esp_timer timming drift always be negative 2025-06-13 20:38:46 +08:00
wuzhenghui f861b7dd65 fix(esp_hw_support): config lact in critical 2025-06-13 20:38:46 +08:00
Fu Hanxi 520ee76e03 fix: limit idf-component-manager version 2025-06-13 13:56:22 +02:00
Kevin (Lao Kaiyao) d445536897 Merge branch 'refactor/remove_legacy_dac_driver' into 'master'
remove(legacy_dac): remove legacy dac driver in IDF v6.0

Closes IDF-13344

See merge request espressif/esp-idf!39682
2025-06-13 19:42:27 +08:00
shenmengjing 71072cc1af docs: Provide CN translation for two migration-guides docs 2025-06-13 19:14:18 +08:00
Rahul Tank beb6d79fc9 Merge branch 'bugfix/pawr_sync' into 'master'
fix(nimble): memset the sync structs to prevent uncertainty for ext_adv reports

Closes BLERP-1936

See merge request espressif/esp-idf!39514
2025-06-13 15:24:30 +05:30
gaoxu d7aba9b677 ci(adc): reenable c5 adc test and fix test val 2025-06-13 17:28:39 +08:00
Konstantin Kondrashov e603f4ec6b Merge branch 'feature/bootloader_ota' into 'master'
feat(bootloader): Supports recovery bootloader

Closes IDF-7780 and IDF-7779

See merge request espressif/esp-idf!31893
2025-06-13 17:05:39 +08:00
Peter Macko 7eb710862c Merge branch 'feature/master_test_macos_virtualization' into 'master'
master(6.0): Migrate macOS to VM parallels

See merge request espressif/esp-idf!39373
2025-06-13 16:50:58 +08:00
laokaiyao b35982d521 fix(touch): fixed touch interval freq unit convert issue 2025-06-13 16:34:38 +08:00
Erhan Kurubas 81ee3bbe2c Merge branch 'fix/apptrace_crc_calculation' into 'master'
fix(apptrace): calculate crc16 of the current block before swap

See merge request espressif/esp-idf!39815
2025-06-13 10:27:47 +02:00
Konstantin Kondrashov d099224758 Merge branch 'feature/p4_add_3bit_for_wafer_major' into 'master'
feat(efuse): Adds 3-bit field for wafer major version in ESP32-P4

See merge request espressif/esp-idf!39562
2025-06-13 15:06:20 +08:00
Gao Xu d38621e95a Merge branch 'fix/fix_adc_cali_error_c5' into 'master'
fix(adc): fix adc calibration error on c5

Closes IDF-8701, IDF-8702, and IDF-8703

See merge request espressif/esp-idf!39820
2025-06-13 14:25:10 +08:00
Rocha Euripedes 1548e1dd67 Merge branch 'contrib/github_pr_16118' into 'master'
docs(esp_transport_ws): fix parameter name documentat (GitHub PR)

See merge request espressif/esp-idf!39827
2025-06-13 14:01:42 +08:00
Guillaume Souchere 740762c997 feat(usb_serial_jtag): Update vfs read to be POSIX compliant
The function now returns with available data in blocking mode
instead of waiting for the requested size to be available before
returning.
2025-06-13 07:58:22 +02:00
weiyuhan 56130d0366 Resupport C61 documentation build 2025-06-13 11:52:07 +08:00
Richard Allen a8b6017ca5 docs(esp_transport_ws): fix parameter name documentation 2025-06-12 10:44:06 -05:00
Rahul Tank 8fb69d6ef8 Merge branch 'bugfix/fix_kconfig_names' into 'master'
fix(nimble): Modified Kconfig information to make it more user friendly

See merge request espressif/esp-idf!39617
2025-06-12 20:25:29 +05:30
Rahul Tank 52a6290cf5 Merge branch 'feat/ram_optimization' into 'master'
fix(nimble): Add support to minimize ram consumption

Closes BLERP-1947

See merge request espressif/esp-idf!38983
2025-06-12 20:23:25 +05:30
Shreeyash bb5fc032e0 fix(nimble): Add support to minimize ram consumption 2025-06-12 19:31:07 +05:30
Rahul Tank 8192dfc530 fix(nimble): Add fixes for compilation issues in nimble
1. Fix compile failures when CSFCS is 0
2. Wrap BLE service API with extern "C"
2025-06-12 19:27:38 +05:30
Island 68f9f0381a Merge branch 'feat/add_ble_dtm_on_cert_test' into 'master'
feat(ble): add dtm test code to cert test example on ESP32-C6

Closes BLERP-1985

See merge request espressif/esp-idf!39785
2025-06-12 21:51:43 +08:00
Guillaume Souchere 81b93828cf Merge branch 'change/update-esp-event-register-doxygen' into 'master'
change(esp-event): Update the doxygen comment of esp_event_handler_register

Closes IDF-13368

See merge request espressif/esp-idf!39819
2025-06-12 15:01:41 +02:00
Konstantin Kondrashov 3a7c1a2e74 feat(bootloader): Bootloader OTA update with recovery bootloader feat 2025-06-12 18:47:33 +08:00
gaoxu 49df6a8b77 fix(adc): fix adc calibration error on c5 2025-06-12 16:56:12 +08:00
laokaiyao a4cb2dc98b remove(i2s): remove deprecated configuration in IDF v6.0 2025-06-12 16:53:50 +08:00
laokaiyao bf3a050f4d remove(legacy_dac): remove legacy dac driver in IDF v6.0 2025-06-12 16:53:47 +08:00
Roland Dobai 1b7cb43842 Merge branch 'fix/create_project_read_only' into 'master'
fix(tools): idf.py create-project works in read-only ESP-IDF

Closes IDFGH-15364 and IDFGH-15305

See merge request espressif/esp-idf!39751
2025-06-12 10:50:29 +02:00
zwl 71bc00568d feat(ble): add dtm test code to cert test example on ESP32-C6 2025-06-12 16:34:19 +08:00
Chen Jichang f3f6bc95df feat(gdma): support gdma weighted arbitration on c61 v1.0 2025-06-12 16:17:30 +08:00
morris 3e09d4f251 Merge branch 'refactor/remove_gdma_deprecated_functions' into 'master'
refactor(dma)!: remove deprecated functions

Closes IDF-10942

See merge request espressif/esp-idf!39372
2025-06-12 15:51:15 +08:00
David Čermák d9457b807c Merge branch 'fix/lwip_dhcp_option_len_assert' into 'master'
fix(lwip): Fix appending DHCP option with HW-ID

Closes IDF-13354

See merge request espressif/esp-idf!39749
2025-06-12 15:01:10 +08:00
Guillaume Souchere 2a17297d66 change(esp-event): Update the doxygen comment of esp_event_handler_register
Add a comment to specify what happens when registering a handler several times
to the same event.
2025-06-12 08:23:20 +02:00
morris fb4b590941 refactor(dma)!: remove deprecated functions 2025-06-12 12:24:58 +08:00
Mahavir Jain a8bf745f23 Merge branch 'feat/adding_different_strategy_to_perform_tls_using_dynamic_feature' into 'master'
Add configuration to control dynamic buffer strategy in mbedtls

Closes IDF-12591

See merge request espressif/esp-idf!39469
2025-06-12 09:52:35 +05:30
Mahavir Jain dd893957f3 Merge branch 'docs/update_reprovisioning_docs_in_wifi_prov_mgr_example' into 'master'
Updated reprovisioning docs in wifi prov mgr example

Closes IDF-12699

See merge request espressif/esp-idf!39058
2025-06-12 09:48:08 +05:30
Chen Ji Chang 81bb6a0557 Merge branch 'refactor/remove_legacy_pcnt_driver' into 'master'
remove(legacy_pcnt)!: remove legacy pcnt driver in IDF v6.0

Closes IDF-13172 and IDF-13036

See merge request espressif/esp-idf!39754
2025-06-12 11:49:55 +08:00
morris 3785a2421d Merge branch 'feat/add_h264_encoder_decoder_demo' into 'master'
feat(esp_h264): Add esp_h264 enocder and decoder example

Closes AUD-6406

See merge request espressif/esp-idf!39676
2025-06-12 11:03:22 +08:00
houhaiyan fa54de736e feat(esp_h264): Added esp_h264 encoder and decoder 2025-06-12 10:43:18 +08:00
Chen Ji Chang f05d47c7d3 Merge branch 'feat/parlio_tx_use_dma_eof' into 'master'
feat(parlio_tx): Supported to transmit infinitely long buffer on ESP32-C5

Closes IDF-12732 and IDF-10974

See merge request espressif/esp-idf!38919
2025-06-12 10:38:15 +08:00
Erhan Kurubas 1615270205 fix(apptrace): calculate crc16 of the current block before swap 2025-06-11 22:41:05 +02:00
Song Ruo Jing 3e2945b595 fix(gpio): remove GPIO_OUTPUT_SET macro for ESP32P4
Use GPIO_OUTPUT_SET led to compilation error

Closes https://github.com/espressif/esp-idf/issues/16050
2025-06-11 20:56:12 +08:00
Song Ruo Jing 60bef64f5c feat(gpio): esp_rom_gpio_connect_in/out_signal now has their hal implementation 2025-06-11 20:41:37 +08:00
gaoxu e8cefb33c8 fix(adc): fix wrong adc channel on c61 adc/tsens test 2025-06-11 17:37:56 +08:00
hrushikesh.bhosale 619caaa79f docs(wifi_prov_mgr): Updated the README.md for reprovisioning usage
Updated the README.md for the reprovisoning usage in wifi_prov_mgr example
and udpated the commnet for wifi_prov_mgr_reset_sm_state_for_reprovision api.
2025-06-11 15:04:05 +05:30
morris 42682b1e36 Merge branch 'feat/axi_bus_priority' into 'master'
feat(axi): add low level function for adjusting the arbitration priority when DMA and cache both are accessing the external memory

Closes IDF-12654 and IDF-12875

See merge request espressif/esp-idf!39713
2025-06-11 17:11:09 +08:00
Chen Jichang 2fb4c6771a test(pcnt): with malloc comes from PSRAM by default 2025-06-11 16:54:41 +08:00
Chen Jichang d345ac1a50 remove(legacy_pcnt): remove legacy pcnt driver in IDF v6.0 2025-06-11 16:54:41 +08:00
Chen Jichang 00b1d66c6e feat(parlio_tx): support to use dma eof on esp32c5 2025-06-11 16:37:55 +08:00
Chen Jichang f10dcd6140 feat(parlio_tx): add cache safe test 2025-06-11 16:37:55 +08:00
Chen Jichang 86d33f4460 fix(parlio_tx): update gpio state in delete function 2025-06-11 16:37:55 +08:00
Konstantin Kondrashov 3b0f4e4083 feat(efuse): Adds 3-bit field for wafer major version in ESP32-P4 2025-06-11 16:35:03 +08:00
Armando (Dou Yiwen) ae3f20fa9f Merge branch 'refactor/change_mmap_cache_lock_type' into 'master'
mmu: use cache freeze for mmap APIs

See merge request espressif/esp-idf!39199
2025-06-11 06:45:16 +00:00
armando 10d4e71323 feat(mmu): use cache freeze for mmap apis 2025-06-11 10:27:55 +08:00
Peter Macko c205f50f93 feat(ci): Migrate macOS runners to Parallels VM 2025-06-10 18:08:05 +02:00
Marek Fiala b3f24a9533 fix(tools): idf.py create-project works in read-only ESP-IDF
As the native copy function shutil.copyfile preserves directories metadata
such as file permissions, we need to ensure the copied destination
is writable for owner.

Closes https://github.com/espressif/esp-idf/issues/15964
Closes https://github.com/espressif/esp-idf/pull/16021
2025-06-10 14:48:08 +02:00
Marek Fiala 5ec67f5e2c feat(tools): adjusted create_ext.py by ruff formatter 2025-06-10 14:48:08 +02:00
Wu Zheng Hui a2257490d2 Merge branch 'feat/enable_wakeup_tests_for_more_chips' into 'master'
feat(esp_hw_support): enable wakeup tests for more chips

Closes PM-337

See merge request espressif/esp-idf!39675
2025-06-10 20:09:39 +08:00
Sylvio Alves 044de64f5b fix(esp_system): rename modem clock source selection
Make sure to use proper label for modem source selection.
This does not fix any issue.

Signed-off-by: Sylvio Alves <sylvio.alves@espressif.com>
2025-06-10 20:03:06 +08:00
Jiang Jiang Jian 916f70192f Merge branch 'bugfix/fix_mesh_sta_send_data_error_on_c5' into 'master'
fix(wifi/mesh): fixed the mesh STA sends data error on c5

Closes WIFIBUG-1222 and WIFI-6852

See merge request espressif/esp-idf!39752
2025-06-10 18:56:09 +08:00
Kevin (Lao Kaiyao) e71e7552ef Merge branch 'refactor/remove_legacy_i2s_driver' into 'master'
remove(legacy_i2s): remove legacy i2s driver in IDF v6.0

Closes IDF-13170

See merge request espressif/esp-idf!39681
2025-06-10 18:49:55 +08:00
Kevin (Lao Kaiyao) 443e8718b8 Merge branch 'bugfix/fix_touch_sens_failure' into 'master'
fix(touch): fixed channel offset issue in touch v2

Closes IDFCI-2964

See merge request espressif/esp-idf!39766
2025-06-10 18:34:53 +08:00
Island 85d74cdde8 Merge branch 'feat/support_ble_vendor_evt_report_with_param' into 'master'
feat(bt/bluedroid): Support BLE vendor event reporting with params

Closes BLERP-1624

See merge request espressif/esp-idf!37539
2025-06-10 18:22:51 +08:00
Island a4fcd06785 Merge branch 'feat/support_anonymous_addr_type_for_white_list' into 'master'
feat(ble/bluedroid): Support anonymous address type for white list

Closes BLERP-1844

See merge request espressif/esp-idf!38950
2025-06-10 18:22:40 +08:00
Island a172dac0ef Merge branch 'bugfix/fix_blecibr25_119' into 'master'
fix(ble/bluedroid): Fixed extended adv restart failure during reconnection

Closes BLERP-1969, BLERP-1970, BLERP-1971, and BLERP-1979

See merge request espressif/esp-idf!39709
2025-06-10 18:22:36 +08:00
Song Ruo Jing 0fa5b07c7e Merge branch 'feature/esp32c61_eco3_gpio_update' into 'master'
change(gpio): add GPIO25~29 for ESP32C61 ECO3

Closes IDF-12874 and IDF-9316

See merge request espressif/esp-idf!39714
2025-06-10 16:17:05 +08:00
Aditya Patwardhan f4e8813d45 Merge branch 'contrib/github_pr_15972' into 'master'
feat(esp_http_client): Event to signal last header downloaded (GitHub PR)

See merge request espressif/esp-idf!39309
2025-06-10 13:08:10 +05:30
C.S.M 446e2fce11 Merge branch 'bugfix/jpeg_dec_black_line' into 'master'
bugfix(jpeg): eliminate random black line on jpeg decoder

Closes IDF-13158

See merge request espressif/esp-idf!39742
2025-06-10 15:32:16 +08:00
morris 3550140131 Merge branch 'bugfix/ana_cmpr_cache_safe_test' into 'master'
fix(ana_cmpr): regression in the cache safe test

Closes IDFCI-2951 and IDFCI-2952

See merge request espressif/esp-idf!39764
2025-06-10 15:31:03 +08:00
laokaiyao b25f3fa966 fix(touch): fixed channel offset issue in touch v2 2025-06-10 15:06:23 +08:00
chenjianhua 6392180813 fix(ble/bluedroid): Fixed extended adv restart failure during reconnection 2025-06-10 15:06:03 +08:00
Alexey Lapshin 555c511d28 feat(build): change orphan-handling behavior to error 2025-06-10 14:44:01 +08:00
Zhou Xiao 7847a82b28 change(ble): resupport ble for ESP32C61ECO3 2025-06-10 14:34:49 +08:00
morris baa888e09b fix(ana_cmpr): regression in the cache safe test 2025-06-10 13:52:58 +08:00
laokaiyao 6eb5bfe587 remove(legacy_i2s): remove legacy i2s driver in IDF v6.0 2025-06-10 12:23:23 +08:00
chenjianhua 71e15a1085 feat(ble/bluedroid): Add config for BLE vendor hci command and event 2025-06-10 10:54:18 +08:00
morris 2fbb86deb7 feat(axi): add low level function for adjusting the arbitration priority 2025-06-10 10:32:01 +08:00
wuzhenghui 96c6c0db67 feat(esp_hw_support): enable wakeup tests for more chips 2025-06-10 10:21:19 +08:00
David Čermák c10d3ac9ff Merge branch 'update/wifi_remote' into 'master'
change(examples): Re-enable examples which need esp_wifi_remote

See merge request espressif/esp-idf!39067
2025-06-10 00:42:09 +08:00
wuzhenghui 1c95cdf649 fix(hal): fix pmu_ll_ext1_clear_wakeup_status API 2025-06-09 20:32:48 +08:00
chenjianhua 0fe1586a55 feat(ble/bluedroid): Support BLE vendor event reporting with params 2025-06-09 20:26:18 +08:00
chenjianhua 913645d239 feat(ble/bluedroid): Support anonymous address type for white list 2025-06-09 19:41:54 +08:00
Song Ruo Jing da4ac0c56a feat(gpio): update GPIO capabilities IO0-29 for ESP32-C61 ECO3 2025-06-09 19:09:49 +08:00
zhangyanjiao 3c403e97e1 fix(wifi/mesh): fixed the mesh STA sends data error on c5 2025-06-09 17:51:00 +08:00
Ondrej Kosta 48b37dd56e Merge branch 'contrib/github_pr_16016' into 'master'
Enable Timestamping for Non-PTP Ethernet frames (GitHub PR)

Closes IDFGH-15359

See merge request espressif/esp-idf!39581
2025-06-09 16:58:07 +08:00
Island 23d71fecd6 Merge branch 'feat/add_cte_iq_report_example' into 'master'
Add Bluetooth LE CTE connless example.

See merge request espressif/esp-idf!39327
2025-06-09 16:41:21 +08:00
David Cermak a39d38994f fix(lwip): Fix appending DHCP option with HW-ID 2025-06-09 10:29:24 +02:00
David Cermak d49f4d31d0 fix(examples): Update wifi-remote dependency to include IDF-v6
Use esp_wifi_remote version < v2.0
Planned release v1.0 to support remote and native coexistence, which
should be still compatible with IDFv5.x and IDFv6.x
2025-06-09 10:25:52 +02:00
David Cermak 8fede49368 change(examples): Re-enable examples which need esp_wifi_remote
This reverts commit 7023b489a7.
2025-06-09 10:25:48 +02:00
morris 4233552ce4 Merge branch 'ci/kconfig_change_should_build_full_doc' into 'master'
ci(doc): kconfig change should trigger a full doc build

See merge request espressif/esp-idf!39623
2025-06-09 15:01:36 +08:00
Jiang Jiang Jian 39a44b4a94 Merge branch 'fix/add_check_for_wifi_set_config' into 'master'
fix(wifi): add check for esp_wifi_set_config

See merge request espressif/esp-idf!39683
2025-06-09 14:44:00 +08:00
Island f1dd6da8a3 Merge branch 'bugfix/fix_ble_init_exception' into 'master'
Fixed double free exception during BLE init under low memory

Closes BLERP-1954

See merge request espressif/esp-idf!39680
2025-06-09 14:38:32 +08:00
Harshal Patil c85075dc12 Merge branch 'update/update_cmn_crt_authorities_csv' into 'master'
Update common cert authorities csv

See merge request espressif/esp-idf!39564
2025-06-09 12:08:03 +05:30
C.S.M 724ce1fc97 Merge branch 'feature/suspend_support_c5_c61' into 'master'
feat(spi_flash): Add spi flash suspend support on esp32c5, esp32c61

Closes IDF-12879 and IDF-12635

See merge request espressif/esp-idf!39652
2025-06-09 14:30:02 +08:00
C.S.M c490702340 bugfix(jpeg): eliminate random black line on jpeg decoder 2025-06-09 14:14:20 +08:00
Aditya Patwardhan 8d0527d7bf Merge branch 'feat/support_sha512_for_esp32c5' into 'master'
Support SHA 512 for ESP32-C5

See merge request espressif/esp-idf!39421
2025-06-09 09:42:37 +05:30
wangtao@espressif.com ce3611db26 fix(wifi): add check for esp_wifi_set_config 2025-06-09 11:52:01 +08:00
Laukik Hase 5b7922b028 Merge branch 'refactor/apm_tee_ll_hal' into 'master'
refactor(hal): Refactor the APM LL/HAL APIs

Closes IDF-10423 and IDF-12830

See merge request espressif/esp-idf!38522
2025-06-09 09:13:26 +05:30
Island 71da548124 Merge branch 'change/ble_update_lib_20250606' into 'master'
change(ble): [AUTO_MR] 20250606 - Update ESP BLE Controller Lib

Closes BLERP-1921, BLERP-1919, BLERP-1955, BLERP-1951, BLERP-1950, BLERP-1933, BLERP-1932, BLERP-1929, BLERP-1927, BLERP-1893, BLERP-1885, and BLERP-1900

See merge request espressif/esp-idf!39712
2025-06-09 10:57:03 +08:00
morris 3b504812df Merge branch 'refactor/remove_legacy_timer_driver' into 'master'
!Remove legacy timer group driver

Closes IDF-13169

See merge request espressif/esp-idf!39346
2025-06-09 10:56:06 +08:00
Kevin (Lao Kaiyao) c1666c8033 Merge branch 'refactor/p4_touch_channel_increase_1' into 'master'
refactor(touch): adjust touch channel number on P4 from 0-13 to 1-14

Closes IDF-12744

See merge request espressif/esp-idf!39331
2025-06-09 10:37:17 +08:00
Zhang Shu Xian ec689969c2 Merge branch 'docs/add_doc_link_for_esp32p4' into 'master'
docs: Update hw-reference/index.rst for esp32p4

Closes DOC-8754

See merge request espressif/esp-idf!39707
2025-06-09 10:35:10 +08:00
Gao Xu 18e884532b Merge branch 'camera/add_dvp_example' into 'master'
P4 DVP example and bugfix

See merge request espressif/esp-idf!39308
2025-06-09 09:57:14 +08:00
laokaiyao 6d2bfc70c1 fix(touch): fixed incorrect interval clock source 2025-06-08 22:08:00 +08:00
laokaiyao 0f2c1ab859 refactor(touch): adjust touch channel number on P4 from 0-13 to 1-14 2025-06-08 22:08:00 +08:00
Espressif BOT da1842ea0f change(mbedtls/crt_bundle): Update esp_cmn_crt_bundle certificates 2025-06-08 13:35:51 +05:30
Rahul Tank adcbdd7da4 Merge branch 'bugfix/add_missing_deinit_call' into 'master'
fix(nimble): Add invocation for mempool_deinit

Closes BT-4026

See merge request espressif/esp-idf!39664
2025-06-07 18:34:54 +05:30
David Cermak c57254c4b1 fix(esp_netif): Fix reasigning static IP after netif down -> up
Fixes regression from 307f45d5 (ip_info should be cleaned, but only if we're running DHCP client on that netif)
2025-06-06 15:43:53 +02:00
Laukik Hase 0d8a1f5427 refactor(hal): Refactor the APM LL/HAL APIs 2025-06-06 18:28:47 +05:30
Abhinav Kudnar b03186d71f fix(nimble): memset the sync structs to prevent uncertainty for ext_adv reports 2025-06-06 16:58:48 +05:30
Aditya Patwardhan d835854c8f Merge branch 'bugfix/fix_tls1_3_dynamic_buffer_build' into 'master'
fix(mbedtls): Fix failing build with TLS1.3 only and dynamic buffer enabled

Closes IDF-13140

See merge request espressif/esp-idf!39319
2025-06-06 16:09:25 +05:30
Jiang Jiang Jian a3cf6468b1 Merge branch 'bugfix/fix_cant_enter_modem_sleep_after_probe_disassoc' into 'master'
fix(wifi): fix cant sleep if connection breaks during sending probe

Closes AUD-6394

See merge request espressif/esp-idf!39702
2025-06-06 18:08:54 +08:00
morris 6bbd68b1f8 ci(doc): kconfig change should trigger a full doc build 2025-06-06 18:00:16 +08:00
cjin a10696d7e1 fix(ble): change the default ble cca thresh on ESP32-C2 2025-06-06 17:57:35 +08:00
cjin a2fab0ad60 fix(ble): change the default ble cca thresh on ESP32-H2 2025-06-06 17:57:04 +08:00
cjin 581521526b fix(ble): change the default ble cca thresh on ESP32-C6 2025-06-06 17:56:55 +08:00
cjin c802176535 fix(ble): change the default ble cca thresh on ESP32-C5 2025-06-06 17:56:44 +08:00
zwl 6c5bff1bd8 fix(ble): change ld file on ESP32-C2 2025-06-06 17:56:32 +08:00
zwl 44d7fc43f6 fix(ble): fixed an occasional abnormal scanning stop issue on ESP32-C5 2025-06-06 17:56:23 +08:00
zwl 3c8ba488e0 fix(ble): fixed an occasional assertion issue during sync on ESP32-C6 2025-06-06 17:56:11 +08:00
zwl 4be18a2469 change(ble): [AUTO_MR] Update lib_esp32c2 to 7f72c031 2025-06-06 17:55:08 +08:00
zwl 57c8d23800 change(ble): [AUTO_MR] Update lib_esp32c6 to 35fe65f4 2025-06-06 17:55:08 +08:00
zwl dacaae746e change(ble): [AUTO_MR] Update lib_esp32c5 to 35fe65f4 2025-06-06 17:55:08 +08:00
zwl dbf7835a6b change(ble): [AUTO_MR] Update lib_esp32h2 to 35fe65f4 2025-06-06 17:55:07 +08:00
Geng Yuchao aa4489a879 feat(esp32c5): Enable Bluetooth LE CTE feature 2025-06-06 17:52:41 +08:00
Geng Yuchao d8631ed3db feat(ble): Add Bluetooth LE CTE connectionless AoA/AoD examples 2025-06-06 17:52:41 +08:00
Guillaume Souchere 139df47cf3 feat(usb_cdc): Update vfs read() to comply with POSIX standards 2025-06-06 11:41:26 +02:00
Frangen, Leon eae1f3c302 feat(esp_eth): Enable rx/tx timestamp for non-PTP frames via ioctl 2025-06-06 11:35:10 +02:00
harshal.patil 85ec4df4db change(mbedlts/port): Remove deprecated header files 2025-06-06 14:52:03 +05:30
harshal.patil fe78370ec9 feat(mbedtls/sha): New API for setting SHA mode 2025-06-06 14:51:44 +05:30
harshal.patil afdf1a31c8 feat(soc): Update ESP32-C5 ECO2 to support SHA512 2025-06-06 14:51:44 +05:30
Armando (Dou Yiwen) d0aabd36b4 Merge branch 'fix/fix_xip_psram_ptr_check' into 'master'
psram: fixed psram ptr check issue under xip_psram condition for ESP32P4

Closes IDFGH-15338, IDFGH-15340, and IDF-12458

See merge request espressif/esp-idf!39405
2025-06-06 08:54:34 +00:00
gaoxu b173783d92 docs(camera): add lcd_cam dvp driver docs for camera 2025-06-06 16:53:51 +08:00
Kapil Gupta bc93cee52e Merge branch 'bugfix/set_default_ap_mgmt_cipher' into 'master'
fix(esp_wifi): Set default ap mgmt cipher

See merge request espressif/esp-idf!39691
2025-06-06 14:00:04 +05:30
Roland Dobai 5799f556b4 Merge branch 'break/drop_gdbgui' into 'master'
Tools: Drop official support for gdbgui

Closes IDF-4627

See merge request espressif/esp-idf!39326
2025-06-06 10:23:44 +02:00
Zhang Shuxian 8b30f85f2f docs: Update hw-reference/index.rst for esp32p4 2025-06-06 16:23:43 +08:00
Armando (Dou Yiwen) af69042685 Merge branch 'fix/fix_c5_eco2_psram_wrong_tuning_point' into 'master'
psram: fixed wrong psram tuning point on c5 eco2

See merge request espressif/esp-idf!39642
2025-06-06 07:57:57 +00:00
Marius Vikhammer 24c15284db Merge branch 'bugfix/c5_newlib_tests' into 'master'
test(newlib): fixed failing C5 ECO2 newlib tests

Closes IDFCI-2879

See merge request espressif/esp-idf!39639
2025-06-06 15:50:35 +08:00
morris a04df4631e refactor(gptimer)!: removed the legacy driver
also provide idy.py hints instructions
2025-06-06 15:11:26 +08:00
C.S.M b194636859 feat(spi_flash): Add spi flash suspend support on esp32c5, esp32c61 2025-06-06 15:03:41 +08:00
Zhang Wen Xu 4a80901841 Merge branch 'fix/rx_abort_next_op' into 'master'
fix(openthread): disable rx_abort events in next operation

See merge request espressif/esp-idf!39708
2025-06-06 06:55:04 +00:00
Marius Vikhammer 27f232a929 test(newlib): fixed failing C5 ECO2 newlib tests 2025-06-06 08:38:24 +02:00
Roland Dobai 3efb46e480 remove(tools): Drop official support for gdbgui 2025-06-06 14:32:05 +08:00
Roland Dobai 532ea1ad6d change(tools): fix the style of debug_ext.py 2025-06-06 14:32:05 +08:00
Li Shuai ea4787e6e6 Merge branch 'bugfix/idfci-2959' into 'master'
fix ci build doc field on power management and sleep rst text

Closes IDFCI-2959 and IDFCI-2960

See merge request espressif/esp-idf!39643
2025-06-06 14:29:26 +08:00
Tan Yan Quan ce970143bb fix(openthread): disable rx_abort events in next operation 2025-06-06 12:26:44 +08:00
gaoxu 1533cab12b fix(cam): fix dvp do not generate clock 2025-06-06 11:50:18 +08:00
armando 3b2c6aee2e fix(psram): fixed wrong psram tuning point on c5 eco2 2025-06-06 02:49:59 +00:00
armando 7a6cd632c5 fix(psram): fixed psram ptr check under xip_psram condition
Closes https://github.com/espressif/esp-idf/pull/15999
Closes https://github.com/espressif/esp-idf/issues/15997
2025-06-06 10:11:32 +08:00
John Boiles 0e680775f9 fix(memory-utils): Add _instruction_reserved_start/end to esp_psram_check_ptr_addr
Adds missing range check that can be used when SPIRAM_XIP_FROM_PSRAM is enabled.
2025-06-06 10:11:32 +08:00
John Boiles 6287650225 fix(freertos): Use ESP_EARLY_LOGE in vPortTLSPointersDelCb for RISCV
Using ESP_LOG* in this function causes a crash
2025-06-06 10:11:32 +08:00
liuning 4323627865 fix(wifi): fix cant sleep if connection breaks during sending probe 2025-06-05 20:48:46 +08:00
Jiang Jiang Jian dc814f241a Merge branch 'bugfix/dpp_sync_issue' into 'master'
fix(esp_wifi): Fixed DPP concurrency issue

Closes WIFIBUG-1229

See merge request espressif/esp-idf!38832
2025-06-05 19:49:44 +08:00
Guillaume Souchere 24048d8267 feat(usb_serial_tag_vfs): Add test for read exit conditions
Add a test to make sure the VFS read does not return on reception
of the \n character
2025-06-05 12:14:50 +02:00
Kapil Gupta 514853d2e3 fix(esp_wifi): Set default ap mgmt cipher 2025-06-05 15:35:20 +05:30
Shu Chen de3b6ff3d6 Merge branch 'feat/add_config_for_openthread' into 'master'
feat(openthread): add some configurations in Kconfig

Closes TZ-1823

See merge request espressif/esp-idf!39609
2025-06-05 09:17:25 +00:00
Kapil Gupta 3c84fd7b4d fix(esp_wifi): Make sure old DPP listen is cancelled 2025-06-05 16:55:21 +08:00
Kapil Gupta ab9304d3b7 fix(esp_wifi): Modify check for dpp event handlers 2025-06-05 16:55:21 +08:00
Kapil Gupta a929aae33f change(esp_wifi): Update dpp enrollee example to use updated events 2025-06-05 16:55:21 +08:00
Kapil Gupta 15c336bf49 fix(esp_wifi): Update dpp code to send events in freeRTOS context 2025-06-05 16:55:21 +08:00
Kapil Gupta 76723c063a fix(esp_wifi): Fixed DPP concurrency issue 2025-06-05 16:55:21 +08:00
hrushikesh.bhosale 5928a87aa7 feat(mbedtls): Add configuration to control dynamic buffer strategy in mbedtls
Problem:
1. In low-memory scenarios, the dynamic buffer feature can fail due to memory fragmentation.
2. It requires a contiguous 16KB heap chunk, but continuous allocation and deallocation of
the RX buffer can lead to fragmentation.
3. If another component allocates memory between these operations, it can break up the
available 16KB block, causing allocation failure.

Solution:
1. Introduce configurable strategy for using dynamic buffers in TLS connections.
2. For example, convert RX buffers to static after the TLS handshake.
3. Allow users to select the strategy via a new field in the esp_http_client_cfg_t structure.
4. The strategy can be controlled independently for each TLS session.
2025-06-05 12:43:47 +05:30
gaoxu 2a13a36589 feat(cam): add esp32p4 dvp example 2025-06-05 14:58:58 +08:00
Li Shuai c6c2948a99 change(unit-test): filter top domain power down check for some sleep test cases 2025-06-05 14:28:15 +08:00
zhanghaipeng 49a4325b15 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(4713a69)
- Fixed double free exception during BLE init under low memory
2025-06-05 11:10:25 +08:00
Island 92883fbbdf Merge branch 'feat/ble_mesh_micellaneous_fix' into 'master'
Feat/ble mesh micellaneous fix

Closes BLERP-1939, BLERP-1938, BLERP-1937, and BLERP-1940

See merge request espressif/esp-idf!39519
2025-06-05 10:34:35 +08:00
Rahul Tank 2209a6c0b5 Merge branch 'feat/nimble_ancs_final' into 'master'
fix(nimble): Added support for ANCS in nimble

See merge request espressif/esp-idf!39565
2025-06-04 19:13:29 +05:30
Li Shuai 7912f9fafe change(esp_hw_support): force top domain power up during sleep 2025-06-04 21:03:02 +08:00
Frantisek Hrbata 63b7ae9ad1 fix(esp_common/cmake): do not rely on the target variable being set
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-04 19:50:27 +08:00
Frantisek Hrbata b84e9b69ba fix(newlib/cmake): avoid using uninitialized ldfragments variable
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-04 19:50:27 +08:00
Frantisek Hrbata 26e49e1e82 fix(vfs/cmake): avoid using uninitialized sources variable
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-04 19:50:27 +08:00
Frantisek Hrbata 56ac76d4d2 fix(esp_coex/cmake): avoid using uninitialized srcs variable
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-04 19:50:27 +08:00
Frantisek Hrbata f50ae95ab5 fix(lwip/cmake): avoid using uninitialized srcs variable
Currently, lwip's CMakeLists.txt might use an uninitialized srcs value
if CONFIG_LWIP_ENABLE is disabled. This means it could use a srcs value
set by another component, involving sources that are entirely
unrelated to the lwip component during registration. Perhaps we
should simply exit when CONFIG_LWIP_ENABLE is not enabled and avoid
registering the component altogether.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-04 19:50:27 +08:00
Rahul Tank c62b4c7994 fix(nimble): Add invocation for mempool_deinit 2025-06-04 16:35:59 +05:30
Fu Hanxi fc4b2fbc28 Merge branch 'ci/disable-plugin-idf_ci' into 'master'
ci: disable idf-ci plugin

See merge request espressif/esp-idf!39600
2025-06-04 12:12:18 +02:00
Island 7d25722980 Merge branch 'bugfix/fix_ble_smp_fail_0x82' into 'master'
Bugfix/fix ble smp fail 0x82

Closes BLERP-1949

See merge request espressif/esp-idf!39494
2025-06-04 17:08:31 +08:00
Li Shuai f8832b583c Revert "fix(esp_pm): esp32c5 eco2 disable top pd to avoid mem being changed during sleep"
This reverts commit 8c2ea986b4.
2025-06-04 14:15:16 +08:00
Astha Verma a045046a7a fix(nimble): Added support for ANCS in nimble 2025-06-04 08:08:22 +05:30
Kapil Gupta 4ce1da7569 Merge branch 'fix/bcast_mgmt_api' into 'master'
Add BIP support for AP mode.

Closes WIFIBUG-1155

See merge request espressif/esp-idf!38249
2025-06-03 21:46:01 +05:30
tarun.kumar 9abd30adc0 fix(wifi): Made changes in api for sending bcast deauth frames 2025-06-03 20:33:56 +05:30
Marius Vikhammer 6aeba18713 Merge branch 'feature/misc_core_iram' into 'master'
feat(core): added option for placing more core functions in flash

See merge request espressif/esp-idf!39489
2025-06-03 21:44:04 +08:00
Rahul Tank 44ba32bef7 fix(nimble): Modified Kconfig information to make it more user friendly 2025-06-03 16:00:54 +05:30
Roland Dobai a2b7ce698b Merge branch 'feat/ksh_compatible_shells' into 'master'
fix(tools): add support for shells compatible with ksh

Closes IDFGH-15389

See merge request espressif/esp-idf!39602
2025-06-03 12:11:23 +02:00
Jiang Jiang Jian 473f316906 Merge branch 'bugfix/fix_coex_ble_disc' into 'master'
fix(coex): Fix ble disconnect when coexisting wifi on esp32c2

Closes BT-4021

See merge request espressif/esp-idf!39522
2025-06-03 18:08:38 +08:00
Jiang Jiang Jian 1294da2754 Merge branch 'fix/fix_esp32c2_auth_thre_issue' into 'master'
fix(wifi): fix eps32c2 auth threshold issue

Closes WIFIBUG-1231, WIFIBUG-1235, WIFIBUG-1236, and WIFIBUG-1237

See merge request espressif/esp-idf!39496
2025-06-03 18:05:13 +08:00
Guillaume Souchere a3270694f0 fix(driver): remove unecessary if conditions in the read function
This changes affect usb_serial_jtag_vfs and cdcacm_vfs read functions.
This commit removes the exit condition on reception of \n character.
2025-06-03 12:04:14 +02:00
David Čermák 469a39bb22 Merge branch 'fix/netif_ppp_dhcp' into 'master'
fix(esp_netif): Fix incorrect DHCP call for PPP interfaces

Closes IDFGH-15097

See merge request espressif/esp-idf!38403
2025-06-03 17:59:13 +08:00
Radek Tandler efb4d5766a Merge branch 'feature/storage_nvs_perf_blob' into 'master'
Improvement of NVS Blob performance

See merge request espressif/esp-idf!39084
2025-06-03 11:41:29 +02:00
Fu Hanxi efcb8a5a49 Merge branch 'feat/support_kconfig_in_pacman' into 'master'
feat: support kconfig in component manager

Closes PACMAN-963 and PACMAN-686

See merge request espressif/esp-idf!35526
2025-06-03 11:38:47 +02:00
morris 4a8e0d85e4 Merge branch 'fix/gptimer_sleep_retention_case' into 'master'
test(gptimer): power domain is not power down on esp32c5

Closes IDFCI-2923 and IDFCI-2922

See merge request espressif/esp-idf!39591
2025-06-03 17:24:31 +08:00
Xu Si Yu 3c01fd8301 feat(openthread): add some configurations in Kconfig 2025-06-03 16:29:46 +08:00
luoxu 7f95986a0e feat(ble_mesh): update lib to f15b27e2d2 2025-06-03 15:34:32 +08:00
luoxu 224b7e158d fix(ble_mesh): fixed issue with recv ntf before ccc done 2025-06-03 15:34:32 +08:00
luoxu 7738bca124 fix(ble_mesh): fixed proxy server might send segment message with incorrect format 2025-06-03 15:34:32 +08:00
luoxu d4cd6e5741 feat(ble_mesh): support ble 50 for esp32c6 series chip 2025-06-03 15:34:32 +08:00
Frantisek Hrbata 28e3112cde fix(tools): ruff-format changes for shell_types.py
Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-03 09:26:50 +02:00
Frantisek Hrbata 1f8ced8e6f fix(tools): add support for shells compatible with ksh
Currently, the export tools are detecting only ksh, but there are also
compatible variants like pdksh and others. This update adds support for
such ksh-compatible shells to improve export tool compatibility with ksh
variants.

Closes https://github.com/espressif/esp-idf/issues/16043

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-06-03 09:22:53 +02:00
Fu Hanxi 9f4b9d815a feat: support kconfig in component manager 2025-06-03 08:43:09 +02:00
Fu Hanxi 87a5aedb85 ci: disable idf-ci plugin
this plugin will be re-enabled with compatible code in !38755
2025-06-03 08:37:56 +02:00
Jiang Jiang Jian 11ad7e0581 Merge branch 'fix/retry_cnt_issue_for_non_pmf_sta' into 'master'
fix(failure_retry_cnt): Prevent NON-PMF STA retries if esp_wifi_disconnect() before handshake

Closes WIFIBUG-1226

See merge request espressif/esp-idf!39497
2025-06-03 14:05:56 +08:00
Shu Chen 1f45f98573 Merge branch 'feature/optimize-zcl-utility-path' into 'master'
feat(zigbee): optimize the path of zcl_utility

See merge request espressif/esp-idf!39506
2025-06-03 04:30:03 +00:00
Nachiket Kukade 5036509679 Merge branch 'bugfix/enable_ipv6_if_nan' into 'master'
bugfix(wifi): Enable IPv6 support via LWIP_IPV6 when WiFi Aware(NAN) is enabled

Closes WIFIBUG-1215

See merge request espressif/esp-idf!39385
2025-06-03 12:07:42 +08:00
Wan Lei 50ef5946cb Merge branch 'test/spi_common_gpio_refa' into 'master'
feat(driver_spi): gpio reserve support for spi master/slave/slave_hd driver

Closes IDF-9107 and IDF-11126

See merge request espressif/esp-idf!31301
2025-06-03 11:21:43 +08:00
Island 15414f99c3 Merge branch 'fix/ble_log_spi_out_timer_delete' into 'master'
fix(ble): set timer handle to null after deletion

Closes BLERP-1941 and BLERP-1942

See merge request espressif/esp-idf!39548
2025-06-03 11:16:49 +08:00
morris bf950e7dc5 test(gptimer): power domain is not power down on esp32c5 2025-06-03 11:15:24 +08:00
Island f51c769d99 Merge branch 'bugfix/fix_ble_crash_when_check_send_pkts' into 'master'
fix(ble/bluedroid): Fixed null pointer assert in l2c_link_check_send_pkts

Closes BLERP-1944

See merge request espressif/esp-idf!39463
2025-06-03 10:41:41 +08:00
Omar Chebib 0e6c063a13 Merge branch 'bugfix/clic_mapping_mask' into 'master'
fix(hal): make CLIC interrupt routing function to only write related bits

Closes IDF-8654 and IDF-9262

See merge request espressif/esp-idf!39320
2025-06-03 10:15:50 +08:00
Ivan Grokhotkov 441b801bc8 Merge branch 'fix/latest_tag_v6' into 'master'
fix(ci): Fix the latest tag to master's v6.0-dev

See merge request espressif/esp-idf!39413
2025-06-02 17:01:57 +02:00
radek.tandler c23c21f3c0 refactor(nvs_flash): Improved Blob performance
The findItem method was improved to use a hash list in RAM when searching for BLOB data chunks

The findItem method was extended with a parameter that returns the position of an item on the page,
if it is found

The algorithm for matching existing variable-length data (such as strings and BLOBs) with
new values was enhanced by comparing the CRC32 of the data chunks before reading the data from flash
2025-06-02 16:01:40 +02:00
akshat ad164f5d57 bugfix(wifi): Define ETH_ALEN for IPV6 Communication Type 2025-06-02 15:44:39 +05:30
akshat 5dcd1a578b bugfix(wifi): Enable IPv6 support via LWIP_IPV6 when WiFi Aware(NAN) is enabled 2025-06-02 15:44:39 +05:30
Ashish Sharma 2ef09a7952 fix(esp_tls): fix failing build with TLS1.3 only and dynamic buffer 2025-06-02 09:14:03 +08:00
David Cermak 63acb01dc1 fix(esp_netif): Rename IP_EVENT_AP_STAIPASSIGNED to generic name
Since it's the DHCP server that assigned and IP to a client,
(the DHPCS doesn't have to be an AP, and DHCPC doesn't have to
be a station or an Eth netif)

Closes https://github.com/espressif/esp-idf/issues/15663
2025-05-30 16:42:38 +02:00
Marius Vikhammer 4d27e1a399 change(freertos): vApplicationStackOverflowHook is now flashed in flash if option enabled
CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH will now also place vApplicationStackOverflowHook in
flash
2025-05-30 14:22:54 +02:00
Marius Vikhammer db3946ab9f change(heap): moved tlsf patch functions to flash 2025-05-30 14:07:13 +02:00
Roland Dobai 47d20da4cd Merge branch 'change/support_lowercase_kconfig_filename' into 'master'
Support misspelled Kconfig[.projbuild] files

Closes IDFGH-15241

See merge request espressif/esp-idf!39183
2025-05-30 11:53:10 +02:00
zhanghaipeng 8150573012 fix(ble/bluedroid): Fixed null pointer assert in l2c_link_check_send_pkts 2025-05-30 17:37:21 +08:00
Jiang Jiang Jian d4129533e6 Merge branch 'bugfix/esp32c5_eco2_cpulockup_top_pu' into 'master'
esp32c5 eco2 disable digitall peripherals power down to avoid mem being changed during sleep

Closes PM-410, PM-406, and PM-436

See merge request espressif/esp-idf!39530
2025-05-30 17:15:23 +08:00
Kevin (Lao Kaiyao) d86a84edfd Merge branch 'change/sync_trm_csv_update_5_27' into 'master'
change(csv_update): sync the csv update to idf

See merge request espressif/esp-idf!39459
2025-05-30 16:00:04 +08:00
Zhou Xiao 1614e71eb6 fix(ble): set timer handle to null after deletion 2025-05-30 15:23:05 +08:00
Krzysztof Budzynski a9cdd337ce Merge branch 'contrib/github_pr_15944' into 'master'
Update CLion documentation page (GitHub PR)

Closes IDFGH-15285

See merge request espressif/esp-idf!39258
2025-05-30 15:04:25 +08:00
Shu Chen 1bb75b2fb9 Merge branch 'feat/and_function_to_exit_ot_mainloop' into 'master'
feat(openthread): add a function to exit openthread mainloop safely

Closes TZ-1796

See merge request espressif/esp-idf!39389
2025-05-30 06:58:26 +00:00
Wan Lei 6cd14c143b Merge branch 'feat/twai_driver_add_programming_guide' into 'master'
feat(driver_twai): new driver add programming guide

Closes IDF-9466

See merge request espressif/esp-idf!39013
2025-05-30 14:27:33 +08:00
renpeiying 94190ff7a9 docs: Add CN translation to CLion doc 2025-05-30 14:07:49 +08:00
wangtao@espressif.com 5521ddff22 fix(wifi): fix esp32c2 auth threshold issue 2025-05-30 13:51:00 +08:00
C.S.M 36a5a71d5c Merge branch 'feat/i2c_support_c61' into 'master'
refactor(i2c): Remove slave_v2 source file

See merge request espressif/esp-idf!39516
2025-05-30 11:34:45 +08:00
Wang Meng Yang 8f224d6a63 Merge branch 'change/opt_hid_device_connect_description' into 'master'
docs(bt/bluedroid): Updated HID Device connect API description

Closes IDFGH-15363

See merge request espressif/esp-idf!39434
2025-05-30 07:12:06 +08:00
Sarvesh Bodakhe bebfd14ae5 fix(wif): Prevent NON-PMF STA retries if esp_wifi_disconnect() before handshake
Ensure that NON-PMF station does not attemp connection retries when
'esp_wifi_disconnect()' is called before the 4-way-handshake completes,
even if 'failure_retry_cnt' allows retries.
2025-05-29 21:46:49 +05:30
Jiang Jiang Jian fed2fb0a23 Merge branch 'bugfix/add_more_checks_when_receiving_espnow' into 'master'
fix(wifi): Added more check when receiving espnow data

Closes WIFI-6846

See merge request espressif/esp-idf!38593
2025-05-29 21:24:28 +08:00
wanckl 77277b59fc feat(driver_twai): new driver add programming guide 2025-05-29 21:00:50 +08:00
Jan Beran c6a0d9118e change: Support misspelled Kconfig[.projbuild] file names
If the name is misspelled, CMake prints out a warning.
Original issue: https://github.com/espressif/esp-idf-kconfig/issues/14
2025-05-29 14:18:20 +02:00
Li Shuai 8c2ea986b4 fix(esp_pm): esp32c5 eco2 disable top pd to avoid mem being changed during sleep 2025-05-29 20:14:13 +08:00
Island 44895c0b3a Merge branch 'fix/ble_mesh_solic_tx_pdu_fix' into 'master'
fix(ble_mesh): fixed issues with proxy solic pdu adv

Closes BLERP-1931

See merge request espressif/esp-idf!39480
2025-05-29 20:07:13 +08:00
Chen Ji Chang 713a63fb9f Merge branch 'feat/gdma_weight_based_arbitration' into 'master'
feat(gdma): support gdma weighted arbitration on C5 ECO2

Closes IDF-8007

See merge request espressif/esp-idf!32826
2025-05-29 19:59:44 +08:00
linruihao 3dc6313c21 fix(coex): Fix ble disconnect when coexisting wifi on esp32c2 2025-05-29 19:20:10 +08:00
C.S.M 99aa39f8e8 refactor(i2c): Remove slave_v2 source file 2025-05-29 18:52:58 +08:00
Rahul Tank adf1c5bc97 Merge branch 'bugfix/add_ci_files' into 'master'
fix(nimble): Add CI files for base configurations

Closes BLERP-1896

See merge request espressif/esp-idf!37954
2025-05-29 14:06:13 +05:30
laokaiyao fb32407754 change(pmu): update pmu sig soc headers of c5 2025-05-29 14:55:14 +08:00
laokaiyao 7f2d5939b5 change(pms): update pms soc headers of p4 2025-05-29 14:55:14 +08:00
laokaiyao f5748246ea change(ecdsa): update ecdsa soc headers of h21 2025-05-29 14:55:14 +08:00
liqigan 31c8dac885 docs(bt/bluedroid): Updated HID Device connect API description
Closes https://github.com/espressif/esp-idf/issues/16020
2025-05-29 14:52:21 +08:00
Wang Meng Yang 6177115241 Merge branch 'fear/add_avrcp_init_state_event' into 'master'
feat(bt/bluedroid): Add events to indicate the initialization states of AVRCP

Closes CBI-1400 and BTQABR2023-507

See merge request espressif/esp-idf!39278
2025-05-29 14:47:02 +08:00
luoxu ca30088aa8 fix(ble_mesh): fixed issues with proxy solic pdu adv 2025-05-29 14:40:49 +08:00
zhangyanjiao edc227c5ea fix(wifi): Added more check when receiving espnow data 2025-05-29 14:31:54 +08:00
Hrushikesh Bhosale 4ffb3fb32d Merge branch 'feat/add_support_for_cert_bundle_for_advanced_ota_example' into 'master'
fix(advanced_ota): Added support for cert bundle in advanced OTA

See merge request espressif/esp-idf!39219
2025-05-29 13:57:00 +08:00
Harshal Patil e05390f338 Merge branch 'update/update_certs_bundle' into 'master'
Update esp_crt_bundle certificates

See merge request espressif/esp-idf!39302
2025-05-29 11:12:38 +05:30
Omar Chebib a7388ddc6c fix(hal): make CLIC interrupt routing function to only write related bits 2025-05-29 12:29:40 +08:00
Chen Jichang 16d25b4a52 feat(gdma): support gdma weighted arbitration on ESP32C5 2025-05-29 11:41:02 +08:00
zhanghaipeng 99121258d4 fix(ble/bluedroid): Fixed BLE SMP state machine inconsistency on disconnection 2025-05-29 10:50:50 +08:00
xieqinan@espressif.com 8806db34a3 feat(zigbee): optimize the path of zcl_utility 2025-05-29 10:36:45 +08:00
zhanghaipeng de9a367f13 feat(ble/bluedroid): Include SMP state in BLE status reporting 2025-05-29 10:36:26 +08:00
Island bb41e4163b Merge branch 'fix/ble_mesh_micellaneous_update' into 'master'
feat(ble_mesh): Fix/ble mesh micellaneous update

Closes BLERP-1894

See merge request espressif/esp-idf!39466
2025-05-29 10:35:46 +08:00
Island ccda40d8f2 Merge branch 'feat/ble_mesh_unify_tinycrypto' into 'master'
feat(ble_mesh): unify tinycrypto component

Closes BLERP-1934

See merge request espressif/esp-idf!39491
2025-05-29 10:35:41 +08:00
Island 1b5758a25e Merge branch 'bugfix/fix_esp32c5_ble_tx_error_after_deep_sleep' into 'master'
fix(phy): update phy lib on ESP32-C5

See merge request espressif/esp-idf!39170
2025-05-29 10:29:16 +08:00
Wang Meng Yang fb6693c7a0 Merge branch 'fix/incorrect_setting_of_sco_packet_type_mask' into 'master'
fix(bt): fixed incorrect mask was used to exclude sco packets

Closes CBI-1403

See merge request espressif/esp-idf!39396
2025-05-29 08:01:20 +08:00
Roman Leonov 79d69bc7e1 Merge branch 'fix/usb_host_test_with_multiple_hubs' into 'master'
fix(ext_hub): Added processing waiting_release flag while dev changed to IDLE

See merge request espressif/esp-idf!39322
2025-05-29 05:05:21 +08:00
harshal.patil 65642866bc change(mbedtls/esp_crt_bundle): Remove deprecated certs for the major release version (v6.0) 2025-05-28 23:16:47 +05:30
Espressif BOT e6d92ab49c change(mbedtls/crt_bundle): Update esp_crt_bundle certificates 2025-05-28 23:16:47 +05:30
Rahul Tank 17338659b9 fix(nimble): Added CI files for various configurations 2025-05-28 21:51:23 +05:30
Richard Allen 30758d9beb feat(esp_http_client): Event to signal last header download
When parsing ND-JSON streams, this is needed to indicate the
point when the ND-JSON stream is considered open, which
occurs just after the last HTTP_EVENT_ON_HEADER.

ND-JSON stream clients cannot rely on the first HTTP_EVENT_ON_DATA,
since that is only triggered by an event, which are optional and
may never be sent, or only sent well after the last HTTP_EVENT_ON_HEADER.

Closes #15952
2025-05-28 08:50:28 -05:00
wanckl 4c11e81fd9 feat(driver_spi): support gpio reserved check 2025-05-28 19:29:46 +08:00
xiongweichao a8ed0133ca feat(bt/bluedroid): Add events to indicate the initialization states of AVRCP 2025-05-28 11:24:32 +00:00
luoxu 5f743900e7 feat(ble_mesh): unify tinycrypto component 2025-05-28 17:35:37 +08:00
gaoxu 449abbab76 fix(cam): fix dvp can not get cam_buffer 2025-05-28 17:29:38 +08:00
David Cermak 80a5ec8e78 feat(iperf): Add minimum IRAM test config 2025-05-28 10:39:36 +02:00
Marius Vikhammer 40844075c3 Merge branch 'revert/enable_sysview_tests' into 'master'
Revert "ci: enable sysview example tests for all chips"

See merge request espressif/esp-idf!39487
2025-05-28 16:17:29 +08:00
Mahavir Jain 619996f74a Merge branch 'bugfix/fix_tls1_3_server_failing_handshake' into 'master'
fix(mbedtls): Fix failing handshake when running HTTPS Server with TLS1.3

Closes IDFGH-15325 and IDF-13113

See merge request espressif/esp-idf!39318
2025-05-28 13:16:49 +05:30
gaoxu 5f582fdc28 fix(cam): decrease i2c sccb frequency for camera 2025-05-28 15:17:30 +08:00
Marius Vikhammer 951bc53a03 fix(sysview): fixed spelling mistake in comment 2025-05-28 08:46:26 +02:00
Marius Vikhammer eb76e6341d Merge branch 'feature/h4_core_support' into 'master'
feat(core): bringup dual-core for H4

Closes IDF-12317, IDF-12319, IDF-12484, IDF-12311, and IDF-12293

See merge request espressif/esp-idf!39279
2025-05-28 14:42:58 +08:00
Marius Vikhammer f764953df3 Revert "ci: enable sysview examples for all chips"
This reverts commit c9cf11cd1c.
2025-05-28 08:38:08 +02:00
Marius Vikhammer 24d2720793 Revert "ci: OpenOCD class as fixture"
This reverts commit 0eb74ffcc3.
2025-05-28 08:38:08 +02:00
Marius Vikhammer 4c3b989ce5 Revert "ci: use shared OpenOCD class for GDB test app"
This reverts commit 60e64d2464.
2025-05-28 08:38:06 +02:00
Marius Vikhammer 09f077969c Revert "feat(tools): add esp32c3 rev1.1 rom version string"
This reverts commit fb2565815e.
2025-05-28 08:38:03 +02:00
Nilesh Kale d8f4388926 Merge branch 'feat/enable_hardware_deterministic_mode_for_esp32h21' into 'master'
feat(hal): enabled hardware deterministic loop feature in ESP32H21

See merge request espressif/esp-idf!39464
2025-05-28 14:23:39 +08:00
morris 94143f2f18 Merge branch 'contrib/github_pr_16025' into 'master'
Update COMPATIBILITY.md - Updated links to documents. (GitHub PR)

Closes IDFGH-15368

See merge request espressif/esp-idf!39479
2025-05-28 14:08:30 +08:00
Wu Zheng Hui 2a861eadfb Merge branch 'feat/support_c5_esp_perip_clk_init' into 'master'
feat: optimize esp32c5 active power consumption

Closes IDF-8844

See merge request espressif/esp-idf!36414
2025-05-28 13:17:25 +08:00
Anton Maklakov 00038bd6f3 Merge branch 'fix/temp_disable_win_cli_installer' into 'master'
fix(test): Temporarily disable test_cli_installer_win

See merge request espressif/esp-idf!39458
2025-05-28 11:53:02 +07:00
morris bb9fbc040e Merge branch 'feat/c61_eco3_soc_update' into 'master'
feat(soc): c61 eco3 rom and soc header update

See merge request espressif/esp-idf!39166
2025-05-28 12:19:26 +08:00
Samuel Obuch e0c43e6e7c Merge branch 'ci/enable_sysview_tests' into 'master'
ci: enable sysview example tests for all chips

Closes IDFCI-807, IDFCI-808, and IDF-13000

See merge request espressif/esp-idf!39153
2025-05-28 03:19:41 +08:00
Konstantin Kondrashov ef58299d06 Merge branch 'doc/improve_part_table_doc' into 'master'
feat(partition_table): Improves documentation for partition table

See merge request espressif/esp-idf!39368
2025-05-27 22:27:39 +08:00
wuzhenghui 65b7e70564 feat(driver): support acquire/release clock source dependency for all drivers 2025-05-27 21:21:38 +08:00
David Cermak b90c12c30f fix(esp_netif): Fix incorrect DHCP call for PPP interfaces
Closes https://github.com/espressif/esp-protocols/issues/800
2025-05-27 20:07:34 +08:00
luoxu ffdd4d6c7b feat(ble_mesh): update lib to bbb57d10f9 2025-05-27 20:04:48 +08:00
wuzhenghui 113f40a3e0 feat(esp_hw_support): support gate PLL div clock source by reference count 2025-05-27 19:55:23 +08:00
wuzhenghui 34f249a28b feat(esp_hw_support): support esp_perip_clk_init for esp32c5 2025-05-27 19:55:22 +08:00
Chen Ji Chang 904d9526d3 Merge branch 'feat/change_mcpwm_prescale' into 'master'
change(mcpwm): change default mcpwm group prescale

Closes IDFGH-13989 and IDF-12790

See merge request espressif/esp-idf!34897
2025-05-27 19:27:43 +08:00
luoxu 643e6ffdf1 feat(ble_mesh): Change the type of rpl size from uint8 to uint16 2025-05-27 17:31:42 +08:00
Marek Fiala c17baef38d feat(test): Lower the scope when win tests are automatically executed
Introduced new rule "atterns-build_system_win", that coveres scope
for windows test. It currently contains only "tools/test_build_system/**/*".
2025-05-27 11:24:58 +02:00
nilesh.kale 7926ffd13f feat(hal): enabled hardware deterministic mode in ESP32H21 2025-05-27 14:54:13 +05:30
Marek Fiala 94994f7ad3 fix(test): Temporarily disable test_cli_installer_win 2025-05-27 11:13:04 +02:00
C.S.M 456ae964a1 Merge branch 'refactor/remove_i2c_slave_v1' into 'master'
refactor(i2c): Remove i2c slave v1 driver

See merge request espressif/esp-idf!39329
2025-05-27 15:28:43 +08:00
Jiang Jiang Jian b3560860dd Merge branch 'bugfix/supplicant_analyzer_fixes' into 'master'
Bugfix/supplicant analyzer fixes

Closes WIFIBUG-1218 and IDF-13129

See merge request espressif/esp-idf!39300
2025-05-27 15:07:30 +08:00
Chen Jichang 77e18528cd feat(mcpwm): change default mcpwm group prescale to 1
Closes https://github.com/espressif/esp-idf/issues/14815
2025-05-27 14:48:14 +08:00
Chen Jichang e89dc281e9 test(mcpwm): add multi input banding to the same pin test
Closes https://github.com/espressif/esp-idf/issues/14958
2025-05-27 14:48:14 +08:00
Michael (XIAO Xufeng) 45a9a31a7e Merge branch 'fix/wss_server_larger_partition' into 'master'
wss_server: use large partition table config

See merge request espressif/esp-idf!39430
2025-05-27 14:47:25 +08:00
Zhang Hai Peng c91a897697 Merge branch 'bugfix/fix_send_delete_link_key_cmd_1' into 'master'
Bugfix/fix send delete link key cmd 1

Closes BLERP-1735

See merge request espressif/esp-idf!39424
2025-05-27 14:41:59 +08:00
Island b4846b8f26 Merge branch 'fix/printf_va_list_cross_function_pass' into 'master'
fix(ble): fixed spi ble log bugs

Closes BLERP-1920, BLERP-1923, BLERP-1926, and BLERP-1928

See merge request espressif/esp-idf!39384
2025-05-27 14:21:01 +08:00
hrushikesh.bhosale 2c5530528c fix(advanced_ota): Added support for cert bundle in advanced OTA
1. Added support for cert bundle in advanced OTA
2. This allows to easily test example with different public servers
2025-05-27 10:53:19 +05:30
Kevin (Lao Kaiyao) 7e554894ce Merge branch 'change/sync_trm_csv_update_5_23' into 'master'
change(csv_update): sync the csv update to idf

See merge request espressif/esp-idf!39386
2025-05-27 12:45:14 +08:00
Xiao Xufeng 1d9e0ceab7 wss_server: use large partition table config 2025-05-27 12:01:57 +08:00
C.S.M 1f37a8da9a refactor(i2c): Remove i2c slave v1 driver 2025-05-27 11:22:20 +08:00
Armando (Dou Yiwen) 2b81deaca8 Merge branch 'change/psram_2t_check_only_on_ap' into 'master'
psram: limited 2t check only for ap

See merge request espressif/esp-idf!39411
2025-05-27 03:10:24 +00:00
Zhang Shuxian 463135fded docs: Update CN translation for partition-tables.rst 2025-05-27 11:02:18 +08:00
laokaiyao 0a93309a89 change(cache): update cache soc headers of c61 2025-05-27 10:31:30 +08:00
laokaiyao 78a2e2cb2f change(apm): update apm soc headers of c5 2025-05-27 10:31:30 +08:00
laokaiyao 10aef84983 change(etm): update etm soc headers of h21 2025-05-27 10:31:30 +08:00
Erhan Kurubas fb2565815e feat(tools): add esp32c3 rev1.1 rom version string 2025-05-27 04:48:18 +08:00
Samuel Obuch 60e64d2464 ci: use shared OpenOCD class for GDB test app 2025-05-27 04:48:18 +08:00
Samuel Obuch 0eb74ffcc3 ci: OpenOCD class as fixture 2025-05-27 04:48:18 +08:00
Samuel Obuch c9cf11cd1c ci: enable sysview examples for all chips 2025-05-27 04:48:18 +08:00
Mahavir Jain aebdb81aa6 Merge branch 'change/exclude_cve-2023-53154' into 'master'
change: adds CVE-2023-53154 to cJSON sbom exclude list

See merge request espressif/esp-idf!39395
2025-05-26 22:03:50 +05:30
Marius Vikhammer e527554144 feat(core): bringup dual-core for H4 2025-05-26 17:11:12 +02:00
Frantisek Hrbata b9d7771a14 fix(docs/idf-size): update idf.py size summary output
The total flash size is no longer reported by esp-idf-size. Update the
output example in the documentation to reflect this change. Also,
include the note about total memory sizes as now printed by
esp-idf-size.

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2025-05-26 23:04:10 +08:00
zhanghaipeng 21391a45fd fix(ble/bluedroid): Fixed clear BLE device recored 2025-05-26 20:21:35 +08:00
Jiang Jiang Jian 03e6dda224 Merge branch 'bugfix/fix_some_wifi_bugs_ralated_max_bss_idle' into 'master'
fix(bss_max_idle): fix some wifi bugs related to bss max idle

Closes WIFIBUG-1193, WIFIBUG-1194, and PM-411

See merge request espressif/esp-idf!39288
2025-05-26 19:48:24 +08:00
morris 6d502b710c Merge branch 'bugfix/fix_lcd_ll_macro_safety' into 'master'
fix(hal): Wrap LL macros with atomic env in do-while for control safety

Closes IDF-11981

See merge request espressif/esp-idf!39202
2025-05-26 19:06:11 +08:00
Mahavir Jain 4d59537d5f Merge branch 'update/update_cmn_crt_authorities_csv' into 'master'
Update common cert authorities csv

See merge request espressif/esp-idf!39223
2025-05-26 14:55:42 +05:30
David Cermak c275b5e55b fix(ci): Fix the latest tag to master's v6.0-dev
This is used only for caching (pip packages and submodules), so not very
important.
Probably forgotten when merging !38889 (f89d6ee5a0)
2025-05-26 11:22:53 +02:00
Ashish Sharma dbb846c348 fix(mbedtls): Fixes failing TLS 1.3 server handshake
Closes https://github.com/espressif/esp-idf/issues/15984
2025-05-26 17:16:21 +08:00
armando 412b79ed1c change(psram): limited 2t check only for ap 2025-05-26 17:06:03 +08:00
David Čermák a74725a31b Merge branch 'feat/lwip/ipv6_dup_detect_tries' into 'master'
feat(lwip/config): add menuconfig option for setting LWIP_IPV6_DUP_DETECT_ATTEMPTS

Closes IDFGH-9320

See merge request espressif/esp-idf!39080
2025-05-26 17:00:47 +08:00
gongyantao f7fedf3fb8 fix(bt): fixed incorrect mask was used to exclude sco packets 2025-05-26 16:49:06 +08:00
Tomas Sebestik f2ac9185aa Merge branch 'ci/update-commitlinter' into 'master'
Update conventional precommit linter to v1.10.0

Closes RDT-1312

See merge request espressif/esp-idf!39222
2025-05-26 10:32:37 +02:00
wanckl 6fde8cf8d2 ci(esp32c61): disable soc_caps, docs, test for eco3 update 2025-05-26 16:04:23 +08:00
wanckl 783ea76212 feat(soc): c61 eco3 soc header update 2025-05-26 16:04:18 +08:00
Espressif BOT e08ed84287 change(mbedtls/crt_bundle): Update esp_cmn_crt_bundle certificates 2025-05-26 13:19:57 +05:30
Harshal Patil fe40cc8f8b Merge branch 'fix/suppress_cert_bundle_serial_number_warning' into 'master'
fix(mbedtls/esp_crt_bundle): Suppress non-negative serial number warning

Closes IDFCI-2945

See merge request espressif/esp-idf!39381
2025-05-26 13:19:00 +05:30
Zhou Xiao 3ce7470434 change(ble): make falling edge when disabling ts sync 2025-05-26 15:33:47 +08:00
Xu Si Yu bd87b7cf57 feat(openthread): add a function to exit openthread main loop safely 2025-05-26 15:21:31 +08:00
Kevin (Lao Kaiyao) 79c0c7a3db Merge branch 'feature/enable_stub_for_c5_eco2' into 'master'
feat(esp32c5): enable stub for esp32c5 eco2

See merge request espressif/esp-idf!39207
2025-05-26 15:10:09 +08:00
Kevin (Lao Kaiyao) 9466411cd6 Merge branch 'ci/test_i2s_with_psram_config' into 'master'
ci: test ana_cmpr, dac, i2s, touch with CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0

Closes IDF-13027, IDF-13028, IDF-13032, and IDF-13044

See merge request espressif/esp-idf!39005
2025-05-26 14:47:29 +08:00
yinqingzhao 18a468b0d5 fix(bss_max_idle): fix some wifi bugs related to bss max idle 2025-05-26 14:26:19 +08:00
Harshal Patil d8d8e91a80 Merge branch 'fix/all_crypto_periphs_reset_cause_sec_reset' into 'master'
fix(system_internal): Avoid the sec clock reset caused due to resetting all crypto peripherals

Closes IDF-13064, IDFCI-2878, and IDFCI-2877

See merge request espressif/esp-idf!39357
2025-05-26 11:40:06 +05:30
morris 1fa420ef2f Merge branch 'refactor/remove_io_loop_back' into 'master'
refactor(drivers)!: remove unnecessary io_loop_back config option

Closes IDF-11274

See merge request espressif/esp-idf!39062
2025-05-26 14:09:28 +08:00
laokaiyao a2cf361c5a ci: test i2s, touch, ana_cmpr with CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 2025-05-26 13:09:45 +08:00
laokaiyao 7d086d6a8d fix(ana_cmpr): fixed FUNC_IN_IRAM option involves flash data 2025-05-26 13:09:45 +08:00
laokaiyao 16cc8f974d ci: test i2s, touch, ana_cmpr with CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=0 2025-05-26 13:09:45 +08:00
laokaiyao 0359404330 feat(esp32c5): enable stub for esp32c5 eco2 2025-05-26 13:08:46 +08:00
Zhang Xiao Yan c6bc55f91e Merge branch 'docs/update_getting_started_page_c5' into 'master'
docs: update get-started documents for ESP32-C5

See merge request espressif/esp-idf!38992
2025-05-26 13:06:22 +08:00
Zhang Xiao Yan a93d61b756 docs: update get-started documents for ESP32-C5 2025-05-26 13:06:21 +08:00
wanckl c36f55c451 feat(esp_rom): update rom files for eco3 2025-05-26 11:39:26 +08:00
Zhou Xiao b8c1c2b616 fix(ble): fixed spi log init failure return value for ESP32 2025-05-26 10:46:19 +08:00
Ashish Sharma 87feca0350 change: adds CVE-2023-53154 to cJSON sbom exclude list 2025-05-26 10:27:54 +08:00
Artur Zgodziński bf24bcd836 Update COMPATIBILITY.md
Updated links to documents.
2025-05-25 09:02:23 +01:00
Samuel Obuch a952037d82 Merge branch 'ci/fix-custom-oocd-setting' into 'master'
ci: select OpenOCD binary based on runner

See merge request espressif/esp-idf!39375
2025-05-23 22:47:50 +08:00
Zhou Xiao f582bd9ed0 fix(ble): fixed ts sync sleep support trigger 2025-05-23 19:11:50 +08:00
Jiang Jiang Jian 49c373e2e8 Merge branch 'feature/update_wifi_cmd_version' into 'master'
update: update wifi-cmd of iperf example

See merge request espressif/esp-idf!38923
2025-05-23 19:06:32 +08:00
Roland Dobai bf8a3c3e51 Merge branch 'fix/temp_allow_fail_cli_installer_win' into 'master'
fix(test): Temporarily allow test_cli_installer_win to fail

See merge request espressif/esp-idf!39112
2025-05-23 12:41:31 +02:00
morris f6b8ad87fa feat(docs): initial migration guide for idf 6.x 2025-05-23 18:10:01 +08:00
morris c63f51dcb3 refactor(drivers)!: remove unnecessary io_loop_back and pull up/down config option 2025-05-23 18:09:53 +08:00
morris 8afb0fb9e6 Merge branch 'fix/drop_pm_code_if_not_need' into 'master'
fix(drivers): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled

Closes IDFGH-15263

See merge request espressif/esp-idf!39045
2025-05-23 16:15:29 +08:00
Konstantin Kondrashov 9d0d1d2614 Merge branch 'contrib/github_pr_15930' into 'master'
docs(esp32): Add note about including esp_check.h for error-handling.rst docs page in English (GitHub PR)

Closes IDFGH-15271 and DOC-11245

See merge request espressif/esp-idf!39012
2025-05-23 16:13:48 +08:00
Nilesh Kale fa7c9b63b1 Merge branch 'feature/enable_support_for_deterministic_mode_and_ecdsa_192' into 'master'
enable support for deterministic mode and ecdsa 192 in ESP32H2

Closes IDF-12011, IDF-13065, and DOC-11194

See merge request espressif/esp-idf!39103
2025-05-23 15:19:08 +08:00
Zhou Xiao 8184004a4e fix(ble): fixed printf va list cross function pass failure 2025-05-23 12:32:26 +08:00
C.S.M 561c7c4884 Merge branch 'fix/flash_log_clearer' into 'master'
fix(spi_flash): Make GD chip to be linked as default, also optimization the log information

See merge request espressif/esp-idf!39165
2025-05-23 12:16:54 +08:00
harshal.patil 5ae42e6f0b fix(mbedtls/esp_crt_bundle): Suppress non-negative serial number warning
Co-authored-by: Mahavir Jain <mahavir.jain@espressif.com>
2025-05-23 09:28:42 +05:30
Armando (Dou Yiwen) e9d7adf697 Merge branch 'test/re_enable_c5_80m_psram_tests' into 'master'
psram: re-enable 80M psram tests on C5 ECO2

See merge request espressif/esp-idf!39347
2025-05-23 02:58:45 +00:00
Samuel Obuch e80293fdbe ci: select OpenOCD binary based on runner 2025-05-22 20:43:39 +02:00
Adam Múdry 8925459572 Merge branch 'docs/filesystem_considerations_readonly_nvs' into 'master'
docs: Added a mention of read-only NVS in filesystem considerations document

Closes IDF-12520

See merge request espressif/esp-idf!38887
2025-05-22 20:31:52 +02:00
Adam Múdry e0be50d9b5 docs: Added a mention of read-only NVS in filesystem considerations document 2025-05-22 19:18:01 +02:00
Konstantin Kondrashov 909fd09ffa feat(partition_table): Improves documentation for partition table 2025-05-22 16:09:08 +03:00
Island 6897f90612 Merge branch 'feat/reduce_bin_size_and_iram_for_ble_rom_code' into 'master'
feat(ble/controller): Reduce bin size and IRAM for BLE rom code on ESP32-C3 and ESP32-S3

Closes BLERP-1855

See merge request espressif/esp-idf!38987
2025-05-22 20:20:22 +08:00
Rahul Tank d55709fdae Merge branch 'bugfix/coverity_fix' into 'master'
fix(nimble): Add changes for coverity reported issue

See merge request espressif/esp-idf!39292
2025-05-22 16:27:21 +05:30
harshal.patil e08189f37b fix(system_internal): Avoid the sec clock reset caused due to resetting all crypto peripherals 2025-05-22 16:01:02 +05:30
Zhang Shuxian ff408c31c7 docs: Update CN translation for error-handling.rst 2025-05-22 17:39:27 +08:00
Chen Jichang 91f92b0e57 fix(glithc_filter): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang 90050df641 fix(jpeg): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang 8555b6c837 fix(adc): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang 6674470e89 fix(ana_cmpr): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang fe1091c2ff fix(lcd): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang 5599fd4b1f fix(sdm): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Chen Jichang 70e5042ea9 fix(parlio): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:38:58 +08:00
Laukik Hase a1c6d2a458 fix(esp_tee): Fix failing SPI1 flash protection test-cases 2025-05-22 17:35:09 +08:00
C.S.M 0f1dbcc6a5 fix(spi_flash): Make GD chip to be linked as default, also optimization the log information 2025-05-22 17:35:09 +08:00
Chen Jichang a21f7c78f9 fix(sdmmc): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang 4bfd180a94 fix(i2c): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang 6397820d0b fix(rmt): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang c8371ca405 fix(mcpwm): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang 91d1812315 fix(uhci): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang 9837138659 fix(gptimer): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
Chen Jichang 9e5ed3bdd2 fix(twai): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled 2025-05-22 17:27:18 +08:00
morris 57420057b6 fix(pcnt): only call esp_pm APIs when CONFIG_PM_ENABLE is enabled
Closes https://github.com/espressif/esp-idf/issues/15923
2025-05-22 17:27:18 +08:00
Zhang Shuxian 522e9a1bb9 docs: Update CN translation for ecdsa.rst 2025-05-22 14:55:15 +05:30
nilesh.kale 148d31b659 feat: enable support for deterministic mode for esp32h2 2025-05-22 14:55:15 +05:30
nilesh.kale 0fb8c2a9b8 feat: enabled ECDSA-P192 support for ESP32H2 2025-05-22 14:55:03 +05:30
Wan Lei d86c2bde3e Merge branch 'ci/c61_disable_test_for_eco3' into 'master'
fix(ci): disable target test for c61 eco3 update

See merge request espressif/esp-idf!39349
2025-05-22 17:05:45 +08:00
Rocha Euripedes 5783a22d84 Merge branch 'update_mqtt_pre_refactor' into 'master'
Update esp-mqtt submodule to 6af4446a

Closes IDFGH-11179, IDFGH-14022, IDFGH-14489, and IDFGH-14616

See merge request espressif/esp-idf!38893
2025-05-22 16:59:13 +08:00
Chai Ji’e 13904408af Merge branch 'feature/c61_ldo_dbias_read_from_efuse' into 'master'
feat(C61): support ldo dbias and ocode read from efuse for chip762

See merge request espressif/esp-idf!39215
2025-05-22 16:55:01 +08:00
Wu Zheng Hui a42929a75f Merge branch 'fix/fix_esp_timer_accuracy_when_do_dfs' into 'master'
fix(esp_hw_support): improve esp timer accuracy on DFS for esp32 & esp32s2

Closes PM-405, WIFI-4986, and WIFI-5942

See merge request espressif/esp-idf!39217
2025-05-22 16:38:10 +08:00
Island d877949357 Merge branch 'feat/ble_log_spi_out_dev_phase_3' into 'master'
Feat/ble log spi out dev phase 3

See merge request espressif/esp-idf!39291
2025-05-22 16:26:39 +08:00
wanckl 994f2c2b68 fix(ci): disable target test for c61 eco3 update 2025-05-22 15:17:32 +08:00
C.S.M 9b77416b60 Merge branch 'fix/jpeg_encode_msync' into 'master'
fix(jpeg): Fix wrong parameter in jpeg encoder msync

See merge request espressif/esp-idf!39321
2025-05-22 15:15:42 +08:00
armando 2f8cd616cc test(psram): re-enable 80M psram tests on C5 ECO2 2025-05-22 14:52:40 +08:00
Guilherme Ferreira 1d12eb4124 Merge branch 'feat/add-ws-get-response-headers' into 'master'
feat(tcp_transport): Add ws get HTTP response headers

Closes IDFGH-14252

See merge request espressif/esp-idf!38212
2025-05-22 14:49:49 +08:00
Yuan Yu 18091976ec fix(hal): Wrap LL macros with atomic env in do-while for control safety
- Standardize all LL macros using atomic env variables with `do { ... } while (0)`
- Prevent potential macro misuse in control flow constructs (e.g., if/else)
- Affected targets: esp32, esp32c2, esp32c5, esp32s3, esp32p4, etc.
- Affected modules include: LCD, I2S, TIMER, and others
2025-05-22 14:42:11 +08:00
Armando (Dou Yiwen) dadcc7b9f3 Merge branch 'feat/c5_eco2_psram_timing_tuning' into 'master'
mspi: psram 80M timing tuning on C5 ECO2

Closes IDF-13003

See merge request espressif/esp-idf!39232
2025-05-22 06:41:56 +00:00
Armando (Dou Yiwen) 5133b89183 Merge branch 'test/reenable_sdspi_c5_test' into 'master'
sdspi: re-enable sdspi test on c5 eco2

See merge request espressif/esp-idf!39330
2025-05-22 06:27:28 +00:00
armando 9a3018e201 test(sdspi): re-enable sdspi test on c5 eco2 2025-05-22 14:01:51 +08:00
wuzhenghui 481f42ac9d test(esp_timer): add UT case for esp_timer period alarm with DFS 2025-05-22 13:58:54 +08:00
wuzhenghui 11f32b88ac feat(esp_hw_support): compensate the error introduced to LACT during APB frequency switching 2025-05-22 13:58:54 +08:00
wuzhenghui 022614b1d3 fix(esp_hw_support): update systimer step immediately when XTAL changes on esp32s2 2025-05-22 13:58:54 +08:00
wuzhenghui 2931aa23b6 fix(esp_hw_support): update LACT clock prescale immediately when APB changes on esp32 2025-05-22 13:58:50 +08:00
Aleksei Apaseev 7b54ca004f Merge branch 'ci/dynamic-pipeline-report-adjustments' into 'master'
ci: dynamic pypiline report adjustments

Closes IDFCI-1939 and IDFCI-2436

See merge request espressif/esp-idf!38460
2025-05-22 13:43:17 +08:00
Aleksei Apaseev c25f87920a ci: improve the dynamic pipeline report 2025-05-22 13:25:39 +08:00
armando 7d5f89fa90 fix(ci): fixed psram tests not running on c5 issue 2025-05-22 10:27:19 +08:00
armando 00e3f4885a feat(mspi): supported psram 80MHz timing tuning 2025-05-22 10:27:19 +08:00
glmfe 1d71a9e811 feat(tcp_transport): Add ws get HTTP response headers 2025-05-21 16:34:10 +02:00
Euripedes Rocha 412e7c48ee change(mqtt): Adds retry on publish connect test case
This test case fails mostly for network related issues, with retrys we
might avoid the failure of the whole job.
2025-05-21 22:32:32 +08:00
Euripedes Rocha eb9614d37f change(mqtt): Update submodule to 6af4446a
git log --oneline cac1552e..6af4446a

Detailed description of the changes:
* Multiple event data
  - See merge request espressif/esp-mqtt!240
  - fix: Multiple event data (espressif/esp-mqtt@9c76b70)
* Updated the idf version check for ECDSA support
  - See merge request espressif/esp-mqtt!239
  - fix(mqtt): Updated the idf version check for ECDSA support (espressif/esp-mqtt@7d9a384)
* Added the support for the ECDSA signing
  - See merge request espressif/esp-mqtt!238
  - feat(mqtt): Add support for ECDSA signing (espressif/esp-mqtt@b35a691)
* fix: pubrel message resending when pubcomp not received
  - See merge request espressif/esp-mqtt!236
  - See commit https://github.com/espressif/esp-mqtt/commit/f38a5fc
* Change error message to fix warning.
  - fix: Change error message to fix warning. (espressif/esp-mqtt@c395c2f)
* Small cleanu
  - See merge request espressif/esp-mqtt!231
  - fix: Adds all IDF versions under support (espressif/esp-mqtt@bb85b20)
  - fix: Update badges url to reflect current status (espressif/esp-mqtt@263c167)
* feat(mqtt5): Add parsing of DISCONNECT packet to mqtt5 client
  - mqtt_client: Manage disconnect packet (espressif/esp-mqtt@470cb93)
* feat(mqtt5): Reduce log verbosity for MQTT ACK
  - Reduce log verbosity for MQTT v5 ACKs (espressif/esp-mqtt@6b7b9c3)
* PR: workflows: fix update actions to v4
  - workflows: fix update actions to v4 (espressif/esp-mqtt@06b8923)
* When MQTT_REPORT_DELETED_MESSAGES, delete QOS messages with id 0
  - doc: Clarify deleted message event to cover QoS=0 case (espressif/esp-mqtt@ea036a5)
  - See commit https://github.com/espressif/esp-mqtt/commit/b82c8f6
* fix: Race condition when using destroy
  - See merge request espressif/esp-mqtt!223
  - See commit https://github.com/espressif/esp-mqtt/commit/44292cc
* feat: Add TCP keepalive configuration
  - See commit https://github.com/espressif/esp-mqtt/commit/7c3227a
* feat: Include message topic in all chunks
  - feat: Include message topic in all data events for big messages. (espressif/esp-mqtt@82017e9)
* fix: set TCP transport every time when setting the config
  - See merge request espressif/esp-mqtt!218
  - See commit https://github.com/espressif/esp-mqtt/commit/c3c4cb9
* feat: Allow users to get the transport in use
  - See merge request espressif/esp-mqtt!216
  - See commit https://github.com/espressif/esp-mqtt/commit/97dc85a
* clean: Remove expired deletion from publish
  - See merge request espressif/esp-mqtt!217
  - See commit https://github.com/espressif/esp-mqtt/commit/2285726
2025-05-21 22:32:32 +08:00
Igor Masar 574f037b1e Merge branch 'fix/usb-log-priu32-fifo-config' into 'master'
fix(usb/hcd): Use PRIu32 in FIFO config log for portability

See merge request espressif/esp-idf!39299
2025-05-21 20:00:27 +08:00
Roman Leonov 11382a2aae fix(ext_hub): Added processing waiting_release flag while dev changed to IDLE 2025-05-21 12:13:47 +02:00
hongshuqing 5981ae8a11 feat(pmu): support ldo dbias and ocode read from efuse for chip762 2025-05-21 18:05:05 +08:00
C.S.M bfc69338c8 fix(jpeg): Fix wrong parameter in jpeg encoder msync 2025-05-21 17:54:44 +08:00
Roman Leonov 602941ef61 Merge branch 'refactor/usb_host_ext_hub_port_gone' into 'master'
refactor(ext_hub): Device release (allows to run usb_host test with ext hub)

Closes IDF-12173, IDF-10490, and IDF-13132

See merge request espressif/esp-idf!38176
2025-05-21 17:34:48 +08:00
Konstantin Kondrashov 884e54a8dd Merge branch 'feature/efuse_esp32c61_eco3_update' into 'master'
feat(efuse): Adds efuses for ESP32-C61 ECO3

See merge request espressif/esp-idf!39146
2025-05-21 17:11:33 +08:00
morris b1b99b30ef Merge branch 'fix/i2c_gpio_rsv' into 'master'
fix(i2c): Add gpio reserve check on i2c driver

Closes IDF-9098

See merge request espressif/esp-idf!39310
2025-05-21 16:49:04 +08:00
Marek Fiala a3318d6280 fix(test): Temporarily allow test_cli_installer_win to fail 2025-05-21 16:12:35 +08:00
Mahavir Jain f229a84578 Merge branch 'contrib/github_pr_15968' into 'master'
docs(esp_http_client): update return codes for open & perform (GitHub PR)

See merge request espressif/esp-idf!39239
2025-05-21 13:23:05 +05:30
Jiang Jiang Jian 4b6b9c0ec8 Merge branch 'fix/config_param_gtk_rekeying' into 'master'
Add config param for gtk rekeying on softAP side

Closes WIFI-4897

See merge request espressif/esp-idf!38383
2025-05-21 15:52:44 +08:00
Roland Dobai fc69f691ba Merge branch 'fix/enable_remove_requirements_file' into 'master'
fix(tools): handle missing `requirements.*.txt` files for enabled features

Closes IDF-12849

See merge request espressif/esp-idf!39218
2025-05-21 09:38:04 +02:00
C.S.M 8ab564a711 Merge branch 'feat/add_xmc_32bit_support' into 'master'
feat(spi_flash): Add XMC chip 32-bits address support

See merge request espressif/esp-idf!39161
2025-05-21 15:10:26 +08:00
Mahavir Jain be89fa36aa Merge branch 'feature/add_api_for_cleanup_otadata' into 'master'
feat(esp_ota_ops): Revised logic to always update non-running otadata at the time of setting ota boot partition

Closes IDFGH-13839

See merge request espressif/esp-idf!37928
2025-05-21 11:33:03 +05:30
Nilesh Kale 996a9ca25f fix(app_update): Do not change ota_seq when partition is the same
Revised logic to always update non-running otadata at the time of setting ota boot partition

Closes https://github.com/espressif/esp-idf/issues/14688
2025-05-21 11:33:03 +05:30
Mahavir Jain 88f66ae3aa Merge branch 'feature/esp_tee_h2' into 'master'
feat(esp_tee): Support for ESP32-H2

See merge request espressif/esp-idf!37708
2025-05-21 09:59:26 +05:30
Rahul Tank ebd4caf360 Merge branch 'bugfix/handle_flow_control_flag' into 'master'
fix(nimble): Add chip dependancy flag for Flow control feature

See merge request espressif/esp-idf!39181
2025-05-21 09:53:03 +05:30
Rahul Tank b8650708aa fix(nimble): Add changes for coverity reported issue 2025-05-21 09:50:23 +05:30
C.S.M b164919f4b fix(i2c): Add gpio reserve check on i2c driver,
Closes https://github.com/espressif/esp-idf/issues/15995
2025-05-21 12:15:47 +08:00
Kapil Gupta 17cd200c67 fix(esp_wifi): Fixed static analyzer issues 2025-05-21 09:26:40 +05:30
Kapil Gupta 2ce481ffbd fix(esp_wifi): Disble IP renew skip by default 2025-05-21 09:00:09 +05:30
Song Ruo Jing 0631340e2c Merge branch 'feature/esp32h21_regi2c_support' into 'master'
feat(regi2c): add regi2c support for esp32h21

Closes IDF-11550 and IDF-11858

See merge request espressif/esp-idf!37369
2025-05-21 11:22:07 +08:00
Zhou Xiao 1e6bc70837 fix(ble): fixed upper layer trans append failure bug 2025-05-21 11:06:12 +08:00
C.S.M 6ead06c6d5 feat(spi_flash): Add XMC chip 32-bits address support 2025-05-21 10:50:04 +08:00
zhiweijian 1d739291ca feat(ble/controller): Reduce bin size and IRAM for BLE rom code 2025-05-21 10:22:37 +08:00
morris 27d68f57e6 Merge branch 'fix/driver_issue_by_coverity' into 'master'
Fix some false issue report by coverity

Closes IDF-13116, IDF-13120, IDF-13104, IDF-13106, IDF-13107, IDF-13109, IDF-13112, IDF-13124, and IDF-13126

See merge request espressif/esp-idf!39287
2025-05-21 10:05:28 +08:00
Rahul Tank 6a57d5fa61 Merge branch 'feat/min_size_builds' into 'master'
fix(nimble): Add support for minimilistic builds

Closes BLERP-1848 and BCI-431

See merge request espressif/esp-idf!38515
2025-05-20 21:03:49 +05:30
igor.masar dcdeeeff45 fix(usb/hcd): Use PRIu32 in FIFO config log for portability
The ESP_LOGD message that prints FIFO line sizes used %u for uint32_t,
which may cause incorrect output on some architectures (e.g., ESP32-P4
where uint32_t maps to unsigned long). To ensure portable and correct
logging across all supported platforms, this patch replaces %u with
%" PRIu32 ", defined in <inttypes.h>.

No functional behavior is affected — this is a formatting correction
for debug output only.
2025-05-20 16:27:27 +02:00
Rahul Tank 925b563278 Merge branch 'feat/gattc_gatts_coex' into 'master'
feat(nimble): Add new gattc + gatts coex example for nimble

Closes IDFGH-11642

See merge request espressif/esp-idf!37139
2025-05-20 19:49:02 +05:30
Zhou Xiao e10460ce14 feat(ble): support ts sync for sleep app 2025-05-20 20:52:44 +08:00
Laukik Hase b8e48fbfc0 ci(esp_tee): Enable the tee_test_fw test app for ESP32-H2 2025-05-20 16:31:23 +05:30
Laukik Hase 12e2df2d74 feat(esp_tee): Support for ESP32-H2 - the rest of the components 2025-05-20 16:31:23 +05:30
Laukik Hase 958f4b8900 feat(esp_tee): Support for ESP32-H2 - the esp_tee component 2025-05-20 16:31:22 +05:30
tarun.kumar 004abebdbd fix)wifi): Add GTK rekeying interval field in softap example 2025-05-20 15:33:54 +05:30
tarun.kumar 6d7593c1be fix(wifi) : Add config param for gtk rekeying on softAP side 2025-05-20 15:33:05 +05:30
Roman Leonov f238d75ba3 refactor(ext_port): Remove the error verification, as error will be handled in ext hub driver 2025-05-20 11:34:53 +02:00
Roman Leonov 19ce9ed634 refactor(test_usb_host_async): Added host_lib_task finish notification 2025-05-20 11:34:53 +02:00
Roman Leonov 3003362bcb refactor(usb_host): Cancel hub porpagation to the user, rename non-critical func 2025-05-20 11:34:53 +02:00
Roman Leonov 3fd17b8be8 refactor(hub): Applied new ext_hub api, refactor func names 2025-05-20 11:34:53 +02:00
Roman Leonov fc61875a56 refactor(ext_hub): Pospone the device release, if device is not IDLE 2025-05-20 11:34:53 +02:00
Roman Leonov 754d357f18 refactor(ext_hub): Fixed device release, optimized the order of closing usbh device 2025-05-20 11:34:53 +02:00
Jiang Jiang Jian 0dbce7210d Merge branch 'bugfix/nvs_idfgh_issue' into 'master'
feat(esp_wifi): Add example to write wifi config in nvs

Closes IDFGH-13678

See merge request espressif/esp-idf!36693
2025-05-20 17:16:44 +08:00
Rocha Euripedes 061c05c88c Merge branch 'contrib/github_pr_15967' into 'master'
fix(tcp_transport): Silence recoverable read failures (GitHub PR)

Closes IDFGH-15309

See merge request espressif/esp-idf!39259
2025-05-20 17:02:17 +08:00
Armando (Dou Yiwen) 30f98140bb Merge branch 'fix/slot0_requires_all_pins_in_1bit_mode_issue' into 'master'
sd: fixed all pins need to be set when using slot0 on esp32p4 issue

Closes IDF-12816

See merge request espressif/esp-idf!39197
2025-05-20 09:00:51 +00:00
Zhou Xiao ed09e97c66 feat(ble): support controller raw log print out 2025-05-20 16:54:49 +08:00
morris 7af3bddbca fix(drivers): some false reports from coverity 2025-05-20 16:52:32 +08:00
morris d46019bf43 refactor(bitscrambler): don't use Reset Clock Control lock of RC version 2025-05-20 16:52:32 +08:00
Zhou Xiao 9800d715a5 feat(ble): refactored loss report module and represent frame using struct 2025-05-20 16:22:52 +08:00
yinqingzhao 9c8c40369a update: update wifi-cmd of iperf example 2025-05-20 16:13:28 +08:00
Konstantin Kondrashov 43e2abac14 feat(docs): Improve error handling documentation
Merges https://github.com/espressif/esp-idf/pull/15930
2025-05-20 11:11:07 +03:00
Zhou Xiao cd3aa6527c feat(ble): support le audio log buffer separation 2025-05-20 16:09:25 +08:00
Chai Ji’e 22f63191e6 Merge branch 'feat/support_different_pwr_glitch_dref_to_fit_eco_esp32c61' into 'master'
feat(power_glich): power glitch initial for esp32c5/esp32c61, only detect vddpst pwr_glitch, not support esp32c5_eco0 & eco32c61_eco0/1 no longer

See merge request espressif/esp-idf!35206
2025-05-20 16:06:57 +08:00
Konstantin Kondrashov 086555e0ed feat(efuse): Adds efuses for ESP32-C61 ECO3 2025-05-20 15:57:10 +08:00
Jiang Jiang Jian 0e85a78aa9 Merge branch 'feat/move_ocode_config_to_pmuinit_c6_c5_c61' into 'master'
refactor: move_ocode_to_pmu_init_c6_c5_c61

See merge request espressif/esp-idf!38957
2025-05-20 15:51:32 +08:00
Wu Zheng Hui 8931a8a764 Merge branch 'fix/fix_esp32p4_stuck_in_pd_ana' into 'master'
fix(esp_hw_support): fix esp32p4 may get stuck when entering deepsleep

Closes PM-389 and PM-391

See merge request espressif/esp-idf!38780
2025-05-20 15:50:45 +08:00
Zhou Xiao e4be25ba63 feat(ble): optimized printf functions code size and speed 2025-05-20 15:50:13 +08:00
Zhou Xiao 70792443c7 feat(ble): refactored flush module and provided public flush api 2025-05-20 15:39:30 +08:00
Zhou Xiao bba90309e7 feat(ble): refactored ll isr buffer append and buffer flush using event handler 2025-05-20 15:16:37 +08:00
Zhou Xiao 3568f19fef feat(ble): provided dynamic spi enable/disable api 2025-05-20 14:22:42 +08:00
Zhou Xiao 16a3b2c71b feat(ble): support hci log buffer separation 2025-05-20 14:11:18 +08:00
chaijie@espressif.com 1db79146e9 fix(pmu): fix deepsleep current too big bug for esp32c61 2025-05-20 14:06:15 +08:00
chaijie@espressif.com 74c34669f0 feat(power_glich): support power_glitch of esp32c5_eco1 and above, eco32c61 eco2 and above 2025-05-20 14:06:15 +08:00
Rahul Tank 3f65227d39 feat(nimble): Add demo example for gattc and gatts coex for nimble 2025-05-20 11:27:02 +05:30
Zhou Xiao f8699785e9 feat(ble): optimized macros readability 2025-05-20 12:54:41 +08:00
chaijie@espressif.com 24c46f1b89 refactor: move_ocode_to_pmu_init_c6_c5_c61 2025-05-20 11:08:35 +08:00
morris 7bca1fe76f Merge branch 'fix/twai_psram' into 'master'
test(twai): with malloc comes from PSRAM by default

Closes IDF-13045

See merge request espressif/esp-idf!39246
2025-05-20 10:30:53 +08:00
Jiang Jiang Jian abd5be52f1 Merge branch 'bugfix/fix_rx_bcn_failed_when_sta_off_channel' into 'master'
fix(wifi): rx bcn failed when sta off channel under modem state

Closes WIFIBUG-1179

See merge request espressif/esp-idf!39097
2025-05-20 10:23:27 +08:00
Wu Zheng Hui baab409af9 Merge branch 'fix/fix_iram_safe_code_inlined_to_flash_' into 'master'
fix(esp_hw_support): fix sleep iram safe code inlined to flash

Closes PM-412 and PM-413

See merge request espressif/esp-idf!39185
2025-05-20 09:58:44 +08:00
Nachiket Kukade f931739352 Merge branch 'bugfix/roam_event_scan_failure' into 'master'
bugfix(wifi): Reset scan_ongoing flag in scan done event to allow scan trigger post roam

Closes WIFIBUG-1203

See merge request espressif/esp-idf!39163
2025-05-20 01:51:23 +08:00
Marek Fiala 39cbbab859 fix(tools): Enabled removing requirements.* files 2025-05-19 15:51:49 +02:00
Song Ruo Jing 8262915e28 refactor(regi2c): remove regi2c_defs.h from some targets 2025-05-19 21:46:40 +08:00
Song Ruo Jing 9ef152c220 feat(regi2c): add regi2c support for esp32h21 2025-05-19 21:46:40 +08:00
Jiang Jiang Jian 79d503f267 Merge branch 'fix/c5_iperf_size' into 'master'
iperf: increased app partition size in  example

See merge request espressif/esp-idf!39240
2025-05-19 21:29:47 +08:00
wuzhenghui 077ce905ed fix(esp_hw_support): fix sleep iram safe code inlined to flash 2025-05-19 21:02:24 +08:00
Konstantin Kondrashov f7bc58e4ec Merge branch 'ci/fix_secure_tests_for_efuse_example' into 'master'
fix(examples): Fix CI tests for secure boot cases

Closes IDF-13077

See merge request espressif/esp-idf!39111
2025-05-19 20:59:00 +08:00
sibeibei 10ac8e622e fix(wifi): rx bcn failed when sta off channel under modem state 2025-05-19 20:08:58 +08:00
akshat 928b07b859 bugfix(wifi): Reset scan_ongoing flag in scan done event to allow scan trigger post roam 2025-05-19 15:59:55 +05:30
Jiang Jiang Jian fbfa32c372 Merge branch 'feature/ftm_support_5ghz_esp32c5' into 'master'
feat(esp_wifi): Add FTM support for ESP32C5

Closes WIFI-6426, IDF-10612, and IDFGH-15244

See merge request espressif/esp-idf!33587
2025-05-19 17:34:19 +08:00
Yuan Yu 3d842bcee7 test(twai): with malloc comes from PSRAM by default 2025-05-19 17:12:39 +08:00
Shu Chen 016e83671d Merge branch 'docs/sntp_example_thread' into 'master'
docs(sntp_example): Add Thread network setup instruction for sntp example

Closes IDFGH-14888

See merge request espressif/esp-idf!39121
2025-05-19 08:52:04 +00:00
C.S.M f3147df360 Merge branch 'refactor/remove_i2c_slave_v1_s1' into 'master'
refactor(i2c): Replace i2c test from version one to version two

See merge request espressif/esp-idf!39085
2025-05-19 16:49:10 +08:00
Sudeep Mohanty a7e61220a1 Merge branch 'fix/lp_periph_use_int_raw' into 'master'
change(lp-core): Update LP I2C and LP UART drivers to use raw interrupt status

See merge request espressif/esp-idf!39008
2025-05-19 10:31:03 +02:00
Aditi 747e3e0f31 feat(esp_wifi): Add unit test for writing wifi config in nvs
This commit adds a unit test for using wifi station and softap by flashing wifi config
directly into nvs using NVS Partition generator Utility (using csv file).
2025-05-19 13:53:45 +05:30
Oleg Zinovyev 465d809845 docs: Update CLion documentation
Update CLion documentation page

docs: Update CLion documentation
2025-05-19 10:15:15 +03:00
Rahul Tank a58ce394c4 fix(nimble): Add support for minimilistic builds 2025-05-19 12:44:34 +05:30
Rahul Tank 644e38fb7a Merge branch 'fix/gattc_proc_comparison' into 'master'
fix(nimble): Fix proc rx entry comparison

See merge request espressif/esp-idf!39113
2025-05-19 12:31:49 +05:30
Island bd5b0917fc Merge branch 'fix/ble_mesh_set_proxy_adv_param_failed' into 'master'
fix(ble_mesh): fixed the issue of incorrect proxy adv flag setting

Closes BLERP-1803

See merge request espressif/esp-idf!38654
2025-05-19 14:59:16 +08:00
C.S.M 660244e6ee refactor(i2c): Replace i2c test from version one to version two 2025-05-19 14:13:10 +08:00
Xiao Xufeng 98a0702ffc iperf: increased app partition size in example 2025-05-19 14:11:25 +08:00
Omar Chebib 1e516f0f84 Merge branch 'fix/bootloader_reserved_area_alignment' into 'master'
fix(esp_system): fix RTC reserved area alignment in the linker script

Closes IDFGH-12017

See merge request espressif/esp-idf!28821
2025-05-19 14:09:22 +08:00
Michael (XIAO Xufeng) f23bbb6cc7 Merge branch 'fix/c5_http_server_size' into 'master'
fix: increase the bin size of http example in the partition table

See merge request espressif/esp-idf!39204
2025-05-19 14:06:54 +08:00
akshat 9b1a80695c feat(esp_wifi): Add FTM support for ESP32C5 (ECO2)
Closes https://github.com/espressif/esp-idf/issues/15909
2025-05-19 10:31:16 +05:30
Mahavir Jain 54e071a88c Merge branch 'feat/httpd_register_uri_handler_strdup_failure_case_check' into 'master'
Handling httdp_register_uri_handler() strdup function failure case check

Closes IDFGH-15208

See merge request espressif/esp-idf!38933
2025-05-19 10:23:25 +05:30
Wang Meng Yang e178a09d19 Merge branch 'bugfix/fix_ble_scan_no_adv_report_when_connected' into 'master'
Fixed missing ADV reports after bonding and connection on ESP32-C3 and ESP32-S3

Closes BLERP-1874 and IDFGH-15110

See merge request espressif/esp-idf!38609
2025-05-19 11:55:28 +08:00
armando 3cbe162bf0 refactor(mspi): change mspi timing tuning dirrectory structure 2025-05-19 11:50:43 +08:00
Wang Meng Yang b452748eb5 Merge branch 'change/ble_update_lib_20250516' into 'master'
change(ble): [AUTO_MR] 20250516 - Update ESP BLE Controller Lib

Closes BLERP-1833, BLERP-1838, BLERP-1753, BLERP-1708, BLERP-1849, BLERP-1821, BLERP-1840, BLERP-1778, BLERP-1865, BLERP-1879, BLERP-1880, BLERP-1881, BLERP-1866, BLERP-1882, BLERP-1883, BLERP-1887, BLERP-1889, BLERP-1890, and BLERP-1892

See merge request espressif/esp-idf!39200
2025-05-19 11:50:40 +08:00
armando ad98c1d9a1 fix(sd): fixed menuconfig multi pin definitions issue 2025-05-19 11:16:18 +08:00
Xiao Xufeng de2962dd77 https_server: use larger partition table in the example 2025-05-19 11:00:56 +08:00
WanqQixiang f64b4d00b6 docs(sntp_example): Add Thread network setup instruction for sntp example
Closes https://github.com/espressif/esp-idf/issues/15605
2025-05-19 10:52:28 +08:00
Tomas Sebestik 892ba4cbf7 ci(pre-commit-hooks): update conventional precommit linter to v1.10.0
Closes https://github.com/espressif/esp-idf/issues/15969
Closes https://github.com/espressif/conventional-precommit-linter/issues/31
2025-05-17 17:15:45 +02:00
Maciej Ślusarz 2cc28d90fb feat(docs): Add note about including esp_check.h for error-handling.rst docs page 2025-05-16 17:03:24 +03:00
Richard Allen a0f085d012 docs(esp_http_client): update return codes for open & perform
Extend the return code section to include async return values.
2025-05-16 08:55:08 -05:00
Richard Allen 7f982fa09d fix(tcp_transport): Silence recoverable read failures
In some applications, ESP_TLS_ERR_SSL_WANT_READ and
ESP_TLS_ERR_SSL_TIMEOUT are common results which
need handled at the next layer. Downgrade these
to debug.
2025-05-16 08:37:19 -05:00
C.S.M 1637e27ae3 Merge branch 'docs/uhci_programming_guide' into 'master'
docs(uhci): Added implementation for uart-dma (uhci) programming guide

See merge request espressif/esp-idf!38663
2025-05-16 17:26:26 +08:00
C.S.M 093db55bf4 docs(uhci): implementation for uart-dma (uhci) docs 2025-05-16 15:14:51 +08:00
Zhou Xiao d12e072b35 fix(ble): added missed printf for ll log interface 2025-05-16 15:10:44 +08:00
zwl 9d687daf36 feat(ble): support creating connections during scanning process on ESP32-C5 2025-05-16 15:09:16 +08:00
Konstantin Kondrashov eb81a853fb Merge branch 'fix/bin_log_config' into 'master'
fix(log): Fix bin log config available only for log version 2

See merge request espressif/esp-idf!39186
2025-05-16 15:03:06 +08:00
zwl 207d85a5f7 feat(ble): support creating connections during scanning process on ESP32-H2 2025-05-16 14:31:44 +08:00
zwl cd6038b6cf fix(ble): fixed occasional assert issue in scan and connection scenarios on ESP32-C6 2025-05-16 14:22:25 +08:00
zwl 3cfd4d0166 change(ble): [AUTO_MR] Update lib_esp32c2 to 664e4255 2025-05-16 13:56:14 +08:00
zwl 69158d5064 change(ble): [AUTO_MR] Update lib_esp32c6 to 1304a9d0 2025-05-16 13:56:14 +08:00
zwl 27220c1b4c change(ble): [AUTO_MR] Update lib_esp32c5 to 1304a9d0 2025-05-16 13:56:14 +08:00
zwl 29f89efea6 change(ble): [AUTO_MR] Update lib_esp32h2 to 1304a9d0 2025-05-16 13:56:13 +08:00
zhanghaipeng 244d4f8fa7 fix(bt): Update bt lib for ESP32-C3 and ESP32-S3(4713205)
- Fix: Missing ADV reports after bonding and connection
2025-05-16 11:55:52 +08:00
armando 616dd97398 fix(sd): fixed slot0 requires all pins to be set when using 1bit iomux mode on p4 2025-05-16 11:10:58 +08:00
morris 9c8ead5e03 Merge branch 'bugfix/periphint_typo' into 'master'
Fix typo in periph_inttrput_t type name

Closes IDF-12096

See merge request espressif/esp-idf!39179
2025-05-16 10:38:23 +08:00
Armando (Dou Yiwen) b1999b5cb2 Merge branch 'feat/sd_host_ng' into 'master'
sd: driver NG for host layer, supported SDR104 (200 MHz) speed mode

Closes IDF-10545 and IDF-10547

See merge request espressif/esp-idf!37378
2025-05-16 10:05:27 +08:00
Erhan Kurubas 89adafa6af Merge branch 'feat/apptrace-crc16' into 'master'
Store CRC16 checksum value in the PERFMON1 reg

See merge request espressif/esp-idf!39020
2025-05-16 02:40:09 +08:00
Konstantin Kondrashov 184b993d41 Merge branch 'contrib/github_pr_15942' into 'master'
fix(esp_hw_support): Fix compile error on esp_cpu_int_has_handler on ESP32-P4 (GitHub PR)

Closes IDFGH-15283

See merge request espressif/esp-idf!39116
2025-05-15 22:54:19 +08:00
Konstantin Kondrashov e9aa543a43 Merge branch 'contrib/github_pr_15917' into 'master'
feat(docs): Small additions to ulp-risc-v regarding the ULP I2C hardware limitation (GitHub PR)

Closes IDFGH-15254

See merge request espressif/esp-idf!39004
2025-05-15 22:30:17 +08:00
Song Ruo Jing 81cca78ca1 Merge branch 'feature/add_uart_io_deinit_process' into 'master'
fix(uart): eliminate garbled data on TX/RX line in sleep

Closes IDF-4897, IDF-13030, and IDF-13037

See merge request espressif/esp-idf!38673
2025-05-15 21:53:04 +08:00
morris 5945ad1a63 Merge branch 'refactor/add_dfs_init_auto_test' into 'master'
fix(mcpwm): the wrong pm lock type on esp32 and esp32s3

See merge request espressif/esp-idf!38934
2025-05-15 21:51:59 +08:00
Konstantin Kondrashov ec096b3823 fix(log): Fix bin log config available only for log version 2 2025-05-15 16:46:45 +03:00
Rahul Tank 9f69fe5033 fix(nimble): Add chip dependancy flag for Flow control feature 2025-05-15 16:30:22 +05:30
Guilherme Ferreira a5313b998c Merge branch 'feat/add-ws-redir' into 'master'
feat(tcp_transport): Add websocket HTTP redirect

Closes IDF-9073

See merge request espressif/esp-idf!37175
2025-05-15 18:56:56 +08:00
Yuan Yu 9a109ca17c fix(peripherals): Correct typo in periph_inttrput_t
Corrected the typo in the type name from 'periph_inttrput_t' to 'periph_interrupt_t'.
2025-05-15 18:40:57 +08:00
radek.tandler c3239ce836 fix(vfs): Fixed include for target linux failing on MacOs 2025-05-15 12:28:11 +02:00
Konstantin Kondrashov 9f6136d650 Merge branch 'feature/parttable_tool_use_only_ascii_for_names' into 'master'
fix(partition_table): Ignore UTF-8 BOM bytes in csv file

See merge request espressif/esp-idf!38954
2025-05-15 18:19:05 +08:00
Erhan Kurubas cead328c1c feat(apptrace): Store CRC16 checksum value of exposed block in the perfmon reg 2025-05-15 12:17:58 +02:00
Sumeet Singh 3dc92d64b9 fix(nimble): Fix proc rx entry comparison 2025-05-15 15:37:55 +05:30
Nachiket Kukade c707faa41d Merge branch 'bugfix/incorrect_sae_pk_flag' into 'master'
Disable SAE-PK indication in Assoc Request when not configured

Closes WIFIBUG-1044

See merge request espressif/esp-idf!38320
2025-05-15 17:55:45 +08:00
Jiang Jiang Jian 4983ba1a59 Merge branch 'bugfix/wpa_eap_v1_connect_issue' into 'master'
fix(softAP): Adjusted authentication mode for wpa-eap version 1

Closes WIFIBUG-954

See merge request espressif/esp-idf!35321
2025-05-15 17:51:49 +08:00
Tomas Rezucha 94d71a8cd0 Merge branch 'feature/usb_dual_host_2' into 'master'
feat(usb/host): Add option to choose peripherals for USB host library

Closes IDF-11705, IDF-9052, and DOC-10991

See merge request espressif/esp-idf!35401
2025-05-15 16:18:05 +08:00
Omar Chebib 6918a45ee6 fix(esp_system): fix RTC reserved area alignment in the linker script
Make sure the size of the RTC reserved area complies with the alignment requirement.

Closes https://github.com/espressif/esp-idf/issues/13082
2025-05-15 16:11:19 +08:00
Wu Zheng Hui d5441e65e5 Merge branch 'fix/fix_usb_hs_phy_leakage_on_deepsleep' into 'master'
fix(esp_hw_support): Fix deepsleep leakage after USB HS phy is initialized

Closes PM-417

See merge request espressif/esp-idf!39144
2025-05-15 16:02:17 +08:00
cjin 4a18a67898 fix(phy): update phy lib to fix phy errors on ESP32-C5 2025-05-15 15:55:46 +08:00
akshat 1b9fe2142d bugfix(wifi): Fix incorrect SAE-PK advertisement in assoc request 2025-05-15 12:47:11 +05:30
armando 8f6a2370d2 refactor(sd): updated sd host api to make 0 value as no change to configurations
use value 0 for `sd_host_slot_cfg_t` members, means no change to previous configurations,
instead of using `override/valid` flag
2025-05-15 15:16:38 +08:00
luoxu 6297edade5 fix(ble_mesh): fixed the issue of incorrect proxy adv flag setting 2025-05-15 15:04:57 +08:00
Samuel Obuch 31a089c751 Merge branch 'ci/enable_gcov_test' into 'master'
ci: enable gcov example for all chips

See merge request espressif/esp-idf!39114
2025-05-15 15:00:48 +08:00
renpeiying 8e4da0b71c Add CN 2025-05-15 14:57:40 +08:00
tarun.kumar c776b440ec fix(softAP): Adjusted authentication mode for wpa-eap version 1 2025-05-15 13:51:31 +08:00
morris a8128adc92 Merge branch 'bugfix/fix_bitscrambler_rx_mode_init_error' into 'master'
fix(bitscrambler): fix bitscrambler RX mode initialization error

Closes IDF-13082

See merge request espressif/esp-idf!39154
2025-05-15 13:42:03 +08:00
morris 4911efca3a Merge branch 'feat/h4_basic_gpio_support' into 'master'
feat(driver_gpio): add esp32h4 basic gpio support

Closes IDF-12390

See merge request espressif/esp-idf!38604
2025-05-15 13:37:01 +08:00
Anton Maklakov c19ed90553 Merge branch 'docs/fix_p4_usb_jtag_pins' into 'master'
docs(jtag): fix esp32p4 usb jtag pins

See merge request espressif/esp-idf!38629
2025-05-15 13:14:04 +08:00
Jiang Jiang Jian c742f0a677 Merge branch 'bugfix/wpa2_suiteb_192bit_reason_code' into 'master'
fix(wifi): Add enterprise check for Suite-B 192-bit certification

Closes WIFIBUG-1070

See merge request espressif/esp-idf!37498
2025-05-15 11:53:31 +08:00
Dong Heng afa79e0473 fix(bitscrambler): fix bitscrambler RX mode initialization error 2025-05-15 11:43:39 +08:00
Gao Xu 733c0586bc Merge branch 'refactor/rng_ll_p4' into 'master'
refactor(rng): refactor to use hal/ll apis for P4

Closes IDF-12476

See merge request espressif/esp-idf!38119
2025-05-15 11:30:54 +08:00
Song Ruo Jing abc9c1fd55 test(gpio,gpio_ext,ppa): test with malloc from psram by default 2025-05-15 11:21:06 +08:00
Song Ruo Jing fa00aa43e7 refactor(uart): minor refactor to uart wakeup code 2025-05-15 11:20:59 +08:00
Song Ruo Jing f1446571e7 fix(uart): eliminate garbled data on UART TX/RX line in sleep 2025-05-15 11:07:26 +08:00
Song Ruo Jing 007a497483 feat(uart): add pin release process to uart driver 2025-05-15 11:07:26 +08:00
tarun.kumar 4fae51e3c1 fix(wifi): Sending disconnect event in connect fail and add enterprise check in Suite-B 192-bit certification 2025-05-15 11:02:32 +08:00
armando c2b8ea07d0 feat(sd): supported UHS-I SDR104 200MHz speed 2025-05-15 10:57:45 +08:00
armando 0944a2a68a test(sd): added SD NG driver allocation tests 2025-05-15 10:57:45 +08:00
armando 0c8b297610 fix(sd): fixed sd with offset performance test wrong log issue 2025-05-15 10:57:45 +08:00
armando 77ae2808b0 refactor(sd): port legacy sd driver with NG driver 2025-05-15 10:57:45 +08:00
armando 402bf0ce58 feat(sd): sd host driver layer driver NG 2025-05-15 10:57:33 +08:00
wanckl 0ed5a94ab0 feat(driver_gpio): add esp32h4 basic gpio support 2025-05-15 10:35:49 +08:00
wuzhenghui 7107177e2d fix(esp_hw_support): Fix deepsleep leakage after initializing USB HS phy 2025-05-15 10:12:59 +08:00
Konstantin Kondrashov 179eb5a5aa refactor(partition_table): Refactoring of code style 2025-05-14 18:45:49 +03:00
Konstantin Kondrashov fc72712b10 fix(partition_table): Ignore UTF-8 BOM bytes in csv file 2025-05-14 18:45:49 +03:00
Roland Dobai f9765d0316 Merge branch 'feat/update_ccache_to_4.11.2' into 'master'
feat(tools): Update ccache 4.10.2 -> 4.11.2

Closes IDFGH-14606

See merge request espressif/esp-idf!38382
2025-05-14 22:24:15 +08:00
Jiang Jiang Jian f1da7a55b1 Merge branch 'bugfix/fix_some_wifi_bugs_250512' into 'master'
bugfix/fix_some_wifi_bugs_250512

See merge request espressif/esp-idf!39047
2025-05-14 21:31:38 +08:00
Harshal Patil e70f2705f3 Merge branch 'fix/enable_ecdsa_verify_sw_fallback_when_p192_disabled' into 'master'
Enable signature verification s/w fallback when ECDSA-P192 is disabled

See merge request espressif/esp-idf!39039
2025-05-14 21:06:03 +08:00
Rahul Tank 01520e84fb Merge branch 'bugfix/fix_nimble_issue_0513' into 'master'
fix(nimble): fix nimble issues 10052025

Closes BLERP-1843, BLERP-1845, BLERP-1861, BLERP-1864, and BLERP-1776

See merge request espressif/esp-idf!39095
2025-05-14 20:27:25 +08:00
Jiang Jiang Jian e7d7412222 Merge branch 'feat/impl_bt_coex_timer_event' into 'master'
feat(coex): implement BT coex timer event

See merge request espressif/esp-idf!39048
2025-05-14 20:25:55 +08:00
Jiang Jiang Jian acc74fd930 Merge branch 'bugfix/force_calibrate_ocode_no_inline_c5eco2' into 'master'
fix(esp_hw_support): Force function calibrate_ocode not inlined to flash

See merge request espressif/esp-idf!39007
2025-05-14 18:44:00 +08:00
Jiang Jiang Jian 582e5690b2 Merge branch 'fix/rrm_config_set' into 'master'
Set rrm config condition in case RRM monitoring is enable

Closes WIFIBUG-1161

See merge request espressif/esp-idf!38841
2025-05-14 17:41:29 +08:00
Samuel Obuch b5303b5d95 Merge branch 'freertos_sysview_deadlock_fix' into 'master'
fix(app_trace): prevent deadlock on sysview start

See merge request espressif/esp-idf!38844
2025-05-14 17:10:42 +08:00
Anton Maklakov c559e045fc docs(jtag): fix esp32p4 usb jtag pins 2025-05-14 17:02:22 +08:00
Zhang Shuxian f201fd08da docs: Update CN for usb_host.rst 2025-05-14 10:34:18 +02:00
Tomas Rezucha cf18fe5568 refactor(usb/host): Remove deprecated usb_otg_periph.h 2025-05-14 10:34:17 +02:00
Tomas Rezucha b961f42e8b feat(usb/host): Add option to choose peripheral for USB host library
Starting with ESP32-P4 we can have targets that have more than 1 USB-OTG peripheral.
This commit adds an option to choose which peripherals will be used by USB Host lib.

Internally, we will still have only 1 Root HUB but with multiple Root ports.
2025-05-14 10:34:11 +02:00
wanglei accfa14bcd fix(esp_hw_support): Force function calibrate_ocode not inlined to flash 2025-05-14 16:24:03 +08:00
tarun.kumar 36588e9a92 fix(wifi) : Set rrm config condition in case RRM monitoring is enabled 2025-05-14 16:21:51 +08:00
Fu Hanxi 66e5cc8801 Merge branch 'ci/child-pipeline-default-value' into 'master'
Ci/child pipeline default value

See merge request espressif/esp-idf!39130
2025-05-14 16:21:41 +08:00
Fu Hanxi 9f68214ab7 ci: child pipeline default value to avoid circular dependency issue 2025-05-14 10:16:36 +02:00
Armando (Dou Yiwen) 0a771792a9 Merge branch 'feat/cache_support_h21' into 'master'
cache: supported cache driver and cache panic drivers on esp32h21

Closes IDF-11524 and IDF-11525

See merge request espressif/esp-idf!39122
2025-05-14 15:48:27 +08:00
Fu Hanxi 0c1e5a13e2 Merge branch 'ci/fix-deploy-jobs-rules' into 'master'
ci: improve deploy rules

Closes IDFCI-2938

See merge request espressif/esp-idf!39068
2025-05-14 15:11:10 +08:00
harshal.patil 0154c7cfe3 fix(mbedtls): Enable signature verification s/w fallback when ECDSA curve is disabled 2025-05-14 12:31:56 +05:30
morris cd10016953 Merge branch 'refactor/public_some_gpio_private_api' into 'master'
refactor(gpio): public some private GPIO functions

See merge request espressif/esp-idf!39120
2025-05-14 14:38:05 +08:00
Peter Dragun 4acf13dc7b Merge branch 'docs/autocolor_multiline' into 'master'
docs(tools/idf-monitor): Add note about autocoloring limitation on multiline logs

Closes IDFGH-15114

See merge request espressif/esp-idf!38829
2025-05-14 14:31:24 +08:00
gaoxu e1b6493304 feat(adc): add always inline for adc ll functions called by bootloader 2025-05-14 13:45:55 +08:00
Mahavir Jain 9750c21933 Merge branch 'feat/cjson_update_to_upstream' into 'master'
feat(cjson): update to latest upstream

See merge request espressif/esp-idf!39053
2025-05-14 13:43:07 +08:00
Gao Xu a6c26c3e21 Merge branch 'feat/add_cam_pm_lock' into 'master'
feat(cam): esp_cam add pm lock function

Closes IDF-12596 and IDF-10093

See merge request espressif/esp-idf!38120
2025-05-14 13:28:23 +08:00
Mahavir Jain ef08ccaddf Merge branch 'bugfix/secure_ota_no_secure_boot' into 'master'
fix: secure OTA without secure boot issue for MMU page size configurable SoCs

Closes IDFGH-15277

See merge request espressif/esp-idf!39022
2025-05-14 13:11:00 +08:00
Sumeet Singh 0a8064c1e5 fix(nimble): Fixed async race condition with HCI outstanding packets counter 2025-05-14 10:26:28 +05:30
Rahul Tank 58542cfdc9 fix(nimble): Extend support for allow connect during scan for more chips 2025-05-14 10:25:13 +05:30
Rahul Tank b9546506d4 fix(nimble): Add support for anonymous address type for whitelist 2025-05-14 10:24:39 +05:30
Rahul Tank 342e0024f1 fix(nimble): Add configurable option to select ext adv v2 command 2025-05-14 10:24:10 +05:30
Ashish Sharma 1e0577ebd0 feat(cjson): update to latest upstream 2025-05-14 12:45:35 +08:00
Armando (Dou Yiwen) 90b978c9cf Merge branch 'feat/mmu_support_h21' into 'master'
mmu: supported esp_mmu_map and flash_mmap drivers on esp32h21

Closes IDF-11540

See merge request espressif/esp-idf!39038
2025-05-14 11:40:59 +08:00
armando 0c6aeecde4 feat(cache): supported cache panic driver on h21 2025-05-14 11:37:30 +08:00
armando acda9a7a7e feat(cache): supported cache driver on h21 2025-05-14 11:37:30 +08:00
gaoxu e7449782d0 ci(cam): test csi/dvp/isp_dvp and test iram_safe 2025-05-14 11:11:59 +08:00
gaoxu 6599ba3c00 feat(cam): esp_cam add pm lock function and test 2025-05-14 11:11:58 +08:00
Zhang Xiao Yan 2189c52776 Merge branch 'docs/add_p4_hdg_and_user_guide' into 'master'
docs: Add links to ESP32-P4 HDG and user guides

See merge request espressif/esp-idf!39029
2025-05-14 10:21:46 +08:00
morris 2b4aae2e3a refactor(gpio): public some private GPIO functions
like enable/disable open drain, enable/disable output capability
2025-05-14 10:14:07 +08:00
Rahul Tank c9bab9e0d3 Merge branch 'fix/gatt_cache_inc_services_uuid_type_error' into 'master'
fix(nimble): Fixed UUID type error in gatt caching included service search

See merge request espressif/esp-idf!39086
2025-05-14 09:26:19 +08:00
Samuel Obuch bee2ed2502 ci: fix app_trace_basic rules and test 2025-05-13 21:31:43 +02:00
Samuel Obuch 4b664441ac ci: enable gcov example for all chips 2025-05-13 21:26:14 +02:00
Roman Leonov 79c66cc16c Merge branch 'refactor/usb_dwc_buff_delay_on_p4' into 'master'
refactor(hcd_dwc): Apply ls_via_fs_hub delay for all targets

See merge request espressif/esp-idf!38946
2025-05-14 01:08:55 +08:00
Tomas Rezucha 27099e1c55 Merge branch 'fix/usbjtag_after_tinyusb' into 'master'
fix(usb/phy): Fix ability to switch back to USB/JTAG after uninstalling TinyUSB

Closes IDFGH-15273 and IDFGH-15248

See merge request espressif/esp-idf!39061
2025-05-14 01:06:05 +08:00
Konstantin Kondrashov 11321b585e fix(examples): Fix CI tests for secure boot cases 2025-05-13 19:20:22 +03:00
Weltenprinz f24025f798 fix(esp_hw_support): Fix compile error on esp_cpu_int_has_handler on ESP32-P4
Merges https://github.com/espressif/esp-idf/pull/15942
Closes https://github.com/espressif/esp-idf/issues/15941
2025-05-13 18:13:15 +03:00
Igor Masar c06fa310cf Merge branch 'feat/usb-explicit-fifo-config' into 'master'
feat(usb/hal): Add HAL API to configure custom FIFO layout

Closes IDF-9042

See merge request espressif/esp-idf!38404
2025-05-13 22:28:41 +08:00
Sudeep Mohanty 0f45b6c6c3 change(lp-core): Update LP I2C and LP UART drivers to use raw interrupt status
This commit updates the LP I2C and LP UART drivers to use the raw
interrupt status without enabling the interrupts.
2025-05-13 15:43:39 +02:00
Chen Yu Dong 8a4f94faf4 Merge branch 'ci/shiny_pip_install' into 'master'
ci: optimize ci runner pip install

Closes RDT-1299

See merge request espressif/esp-idf!38953
2025-05-13 21:29:11 +08:00
Mahavir Jain 17599e60c7 test: add secure image verification case for C6/H2 2025-05-13 18:09:11 +05:30
Mahavir Jain eb5d761c9d fix: secure OTA without secure boot issue for MMU page size configurable SoCs
For secure app verification during OTA update case, the image was
getting memory mapped twice and hence the failure in verification.

Modified from memory mapped flash read to SPI flash read approach
for the MMU page size from image header.

Regression from 07318a4987

Closes https://github.com/espressif/esp-idf/issues/15936
2025-05-13 18:09:03 +05:30
Sumeet Singh b901559207 fix(nimble): Fixed UUID type error in gatt caching included service search 2025-05-13 17:32:01 +05:30
Fu Hanxi dc05b46ab5 ci: inherit more variables
this is somehow a temporary workaround, the long-term solution shall be
related to `inherit:variables`
2025-05-13 13:27:42 +02:00
Fu Hanxi 9a9438b79a ci: improve rules for deploy jobs 2025-05-13 13:27:42 +02:00
John Boiles c9c8560169 fix(usb/phy): Fix ability to switch back to USB/JTAG after uninstalling TinyUSB
Fixes #15912. This is a revert of a change made in 005ae0554 that breaks the
ability to re-initalize the USB/JTAG device after uninstalling TinyUSB.

Closes https://github.com/espressif/esp-idf/issues/15912
2025-05-13 13:21:41 +02:00
Peter Marcisovsky 6d2f4b3656 Merge branch 'feat/usb_host_move_dma_cap_mem_to_psram_p4' into 'master'
feat(usb_host): Move DMA capable memory to external ram on P4

Closes IDF-11115

See merge request espressif/esp-idf!37949
2025-05-13 19:08:11 +08:00
Chen Ji Chang 3baaa8c829 Merge branch 'fix/rename_the_rmt_extra_flags_structure' into 'master'
docs(rmt): rename the rmt extra flags structure

Closes IDFGH-15274 and IDFGH-15270

See merge request espressif/esp-idf!39041
2025-05-13 18:37:05 +08:00
Marius Vikhammer 334cbe0dab Merge branch 'docs/build_h4_docs' into 'master'
feat(docs): add support for building H4 docs

See merge request espressif/esp-idf!38637
2025-05-13 16:16:01 +08:00
Island 617d215f93 Merge branch 'bugfix/fix_some_ble_bugs_0422' into 'master'
Bugfix/fix some ble bugs 0422

Closes BLERP-1863

See merge request espressif/esp-idf!39042
2025-05-13 15:38:38 +08:00
peter.marcisovsky cd5b3877bf feat(usb_host): Move DMA capable memory to external ram on P4
- DWC-OTG internal DMA can access psram on esp32p4
    - Move DMA memory buffs to psram, to save internal ram
    - HCD tests and MSC example runs in CI with psram enabled
2025-05-13 15:37:30 +08:00
linruihao b370ebdef4 feat(coex): implement BT coex timer event 2025-05-13 15:13:12 +08:00
Marek Fiala 478eea8992 feat(tools): Update ccache 4.10.2 -> 4.11.2
Closes https://github.com/espressif/idf-installer/issues/305
2025-05-13 15:07:51 +08:00
armando 45db752f2f feat(mmu): supported esp_mmu_map and flash_mmap drivers on esp32h21 2025-05-13 14:58:19 +08:00
C.S.M 38e84d554a Merge branch 'fix/i2c_ci_esp32c5' into 'master'
test(i2c): Re-enable i2c test on esp32c5

Closes IDFCI-2895

See merge request espressif/esp-idf!39040
2025-05-13 14:56:02 +08:00
yinqingzhao 4e20dc58b3 fix(wifi): fix build issue by modifying parttion table of file_server example 2025-05-13 14:39:30 +08:00
Chen Jichang e53c25d3ae docs(rmt): improve the documentation
Closes https://github.com/espressif/esp-idf/issues/15933
Closes https://github.com/espressif/esp-idf/issues/15929
2025-05-13 14:14:45 +08:00
hrushikesh.bhosale 542d07d34a feat(http_server): httpd register handler strdup failure case check
In httpd_register_uri_handler api, for the strdup function failure case was not
checked and not returned any error by freeing previously allocated memory, if the memory
allocation for strdup function did not gets successful.

Closes https://github.com/espressif/esp-idf/issues/15878
2025-05-13 11:27:02 +05:30
Rahul Tank 764d722bec Merge branch 'feat/gatt_cache_info' into 'master'
fix(nimble): Added api's to fetch gatt cache info

Closes BLERP-1702

See merge request espressif/esp-idf!38048
2025-05-13 13:54:19 +08:00
morris aa714f5ae6 Merge branch 'doc/summarize_bs_support_status' into 'master'
docs(bitscrambler): update documentation with integration details

See merge request espressif/esp-idf!39044
2025-05-13 13:37:52 +08:00
Roland Dobai 810eadd917 Merge branch 'fix/gen_soc_caps' into 'master'
change: config options of the same name must have the same type

Closes IDF-12805

See merge request espressif/esp-idf!38322
2025-05-13 12:48:03 +08:00
Mahavir Jain 28afc7067f Merge branch 'fix/esp32c5_eco2_efuse_test' into 'master'
fix(efuse): Fix ESP32-C5 eFuse test for ECO2

Closes IDFCI-2920

See merge request espressif/esp-idf!39046
2025-05-13 12:13:46 +08:00
yinqingzhao 5bed100761 feat(wifi): add tx error 0xa0 count 2025-05-13 11:54:59 +08:00
Jiang Jiang Jian 9c84243073 Merge branch 'bugfix/wps_pbc_overlap_uuid' into 'master'
fix(wpa_supplicant): Ensure pbc_overlap event is posted correctly

Closes WIFIBUG-1115 and WIFIBUG-1055

See merge request espressif/esp-idf!38206
2025-05-13 11:11:43 +08:00
Marius Vikhammer f3d1717408 docs(esp32h4): support building esp32h4 docs 2025-05-13 11:09:15 +08:00
Wu Zheng Hui 27ec17a623 Merge branch 'fix/fix_usj_pad_leakage' into 'master'
fix(esp_hw_support): fix usj pad leakage in lightsleep

Closes PM-407

See merge request espressif/esp-idf!38949
2025-05-13 10:41:51 +08:00
Jiang Jiang Jian c4aaceb430 Merge branch 'bugfix/scan_stop_when_conenct' into 'master'
fix(esp_wifi): Fix locking in inccorrect state when stop_scan is called after connect

See merge request espressif/esp-idf!38779
2025-05-13 10:36:12 +08:00
zhanghaipeng 7c16bce827 fix(ble/bluedroid): Fixed issue with deleting link key when classic Bluetooth is not used 2025-05-13 10:25:24 +08:00
gaoxu b691eaba6d refactor(rng): refactor to use hal/ll apis for P4 2025-05-13 09:09:06 +08:00
Ivan Grokhotkov 7f6e7f4506 Merge branch 'version/v6.0.0' into 'master'
change(version): Update version to v6.0-dev

See merge request espressif/esp-idf!38889
2025-05-12 23:56:30 +02:00
Samuel Obuch e65f7359e6 fix(sysview): do not use freertos ticks to prevent deadlock 2025-05-12 16:12:26 +02:00
renpeiying f5a28000fa docs: Update CN for idf-monitor.rst 2025-05-12 22:07:50 +08:00
Peter Dragun 9859f5e690 docs(tools/idf-monitor): Add note about autocoloring limitation on multiline logs
Closes https://github.com/espressif/esp-idf/issues/15793
2025-05-12 22:07:50 +08:00
Shreyas Sheth 0103155f6f fix(esp_wifi): Fix locking in incorrect state when stop_scan is called after connect 2025-05-12 18:03:43 +05:30
akshat 3ee449bc5d fix(wpa_supplicant): Disconnect from previous AP while initiating WPS 2025-05-12 20:23:11 +08:00
akshat 91da4ea792 fix(wpa_supplicant): Detect PBC overlap even when UUID is null 2025-05-12 20:23:11 +08:00
akshat c99c80c1d0 fix(wpa_supplicant): Ensure pbc_overlap event is posted correctly
Preserves the pbc_overlap flag to allow proper event posting.
This ensures that pbc overlap detection functions as expected.
2025-05-12 20:23:11 +08:00
Konstantin Kondrashov f9b81e80ba fix(efuse): Fix ESP32-C5 eFuse test for ECO2 2025-05-12 14:33:41 +03:00
Ivan Grokhotkov f89d6ee5a0 change(version): Update version to v6.0-dev 2025-05-12 11:39:42 +02:00
Ivan Grokhotkov f019c5d549 change(docs): silence new Sphinx warnings after Doxygen upgrade
Co-authored-by: Marius Vikhammer <marius.vikhammer@espressif.com>
2025-05-12 11:39:41 +02:00
Ivan Grokhotkov 7023b489a7 change(examples): temp. disable examples which need esp_wifi_remote
Will be re-enabled after adding IDF 6.0 compatibility in
esp_wifi_remote.
2025-05-12 11:39:41 +02:00
Ivan Grokhotkov 236200a93f change(examples): remove idf version dependency 2025-05-12 11:39:41 +02:00
Linda 71b992ac5d docs: Add links to ESP32-P4 HDG and user guides 2025-05-12 17:13:39 +08:00
zhanghaipeng 0586d10317 fix(ble/bluedroid): Reduce Bluedroid host log output over SPI 2025-05-12 17:12:44 +08:00
morris 94830549ae docs(bitscrambler): update documentation with integration details 2025-05-12 17:09:00 +08:00
Nebojsa Cvetkovic bfa0fff2e5 fix(ble/bluedroid): Added value len check in esp_ble_gatts_send_indicate() 2025-05-12 16:29:03 +08:00
zhanghaipeng df8c1f7a96 fix(ble/bluedroid): Change maximum length of attribute value to 517 2025-05-12 16:29:03 +08:00
zhanghaipeng ebb76933d0 docs(ble): clarify meaning of 0 value for esp_ble_gap_start_ext_scan() parameters 2025-05-12 16:29:03 +08:00
zhanghaipeng 6552854cb5 fix(ble/bluedroid): Fixed BLE GAP appearance configuration check 2025-05-12 16:29:03 +08:00
C.S.M c758af714a test(i2c): Re-enable i2c test on esp32c5 2025-05-12 15:48:52 +08:00
Astha Verma 993bd86ee1 fix(nimble): Added api's for fetching gatt cache data and for discovering included service 2025-05-12 11:54:27 +05:30
igor.masar cb4d90186f feat(usb/hal): Add support for explicit FIFO configuration
Introduce a new HAL API `usb_dwc_hal_set_fifo_config()` that allows advanced users
to manually configure RX, Non-Periodic TX, and Periodic TX FIFO sizes. This offers
fine-grained control beyond the previous bias-based sizing approach.

The HAL function no longer returns `esp_err_t`, and internal validations are enforced
via `HAL_ASSERT()`. Responsibility for input validation has been moved to the HCD layer.

FIFO configuration must be applied before any USB pipes are created or activated.
This feature is intended for use during `usb_host_install()`.

If no custom FIFO configuration is provided (i.e., all values are zero),
the driver falls back to a bias-based default layout based on Kconfig settings
(`CONFIG_USB_HOST_HW_BUFFER_BIAS_*`). Bias resolution is done inside `hcd_port_init()`.

The `port_obj_t` structure has been extended with a `fifo_config` field, which stores
the configuration to allow re-application after a USB port reset.

Obsolete FIFO bias enums (`usb_hal_fifo_bias_t`, `hcd_port_fifo_bias_t`) and related
APIs (`hcd_port_set_fifo_bias()`) have been removed in favor of the new structure-based mechanism.

The HCD initialization and port reset flow has been updated to use the explicit
FIFO configuration.

USB Host maintainer documentation (`maintainers.md`) has been updated accordingly.
Test cases were updated to remove the usage of removed bias API and now rely on default
or custom FIFO configuration.
2025-05-09 15:03:52 +02:00
Erik Slagter 1fa908a7a5 feat(docs): Small additions to ulp-risc-v.rst regarding the ULP I2C peripheral
This clarifies that the limited set of possible
transactions using the ULP I2C peripheral is a
hardware limitation and not a limitation of the
ESP-IDF and exactly what and how it's limited.

Merge https://github.com/espressif/esp-idf/pull/15917
2025-05-09 12:08:22 +03:00
Chen Yudong a62464501f ci: optimize ci runner pip install 2025-05-09 16:01:32 +08:00
Aditi 9f4eb5c94b feat(esp_wifi): Add example to write wifi config in nvs
This commit adds example for using wifi station and softap by flashing wifi config
directly into nvs using NVS Partition generator Utility (using csv file).

Closes https://github.com/espressif/esp-idf/issues/14554
2025-05-09 11:34:47 +05:30
morris 5cc6cbd4c7 fix(mcpwm): the wrong pm lock type on esp32 and esp32s3 2025-05-08 21:25:47 +08:00
Jan Beran ba86dbb9f6 change(gen_soc_caps_kconfig): check if config options have the same type
Also introduce ignore pragma to prevent some #defines from .h files to
be translated to Kconfig files.
2025-05-07 13:37:05 +02:00
wuzhenghui cd54be77db fix(esp_hw_support): always disable USJ pad in sleep to supress leakage 2025-05-07 17:33:25 +08:00
Roman Leonov 898f881226 refactor(hcd_dwc): Apply delay for all targets 2025-05-07 11:14:30 +02:00
glmfe 2205a22dc1 feat(tcp_transport): Add websocket HTTP redirect
- Add and expose URI parser from HTTP when received a 301 status
2025-05-06 08:20:42 -03:00
Amitesh Singh 201df702da feat(lwip/config): add menuconfig option for setting LWIP_IPV6_DUP_DETECT_ATTEMPTS
In my network, ipv6 address allocation to esp32 was unreliable.
I'd to disable LWIP_IPV6_DUP_DETECT_ATTEMPTS to 0 to actually make
esp32 ipv6 address assignment work reliably.

Signed-off-by: Amitesh Singh <singh.amitesh@gmail.com>
2025-05-06 10:17:59 +05:30
wuzhenghui fc58a6c116 fix(esp_hw_support): fix esp32p4 may get stuck when entering deepsleep 2025-04-27 19:27:24 +08:00
1546 changed files with 72444 additions and 70917 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
[codespell]
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*,*.pem,components/newlib/COPYING.*
skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*,*.pem,components/newlib/COPYING.*,docs/sphinx-known-warnings.txt
ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart,wheight,wel,ot,fane,assertIn,registr,oen,parms
write-changes = true
+1 -1
View File
@@ -8,7 +8,7 @@ on:
jobs:
release_zips:
name: Create release zip file
runs-on: ubuntu-24.04
runs-on: ubuntu-20.04
steps:
- name: Create a recursive clone source zip
uses: espressif/release-zips-action@v1
+1
View File
@@ -37,6 +37,7 @@ components/**/build/
components/**/build_*_*/
components/**/sdkconfig
components/**/sdkconfig.old
components/**/test_apps/wifi_nvs_config/nvs_data_suffix.csv
# Example project files
examples/**/build/
+249 -1
View File
@@ -2,5 +2,253 @@
#
# https://docs.gitlab.com/ee/user/project/code_owners.html#the-syntax-of-code-owners-files
#
# If more than one rule matches a given file, the latest rule is used.
# The file should be generally kept sorted, except when it is necessary
# to use a different order due to the fact above. In that case, use
# '# sort-order-reset' comment line to reset the sort order.
#
# Recipes for a few common cases:
#
# 1. Specific directory with all its contents:
#
# /components/app_trace/
#
# Note the trailing slash!
#
# 2. File with certain extension in any subdirectory of a certain directory:
#
# /examples/**/*.py
#
# This includes an *.py files in /examples/ directory as well.
#
# 3. Contents of a directory with a certain name, anywhere in the tree:
#
# test_*_host/
#
# Will match everything under components/efuse/test_efuse_host/,
# components/heap/test_multi_heap_host/, components/lwip/test_afl_host/, etc.
#
# 4. Same as above, except limited to a specific place in the tree:
#
# /components/esp32*/
#
# Matches everything under /components/esp32, /components/esp32s2, etc.
# Doesn't match /tools/some-test/components/esp32s5.
#
# 5. Specific file:
#
# /tools/tools.json
#
# 6. File with a certain name anywhere in the tree
#
# .gitignore
#
* @esp-idf-codeowners/all-maintainers
* @esp-idf-codeowners/other
/.* @esp-idf-codeowners/tools
/.codespellrc @esp-idf-codeowners/ci
/.github/workflows/ @esp-idf-codeowners/ci
/.gitlab-ci.yml @esp-idf-codeowners/ci
/.gitlab/ci/ @esp-idf-codeowners/ci
/.pre-commit-config.yaml @esp-idf-codeowners/ci
/.readthedocs.yml @esp-idf-codeowners/docs
/.vale.ini @esp-idf-codeowners/docs
/CMakeLists.txt @esp-idf-codeowners/build-config
/COMPATIBILITY*.md @esp-idf-codeowners/peripherals
/CONTRIBUTING.md @esp-idf-codeowners/docs
/Kconfig @esp-idf-codeowners/build-config
/README*.md @esp-idf-codeowners/docs
/ROADMAP*.md @esp-idf-codeowners/docs
/SUPPORT_POLICY*.md @esp-idf-codeowners/docs
/add_path.sh @esp-idf-codeowners/tools
/conftest.py @esp-idf-codeowners/ci
/export.* @esp-idf-codeowners/tools
/install.* @esp-idf-codeowners/tools
/pytest.ini @esp-idf-codeowners/ci
/ruff.toml @esp-idf-codeowners/tools
/sdkconfig.rename @esp-idf-codeowners/build-config
/sonar-project.properties @esp-idf-codeowners/ci
# sort-order-reset
/components/app_trace/ @esp-idf-codeowners/debugging
/components/app_update/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
/components/bootloader*/ @esp-idf-codeowners/system @esp-idf-codeowners/security
/components/bootloader_support/bootloader_flash/ @esp-idf-codeowners/peripherals
/components/bt/ @esp-idf-codeowners/bluetooth
/components/cmock/ @esp-idf-codeowners/system
/components/console/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities/console
/components/cxx/ @esp-idf-codeowners/system
/components/driver/ @esp-idf-codeowners/peripherals
/components/efuse/ @esp-idf-codeowners/system
/components/esp_adc/ @esp-idf-codeowners/peripherals
/components/esp_app_format/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
/components/esp_bootloader_format/ @esp-idf-codeowners/system @esp-idf-codeowners/app-utilities
/components/esp_coex/ @esp-idf-codeowners/wifi @esp-idf-codeowners/bluetooth @esp-idf-codeowners/ieee802154
/components/esp_common/ @esp-idf-codeowners/system
/components/esp_driver_*/ @esp-idf-codeowners/peripherals
/components/esp_driver_sdmmc/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/storage
/components/esp_eth/ @esp-idf-codeowners/network
/components/esp_event/ @esp-idf-codeowners/system
/components/esp_gdbstub/ @esp-idf-codeowners/debugging
/components/esp_hid/ @esp-idf-codeowners/bluetooth
/components/esp_http_client/ @esp-idf-codeowners/app-utilities
/components/esp_http_server/ @esp-idf-codeowners/app-utilities
/components/esp_https_ota/ @esp-idf-codeowners/app-utilities
/components/esp_https_server/ @esp-idf-codeowners/app-utilities
/components/esp_hw_support/ @esp-idf-codeowners/system @esp-idf-codeowners/peripherals
/components/esp_hw_support/lowpower/ @esp-idf-codeowners/power-management
/components/esp_lcd/ @esp-idf-codeowners/peripherals
/components/esp_local_ctrl/ @esp-idf-codeowners/app-utilities
/components/esp_mm/ @esp-idf-codeowners/peripherals
/components/esp_netif/ @esp-idf-codeowners/network
/components/esp_netif_stack/ @esp-idf-codeowners/network
/components/esp_partition/ @esp-idf-codeowners/storage
/components/esp_phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
/components/esp_pm/ @esp-idf-codeowners/power-management @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/system
/components/esp_psram/ @esp-idf-codeowners/peripherals
/components/esp_psram/system_layer/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
/components/esp_ringbuf/ @esp-idf-codeowners/system
/components/esp_rom/ @esp-idf-codeowners/system @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi
/components/esp_security/ @esp-idf-codeowners/security
/components/esp_system/ @esp-idf-codeowners/system
/components/esp_tee/ @esp-idf-codeowners/security
/components/esp_timer/ @esp-idf-codeowners/system
/components/esp-tls/ @esp-idf-codeowners/app-utilities
/components/esp_vfs_*/ @esp-idf-codeowners/storage
/components/esp_vfs_console/ @esp-idf-codeowners/storage @esp-idf-codeowners/system
/components/esp_wifi/ @esp-idf-codeowners/wifi
/components/espcoredump/ @esp-idf-codeowners/debugging
/components/esptool_py/ @esp-idf-codeowners/tools
/components/fatfs/ @esp-idf-codeowners/storage
/components/freertos/ @esp-idf-codeowners/system
/components/hal/ @esp-idf-codeowners/peripherals
/components/hal/test_apps/crypto/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/security
/components/heap/ @esp-idf-codeowners/system
/components/http_parser/ @esp-idf-codeowners/app-utilities
/components/idf_test/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
/components/ieee802154/ @esp-idf-codeowners/ieee802154
/components/json/ @esp-idf-codeowners/app-utilities
/components/linux/ @esp-idf-codeowners/system
/components/log/ @esp-idf-codeowners/system
/components/lwip/ @esp-idf-codeowners/lwip
/components/mbedtls/ @esp-idf-codeowners/app-utilities/mbedtls @esp-idf-codeowners/security
/components/mqtt/ @esp-idf-codeowners/network
/components/newlib/ @esp-idf-codeowners/system @esp-idf-codeowners/toolchain
/components/nvs_flash/ @esp-idf-codeowners/storage
/components/nvs_sec_provider/ @esp-idf-codeowners/storage @esp-idf-codeowners/security
/components/openthread/ @esp-idf-codeowners/ieee802154
/components/partition_table/ @esp-idf-codeowners/system
/components/perfmon/ @esp-idf-codeowners/debugging
/components/protobuf-c/ @esp-idf-codeowners/app-utilities
/components/protocomm/ @esp-idf-codeowners/app-utilities/provisioning
/components/pthread/ @esp-idf-codeowners/system
/components/riscv/ @esp-idf-codeowners/system
/components/rt/ @esp-idf-codeowners/system
/components/sdmmc/ @esp-idf-codeowners/storage
/components/soc/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
/components/spi_flash/ @esp-idf-codeowners/peripherals
/components/spiffs/ @esp-idf-codeowners/storage
/components/tcp_transport/ @esp-idf-codeowners/network
/components/touch_element/ @esp-idf-codeowners/peripherals
/components/ulp/ @esp-idf-codeowners/system
/components/unity/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system
/components/usb/ @esp-idf-codeowners/peripherals/usb
/components/vfs/ @esp-idf-codeowners/storage
/components/wear_levelling/ @esp-idf-codeowners/storage
/components/wifi_provisioning/ @esp-idf-codeowners/app-utilities/provisioning
/components/wpa_supplicant/ @esp-idf-codeowners/wifi @esp-idf-codeowners/app-utilities/mbedtls
/components/xtensa/ @esp-idf-codeowners/system
/docs/ @esp-idf-codeowners/docs
/docs/docs_not_updated/ @esp-idf-codeowners/all-maintainers
/docs/**/api-guides/tools/ @esp-idf-codeowners/tools
/docs/en/api-guides/core_dump.rst @esp-idf-codeowners/debugging
/docs/**/api-guides/wifi* @esp-idf-codeowners/wifi
/docs/**/api-guides/esp-wifi-mesh.rst @esp-idf-codeowners/wifi
/docs/en/api-guides/jtag-debugging/ @esp-idf-codeowners/debugging
/docs/**/api-reference/bluetooth/ @esp-idf-codeowners/bluetooth
/docs/**/api-reference/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi
/docs/**/api-reference/peripherals/ @esp-idf-codeowners/peripherals
/docs/**/api-reference/peripherals/usb* @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
/docs/**/api-reference/peripherals/usb*/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
/docs/**/api-reference/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
/docs/**/api-reference/provisioning/ @esp-idf-codeowners/app-utilities/provisioning
/docs/**/api-reference/storage/ @esp-idf-codeowners/storage
/docs/**/api-reference/system/ @esp-idf-codeowners/system
/docs/**/security/ @esp-idf-codeowners/security
/docs/**/migration-guides/ @esp-idf-codeowners/docs @esp-idf-codeowners/all-maintainers
/docs/**/contribute/install-pre-commit-hook.rst @esp-idf-codeowners/ci @esp-idf-codeowners/tools
/examples/README.md @esp-idf-codeowners/docs @esp-idf-codeowners/ci
/examples/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
/examples/bluetooth/ @esp-idf-codeowners/bluetooth
/examples/build_system/ @esp-idf-codeowners/build-config
/examples/common_components/ @esp-idf-codeowners/system @esp-idf-codeowners/wifi @esp-idf-codeowners/lwip @esp-idf-codeowners/network
/examples/custom_bootloader/ @esp-idf-codeowners/system
/examples/cxx/ @esp-idf-codeowners/system
/examples/ethernet/ @esp-idf-codeowners/network
/examples/get-started/ @esp-idf-codeowners/system
/examples/ieee802154/ @esp-idf-codeowners/ieee802154
/examples/lowpower/ @esp-idf-codeowners/power-management @esp-idf-codeowners/system
/examples/mesh/ @esp-idf-codeowners/wifi
/examples/network/ @esp-idf-codeowners/network @esp-idf-codeowners/wifi
/examples/openthread/ @esp-idf-codeowners/ieee802154
/examples/peripherals/ @esp-idf-codeowners/peripherals
/examples/peripherals/usb/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/peripherals/usb
/examples/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
/examples/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
/examples/provisioning/ @esp-idf-codeowners/app-utilities/provisioning
/examples/security/ @esp-idf-codeowners/security
/examples/storage/ @esp-idf-codeowners/storage
/examples/system/ @esp-idf-codeowners/system
/examples/system/ota/ @esp-idf-codeowners/app-utilities
/examples/wifi/ @esp-idf-codeowners/wifi
/examples/zigbee/ @esp-idf-codeowners/ieee802154
/tools/ @esp-idf-codeowners/tools
/tools/ble/ @esp-idf-codeowners/app-utilities
/tools/bt/ @esp-idf-codeowners/bluetooth
/tools/catch/ @esp-idf-codeowners/ci
/tools/ci/ @esp-idf-codeowners/ci
/tools/cmake/ @esp-idf-codeowners/build-config
/tools/cmake/toolchain-*.cmake @esp-idf-codeowners/toolchain
/tools/esp_app_trace/ @esp-idf-codeowners/debugging
/tools/esp_prov/ @esp-idf-codeowners/app-utilities
/tools/gdb_panic_server.py @esp-idf-codeowners/debugging
/tools/kconfig*/ @esp-idf-codeowners/build-config
/tools/ldgen/ @esp-idf-codeowners/build-config
/tools/mass_mfg/ @esp-idf-codeowners/app-utilities
/tools/mocks/ @esp-idf-codeowners/system
/tools/test_apps/ @esp-idf-codeowners/ci
/tools/test_apps/README.md @esp-idf-codeowners/docs @esp-idf-codeowners/ci
## Note: owners here should be the same as the owners for the same example subdir, above
/tools/test_apps/build_system/ @esp-idf-codeowners/build-config
/tools/test_apps/configs/ @esp-idf-codeowners/system
/tools/test_apps/linux_compatible/ @esp-idf-codeowners/system
/tools/test_apps/peripherals/ @esp-idf-codeowners/peripherals
/tools/test_apps/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154
/tools/test_apps/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities
/tools/test_apps/security/ @esp-idf-codeowners/security
/tools/test_apps/storage/ @esp-idf-codeowners/storage
/tools/test_apps/system/ @esp-idf-codeowners/system
/tools/test_apps/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
/tools/test_build_system/ @esp-idf-codeowners/tools @esp-idf-codeowners/build-config
/tools/tools.json @esp-idf-codeowners/tools @esp-idf-codeowners/toolchain @esp-idf-codeowners/debugging
/tools/unit-test-app/ @esp-idf-codeowners/system @esp-idf-codeowners/tools
# sort-order-reset
/components/**/test_apps/**/*.py @esp-idf-codeowners/ci @esp-idf-codeowners/tools
# ignore lists
/tools/ci/check_copyright_config.yaml @esp-idf-codeowners/all-maintainers
/tools/ci/check_copyright_ignore.txt @esp-idf-codeowners/all-maintainers
/tools/ci/mypy_ignore_list.txt @esp-idf-codeowners/tools
+6 -1
View File
@@ -231,13 +231,18 @@ pytest_build_system_macos:
- .after_script:build:macos:upload-failed-job-logs:ccache-show-stats
- .rules:build:macos
tags:
- macos_shell
- macos
parallel: 3
variables:
PYENV_VERSION: "3.9"
# CCACHE_DIR: "/cache/idf_ccache". On macOS, you cannot write to this folder due to insufficient permissions.
CCACHE_DIR: "" # ccache will use "$HOME/Library/Caches/ccache".
CCACHE_MAXSIZE: "5G" # To preserve the limited Macbook storage. CCACHE automatically prunes old caches to fit the set limit.
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,
# but a relative path to the build directory (builds/espressif/esp-idf instead of ~/builds/espressif/esp-idf.
# GitLab sets the project dir to this template `<builds_dir>/<namespace>/<project_name>`
IDF_PATH: "/Users/espressif/builds/espressif/esp-idf"
build_docker:
extends:
- .before_script:minimal
+12 -7
View File
@@ -40,7 +40,7 @@ variables:
GIT_FETCH_EXTRA_FLAGS: "--no-recurse-submodules --prune --prune-tags"
# we're using .cache folder for caches
GIT_CLEAN_FLAGS: -ffdx -e .cache/
LATEST_GIT_TAG: v5.5
LATEST_GIT_TAG: v6.0-dev
SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py"
# by default we will fetch all submodules
@@ -55,9 +55,9 @@ variables:
CHECKOUT_REF_SCRIPT: "$CI_PROJECT_DIR/tools/ci/checkout_project_ref.py"
# Docker images
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v5.5:3"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v5.5:3-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.5:2"
ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v6.0:1"
ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v6.0:1-1"
TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v6.0:1"
SONARQUBE_SCANNER_IMAGE: "${CI_DOCKER_REGISTRY}/sonarqube-scanner:5"
PRE_COMMIT_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-pre-commit:1"
@@ -70,7 +70,7 @@ variables:
CI_PYTHON_CONSTRAINT_BRANCH: ""
# Update the filename for a specific ESP-IDF release. It is used only with CI_PYTHON_CONSTRAINT_BRANCH.
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v5.5.txt"
CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v6.0.txt"
# Set this variable to repository name of a Python tool you wish to install and test in the context of ESP-IDF CI.
# Keep the variable empty when not used.
@@ -140,6 +140,13 @@ variables:
if [[ -n "$IDF_DONT_USE_MIRRORS" ]]; then
export IDF_MIRROR_PREFIX_MAP=
fi
# Optimize pip install
if echo "${CI_RUNNER_TAGS}" | grep "shiny"; then
export PIP_INDEX_URL="${PIP_INDEX_URL_SHINY}"
fi
if [[ "$(uname -m)" == "x86_64" ]] || [[ "$(uname -m)" == "aarch64" ]]; then
export IDF_PIP_WHEELS_URL=""
fi
if [[ "${CI_JOB_STAGE}" != "target_test" ]]; then
section_start "running_install_sh" "Running install.sh"
@@ -236,8 +243,6 @@ variables:
# Ensure pyenv and PYENV_VERSION installed
- eval "$(pyenv init -)"
- *common-before_scripts
# On macOS, these tools need to be installed
- export IDF_TOOLS_PATH="${HOME}/.espressif_runner_${CI_RUNNER_ID}_${CI_CONCURRENT_ID}"
# remove idf-env.json, since it may contains enabled "features"
- rm -f $IDF_TOOLS_PATH/idf-env.json
# This adds tools (compilers) and the version-specific Python environment to PATH
+1 -1
View File
@@ -14,9 +14,9 @@ extra_default_build_targets:
bypass_check_test_targets:
- esp32h21
- esp32c61
- esp32h4
- esp32c5
- esp32c61
#
# These lines would
+1 -1
View File
@@ -91,4 +91,4 @@
specific_rules:
- if-schedule-test-build-system-windows
patterns:
- build_system
- build_system_win
+10 -3
View File
@@ -3,7 +3,6 @@
image: $ESP_ENV_IMAGE
tags: [ deploy ]
# Check this before push_to_github
check_submodule_sync:
extends:
- .deploy_job_template
@@ -31,8 +30,9 @@ push_to_github:
extends:
- .deploy_job_template
- .before_script:minimal
- .rules:push_to_github
- .rules:protected:deploy
needs:
# submodule must be synced before pushing to github
- check_submodule_sync
tags: [ brew, github_sync ]
variables:
@@ -45,12 +45,16 @@ push_to_github:
- git remote remove github &>/dev/null || true
- git remote add github git@github.com:espressif/esp-idf.git
- tools/ci/push_to_github.sh
environment:
name: push_to_github_production
deployment_tier: production
url: "https://github.com/espressif/esp-idf"
deploy_update_SHA_in_esp-dockerfiles:
extends:
- .deploy_job_template
- .before_script:minimal
- .rules:protected-no_label-always
- .rules:protected:deploy
dependencies: []
variables:
GIT_DEPTH: 2
@@ -59,3 +63,6 @@ deploy_update_SHA_in_esp-dockerfiles:
- 'curl --header "PRIVATE-TOKEN: ${ESPCI_SCRIPTS_TOKEN}" -o create_MR_in_esp_dockerfile.sh $GITLAB_HTTP_SERVER/api/v4/projects/1260/repository/files/create_MR_in_esp_dockerfile%2Fcreate_MR_in_esp_dockerfile.sh/raw\?ref\=master'
- chmod +x create_MR_in_esp_dockerfile.sh
- ./create_MR_in_esp_dockerfile.sh
environment:
name: eploy_update_SHA_in_esp-dockerfiles_production
deployment_tier: production
+15 -12
View File
@@ -4,10 +4,10 @@
- "**/*.rst"
- "CONTRIBUTING.rst"
- "**/soc_caps.h"
- "**/Kconfig*"
.patterns-docs-partial: &patterns-docs-partial
- "components/**/*.h"
- "components/**/Kconfig*"
- "components/**/CMakeList.txt"
- "components/**/sdkconfig*"
- "tools/tools.json"
@@ -19,12 +19,9 @@
.patterns-docs-preview: &patterns-docs-preview
- "docs/**/*"
.if-protected: &if-protected
.if-protected-check: &if-protected-check
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/)'
.if-protected-no_label: &if-protected-no_label
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && $BOT_TRIGGER_WITH_LABEL == null'
.if-qa-test-tag: &if-qa-test-tag
if: '$CI_COMMIT_TAG =~ /^qa-test/'
@@ -41,7 +38,7 @@
rules:
- <<: *if-qa-test-tag
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build_docs
- <<: *if-label-docs_full
- <<: *if-dev-push
@@ -64,7 +61,7 @@ check_readme_links:
tags: ["build", "amd64", "internet"]
allow_failure: true
rules:
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-dev-push
changes: *patterns-example-readme
script:
@@ -96,7 +93,7 @@ check_docs_lang_sync:
parallel:
matrix:
- DOCLANG: ["en", "zh_CN"]
DOCTGT: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c2", "esp32c6", "esp32c61", "esp32c5","esp32h2", "esp32h21", "esp32p4"]
DOCTGT: ["esp32", "esp32s2", "esp32s3", "esp32c3", "esp32c2", "esp32c6", "esp32c61", "esp32c5", "esp32h2", "esp32h4", "esp32h21", "esp32p4"]
check_docs_gh_links:
image: $ESP_IDF_DOC_ENV_IMAGE
@@ -182,14 +179,17 @@ deploy_docs_preview:
DOCS_DEPLOY_SERVER_USER: "$DOCS_SERVER_USER"
DOCS_DEPLOY_PATH: "$DOCS_PATH"
DOCS_DEPLOY_URL_BASE: "https://$DOCS_PREVIEW_SERVER_URL/docs/esp-idf"
environment:
name: deploy_docs_preview
deployment_tier: staging
url: "https://$DOCS_PREVIEW_SERVER_URL/docs/esp-idf"
# stage: post_deploy
deploy_docs_production:
# The DOCS_PROD_* variables used by this job are "Protected" so these branches must all be marked "Protected" in Gitlab settings
extends:
- .deploy_docs_template
rules:
- <<: *if-protected-no_label
- .rules:protected:deploy
stage: post_deploy
dependencies: # set dependencies to null to avoid missing artifacts issue
needs: # ensure runs after push_to_github succeeded
@@ -204,12 +204,15 @@ deploy_docs_production:
DOCS_DEPLOY_PATH: "$DOCS_PROD_PATH"
DOCS_DEPLOY_URL_BASE: "https://docs.espressif.com/projects/esp-idf"
DEPLOY_STABLE: 1
environment:
name: deploy_docs_production
deployment_tier: production
url: "https://docs.espressif.com/projects/esp-idf"
check_doc_links:
extends:
- .build_docs_template
rules:
- <<: *if-protected-no_label
- .rules:protected:deploy
stage: post_deploy
needs:
- job: deploy_docs_production
+9 -4
View File
@@ -113,7 +113,8 @@ test_cli_installer:
script:
# Tools must be downloaded for testing
# We could use "idf_tools.py download all", but we don't want to install clang because of its huge size
- python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa cmake
# cmake@version that is supported
- python3 ${IDF_PATH}/tools/idf_tools.py download required qemu-riscv32 qemu-xtensa cmake cmake@3.16.3
- cd ${IDF_PATH}/tools/test_idf_tools
- python3 -m pip install jsonschema
- python3 ./test_idf_tools.py -v
@@ -348,7 +349,7 @@ test_pytest_macos:
- .host_test_template
- .before_script:build:macos
tags:
- macos_shell
- macos
artifacts:
paths:
- XUNIT_RESULT.xml
@@ -359,18 +360,22 @@ test_pytest_macos:
variables:
PYENV_VERSION: "3.9"
PYTEST_IGNORE_COLLECT_IMPORT_ERROR: "1"
# Workaround for a bug in Parallels executor where CI_PROJECT_DIR is not an absolute path,
# but a relative path to the build directory (builds/espressif/esp-idf instead of ~/builds/espressif/esp-idf.
# GitLab sets the project dir to this template `<builds_dir>/<namespace>/<project_name>`
IDF_PATH: "/Users/espressif/builds/espressif/esp-idf"
script:
- run_cmd python tools/ci/ci_build_apps.py components examples tools/test_apps -v
--target linux
--pytest-apps
-m \"host_test and macos_shell\"
-m \"host_test and macos\"
--collect-app-info "list_job_${CI_JOB_NAME_SLUG}.txt"
--modified-components ${MR_MODIFIED_COMPONENTS}
--modified-files ${MR_MODIFIED_FILES}
- python tools/ci/get_known_failure_cases_file.py
- run_cmd pytest
--target linux
-m \"host_test and macos_shell\"
-m \"host_test and macos\"
--junitxml=XUNIT_RESULT.xml
--ignore-result-files ${KNOWN_FAILURE_CASES_FILE_NAME}
--app-info-filepattern \"list_job_*.txt\"
+15 -7
View File
@@ -1,11 +1,15 @@
generate_failed_jobs_report:
.post_deploy_template:
stage: post_deploy
tags: [build, shiny]
image: $ESP_ENV_IMAGE
generate_failed_jobs_report:
extends:
- .post_deploy_template
tags: [build, shiny]
when: always
dependencies: [] # Do not download artifacts from the previous stages
artifacts:
expire_in: 1 week
expire_in: 2 week
when: always
paths:
- job_report.html
@@ -13,12 +17,16 @@ generate_failed_jobs_report:
- python tools/ci/dynamic_pipelines/scripts/generate_report.py --report-type job
sync_support_status:
stage: post_deploy
extends:
- .rules:sync_support_status
- .post_deploy_template
- .rules:master:push
tags: [ brew, github_sync ]
needs:
- push_to_github
image: $ESP_ENV_IMAGE
tags: [ brew, github_sync ]
cache: []
before_script: []
script:
- curl --fail --request POST --form token="$IDF_STATUS_TRIG_TOKEN" --form ref="$IDF_STATUS_BRANCH" --form "variables[UPLOAD_TO_S3]=true" "$IDF_STATUS_TRIG_URL"
environment:
name: sync_support_status_production
deployment_tier: production
+1 -1
View File
@@ -10,7 +10,7 @@ check_version:
# esp_idf_version.h in a branch before tagging the next version.
extends:
- .pre_check_template
- .rules:protected
- .rules:protected:check
tags: [ brew, github_sync ]
variables:
# need a full clone to get the latest tag
+31 -45
View File
@@ -56,6 +56,9 @@
- "tools/ci/ci_build_apps.py"
- "tools/test_build_system/**/*"
.patterns-build_system_win: &patterns-build_system_win
- "tools/test_build_system/**/*"
.patterns-build_macos: &patterns-build_macos
- "tools/ci/test_configure_ci_environment.sh"
@@ -167,22 +170,19 @@
##############
# if anchors #
##############
.if-ref-master: &if-ref-master
if: '$CI_COMMIT_REF_NAME == "master"'
.if-master-push: &if-master-push
if: '$CI_COMMIT_REF_NAME == "master" && $CI_PIPELINE_SOURCE == "push"'
.if-ref-master-no_label: &if-ref-master-no_label
if: '$CI_COMMIT_REF_NAME == "master" && $BOT_TRIGGER_WITH_LABEL == null'
.if-tag-release: &if-tag-release
.if-release-tag: &if-release-tag
if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/'
.if-protected: &if-protected
.if-protected-check: &if-protected-check
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) || $CI_COMMIT_TAG =~ /^qa-test/'
.if-protected-no_label: &if-protected-no_label
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && $BOT_TRIGGER_WITH_LABEL == null'
.if-protected-deploy: &if-protected-deploy
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/ || $CI_COMMIT_TAG =~ /^v\d+\.\d+(\.\d+)?($|-)/) && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "api")'
.if-protected-ref-push: &if-protected-ref-push
.if-protected-branch-push: &if-protected-branch-push
# rules:changes always evaluates to true for new branch pipelines or when there is no Git push event
if: '($CI_COMMIT_REF_NAME == "master" || $CI_COMMIT_BRANCH =~ /^release\/v/) && $CI_PIPELINE_SOURCE == "push"'
@@ -192,9 +192,6 @@
.if-dev-push: &if-dev-push
if: '$CI_COMMIT_REF_NAME != "master" && $CI_COMMIT_BRANCH !~ /^release\/v/ && $CI_COMMIT_TAG !~ /^v\d+\.\d+(\.\d+)?($|-)/ && $CI_COMMIT_TAG !~ /^qa-test/ && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
.if-schedule: &if-schedule
if: '$CI_PIPELINE_SOURCE == "schedule"'
.if-schedule-nightly: &if-schedule-nightly
if: '$CI_PIPELINE_SOURCE == "schedule" && $INCLUDE_NIGHTLY_RUN == "1"'
@@ -214,51 +211,41 @@
# Rules #
#########
### Branches ###
.rules:protected:
.rules:protected:check:
rules:
- <<: *if-protected
- <<: *if-protected-check
.rules:push_to_github:
.rules:protected:deploy:
rules:
- <<: *if-qa-test-tag
when: never
- <<: *if-protected-no_label
- <<: *if-protected-deploy
# Not uploading on release branches
.rules:sync_support_status:
.rules:master:push:
rules:
- <<: *if-ref-master-no_label
.rules:protected-no_label-always:
rules:
- <<: *if-qa-test-tag
when: never
- <<: *if-protected-no_label
when: always
- <<: *if-master-push
.rules:tag:release:
rules:
- <<: *if-tag-release
- <<: *if-release-tag
.rules:dev-push:
rules:
- <<: *if-dev-push
# Do not upload caches on dev branches by default
.rules:upload-python-cache:
rules:
- <<: *if-tag-release
- <<: *if-release-tag
- <<: *if-schedule-nightly
- <<: *if-protected-ref-push
- <<: *if-protected-branch-push
changes: *patterns-python-cache
- <<: *if-label-upload_cache
when: manual
.rules:upload-submodule-cache:
rules:
# Needn't upload submodule cache in schedule pipeline
- <<: *if-tag-release
- <<: *if-protected-ref-push
- <<: *if-release-tag
- <<: *if-protected-branch-push
changes: *patterns-submodule
- <<: *if-label-upload_cache
when: manual
@@ -266,11 +253,10 @@
### Patterns ###
.rules:patterns:clang_tidy:
rules:
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-dev-push
changes: *patterns-c-files
#.rules:patterns:static-code-analysis-preview:
# rules:
# - <<: *if-dev-push
@@ -282,7 +268,7 @@
.rules:patterns:idf-pytest-plugin:
rules:
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-dev-push
changes: *patterns-idf-pytest-plugin
@@ -326,7 +312,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-dev-push
changes: *patterns-build_components
@@ -339,7 +325,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-dev-push
changes: *patterns-build_check
@@ -354,7 +340,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-label-docker
- <<: *if-dev-push
@@ -370,7 +356,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-label-macos
- <<: *if-label-macos_test
@@ -385,7 +371,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build
- <<: *if-dev-push
changes: *patterns-build_components
@@ -409,13 +395,13 @@
- <<: *if-schedule-test-build-system-windows
- <<: *if-label-windows
- <<: *if-dev-push
changes: *patterns-build_system
changes: *patterns-build_system_win
.rules:test:host_test:
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build-only
when: never
- <<: *if-label-host_test
@@ -426,7 +412,7 @@
rules:
- <<: *if-revert-branch
when: never
- <<: *if-protected
- <<: *if-protected-check
- <<: *if-label-build-only
when: never
- <<: *if-label-submodule
+1 -1
View File
@@ -85,7 +85,7 @@ clang_tidy_check:
#code_quality_report:
# extends:
# - .sonar_scan_template
# - .rules:protected
# - .rules:protected:check
# allow_failure: true # it's using exit code to indicate the code analysis result,
# # we don't want to block ci when critical issues founded
# script:
+5 -2
View File
@@ -18,9 +18,12 @@
after_script: []
test_cli_installer_win:
rules:
- when: never
extends:
- .host_test_win_template
- .rules:labels:windows_pytest_build_system
allow_failure: true
artifacts:
when: on_failure
paths:
@@ -30,10 +33,10 @@ test_cli_installer_win:
variables:
IDF_PATH: "$CI_PROJECT_DIR"
timeout: 3h
allow_failure: true
script:
# Tools must be downloaded for testing
- python ${IDF_PATH}\tools\idf_tools.py download required qemu-riscv32 qemu-xtensa cmake
# cmake@version that is supported
- python ${IDF_PATH}\tools\idf_tools.py download required qemu-riscv32 qemu-xtensa cmake cmake@3.16.3
- cd ${IDF_PATH}\tools\test_idf_tools
- python -m pip install jsonschema
- python .\test_idf_tools.py
+1 -2
View File
@@ -70,7 +70,6 @@ repos:
rev: v2.3.0
hooks:
- id: codespell
exclude: ^docs/sphinx-known-warnings\.txt$
- repo: local
hooks:
- id: check-executables
@@ -213,7 +212,7 @@ repos:
- id: check-copyright
args: ['--ignore', 'tools/ci/check_copyright_ignore.txt', '--config', 'tools/ci/check_copyright_config.yaml']
- repo: https://github.com/espressif/conventional-precommit-linter
rev: v1.7.0
rev: v1.10.0
hooks:
- id: conventional-precommit-linter
stages: [commit-msg]
+2 -2
View File
@@ -8,9 +8,9 @@ This document describes the compatibility between ESP-IDF releases and Espressif
NOTE: This document on release branches may be out-of-date. Check the [Compatibility file on master](https://github.com/espressif/esp-idf/blob/master/COMPATIBILITY.md) for the most accurate information.
See [Compatibility Advisory for Chip Revision Numbering Scheme](https://www.espressif.com.cn/sites/default/files/advisory_downloads/AR2022-005%20Compatibility%20Advisory%20for%20Chip%20Revision%20Numbering%20%20Scheme.pdf) on the versioning of Espressif SoC revisions.
See [Compatibility Advisory for Chip Revision Numbering Scheme](https://www.espressif.com/sites/default/files/advisory_downloads/AR2022-005%20Compatibility%20Advisory%20for%20Chip%20Revision%20Numbering%20%20Scheme.pdf) on the versioning of Espressif SoC revisions.
You can run `esptool chip_id` to detect the series and revision of an SoC. See [SoC Errata](https://www.espressif.com.cn/en/support/documents/technical-documents?keys=errata) for more on how to distinguish between chip revisions, and the improvements provided by chip revisions. And run `idf.py --version` to know the version of current ESP-IDF.
You can run `esptool chip_id` to detect the series and revision of an SoC. See [SoC Errata](https://www.espressif.com/en/support/documents/technical-documents?keys=errata) for more on how to distinguish between chip revisions, and the improvements provided by chip revisions. And run `idf.py --version` to know the version of current ESP-IDF.
## ESP-IDF Support for Different Chip Revisions
+7 -5
View File
@@ -118,8 +118,6 @@ mainmenu "Espressif IoT Development Framework Configuration"
default "y" if IDF_TARGET="esp32c5"
select FREERTOS_UNICORE
select IDF_TARGET_ARCH_RISCV
# TODO: [ESPTOOL-1044] remove when stub supported
select IDF_ENV_BRINGUP
config IDF_TARGET_ESP32P4
bool
@@ -143,13 +141,11 @@ mainmenu "Espressif IoT Development Framework Configuration"
default "y" if IDF_TARGET="esp32h21"
select FREERTOS_UNICORE
select IDF_TARGET_ARCH_RISCV
select IDF_ENV_FPGA
select IDF_ENV_BRINGUP
config IDF_TARGET_ESP32H4
bool
default "y" if IDF_TARGET="esp32h4"
select FREERTOS_UNICORE # TODO: [ESP32H4] IDF-12319, need remove
select IDF_TARGET_ARCH_RISCV
select IDF_ENV_FPGA
select IDF_ENV_BRINGUP
@@ -650,7 +646,7 @@ mainmenu "Espressif IoT Development Framework Configuration"
choice COMPILER_ORPHAN_SECTIONS
prompt "Orphan sections handling"
default COMPILER_ORPHAN_SECTIONS_WARNING
default COMPILER_ORPHAN_SECTIONS_ERROR
depends on !IDF_TARGET_LINUX
help
If the linker finds orphan sections, it attempts to place orphan sections after sections of the same
@@ -658,6 +654,11 @@ mainmenu "Espressif IoT Development Framework Configuration"
That means that orphan sections could placed between sections defined in IDF linker scripts.
This could lead to corruption of the binary image. Configure the linker action here.
config COMPILER_ORPHAN_SECTIONS_ERROR
bool "Fail if orphan sections found"
help
Fails the link step with an error if orphan sections are detected.
config COMPILER_ORPHAN_SECTIONS_WARNING
bool "Place with warning"
help
@@ -707,3 +708,4 @@ mainmenu "Espressif IoT Development Framework Configuration"
- CONFIG_ESP_WIFI_ENABLE_ROAMING_APP
- CONFIG_USB_HOST_EXT_PORT_RESET_ATTEMPTS
- CONFIG_LIBC_PICOLIBC
- CONFIG_GDMA_ENABLE_WEIGHTED_ARBITRATION
+12 -12
View File
@@ -15,18 +15,18 @@ ESP-IDF is the development framework for Espressif SoCs supported on Windows, Li
The following table shows ESP-IDF support of Espressif SoCs where ![alt text][preview] and ![alt text][supported] denote preview status and support, respectively. The preview support is usually limited in time and intended for beta versions of chips. Please use an ESP-IDF release where the desired SoC is already supported.
|Chip | v5.1 | v5.2 | v5.3 | v5.4 | v5.5 | |
|:----------- |:--------------------: | :--------------------: | :--------------------: | :--------------------: | :--------------------: |:------------------------------------------------------------------- |
|ESP32 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S2 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-C3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_S3) |
|ESP32-C2 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32-C2) |
|ESP32-C6 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_C6) |
|ESP32-H2 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_H2) |
|ESP32-P4 | | | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32-P4) |
|ESP32-C5 | | | | |![alt text][preview] |[Announcement](https://www.espressif.com/en/news/ESP32-C5) |
|ESP32-C61 | | | | |![alt text][preview] |[Announcement](https://www.espressif.com/en/products/socs/esp32-c61) |
|Chip | v5.0 | v5.1 | v5.2 | v5.3 | v5.4 | |
|:----------- | :---------------------:| :--------------------: | :--------------------: | :--------------------: | :--------------------: |:------------------------------------------------------------------- |
|ESP32 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S2 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-C3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_S3) |
|ESP32-C2 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32-C2) |
|ESP32-C6 | | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_C6) |
|ESP32-H2 | | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32_H2) |
|ESP32-P4 | | | | ![alt text][supported] | ![alt text][supported] |[Announcement](https://www.espressif.com/en/news/ESP32-P4) |
|ESP32-C5 | | | | | ![alt text][preview] |[Announcement](https://www.espressif.com/en/news/ESP32-C5) |
|ESP32-C61 | | | | | ![alt text][preview] |[Announcement](https://www.espressif.com/en/products/socs/esp32-c61) |
[supported]: https://img.shields.io/badge/-supported-green "supported"
[preview]: https://img.shields.io/badge/-preview-orange "preview"
+12 -13
View File
@@ -15,19 +15,18 @@ ESP-IDF 是乐鑫官方推出的物联网开发框架,支持 Windows、Linux
下表总结了乐鑫芯片在 ESP-IDF 各版本中的支持状态,其中 ![alt text][supported] 代表已支持,![alt text][preview] 代表目前处于预览支持状态。预览支持状态通常有时间限制,而且仅适用于测试版芯片。请确保使用与芯片相匹配的 ESP-IDF 版本。
芯片 | v5.1 | v5.2 | v5.3 | v5.4 | v5.5 | |
|:----------- | :--------------------: | :--------------------: | :--------------------: | :--------------------: | :--------------------: |:------------------------------------------------------------------------ |
|ESP32 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | |
|ESP32-S2 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-C3 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S3 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_S3) |
|ESP32-C2 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-C2) |
|ESP32-C6 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_C6) |
|ESP32-H2 |![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_H2) |
|ESP32-P4 | | | ![alt text][supported] | ![alt text][supported] |![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-P4) |
|ESP32-C5 | | | | |![alt text][preview] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-C5) |
|ESP32-C61 | | | | |![alt text][preview] | [芯片发布公告](https://www.espressif.com/zh-hans/products/socs/esp32-c61) |
|芯片 | v5.0 | v5.1 | v5.2 | v5.3 | v5.4 | |
|:----------- | :---------------------:| :--------------------: | :--------------------: | :--------------------: | :--------------------: | :------------------------------------------------------------------------ |
|ESP32 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S2 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-C3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | |
|ESP32-S3 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_S3) |
|ESP32-C2 | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-C2) |
|ESP32-C6 | | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_C6) |
|ESP32-H2 | | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | ![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32_H2) |
|ESP32-P4 | | | | ![alt text][supported] | ![alt text][supported] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-P4) |
|ESP32-C5 | | | | | ![alt text][preview] | [芯片发布公告](https://www.espressif.com/zh-hans/news/ESP32-C5) |
|ESP32-C61 | | | | | ![alt text][preview] | [芯片发布公告](https://www.espressif.com/zh-hans/products/socs/esp32-c61) |
[supported]: https://img.shields.io/badge/-%E6%94%AF%E6%8C%81-green "supported"
[preview]: https://img.shields.io/badge/-%E9%A2%84%E8%A7%88-orange "preview"
@@ -92,7 +92,7 @@ static esp_err_t esp_apptrace_membufs_swap(esp_apptrace_membufs_proto_data_t *pr
// switch to new block
proto->state.in_block++;
proto->hw->swap(new_block_num);
proto->hw->swap(new_block_num, proto->state.markers[prev_block_num]);
// handle data from host
esp_hostdata_hdr_t *hdr = (esp_hostdata_hdr_t *)proto->blocks[new_block_num].start;
+2 -2
View File
@@ -50,7 +50,7 @@ static uint8_t *esp_apptrace_riscv_down_buffer_get(esp_apptrace_riscv_data_t *hw
static esp_err_t esp_apptrace_riscv_down_buffer_put(esp_apptrace_riscv_data_t *hw_data, uint8_t *ptr, esp_apptrace_tmo_t *tmo);
static bool esp_apptrace_riscv_host_is_connected(esp_apptrace_riscv_data_t *hw_data);
static esp_err_t esp_apptrace_riscv_buffer_swap_start(uint32_t curr_block_id);
static esp_err_t esp_apptrace_riscv_buffer_swap(uint32_t new_block_id);
static esp_err_t esp_apptrace_riscv_buffer_swap(uint32_t new_block_id, uint32_t prev_block_len);
static esp_err_t esp_apptrace_riscv_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
static bool esp_apptrace_riscv_host_data_pending(void);
@@ -353,7 +353,7 @@ static esp_err_t esp_apptrace_riscv_buffer_swap_end(uint32_t new_block_id, uint3
return ESP_OK;
}
static esp_err_t esp_apptrace_riscv_buffer_swap(uint32_t new_block_id)
static esp_err_t esp_apptrace_riscv_buffer_swap(uint32_t new_block_id, uint32_t prev_block_len)
{
/* do nothing */
return ESP_OK;
+9 -9
View File
@@ -208,7 +208,7 @@ static uint8_t *esp_apptrace_trax_down_buffer_get(esp_apptrace_trax_data_t *hw_d
static esp_err_t esp_apptrace_trax_down_buffer_put(esp_apptrace_trax_data_t *hw_data, uint8_t *ptr, esp_apptrace_tmo_t *tmo);
static bool esp_apptrace_trax_host_is_connected(esp_apptrace_trax_data_t *hw_data);
static esp_err_t esp_apptrace_trax_buffer_swap_start(uint32_t curr_block_id);
static esp_err_t esp_apptrace_trax_buffer_swap(uint32_t new_block_id);
static esp_err_t esp_apptrace_trax_buffer_swap(uint32_t new_block_id, uint32_t prev_block_len);
static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32_t prev_block_len);
static bool esp_apptrace_trax_host_data_pending(void);
@@ -526,21 +526,21 @@ static esp_err_t esp_apptrace_trax_buffer_swap_end(uint32_t new_block_id, uint32
uint32_t ctrl_reg = eri_read(ESP_APPTRACE_TRAX_CTRL_REG);
uint32_t host_connected = ESP_APPTRACE_TRAX_HOST_CONNECT & ctrl_reg;
/* calculate CRC16 of the already switched block */
if (prev_block_len > 0) {
const uint8_t *prev_block_start = s_trax_blocks[!((new_block_id % 2))];
uint16_t crc16 = esp_rom_crc16_le(0, prev_block_start, prev_block_len);
eri_write(ESP_APPTRACE_TRAX_CRC16_REG, crc16 | ESP_APPTRACE_CRC_INDICATOR);
ESP_APPTRACE_LOGD("CRC16:%x %d @%x", crc16, prev_block_len, prev_block_start);
}
eri_write(ESP_APPTRACE_TRAX_CTRL_REG, ESP_APPTRACE_TRAX_BLOCK_ID(new_block_id) |
host_connected | ESP_APPTRACE_TRAX_BLOCK_LEN(prev_block_len));
esp_apptrace_trax_buffer_swap_unlock();
return ESP_OK;
}
static esp_err_t esp_apptrace_trax_buffer_swap(uint32_t new_block_id)
static esp_err_t esp_apptrace_trax_buffer_swap(uint32_t new_block_id, uint32_t prev_block_len)
{
/* Before switching to the new block, calculate CRC16 of the current block */
if (prev_block_len > 0) {
const uint8_t *prev_block_start = s_trax_blocks[!((new_block_id % 2))];
uint16_t crc16 = esp_rom_crc16_le(0, prev_block_start, prev_block_len);
eri_write(ESP_APPTRACE_TRAX_CRC16_REG, crc16 | ESP_APPTRACE_CRC_INDICATOR);
ESP_APPTRACE_LOGD("CRC16:%x %d @%x", crc16, prev_block_len, prev_block_start);
}
esp_apptrace_trax_select_memory_block(new_block_id);
return ESP_OK;
}
@@ -29,7 +29,7 @@ typedef struct {
typedef struct {
esp_err_t (*swap_start)(uint32_t curr_block_id);
esp_err_t (*swap)(uint32_t new_block_id);
esp_err_t (*swap)(uint32_t new_block_id, uint32_t prev_block_len);
esp_err_t (*swap_end)(uint32_t new_block_id, uint32_t prev_block_len);
bool (*host_data_pending)(void);
} esp_apptrace_membufs_proto_hw_t;
+105 -29
View File
@@ -33,7 +33,7 @@
#include "esp_flash.h"
#include "esp_flash_internal.h"
#define SUB_TYPE_ID(i) (i & 0x0F)
#define OTA_SLOT(i) (i & 0x0F)
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
/* Partial_data is word aligned so no reallocation is necessary for encrypted flash write */
@@ -539,6 +539,69 @@ static esp_err_t rewrite_ota_seq(esp_ota_select_entry_t *two_otadata, uint32_t s
}
}
/**
* @brief Calculate the next OTA sequence number that will boot the given OTA slot.
*
* Based on the ESP-IDF OTA boot scheme, the system selects the OTA slot to boot by:
* boot_slot = (seq - 1) % ota_app_count
*
* This function determines the required seq value that would cause the given ota_slot_idx
* to be selected on next boot.
*
* @param current_seq Current active OTA sequence number
* @param ota_slot_idx Target OTA slot index (0-based)
* @param ota_app_count Total number of OTA slots
*
* @return New sequence number that will result in booting ota_slot_idx
*/
static uint32_t compute_ota_seq_for_target_slot(uint32_t current_seq, uint32_t ota_slot_idx, uint8_t ota_app_count)
{
if (ota_app_count == 0) {
return 0;
}
/* ESP-IDF stores OTA boot information in the OTA data partition, which consists of two sectors.
* Each sector holds an esp_ota_select_entry_t structure: otadata[0] and otadata[1].
* These structures record the OTA sequence number (ota_seq) used to determine the current boot partition.
*
* Boot selection logic:
* - If both otadata[0].ota_seq and otadata[1].ota_seq are 0xFFFFFFFF (invalid), it is the initial state:
* → Boot the factory app, if it exists.
* → Otherwise, fall back to booting ota[0].
*
* - If both otadata entries have valid sequence numbers and CRCs:
* → Choose the higher sequence number (max_seq).
* → Determine the OTA partition for boot (or running partition) using:
* running_ota_slot = (max_seq - 1) % ota_app_count
* where ota_app_count is the total number of OTA app partitions.
*
* Example:
* otadata[0].ota_seq = 4
* otadata[1].ota_seq = 5
* ota_app_count = 8 (available OTA slots: ota_0 to ota_7)
* → max_seq = 5
* → running slot = (5 - 1) % 8 = 4
* → So ota_4 is currently running
*
* If you want to switch to boot a different OTA slot (e.g., ota_7):
* → You need to compute a new sequence number such that:
* (new_seq - 1) % ota_app_count == 7
* while ensuring new_seq > current_seq.
*
* General formula:
* x = current OTA slot ID
* ota_slot_idx = desired OTA slot ID
* seq = current ota_seq
*
* To find the next ota_seq that will boot ota_y, use:
* new_seq = ((ota_slot_idx + 1) % ota_app_count) + ota_app_count * i;
* // where i is the smallest non-negative integer such that new_seq > seq
*/
uint32_t i = 0;
uint32_t base = (ota_slot_idx + 1) % ota_app_count;
while (current_seq > (base + i * ota_app_count)) { i++; };
return base + i * ota_app_count;
}
uint8_t esp_ota_get_app_partition_count(void)
{
uint16_t ota_app_count = 0;
@@ -549,6 +612,30 @@ uint8_t esp_ota_get_app_partition_count(void)
return ota_app_count;
}
/**
* @brief Update the OTA data partition to set the given OTA app subtype as the next boot target.
*
* ESP-IDF uses the OTA data partition to track which OTA app should boot.
* This partition contains two entries (otadata[0] and otadata[1]), each storing an esp_ota_select_entry_t struct,
* which includes the OTA sequence number (ota_seq).
*
* On boot, the chip determines the current running OTA slot using:
* current_slot = (max(ota_seq) - 1) % ota_app_count
*
* This function updates the OTA data to switch the next boot to the partition with the given subtype.
*
* Behavior:
* - If the currently selected OTA slot already matches the requested subtype,
* only the state field is updated (e.g., to mark the app as newly downloaded).
* - Otherwise, it calculates the next valid ota_seq that will cause the bootloader to select
* the requested OTA slot on reboot, and writes it to the inactive OTA data sector.
*
* @param subtype The OTA partition subtype (e.g., ESP_PARTITION_SUBTYPE_APP_OTA_0, ..._OTA_1, ...)
* @return
* - ESP_OK if update was successful
* - ESP_ERR_NOT_FOUND if OTA data partition not found
* - ESP_ERR_INVALID_ARG if subtype is out of range
*/
static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
{
esp_ota_select_entry_t otadata[2];
@@ -558,42 +645,31 @@ static esp_err_t esp_rewrite_ota_data(esp_partition_subtype_t subtype)
}
uint8_t ota_app_count = esp_ota_get_app_partition_count();
if (SUB_TYPE_ID(subtype) >= ota_app_count) {
if (OTA_SLOT(subtype) >= ota_app_count) {
return ESP_ERR_INVALID_ARG;
}
//esp32_idf use two sector for store information about which partition is running
//it defined the two sector as ota data partition,two structure esp_ota_select_entry_t is saved in the two sector
//named data in first sector as otadata[0], second sector data as otadata[1]
//e.g.
//if otadata[0].ota_seq == otadata[1].ota_seq == 0xFFFFFFFF,means ota info partition is in init status
//so it will boot factory application(if there is),if there's no factory application,it will boot ota[0] application
//if otadata[0].ota_seq != 0 and otadata[1].ota_seq != 0,it will choose a max seq ,and get value of max_seq%max_ota_app_number
//and boot a subtype (mask 0x0F) value is (max_seq - 1)%max_ota_app_number,so if want switch to run ota[x],can use next formulas.
//for example, if otadata[0].ota_seq = 4, otadata[1].ota_seq = 5, and there are 8 ota application,
//current running is (5-1)%8 = 4,running ota[4],so if we want to switch to run ota[7],
//we should add otadata[0].ota_seq (is 4) to 4 ,(8-1)%8=7,then it will boot ota[7]
//if A=(B - C)%D
//then B=(A + C)%D + D*n ,n= (0,1,2...)
//so current ota app sub type id is x , dest bin subtype is y,total ota app count is n
//seq will add (x + n*1 + 1 - seq)%n
int active_otadata = bootloader_common_get_active_otadata(otadata);
int next_otadata;
uint32_t new_seq;
if (active_otadata != -1) {
uint32_t seq = otadata[active_otadata].ota_seq;
uint32_t i = 0;
while (seq > (SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count) {
i++;
uint32_t ota_slot = (otadata[active_otadata].ota_seq - 1) % ota_app_count;
if (ota_slot == OTA_SLOT(subtype)) {
// ota_data is already valid and points to the correct OTA slot.
// So after reboot the requested partition will be selected for boot.
// Only update the ota_state of the requested partition.
next_otadata = active_otadata;
new_seq = otadata[active_otadata].ota_seq;
} else {
next_otadata = (~active_otadata) & 1; // if 0 -> will be next 1. and if 1 -> will be next 0.
new_seq = compute_ota_seq_for_target_slot(otadata[active_otadata].ota_seq, OTA_SLOT(subtype), ota_app_count);
}
int next_otadata = (~active_otadata)&1; // if 0 -> will be next 1. and if 1 -> will be next 0.
otadata[next_otadata].ota_state = set_new_state_otadata();
return rewrite_ota_seq(otadata, (SUB_TYPE_ID(subtype) + 1) % ota_app_count + i * ota_app_count, next_otadata, otadata_partition);
} else {
/* Both OTA slots are invalid, probably because unformatted... */
int next_otadata = 0;
otadata[next_otadata].ota_state = set_new_state_otadata();
return rewrite_ota_seq(otadata, SUB_TYPE_ID(subtype) + 1, next_otadata, otadata_partition);
next_otadata = 0;
new_seq = OTA_SLOT(subtype) + 1;
}
otadata[next_otadata].ota_state = set_new_state_otadata();
return rewrite_ota_seq(otadata, new_seq, next_otadata, otadata_partition);
}
esp_err_t esp_ota_set_boot_partition(const esp_partition_t *partition)
@@ -7,6 +7,7 @@ components/app_update/test_apps:
- if: CONFIG_NAME == "xip_psram" and SOC_SPIRAM_XIP_SUPPORTED == 1
# S2 doesn't have ROM for flash
- if: CONFIG_NAME == "xip_psram_with_rom_impl" and (SOC_SPIRAM_XIP_SUPPORTED == 1 and IDF_TARGET != "esp32s2")
- if: CONFIG_NAME == "recovery_bootloader" and SOC_RECOVERY_BOOTLOADER_SUPPORTED == 1
disable:
- if: IDF_TARGET in ["esp32h21", "esp32h4"]
temporary: true
@@ -14,3 +15,7 @@ components/app_update/test_apps:
- if: IDF_TARGET == "esp32c61" and CONFIG_NAME == "xip_psram_with_rom_impl"
temporary: true
reason: not supported yet # TODO: [ESP32C61] IDF-12784
disable_test:
- if: CONFIG_NAME == "recovery_bootloader" and SOC_RECOVERY_BOOTLOADER_SUPPORTED == 1 and IDF_TARGET == "esp32c61"
temporary: true
reason: lack of runners # TODO: [ESP32C61] IDF-13165
@@ -1,4 +1,15 @@
idf_component_register(SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES cmock test_utils app_update bootloader_support nvs_flash driver spi_flash esp_psram
WHOLE_ARCHIVE)
idf_component_register(
SRC_DIRS "."
PRIV_INCLUDE_DIRS "."
PRIV_REQUIRES
cmock
test_utils
app_update
bootloader_support
nvs_flash
driver
spi_flash
esp_psram
efuse
WHOLE_ARCHIVE
)
@@ -0,0 +1,87 @@
/*
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
* Tests bootloader update.
*/
#include "unity.h"
#include "esp_log.h"
#include "esp_efuse.h"
#include "esp_flash_internal.h"
#include "esp_rom_sys.h"
#include "utils_update.h"
#include "sdkconfig.h"
#define BOOT_COUNT_NAMESPACE "boot_count"
static __attribute__((unused)) const char *TAG = "btldr_update";
#if CONFIG_BOOTLOADER_RECOVERY_ENABLE
/* @brief Checks and prepares the partition so that the factory app is launched after that.
*/
static void start_test(void)
{
ESP_LOGI(TAG, "boot count 1 - reset");
set_boot_count_in_nvs(1);
erase_ota_data();
ESP_LOGI(TAG, "ota_data erased");
ESP_LOGI(TAG, "Bootloader offset: 0x%x", esp_rom_get_bootloader_offset());
reboot_as_deep_sleep();
}
static void test_flow1(void)
{
uint8_t boot_count = get_boot_count_from_nvs();
boot_count++;
set_boot_count_in_nvs(boot_count);
ESP_LOGI(TAG, "boot count %d", boot_count);
ESP_LOGI(TAG, "Bootloader offset: 0x%x", esp_rom_get_bootloader_offset());
const esp_partition_t *primary_bootloader;
TEST_ESP_OK(esp_partition_register_external(NULL, ESP_PRIMARY_BOOTLOADER_OFFSET, ESP_BOOTLOADER_SIZE, "PrimaryBTLDR", ESP_PARTITION_TYPE_BOOTLOADER, ESP_PARTITION_SUBTYPE_BOOTLOADER_PRIMARY, &primary_bootloader));
const esp_partition_t *recovery_bootloader;
TEST_ESP_OK(esp_partition_register_external(NULL, CONFIG_BOOTLOADER_RECOVERY_OFFSET, ESP_BOOTLOADER_SIZE, "RecoveryBTLDR", ESP_PARTITION_TYPE_BOOTLOADER, ESP_PARTITION_SUBTYPE_BOOTLOADER_RECOVERY, &recovery_bootloader));
ESP_LOGI(TAG, "Bootloaders are registered");
// Remove write protection for the bootloader
esp_flash_set_dangerous_write_protection(esp_flash_default_chip, false);
switch (boot_count) {
case 2:
TEST_ASSERT_EQUAL_HEX32(ESP_PRIMARY_BOOTLOADER_OFFSET, esp_rom_get_bootloader_offset());
TEST_ESP_OK(esp_partition_erase_range(recovery_bootloader, 0, recovery_bootloader->size));
ESP_LOGI(TAG, "Erase recovery bootloader");
TEST_ESP_OK(esp_efuse_set_recovery_bootloader_offset(CONFIG_BOOTLOADER_RECOVERY_OFFSET));
ESP_LOGI(TAG, "Backup, copy <%s> -> <%s>", primary_bootloader->label, recovery_bootloader->label);
TEST_ESP_OK(esp_partition_copy(recovery_bootloader, 0, primary_bootloader, 0, primary_bootloader->size));
TEST_ESP_OK(esp_partition_erase_range(primary_bootloader, 0, primary_bootloader->size));
ESP_LOGI(TAG, "Erase primary bootloader");
reboot_as_deep_sleep();
break;
case 3:
TEST_ASSERT_EQUAL_HEX32(CONFIG_BOOTLOADER_RECOVERY_OFFSET, esp_rom_get_bootloader_offset());
ESP_LOGI(TAG, "Return to primary bootloader...");
ESP_LOGI(TAG, "Copy <%s> -> <%s>", recovery_bootloader->label, primary_bootloader->label);
TEST_ESP_OK(esp_partition_copy(primary_bootloader, 0, recovery_bootloader, 0, primary_bootloader->size));
TEST_ESP_OK(esp_partition_erase_range(recovery_bootloader, 0, recovery_bootloader->size));
ESP_LOGI(TAG, "Erase recovery bootloader");
break;
default:
TEST_FAIL_MESSAGE("Unexpected stage");
break;
}
}
TEST_CASE_MULTIPLE_STAGES("Recovery bootloader feature", "[recovery_bootloader][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET]", start_test, test_flow1, test_flow1);
#endif // CONFIG_BOOTLOADER_RECOVERY_ENABLE
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -7,314 +7,16 @@
* Tests for switching between partitions: factory, OTAx, test.
*/
#include <esp_types.h>
#include <stdio.h>
#include "string.h"
#include <inttypes.h>
#include "sdkconfig.h"
#include "esp_rom_spiflash.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "freertos/queue.h"
#include "unity.h"
#include "esp_system.h"
#include "bootloader_common.h"
#include "../bootloader_flash/include/bootloader_flash_priv.h"
#include "esp_err.h"
#include "esp_log.h"
#include "esp_ota_ops.h"
#include "esp_partition.h"
#include "esp_flash_partitions.h"
#include "esp_image_format.h"
#include "nvs_flash.h"
#include "driver/gpio.h"
#include "esp_sleep.h"
#include "test_utils.h"
#define BOOT_COUNT_NAMESPACE "boot_count"
#include "unity.h"
#include "utils_update.h"
#include "sdkconfig.h"
static const char *TAG = "ota_test";
static void set_boot_count_in_nvs(uint8_t boot_count)
{
nvs_handle_t boot_count_handle;
esp_err_t err = nvs_open(BOOT_COUNT_NAMESPACE, NVS_READWRITE, &boot_count_handle);
if (err != ESP_OK) {
TEST_ESP_OK(nvs_flash_erase());
TEST_ESP_OK(nvs_flash_init());
TEST_ESP_OK(nvs_open(BOOT_COUNT_NAMESPACE, NVS_READWRITE, &boot_count_handle));
}
TEST_ESP_OK(nvs_set_u8(boot_count_handle, "boot_count", boot_count));
TEST_ESP_OK(nvs_commit(boot_count_handle));
nvs_close(boot_count_handle);
}
static uint8_t get_boot_count_from_nvs(void)
{
nvs_handle_t boot_count_handle;
esp_err_t err = nvs_open(BOOT_COUNT_NAMESPACE, NVS_READONLY, &boot_count_handle);
if (err == ESP_ERR_NVS_NOT_FOUND) {
set_boot_count_in_nvs(0);
}
uint8_t boot_count;
TEST_ESP_OK(nvs_get_u8(boot_count_handle, "boot_count", &boot_count));
nvs_close(boot_count_handle);
return boot_count;
}
/* @brief Copies a current app to next partition using handle.
*
* @param[in] update_handle - Handle of API ota.
* @param[in] cur_app - Current app.
*/
static void copy_app_partition(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
TEST_ESP_OK(esp_partition_mmap(curr_app, 0, curr_app->size, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write(update_handle, (const void *)partition_bin, curr_app->size));
esp_partition_munmap(data_map);
ESP_LOGI(TAG, "finish the copy process");
}
/* @brief Copies a current app to next partition using handle.
*
* @param[in] update_handle - Handle of API ota.
* @param[in] cur_app - Current app.
*/
static void copy_app_partition_with_offset(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
uint32_t offset = 0, bytes_to_write = curr_app->size;
uint32_t write_bytes;
while (bytes_to_write > 0) {
write_bytes = (bytes_to_write > (4 * 1024)) ? (4 * 1024) : bytes_to_write;
TEST_ESP_OK(esp_partition_mmap(curr_app, offset, write_bytes, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write_with_offset(update_handle, (const void *)partition_bin, write_bytes, offset));
esp_partition_munmap(data_map);
bytes_to_write -= write_bytes;
offset += write_bytes;
}
ESP_LOGI(TAG, "finish the copy process");
}
/* @brief Get the next partition of OTA for the update.
*
* @return The next partition of OTA(OTA0-15).
*/
static const esp_partition_t * get_next_update_partition(void)
{
const esp_partition_t *update_partition = esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, update_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, update_partition->subtype, update_partition->address);
return update_partition;
}
/* @brief Copies a current app to next partition (OTA0-15) and then configure OTA data for a new boot partition.
*
* @param[in] cur_app_partition - Current app.
* @param[in] next_app_partition - Next app for boot.
*/
static void copy_current_app_to_next_part(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition)
{
esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, next_app_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, next_app_partition->subtype, next_app_partition->address);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(next_app_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition(update_handle, cur_app_partition);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(next_app_partition));
}
/* @brief Copies a current app to next partition (OTA0-15) and then configure OTA data for a new boot partition.
*
* @param[in] cur_app_partition - Current app.
* @param[in] next_app_partition - Next app for boot.
*/
static void copy_current_app_to_next_part_with_offset(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition)
{
esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, next_app_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, next_app_partition->subtype, next_app_partition->address);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(next_app_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition_with_offset(update_handle, cur_app_partition);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(next_app_partition));
}
/* @brief Erase otadata partition
*/
static void erase_ota_data(void)
{
const esp_partition_t *data_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
TEST_ASSERT_NOT_EQUAL(NULL, data_partition);
TEST_ESP_OK(esp_partition_erase_range(data_partition, 0, 2 * data_partition->erase_size));
}
/* @brief Reboots ESP using mode deep sleep. This mode guaranty that RTC_DATA_ATTR variables is not reset.
*/
static void reboot_as_deep_sleep(void)
{
ESP_LOGI(TAG, "reboot as deep sleep");
esp_deep_sleep(20000);
TEST_FAIL_MESSAGE("Should never be reachable except when sleep is rejected, abort");
}
/* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx.
*/
static void copy_current_app_to_next_part_and_reboot(void)
{
const esp_partition_t *cur_app = esp_ota_get_running_partition();
ESP_LOGI(TAG, "copy current app to next part");
copy_current_app_to_next_part(cur_app, get_next_update_partition());
reboot_as_deep_sleep();
}
/* @brief Copies a current app to next partition (OTA0-15) using esp_ota_write_with_offest(), after that ESP is rebooting and run this (the next) OTAx.
*/
static void copy_current_app_to_next_part_with_offset_and_reboot(void)
{
const esp_partition_t *cur_app = esp_ota_get_running_partition();
ESP_LOGI(TAG, "copy current app to next part");
copy_current_app_to_next_part_with_offset(cur_app, get_next_update_partition());
reboot_as_deep_sleep();
}
/* @brief Get running app.
*
* @return The next partition of OTA(OTA0-15).
*/
static const esp_partition_t* get_running_firmware(void)
{
const esp_partition_t *configured = esp_ota_get_boot_partition();
const esp_partition_t *running = esp_ota_get_running_partition();
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08"PRIx32")",
running->type, running->subtype, running->address);
ESP_LOGI(TAG, "Configured partition type %d subtype %d (offset 0x%08"PRIx32")",
configured->type, configured->subtype, configured->address);
TEST_ASSERT_NOT_EQUAL(NULL, configured);
TEST_ASSERT_NOT_EQUAL(NULL, running);
if (running->subtype != ESP_PARTITION_SUBTYPE_APP_TEST) {
TEST_ASSERT_EQUAL_PTR(running, configured);
}
return running;
}
// type of a corrupt ota_data
typedef enum {
CORR_CRC_1_SECTOR_OTA_DATA = (1 << 0), /*!< Corrupt CRC only 1 sector of ota_data */
CORR_CRC_2_SECTOR_OTA_DATA = (1 << 1), /*!< Corrupt CRC only 2 sector of ota_data */
} corrupt_ota_data_t;
/* @brief Get two copies ota_data from otadata partition.
*
* @param[in] otadata_partition - otadata partition.
* @param[out] ota_data_0 - First copy from otadata_partition.
* @param[out] ota_data_1 - Second copy from otadata_partition.
*/
static void get_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data_0, esp_ota_select_entry_t *ota_data_1)
{
uint32_t offset = otadata_partition->address;
uint32_t size = otadata_partition->size;
if (offset != 0) {
const esp_ota_select_entry_t *ota_select_map;
ota_select_map = bootloader_mmap(offset, size);
TEST_ASSERT_NOT_EQUAL(NULL, ota_select_map);
memcpy(ota_data_0, ota_select_map, sizeof(esp_ota_select_entry_t));
memcpy(ota_data_1, (uint8_t *)ota_select_map + otadata_partition->erase_size, sizeof(esp_ota_select_entry_t));
bootloader_munmap(ota_select_map);
}
}
/* @brief Writes a ota_data into required sector of otadata_partition.
*
* @param[in] otadata_partition - Partition information otadata.
* @param[in] ota_data - otadata structure.
* @param[in] sec_id - Sector number 0 or 1.
*/
static void write_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data, int sec_id)
{
esp_partition_write(otadata_partition, otadata_partition->erase_size * sec_id, &ota_data[sec_id], sizeof(esp_ota_select_entry_t));
}
/* @brief Makes a corrupt of ota_data.
* @param[in] err - type error
*/
static void corrupt_ota_data(corrupt_ota_data_t err)
{
esp_ota_select_entry_t ota_data[2];
const esp_partition_t *otadata_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
TEST_ASSERT_NOT_EQUAL(NULL, otadata_partition);
get_ota_data(otadata_partition, &ota_data[0], &ota_data[1]);
if (err & CORR_CRC_1_SECTOR_OTA_DATA) {
ota_data[0].crc = 0;
}
if (err & CORR_CRC_2_SECTOR_OTA_DATA) {
ota_data[1].crc = 0;
}
TEST_ESP_OK(esp_partition_erase_range(otadata_partition, 0, otadata_partition->size));
write_ota_data(otadata_partition, &ota_data[0], 0);
write_ota_data(otadata_partition, &ota_data[1], 1);
}
#if defined(CONFIG_BOOTLOADER_FACTORY_RESET) || defined(CONFIG_BOOTLOADER_APP_TEST)
/* @brief Sets the pin number to output and sets output level as low. After reboot (deep sleep) this pin keep the same level.
*
* The output level of the pad will be force locked and can not be changed.
* Power down or call gpio_hold_dis will disable this function.
*
* @param[in] num_pin - Pin number
*/
static void set_output_pin(uint32_t num_pin)
{
TEST_ESP_OK(gpio_hold_dis(num_pin));
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL << num_pin);
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
TEST_ESP_OK(gpio_config(&io_conf));
TEST_ESP_OK(gpio_set_level(num_pin, 0));
TEST_ESP_OK(gpio_hold_en(num_pin));
}
/* @brief Unset the pin number hold function.
*/
static void reset_output_pin(uint32_t num_pin)
{
TEST_ESP_OK(gpio_hold_dis(num_pin));
TEST_ESP_OK(gpio_reset_pin(num_pin));
}
#endif
static void mark_app_valid(void)
{
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
#endif
}
/* @brief Checks and prepares the partition so that the factory app is launched after that.
*/
@@ -546,20 +248,6 @@ static void test_flow5(void)
TEST_CASE_MULTIPLE_STAGES("Switching between factory, test, factory", "[app_update][timeout=90][reset=SW_CPU_RESET, SW_CPU_RESET, DEEPSLEEP_RESET]", start_test, test_flow5, test_flow5, test_flow5);
#endif
static const esp_partition_t* app_update(void)
{
const esp_partition_t *cur_app = get_running_firmware();
const esp_partition_t* update_partition = esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_NULL(update_partition);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition(update_handle, cur_app);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(update_partition));
return update_partition;
}
static void test_rollback1(void)
{
uint8_t boot_count = get_boot_count_from_nvs();
@@ -930,3 +618,51 @@ static void test_rollback3_1(void)
}
TEST_CASE_MULTIPLE_STAGES("Test rollback. Updated partition invalidated after esp_ota_begin", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback3, test_rollback3, test_rollback3, test_rollback3_1);
static void test_rollback4(void)
{
uint8_t boot_count = get_boot_count_from_nvs();
boot_count++;
set_boot_count_in_nvs(boot_count);
ESP_LOGI(TAG, "boot count %d", boot_count);
const esp_partition_t *cur_app = get_running_firmware();
switch (boot_count) {
case 2:
ESP_LOGI(TAG, "Factory");
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_FACTORY, cur_app->subtype);
app_update();
reboot_as_deep_sleep();
break;
case 3:
ESP_LOGI(TAG, "OTA0");
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_0, cur_app->subtype);
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
app_update();
// Do not reboot and call app_update again.
// This will not change the running partition since we haven't rebooted.
// The esp_rewrite_otadata() will update the otadata for the non-running partition only.
app_update();
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
// The last call to esp_rewrite_otadata should have updated the otadata for the non-running partition only.
// Therefore, calling esp_ota_get_state_partition on the running partition should succeed and not return ESP_ERR_NOT_FOUND
const esp_partition_t* running_partition;
running_partition = esp_ota_get_running_partition();
esp_ota_img_states_t ota_state;
TEST_ESP_OK(esp_ota_get_state_partition(running_partition, &ota_state));
#endif
reboot_as_deep_sleep();
break;
case 4:
ESP_LOGI(TAG, "OTA1");
TEST_ASSERT_EQUAL(ESP_PARTITION_SUBTYPE_APP_OTA_1, cur_app->subtype);
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
break;
default:
erase_ota_data();
TEST_FAIL_MESSAGE("Unexpected stage");
break;
}
}
TEST_CASE_MULTIPLE_STAGES("Test esp_rewrite_otadata. Updated sequence number for non-running partition always", "[app_update][timeout=90][reset=DEEPSLEEP_RESET, DEEPSLEEP_RESET, DEEPSLEEP_RESET, SW_CPU_RESET]", start_test, test_rollback4, test_rollback4, test_rollback4);
@@ -0,0 +1,307 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_rom_spiflash.h"
#include "driver/gpio.h"
#include "nvs_flash.h"
#include "esp_partition.h"
#include "esp_flash_partitions.h"
#include "esp_image_format.h"
#include "../bootloader_flash/include/bootloader_flash_priv.h"
#include "esp_sleep.h"
#include "esp_ota_ops.h"
#include "esp_err.h"
#include "esp_log.h"
#include "test_utils.h"
#include "utils_update.h"
#include "unity.h"
#include "sdkconfig.h"
#define BOOT_COUNT_NAMESPACE "boot_count"
static const char *TAG = "ota_test";
void set_boot_count_in_nvs(uint8_t boot_count)
{
nvs_handle_t boot_count_handle;
esp_err_t err = nvs_open(BOOT_COUNT_NAMESPACE, NVS_READWRITE, &boot_count_handle);
if (err != ESP_OK) {
TEST_ESP_OK(nvs_flash_erase());
TEST_ESP_OK(nvs_flash_init());
TEST_ESP_OK(nvs_open(BOOT_COUNT_NAMESPACE, NVS_READWRITE, &boot_count_handle));
}
TEST_ESP_OK(nvs_set_u8(boot_count_handle, "boot_count", boot_count));
TEST_ESP_OK(nvs_commit(boot_count_handle));
nvs_close(boot_count_handle);
}
uint8_t get_boot_count_from_nvs(void)
{
nvs_handle_t boot_count_handle;
esp_err_t err = nvs_open(BOOT_COUNT_NAMESPACE, NVS_READONLY, &boot_count_handle);
if (err == ESP_ERR_NVS_NOT_FOUND) {
set_boot_count_in_nvs(0);
}
uint8_t boot_count;
TEST_ESP_OK(nvs_get_u8(boot_count_handle, "boot_count", &boot_count));
nvs_close(boot_count_handle);
return boot_count;
}
/* @brief Copies a current app to next partition using handle.
*
* @param[in] update_handle - Handle of API ota.
* @param[in] cur_app - Current app.
*/
void copy_app_partition(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
TEST_ESP_OK(esp_partition_mmap(curr_app, 0, curr_app->size, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write(update_handle, (const void *)partition_bin, curr_app->size));
esp_partition_munmap(data_map);
ESP_LOGI(TAG, "finish the copy process");
}
/* @brief Copies a current app to next partition using handle.
*
* @param[in] update_handle - Handle of API ota.
* @param[in] cur_app - Current app.
*/
void copy_app_partition_with_offset(esp_ota_handle_t update_handle, const esp_partition_t *curr_app)
{
const void *partition_bin = NULL;
esp_partition_mmap_handle_t data_map;
ESP_LOGI(TAG, "start the copy process");
uint32_t offset = 0, bytes_to_write = curr_app->size;
uint32_t write_bytes;
while (bytes_to_write > 0) {
write_bytes = (bytes_to_write > (4 * 1024)) ? (4 * 1024) : bytes_to_write;
TEST_ESP_OK(esp_partition_mmap(curr_app, offset, write_bytes, ESP_PARTITION_MMAP_DATA, &partition_bin, &data_map));
TEST_ESP_OK(esp_ota_write_with_offset(update_handle, (const void *)partition_bin, write_bytes, offset));
esp_partition_munmap(data_map);
bytes_to_write -= write_bytes;
offset += write_bytes;
}
ESP_LOGI(TAG, "finish the copy process");
}
/* @brief Get the next partition of OTA for the update.
*
* @return The next partition of OTA(OTA0-15).
*/
const esp_partition_t * get_next_update_partition(void)
{
const esp_partition_t *update_partition = esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, update_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, update_partition->subtype, update_partition->address);
return update_partition;
}
/* @brief Copies a current app to next partition (OTA0-15) and then configure OTA data for a new boot partition.
*
* @param[in] cur_app_partition - Current app.
* @param[in] next_app_partition - Next app for boot.
*/
void copy_current_app_to_next_part(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition)
{
esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, next_app_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, next_app_partition->subtype, next_app_partition->address);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(next_app_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition(update_handle, cur_app_partition);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(next_app_partition));
}
/* @brief Copies a current app to next partition (OTA0-15) and then configure OTA data for a new boot partition.
*
* @param[in] cur_app_partition - Current app.
* @param[in] next_app_partition - Next app for boot.
*/
void copy_current_app_to_next_part_with_offset(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition)
{
esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_EQUAL(NULL, next_app_partition);
ESP_LOGI(TAG, "Writing to partition subtype %d at offset 0x%"PRIx32, next_app_partition->subtype, next_app_partition->address);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(next_app_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition_with_offset(update_handle, cur_app_partition);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(next_app_partition));
}
/* @brief Erase otadata partition
*/
void erase_ota_data(void)
{
const esp_partition_t *data_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
TEST_ASSERT_NOT_EQUAL(NULL, data_partition);
TEST_ESP_OK(esp_partition_erase_range(data_partition, 0, 2 * data_partition->erase_size));
}
/* @brief Reboots ESP using mode deep sleep. This mode guaranty that RTC_DATA_ATTR variables is not reset.
*/
void reboot_as_deep_sleep(void)
{
ESP_LOGI(TAG, "reboot as deep sleep");
esp_deep_sleep(20000);
TEST_FAIL_MESSAGE("Should never be reachable except when sleep is rejected, abort");
}
/* @brief Copies a current app to next partition (OTA0-15), after that ESP is rebooting and run this (the next) OTAx.
*/
void copy_current_app_to_next_part_and_reboot(void)
{
const esp_partition_t *cur_app = esp_ota_get_running_partition();
ESP_LOGI(TAG, "copy current app to next part");
copy_current_app_to_next_part(cur_app, get_next_update_partition());
reboot_as_deep_sleep();
}
/* @brief Copies a current app to next partition (OTA0-15) using esp_ota_write_with_offest(), after that ESP is rebooting and run this (the next) OTAx.
*/
void copy_current_app_to_next_part_with_offset_and_reboot(void)
{
const esp_partition_t *cur_app = esp_ota_get_running_partition();
ESP_LOGI(TAG, "copy current app to next part");
copy_current_app_to_next_part_with_offset(cur_app, get_next_update_partition());
reboot_as_deep_sleep();
}
/* @brief Get running app.
*
* @return The next partition of OTA(OTA0-15).
*/
const esp_partition_t* get_running_firmware(void)
{
const esp_partition_t *configured = esp_ota_get_boot_partition();
const esp_partition_t *running = esp_ota_get_running_partition();
// If a reboot hasn't occurred after app_update(), the configured and running partitions may differ
ESP_LOGI(TAG, "Running partition type %d subtype %d (offset 0x%08"PRIx32")",
running->type, running->subtype, running->address);
ESP_LOGI(TAG, "Configured partition type %d subtype %d (offset 0x%08"PRIx32")",
configured->type, configured->subtype, configured->address);
TEST_ASSERT_NOT_EQUAL(NULL, configured);
TEST_ASSERT_NOT_EQUAL(NULL, running);
return running;
}
/* @brief Get two copies ota_data from otadata partition.
*
* @param[in] otadata_partition - otadata partition.
* @param[out] ota_data_0 - First copy from otadata_partition.
* @param[out] ota_data_1 - Second copy from otadata_partition.
*/
void get_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data_0, esp_ota_select_entry_t *ota_data_1)
{
uint32_t offset = otadata_partition->address;
uint32_t size = otadata_partition->size;
if (offset != 0) {
const esp_ota_select_entry_t *ota_select_map;
ota_select_map = bootloader_mmap(offset, size);
TEST_ASSERT_NOT_EQUAL(NULL, ota_select_map);
memcpy(ota_data_0, ota_select_map, sizeof(esp_ota_select_entry_t));
memcpy(ota_data_1, (uint8_t *)ota_select_map + otadata_partition->erase_size, sizeof(esp_ota_select_entry_t));
bootloader_munmap(ota_select_map);
}
}
/* @brief Writes a ota_data into required sector of otadata_partition.
*
* @param[in] otadata_partition - Partition information otadata.
* @param[in] ota_data - otadata structure.
* @param[in] sec_id - Sector number 0 or 1.
*/
void write_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data, int sec_id)
{
esp_partition_write(otadata_partition, otadata_partition->erase_size * sec_id, &ota_data[sec_id], sizeof(esp_ota_select_entry_t));
}
/* @brief Makes a corrupt of ota_data.
* @param[in] err - type error
*/
void corrupt_ota_data(corrupt_ota_data_t err)
{
esp_ota_select_entry_t ota_data[2];
const esp_partition_t *otadata_partition = esp_partition_find_first(ESP_PARTITION_TYPE_DATA, ESP_PARTITION_SUBTYPE_DATA_OTA, NULL);
TEST_ASSERT_NOT_EQUAL(NULL, otadata_partition);
get_ota_data(otadata_partition, &ota_data[0], &ota_data[1]);
if (err & CORR_CRC_1_SECTOR_OTA_DATA) {
ota_data[0].crc = 0;
}
if (err & CORR_CRC_2_SECTOR_OTA_DATA) {
ota_data[1].crc = 0;
}
TEST_ESP_OK(esp_partition_erase_range(otadata_partition, 0, otadata_partition->size));
write_ota_data(otadata_partition, &ota_data[0], 0);
write_ota_data(otadata_partition, &ota_data[1], 1);
}
#if defined(CONFIG_BOOTLOADER_FACTORY_RESET) || defined(CONFIG_BOOTLOADER_APP_TEST)
/* @brief Sets the pin number to output and sets output level as low. After reboot (deep sleep) this pin keep the same level.
*
* The output level of the pad will be force locked and can not be changed.
* Power down or call gpio_hold_dis will disable this function.
*
* @param[in] num_pin - Pin number
*/
void set_output_pin(uint32_t num_pin)
{
TEST_ESP_OK(gpio_hold_dis(num_pin));
gpio_config_t io_conf;
io_conf.intr_type = GPIO_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = (1ULL << num_pin);
io_conf.pull_down_en = 0;
io_conf.pull_up_en = 0;
TEST_ESP_OK(gpio_config(&io_conf));
TEST_ESP_OK(gpio_set_level(num_pin, 0));
TEST_ESP_OK(gpio_hold_en(num_pin));
}
/* @brief Unset the pin number hold function.
*/
void reset_output_pin(uint32_t num_pin)
{
TEST_ESP_OK(gpio_hold_dis(num_pin));
TEST_ESP_OK(gpio_reset_pin(num_pin));
}
#endif
void mark_app_valid(void)
{
#ifdef CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE
TEST_ESP_OK(esp_ota_mark_app_valid_cancel_rollback());
#endif
}
const esp_partition_t* app_update(void)
{
const esp_partition_t *cur_app = get_running_firmware();
const esp_partition_t* update_partition = esp_ota_get_next_update_partition(NULL);
TEST_ASSERT_NOT_NULL(update_partition);
esp_ota_handle_t update_handle = 0;
TEST_ESP_OK(esp_ota_begin(update_partition, OTA_SIZE_UNKNOWN, &update_handle));
copy_app_partition(update_handle, cur_app);
TEST_ESP_OK(esp_ota_end(update_handle));
TEST_ESP_OK(esp_ota_set_boot_partition(update_partition));
return update_partition;
}
@@ -0,0 +1,148 @@
/*
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "esp_ota_ops.h"
#include "esp_partition.h"
#ifdef __cplusplus
extern "C"
{
#endif
/**
* @brief Enumeration for specifying which OTA data sectors' CRCs to corrupt.
*/
typedef enum {
CORR_CRC_1_SECTOR_OTA_DATA = (1 << 0), /*!< Corrupt CRC only 1 sector of ota_data */
CORR_CRC_2_SECTOR_OTA_DATA = (1 << 1), /*!< Corrupt CRC only 2 sector of ota_data */
} corrupt_ota_data_t;
/**
* @brief Set boot count value in NVS.
* @param boot_count Value to set.
*/
void set_boot_count_in_nvs(uint8_t boot_count);
/**
* @brief Get boot count value from NVS.
* @return Boot count value.
*/
uint8_t get_boot_count_from_nvs(void);
/**
* @brief Copy current app to next partition using OTA handle.
* @param update_handle OTA update handle.
* @param curr_app Current app partition.
*/
void copy_app_partition(esp_ota_handle_t update_handle, const esp_partition_t *curr_app);
/**
* @brief Copy current app to next partition using OTA handle with offset.
* @param update_handle OTA update handle.
* @param curr_app Current app partition.
*/
void copy_app_partition_with_offset(esp_ota_handle_t update_handle, const esp_partition_t *curr_app);
/**
* @brief Get the next OTA update partition.
* @return Pointer to next OTA partition.
*/
const esp_partition_t * get_next_update_partition(void);
/**
* @brief Copy current app to next partition and set boot partition.
* @param cur_app_partition Current app partition.
* @param next_app_partition Next app partition.
*/
void copy_current_app_to_next_part(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition);
/**
* @brief Copy current app to next partition with offset and set boot partition.
* @param cur_app_partition Current app partition.
* @param next_app_partition Next app partition.
*/
void copy_current_app_to_next_part_with_offset(const esp_partition_t *cur_app_partition, const esp_partition_t *next_app_partition);
/**
* @brief Erase OTA data partition.
*/
void erase_ota_data(void);
/**
* @brief Reboot ESP using deep sleep mode.
*/
void reboot_as_deep_sleep(void);
/**
* @brief Copy current app to next partition and reboot.
*/
void copy_current_app_to_next_part_and_reboot(void);
/**
* @brief Copy current app to next partition with offset and reboot.
*/
void copy_current_app_to_next_part_with_offset_and_reboot(void);
/**
* @brief Get running firmware partition.
* @return Pointer to running firmware partition.
*/
const esp_partition_t* get_running_firmware(void);
/**
* @brief Get two OTA data copies from OTA data partition.
* @param otadata_partition OTA data partition.
* @param ota_data_0 First OTA data copy.
* @param ota_data_1 Second OTA data copy.
*/
void get_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data_0, esp_ota_select_entry_t *ota_data_1);
/**
* @brief Write OTA data into required sector of OTA data partition.
* @param otadata_partition OTA data partition.
* @param ota_data OTA data structure.
* @param sec_id Sector number (0 or 1).
*/
void write_ota_data(const esp_partition_t *otadata_partition, esp_ota_select_entry_t *ota_data, int sec_id);
/**
* @brief Corrupt OTA data for testing.
* @param err Type of corruption.
*/
void corrupt_ota_data(corrupt_ota_data_t err);
#if defined(CONFIG_BOOTLOADER_FACTORY_RESET) || defined(CONFIG_BOOTLOADER_APP_TEST)
/**
* @brief Set output pin to low and hold state.
* @param num_pin Pin number.
*/
void set_output_pin(uint32_t num_pin);
/**
* @brief Reset output pin hold function.
* @param num_pin Pin number.
*/
void reset_output_pin(uint32_t num_pin);
#endif
/**
* @brief Mark app as valid and cancel rollback.
*/
void mark_app_valid(void);
/**
* @brief Perform app update and set new boot partition.
* @return Pointer to updated partition.
*/
const esp_partition_t* app_update(void);
#ifdef __cplusplus
}
#endif
@@ -20,7 +20,7 @@ TEST_SUBMENU_PATTERN_PYTEST = re.compile(rb'\s+\((\d+)\)\s+"([^"]+)"\r?\n')
)
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
def test_app_update(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=90)
dut.run_all_single_board_cases(timeout=180)
@pytest.mark.generic
@@ -33,7 +33,7 @@ def test_app_update(dut: Dut) -> None:
)
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
def test_app_update_xip_psram(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=90)
dut.run_all_single_board_cases(timeout=180)
@pytest.mark.generic
@@ -46,7 +46,7 @@ def test_app_update_xip_psram(dut: Dut) -> None:
)
@idf_parametrize('target', ['supported_targets'], indirect=['target'])
def test_app_update_xip_psram_rom_impl(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=90)
dut.run_all_single_board_cases(timeout=180)
@pytest.mark.generic
@@ -59,4 +59,19 @@ def test_app_update_xip_psram_rom_impl(dut: Dut) -> None:
)
@idf_parametrize('target', ['esp32', 'esp32c3', 'esp32s3', 'esp32p4'], indirect=['target'])
def test_app_update_with_rollback(dut: Dut) -> None:
dut.run_all_single_board_cases(timeout=90)
dut.run_all_single_board_cases(timeout=180)
@pytest.mark.recovery_bootloader
@pytest.mark.parametrize(
'config',
['recovery_bootloader'],
indirect=True,
)
@idf_parametrize('target', ['esp32c5'], indirect=['target'])
def test_recovery_bootloader_update(dut: Dut) -> None:
try:
dut.run_all_single_board_cases(group='recovery_bootloader', timeout=90)
finally:
# Erase recovery bootloader after test because it may interfere with other tests using this runner
dut.serial.erase_flash()
@@ -0,0 +1,3 @@
CONFIG_BOOTLOADER_RECOVERY_ENABLE=y
CONFIG_BOOTLOADER_RECOVERY_OFFSET=0x3F0000
CONFIG_PARTITION_TABLE_OFFSET=0x9000
@@ -0,0 +1,2 @@
# ESP32C5 supports the Recovery bootloader feature in ROM starting from v1.0 (ECO2)
CONFIG_IDF_TARGET="esp32c5"
@@ -0,0 +1,2 @@
# ESP32C61 supports the Recovery bootloader feature in ROM starting from v1.0 (ECO3)
CONFIG_IDF_TARGET="esp32c61"
@@ -1,8 +1,37 @@
menu "Bootloader Rollback"
menu "Recovery Bootloader and Rollback"
config BOOTLOADER_RECOVERY_ENABLE
bool "Enable Recovery Bootloader"
depends on SOC_RECOVERY_BOOTLOADER_SUPPORTED
default n
help
The recovery bootloader feature is implemented in the ROM bootloader. It is required for safe OTA
updates of the bootloader. The feature is activated when the eFuse field
(ESP_EFUSE_RECOVERY_BOOTLOADER_FLASH_SECTOR) is set, which defines the flash address of the
recovery bootloader. If activated and the primary bootloader fails to load, the ROM bootloader
will attempt to load the recovery bootloader from the address specified in eFuse.
config BOOTLOADER_RECOVERY_OFFSET
hex "Recovery Bootloader Flash Offset"
depends on BOOTLOADER_RECOVERY_ENABLE
default 0x3F0000
range 0x0 0xFFE000
help
Flash address where the recovery bootloader is stored.
This value must be written to the eFuse field (ESP_EFUSE_RECOVERY_BOOTLOADER_FLASH_SECTOR)
to activate the recovery bootloader in the ROM bootloader. The eFuse can be programmed
using espefuse.py or in the user application with the API esp_efuse_set_recovery_bootloader_offset().
Setting this value in the config allows parttool.py to verify that it does not overlap with existing
partitions in the partition table.
The address must be a multiple of the flash sector size (0x1000 bytes).
The eFuse field stores the offset in sectors.
If the feature is no longer needed or unused, you can burn the 0xFFF value to disable this feature in
the ROM bootloader.
config BOOTLOADER_ANTI_ROLLBACK_ENABLE
bool "Enable bootloader rollback support"
depends on SOC_RECOVERY_BOOTLOADER_SUPPORTED
depends on BOOTLOADER_RECOVERY_ENABLE
default n
help
This option prevents rollback to previous bootloader image with lower security version.
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -18,6 +18,7 @@
#include "hal/cache_hal.h"
#include "hal/cache_ll.h"
#include "hal/mspi_ll.h"
#include "hal/clk_tree_ll.h"
#include "soc/pcr_reg.h"
static const char *TAG = "boot.esp32h21";
@@ -80,7 +81,9 @@ void IRAM_ATTR bootloader_configure_spi_pins(int drv)
static void IRAM_ATTR bootloader_flash_clock_init(void)
{
// At this moment, BBPLL should be enabled, safe to switch MSPI clock source to PLL_F64M (default clock src) to raise speed
// To raise the MSPI clock to 64MHz, needs to enable the 64MHz clock source, which is XTAL_X2_CLK
// (FPGA image fixed MSPI0/1 clock to 64MHz)
clk_ll_xtal_x2_enable();
_mspi_timing_ll_set_flash_clk_src(0, FLASH_CLK_SRC_PLL_F64M);
}
@@ -18,7 +18,7 @@
#include "soc/pmu_reg.h"
#endif
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32C5
#if CONFIG_IDF_TARGET_ESP32
#include "hal/clk_tree_ll.h"
#endif
#include "esp_rom_sys.h"
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -19,6 +19,7 @@
#include "hal/wdt_hal.h"
#include "hal/efuse_hal.h"
#include "esp_bootloader_desc.h"
#include "esp_rom_sys.h"
static const char *TAG = "boot";
@@ -34,7 +35,12 @@ void bootloader_clear_bss_section(void)
esp_err_t bootloader_read_bootloader_header(void)
{
/* load bootloader image header */
if (bootloader_flash_read(ESP_BOOTLOADER_OFFSET, &bootloader_image_hdr, sizeof(esp_image_header_t), true) != ESP_OK) {
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
const uint32_t bootloader_flash_offset = esp_rom_get_bootloader_offset();
#else
const uint32_t bootloader_flash_offset = ESP_PRIMARY_BOOTLOADER_OFFSET;
#endif
if (bootloader_flash_read(bootloader_flash_offset, &bootloader_image_hdr, sizeof(esp_image_header_t), true) != ESP_OK) {
ESP_EARLY_LOGE(TAG, "failed to load bootloader image header!");
return ESP_FAIL;
}
@@ -25,20 +25,19 @@ void bootloader_init_mem(void)
* So, at boot disabling these filters. They will enable as per the
* use case by TEE initialization code.
*/
#ifdef SOC_APM_CTRL_FILTER_SUPPORTED
apm_hal_apm_ctrl_filter_enable_all(false);
/* [APM] On power-up, only the HP CPU starts in TEE mode; others default to REE2.
* APM blocks REE0REE2 access by default. C5 ECO2 adds per-peripheral control
* (default REEx blocking), but config support is pending. As a workaround,
* all masters are set to TEE mode.
#if SOC_APM_CTRL_FILTER_SUPPORTED
apm_hal_enable_ctrl_filter_all(false);
/* [APM] On power-up, only the HP CPU starts in TEE mode; others
* default to REE2. APM blocks REE0REE2 access by default.
* Thus, all masters are set to TEE mode.
*/
#if SOC_APM_SUPPORT_TEE_PERI_ACCESS_CTRL
apm_tee_hal_set_master_secure_mode_all(APM_LL_SECURE_MODE_TEE);
apm_hal_set_master_sec_mode_all(APM_SEC_MODE_TEE);
#endif // SOC_APM_SUPPORT_TEE_PERI_ACCESS_CTRL
#endif // SOC_APM_CTRL_FILTER_SUPPORTED
#endif
#ifdef CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
#if CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE
// protect memory region
esp_cpu_configure_region_protection();
#endif
@@ -10,6 +10,8 @@
#include "hal/adc_types.h"
#include "esp_private/regi2c_ctrl.h"
#define I2C_SAR_ADC_INIT_CODE_VAL 2150
void bootloader_random_enable(void)
{
adc_ll_reset_register();
@@ -29,8 +31,8 @@ void bootloader_random_enable(void)
ANALOG_CLOCK_ENABLE();
adc_ll_regi2c_init();
adc_ll_set_calibration_param(ADC_UNIT_1, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_2, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_1, I2C_SAR_ADC_INIT_CODE_VAL);
adc_ll_set_calibration_param(ADC_UNIT_2, I2C_SAR_ADC_INIT_CODE_VAL);
adc_digi_pattern_config_t pattern_config = {};
pattern_config.unit = ADC_UNIT_1;
@@ -10,6 +10,8 @@
#include "hal/adc_types.h"
#include "esp_private/regi2c_ctrl.h"
#define I2C_SAR_ADC_INIT_CODE_VAL 2150
void bootloader_random_enable(void)
{
adc_ll_reset_register();
@@ -29,8 +31,8 @@ void bootloader_random_enable(void)
ANALOG_CLOCK_ENABLE();
adc_ll_regi2c_init();
adc_ll_set_calibration_param(ADC_UNIT_1, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_2, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_1, I2C_SAR_ADC_INIT_CODE_VAL);
adc_ll_set_calibration_param(ADC_UNIT_2, I2C_SAR_ADC_INIT_CODE_VAL);
adc_digi_pattern_config_t pattern_config = {};
pattern_config.unit = ADC_UNIT_2;
@@ -10,6 +10,8 @@
#include "hal/adc_types.h"
#include "esp_private/regi2c_ctrl.h"
#define I2C_SAR_ADC_INIT_CODE_VAL 2150
void bootloader_random_enable(void)
{
adc_ll_reset_register();
@@ -29,8 +31,8 @@ void bootloader_random_enable(void)
ANALOG_CLOCK_ENABLE();
adc_ll_regi2c_init();
adc_ll_set_calibration_param(ADC_UNIT_1, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_2, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_1, I2C_SAR_ADC_INIT_CODE_VAL);
adc_ll_set_calibration_param(ADC_UNIT_2, I2C_SAR_ADC_INIT_CODE_VAL);
adc_digi_pattern_config_t pattern_config = {};
pattern_config.unit = ADC_UNIT_1;
@@ -10,6 +10,8 @@
#include "hal/adc_types.h"
#include "esp_private/regi2c_ctrl.h"
#define I2C_SAR_ADC_INIT_CODE_VAL 2150
void bootloader_random_enable(void)
{
adc_ll_reset_register();
@@ -29,8 +31,8 @@ void bootloader_random_enable(void)
ANALOG_CLOCK_ENABLE();
adc_ll_regi2c_init();
adc_ll_set_calibration_param(ADC_UNIT_1, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_2, 0x866);
adc_ll_set_calibration_param(ADC_UNIT_1, I2C_SAR_ADC_INIT_CODE_VAL);
adc_ll_set_calibration_param(ADC_UNIT_2, I2C_SAR_ADC_INIT_CODE_VAL);
adc_digi_pattern_config_t pattern_config = {};
pattern_config.atten = ADC_ATTEN_DB_2_5;
@@ -1,108 +1,72 @@
/*
* SPDX-FileCopyrightText: 2023-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "sdkconfig.h"
#include "bootloader_random.h"
#include "soc/soc.h"
#include "soc/adc_reg.h"
#include "soc/pmu_reg.h"
#include "soc/regi2c_saradc.h"
#include "soc/hp_sys_clkrst_reg.h"
#include "soc/lp_adc_reg.h"
#include "esp_private/regi2c_ctrl.h"
#include "esp_rom_regi2c.h"
#include "hal/regi2c_ctrl_ll.h"
#include "hal/adc_ll.h"
#include "hal/adc_types.h"
// TODO IDF-6497: once ADC API is supported, use the API instead of defining functions and constants here
#include "esp_private/periph_ctrl.h"
#include "esp_private/adc_share_hw_ctrl.h"
#define I2C_SAR_ADC_INIT_CODE_VAL 2166
typedef struct {
int atten;
int channel;
} pattern_item;
typedef struct {
pattern_item item[4];
} pattern_table;
static void adc1_fix_initcode_set(uint32_t initcode_value)
{
uint32_t msb = initcode_value >> 8;
uint32_t lsb = initcode_value & 0xff;
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, msb);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, lsb);
}
//total 4 tables
static void hpadc_sar1_pattern_table_cfg(unsigned int table_idx, pattern_table table)
{
uint32_t wdata = 0;
wdata = (table.item[0].channel << 20 | table.item[0].atten << 18 |
table.item[1].channel << 14|table.item[1].atten << 12 |
table.item[2].channel << 8 |table.item[2].atten << 6 |
table.item[3].channel << 2 |table.item[3].atten);
WRITE_PERI_REG(ADC_SAR1_PATT_TAB1_REG + table_idx * 4, wdata);
}
void bootloader_random_enable(void)
{
pattern_table sar1_table[4] = {};
uint32_t pattern_len = 0;
_adc_ll_reset_register();
_adc_ll_enable_bus_clock(true);
SET_PERI_REG_MASK(HP_SYS_CLKRST_SOC_CLK_CTRL2_REG, HP_SYS_CLKRST_REG_ADC_APB_CLK_EN);
SET_PERI_REG_MASK(HP_SYS_CLKRST_PERI_CLK_CTRL23_REG, HP_SYS_CLKRST_REG_ADC_CLK_EN);
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_XTAL);
adc_ll_digi_controller_clk_div(0, 0, 0);
SET_PERI_REG_MASK(RTCADC_MEAS1_MUX_REG, RTCADC_SAR1_DIG_FORCE);
SET_PERI_REG_MASK(PMU_RF_PWC_REG,PMU_XPD_PERIF_I2C);
uint32_t sar1_clk_div_num = GET_PERI_REG_BITS2((HP_SYS_CLKRST_PERI_CLK_CTRL24_REG),
(HP_SYS_CLKRST_REG_ADC_SAR1_CLK_DIV_NUM_M),
(HP_SYS_CLKRST_REG_ADC_SAR1_CLK_DIV_NUM_S));
SET_PERI_REG_MASK(ADC_CTRL_REG_REG, ADC_START_FORCE); //start force 1
// some ADC sensor registers are in power group PERIF_I2C and need to be enabled via PMU
#ifndef BOOTLOADER_BUILD
regi2c_saradc_enable();
#else
regi2c_ctrl_ll_i2c_sar_periph_enable();
#endif
// enable analog i2c master clock for RNG runtime
ANALOG_CLOCK_ENABLE();
adc1_fix_initcode_set(I2C_SAR_ADC_INIT_CODE_VAL);
adc_ll_regi2c_init();
adc_ll_set_calibration_param(ADC_UNIT_1, I2C_SAR_ADC_INIT_CODE_VAL);
// cfg pattern table
sar1_table[0].item[0].channel = 10; //rand() % 6;
sar1_table[0].item[0].atten = 3;
sar1_table[0].item[1].channel = 10;
sar1_table[0].item[1].atten = 3;
sar1_table[0].item[2].channel = 10;
sar1_table[0].item[2].atten = 3;
sar1_table[0].item[3].channel = 10;
sar1_table[0].item[3].atten = 3;
adc_digi_pattern_config_t pattern_config = {};
pattern_config.unit = ADC_UNIT_1;
pattern_config.atten = ADC_ATTEN_DB_12;
pattern_config.channel = ADC_CHANNEL_10;
adc_ll_digi_set_pattern_table(ADC_UNIT_1, 0, pattern_config);
adc_ll_digi_set_pattern_table(ADC_UNIT_1, 1, pattern_config);
adc_ll_digi_set_pattern_table(ADC_UNIT_1, 2, pattern_config);
adc_ll_digi_set_pattern_table(ADC_UNIT_1, 3, pattern_config);
adc_ll_digi_set_pattern_table_len(ADC_UNIT_1, 1);
hpadc_sar1_pattern_table_cfg(0, sar1_table[0]);
SET_PERI_REG_BITS(ADC_CTRL_REG_REG, ADC_SAR1_PATT_LEN, pattern_len, ADC_SAR1_PATT_LEN_S);
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_DIG);
adc_ll_digi_set_power_manage(ADC_UNIT_1, ADC_LL_POWER_SW_ON);
SET_PERI_REG_BITS(ADC_CTRL_REG_REG, ADC_XPD_SAR1_FORCE, 3, ADC_XPD_SAR1_FORCE_S);
SET_PERI_REG_BITS(ADC_CTRL_REG_REG, ADC_XPD_SAR2_FORCE, 3, ADC_XPD_SAR2_FORCE_S);
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_ENT_VDD_GRP1, 1);
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_DTEST_VDD_GRP1, 0);
CLEAR_PERI_REG_MASK(ADC_CTRL_REG_REG, ADC_START_FORCE);
SET_PERI_REG_MASK(ADC_CTRL2_REG, ADC_TIMER_EN);
SET_PERI_REG_BITS(ADC_CTRL2_REG, ADC_TIMER_TARGET, sar1_clk_div_num * 25, ADC_TIMER_TARGET_S);
while (GET_PERI_REG_MASK(ADC_INT_RAW_REG, ADC_SAR1_DONE_INT_RAW) == 0) { }
SET_PERI_REG_MASK(ADC_INT_CLR_REG, ADC_APB_SARADC1_DONE_INT_CLR);
adc_ll_digi_set_clk_div(15);
adc_ll_digi_set_trigger_interval(100);
adc_ll_digi_trigger_enable();
}
void bootloader_random_disable(void)
{
adc_ll_digi_trigger_disable();
adc_ll_digi_reset_pattern_table();
adc_ll_set_calibration_param(ADC_UNIT_1, 0x0);
adc_ll_set_calibration_param(ADC_UNIT_2, 0x0);
adc_ll_regi2c_adc_deinit();
#ifndef BOOTLOADER_BUILD
regi2c_saradc_disable();
#endif
// disable analog i2c master clock
ANALOG_CLOCK_DISABLE();
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_LOW_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, ADC_SAR1_INITIAL_CODE_HIGH_ADDR, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_ENT_VDD_GRP1, 0);
REGI2C_WRITE_MASK(I2C_SAR_ADC, I2C_SAR_ADC_DTEST_VDD_GRP1, 0);
adc_ll_digi_controller_clk_div(4, 0, 0);
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_XTAL);
}
@@ -167,7 +167,7 @@ esp_err_t bootloader_init(void)
#if XCHAL_ERRATUM_572
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
WSR(MEMCTL, memctl);
WSR(XT_REG_MEMCTL, memctl);
#endif // XCHAL_ERRATUM_572
// In RAM_APP, memory will be initialized in `call_start_cpu0`
@@ -86,7 +86,6 @@ static void bootloader_super_wdt_auto_feed(void)
static inline void bootloader_hardware_init(void)
{
_regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
regi2c_ctrl_ll_master_force_enable_clock(true); // TODO: IDF-8667 Remove this?
regi2c_ctrl_ll_master_configure_clock();
}
@@ -87,7 +87,6 @@ static void bootloader_super_wdt_auto_feed(void)
static inline void bootloader_hardware_init(void)
{
_regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
regi2c_ctrl_ll_master_force_enable_clock(true); // TODO: IDF-9274 Remove this?
regi2c_ctrl_ll_master_configure_clock();
}
@@ -89,8 +89,7 @@ static inline void bootloader_hardware_init(void)
CLEAR_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_RFPLL);
SET_PERI_REG_MASK(PMU_RF_PWC_REG, PMU_XPD_FORCE_RFPLL);
//TODO: [ESP32H21] IDF-11550, regi2c atomic clock
regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
_regi2c_ctrl_ll_master_enable_clock(true); // keep ana i2c mst clock always enabled in bootloader
regi2c_ctrl_ll_master_configure_clock();
}
@@ -144,7 +144,7 @@ esp_err_t bootloader_init(void)
#if XCHAL_ERRATUM_572
uint32_t memctl = XCHAL_CACHE_MEMCTL_DEFAULT;
WSR(MEMCTL, memctl);
WSR(XT_REG_MEMCTL, memctl);
#endif // XCHAL_ERRATUM_572
bootloader_ana_reset_config();
@@ -23,6 +23,7 @@
#include "soc/soc_caps.h"
#include "hal/cache_ll.h"
#include "spi_flash_mmap.h"
#include "hal/efuse_hal.h"
#define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
@@ -119,11 +120,26 @@ void esp_image_bootloader_offset_set(const uint32_t offset)
{
s_bootloader_partition_offset = offset;
ESP_LOGI(TAG, "Bootloader offsets for PRIMARY: 0x%x, Secondary: 0x%" PRIx32, ESP_PRIMARY_BOOTLOADER_OFFSET, s_bootloader_partition_offset);
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
uint32_t recovery_offset = efuse_hal_get_recovery_bootloader_address();
if (efuse_hal_recovery_bootloader_enabled()) {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: 0x%" PRIx32, recovery_offset);
} else if (recovery_offset == 0) {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: has not been set yet");
} else {
ESP_LOGI(TAG, "Bootloader offset for RECOVERY: is disabled");
}
#endif
}
static bool is_bootloader(uint32_t offset)
{
return ((offset == ESP_PRIMARY_BOOTLOADER_OFFSET) || (offset == s_bootloader_partition_offset));
return ((offset == ESP_PRIMARY_BOOTLOADER_OFFSET)
|| (offset == s_bootloader_partition_offset)
#if SOC_RECOVERY_BOOTLOADER_SUPPORTED
|| (efuse_hal_recovery_bootloader_enabled() ? offset == efuse_hal_get_recovery_bootloader_address() : false)
#endif
);
}
static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data)
+24 -16
View File
@@ -29,7 +29,6 @@ set(common_include_dirs
set(ble_mesh_include_dirs
"esp_ble_mesh/common/include"
"esp_ble_mesh/common/tinycrypt/include"
"esp_ble_mesh/core"
"esp_ble_mesh/core/include"
"esp_ble_mesh/core/storage"
@@ -42,6 +41,10 @@ set(ble_mesh_include_dirs
"esp_ble_mesh/api"
)
set(ble_mesh_tinycrypt_dirs
"esp_ble_mesh/common/tinycrypt/include"
)
set(ble_mesh_v11_include_dirs
"esp_ble_mesh/lib/include"
"esp_ble_mesh/v1.1/api/core/include"
@@ -500,21 +503,6 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/btc/btc_ble_mesh_prov.c"
"esp_ble_mesh/btc/btc_ble_mesh_sensor_model.c"
"esp_ble_mesh/btc/btc_ble_mesh_time_scene_model.c"
"esp_ble_mesh/common/tinycrypt/src/aes_decrypt.c"
"esp_ble_mesh/common/tinycrypt/src/aes_encrypt.c"
"esp_ble_mesh/common/tinycrypt/src/cbc_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ccm_mode.c"
"esp_ble_mesh/common/tinycrypt/src/cmac_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ctr_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ctr_prng.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_dh.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_dsa.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_platform_specific.c"
"esp_ble_mesh/common/tinycrypt/src/ecc.c"
"esp_ble_mesh/common/tinycrypt/src/hmac_prng.c"
"esp_ble_mesh/common/tinycrypt/src/hmac.c"
"esp_ble_mesh/common/tinycrypt/src/sha256.c"
"esp_ble_mesh/common/tinycrypt/src/utils.c"
"esp_ble_mesh/common/atomic.c"
"esp_ble_mesh/common/buf.c"
"esp_ble_mesh/common/common.c"
@@ -565,6 +553,26 @@ if(CONFIG_BT_ENABLED)
"esp_ble_mesh/models/server/state_binding.c"
"esp_ble_mesh/models/server/state_transition.c"
"esp_ble_mesh/models/server/time_scene_server.c")
if(NOT CONFIG_BLE_MESH_USE_UNIFIED_CRYPTO)
list(APPEND include_dirs ${ble_mesh_tinycrypt_dirs})
list(APPEND srcs
"esp_ble_mesh/common/tinycrypt/src/aes_decrypt.c"
"esp_ble_mesh/common/tinycrypt/src/aes_encrypt.c"
"esp_ble_mesh/common/tinycrypt/src/cbc_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ccm_mode.c"
"esp_ble_mesh/common/tinycrypt/src/cmac_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ctr_mode.c"
"esp_ble_mesh/common/tinycrypt/src/ctr_prng.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_dh.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_dsa.c"
"esp_ble_mesh/common/tinycrypt/src/ecc_platform_specific.c"
"esp_ble_mesh/common/tinycrypt/src/ecc.c"
"esp_ble_mesh/common/tinycrypt/src/hmac_prng.c"
"esp_ble_mesh/common/tinycrypt/src/hmac.c"
"esp_ble_mesh/common/tinycrypt/src/sha256.c"
"esp_ble_mesh/common/tinycrypt/src/utils.c")
endif()
if(CONFIG_BLE_MESH_V11_SUPPORT)
list(APPEND include_dirs ${ble_mesh_v11_include_dirs})
@@ -37,7 +37,6 @@
#define SPI_OUT_PACKET_LOSS_FRAME_SIZE (6)
#define SPI_OUT_TRANS_ITVL_MIN_US (30)
#define SPI_OUT_UL_LOG_STR_BUF_SIZE (100)
#define SPI_OUT_MALLOC(size) heap_caps_malloc(size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)
#if SPI_OUT_TS_SYNC_ENABLED
#define SPI_OUT_TS_SYNC_TIMEOUT (1000 * 1000)
@@ -234,13 +233,13 @@ static void spi_out_le_audio_log_deinit(void);
static int spi_out_init_trans(spi_out_trans_cb_t **trans_cb, uint16_t buf_size)
{
// Memory allocations
*trans_cb = (spi_out_trans_cb_t *)SPI_OUT_MALLOC(sizeof(spi_out_trans_cb_t));
*trans_cb = (spi_out_trans_cb_t *)malloc(sizeof(spi_out_trans_cb_t));
if (!(*trans_cb)) {
return -1;
}
memset(*trans_cb, 0, sizeof(spi_out_trans_cb_t));
uint8_t *buf = (uint8_t *)SPI_OUT_MALLOC((size_t)buf_size);
uint8_t *buf = (uint8_t *)spi_bus_dma_memory_alloc(SPI_OUT_BUS, (size_t)buf_size, 0);
if (!buf) {
free(*trans_cb);
*trans_cb = NULL;
@@ -312,7 +311,7 @@ recycle:
static int spi_out_log_cb_init(spi_out_log_cb_t **log_cb, uint16_t buf_size, uint8_t type)
{
// Initialize log control block
*log_cb = (spi_out_log_cb_t *)SPI_OUT_MALLOC(sizeof(spi_out_log_cb_t));
*log_cb = (spi_out_log_cb_t *)malloc(sizeof(spi_out_log_cb_t));
if (!(*log_cb)) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize log control block!");
return -1;
@@ -428,7 +427,7 @@ IRAM_ATTR static bool spi_out_log_cb_write(spi_out_log_cb_t *log_cb, const uint8
memcpy(buf, (const uint8_t *)&head, SPI_OUT_FRAME_HEAD_LEN);
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN, addr, len);
if (len_append && addr_append) {
if (len_append) {
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + len, addr_append, len_append);
}
memcpy(buf + SPI_OUT_FRAME_HEAD_LEN + total_length, &checksum, SPI_OUT_FRAME_TAIL_LEN);
@@ -521,7 +520,7 @@ static int spi_out_ul_log_init(void)
}
// Initialize string buffer
ul_log_str_buf = (uint8_t *)SPI_OUT_MALLOC(SPI_OUT_UL_LOG_STR_BUF_SIZE);
ul_log_str_buf = (uint8_t *)malloc(SPI_OUT_UL_LOG_STR_BUF_SIZE);
if (!ul_log_str_buf) {
ESP_LOGE(BLE_LOG_TAG, "Failed to initialize string buffer for upper layer task log!");
goto str_buf_init_failed;
@@ -13,7 +13,6 @@
#include "esp_timer.h"
#include "esp_log.h"
#include "freertos/semphr.h"
#include "esp_heap_caps.h"
// Public enums
enum {
+2 -2
View File
@@ -490,10 +490,10 @@ static bt_status_t btc_init_mem(void) {
#endif
#if BTC_HF_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
if ((hf_local_param_ptr = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
if ((hf_local_param_ptr = (hf_local_param_t *)osi_malloc(sizeof(hf_local_param_t))) == NULL) {
goto error_exit;
}
memset((void *)hf_local_param_ptr, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
memset((void *)hf_local_param_ptr, 0, sizeof(hf_local_param_t));
#endif
#if BTC_HF_CLIENT_INCLUDED == TRUE && HFP_DYNAMIC_MEMORY == TRUE
+23 -23
View File
@@ -57,17 +57,17 @@ xt_highint4:
wsr a0, CCOMPARE2
/* Enable Timer 2 interrupt */
rsr a0, INTENABLE
rsr a0, XT_REG_INTENABLE
extui a0, a0, 16, 1
bnez a0, 1f
movi a0, 0
xsr a0, INTENABLE /* disable all interrupts */
xsr a0, XT_REG_INTENABLE /* disable all interrupts */
/* And a0 with (1 << 16) for Timer 2 interrupt mask */
addmi a0, a0, (1<<14)
addmi a0, a0, (1<<14)
addmi a0, a0, (1<<14)
addmi a0, a0, (1<<14)
wsr a0, INTENABLE /* Enable Timer 2 */
wsr a0, XT_REG_INTENABLE /* Enable Timer 2 */
1:
#endif
@@ -76,37 +76,37 @@ xt_highint4:
s32i a1, a0, 4
s32i a2, a0, 8
s32i a3, a0, 12
rsr a2, EXCSAVE_4 /* holds the value of a0 */
rsr a2, XT_REG_EXCSAVE_4 /* holds the value of a0 */
s32i a2, a0, 0
/* Save special registers */
addi a0, a0, SPECREG_OFFSET
rsr a2, WINDOWBASE
rsr a2, XT_REG_WINDOWBASE
s32i a2, a0, 0
rsr a2, WINDOWSTART
rsr a2, XT_REG_WINDOWSTART
s32i a2, a0, 4
rsr a2, SAR
rsr a2, XT_REG_SAR
s32i a2, a0, 8
rsr a2, LBEG
rsr a2, XT_REG_LBEG
s32i a2, a0, 12
rsr a2, LEND
rsr a2, XT_REG_LEND
s32i a2, a0, 16
rsr a2, LCOUNT
rsr a2, XT_REG_LCOUNT
s32i a2, a0, 20
rsr a2, EPC1
s32i a2, a0, 24
#if CONFIG_ESP32_ECO3_CACHE_LOCK_FIX
movi a0, 0
xsr a0, INTENABLE /* disable all interrupts */
xsr a0, XT_REG_INTENABLE /* disable all interrupts */
movi a2, ~(1<<16)
and a0, a2, a0
wsr a0, INTENABLE
wsr a0, XT_REG_INTENABLE
#endif
/* disable exception mode, window overflow */
movi a0, PS_INTLEVEL(5) | PS_EXCM
wsr a0, PS
wsr a0, XT_REG_PS
rsync
/* Save the remaining physical registers.
@@ -153,12 +153,12 @@ xt_highint4:
/* a0 still points to _l4_save_ctx */
/* Can clear WINDOWSTART now, all registers are saved */
rsr a2, WINDOWBASE
rsr a2, XT_REG_WINDOWBASE
/* WINDOWSTART = (1 << WINDOWBASE) */
movi a3, 1
ssl a2
sll a3, a3
wsr a3, WINDOWSTART
wsr a3, XT_REG_WINDOWSTART
_highint4_stack_switch:
movi a0, 0
@@ -169,7 +169,7 @@ _highint4_stack_switch:
/* Set up PS for C, disable all interrupts except NMI and debug, and clear EXCM. */
movi a6, PS_INTLEVEL(4) | PS_UM | PS_WOE
wsr a6, PS
wsr a6, XT_REG_PS
rsync
/* Call C handler */
@@ -180,7 +180,7 @@ _highint4_stack_switch:
/* Done with C handler; re-enable exception mode, disabling window overflow */
movi a2, PS_INTLEVEL(5) | PS_EXCM /* TOCHECK */
wsr a2, PS
wsr a2, XT_REG_PS
rsync
/* Restore the special registers.
@@ -188,13 +188,13 @@ _highint4_stack_switch:
*/
movi a0, _l4_save_ctx + SPECREG_OFFSET
l32i a2, a0, 8
wsr a2, SAR
wsr a2, XT_REG_SAR
l32i a2, a0, 12
wsr a2, LBEG
wsr a2, XT_REG_LBEG
l32i a2, a0, 16
wsr a2, LEND
wsr a2, XT_REG_LEND
l32i a2, a0, 20
wsr a2, LCOUNT
wsr a2, XT_REG_LCOUNT
l32i a2, a0, 24
wsr a2, EPC1
@@ -247,12 +247,12 @@ _highint4_stack_switch:
movi a0, _l4_save_ctx
l32i a2, a0, SPECREG_OFFSET + 4
wsr a2, WINDOWSTART
wsr a2, XT_REG_WINDOWSTART
l32i a1, a0, 4
l32i a2, a0, 8
l32i a3, a0, 12
rsr a0, EXCSAVE_4 /* holds the value of a0 before the interrupt handler */
rsr a0, XT_REG_EXCSAVE_4 /* holds the value of a0 before the interrupt handler */
/* Return from the interrupt, restoring PS from EPS_4 */
rfi 4
+8
View File
@@ -22,6 +22,14 @@ if BLE_MESH
for mesh packets. And this could help avoid collision of
advertising packets.
config BLE_MESH_USE_UNIFIED_CRYPTO
bool "Use the unified BLE tinycrypt implementation"
depends on !BT_LE_CRYPTO_STACK_MBEDTLS && !BT_NIMBLE_CRYPTO_STACK_MBEDTLS
default n
help
Enable this option to use the unified BLE tinycrypt solution
instead of the default one in BLE Mesh stack.
menuconfig BLE_MESH_USE_BLE_50
bool "Support using BLE 5.0 APIs for BLE Mesh"
depends on BLE_MESH_EXPERIMENTAL
@@ -1724,9 +1724,11 @@ void btc_avrc_get_profile_status(esp_avrc_profile_status_t *param)
if (btc_avrc_ct_init_p()) {
param->avrc_ct_inited = true;
}
#if BTC_AV_CA_INCLUDED
if (btc_rc_cb.rc_cover_art_connected) {
param->ct_cover_art_conn_num++;
}
#endif
}
}
@@ -66,7 +66,7 @@
static UINT16 btc_max_hf_clients = BTC_HF_NUM_CB;
/* HF Param Definition */
#if HFP_DYNAMIC_MEMORY == FALSE
static hf_local_param_t hf_local_param[BTC_HF_NUM_CB];
static hf_local_param_t hf_local_param;
#else
hf_local_param_t *hf_local_param_ptr = NULL;
#endif
@@ -117,7 +117,7 @@ do {
if ((idx < 0) || (idx >= BTC_HF_NUM_CB)) { \
return BT_STATUS_FAIL; \
} \
if (!hf_local_param[idx].btc_hf_cb.initialized) { \
if (!hf_local_param.initialized) { \
BTIF_TRACE_WARNING("CHECK_HF_INIT: %s: HF AG not initialized", __FUNCTION__); \
return BT_STATUS_NOT_READY; \
} else { \
@@ -130,8 +130,8 @@ do {
if ((idx < 0) || (idx >= BTC_HF_NUM_CB)) { \
return BT_STATUS_FAIL; \
} \
if (!hf_local_param[idx].btc_hf_cb.initialized || \
hf_local_param[idx].btc_hf_cb.connection_state != ESP_HF_CONNECTION_STATE_SLC_CONNECTED) { \
if (!hf_local_param.initialized || \
hf_local_param.btc_hf_cb[idx].connection_state != ESP_HF_CONNECTION_STATE_SLC_CONNECTED) { \
BTIF_TRACE_WARNING("CHECK_HF_SLC_CONNECTED: %s: HF AG SLC not connected", __FUNCTION__); \
return BT_STATUS_NOT_READY; \
} else { \
@@ -141,10 +141,10 @@ do {
#define clear_phone_state() \
hf_local_param[idx].btc_hf_cb.call_state = ESP_HF_CALL_STATUS_NO_CALLS; \
hf_local_param[idx].btc_hf_cb.call_setup_state = ESP_HF_CALL_SETUP_STATUS_IDLE;\
hf_local_param[idx].btc_hf_cb.num_active = 0; \
hf_local_param[idx].btc_hf_cb.num_held = 0;
hf_local_param.btc_hf_cb[idx].call_state = ESP_HF_CALL_STATUS_NO_CALLS; \
hf_local_param.btc_hf_cb[idx].call_setup_state = ESP_HF_CALL_SETUP_STATUS_IDLE;\
hf_local_param.btc_hf_cb[idx].num_active = 0; \
hf_local_param.btc_hf_cb[idx].num_held = 0;
#define CHECK_HF_IDX(idx) \
do { \
@@ -160,7 +160,7 @@ do {
static int btc_hf_idx_by_bdaddr(bt_bdaddr_t *bd_addr)
{
for (int i = 0; i < btc_max_hf_clients; ++i) {
if (bdcmp(bd_addr->address, hf_local_param[i].btc_hf_cb.connected_bda.address) == 0) {
if (bdcmp(bd_addr->address, hf_local_param.btc_hf_cb[i].connected_bda.address) == 0) {
return i;
}
}
@@ -170,8 +170,8 @@ static int btc_hf_idx_by_bdaddr(bt_bdaddr_t *bd_addr)
static int btc_hf_find_free_idx(void)
{
for (int idx = 0; idx < btc_max_hf_clients; ++idx) {
if (hf_local_param[idx].btc_hf_cb.initialized &&
hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_DISCONNECTED) {
if (hf_local_param.initialized &&
hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_DISCONNECTED) {
return idx;
}
}
@@ -180,9 +180,9 @@ static int btc_hf_find_free_idx(void)
static BOOLEAN is_connected(int idx, bt_bdaddr_t *bd_addr)
{
if ((bdcmp(bd_addr->address,hf_local_param[idx].btc_hf_cb.connected_bda.address) == 0) &&
((hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_CONNECTED) ||
(hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED))) {
if ((bdcmp(bd_addr->address,hf_local_param.btc_hf_cb[idx].connected_bda.address) == 0) &&
((hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_CONNECTED) ||
(hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED))) {
return TRUE;
}
return FALSE;
@@ -196,9 +196,9 @@ static int btc_hf_latest_connected_idx(void)
conn_time_delta.tv_sec = now.tv_sec;
for (int i = 0; i < btc_max_hf_clients; i++) {
if (hf_local_param[i].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED) {
if ((now.tv_sec - hf_local_param[i].btc_hf_cb.connected_timestamp.tv_sec) < conn_time_delta.tv_sec) {
conn_time_delta.tv_sec = now.tv_sec - hf_local_param[i].btc_hf_cb.connected_timestamp.tv_sec;
if (hf_local_param.btc_hf_cb[i].connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED) {
if ((now.tv_sec - hf_local_param.btc_hf_cb[i].connected_timestamp.tv_sec) < conn_time_delta.tv_sec) {
conn_time_delta.tv_sec = now.tv_sec - hf_local_param.btc_hf_cb[i].connected_timestamp.tv_sec;
latest_conn_idx = i;
}
}
@@ -264,24 +264,24 @@ static void bte_hf_evt(tBTA_AG_EVT event, tBTA_AG *param)
************************************************************************************/
void btc_hf_reg_data_cb(esp_hf_incoming_data_cb_t recv, esp_hf_outgoing_data_cb_t send)
{
hf_local_param[0].btc_hf_incoming_data_cb = recv;
hf_local_param[0].btc_hf_outgoing_data_cb = send;
hf_local_param.btc_hf_incoming_data_cb = recv;
hf_local_param.btc_hf_outgoing_data_cb = send;
}
void btc_hf_reg_audio_data_cb(esp_hf_ag_audio_data_cb_t callback)
{
hf_local_param[0].btc_hf_audio_data_cb = callback;
hf_local_param.btc_hf_audio_data_cb = callback;
}
void btc_hf_audio_data_cb_to_app(uint8_t *buf, uint8_t *data, uint16_t len, bool is_bad_frame)
{
if (hf_local_param[0].btc_hf_audio_data_cb) {
if (hf_local_param.btc_hf_audio_data_cb) {
/* we always have sizeof(BT_HDR) bytes free space before data, it is enough for esp_hf_audio_buff_t */
esp_hf_audio_buff_t *audio_buff = (esp_hf_audio_buff_t *)buf;
audio_buff->buff_size = len;
audio_buff->data_len = len;
audio_buff->data = data;
hf_local_param[0].btc_hf_audio_data_cb(hf_local_param[0].btc_hf_cb.sync_conn_hdl, audio_buff, is_bad_frame);
hf_local_param.btc_hf_audio_data_cb(hf_local_param.btc_hf_cb[0].sync_conn_hdl, audio_buff, is_bad_frame);
}
else {
osi_free(buf);
@@ -290,19 +290,17 @@ void btc_hf_audio_data_cb_to_app(uint8_t *buf, uint8_t *data, uint16_t len, bool
void btc_hf_incoming_data_cb_to_app(const uint8_t *data, uint32_t len)
{
int idx = 0;
// todo: critical section protection
if (hf_local_param[idx].btc_hf_incoming_data_cb) {
hf_local_param[idx].btc_hf_incoming_data_cb(data, len);
if (hf_local_param.btc_hf_incoming_data_cb) {
hf_local_param.btc_hf_incoming_data_cb(data, len);
}
}
uint32_t btc_hf_outgoing_data_cb_to_app(uint8_t *data, uint32_t len)
{
int idx = 0;
// todo: critical section protection
if (hf_local_param[idx].btc_hf_outgoing_data_cb) {
return hf_local_param[idx].btc_hf_outgoing_data_cb(data, len);
if (hf_local_param.btc_hf_outgoing_data_cb) {
return hf_local_param.btc_hf_outgoing_data_cb(data, len);
} else {
return 0;
}
@@ -321,7 +319,7 @@ bt_status_t btc_hf_execute_service(BOOLEAN b_enable)
} else {
/* De-register AG */
for (idx = 0; idx < btc_max_hf_clients; idx++) {
BTA_AgDeregister(hf_local_param[idx].btc_hf_cb.handle);
BTA_AgDeregister(hf_local_param.btc_hf_cb[idx].handle);
}
/* Disable AG */
BTA_AgDisable();
@@ -339,30 +337,29 @@ bt_status_t btc_hf_init(void)
{
int idx = 0;
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param)
#endif
{
if (hf_local_param[idx].btc_hf_cb.initialized) {
esp_hf_cb_param_t param = {
.prof_stat.state = ESP_HF_INIT_ALREADY,
};
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
return BT_STATUS_SUCCESS;
}
if (hf_local_param.initialized) {
esp_hf_cb_param_t param = {
.prof_stat.state = ESP_HF_INIT_ALREADY,
};
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
return BT_STATUS_SUCCESS;
}
BTC_TRACE_DEBUG("%s - max_hf_clients=%d", __func__, btc_max_hf_clients);
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param == NULL) {
if ((hf_local_param = (hf_local_param_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(hf_local_param_t))) == NULL) {
if (hf_local_param.btc_hf_cb == NULL) {
hf_local_param.btc_hf_cb = (btc_hf_cb_t *)osi_malloc(BTC_HF_NUM_CB * sizeof(btc_hf_cb_t));
if (hf_local_param.btc_hf_cb == NULL) {
BTC_TRACE_ERROR("%s malloc failed!", __func__);
return BT_STATUS_NOMEM;
}
}
memset((void *)hf_local_param, 0, BTC_HF_NUM_CB * sizeof(hf_local_param_t));
#endif
memset(hf_local_param.btc_hf_cb, 0, BTC_HF_NUM_CB * sizeof(btc_hf_cb_t));
for (int i = 0; i < BTC_HF_NUM_CB; i++) {
hf_local_param.btc_hf_cb[i].sync_conn_hdl = ESP_INVALID_CONN_HANDLE;
}
hf_local_param.hf_idx = BTC_HF_INVALID_IDX;
/* Invoke the enable service API to the core to set the appropriate service_id
* Internally, the HSP_SERVICE_ID shall also be enabled if HFP is enabled (phone)
@@ -373,10 +370,7 @@ bt_status_t btc_hf_init(void)
btc_dm_enable_service(BTA_HSP_SERVICE_ID);
#endif
clear_phone_state();
memset(&hf_local_param[idx].btc_hf_cb, 0, sizeof(btc_hf_cb_t));
for (int i = 0; i < BTC_HF_NUM_CB; i++) {
hf_local_param[i].btc_hf_cb.sync_conn_hdl = ESP_INVALID_CONN_HANDLE;
}
// set audio path
#if (BT_CONTROLLER_INCLUDED == TRUE)
#if BTM_SCO_HCI_INCLUDED
@@ -394,19 +388,12 @@ void btc_hf_deinit(void)
{
BTC_TRACE_EVENT("%s", __FUNCTION__);
int idx = 0;
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param)
#endif
{
if (!hf_local_param[idx].btc_hf_cb.initialized) {
esp_hf_cb_param_t param = {
.prof_stat.state = ESP_HF_DEINIT_ALREADY,
};
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
return;
}
if (!hf_local_param.initialized) {
esp_hf_cb_param_t param = {
.prof_stat.state = ESP_HF_DEINIT_ALREADY,
};
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
return;
}
btc_dm_disable_service(BTA_HFP_SERVICE_ID);
@@ -414,12 +401,8 @@ void btc_hf_deinit(void)
static void btc_hf_cb_release(void)
{
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param) {
osi_free(hf_local_param);
hf_local_param = NULL;
}
#endif
osi_free(hf_local_param.btc_hf_cb);
hf_local_param.btc_hf_cb = NULL;
}
static bt_status_t connect_init(bt_bdaddr_t *bd_addr, uint16_t uuid)
@@ -431,9 +414,9 @@ static bt_status_t connect_init(bt_bdaddr_t *bd_addr, uint16_t uuid)
}
if (!is_connected(idx, bd_addr)) {
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_CONNECTING;
bdcpy(hf_local_param[idx].btc_hf_cb.connected_bda.address, bd_addr->address);
BTA_AgOpen(hf_local_param[idx].btc_hf_cb.handle, hf_local_param[idx].btc_hf_cb.connected_bda.address, BTC_HF_SECURITY, BTC_HF_SERVICES);
hf_local_param.btc_hf_cb[idx].connection_state = ESP_HF_CONNECTION_STATE_CONNECTING;
bdcpy(hf_local_param.btc_hf_cb[idx].connected_bda.address, bd_addr->address);
BTA_AgOpen(hf_local_param.btc_hf_cb[idx].handle, hf_local_param.btc_hf_cb[idx].connected_bda.address, BTC_HF_SECURITY, BTC_HF_SERVICES);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_BUSY;
@@ -453,7 +436,7 @@ bt_status_t btc_hf_disconnect(bt_bdaddr_t *bd_addr)
}
if (is_connected(idx, bd_addr)) {
BTA_AgClose(hf_local_param[idx].btc_hf_cb.handle);
BTA_AgClose(hf_local_param.btc_hf_cb[idx].handle);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -465,13 +448,13 @@ bt_status_t btc_hf_connect_audio(bt_bdaddr_t *bd_addr)
CHECK_HF_SLC_CONNECTED(idx);
if (is_connected(idx, bd_addr)) {
BTA_AgAudioOpen(hf_local_param[idx].btc_hf_cb.handle);
BTA_AgAudioOpen(hf_local_param.btc_hf_cb[idx].handle);
/* Inform the application that the audio connection has been initiated successfully */
do {
esp_hf_cb_param_t param;
memset(&param, 0, sizeof(esp_hf_cb_param_t));
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTING;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
memcpy(param.audio_stat.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda, sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while (0);
return BT_STATUS_SUCCESS;
@@ -485,7 +468,7 @@ bt_status_t btc_hf_disconnect_audio(bt_bdaddr_t *bd_addr)
CHECK_HF_SLC_CONNECTED(idx);
if (is_connected(idx, bd_addr)) {
BTA_AgAudioClose(hf_local_param[idx].btc_hf_cb.handle);
BTA_AgAudioClose(hf_local_param.btc_hf_cb[idx].handle);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -499,7 +482,7 @@ static bt_status_t btc_hf_pkt_stat_nums_get(UINT16 sync_conn_handle)
CHECK_HF_SLC_CONNECTED(idx);
if (idx != BTC_HF_INVALID_IDX) {
BTA_AgPktStatsNumsGet(hf_local_param[idx].btc_hf_cb.handle, sync_conn_handle);
BTA_AgPktStatsNumsGet(hf_local_param.btc_hf_cb[idx].handle, sync_conn_handle);
status = BT_STATUS_SUCCESS;
}
#endif /*#if (BTM_SCO_HCI_INCLUDED == TRUE) */
@@ -516,11 +499,11 @@ static bt_status_t btc_hf_vra(bt_bdaddr_t *bd_addr, esp_hf_vr_state_t value)
CHECK_HF_SLC_CONNECTED(idx);
if (is_connected(idx, bd_addr)) {
if (hf_local_param[idx].btc_hf_cb.peer_feat & BTA_AG_PEER_FEAT_VREC) {
if (hf_local_param.btc_hf_cb[idx].peer_feat & BTA_AG_PEER_FEAT_VREC) {
tBTA_AG_RES_DATA ag_res;
memset(&ag_res, 0, sizeof(ag_res));
ag_res.state = value;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_BVRA_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_BVRA_RES, &ag_res);
return BT_STATUS_SUCCESS;
} else {
return BT_STATUS_UNSUPPORTED;
@@ -538,7 +521,7 @@ static bt_status_t btc_hf_volume_control(bt_bdaddr_t *bd_addr, esp_hf_volume_typ
if (is_connected(idx, bd_addr)) {
ag_res.num = volume;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, (type == ESP_HF_VOLUME_TYPE_SPK) ? BTA_AG_SPK_RES : BTA_AG_MIC_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, (type == ESP_HF_VOLUME_TYPE_SPK) ? BTA_AG_SPK_RES : BTA_AG_MIC_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -562,7 +545,7 @@ static bt_status_t btc_hf_unat_response(bt_bdaddr_t *bd_addr, const char *unat)
ag_res.errcode = BTA_AG_ERR_OP_NOT_SUPPORTED;
}
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_UNAT_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_UNAT_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -583,7 +566,7 @@ static bt_status_t btc_hf_cmee_response(bt_bdaddr_t *bd_addr, esp_hf_at_response
ag_res.ok_flag = BTA_AG_OK_ERROR;
ag_res.errcode = error_code;
}
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_UNAT_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_UNAT_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -644,7 +627,7 @@ static bt_status_t btc_hf_cind_response(bt_bdaddr_t *bd_addr,
batt_lev, /* Battery level */
call_held_status /* Callheld state */
);
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_CIND_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_CIND_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -662,7 +645,7 @@ static bt_status_t btc_hf_cops_response(bt_bdaddr_t *bd_addr, const char *name)
/* Format the response */
sprintf(ag_res.str, "0,0,\"%s\"", name);
ag_res.ok_flag = BTA_AG_OK_DONE;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_COPS_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_COPS_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -694,7 +677,7 @@ static bt_status_t btc_hf_clcc_response(bt_bdaddr_t *bd_addr, int index, esp_hf_
}
}
}
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_CLCC_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_CLCC_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -716,7 +699,7 @@ static bt_status_t btc_hf_cnum_response(bt_bdaddr_t *bd_addr, const char *number
sprintf(ag_res.str, ",\"%s\",%d,,",number, number_type);
}
ag_res.ok_flag = BTA_AG_OK_DONE;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_CNUM_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_CNUM_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -732,7 +715,7 @@ static bt_status_t btc_hf_inband_ring(bt_bdaddr_t *bd_addr, esp_hf_in_band_ring_
tBTA_AG_RES_DATA ag_res;
memset (&ag_res, 0, sizeof (ag_res));
ag_res.state = state;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_INBAND_RING_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_INBAND_RING_RES, &ag_res);
return BT_STATUS_SUCCESS;
}
return BT_STATUS_FAIL;
@@ -750,8 +733,8 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
int idx = btc_hf_idx_by_bdaddr(bd_addr), i;
/* hf_idx is index of connected HS that sent ATA/BLDN, otherwise index of latest connected HS */
if (hf_local_param->hf_idx != BTC_HF_INVALID_IDX) {
idx = hf_local_param->hf_idx;
if (hf_local_param.hf_idx != BTC_HF_INVALID_IDX) {
idx = hf_local_param.hf_idx;
} else {
idx = btc_hf_latest_connected_idx();
}
@@ -759,28 +742,28 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
BTC_TRACE_DEBUG("phone_state_change: idx = %d", idx);
CHECK_HF_SLC_CONNECTED(idx);
BTC_TRACE_DEBUG("phone_state_change: num_active=%d [prev: %d] num_held=%d[prev: %d] call =%s [prev: %s] call_setup=%s [prev: %s]",
num_active, hf_local_param[idx].btc_hf_cb.num_active,
num_held, hf_local_param[idx].btc_hf_cb.num_held,
dump_hf_call_state(call_state), dump_hf_call_state(hf_local_param[idx].btc_hf_cb.call_state),
dump_hf_call_setup_state(call_setup_state), dump_hf_call_setup_state(hf_local_param[idx].btc_hf_cb.call_setup_state));
num_active, hf_local_param.btc_hf_cb[idx].num_active,
num_held, hf_local_param.btc_hf_cb[idx].num_held,
dump_hf_call_state(call_state), dump_hf_call_state(hf_local_param.btc_hf_cb[idx].call_state),
dump_hf_call_setup_state(call_setup_state), dump_hf_call_setup_state(hf_local_param.btc_hf_cb[idx].call_setup_state));
/* If all indicators are 0, send end call and return */
if (num_active == 0 && num_held == 0 && call_state == ESP_HF_CALL_STATUS_NO_CALLS && call_setup_state == ESP_HF_CALL_SETUP_STATUS_IDLE) {
BTC_TRACE_DEBUG("%s: Phone on hook", __FUNCTION__);
/* Record call termination timestamp if there was an active/held call or call_setup_state > ESP_HF_CALL_SETUP_STATUS_IDLE */
if ((hf_local_param[idx].btc_hf_cb.call_state != ESP_HF_CALL_STATUS_NO_CALLS) ||
(hf_local_param[idx].btc_hf_cb.call_setup_state != ESP_HF_CALL_SETUP_STATUS_IDLE) ||
(hf_local_param[idx].btc_hf_cb.num_active) ||
(hf_local_param[idx].btc_hf_cb.num_held)) {
if ((hf_local_param.btc_hf_cb[idx].call_state != ESP_HF_CALL_STATUS_NO_CALLS) ||
(hf_local_param.btc_hf_cb[idx].call_setup_state != ESP_HF_CALL_SETUP_STATUS_IDLE) ||
(hf_local_param.btc_hf_cb[idx].num_active) ||
(hf_local_param.btc_hf_cb[idx].num_held)) {
BTC_TRACE_DEBUG("%s: Record call termination timestamp", __FUNCTION__);
clock_gettime(CLOCK_MONOTONIC, &hf_local_param[0].btc_hf_cb.call_end_timestamp);
clock_gettime(CLOCK_MONOTONIC, &hf_local_param.btc_hf_cb[idx].call_end_timestamp);
}
BTA_AgResult(BTA_AG_HANDLE_ALL, BTA_AG_END_CALL_RES, NULL);
hf_local_param->hf_idx = BTC_HF_INVALID_IDX;
hf_local_param.hf_idx = BTC_HF_INVALID_IDX;
/* If held call was present, reset that as well. */
if (hf_local_param[idx].btc_hf_cb.num_held) {
if (hf_local_param.btc_hf_cb[idx].num_held) {
send_indicator_update(BTA_AG_IND_CALLHELD, 0);
}
goto update_call_states;
@@ -794,13 +777,13 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
/* Handle case(3) here prior to call setup handling.*/
if (((num_active + num_held) > 0) &&
(hf_local_param[idx].btc_hf_cb.num_active == 0) &&
(hf_local_param[idx].btc_hf_cb.num_held == 0) &&
(hf_local_param[idx].btc_hf_cb.call_setup_state == ESP_HF_CALL_SETUP_STATUS_IDLE)) {
(hf_local_param.btc_hf_cb[idx].num_active == 0) &&
(hf_local_param.btc_hf_cb[idx].num_held == 0) &&
(hf_local_param.btc_hf_cb[idx].call_setup_state == ESP_HF_CALL_SETUP_STATUS_IDLE)) {
BTC_TRACE_DEBUG("%s: Active/Held call notification received without call setup update", __FUNCTION__);
memset(&ag_res, 0, sizeof(tBTA_AG_RES_DATA));
ag_res.audio_handle = hf_local_param[idx].btc_hf_cb.handle;
ag_res.audio_handle = hf_local_param.btc_hf_cb[idx].handle;
/* Addition callsetup with the Active call. */
if (call_setup_state != ESP_HF_CALL_SETUP_STATUS_IDLE) {
@@ -816,9 +799,9 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
}
/* Handle call_setup indicator change. */
if (call_setup_state != hf_local_param[idx].btc_hf_cb.call_setup_state) {
if (call_setup_state != hf_local_param.btc_hf_cb[idx].call_setup_state) {
BTC_TRACE_DEBUG("%s: Call setup states changed. old: %s new: %s", __FUNCTION__,
dump_hf_call_setup_state(hf_local_param[idx].btc_hf_cb.call_setup_state),
dump_hf_call_setup_state(hf_local_param.btc_hf_cb[idx].call_setup_state),
dump_hf_call_setup_state(call_setup_state));
memset(&ag_res, 0, sizeof(tBTA_AG_RES_DATA));
@@ -826,14 +809,14 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
{
case ESP_HF_CALL_SETUP_STATUS_IDLE:
{
switch(hf_local_param[idx].btc_hf_cb.call_setup_state)
switch(hf_local_param.btc_hf_cb[idx].call_setup_state)
{
case ESP_HF_CALL_SETUP_STATUS_INCOMING:
{
if (num_active > hf_local_param[idx].btc_hf_cb.num_active) {
if (num_active > hf_local_param.btc_hf_cb[idx].num_active) {
res = BTA_AG_IN_CALL_CONN_RES;
ag_res.audio_handle = hf_local_param[idx].btc_hf_cb.handle;
} else if (num_held > hf_local_param[idx].btc_hf_cb.num_held) {
ag_res.audio_handle = hf_local_param.btc_hf_cb[idx].handle;
} else if (num_held > hf_local_param.btc_hf_cb[idx].num_held) {
res = BTA_AG_IN_CALL_HELD_RES;
} else {
res = BTA_AG_CALL_CANCEL_RES;
@@ -844,7 +827,7 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
case ESP_HF_CALL_SETUP_STATUS_OUTGOING_DIALING:
case ESP_HF_CALL_SETUP_STATUS_OUTGOING_ALERTING:
{
if (num_active > hf_local_param[idx].btc_hf_cb.num_active) {
if (num_active > hf_local_param.btc_hf_cb[idx].num_active) {
res = BTA_AG_OUT_CALL_CONN_RES;
ag_res.audio_handle = BTA_AG_HANDLE_SCO_NO_CHANGE;
} else {
@@ -887,7 +870,7 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
case ESP_HF_CALL_SETUP_STATUS_OUTGOING_DIALING:
{
if (!(num_active + num_held)) {
ag_res.audio_handle = hf_local_param[idx].btc_hf_cb.handle;
ag_res.audio_handle = hf_local_param.btc_hf_cb[idx].handle;
}
res = BTA_AG_OUT_CALL_ORIG_RES;
break;
@@ -895,9 +878,9 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
case ESP_HF_CALL_SETUP_STATUS_OUTGOING_ALERTING:
{
if ((hf_local_param[idx].btc_hf_cb.call_setup_state == ESP_HF_CALL_SETUP_STATUS_IDLE) &&
if ((hf_local_param.btc_hf_cb[idx].call_setup_state == ESP_HF_CALL_SETUP_STATUS_IDLE) &&
!(num_active + num_held)) {
ag_res.audio_handle = hf_local_param[idx].btc_hf_cb.handle;
ag_res.audio_handle = hf_local_param.btc_hf_cb[idx].handle;
/* Force SCO setup here.*/
BTA_AgAudioOpen(ag_res.audio_handle);
}
@@ -927,34 +910,34 @@ static bt_status_t btc_hf_phone_state_update(bt_bdaddr_t *bd_addr,int num_active
/* Handle call_state indicator change. */
if (!activeCallUpdated &&
((num_active + num_held) != (hf_local_param[idx].btc_hf_cb.num_active + hf_local_param[idx].btc_hf_cb.num_held))) {
BTC_TRACE_DEBUG("%s: Active call states changed. old: %d new: %d", __FUNCTION__, hf_local_param[idx].btc_hf_cb.num_active, num_active);
((num_active + num_held) != (hf_local_param.btc_hf_cb[idx].num_active + hf_local_param.btc_hf_cb[idx].num_held))) {
BTC_TRACE_DEBUG("%s: Active call states changed. old: %d new: %d", __FUNCTION__, hf_local_param.btc_hf_cb[idx].num_active, num_active);
send_indicator_update(BTA_AG_IND_CALL, ((num_active + num_held) > 0) ? 1 : 0);
}
/* Handle call_held_state indicator change. */
if (num_held != hf_local_param[idx].btc_hf_cb.num_held ||
((num_active == 0) && ((num_held + hf_local_param[idx].btc_hf_cb.num_held) > 1))) {
BTC_TRACE_DEBUG("%s: Held call states changed. old: %d new: %d", __FUNCTION__, hf_local_param[idx].btc_hf_cb.num_held, num_held);
if (num_held != hf_local_param.btc_hf_cb[idx].num_held ||
((num_active == 0) && ((num_held + hf_local_param.btc_hf_cb[idx].num_held) > 1))) {
BTC_TRACE_DEBUG("%s: Held call states changed. old: %d new: %d", __FUNCTION__, hf_local_param.btc_hf_cb[idx].num_held, num_held);
send_indicator_update(BTA_AG_IND_CALLHELD, ((num_held == 0) ? 0 : ((num_active == 0) ? 2 : 1)));
}
/* Handle Call Active/Held Swap indicator update.*/
if ((call_setup_state == hf_local_param[idx].btc_hf_cb.call_setup_state) &&
if ((call_setup_state == hf_local_param.btc_hf_cb[idx].call_setup_state) &&
(num_active) &&
(num_held) &&
(num_active == hf_local_param[idx].btc_hf_cb.num_active) &&
(num_held == hf_local_param[idx].btc_hf_cb.num_held)) {
(num_active == hf_local_param.btc_hf_cb[idx].num_active) &&
(num_held == hf_local_param.btc_hf_cb[idx].num_held)) {
BTC_TRACE_DEBUG("%s: Calls swapped", __FUNCTION__);
send_indicator_update(BTA_AG_IND_CALLHELD, 1);
}
update_call_states:
for (i = 0; i < btc_max_hf_clients; i++) {
hf_local_param[i].btc_hf_cb.num_active = num_active;
hf_local_param[i].btc_hf_cb.num_held = num_held;
hf_local_param[i].btc_hf_cb.call_state = call_state;
hf_local_param[i].btc_hf_cb.call_setup_state = call_setup_state;
hf_local_param.btc_hf_cb[i].num_active = num_active;
hf_local_param.btc_hf_cb[i].num_held = num_held;
hf_local_param.btc_hf_cb[i].call_state = call_state;
hf_local_param.btc_hf_cb[i].call_setup_state = call_setup_state;
}
return status;
}
@@ -967,7 +950,7 @@ bt_status_t btc_hf_ci_sco_data(void)
CHECK_HF_SLC_CONNECTED(idx);
if (idx != BTC_HF_INVALID_IDX) {
BTA_AgCiData(hf_local_param[idx].btc_hf_cb.handle);
BTA_AgCiData(hf_local_param.btc_hf_cb[idx].handle);
return status;
}
status = BT_STATUS_FAIL;
@@ -982,7 +965,7 @@ bool btc_hf_ag_audio_data_send(uint16_t sync_conn_hdl, uint8_t *p_buff_start, ui
int idx = btc_hf_latest_connected_idx();
CHECK_HF_SLC_CONNECTED(idx);
if (idx != BTC_HF_INVALID_IDX) {
BTA_AgAudioDataSend(hf_local_param[idx].btc_hf_cb.handle, p_buff_start, p_data, data_len);
BTA_AgAudioDataSend(hf_local_param.btc_hf_cb[idx].handle, p_buff_start, p_data, data_len);
return true;
}
#endif
@@ -1342,17 +1325,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
break;
case BTA_AG_DISABLE_EVT:
{
idx = 0;
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param)
#endif
{
if (hf_local_param[idx].btc_hf_cb.initialized) {
hf_local_param[idx].btc_hf_cb.initialized = false;
btc_hf_cb_release();
param.prof_stat.state = ESP_HF_DEINIT_SUCCESS;
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
}
if (hf_local_param.initialized) {
hf_local_param.initialized = false;
btc_hf_cb_release();
param.prof_stat.state = ESP_HF_DEINIT_SUCCESS;
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
}
break;
}
@@ -1360,14 +1337,14 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
hf_local_param[idx].btc_hf_cb.handle = p_data->reg.hdr.handle;
BTC_TRACE_DEBUG("%s: BTA_AG_REGISTER_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d",
__FUNCTION__, idx, hf_local_param[idx].btc_hf_cb.handle);
if (!hf_local_param[idx].btc_hf_cb.initialized) {
hf_local_param.btc_hf_cb[idx].handle = p_data->reg.hdr.handle;
BTC_TRACE_DEBUG("%s: BTA_AG_REGISTER_EVT," "hf_hf_cb[%d].btc_hf_cb.handle = %d",
__FUNCTION__, idx, hf_local_param.btc_hf_cb[idx].handle);
if (!hf_local_param.initialized) {
param.prof_stat.state = ESP_HF_INIT_SUCCESS;
btc_hf_cb_to_app(ESP_HF_PROF_STATE_EVT, &param);
}
hf_local_param[idx].btc_hf_cb.initialized = true;
hf_local_param.initialized = true;
break;
}
@@ -1377,30 +1354,30 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
if (p_data->open.hdr.status == BTA_AG_SUCCESS)
{
bdcpy(hf_local_param[idx].btc_hf_cb.connected_bda.address, p_data->open.bd_addr);
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_CONNECTED;
hf_local_param[idx].btc_hf_cb.peer_feat = 0;
hf_local_param[idx].btc_hf_cb.chld_feat = 0;
bdcpy(hf_local_param.btc_hf_cb[idx].connected_bda.address, p_data->open.bd_addr);
hf_local_param.btc_hf_cb[idx].connection_state = ESP_HF_CONNECTION_STATE_CONNECTED;
hf_local_param.btc_hf_cb[idx].peer_feat = 0;
hf_local_param.btc_hf_cb[idx].chld_feat = 0;
//clear_phone_state();
} else if (hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_CONNECTING) {
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
} else if (hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_CONNECTING) {
hf_local_param.btc_hf_cb[idx].connection_state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
} else {
BTC_TRACE_WARNING("%s: AG open failed, but another device connected. status=%d state=%d connected device=%s", __FUNCTION__,
p_data->open.hdr.status, hf_local_param[idx].btc_hf_cb.connection_state,
bdaddr_to_string(&hf_local_param[idx].btc_hf_cb.connected_bda, bdstr, sizeof(bdstr)));
p_data->open.hdr.status, hf_local_param.btc_hf_cb[idx].connection_state,
bdaddr_to_string(&hf_local_param.btc_hf_cb[idx].connected_bda, bdstr, sizeof(bdstr)));
break;
}
do {
memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
memcpy(param.conn_stat.remote_bda, &hf_local_param.btc_hf_cb[idx].connected_bda, sizeof(esp_bd_addr_t));
param.conn_stat.state = hf_local_param.btc_hf_cb[idx].connection_state;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
btc_hf_cb_to_app(ESP_HF_CONNECTION_STATE_EVT, &param);
} while (0);
if (hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_DISCONNECTED)
bdsetany(hf_local_param[idx].btc_hf_cb.connected_bda.address);
if (hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_DISCONNECTED)
bdsetany(hf_local_param.btc_hf_cb[idx].connected_bda.address);
if (p_data->open.hdr.status != BTA_AG_SUCCESS)
btc_queue_advance();
@@ -1411,20 +1388,20 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
clock_gettime(CLOCK_MONOTONIC, &(hf_local_param[idx].btc_hf_cb.connected_timestamp));
clock_gettime(CLOCK_MONOTONIC, &(hf_local_param.btc_hf_cb[idx].connected_timestamp));
BTC_TRACE_DEBUG("%s: BTA_AG_CONN_EVT, idx = %d ", __FUNCTION__, idx);
hf_local_param[idx].btc_hf_cb.peer_feat = p_data->conn.peer_feat;
hf_local_param[idx].btc_hf_cb.chld_feat = p_data->conn.chld_feat;
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED;
hf_local_param.btc_hf_cb[idx].peer_feat = p_data->conn.peer_feat;
hf_local_param.btc_hf_cb[idx].chld_feat = p_data->conn.chld_feat;
hf_local_param.btc_hf_cb[idx].connection_state = ESP_HF_CONNECTION_STATE_SLC_CONNECTED;
do {
param.conn_stat.state = hf_local_param[idx].btc_hf_cb.connection_state;
param.conn_stat.peer_feat = hf_local_param[idx].btc_hf_cb.peer_feat;
param.conn_stat.chld_feat = hf_local_param[idx].btc_hf_cb.chld_feat;
memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
param.conn_stat.state = hf_local_param.btc_hf_cb[idx].connection_state;
param.conn_stat.peer_feat = hf_local_param.btc_hf_cb[idx].peer_feat;
param.conn_stat.chld_feat = hf_local_param.btc_hf_cb[idx].chld_feat;
memcpy(param.conn_stat.remote_bda, &hf_local_param.btc_hf_cb[idx].connected_bda, sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CONNECTION_STATE_EVT, &param);
} while(0);
hf_local_param[idx].hf_idx = btc_hf_latest_connected_idx();
hf_local_param.hf_idx = btc_hf_latest_connected_idx();
btc_queue_advance();
break;
}
@@ -1433,20 +1410,20 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
hf_local_param[idx].btc_hf_cb.connected_timestamp.tv_sec = 0;
hf_local_param[idx].btc_hf_cb.connection_state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param[%d].btc_hf_cb.handle = %d", __FUNCTION__,
idx, hf_local_param[idx].btc_hf_cb.handle);
hf_local_param.btc_hf_cb[idx].connected_timestamp.tv_sec = 0;
hf_local_param.btc_hf_cb[idx].connection_state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
BTC_TRACE_DEBUG("%s: BTA_AG_CLOSE_EVT," "hf_local_param.btc_hf_cb[%d].handle = %d", __FUNCTION__,
idx, hf_local_param.btc_hf_cb[idx].handle);
do {
param.conn_stat.state = ESP_HF_CONNECTION_STATE_DISCONNECTED;
param.conn_stat.peer_feat = 0;
param.conn_stat.chld_feat = 0;
memcpy(param.conn_stat.remote_bda, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
memcpy(param.conn_stat.remote_bda, &hf_local_param.btc_hf_cb[idx].connected_bda, sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CONNECTION_STATE_EVT, &param);
} while(0);
bdsetany(hf_local_param[idx].btc_hf_cb.connected_bda.address);
bdsetany(hf_local_param.btc_hf_cb[idx].connected_bda.address);
clear_phone_state();
hf_local_param[idx].hf_idx = btc_hf_latest_connected_idx();
hf_local_param.hf_idx = btc_hf_latest_connected_idx();
btc_queue_advance();
break;
}
@@ -1457,8 +1434,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
hf_local_param[idx].btc_hf_cb.sync_conn_hdl = p_data->hdr.sync_conn_handle;
memcpy(param.audio_stat.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
hf_local_param.btc_hf_cb[idx].sync_conn_hdl = p_data->hdr.sync_conn_handle;
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
param.audio_stat.preferred_frame_size = p_data->audio_stat.preferred_frame_size;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
@@ -1472,8 +1449,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
param.audio_stat.state = ESP_HF_AUDIO_STATE_CONNECTED_MSBC;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
hf_local_param[idx].btc_hf_cb.sync_conn_hdl = p_data->hdr.sync_conn_handle;
memcpy(param.audio_stat.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
hf_local_param.btc_hf_cb[idx].sync_conn_hdl = p_data->hdr.sync_conn_handle;
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
param.audio_stat.preferred_frame_size = p_data->audio_stat.preferred_frame_size;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
@@ -1486,8 +1463,8 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
param.audio_stat.state = ESP_HF_AUDIO_STATE_DISCONNECTED;
hf_local_param[idx].btc_hf_cb.sync_conn_hdl = ESP_INVALID_CONN_HANDLE;
memcpy(param.audio_stat.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda, sizeof(esp_bd_addr_t));
hf_local_param.btc_hf_cb[idx].sync_conn_hdl = ESP_INVALID_CONN_HANDLE;
memcpy(param.audio_stat.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda, sizeof(esp_bd_addr_t));
param.audio_stat.sync_conn_handle = p_data->hdr.sync_conn_handle;
btc_hf_cb_to_app(ESP_HF_AUDIO_STATE_EVT, &param);
} while(0);
@@ -1500,12 +1477,12 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
param.vra_rep.value = p_data->val.num;
memcpy(param.vra_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.vra_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_BVRA_RESPONSE_EVT, &param);
if (p_data->val.num) {
btc_hf_connect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda);
btc_hf_connect_audio(&hf_local_param.btc_hf_cb[idx].connected_bda);
} else {
btc_hf_disconnect_audio(&hf_local_param[idx].btc_hf_cb.connected_bda);
btc_hf_disconnect_audio(&hf_local_param.btc_hf_cb[idx].connected_bda);
}
} while (0);
break;
@@ -1517,7 +1494,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.volume_control.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.volume_control.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.volume_control.type = (event == BTA_AG_SPK_EVT) ? ESP_HF_VOLUME_CONTROL_TARGET_SPK : ESP_HF_VOLUME_CONTROL_TARGET_MIC;
param.volume_control.volume = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_VOLUME_CONTROL_EVT, &param);
@@ -1530,7 +1507,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.unat_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.unat_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.unat_rep.unat = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_UNAT_RESPONSE_EVT, &param);
} while (0);
@@ -1541,7 +1518,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ind_upd.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.ind_upd.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_IND_UPDATE_EVT, &param);
break;
}
@@ -1550,7 +1527,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cind_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.cind_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CIND_RESPONSE_EVT, &param);
break;
}
@@ -1559,7 +1536,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cops_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.cops_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_COPS_RESPONSE_EVT, &param);
break;
}
@@ -1568,7 +1545,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.clcc_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.clcc_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CLCC_RESPONSE_EVT, &param);
break;
}
@@ -1577,7 +1554,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.cnum_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.cnum_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CNUM_RESPONSE_EVT, &param);
break;
}
@@ -1587,7 +1564,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.vts_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.vts_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.vts_rep.code = p_data->val.str;
btc_hf_cb_to_app(ESP_HF_VTS_RESPONSE_EVT, &param);
} while(0);
@@ -1599,7 +1576,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
do {
memcpy(param.nrec.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.nrec.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.nrec.state = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_NREC_RESPONSE_EVT, &param);
} while(0);
@@ -1610,7 +1587,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.ata_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.ata_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_ATA_RESPONSE_EVT, &param);
break;
}
@@ -1619,7 +1596,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
{
idx = p_data->hdr.handle - 1;
CHECK_HF_IDX(idx);
memcpy(param.chup_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.chup_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
btc_hf_cb_to_app(ESP_HF_CHUP_RESPONSE_EVT, &param);
break;
}
@@ -1631,14 +1608,14 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
if (event == BTA_AG_AT_D_EVT) { // dial_number_or_memory
memcpy(param.out_call.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.out_call.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.out_call.type = p_data->val.value;
param.out_call.num_or_loc = osi_malloc((strlen(p_data->val.str) + 1) * sizeof(char));
sprintf(param.out_call.num_or_loc, "%s", p_data->val.str);
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
osi_free(param.out_call.num_or_loc);
} else if (event == BTA_AG_AT_BLDN_EVT) { //dial_last
memcpy(param.out_call.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.out_call.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.out_call.num_or_loc = NULL;
btc_hf_cb_to_app(ESP_HF_DIAL_EVT, &param);
}
@@ -1655,7 +1632,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
memset(&ag_res, 0, sizeof(ag_res));
ag_res.ok_flag = BTA_AG_OK_ERROR;
ag_res.errcode = BTA_AG_ERR_OP_NOT_SUPPORTED;
BTA_AgResult(hf_local_param[idx].btc_hf_cb.handle, BTA_AG_UNAT_RES, &ag_res);
BTA_AgResult(hf_local_param.btc_hf_cb[idx].handle, BTA_AG_UNAT_RES, &ag_res);
break;
}
@@ -1670,11 +1647,11 @@ void btc_hf_cb_handler(btc_msg_t *msg)
** of SCO connection establishment */
if ((btc_conf_hf_force_wbs == TRUE) && (p_data->val.num & BTA_AG_CODEC_MSBC)) {
BTC_TRACE_DEBUG("%s btc_hf override-Preferred Codec to MSBC", __FUNCTION__);
BTA_AgSetCodec(hf_local_param[idx].btc_hf_cb.handle,BTA_AG_CODEC_MSBC);
BTA_AgSetCodec(hf_local_param.btc_hf_cb[idx].handle,BTA_AG_CODEC_MSBC);
}
else {
BTC_TRACE_DEBUG("%s btc_hf override-Preferred Codec to CVSD", __FUNCTION__);
BTA_AgSetCodec(hf_local_param[idx].btc_hf_cb.handle,BTA_AG_CODEC_CVSD);
BTA_AgSetCodec(hf_local_param.btc_hf_cb[idx].handle,BTA_AG_CODEC_CVSD);
}
#endif
break;
@@ -1686,7 +1663,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("Set codec status %d codec %d 1=CVSD 2=MSBC", p_data->val.hdr.status, p_data->val.num);
memcpy(param.wbs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.wbs_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.wbs_rep.codec = p_data->val.num;
btc_hf_cb_to_app(ESP_HF_WBS_RESPONSE_EVT, &param);
} while (0);
@@ -1699,7 +1676,7 @@ void btc_hf_cb_handler(btc_msg_t *msg)
CHECK_HF_IDX(idx);
do {
BTC_TRACE_DEBUG("AG final seleded codec is %d 1=CVSD 2=MSBC", p_data->val.num);
memcpy(param.bcs_rep.remote_addr, &hf_local_param[idx].btc_hf_cb.connected_bda,sizeof(esp_bd_addr_t));
memcpy(param.bcs_rep.remote_addr, &hf_local_param.btc_hf_cb[idx].connected_bda,sizeof(esp_bd_addr_t));
param.bcs_rep.mode = p_data->val.num;
/* No ESP_HF_WBS_NONE case, because HFP 1.6 supported device can send BCS */
btc_hf_cb_to_app(ESP_HF_BCS_RESPONSE_EVT, &param);
@@ -1723,18 +1700,16 @@ void btc_hf_get_profile_status(esp_hf_profile_status_t *param)
{
param->hfp_ag_inited = false; // Not initialized by default
#if HFP_DYNAMIC_MEMORY == TRUE
if (hf_local_param)
#endif
{
if (hf_local_param.initialized) {
param->hfp_ag_inited = true;
}
if (hf_local_param.btc_hf_cb != NULL) {
for (int idx = 0; idx < BTC_HF_NUM_CB; idx++) {
if (hf_local_param[idx].btc_hf_cb.initialized) {
param->hfp_ag_inited = true;
if (hf_local_param[idx].btc_hf_cb.connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED) {
param->slc_conn_num++;
if (hf_local_param[idx].btc_hf_cb.sync_conn_hdl != ESP_INVALID_CONN_HANDLE) {
param->sync_conn_num++;
}
if (hf_local_param.btc_hf_cb[idx].connection_state == ESP_HF_CONNECTION_STATE_SLC_CONNECTED) {
param->slc_conn_num++;
if (hf_local_param.btc_hf_cb[idx].sync_conn_hdl != ESP_INVALID_CONN_HANDLE) {
param->sync_conn_num++;
}
}
}
@@ -215,7 +215,6 @@ typedef union
/* BTC-AG control block to map bdaddr to BTA handle */
typedef struct
{
bool initialized;
UINT16 handle;
UINT16 sync_conn_hdl;
bt_bdaddr_t connected_bda;
@@ -233,9 +232,9 @@ typedef struct
typedef struct
{
bool initialized;
int hf_idx;
UINT32 btc_hf_features;
btc_hf_cb_t btc_hf_cb;
btc_hf_cb_t *btc_hf_cb;
esp_hf_incoming_data_cb_t btc_hf_incoming_data_cb;
esp_hf_outgoing_data_cb_t btc_hf_outgoing_data_cb;
esp_hf_ag_audio_data_cb_t btc_hf_audio_data_cb;
@@ -243,7 +242,7 @@ typedef struct
#if HFP_DYNAMIC_MEMORY == TRUE
extern hf_local_param_t *hf_local_param_ptr;
#define hf_local_param (hf_local_param_ptr)
#define hf_local_param (*hf_local_param_ptr)
#endif
/*******************************************************************************
+18 -8
View File
@@ -751,9 +751,11 @@ config BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
Enable this option to include *included services* (e.g., services referenced by other services)
in the GATT database cache. Disabling this will skip caching of included service entries.
config BT_NIMBLE_INCL_SVC_DISCOVERY
bool "Enable Included service discovery"
default y if BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
default n
bool
default y if BT_NIMBLE_GATT_CACHING && BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
default n if BT_NIMBLE_GATT_CACHING && !BT_NIMBLE_GATT_CACHING_INCLUDE_SERVICES
default n if !BT_NIMBLE_GATT_CACHING
prompt "Enable Included service discovery" if !BT_NIMBLE_GATT_CACHING
help
Enable this option to start discovery for included service.
config BT_NIMBLE_GATT_CACHING_MAX_CONNS
@@ -899,7 +901,7 @@ menu "BLE Services"
Enable HeartRate Service support
menuconfig BT_NIMBLE_HID_SERVICE
bool "HID service"
bool "Human Interface Device service"
default n
help
Enable HID service support
@@ -931,10 +933,10 @@ menu "BLE Services"
Enable/Disable notifications on BAS Battery Level Characteristic
menuconfig BT_NIMBLE_DIS_SERVICE
bool "DIS service"
bool "Device Information Service"
default y
help
Enable DIS service support
Enable Device Information service support
config BT_NIMBLE_SVC_DIS_MANUFACTURER_NAME
depends on BT_NIMBLE_DIS_SERVICE
@@ -1076,7 +1078,6 @@ menu "BLE Services"
default 0 if BT_NIMBLE_SVC_GAP_CAR_NOT_SUPP
default 1 if BT_NIMBLE_SVC_GAP_CAR_SUPP
menu "GAP device name write permissions"
depends on BT_NIMBLE_GAP_SERVICE
config BT_NIMBLE_SVC_GAP_NAME_WRITE
@@ -1107,7 +1108,7 @@ menu "BLE Services"
Enable write with authorisation permission (BLE_GATT_CHR_F_WRITE_AUTHOR)
endmenu
menu "PPCP settings"
menu "Peripheral Preferred Connection Parameters (PPCP) settings"
depends on BT_NIMBLE_GAP_SERVICE
config BT_NIMBLE_SVC_GAP_PPCP_MAX_CONN_INTERVAL
int "PPCP Connection Interval Max (Unit: 1.25 ms)"
@@ -1233,6 +1234,15 @@ config BT_NIMBLE_GATTC_PROC_PREEMPTION_PROTECT
can disrupt the GATT context,causing the service discovery callback to not be invoked.
A temporary list is maintained to preserve the GATT context and use it in case of preemption.
config BT_NIMBLE_GATTC_AUTO_PAIR
bool "Automatically pair upon receiving service request failure"
depends on BT_NIMBLE_ENABLED
default n
help
If enabled, when a service request (e.g. read, write) to a server fails, and the ATT
error suggests insufficient security, then the central will initiate pairing and retry
the service request.
menu "Host-controller Transport"
config BT_NIMBLE_TRANSPORT_UART
bool "Enable Uart Transport"
@@ -2010,6 +2010,14 @@
#endif
#endif
#ifndef MYNEWT_VAL_BLE_GATTC_AUTO_PAIR
#ifdef CONFIG_BT_NIMBLE_GATTC_AUTO_PAIR
#define MYNEWT_VAL_BLE_GATTC_AUTO_PAIR CONFIG_BT_NIMBLE_GATTC_AUTO_PAIR
#else
#define MYNEWT_VAL_BLE_GATTC_AUTO_PAIR (0)
#endif
#endif
#ifndef MYNEWT_VAL_BLE_HOST_ALLOW_CONNECT_WITH_SCAN
#ifdef CONFIG_BT_NIMBLE_HOST_ALLOW_CONNECT_WITH_SCAN
#define MYNEWT_VAL_BLE_HOST_ALLOW_CONNECT_WITH_SCAN CONFIG_BT_NIMBLE_HOST_ALLOW_CONNECT_WITH_SCAN
-47
View File
@@ -16,46 +16,16 @@ set(includes "deprecated"
# Always included linker fragments
set(ldfragments "")
# ADC related source files (deprecated)
if(CONFIG_SOC_ADC_SUPPORTED)
list(APPEND srcs "deprecated/adc_legacy.c")
if(CONFIG_SOC_ADC_DMA_SUPPORTED)
list(APPEND srcs "deprecated/adc_dma_legacy.c")
endif()
endif()
# DAC related source files
if(CONFIG_SOC_DAC_SUPPORTED)
list(APPEND srcs "deprecated/dac_common_legacy.c"
"deprecated/${target}/dac_legacy.c")
endif()
# GPTimer legacy driver
if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "deprecated/timer_legacy.c")
endif()
# I2C related source files
if(CONFIG_SOC_I2C_SUPPORTED)
list(APPEND srcs "i2c/i2c.c")
endif()
# I2S related source files
if(CONFIG_SOC_I2S_SUPPORTED)
list(APPEND srcs "deprecated/i2s_legacy.c")
endif()
# MCPWM legacy driver
if(CONFIG_SOC_MCPWM_SUPPORTED)
list(APPEND srcs "deprecated/mcpwm_legacy.c")
endif()
# PCNT legacy driver
if(CONFIG_SOC_PCNT_SUPPORTED)
list(APPEND srcs "deprecated/pcnt_legacy.c")
endif()
# RMT legacy driver
if(CONFIG_SOC_RMT_SUPPORTED)
list(APPEND srcs "deprecated/rmt_legacy.c")
@@ -66,11 +36,6 @@ if(CONFIG_SOC_SDM_SUPPORTED)
list(APPEND srcs "deprecated/sigma_delta_legacy.c")
endif()
# Temperature Sensor related source files
if(CONFIG_SOC_TEMP_SENSOR_SUPPORTED)
list(APPEND srcs "deprecated/rtc_temperature_legacy.c")
endif()
# Touch Sensor related source files
if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED)
if(CONFIG_SOC_TOUCH_SENSOR_VERSION LESS 3)
@@ -87,18 +52,11 @@ if(CONFIG_SOC_TWAI_SUPPORTED AND NOT CONFIG_SOC_TWAI_SUPPORT_FD)
list(APPEND ldfragments "twai/linker.lf")
endif()
# Other source files
if(${target} STREQUAL "esp32")
list(APPEND srcs "deprecated/adc_i2s_deprecated.c")
endif()
if(BOOTLOADER_BUILD)
# Bootloader shall NOT depend on the drivers
idf_component_register()
else()
# (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent)
# (Legacy drivers requires `esp_adc`, due to ADC HW resource mutex logics are there.
# Can be removed together with legacy drivers)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS ${includes}
PRIV_REQUIRES efuse esp_timer esp_mm
@@ -112,9 +70,4 @@ else()
esp_driver_twai
LDFRAGMENTS ${ldfragments}
)
if(CONFIG_SOC_ADC_SUPPORTED AND
CONFIG_COMPILER_STATIC_ANALYZER AND CMAKE_C_COMPILER_ID STREQUAL "GNU") # TODO GCC-366
set_source_files_properties(deprecated/adc_legacy.c
PROPERTIES COMPILE_FLAGS "-Wno-analyzer-use-of-uninitialized-value")
endif()
endif()
-134
View File
@@ -2,89 +2,6 @@ menu "Driver Configurations"
orsource "./twai/Kconfig.twai"
menu "Legacy ADC Driver Configuration"
config ADC_DISABLE_DAC
depends on SOC_DAC_SUPPORTED
bool "Disable DAC when ADC2 is used on GPIO 25 and 26"
default y
help
If this is set, the ADC2 driver will disable the output of the DAC corresponding to the specified
channel. This is the default value.
For testing, disable this option so that we can measure the output of DAC by internal ADC.
config ADC_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Whether to suppress the deprecation warnings when using legacy adc driver (driver/adc.h).
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config ADC_SKIP_LEGACY_CONFLICT_CHECK
bool "Skip legacy conflict check"
default n
help
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
menu "Legacy ADC Calibration Configuration"
config ADC_CAL_EFUSE_TP_ENABLE
depends on IDF_TARGET_ESP32
bool "Use Two Point Values"
default "y"
help
Some ESP32s have Two Point calibration values burned into eFuse BLOCK3.
This option will allow the ADC calibration component to characterize the
ADC-Voltage curve using Two Point values if they are available.
config ADC_CAL_EFUSE_VREF_ENABLE
depends on IDF_TARGET_ESP32
bool "Use eFuse Vref"
default "y"
help
Some ESP32s have Vref burned into eFuse BLOCK0. This option will allow
the ADC calibration component to characterize the ADC-Voltage curve using
eFuse Vref if it is available.
config ADC_CAL_LUT_ENABLE
depends on IDF_TARGET_ESP32
bool "Use Lookup Tables"
default "y"
help
This option will allow the ADC calibration component to use Lookup Tables
to correct for non-linear behavior in 11db attenuation. Other attenuations
do not exhibit non-linear behavior hence will not be affected by this option.
config ADC_CALI_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Whether to suppress the deprecation warnings when using legacy adc calibration
driver (esp_adc_cal.h).
If you want to continue using the legacy driver, and don't want to see related
deprecation warnings, you can enable this option.
endmenu # Legacy ADC Calibration Configuration
endmenu # Legacy ADC Driver Configuration
menu "Legacy DAC Driver Configurations"
depends on SOC_DAC_SUPPORTED
config DAC_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Whether to suppress the deprecation warnings when using legacy dac driver (driver/dac.h).
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config DAC_SKIP_LEGACY_CONFLICT_CHECK
bool "Skip legacy conflict check"
default n
help
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy DAC Driver Configurations
menu "Legacy MCPWM Driver Configurations"
depends on SOC_MCPWM_SUPPORTED
config MCPWM_SUPPRESS_DEPRECATE_WARN
@@ -102,23 +19,6 @@ menu "Driver Configurations"
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy MCPWM Driver Configurations
menu "Legacy Timer Group Driver Configurations"
depends on SOC_GPTIMER_SUPPORTED
config GPTIMER_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Whether to suppress the deprecation warnings when using legacy timer group driver (driver/timer.h).
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config GPTIMER_SKIP_LEGACY_CONFLICT_CHECK
bool "Skip legacy conflict check"
default n
help
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy Timer Group Driver Configurations
menu "Legacy RMT Driver Configurations"
depends on SOC_RMT_SUPPORTED
config RMT_SUPPRESS_DEPRECATE_WARN
@@ -136,23 +36,6 @@ menu "Driver Configurations"
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy RMT Driver Configurations
menu "Legacy I2S Driver Configurations"
depends on SOC_I2S_SUPPORTED
config I2S_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
Whether to suppress the deprecation warnings when using legacy i2s driver (driver/i2s.h).
If you want to continue using the legacy driver, and don't want to see related deprecation warnings,
you can enable this option.
config I2S_SKIP_LEGACY_CONFLICT_CHECK
bool "Skip legacy conflict check"
default n
help
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy I2S Driver Configurationss
menu "Legacy I2C Driver Configurations"
depends on SOC_I2C_SUPPORTED
config I2C_SKIP_LEGACY_CONFLICT_CHECK
@@ -196,23 +79,6 @@ menu "Driver Configurations"
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy SDM Driver Configurationss
menu "Legacy Temperature Sensor Driver Configurations"
depends on SOC_TEMP_SENSOR_SUPPORTED
config TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
bool "Suppress legacy driver deprecated warning"
default n
help
whether to suppress the deprecation warnings when using legacy temperature sensor driver
(driver/temp_sensor.h). If you want to continue using the legacy driver,
and don't want to see related deprecation warnings, you can enable this option.
config TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
bool "Skip legacy conflict check"
default n
help
This configuration option allows the user to bypass the conflict check mechanism with legacy code.
endmenu # Legacy Temperature Sensor Driver Configurationss
menu "Legacy Touch Sensor Driver Configurations"
depends on SOC_TOUCH_SENSOR_SUPPORTED
config TOUCH_SUPPRESS_DEPRECATE_WARN
@@ -1,51 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#include "esp_err.h"
/**
* @brief For I2S dma to claim the usage of ADC1.
*
* Other tasks will be forbidden to use ADC1 between ``adc1_dma_mode_acquire`` and ``adc1_i2s_release``.
* The I2S module may have to wait for a short time for the current conversion (if exist) to finish.
*
* @return
* - ESP_OK success
* - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success.
*/
esp_err_t adc1_dma_mode_acquire(void);
/**
* @brief For ADC1 to claim the usage of ADC1.
*
* Other tasks will be forbidden to use ADC1 between ``adc1_rtc_mode_acquire`` and ``adc1_i2s_release``.
* The ADC1 may have to wait for some time for the I2S read operation to finish.
*
* @return
* - ESP_OK success
* - ESP_ERR_TIMEOUT reserved for future use. Currently the function will wait until success.
*/
esp_err_t adc1_rtc_mode_acquire(void);
/**
* @brief to let other tasks use the ADC1 when I2S is not work.
*
* Other tasks will be forbidden to use ADC1 between ``adc1_adc/i2s_mode_acquire`` and ``adc1_i2s_release``.
* Call this function to release the occupation of ADC1
*
* @return always return ESP_OK.
*/
esp_err_t adc1_lock_release(void);
#ifdef __cplusplus
}
#endif
@@ -1,676 +0,0 @@
/*
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <esp_types.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include "sdkconfig.h"
#include "soc/soc_caps.h"
#include "esp_intr_alloc.h"
#include "esp_log.h"
#include "esp_pm.h"
#include "esp_check.h"
#include "sys/lock.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/timers.h"
#include "freertos/ringbuf.h"
#include "esp_private/esp_clk_tree_common.h"
#include "esp_private/periph_ctrl.h"
#include "esp_private/adc_share_hw_ctrl.h"
#include "esp_private/sar_periph_ctrl.h"
#include "hal/adc_types.h"
#include "hal/adc_hal.h"
#include "hal/dma_types.h"
#include "hal/adc_hal_common.h"
#include "esp_private/regi2c_ctrl.h"
#include "driver/gpio.h"
#include "driver/adc_types_legacy.h"
//For calibration
#if CONFIG_IDF_TARGET_ESP32S2
#include "esp_efuse_rtc_table.h"
#elif SOC_ADC_CALIBRATION_V1_SUPPORTED
#include "esp_efuse_rtc_calib.h"
#endif
//For DMA
#if SOC_GDMA_SUPPORTED
#include "esp_private/gdma.h"
#elif CONFIG_IDF_TARGET_ESP32S2
#include "hal/spi_types.h"
#include "esp_private/spi_common_internal.h"
#elif CONFIG_IDF_TARGET_ESP32
#include "driver/i2s_types.h"
#include "soc/i2s_periph.h"
#include "esp_private/i2s_platform.h"
#endif
static const char *ADC_TAG = "ADC";
#define ADC_GET_IO_NUM(periph, channel) (adc_channel_io_map[periph][channel])
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
#define ADC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
#define ADC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
#define INTERNAL_BUF_NUM 5
#if SOC_AHB_GDMA_SUPPORTED
#define ADC_GDMA_HOST 0
#define ADC_DMA_INTR_MASK GDMA_LL_EVENT_RX_SUC_EOF
#define ADC_DMA_INTR_MASK GDMA_LL_EVENT_RX_SUC_EOF
#define adc_dma_start(adc_dma, addr) gdma_start(s_adc_digi_ctx->rx_dma_channel, (intptr_t)addr)
#define adc_dma_stop(adc_dma) gdma_stop(s_adc_digi_ctx->rx_dma_channel)
#define adc_dma_reset(adc_dma) gdma_reset(s_adc_digi_ctx->rx_dma_channel)
#define adc_dma_clear_intr(adc_dma)
#define adc_dma_enable_intr(adc_dma)
#define adc_dma_disable_intr(adc_dma)
#define adc_dma_deinit(adc_dma) do { \
gdma_disconnect(s_adc_digi_ctx->rx_dma_channel); \
gdma_del_channel(s_adc_digi_ctx->rx_dma_channel); \
} while (0)
#elif CONFIG_IDF_TARGET_ESP32S2
#define ADC_DMA_SPI_HOST SPI3_HOST
#define ADC_DMA_INTR_MASK SPI_LL_INTR_IN_SUC_EOF
#define adc_dma_start(adc_dma, addr) spi_dma_ll_rx_start(s_adc_digi_ctx->adc_spi_dev, s_adc_digi_ctx->spi_dma_ctx->rx_dma_chan.chan_id, (lldesc_t *)addr)
#define adc_dma_stop(adc_dma) spi_dma_ll_rx_stop(s_adc_digi_ctx->adc_spi_dev, s_adc_digi_ctx->spi_dma_ctx->rx_dma_chan.chan_id);
#define adc_dma_reset(adc_dma) spi_dma_ll_rx_reset(s_adc_digi_ctx->adc_spi_dev, s_adc_digi_ctx->spi_dma_ctx->rx_dma_chan.chan_id);
#define adc_dma_clear_intr(adc_dma) spi_ll_clear_intr(s_adc_digi_ctx->adc_spi_dev, ADC_DMA_INTR_MASK)
#define adc_dma_enable_intr(adc_dma) spi_ll_enable_intr(s_adc_digi_ctx->adc_spi_dev, ADC_DMA_INTR_MASK);
#define adc_dma_disable_intr(adc_dma) spi_ll_disable_intr(s_adc_digi_ctx->adc_spi_dev, ADC_DMA_INTR_MASK);
#define adc_dma_deinit(adc_dma) do { \
esp_intr_free(s_adc_digi_ctx->intr_hdl); \
spicommon_dma_chan_free(s_adc_digi_ctx->spi_dma_ctx); \
spicommon_periph_free(ADC_DMA_SPI_HOST); \
} while (0)
#elif CONFIG_IDF_TARGET_ESP32
#define ADC_DMA_I2S_HOST I2S_NUM_0
#define ADC_DMA_INTR_MASK BIT(9)
#define adc_dma_start(adc_dma, addr) do { \
i2s_ll_enable_dma(s_adc_digi_ctx->adc_i2s_dev, true); \
i2s_ll_rx_start_link(s_adc_digi_ctx->adc_i2s_dev, (uint32_t)addr); \
} while (0)
#define adc_dma_stop(adc_dma) i2s_ll_rx_stop_link(s_adc_digi_ctx->adc_i2s_dev);
#define adc_dma_reset(adc_dma) i2s_ll_rx_reset_dma(s_adc_digi_ctx->adc_i2s_dev);
#define adc_dma_clear_intr(adc_dma) i2s_ll_clear_intr_status(s_adc_digi_ctx->adc_i2s_dev, ADC_DMA_INTR_MASK);
#define adc_dma_enable_intr(adc_dma) i2s_ll_enable_intr(s_adc_digi_ctx->adc_i2s_dev, ADC_DMA_INTR_MASK, true);
#define adc_dma_disable_intr(adc_dma) i2s_ll_enable_intr(s_adc_digi_ctx->adc_i2s_dev, ADC_DMA_INTR_MASK, false);
#define adc_dma_deinit(adc_dma) do { \
esp_intr_free(s_adc_digi_ctx->intr_hdl); \
i2s_platform_release_occupation(I2S_CTLR_HP, ADC_DMA_I2S_HOST); \
} while (0)
#endif
/*---------------------------------------------------------------
Digital Controller Context
---------------------------------------------------------------*/
typedef struct adc_digi_context_t {
uint8_t *rx_dma_buf; //dma buffer
adc_hal_dma_ctx_t hal; //hal context
#if SOC_GDMA_SUPPORTED
gdma_channel_handle_t rx_dma_channel; //dma rx channel handle
#elif CONFIG_IDF_TARGET_ESP32S2
spi_host_device_t spi_host; //ADC uses this SPI DMA
spi_dma_ctx_t *spi_dma_ctx; //spi_dma context
intr_handle_t intr_hdl; //Interrupt handler
spi_dev_t *adc_spi_dev ;
#elif CONFIG_IDF_TARGET_ESP32
i2s_port_t i2s_host; //ADC uses this I2S DMA
intr_handle_t intr_hdl; //Interrupt handler
i2s_dev_t *adc_i2s_dev;
#endif
RingbufHandle_t ringbuf_hdl; //RX ringbuffer handler
intptr_t rx_eof_desc_addr; //eof descriptor address of RX channel
bool ringbuf_overflow_flag; //1: ringbuffer overflow
bool driver_start_flag; //1: driver is started; 0: driver is stopped
bool use_adc1; //1: ADC unit1 will be used; 0: ADC unit1 won't be used.
bool use_adc2; //1: ADC unit2 will be used; 0: ADC unit2 won't be used. This determines whether to acquire sar_adc2_mutex lock or not.
adc_atten_t adc1_atten; //Attenuation for ADC1. On this chip each ADC can only support one attenuation.
adc_atten_t adc2_atten; //Attenuation for ADC2. On this chip each ADC can only support one attenuation.
adc_hal_digi_ctrlr_cfg_t hal_digi_ctrlr_cfg; //Hal digital controller configuration
esp_pm_lock_handle_t pm_lock; //For power management
} adc_digi_context_t;
static adc_digi_context_t *s_adc_digi_ctx = NULL;
#ifdef CONFIG_PM_ENABLE
//Only for deprecated API
extern esp_pm_lock_handle_t adc_digi_arbiter_lock;
#endif //CONFIG_PM_ENABLE
/*---------------------------------------------------------------
ADC Continuous Read Mode (via DMA)
---------------------------------------------------------------*/
//Function to address transaction
static bool s_adc_dma_intr(adc_digi_context_t *adc_digi_ctx);
#if SOC_GDMA_SUPPORTED
static bool adc_dma_in_suc_eof_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data);
#else
static void adc_dma_intr_handler(void *arg);
#endif
static int8_t adc_digi_get_io_num(adc_unit_t adc_unit, uint8_t adc_channel)
{
assert(adc_unit < SOC_ADC_PERIPH_NUM);
uint8_t adc_n = (adc_unit == ADC_UNIT_1) ? 0 : 1;
return adc_channel_io_map[adc_n][adc_channel];
}
static esp_err_t adc_digi_gpio_init(adc_unit_t adc_unit, uint16_t channel_mask)
{
esp_err_t ret = ESP_OK;
uint64_t gpio_mask = 0;
uint32_t n = 0;
int8_t io = 0;
while (channel_mask) {
if (channel_mask & 0x1) {
io = adc_digi_get_io_num(adc_unit, n);
if (io < 0) {
return ESP_ERR_INVALID_ARG;
}
gpio_mask |= BIT64(io);
}
channel_mask = channel_mask >> 1;
n++;
}
gpio_config_t cfg = {
.pin_bit_mask = gpio_mask,
.mode = GPIO_MODE_DISABLE,
};
ret = gpio_config(&cfg);
return ret;
}
esp_err_t adc_digi_deinitialize(void)
{
if (!s_adc_digi_ctx) {
return ESP_ERR_INVALID_STATE;
}
if (s_adc_digi_ctx->driver_start_flag != 0) {
ESP_LOGE(ADC_TAG, "The driver is not stopped");
return ESP_ERR_INVALID_STATE;
}
if (s_adc_digi_ctx->ringbuf_hdl) {
vRingbufferDelete(s_adc_digi_ctx->ringbuf_hdl);
s_adc_digi_ctx->ringbuf_hdl = NULL;
}
#if CONFIG_PM_ENABLE
if (s_adc_digi_ctx->pm_lock) {
esp_pm_lock_delete(s_adc_digi_ctx->pm_lock);
}
#endif //CONFIG_PM_ENABLE
ANALOG_CLOCK_DISABLE();
free(s_adc_digi_ctx->rx_dma_buf);
free(s_adc_digi_ctx->hal.rx_desc);
free(s_adc_digi_ctx->hal_digi_ctrlr_cfg.adc_pattern);
adc_dma_deinit(s_adc_digi_ctx);
free(s_adc_digi_ctx);
s_adc_digi_ctx = NULL;
adc_apb_periph_free();
return ESP_OK;
}
esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config)
{
esp_err_t ret = ESP_OK;
ESP_RETURN_ON_FALSE((init_config->conv_num_each_intr % SOC_ADC_DIGI_DATA_BYTES_PER_CONV == 0), ESP_ERR_INVALID_ARG, ADC_TAG, "conv_frame_size should be in multiples of `SOC_ADC_DIGI_DATA_BYTES_PER_CONV`");
s_adc_digi_ctx = calloc(1, sizeof(adc_digi_context_t));
if (s_adc_digi_ctx == NULL) {
ret = ESP_ERR_NO_MEM;
goto cleanup;
}
//ringbuffer
s_adc_digi_ctx->ringbuf_hdl = xRingbufferCreate(init_config->max_store_buf_size, RINGBUF_TYPE_BYTEBUF);
if (!s_adc_digi_ctx->ringbuf_hdl) {
ret = ESP_ERR_NO_MEM;
goto cleanup;
}
//malloc internal buffer used by DMA
s_adc_digi_ctx->rx_dma_buf = heap_caps_calloc(1, init_config->conv_num_each_intr * INTERNAL_BUF_NUM, MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
if (!s_adc_digi_ctx->rx_dma_buf) {
ret = ESP_ERR_NO_MEM;
goto cleanup;
}
//malloc dma descriptor
uint32_t dma_desc_num_per_frame = (init_config->conv_num_each_intr + DMA_DESCRIPTOR_BUFFER_MAX_SIZE_4B_ALIGNED - 1) / DMA_DESCRIPTOR_BUFFER_MAX_SIZE_4B_ALIGNED;
uint32_t dma_desc_max_num = dma_desc_num_per_frame * INTERNAL_BUF_NUM;
s_adc_digi_ctx->hal.rx_desc = heap_caps_calloc(1, (sizeof(dma_descriptor_t)) * dma_desc_max_num, MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA);
if (!s_adc_digi_ctx->hal.rx_desc) {
ret = ESP_ERR_NO_MEM;
goto cleanup;
}
//malloc pattern table
s_adc_digi_ctx->hal_digi_ctrlr_cfg.adc_pattern = calloc(1, SOC_ADC_PATT_LEN_MAX * sizeof(adc_digi_pattern_config_t));
if (!s_adc_digi_ctx->hal_digi_ctrlr_cfg.adc_pattern) {
ret = ESP_ERR_NO_MEM;
goto cleanup;
}
#if CONFIG_PM_ENABLE
ret = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "adc_dma", &s_adc_digi_ctx->pm_lock);
if (ret != ESP_OK) {
goto cleanup;
}
#endif //CONFIG_PM_ENABLE
//init gpio pins
if (init_config->adc1_chan_mask) {
ret = adc_digi_gpio_init(ADC_UNIT_1, init_config->adc1_chan_mask);
if (ret != ESP_OK) {
goto cleanup;
}
}
if (init_config->adc2_chan_mask) {
ret = adc_digi_gpio_init(ADC_UNIT_2, init_config->adc2_chan_mask);
if (ret != ESP_OK) {
goto cleanup;
}
}
#if SOC_GDMA_SUPPORTED
//alloc rx gdma channel
gdma_channel_alloc_config_t rx_alloc_config = {
.direction = GDMA_CHANNEL_DIRECTION_RX,
};
ret = gdma_new_ahb_channel(&rx_alloc_config, &s_adc_digi_ctx->rx_dma_channel);
if (ret != ESP_OK) {
goto cleanup;
}
gdma_connect(s_adc_digi_ctx->rx_dma_channel, GDMA_MAKE_TRIGGER(GDMA_TRIG_PERIPH_ADC, 0));
gdma_strategy_config_t strategy_config = {
.auto_update_desc = true,
.owner_check = true
};
gdma_apply_strategy(s_adc_digi_ctx->rx_dma_channel, &strategy_config);
gdma_rx_event_callbacks_t cbs = {
.on_recv_eof = adc_dma_in_suc_eof_callback
};
gdma_register_rx_event_callbacks(s_adc_digi_ctx->rx_dma_channel, &cbs, s_adc_digi_ctx);
#elif CONFIG_IDF_TARGET_ESP32S2
//ADC utilises SPI3 DMA on ESP32S2
bool spi_success = false;
spi_success = spicommon_periph_claim(ADC_DMA_SPI_HOST, "adc");
ret = spicommon_dma_chan_alloc(ADC_DMA_SPI_HOST, SPI_DMA_CH_AUTO, &(s_adc_digi_ctx->spi_dma_ctx));
if (ret != ESP_OK || spi_success != ESP_OK) {
goto cleanup;
}
if (!spi_success || (s_adc_digi_ctx->spi_host != ADC_DMA_SPI_HOST)) {
goto cleanup;
}
ret = esp_intr_alloc(spicommon_irqdma_source_for_host(ADC_DMA_SPI_HOST), 0, adc_dma_intr_handler,
(void *)s_adc_digi_ctx, &s_adc_digi_ctx->intr_hdl);
if (ret != ESP_OK) {
goto cleanup;
}
s_adc_digi_ctx->adc_spi_dev = SPI_LL_GET_HW(ADC_DMA_SPI_HOST);
#elif CONFIG_IDF_TARGET_ESP32
//ADC utilises I2S0 DMA on ESP32
ret = i2s_platform_acquire_occupation(I2S_CTLR_HP, ADC_DMA_I2S_HOST, "adc");
if (ret != ESP_OK) {
ret = ESP_ERR_NOT_FOUND;
goto cleanup;
}
s_adc_digi_ctx->i2s_host = I2S_NUM_0;
ret = esp_intr_alloc(i2s_periph_signal[ADC_DMA_I2S_HOST].irq, 0, adc_dma_intr_handler,
(void *)s_adc_digi_ctx, &s_adc_digi_ctx->intr_hdl);
if (ret != ESP_OK) {
goto cleanup;
}
s_adc_digi_ctx->adc_i2s_dev = I2S_LL_GET_HW(ADC_DMA_I2S_HOST);
#endif
adc_hal_dma_config_t config = {
.eof_desc_num = INTERNAL_BUF_NUM,
.eof_step = dma_desc_num_per_frame,
.eof_num = init_config->conv_num_each_intr / SOC_ADC_DIGI_DATA_BYTES_PER_CONV
};
adc_hal_dma_ctx_config(&s_adc_digi_ctx->hal, &config);
adc_apb_periph_claim();
ANALOG_CLOCK_ENABLE();
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_1);
adc_hal_calibration_init(ADC_UNIT_2);
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED
return ret;
cleanup:
adc_digi_deinitialize();
return ret;
}
#if SOC_GDMA_SUPPORTED
static IRAM_ATTR bool adc_dma_in_suc_eof_callback(gdma_channel_handle_t dma_chan, gdma_event_data_t *event_data, void *user_data)
{
assert(event_data);
s_adc_digi_ctx->rx_eof_desc_addr = event_data->rx_eof_desc_addr;
return s_adc_dma_intr(user_data);
}
#else
static IRAM_ATTR void adc_dma_intr_handler(void *arg)
{
adc_digi_context_t *ctx = (adc_digi_context_t *)arg;
bool need_yield = false;
#if CONFIG_IDF_TARGET_ESP32S2
bool conversion_finish = spi_ll_get_intr(s_adc_digi_ctx->adc_spi_dev, ADC_DMA_INTR_MASK);
if (conversion_finish) {
spi_ll_clear_intr(s_adc_digi_ctx->adc_spi_dev, ADC_DMA_INTR_MASK);
intptr_t desc_addr = spi_dma_ll_get_in_suc_eof_desc_addr(s_adc_digi_ctx->adc_spi_dev, s_adc_digi_ctx->spi_dma_ctx->rx_dma_chan.chan_id);
ctx->rx_eof_desc_addr = desc_addr;
need_yield = s_adc_dma_intr(ctx);
}
#elif CONFIG_IDF_TARGET_ESP32
bool conversion_finish = i2s_ll_get_intr_status(s_adc_digi_ctx->adc_i2s_dev) & ADC_DMA_INTR_MASK;
if (conversion_finish) {
i2s_ll_clear_intr_status(s_adc_digi_ctx->adc_i2s_dev, ADC_DMA_INTR_MASK);
uint32_t desc_addr;
i2s_ll_rx_get_eof_des_addr(s_adc_digi_ctx->adc_i2s_dev, &desc_addr);
ctx->rx_eof_desc_addr = (intptr_t)desc_addr;
need_yield = s_adc_dma_intr(ctx);
}
#endif
if (need_yield) {
portYIELD_FROM_ISR();
}
}
#endif
static IRAM_ATTR bool s_adc_dma_intr(adc_digi_context_t *adc_digi_ctx)
{
BaseType_t taskAwoken = 0;
BaseType_t ret;
adc_hal_dma_desc_status_t status = false;
uint8_t *finished_buffer = NULL;
uint32_t finished_size = 0;
while (1) {
status = adc_hal_get_reading_result(&adc_digi_ctx->hal, adc_digi_ctx->rx_eof_desc_addr, &finished_buffer, &finished_size);
if (status != ADC_HAL_DMA_DESC_VALID) {
break;
}
ret = xRingbufferSendFromISR(adc_digi_ctx->ringbuf_hdl, finished_buffer, finished_size, &taskAwoken);
if (ret == pdFALSE) {
//ringbuffer overflow
adc_digi_ctx->ringbuf_overflow_flag = 1;
}
}
return (taskAwoken == pdTRUE);
}
esp_err_t adc_digi_start(void)
{
if (s_adc_digi_ctx->driver_start_flag != 0) {
ESP_LOGE(ADC_TAG, "The driver is already started");
return ESP_ERR_INVALID_STATE;
}
//reset ADC digital part to reset ADC sampling EOF counter
ADC_BUS_CLK_ATOMIC() {
adc_ll_reset_register();
}
sar_periph_ctrl_adc_continuous_power_acquire();
//reset flags
s_adc_digi_ctx->ringbuf_overflow_flag = 0;
s_adc_digi_ctx->driver_start_flag = 1;
if (s_adc_digi_ctx->use_adc1) {
adc_lock_acquire(ADC_UNIT_1);
}
if (s_adc_digi_ctx->use_adc2) {
adc_lock_acquire(ADC_UNIT_2);
}
#if CONFIG_PM_ENABLE
// Lock APB frequency while ADC driver is in use
esp_pm_lock_acquire(s_adc_digi_ctx->pm_lock);
#endif
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
if (s_adc_digi_ctx->use_adc1) {
adc_set_hw_calibration_code(ADC_UNIT_1, s_adc_digi_ctx->adc1_atten);
}
if (s_adc_digi_ctx->use_adc2) {
adc_set_hw_calibration_code(ADC_UNIT_2, s_adc_digi_ctx->adc2_atten);
}
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED
#if SOC_ADC_ARBITER_SUPPORTED
adc_arbiter_t config = ADC_ARBITER_CONFIG_DEFAULT();
adc_hal_arbiter_config(&config);
#endif //#if SOC_ADC_ARBITER_SUPPORTED
adc_hal_set_controller(ADC_UNIT_1, ADC_HAL_CONTINUOUS_READ_MODE);
adc_hal_set_controller(ADC_UNIT_2, ADC_HAL_CONTINUOUS_READ_MODE);
adc_hal_digi_init(&s_adc_digi_ctx->hal);
#if !CONFIG_IDF_TARGET_ESP32
esp_clk_tree_enable_src((soc_module_clk_t)(s_adc_digi_ctx->hal_digi_ctrlr_cfg.clk_src), true);
#endif
adc_hal_digi_controller_config(&s_adc_digi_ctx->hal, &s_adc_digi_ctx->hal_digi_ctrlr_cfg);
adc_dma_stop(s_adc_digi_ctx);
adc_hal_digi_connect(false);
adc_dma_reset(s_adc_digi_ctx);
adc_hal_digi_reset();
adc_hal_digi_dma_link(&s_adc_digi_ctx->hal, s_adc_digi_ctx->rx_dma_buf);
adc_dma_start(s_adc_digi_ctx, s_adc_digi_ctx->hal.rx_desc);
adc_hal_digi_connect(true);
adc_hal_digi_enable(true);
return ESP_OK;
}
esp_err_t adc_digi_stop(void)
{
if (s_adc_digi_ctx->driver_start_flag != 1) {
ESP_LOGE(ADC_TAG, "The driver is already stopped");
return ESP_ERR_INVALID_STATE;
}
s_adc_digi_ctx->driver_start_flag = 0;
adc_dma_stop(s_adc_digi_ctx);
adc_hal_digi_enable(false);
adc_hal_digi_connect(false);
adc_hal_digi_deinit();
#if CONFIG_PM_ENABLE
if (s_adc_digi_ctx->pm_lock) {
esp_pm_lock_release(s_adc_digi_ctx->pm_lock);
}
#endif //CONFIG_PM_ENABLE
if (s_adc_digi_ctx->use_adc2) {
adc_lock_release(ADC_UNIT_2);
}
if (s_adc_digi_ctx->use_adc1) {
adc_lock_release(ADC_UNIT_1);
}
sar_periph_ctrl_adc_continuous_power_release();
return ESP_OK;
}
esp_err_t adc_digi_read_bytes(uint8_t *buf, uint32_t length_max, uint32_t *out_length, uint32_t timeout_ms)
{
TickType_t ticks_to_wait;
esp_err_t ret = ESP_OK;
uint8_t *data = NULL;
size_t size = 0;
ticks_to_wait = timeout_ms / portTICK_PERIOD_MS;
if (timeout_ms == ADC_MAX_DELAY) {
ticks_to_wait = portMAX_DELAY;
}
data = xRingbufferReceiveUpTo(s_adc_digi_ctx->ringbuf_hdl, &size, ticks_to_wait, length_max);
if (!data) {
ESP_LOGV(ADC_TAG, "No data, increase timeout or reduce conv_num_each_intr");
ret = ESP_ERR_TIMEOUT;
*out_length = 0;
return ret;
}
memcpy(buf, data, size);
vRingbufferReturnItem(s_adc_digi_ctx->ringbuf_hdl, data);
assert((size % 4) == 0);
*out_length = size;
if (s_adc_digi_ctx->ringbuf_overflow_flag) {
ret = ESP_ERR_INVALID_STATE;
}
return ret;
}
/*---------------------------------------------------------------
Digital controller setting
---------------------------------------------------------------*/
esp_err_t adc_digi_controller_configure(const adc_digi_configuration_t *config)
{
if (!s_adc_digi_ctx) {
return ESP_ERR_INVALID_STATE;
}
//Pattern related check
ESP_RETURN_ON_FALSE(config->pattern_num <= SOC_ADC_PATT_LEN_MAX, ESP_ERR_INVALID_ARG, ADC_TAG, "Max pattern num is %d", SOC_ADC_PATT_LEN_MAX);
#if CONFIG_IDF_TARGET_ESP32
for (int i = 0; i < config->pattern_num; i++) {
ESP_RETURN_ON_FALSE((config->adc_pattern[i].bit_width >= SOC_ADC_DIGI_MIN_BITWIDTH && config->adc_pattern->bit_width <= SOC_ADC_DIGI_MAX_BITWIDTH), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC bitwidth not supported");
ESP_RETURN_ON_FALSE(config->adc_pattern[i].unit == 0, ESP_ERR_INVALID_ARG, ADC_TAG, "Only support using ADC1 DMA mode");
}
#else
for (int i = 0; i < config->pattern_num; i++) {
ESP_RETURN_ON_FALSE((config->adc_pattern[i].bit_width == SOC_ADC_DIGI_MAX_BITWIDTH), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC bitwidth not supported");
}
#endif
ESP_RETURN_ON_FALSE(config->sample_freq_hz <= SOC_ADC_SAMPLE_FREQ_THRES_HIGH && config->sample_freq_hz >= SOC_ADC_SAMPLE_FREQ_THRES_LOW, ESP_ERR_INVALID_ARG, ADC_TAG, "ADC sampling frequency out of range");
#if CONFIG_IDF_TARGET_ESP32
ESP_RETURN_ON_FALSE(config->format == ADC_DIGI_OUTPUT_FORMAT_TYPE1, ESP_ERR_INVALID_ARG, ADC_TAG, "Please use type1");
#elif CONFIG_IDF_TARGET_ESP32S2
if (config->conv_mode == ADC_CONV_BOTH_UNIT || config->conv_mode == ADC_CONV_ALTER_UNIT) {
ESP_RETURN_ON_FALSE(config->format == ADC_DIGI_OUTPUT_FORMAT_TYPE2, ESP_ERR_INVALID_ARG, ADC_TAG, "Please use type2");
} else if (config->conv_mode == ADC_CONV_SINGLE_UNIT_1 || config->conv_mode == ADC_CONV_SINGLE_UNIT_2) {
ESP_RETURN_ON_FALSE(config->format == ADC_DIGI_OUTPUT_FORMAT_TYPE1, ESP_ERR_INVALID_ARG, ADC_TAG, "Please use type1");
}
#else
ESP_RETURN_ON_FALSE(config->format == ADC_DIGI_OUTPUT_FORMAT_TYPE2, ESP_ERR_INVALID_ARG, ADC_TAG, "Please use type2");
#endif
s_adc_digi_ctx->hal_digi_ctrlr_cfg.adc_pattern_len = config->pattern_num;
s_adc_digi_ctx->hal_digi_ctrlr_cfg.sample_freq_hz = config->sample_freq_hz;
s_adc_digi_ctx->hal_digi_ctrlr_cfg.conv_mode = config->conv_mode;
memcpy(s_adc_digi_ctx->hal_digi_ctrlr_cfg.adc_pattern, config->adc_pattern, config->pattern_num * sizeof(adc_digi_pattern_config_t));
const int atten_uninitialized = 999;
s_adc_digi_ctx->adc1_atten = atten_uninitialized;
s_adc_digi_ctx->adc2_atten = atten_uninitialized;
s_adc_digi_ctx->use_adc1 = 0;
s_adc_digi_ctx->use_adc2 = 0;
for (int i = 0; i < config->pattern_num; i++) {
const adc_digi_pattern_config_t *pat = &config->adc_pattern[i];
if (pat->unit == ADC_UNIT_1) {
s_adc_digi_ctx->use_adc1 = 1;
if (s_adc_digi_ctx->adc1_atten == atten_uninitialized) {
s_adc_digi_ctx->adc1_atten = pat->atten;
} else if (s_adc_digi_ctx->adc1_atten != pat->atten) {
return ESP_ERR_INVALID_ARG;
}
} else if (pat->unit == ADC_UNIT_2) {
//See whether ADC2 will be used or not. If yes, the ``sar_adc2_mutex`` should be acquired in the continuous read driver
s_adc_digi_ctx->use_adc2 = 1;
if (s_adc_digi_ctx->adc2_atten == atten_uninitialized) {
s_adc_digi_ctx->adc2_atten = pat->atten;
} else if (s_adc_digi_ctx->adc2_atten != pat->atten) {
return ESP_ERR_INVALID_ARG;
}
}
}
return ESP_OK;
}
#if !CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that adc_continuous driver is not running along with the legacy adc_continuous driver
*/
__attribute__((constructor))
static void check_adc_continuous_driver_conflict(void)
{
// This function was declared as weak here. adc_continuous driver has one implementation.
// So if adc_continuous driver is not linked in, then `adc_continuous_new_handle` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t adc_continuous_new_handle(const void *init_config, void **ret_handle);
if ((void *)adc_continuous_new_handle != NULL) {
ESP_EARLY_LOGE(ADC_TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
abort();
}
ESP_EARLY_LOGW(ADC_TAG, "legacy driver is deprecated, please migrate to `esp_adc/adc_continuous.h`");
}
#endif //CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
/*---------------------------------------------------------------
ADC Hardware Calibration
---------------------------------------------------------------*/
static __attribute__((constructor)) void adc_hw_calibration(void)
{
//Calculate all ICode
for (int i = 0; i < SOC_ADC_PERIPH_NUM; i++) {
adc_hal_calibration_init(i);
for (int j = 0; j < SOC_ADC_ATTEN_NUM; j++) {
/**
* This may get wrong when attenuations are NOT consecutive on some chips,
* update this when bringing up the calibration on that chip
*/
adc_calc_hw_calibration_code(i, j);
#if SOC_ADC_CALIB_CHAN_COMPENS_SUPPORTED
/* Load the channel compensation from efuse */
for (int k = 0; k < SOC_ADC_CHANNEL_NUM(i); k++) {
adc_load_hw_calibration_chan_compens(i, k, j);
}
#endif
}
}
}
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED
@@ -1,248 +0,0 @@
/*
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*----------------------------------------------------------------------------------
This file contains ESP32 and ESP32S2 Deprecated ADC APIs and functions
-----------------------------------------------------------------------------------*/
#include "sdkconfig.h"
#include "esp_types.h"
#include "esp_log.h"
#include "esp_intr_alloc.h"
#include "driver/rtc_io.h"
#include "hal/adc_ll.h"
#include "hal/adc_types.h"
#ifdef CONFIG_PM_ENABLE
#include "esp_pm.h"
#endif
#include "freertos/FreeRTOS.h"
#include "driver/adc_i2s_legacy.h"
#include "driver/adc_types_legacy.h"
static __attribute__((unused)) const char *ADC_TAG = "ADC";
#define ADC_CHECK_RET(fun_ret) ({ \
if (fun_ret != ESP_OK) { \
ESP_LOGE(ADC_TAG,"%s:%d",__FUNCTION__,__LINE__); \
return ESP_FAIL; \
} \
})
#define ADC_CHECK(a, str, ret_val) ({ \
if (!(a)) { \
ESP_LOGE(ADC_TAG,"%s(%d): %s", __FUNCTION__, __LINE__, str); \
return (ret_val); \
} \
})
#define ADC_CHANNEL_CHECK(periph, channel) ADC_CHECK(channel < SOC_ADC_CHANNEL_NUM(periph), "ADC"#periph" channel error", ESP_ERR_INVALID_ARG)
#define ADC_GET_IO_NUM(periph, channel) (adc_channel_io_map[periph][channel])
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
#define ADC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
#define ADC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
#ifdef CONFIG_PM_ENABLE
esp_pm_lock_handle_t adc_digi_arbiter_lock = NULL;
#endif //CONFIG_PM_ENABLE
#if CONFIG_IDF_TARGET_ESP32
/*---------------------------------------------------------------
ESP32 Deprecated ADC APIs and functions
---------------------------------------------------------------*/
#define DIG_ADC_OUTPUT_FORMAT_DEFUALT (ADC_DIGI_FORMAT_12BIT)
#define DIG_ADC_ATTEN_DEFUALT (ADC_ATTEN_DB_12)
#define DIG_ADC_BIT_WIDTH_DEFUALT (3) //3 for ADC_WIDTH_BIT_12
/**
* @brief ADC digital controller (DMA mode) conversion rules setting.
*/
typedef struct {
union {
struct {
uint8_t atten: 2; /*!< ADC sampling voltage attenuation configuration. Modification of attenuation affects the range of measurements.
0: measurement range 0 - 800mV,
1: measurement range 0 - 1100mV,
2: measurement range 0 - 1350mV,
3: measurement range 0 - 2600mV. */
uint8_t bit_width: 2; /*!< ADC resolution.
- 0: 9 bit;
- 1: 10 bit;
- 2: 11 bit;
- 3: 12 bit. */
int8_t channel: 4; /*!< ADC channel index. */
};
uint8_t val; /*!<Raw data value */
};
} adc_digi_pattern_table_t;
/**
* @brief ADC digital controller (DMA mode) output data format option.
*/
typedef enum {
ADC_DIGI_FORMAT_12BIT, /*!<ADC to DMA data format, [15:12]-channel, [11: 0]-12 bits ADC data (`adc_digi_output_data_t`). Note: For single convert mode. */
ADC_DIGI_FORMAT_11BIT, /*!<ADC to DMA data format, [15]-adc unit, [14:11]-channel, [10: 0]-11 bits ADC data (`adc_digi_output_data_t`). Note: For multi or alter convert mode. */
ADC_DIGI_FORMAT_MAX,
} adc_digi_format_t;
/**
* Explanation of the relationship between `conv_limit_num`, `dma_eof_num` and the number of DMA outputs:
*
* +---------------------+--------+--------+--------+
* | conv_mode | single | both | alter |
* +---------------------+--------+--------+--------+
* | trigger meas times | 1 | 1 | 1 |
* +---------------------+--------+--------+--------+
* | conv_limit_num | +1 | +1 | +1 |
* | dma_eof_num | +1 | +2 | +1 |
* | dma output (byte) | +2 | +4 | +2 |
* +---------------------+--------+--------+--------+
*/
typedef struct {
uint32_t adc1_pattern_len; /*!<Pattern table length for digital controller. Range: 0 ~ 16 (0: Don't change the pattern table setting).
The pattern table that defines the conversion rules for each SAR ADC. Each table has 16 items, in which channel selection,
resolution and attenuation are stored. When the conversion is started, the controller reads conversion rules from the
pattern table one by one. For each controller the scan sequence has at most 16 different rules before repeating itself. */
uint32_t adc2_pattern_len; /*!<Refer to ``adc1_pattern_len`` */
adc_digi_pattern_table_t *adc1_pattern; /*!<Pointer to pattern table for digital controller. The table size defined by `adc1_pattern_len`. */
adc_digi_pattern_table_t *adc2_pattern; /*!<Refer to `adc1_pattern` */
adc_digi_convert_mode_t conv_mode; /*!<ADC conversion mode for digital controller. See ``adc_digi_convert_mode_t``. */
adc_digi_format_t format; /*!<ADC output data format for digital controller. See ``adc_digi_format_t``. */
} adc_digi_config_t;
/**
* Set adc output 16-bit-data format from digital controller.
*
* @param data_sel 1: [15] unit, [14:11] channel, [10:0] data, 11-bit-width at most. Only work under `ADC_LL_DIGI_CONV_BOTH_UNIT` or `ADC_LL_DIGI_CONV_ALTER_UNIT` mode.
* 0: [15:12] channel, [11:0] data, 12-bit-width at most. Only work under `ADC_LL_DIGI_CONV_ONLY_ADC1` or `ADC_LL_DIGI_CONV_ONLY_ADC2` mode
* @note see `adc_ll_digi_pattern_table_t` for more detail of data bit width
*/
static inline void adc_ll_digi_set_output_format(bool data_sel)
{
SYSCON.saradc_ctrl.data_sar_sel = data_sel;
}
static inline void adc_ll_digi_prepare_pattern_table(adc_unit_t adc_n, uint32_t pattern_index, adc_digi_pattern_table_t pattern)
{
uint32_t tab;
uint8_t index = pattern_index / 4;
uint8_t offset = (pattern_index % 4) * 8;
if (adc_n == ADC_UNIT_1) {
tab = SYSCON.saradc_sar1_patt_tab[index]; // Read old register value
tab &= (~(0xFF000000 >> offset)); // clear old data
tab |= ((uint32_t)pattern.val << 24) >> offset; // Fill in the new data
SYSCON.saradc_sar1_patt_tab[index] = tab; // Write back
} else { // adc_n == ADC_UNIT_2
tab = SYSCON.saradc_sar2_patt_tab[index]; // Read old register value
tab &= (~(0xFF000000 >> offset)); // clear old data
tab |= ((uint32_t)pattern.val << 24) >> offset; // Fill in the new data
SYSCON.saradc_sar2_patt_tab[index] = tab; // Write back
}
}
static void adc_digi_controller_reg_set(const adc_digi_config_t *cfg)
{
/* On ESP32, only support ADC1 */
switch (cfg->conv_mode) {
case ADC_CONV_SINGLE_UNIT_1:
adc_ll_digi_set_convert_mode(ADC_LL_DIGI_CONV_ONLY_ADC1);
break;
case ADC_CONV_SINGLE_UNIT_2:
adc_ll_digi_set_convert_mode(ADC_LL_DIGI_CONV_ONLY_ADC2);
break;
case ADC_CONV_BOTH_UNIT:
adc_ll_digi_set_convert_mode(ADC_LL_DIGI_CONV_BOTH_UNIT);
break;
case ADC_CONV_ALTER_UNIT:
adc_ll_digi_set_convert_mode(ADC_LL_DIGI_CONV_ALTER_UNIT);
break;
default:
abort();
}
if (cfg->conv_mode & ADC_CONV_SINGLE_UNIT_1) {
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_DIG);
if (cfg->adc1_pattern_len) {
adc_ll_digi_clear_pattern_table(ADC_UNIT_1);
adc_ll_digi_set_pattern_table_len(ADC_UNIT_1, cfg->adc1_pattern_len);
for (uint32_t i = 0; i < cfg->adc1_pattern_len; i++) {
adc_ll_digi_prepare_pattern_table(ADC_UNIT_1, i, cfg->adc1_pattern[i]);
}
}
}
if (cfg->conv_mode & ADC_CONV_SINGLE_UNIT_2) {
adc_ll_set_controller(ADC_UNIT_2, ADC_LL_CTRL_DIG);
if (cfg->adc2_pattern_len) {
adc_ll_digi_clear_pattern_table(ADC_UNIT_2);
adc_ll_digi_set_pattern_table_len(ADC_UNIT_2, cfg->adc2_pattern_len);
for (uint32_t i = 0; i < cfg->adc2_pattern_len; i++) {
adc_ll_digi_prepare_pattern_table(ADC_UNIT_2, i, cfg->adc2_pattern[i]);
}
}
}
adc_ll_digi_set_output_format(cfg->format);
adc_ll_digi_convert_limit_enable(ADC_LL_DEFAULT_CONV_LIMIT_EN);
adc_ll_digi_set_convert_limit_num(ADC_LL_DEFAULT_CONV_LIMIT_NUM);
adc_ll_digi_set_data_source(ADC_I2S_DATA_SRC_ADC);
}
esp_err_t adc_set_i2s_data_source(adc_i2s_source_t src)
{
ADC_CHECK((src == ADC_I2S_DATA_SRC_IO_SIG || src == ADC_I2S_DATA_SRC_ADC), "ADC i2s data source error", ESP_ERR_INVALID_ARG);
ADC_ENTER_CRITICAL();
adc_ll_digi_set_data_source(src);
ADC_EXIT_CRITICAL();
return ESP_OK;
}
extern esp_err_t adc_common_gpio_init(adc_unit_t adc_unit, adc_channel_t channel);
esp_err_t adc_i2s_mode_init(adc_unit_t adc_unit, adc_channel_t channel)
{
if (adc_unit == ADC_UNIT_1) {
ADC_CHANNEL_CHECK(ADC_UNIT_1, channel);
} else if (adc_unit == ADC_UNIT_2) {
//ADC2 does not support DMA mode
ADC_CHECK(false, "ADC2 not support DMA for now.", ESP_ERR_INVALID_ARG);
ADC_CHANNEL_CHECK(ADC_UNIT_2, channel);
}
adc_digi_pattern_table_t adc1_pattern[1];
adc_digi_pattern_table_t adc2_pattern[1];
adc_digi_config_t dig_cfg = {
.format = DIG_ADC_OUTPUT_FORMAT_DEFUALT,
.conv_mode = ADC_CONV_SINGLE_UNIT_1,
};
if (adc_unit == ADC_UNIT_1) {
adc1_pattern[0].atten = DIG_ADC_ATTEN_DEFUALT;
adc1_pattern[0].bit_width = DIG_ADC_BIT_WIDTH_DEFUALT;
adc1_pattern[0].channel = channel;
dig_cfg.adc1_pattern_len = 1;
dig_cfg.adc1_pattern = adc1_pattern;
} else if (adc_unit == ADC_UNIT_2) {
adc2_pattern[0].atten = DIG_ADC_ATTEN_DEFUALT;
adc2_pattern[0].bit_width = DIG_ADC_BIT_WIDTH_DEFUALT;
adc2_pattern[0].channel = channel;
dig_cfg.adc2_pattern_len = 1;
dig_cfg.adc2_pattern = adc2_pattern;
}
adc_common_gpio_init(adc_unit, channel);
ADC_ENTER_CRITICAL();
adc_ll_digi_set_fsm_time(ADC_LL_FSM_RSTB_WAIT_DEFAULT, ADC_LL_FSM_START_WAIT_DEFAULT,
ADC_LL_FSM_STANDBY_WAIT_DEFAULT);
adc_ll_set_sample_cycle(ADC_LL_SAMPLE_CYCLE_DEFAULT);
adc_ll_pwdet_set_cct(ADC_LL_PWDET_CCT_DEFAULT);
adc_ll_digi_output_invert(ADC_UNIT_1, ADC_LL_DIGI_DATA_INVERT_DEFAULT(ADC_UNIT_1));
adc_ll_digi_output_invert(ADC_UNIT_2, ADC_LL_DIGI_DATA_INVERT_DEFAULT(ADC_UNIT_2));
adc_ll_digi_set_clk_div(ADC_LL_DIGI_SAR_CLK_DIV_DEFAULT);
adc_digi_controller_reg_set(&dig_cfg);
ADC_EXIT_CRITICAL();
return ESP_OK;
}
#endif //#if CONFIG_IDF_TARGET_ESP32
-950
View File
@@ -1,950 +0,0 @@
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <esp_types.h>
#include <stdlib.h>
#include <ctype.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "freertos/timers.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_pm.h"
#include "soc/rtc.h"
#include "soc/soc_caps.h"
#include "esp_private/gpio.h"
#include "sys/lock.h"
#include "esp_private/adc_share_hw_ctrl.h"
#include "esp_private/sar_periph_ctrl.h"
#include "adc1_private.h"
#include "hal/adc_types.h"
#include "hal/adc_hal.h"
#include "hal/adc_ll.h"
#include "hal/adc_hal_common.h"
#include "esp_private/esp_clk_tree_common.h"
#include "esp_private/regi2c_ctrl.h"
#include "esp_private/periph_ctrl.h"
#include "driver/adc_types_legacy.h"
#include "esp_clk_tree.h"
#if SOC_DAC_SUPPORTED
#include "hal/dac_types.h"
#include "hal/dac_ll.h"
#endif
#if CONFIG_IDF_TARGET_ESP32S3
#include "esp_efuse_rtc_calib.h"
#endif
static const char *ADC_TAG = "ADC";
#define ADC_GET_IO_NUM(periph, channel) (adc_channel_io_map[periph][channel])
//////////////////////// Locks ///////////////////////////////////////////
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
#define RTC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
#define RTC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
#define DIGI_ENTER_CRITICAL()
#define DIGI_EXIT_CRITICAL()
#define ADC_POWER_ENTER() RTC_ENTER_CRITICAL()
#define ADC_POWER_EXIT() RTC_EXIT_CRITICAL()
#define DIGI_CONTROLLER_ENTER() DIGI_ENTER_CRITICAL()
#define DIGI_CONTROLLER_EXIT() DIGI_EXIT_CRITICAL()
#define SARADC1_ENTER() RTC_ENTER_CRITICAL()
#define SARADC1_EXIT() RTC_EXIT_CRITICAL()
#define SARADC2_ENTER() RTC_ENTER_CRITICAL()
#define SARADC2_EXIT() RTC_EXIT_CRITICAL()
//n stands for ADC unit: 1 for ADC1 and 2 for ADC2. Currently both unit touches the same registers
#define VREF_ENTER(n) RTC_ENTER_CRITICAL()
#define VREF_EXIT(n) RTC_EXIT_CRITICAL()
#define FSM_ENTER() RTC_ENTER_CRITICAL()
#define FSM_EXIT() RTC_EXIT_CRITICAL()
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
//prevent ADC1 being used by I2S dma and other tasks at the same time.
static _lock_t adc1_dma_lock;
#define SARADC1_ACQUIRE() _lock_acquire( &adc1_dma_lock )
#define SARADC1_RELEASE() _lock_release( &adc1_dma_lock )
#endif
/*
In ADC2, there're two locks used for different cases:
1. lock shared with app and Wi-Fi:
ESP32:
When Wi-Fi using the ADC2, we assume it will never stop, so app checks the lock and returns immediately if failed.
ESP32S2:
The controller's control over the ADC is determined by the arbiter. There is no need to control by lock.
2. lock shared between tasks:
when several tasks sharing the ADC2, we want to guarantee
all the requests will be handled.
Since conversions are short (about 31us), app returns the lock very soon,
we use a spinlock to stand there waiting to do conversions one by one.
adc2_spinlock should be acquired first, then call `adc_lock_release(ADC_UNIT_2)` or rtc_spinlock.
*/
#if CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_PM_ENABLE
static esp_pm_lock_handle_t s_adc2_arbiter_lock;
#endif //CONFIG_PM_ENABLE
#endif // !CONFIG_IDF_TARGET_ESP32
static uint32_t clk_src_freq_hz;
static esp_err_t adc_hal_convert(adc_unit_t adc_n, int channel, uint32_t clk_src_freq_hz, int *out_raw);
/*---------------------------------------------------------------
ADC Common
---------------------------------------------------------------*/
esp_err_t adc1_pad_get_io_num(adc1_channel_t channel, gpio_num_t *gpio_num)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
int io = ADC_GET_IO_NUM(ADC_UNIT_1, channel);
if (io < 0) {
return ESP_ERR_INVALID_ARG;
} else {
*gpio_num = (gpio_num_t)io;
}
return ESP_OK;
}
#if (SOC_ADC_PERIPH_NUM >= 2)
esp_err_t adc2_pad_get_io_num(adc2_channel_t channel, gpio_num_t *gpio_num)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_2), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
int io = ADC_GET_IO_NUM(ADC_UNIT_2, channel);
if (io < 0) {
return ESP_ERR_INVALID_ARG;
} else {
*gpio_num = (gpio_num_t)io;
}
return ESP_OK;
}
#endif
//------------------------------------------------------------RTC Single Read----------------------------------------------//
#if SOC_ADC_RTC_CTRL_SUPPORTED
esp_err_t adc_set_clk_div(uint8_t clk_div)
{
DIGI_CONTROLLER_ENTER();
adc_ll_digi_set_clk_div(clk_div);
DIGI_CONTROLLER_EXIT();
return ESP_OK;
}
static void adc_rtc_chan_init(adc_unit_t adc_unit)
{
if (adc_unit == ADC_UNIT_1) {
/* Workaround: Disable the synchronization operation function of ADC1 and DAC.
If enabled(default), ADC RTC controller sampling will cause the DAC channel output voltage. */
#if SOC_DAC_SUPPORTED
dac_ll_rtc_sync_by_adc(false);
#endif
adc_oneshot_ll_output_invert(ADC_UNIT_1, ADC_LL_DATA_INVERT_DEFAULT(ADC_UNIT_1));
adc_ll_set_sar_clk_div(ADC_UNIT_1, ADC_LL_SAR_CLK_DIV_DEFAULT(ADC_UNIT_1));
#ifdef CONFIG_IDF_TARGET_ESP32
adc_ll_hall_disable(); //Disable other peripherals.
adc_ll_amp_disable(); //Currently the LNA is not open, close it by default.
#endif
}
if (adc_unit == ADC_UNIT_2) {
adc_ll_pwdet_set_cct(ADC_LL_PWDET_CCT_DEFAULT);
adc_oneshot_ll_output_invert(ADC_UNIT_2, ADC_LL_DATA_INVERT_DEFAULT(ADC_UNIT_2));
adc_ll_set_sar_clk_div(ADC_UNIT_2, ADC_LL_SAR_CLK_DIV_DEFAULT(ADC_UNIT_2));
}
}
esp_err_t adc_common_gpio_init(adc_unit_t adc_unit, adc_channel_t channel)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(adc_unit), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
gpio_num_t gpio_num = 0;
//If called with `ADC_UNIT_BOTH (ADC_UNIT_1 | ADC_UNIT_2)`, both if blocks will be run
if (adc_unit == ADC_UNIT_1) {
gpio_num = ADC_GET_IO_NUM(ADC_UNIT_1, channel);
} else if (adc_unit == ADC_UNIT_2) {
gpio_num = ADC_GET_IO_NUM(ADC_UNIT_2, channel);
} else {
return ESP_ERR_INVALID_ARG;
}
return gpio_config_as_analog(gpio_num);
}
esp_err_t adc_set_data_inv(adc_unit_t adc_unit, bool inv_en)
{
if (adc_unit == ADC_UNIT_1) {
SARADC1_ENTER();
adc_oneshot_ll_output_invert(ADC_UNIT_1, inv_en);
SARADC1_EXIT();
}
if (adc_unit == ADC_UNIT_2) {
SARADC2_ENTER();
adc_oneshot_ll_output_invert(ADC_UNIT_2, inv_en);
SARADC2_EXIT();
}
return ESP_OK;
}
esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit)
{
ESP_RETURN_ON_FALSE(width_bit < ADC_WIDTH_MAX, ESP_ERR_INVALID_ARG, ADC_TAG, "unsupported bit width");
adc_bitwidth_t bitwidth = 0;
#if CONFIG_IDF_TARGET_ESP32
if ((uint32_t)width_bit == (uint32_t)ADC_BITWIDTH_DEFAULT) {
bitwidth = SOC_ADC_RTC_MAX_BITWIDTH;
} else {
switch (width_bit) {
case ADC_WIDTH_BIT_9:
bitwidth = ADC_BITWIDTH_9;
break;
case ADC_WIDTH_BIT_10:
bitwidth = ADC_BITWIDTH_10;
break;
case ADC_WIDTH_BIT_11:
bitwidth = ADC_BITWIDTH_11;
break;
case ADC_WIDTH_BIT_12:
bitwidth = ADC_BITWIDTH_12;
break;
default:
return ESP_ERR_INVALID_ARG;
}
}
#elif CONFIG_IDF_TARGET_ESP32S2
bitwidth = ADC_BITWIDTH_13;
#else //esp32s3
bitwidth = ADC_BITWIDTH_12;
#endif
if (adc_unit == ADC_UNIT_1) {
SARADC1_ENTER();
adc_oneshot_ll_set_output_bits(ADC_UNIT_1, bitwidth);
SARADC1_EXIT();
}
if (adc_unit == ADC_UNIT_2) {
SARADC2_ENTER();
adc_oneshot_ll_set_output_bits(ADC_UNIT_2, bitwidth);
SARADC2_EXIT();
}
return ESP_OK;
}
/**
* @brief Reset RTC controller FSM.
*
* @return
* - ESP_OK Success
*/
#if !CONFIG_IDF_TARGET_ESP32
esp_err_t adc_rtc_reset(void)
{
FSM_ENTER();
adc_ll_rtc_reset();
FSM_EXIT();
return ESP_OK;
}
#endif
/*-------------------------------------------------------------------------------------
* ADC1
*------------------------------------------------------------------------------------*/
esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
ESP_RETURN_ON_FALSE(atten < SOC_ADC_ATTEN_NUM, ESP_ERR_INVALID_ARG, ADC_TAG, "ADC Atten Err");
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
if (!clk_src_freq_hz) {
//should never fail
esp_clk_tree_src_get_freq_hz(ADC_DIGI_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &clk_src_freq_hz);
}
#endif //#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
adc_common_gpio_init(ADC_UNIT_1, channel);
SARADC1_ENTER();
adc_rtc_chan_init(ADC_UNIT_1);
adc_oneshot_ll_set_atten(ADC_UNIT_1, channel, atten);
SARADC1_EXIT();
return ESP_OK;
}
esp_err_t adc1_config_width(adc_bits_width_t width_bit)
{
ESP_RETURN_ON_FALSE(width_bit < ADC_WIDTH_MAX, ESP_ERR_INVALID_ARG, ADC_TAG, "unsupported bit width");
adc_bitwidth_t bitwidth = 0;
#if CONFIG_IDF_TARGET_ESP32
if ((uint32_t)width_bit == (uint32_t)ADC_BITWIDTH_DEFAULT) {
bitwidth = SOC_ADC_RTC_MAX_BITWIDTH;
} else {
switch (width_bit) {
case ADC_WIDTH_BIT_9:
bitwidth = ADC_BITWIDTH_9;
break;
case ADC_WIDTH_BIT_10:
bitwidth = ADC_BITWIDTH_10;
break;
case ADC_WIDTH_BIT_11:
bitwidth = ADC_BITWIDTH_11;
break;
case ADC_WIDTH_BIT_12:
bitwidth = ADC_BITWIDTH_12;
break;
default:
return ESP_ERR_INVALID_ARG;
}
}
#elif CONFIG_IDF_TARGET_ESP32S2
bitwidth = ADC_BITWIDTH_13;
#else //esp32s3
bitwidth = ADC_BITWIDTH_12;
#endif
SARADC1_ENTER();
adc_oneshot_ll_set_output_bits(ADC_UNIT_1, bitwidth);
SARADC1_EXIT();
return ESP_OK;
}
esp_err_t adc1_dma_mode_acquire(void)
{
/* Use locks to avoid digtal and RTC controller conflicts.
for adc1, block until acquire the lock. */
SARADC1_ACQUIRE();
ESP_LOGD(ADC_TAG, "dma mode takes adc1 lock.");
sar_periph_ctrl_adc_continuous_power_acquire();
SARADC1_ENTER();
/* switch SARADC into DIG channel */
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_DIG);
SARADC1_EXIT();
return ESP_OK;
}
esp_err_t adc1_rtc_mode_acquire(void)
{
/* Use locks to avoid digtal and RTC controller conflicts.
for adc1, block until acquire the lock. */
SARADC1_ACQUIRE();
sar_periph_ctrl_adc_oneshot_power_acquire();
SARADC1_ENTER();
/* switch SARADC into RTC channel. */
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_RTC);
SARADC1_EXIT();
return ESP_OK;
}
esp_err_t adc1_lock_release(void)
{
ESP_RETURN_ON_FALSE((uint32_t *)adc1_dma_lock != NULL, ESP_ERR_INVALID_STATE, ADC_TAG, "adc1 lock release called before acquire");
/* Use locks to avoid digtal and RTC controller conflicts. for adc1, block until acquire the lock. */
sar_periph_ctrl_adc_oneshot_power_release();
SARADC1_RELEASE();
return ESP_OK;
}
int adc1_get_raw(adc1_channel_t channel)
{
int adc_value;
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
adc1_rtc_mode_acquire();
ANALOG_CLOCK_ENABLE();
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_1);
adc_atten_t atten = adc_ll_get_atten(ADC_UNIT_1, channel);
adc_set_hw_calibration_code(ADC_UNIT_1, atten);
#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED
ANALOG_CLOCK_DISABLE();
SARADC1_ENTER();
#ifdef CONFIG_IDF_TARGET_ESP32
adc_ll_hall_disable(); //Disable other peripherals.
adc_ll_amp_disable(); //Currently the LNA is not open, close it by default.
#endif
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_RTC); //Set controller
adc_oneshot_ll_set_channel(ADC_UNIT_1, channel);
adc_hal_convert(ADC_UNIT_1, channel, clk_src_freq_hz, &adc_value); //Start conversion, For ADC1, the data always valid.
#if !CONFIG_IDF_TARGET_ESP32
adc_ll_rtc_reset(); //Reset FSM of rtc controller
#endif
SARADC1_EXIT();
adc1_lock_release();
return adc_value;
}
int adc1_get_voltage(adc1_channel_t channel) //Deprecated. Use adc1_get_raw() instead
{
return adc1_get_raw(channel);
}
#if SOC_ULP_SUPPORTED
void adc1_ulp_enable(void)
{
sar_periph_ctrl_adc_oneshot_power_acquire();
SARADC1_ENTER();
adc_ll_set_controller(ADC_UNIT_1, ADC_LL_CTRL_ULP);
/* since most users do not need LNA and HALL with uLP, we disable them here
open them in the uLP if needed. */
#ifdef CONFIG_IDF_TARGET_ESP32
/* disable other peripherals. */
adc_ll_hall_disable();
adc_ll_amp_disable();
#endif
SARADC1_EXIT();
}
#endif
#if (SOC_ADC_PERIPH_NUM >= 2)
/*---------------------------------------------------------------
ADC2
---------------------------------------------------------------*/
esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_2), ESP_ERR_INVALID_ARG, ADC_TAG, "invalid channel");
ESP_RETURN_ON_FALSE(atten <= SOC_ADC_ATTEN_NUM, ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 Atten Err");
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
if (!clk_src_freq_hz) {
//should never fail
esp_clk_tree_src_get_freq_hz(ADC_DIGI_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &clk_src_freq_hz);
}
#endif //#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
adc_common_gpio_init(ADC_UNIT_2, channel);
#if CONFIG_IDF_TARGET_ESP32
/** For ESP32S2 and S3, the right to use ADC2 is controlled by the arbiter, and there is no need to set a lock.*/
if (adc_lock_try_acquire(ADC_UNIT_2) != ESP_OK) {
//try the lock, return if failed (wifi using).
return ESP_ERR_TIMEOUT;
}
#endif
//avoid collision with other tasks
SARADC2_ENTER();
adc_rtc_chan_init(ADC_UNIT_2);
adc_oneshot_ll_set_atten(ADC_UNIT_2, channel, atten);
SARADC2_EXIT();
#if CONFIG_IDF_TARGET_ESP32
adc_lock_release(ADC_UNIT_2);
#endif
return ESP_OK;
}
static inline void adc2_init(void)
{
#if CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_PM_ENABLE
/* Lock APB clock. */
if (s_adc2_arbiter_lock == NULL) {
esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "adc2", &s_adc2_arbiter_lock);
}
#endif //CONFIG_PM_ENABLE
#endif //CONFIG_IDF_TARGET_ESP32S2
}
static inline void adc2_dac_disable(adc2_channel_t channel)
{
#if SOC_DAC_SUPPORTED
#ifdef CONFIG_IDF_TARGET_ESP32
if (channel == ADC2_CHANNEL_8) { // the same as DAC channel 0
dac_ll_power_down(DAC_CHAN_0);
} else if (channel == ADC2_CHANNEL_9) {
dac_ll_power_down(DAC_CHAN_1);
}
#else
if (channel == ADC2_CHANNEL_6) { // the same as DAC channel 0
dac_ll_power_down(DAC_CHAN_0);
} else if (channel == ADC2_CHANNEL_7) {
dac_ll_power_down(DAC_CHAN_1);
}
#endif
#endif // SOC_DAC_SUPPORTED
}
/**
* @note For ESP32S2:
* The arbiter's working clock is APB_CLK. When the APB_CLK clock drops below 8 MHz, the arbiter must be in shield mode.
* Or, the RTC controller will fail when get raw data.
* This issue does not occur on digital controllers (DMA mode), and the hardware guarantees that there will be no errors.
*/
esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *raw_out)
{
esp_err_t ret = ESP_OK;
int adc_value = 0;
adc_bitwidth_t bitwidth = 0;
ESP_RETURN_ON_FALSE(raw_out != NULL, ESP_ERR_INVALID_ARG, ADC_TAG, "ADC out value err");
ESP_RETURN_ON_FALSE(channel < ADC2_CHANNEL_MAX, ESP_ERR_INVALID_ARG, ADC_TAG, "ADC Channel Err");
ESP_RETURN_ON_FALSE(width_bit < ADC_WIDTH_MAX, ESP_ERR_INVALID_ARG, ADC_TAG, "unsupported bit width");
#if CONFIG_IDF_TARGET_ESP32
if ((uint32_t)width_bit == (uint32_t)ADC_BITWIDTH_DEFAULT) {
bitwidth = SOC_ADC_RTC_MAX_BITWIDTH;
} else {
switch (width_bit) {
case ADC_WIDTH_BIT_9:
bitwidth = ADC_BITWIDTH_9;
break;
case ADC_WIDTH_BIT_10:
bitwidth = ADC_BITWIDTH_10;
break;
case ADC_WIDTH_BIT_11:
bitwidth = ADC_BITWIDTH_11;
break;
case ADC_WIDTH_BIT_12:
bitwidth = ADC_BITWIDTH_12;
break;
default:
return ESP_ERR_INVALID_ARG;
}
}
#elif CONFIG_IDF_TARGET_ESP32S2
bitwidth = ADC_BITWIDTH_13;
#else //esp32s3
bitwidth = ADC_BITWIDTH_12;
#endif
#if CONFIG_IDF_TARGET_ESP32
/** For ESP32S2 and S3, the right to use ADC2 is controlled by the arbiter, and there is no need to set a lock.*/
if (adc_lock_try_acquire(ADC_UNIT_2) != ESP_OK) {
//try the lock, return if failed (wifi using).
return ESP_ERR_TIMEOUT;
}
#endif
sar_periph_ctrl_adc_oneshot_power_acquire(); //in critical section with whole rtc module
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_2);
adc_atten_t atten = adc_ll_get_atten(ADC_UNIT_2, channel);
adc_set_hw_calibration_code(ADC_UNIT_2, atten);
#endif //SOC_ADC_CALIBRATION_V1_SUPPORTED
//avoid collision with other tasks
adc2_init(); // in critical section with whole rtc module. because the PWDET use the same registers, place it here.
SARADC2_ENTER();
#if SOC_ADC_ARBITER_SUPPORTED
adc_arbiter_t config = ADC_ARBITER_CONFIG_DEFAULT();
adc_hal_arbiter_config(&config);
#endif
#ifdef CONFIG_ADC_DISABLE_DAC
adc2_dac_disable(channel); //disable other peripherals
#endif
adc_oneshot_ll_set_output_bits(ADC_UNIT_2, bitwidth);
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32P4
adc_ll_set_controller(ADC_UNIT_2, ADC_LL_CTRL_RTC);// set controller
#else
adc_ll_set_controller(ADC_UNIT_2, ADC_LL_CTRL_ARB);// set controller
#endif
#if CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_PM_ENABLE
if (s_adc2_arbiter_lock) {
esp_pm_lock_acquire(s_adc2_arbiter_lock);
}
#endif //CONFIG_PM_ENABLE
#endif //CONFIG_IDF_TARGET_ESP32
adc_oneshot_ll_set_channel(ADC_UNIT_2, channel);
ret = adc_hal_convert(ADC_UNIT_2, channel, clk_src_freq_hz, &adc_value);
if (ret != ESP_OK) {
adc_value = -1;
}
#if CONFIG_IDF_TARGET_ESP32S2
#ifdef CONFIG_PM_ENABLE
/* Release APB clock. */
if (s_adc2_arbiter_lock) {
esp_pm_lock_release(s_adc2_arbiter_lock);
}
#endif //CONFIG_PM_ENABLE
#endif //CONFIG_IDF_TARGET_ESP32
SARADC2_EXIT();
sar_periph_ctrl_adc_oneshot_power_release();
#if CONFIG_IDF_TARGET_ESP32
adc_lock_release(ADC_UNIT_2);
#endif
*raw_out = adc_value;
return ret;
}
esp_err_t adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio)
{
#ifdef CONFIG_IDF_TARGET_ESP32
if (adc_unit == ADC_UNIT_1) {
return ESP_ERR_INVALID_ARG;
}
#endif
adc2_channel_t ch = ADC2_CHANNEL_MAX;
/* Check if the GPIO supported. */
for (int i = 0; i < ADC2_CHANNEL_MAX; i++) {
if (gpio == ADC_GET_IO_NUM(ADC_UNIT_2, i)) {
ch = i;
break;
}
}
if (ch == ADC2_CHANNEL_MAX) {
return ESP_ERR_INVALID_ARG;
}
sar_periph_ctrl_adc_oneshot_power_acquire();
if (adc_unit == ADC_UNIT_1) {
VREF_ENTER(1);
adc_ll_vref_output(ADC_UNIT_1, ch, true);
VREF_EXIT(1);
} else if (adc_unit == ADC_UNIT_2) {
VREF_ENTER(2);
adc_ll_vref_output(ADC_UNIT_2, ch, true);
VREF_EXIT(2);
}
//Configure RTC gpio, Only ADC2's channels IO are supported to output reference voltage.
adc_common_gpio_init(ADC_UNIT_2, ch);
return ESP_OK;
}
#endif //SOC_ADC_RTC_CTRL_SUPPORTED
#endif //#if (SOC_ADC_PERIPH_NUM >= 2)
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
/*---------------------------------------------------------------
Legacy ADC Single Read Mode
when RTC controller isn't supported
---------------------------------------------------------------*/
#include "esp_check.h"
portMUX_TYPE adc_reg_lock = portMUX_INITIALIZER_UNLOCKED;
#define ADC_REG_LOCK_ENTER() portENTER_CRITICAL(&adc_reg_lock)
#define ADC_REG_LOCK_EXIT() portEXIT_CRITICAL(&adc_reg_lock)
static adc_atten_t s_atten1_single[ADC1_CHANNEL_MAX]; //Array saving attenuate of each channel of ADC1, used by single read API
#if (SOC_ADC_PERIPH_NUM >= 2)
static adc_atten_t s_atten2_single[ADC2_CHANNEL_MAX]; //Array saving attenuate of each channel of ADC2, used by single read API
#endif
static int8_t adc_digi_get_io_num(adc_unit_t adc_unit, uint8_t adc_channel)
{
assert(adc_unit < SOC_ADC_PERIPH_NUM);
uint8_t adc_n = (adc_unit == ADC_UNIT_1) ? 0 : 1;
return adc_channel_io_map[adc_n][adc_channel];
}
static esp_err_t adc_digi_gpio_init(adc_unit_t adc_unit, uint16_t channel_mask)
{
esp_err_t ret = ESP_OK;
uint32_t n = 0;
int8_t io = 0;
while (channel_mask) {
if (channel_mask & 0x1) {
io = adc_digi_get_io_num(adc_unit, n);
if (io < 0) {
return ESP_ERR_INVALID_ARG;
}
gpio_config_as_analog(io);
}
channel_mask = channel_mask >> 1;
n++;
}
return ret;
}
#if CONFIG_IDF_TARGET_ESP32C3
esp_err_t adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio)
{
esp_err_t ret;
uint32_t channel = ADC2_CHANNEL_MAX;
if (adc_unit == ADC_UNIT_2) {
for (int i = 0; i < ADC2_CHANNEL_MAX; i++) {
if (gpio == ADC_GET_IO_NUM(ADC_UNIT_2, i)) {
channel = i;
break;
}
}
if (channel == ADC2_CHANNEL_MAX) {
return ESP_ERR_INVALID_ARG;
}
}
sar_periph_ctrl_adc_oneshot_power_acquire();
if (adc_unit == ADC_UNIT_1) {
RTC_ENTER_CRITICAL();
adc_ll_vref_output(ADC_UNIT_1, channel, true);
RTC_EXIT_CRITICAL();
} else { //ADC_UNIT_2
RTC_ENTER_CRITICAL();
adc_ll_vref_output(ADC_UNIT_2, channel, true);
RTC_EXIT_CRITICAL();
}
ret = adc_digi_gpio_init(ADC_UNIT_2, BIT(channel));
return ret;
}
#endif
esp_err_t adc1_config_width(adc_bits_width_t width_bit)
{
//On ESP32C3, the data width is always 12-bits.
if (width_bit != ADC_WIDTH_BIT_12) {
return ESP_ERR_INVALID_ARG;
}
return ESP_OK;
}
esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_1), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC1 channel error");
ESP_RETURN_ON_FALSE((atten < SOC_ADC_ATTEN_NUM), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC Atten Err");
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
if (!clk_src_freq_hz) {
//should never fail
esp_clk_tree_src_get_freq_hz(ADC_DIGI_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &clk_src_freq_hz);
}
#endif //#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
esp_err_t ret = ESP_OK;
s_atten1_single[channel] = atten;
ret = adc_digi_gpio_init(ADC_UNIT_1, BIT(channel));
return ret;
}
int adc1_get_raw(adc1_channel_t channel)
{
int raw_out = 0;
if (adc_lock_try_acquire(ADC_UNIT_1) != ESP_OK) {
return ESP_ERR_TIMEOUT;
}
adc_apb_periph_claim();
sar_periph_ctrl_adc_oneshot_power_acquire();
esp_clk_tree_enable_src((soc_module_clk_t)ADC_DIGI_CLK_SRC_DEFAULT, true);
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_DEFAULT);
adc_atten_t atten = s_atten1_single[channel];
ANALOG_CLOCK_ENABLE();
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_1);
adc_set_hw_calibration_code(ADC_UNIT_1, atten);
#endif
ANALOG_CLOCK_DISABLE();
ADC_REG_LOCK_ENTER();
adc_oneshot_ll_set_atten(ADC_UNIT_1, channel, atten);
adc_hal_convert(ADC_UNIT_1, channel, clk_src_freq_hz, &raw_out);
ADC_REG_LOCK_EXIT();
sar_periph_ctrl_adc_oneshot_power_release();
adc_apb_periph_free();
adc_lock_release(ADC_UNIT_1);
return raw_out;
}
#if (SOC_ADC_PERIPH_NUM >= 2)
esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten)
{
ESP_RETURN_ON_FALSE(channel < SOC_ADC_CHANNEL_NUM(ADC_UNIT_2), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 channel error");
ESP_RETURN_ON_FALSE((atten <= ADC_ATTEN_DB_12), ESP_ERR_INVALID_ARG, ADC_TAG, "ADC2 Atten Err");
esp_err_t ret = ESP_OK;
s_atten2_single[channel] = atten;
ret = adc_digi_gpio_init(ADC_UNIT_2, BIT(channel));
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_hal_calibration_init(ADC_UNIT_2);
#endif
return ret;
}
esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *raw_out)
{
//On ESP32C3, the data width is always 12-bits.
if (width_bit != ADC_WIDTH_BIT_12) {
return ESP_ERR_INVALID_ARG;
}
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
if (!clk_src_freq_hz) {
//should never fail
esp_clk_tree_src_get_freq_hz(ADC_DIGI_CLK_SRC_DEFAULT, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &clk_src_freq_hz);
}
#endif //#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
esp_err_t ret = ESP_OK;
if (adc_lock_try_acquire(ADC_UNIT_2) != ESP_OK) {
return ESP_ERR_TIMEOUT;
}
adc_apb_periph_claim();
sar_periph_ctrl_adc_oneshot_power_acquire();
esp_clk_tree_enable_src((soc_module_clk_t)ADC_DIGI_CLK_SRC_DEFAULT, true);
adc_ll_digi_clk_sel(ADC_DIGI_CLK_SRC_DEFAULT);
#if SOC_ADC_ARBITER_SUPPORTED
adc_arbiter_t config = ADC_ARBITER_CONFIG_DEFAULT();
adc_hal_arbiter_config(&config);
#endif
adc_atten_t atten = s_atten2_single[channel];
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
adc_set_hw_calibration_code(ADC_UNIT_2, atten);
#endif
ADC_REG_LOCK_ENTER();
adc_oneshot_ll_set_atten(ADC_UNIT_2, channel, atten);
ret = adc_hal_convert(ADC_UNIT_2, channel, clk_src_freq_hz, raw_out);
ADC_REG_LOCK_EXIT();
sar_periph_ctrl_adc_oneshot_power_release();
adc_apb_periph_free();
adc_lock_release(ADC_UNIT_2);
return ret;
}
#endif //#if (SOC_ADC_PERIPH_NUM >= 2)
#endif //#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
static void adc_hal_onetime_start(adc_unit_t adc_n, uint32_t clk_src_freq_hz)
{
#if SOC_ADC_DIG_CTRL_SUPPORTED && !SOC_ADC_RTC_CTRL_SUPPORTED
(void)adc_n;
/**
* There is a hardware limitation. If the APB clock frequency is high, the step of this reg signal: ``onetime_start`` may not be captured by the
* ADC digital controller (when its clock frequency is too slow). A rough estimate for this step should be at least 3 ADC digital controller
* clock cycle.
*/
uint32_t digi_clk = clk_src_freq_hz / (ADC_LL_CLKM_DIV_NUM_DEFAULT + ADC_LL_CLKM_DIV_A_DEFAULT / ADC_LL_CLKM_DIV_B_DEFAULT + 1);
//Convert frequency to time (us). Since decimals are removed by this division operation. Add 1 here in case of the fact that delay is not enough.
uint32_t delay = (1000 * 1000) / digi_clk + 1;
//3 ADC digital controller clock cycle
delay = delay * 3;
//This coefficient (8) is got from test, and verified from DT. When digi_clk is not smaller than ``APB_CLK_FREQ/8``, no delay is needed.
if (digi_clk >= APB_CLK_FREQ / 8) {
delay = 0;
}
adc_oneshot_ll_start(false);
esp_rom_delay_us(delay);
adc_oneshot_ll_start(true);
//No need to delay here. Because if the start signal is not seen, there won't be a done intr.
#else
(void)clk_src_freq_hz;
adc_oneshot_ll_start(adc_n);
#endif
}
static esp_err_t adc_hal_convert(adc_unit_t adc_n, int channel, uint32_t clk_src_freq_hz, int *out_raw)
{
uint32_t event = (adc_n == ADC_UNIT_1) ? ADC_LL_EVENT_ADC1_ONESHOT_DONE : ADC_LL_EVENT_ADC2_ONESHOT_DONE;
adc_oneshot_ll_clear_event(event);
adc_oneshot_ll_disable_all_unit();
adc_oneshot_ll_enable(adc_n);
adc_oneshot_ll_set_channel(adc_n, channel);
adc_hal_onetime_start(adc_n, clk_src_freq_hz);
while (adc_oneshot_ll_get_event(event) != true) {
;
}
*out_raw = adc_oneshot_ll_get_raw_result(adc_n);
if (adc_oneshot_ll_raw_check_valid(adc_n, *out_raw) == false) {
return ESP_ERR_INVALID_STATE;
}
//HW workaround: when enabling periph clock, this should be false
adc_oneshot_ll_disable_all_unit();
return ESP_OK;
}
#if !CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that adc_oneshot driver is not running along with the legacy adc oneshot driver
*/
__attribute__((constructor))
static void check_adc_oneshot_driver_conflict(void)
{
// This function was declared as weak here. adc_oneshot driver has one implementation.
// So if adc_oneshot driver is not linked in, then `adc_oneshot_new_unit` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t adc_oneshot_new_unit(const void *init_config, void **ret_unit);
if ((void *)adc_oneshot_new_unit != NULL) {
ESP_EARLY_LOGE(ADC_TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
abort();
}
ESP_EARLY_LOGW(ADC_TAG, "legacy driver is deprecated, please migrate to `esp_adc/adc_oneshot.h`");
}
#endif //CONFIG_ADC_SKIP_LEGACY_CONFLICT_CHECK
#if SOC_ADC_CALIBRATION_V1_SUPPORTED
/*---------------------------------------------------------------
ADC Hardware Calibration
---------------------------------------------------------------*/
static __attribute__((constructor)) void adc_hw_calibration(void)
{
ANALOG_CLOCK_ENABLE();
//Calculate all ICode
for (int i = 0; i < SOC_ADC_PERIPH_NUM; i++) {
adc_hal_calibration_init(i);
for (int j = 0; j < SOC_ADC_ATTEN_NUM; j++) {
/**
* This may get wrong when attenuations are NOT consecutive on some chips,
* update this when bringing up the calibration on that chip
*/
adc_calc_hw_calibration_code(i, j);
#if SOC_ADC_CALIB_CHAN_COMPENS_SUPPORTED
/* Load the channel compensation from efuse */
for (int k = 0; k < SOC_ADC_CHANNEL_NUM(i); k++) {
adc_load_hw_calibration_chan_compens(i, k, j);
}
#endif
}
}
ANALOG_CLOCK_DISABLE();
}
#endif //#if SOC_ADC_CALIBRATION_V1_SUPPORTED
@@ -1,144 +0,0 @@
/*
* SPDX-FileCopyrightText: 2019-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "esp_check.h"
#include "freertos/FreeRTOS.h"
#include "esp_private/gpio.h"
#include "driver/dac_types_legacy.h"
#include "soc/dac_periph.h"
#include "hal/gpio_types.h"
#include "hal/dac_ll.h"
#include "clk_ctrl_os.h"
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
static __attribute__((unused)) const char *TAG = "DAC";
/*---------------------------------------------------------------
DAC
---------------------------------------------------------------*/
esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
*gpio_num = (gpio_num_t)dac_periph_signal.dac_channel_io_num[channel];
return ESP_OK;
}
static esp_err_t dac_rtc_pad_init(dac_channel_t channel)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
gpio_num_t gpio_num = 0;
dac_pad_get_io_num(channel, &gpio_num);
gpio_config_as_analog(gpio_num);
return ESP_OK;
}
esp_err_t dac_output_enable(dac_channel_t channel)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
dac_rtc_pad_init(channel);
portENTER_CRITICAL(&rtc_spinlock);
dac_ll_power_on(channel);
dac_ll_rtc_sync_by_adc(false);
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_output_disable(dac_channel_t channel)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
portENTER_CRITICAL(&rtc_spinlock);
dac_ll_power_down(channel);
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
portENTER_CRITICAL(&rtc_spinlock);
dac_ll_update_output_value(channel, dac_value);
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_out_voltage(dac_channel_t channel, uint8_t dac_value)
{
ESP_RETURN_ON_FALSE(channel < SOC_DAC_CHAN_NUM, ESP_ERR_INVALID_ARG, TAG, "DAC channel error");
portENTER_CRITICAL(&rtc_spinlock);
dac_ll_update_output_value(channel, dac_value);
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_cw_generator_enable(void)
{
portENTER_CRITICAL(&rtc_spinlock);
periph_rtc_dig_clk8m_enable();
dac_ll_cw_generator_enable();
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_cw_generator_disable(void)
{
portENTER_CRITICAL(&rtc_spinlock);
dac_ll_cw_generator_disable();
periph_rtc_dig_clk8m_disable();
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
esp_err_t dac_cw_generator_config(dac_cw_config_t *cw)
{
ESP_RETURN_ON_FALSE(cw, ESP_ERR_INVALID_ARG, TAG, "invalid clock configuration");
portENTER_CRITICAL(&rtc_spinlock);
/* Enable the rtc8m clock temporary to get the correct frequency */
periph_rtc_dig_clk8m_enable();
uint32_t rtc_freq = periph_rtc_dig_clk8m_get_freq();
periph_rtc_dig_clk8m_disable();
dac_ll_cw_set_freq(cw->freq, rtc_freq);
dac_ll_cw_set_atten(cw->en_ch, (dac_cosine_atten_t)cw->scale);
dac_ll_cw_set_phase(cw->en_ch, (dac_cosine_phase_t)cw->phase);
dac_ll_cw_set_dc_offset(cw->en_ch, cw->offset);
dac_ll_cw_enable_channel(cw->en_ch, true);
portEXIT_CRITICAL(&rtc_spinlock);
return ESP_OK;
}
#if !CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that this legacy DAC driver is not running along with the new driver
*/
__attribute__((constructor))
static void check_dac_legacy_driver_conflict(void)
{
// This function was declared as weak here. The new DAC driver has one implementation.
// So if the new DAC driver is not linked in, then `dac_priv_register_channel()` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t dac_priv_register_channel(dac_channel_t chan_id, const char *mode_name);
if ((void *)dac_priv_register_channel != NULL) {
ESP_EARLY_LOGE(TAG, "CONFLICT! The new DAC driver is not allowed to be used together with the legacy driver");
abort();
}
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/dac_oneshot.h`, `driver/dac_cosine.h` or `driver/dac_continuous.h` instead");
}
#endif //CONFIG_DAC_SKIP_LEGACY_CONFLICT_CHECK
-355
View File
@@ -1,355 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*----------------------------------------------------------------------------------
This file contains Deprecated ADC APIs
-----------------------------------------------------------------------------------*/
#pragma once
#include "sdkconfig.h"
#include "esp_err.h"
#include "driver/gpio.h"
#include "driver/adc_types_legacy.h"
#include "hal/adc_types.h"
#if !CONFIG_ADC_SUPPRESS_DEPRECATE_WARN
#warning "legacy adc driver is deprecated, please migrate to use esp_adc/adc_oneshot.h and esp_adc/adc_continuous.h for oneshot mode and continuous mode drivers respectively"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*---------------------------------------------------------------
Deprecated API
---------------------------------------------------------------*/
/*---------------------------------------------------------------
ADC Single Read Setting
---------------------------------------------------------------*/
/**
* @brief Get the GPIO number of a specific ADC1 channel.
*
* @param channel Channel to get the GPIO number
* @param gpio_num output buffer to hold the GPIO number
*
* @return
* - ESP_OK if success
* - ESP_ERR_INVALID_ARG if channel not valid
*/
esp_err_t adc1_pad_get_io_num(adc1_channel_t channel, gpio_num_t *gpio_num);
/**
* @brief Set the attenuation of a particular channel on ADC1, and configure its associated GPIO pin mux.
*
* The default ADC voltage is for attenuation 0 dB and listed in the table below.
* By setting higher attenuation it is possible to read higher voltages.
*
* Due to ADC characteristics, most accurate results are obtained within the "suggested range"
* shown in the following table.
*
* +----------+-------------+-----------------+
* | | attenuation | suggested range |
* | SoC | (dB) | (mV) |
* +==========+=============+=================+
* | | 0 | 100 ~ 950 |
* | +-------------+-----------------+
* | | 2.5 | 100 ~ 1250 |
* | ESP32 +-------------+-----------------+
* | | 6 | 150 ~ 1750 |
* | +-------------+-----------------+
* | | 11 | 150 ~ 2450 |
* +----------+-------------+-----------------+
* | | 0 | 0 ~ 750 |
* | +-------------+-----------------+
* | | 2.5 | 0 ~ 1050 |
* | ESP32-S2 +-------------+-----------------+
* | | 6 | 0 ~ 1300 |
* | +-------------+-----------------+
* | | 11 | 0 ~ 2500 |
* +----------+-------------+-----------------+
*
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
*
* @note For any given channel, this function must be called before the first time ``adc1_get_raw()`` is called for that channel.
*
* @note This function can be called multiple times to configure multiple
* ADC channels simultaneously. You may call ``adc1_get_raw()`` only after configuring a channel.
*
* @param channel ADC1 channel to configure
* @param atten Attenuation level
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc1_config_channel_atten(adc1_channel_t channel, adc_atten_t atten);
/**
* @brief Configure ADC1 capture width, meanwhile enable output invert for ADC1.
* The configuration is for all channels of ADC1
* @param width_bit Bit capture width for ADC1
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc1_config_width(adc_bits_width_t width_bit);
/**
* @brief Take an ADC1 reading from a single channel.
* @note ESP32:
* When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
* As a workaround, call sar_periph_ctrl_adc_oneshot_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
* but will remove the glitches on GPIO36 and GPIO39.
*
* @note Call ``adc1_config_width()`` before the first time this
* function is called.
*
* @note For any given channel, adc1_config_channel_atten(channel)
* must be called before the first time this function is called. Configuring
* a new channel does not prevent a previously configured channel from being read.
*
* @param channel ADC1 channel to read
*
* @return
* - -1: Parameter error
* - Other: ADC1 channel reading.
*/
int adc1_get_raw(adc1_channel_t channel);
#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
//TODO IDF-3610, replace these with proper caps
/**
* @brief Set ADC data invert
* @param adc_unit ADC unit index
* @param inv_en whether enable data invert
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc_set_data_inv(adc_unit_t adc_unit, bool inv_en);
/**
* @brief Set ADC source clock
* @param clk_div ADC clock divider, ADC clock is divided from APB clock
* @return
* - ESP_OK success
*/
esp_err_t adc_set_clk_div(uint8_t clk_div);
/**
* @brief Configure ADC capture width.
*
* @param adc_unit ADC unit index
* @param width_bit Bit capture width for ADC unit.
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc_set_data_width(adc_unit_t adc_unit, adc_bits_width_t width_bit);
/**
* @brief Configure ADC1 to be usable by the ULP
*
* This function reconfigures ADC1 to be controlled by the ULP.
* Effect of this function can be reverted using ``adc1_get_raw()`` function.
*
* Note that adc1_config_channel_atten, ``adc1_config_width()`` functions need
* to be called to configure ADC1 channels, before ADC1 is used by the ULP.
*/
void adc1_ulp_enable(void);
#endif //#if CONFIG_IDF_TARGET_ESP32 || CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3
#if (SOC_ADC_PERIPH_NUM >= 2)
/**
* @brief Get the GPIO number of a specific ADC2 channel.
*
* @param channel Channel to get the GPIO number
*
* @param gpio_num output buffer to hold the GPIO number
*
* @return
* - ESP_OK if success
* - ESP_ERR_INVALID_ARG if channel not valid
*/
esp_err_t adc2_pad_get_io_num(adc2_channel_t channel, gpio_num_t *gpio_num);
/**
* @brief Configure the ADC2 channel, including setting attenuation.
*
* The default ADC voltage is for attenuation 0 dB and listed in the table below.
* By setting higher attenuation it is possible to read higher voltages.
*
* Due to ADC characteristics, most accurate results are obtained within the "suggested range"
* shown in the following table.
*
* +----------+-------------+-----------------+
* | | attenuation | suggested range |
* | SoC | (dB) | (mV) |
* +==========+=============+=================+
* | | 0 | 100 ~ 950 |
* | +-------------+-----------------+
* | | 2.5 | 100 ~ 1250 |
* | ESP32 +-------------+-----------------+
* | | 6 | 150 ~ 1750 |
* | +-------------+-----------------+
* | | 11 | 150 ~ 2450 |
* +----------+-------------+-----------------+
* | | 0 | 0 ~ 750 |
* | +-------------+-----------------+
* | | 2.5 | 0 ~ 1050 |
* | ESP32-S2 +-------------+-----------------+
* | | 6 | 0 ~ 1300 |
* | +-------------+-----------------+
* | | 11 | 0 ~ 2500 |
* +----------+-------------+-----------------+
*
* For maximum accuracy, use the ADC calibration APIs and measure voltages within these recommended ranges.
*
* @note This function also configures the input GPIO pin mux to
* connect it to the ADC2 channel. It must be called before calling
* ``adc2_get_raw()`` for this channel.
*
* @note For any given channel, this function must be called before the first time ``adc2_get_raw()`` is called for that channel.
*
* @param channel ADC2 channel to configure
* @param atten Attenuation level
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc2_config_channel_atten(adc2_channel_t channel, adc_atten_t atten);
/**
* @brief Take an ADC2 reading on a single channel
*
* @note ESP32:
* When the power switch of SARADC1, SARADC2, HALL sensor and AMP sensor is turned on,
* the input of GPIO36 and GPIO39 will be pulled down for about 80ns.
* When enabling power for any of these peripherals, ignore input from GPIO36 and GPIO39.
* Please refer to section 3.11 of 'ECO_and_Workarounds_for_Bugs_in_ESP32' for the description of this issue.
* As a workaround, call sar_periph_ctrl_adc_oneshot_power_acquire() in the app. This will result in higher power consumption (by ~1mA),
* but will remove the glitches on GPIO36 and GPIO39.
*
*
* @note ESP32:
* For a given channel, ``adc2_config_channel_atten()``
* must be called before the first time this function is called. If Wi-Fi is started via ``esp_wifi_start()``, this
* function will always fail with ``ESP_ERR_TIMEOUT``.
*
* @note ESP32-S2:
* ADC2 support hardware arbiter. The arbiter is to improve the use efficiency of ADC2. After the control right is robbed by the high priority,
* the low priority controller will read the invalid ADC2 data. Default priority: Wi-Fi > RTC > Digital;
*
* @param channel ADC2 channel to read
* @param width_bit Bit capture width for ADC2
* @param raw_out the variable to hold the output data.
*
* @return
* - ESP_OK if success
* - ESP_ERR_TIMEOUT ADC2 is being used by other controller and the request timed out.
* - ESP_ERR_INVALID_STATE The controller status is invalid. Please try again.
*/
esp_err_t adc2_get_raw(adc2_channel_t channel, adc_bits_width_t width_bit, int *raw_out);
/**
* @brief Output ADC1 or ADC2's reference voltage to ``adc2_channe_t``'s IO.
*
* This function routes the internal reference voltage of ADCn to one of
* ADC2's channels. This reference voltage can then be manually measured
* for calibration purposes.
*
* @note ESP32 only supports output of ADC2's internal reference voltage.
* @param[in] adc_unit ADC unit index
* @param[in] gpio GPIO number (Only ADC2's channels IO are supported)
*
* @return
* - ESP_OK: v_ref successfully routed to selected GPIO
* - ESP_ERR_INVALID_ARG: Unsupported GPIO
*/
esp_err_t adc_vref_to_gpio(adc_unit_t adc_unit, gpio_num_t gpio);
#endif //#if (SOC_ADC_PERIPH_NUM >= 2)
/*---------------------------------------------------------------
ADC DMA Read Setting
---------------------------------------------------------------*/
#if SOC_ADC_DMA_SUPPORTED
/**
* @brief Initialize the Digital ADC.
*
* @param init_config Pointer to Digital ADC initialization config. Refer to ``adc_digi_init_config_t``.
*
* @return
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid.
* - ESP_ERR_NOT_FOUND No free interrupt found with the specified flags
* - ESP_ERR_NO_MEM If out of memory
* - ESP_OK On success
*/
esp_err_t adc_digi_initialize(const adc_digi_init_config_t *init_config);
/**
* @brief Read bytes from Digital ADC through DMA.
*
* @param[out] buf Buffer to read from ADC.
* @param[in] length_max Expected length of data read from the ADC.
* @param[out] out_length Real length of data read from the ADC via this API.
* @param[in] timeout_ms Time to wait for data via this API, in millisecond.
*
* @return
* - ESP_ERR_INVALID_STATE Driver state is invalid. Usually it means the ADC sampling rate is faster than the task processing rate.
* - ESP_ERR_TIMEOUT Operation timed out
* - ESP_OK On success
*/
esp_err_t adc_digi_read_bytes(uint8_t *buf, uint32_t length_max, uint32_t *out_length, uint32_t timeout_ms);
/**
* @brief Start the Digital ADC and DMA peripherals. After this, the hardware starts working.
*
* @return
* - ESP_ERR_INVALID_STATE Driver state is invalid.
* - ESP_OK On success
*/
esp_err_t adc_digi_start(void);
/**
* @brief Stop the Digital ADC and DMA peripherals. After this, the hardware stops working.
*
* @return
* - ESP_ERR_INVALID_STATE Driver state is invalid.
* - ESP_OK On success
*/
esp_err_t adc_digi_stop(void);
/**
* @brief Deinitialize the Digital ADC.
*
* @return
* - ESP_ERR_INVALID_STATE Driver state is invalid.
* - ESP_OK On success
*/
esp_err_t adc_digi_deinitialize(void);
/**
* @brief Setting the digital controller.
*
* @param config Pointer to digital controller parameter. Refer to ``adc_digi_config_t``.
*
* @return
* - ESP_ERR_INVALID_STATE Driver state is invalid.
* - ESP_ERR_INVALID_ARG If the combination of arguments is invalid.
* - ESP_OK On success
*/
esp_err_t adc_digi_controller_configure(const adc_digi_configuration_t *config);
#endif
#ifdef __cplusplus
}
#endif
@@ -1,51 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "sdkconfig.h"
#include "esp_err.h"
#include "hal/adc_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifdef CONFIG_IDF_TARGET_ESP32
/**
* @brief ESP32 ADC DMA source selection.
*/
typedef enum {
ADC_I2S_DATA_SRC_IO_SIG = 0, /*!< I2S data from GPIO matrix signal */
ADC_I2S_DATA_SRC_ADC = 1, /*!< I2S data from ADC */
} adc_i2s_source_t;
#endif
#if CONFIG_IDF_TARGET_ESP32
/*---------------------------------------------------------------
ESP32 Deprecated API
---------------------------------------------------------------*/
/**
* @brief Set I2S data source
* @param src I2S DMA data source, I2S DMA can get data from digital signals or from ADC.
* @return
* - ESP_OK success
*/
esp_err_t adc_set_i2s_data_source(adc_i2s_source_t src);
/**
* @brief Initialize I2S ADC mode
* @param adc_unit ADC unit index
* @param channel ADC channel index
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t adc_i2s_mode_init(adc_unit_t adc_unit, adc_channel_t channel);
#endif
#ifdef __cplusplus
}
#endif
@@ -1,130 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "hal/adc_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief ADC resolution setting option.
* @note Only used in single read mode
*/
typedef enum {
#if CONFIG_IDF_TARGET_ESP32
ADC_WIDTH_BIT_9 = 9, /*!< ADC capture width is 9Bit. */
ADC_WIDTH_BIT_10 = 10, /*!< ADC capture width is 10Bit. */
ADC_WIDTH_BIT_11 = 11, /*!< ADC capture width is 11Bit. */
ADC_WIDTH_BIT_12 = 12, /*!< ADC capture width is 12Bit. */
#elif SOC_ADC_RTC_MAX_BITWIDTH == 12
ADC_WIDTH_BIT_12 = 12, /*!< ADC capture width is 12Bit. */
#elif SOC_ADC_RTC_MAX_BITWIDTH == 13
ADC_WIDTH_BIT_13 = 13, /*!< ADC capture width is 13Bit. */
#endif
ADC_WIDTH_MAX,
} adc_bits_width_t;
/**
* The default (max) bit width of the ADC of current version. You can also get the maximum bitwidth
* by `SOC_ADC_RTC_MAX_BITWIDTH` defined in soc_caps.h.
*/
#define ADC_WIDTH_BIT_DEFAULT (ADC_WIDTH_MAX-1)
typedef enum {
ADC1_CHANNEL_0 = 0,
ADC1_CHANNEL_1,
ADC1_CHANNEL_2,
ADC1_CHANNEL_3,
#if SOC_ADC_CHANNEL_NUM(0) > 4
ADC1_CHANNEL_4,
#endif
#if SOC_ADC_CHANNEL_NUM(0) > 5
ADC1_CHANNEL_5,
#endif
#if SOC_ADC_CHANNEL_NUM(0) > 6
ADC1_CHANNEL_6,
#endif
#if SOC_ADC_CHANNEL_NUM(0) > 7
ADC1_CHANNEL_7,
#endif
#if SOC_ADC_CHANNEL_NUM(0) > 8
ADC1_CHANNEL_8,
#endif
#if SOC_ADC_CHANNEL_NUM(0) > 9
ADC1_CHANNEL_9,
#endif
ADC1_CHANNEL_MAX = SOC_ADC_CHANNEL_NUM(0),
} adc1_channel_t;
#if SOC_ADC_PERIPH_NUM > 1
typedef enum {
ADC2_CHANNEL_0 = 0,
#if SOC_ADC_CHANNEL_NUM(1) > 1
ADC2_CHANNEL_1,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 2
ADC2_CHANNEL_2,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 3
ADC2_CHANNEL_3,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 4
ADC2_CHANNEL_4,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 5
ADC2_CHANNEL_5,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 6
ADC2_CHANNEL_6,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 7
ADC2_CHANNEL_7,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 8
ADC2_CHANNEL_8,
#endif
#if SOC_ADC_CHANNEL_NUM(1) > 9
ADC2_CHANNEL_9,
#endif
ADC2_CHANNEL_MAX = SOC_ADC_CHANNEL_NUM(1),
} adc2_channel_t;
#endif
#if SOC_ADC_DMA_SUPPORTED
/**
* @brief Digital ADC DMA read max timeout value, it may make the ``adc_digi_read_bytes`` block forever if the OS supports
*/
#define ADC_MAX_DELAY UINT32_MAX
/**
* @brief ADC DMA driver configuration
*/
typedef struct adc_digi_init_config_s {
uint32_t max_store_buf_size; ///< Max length of the converted data that driver can store before they are processed.
uint32_t conv_num_each_intr; ///< Bytes of data that can be converted in 1 interrupt. This should be in multiples of `SOC_ADC_DIGI_DATA_BYTES_PER_CONV`.
uint32_t adc1_chan_mask; ///< Channel list of ADC1 to be initialized.
uint32_t adc2_chan_mask; ///< Channel list of ADC2 to be initialized.
} adc_digi_init_config_t;
/**
* @brief ADC digital controller settings
*/
typedef struct {
bool conv_limit_en; ///< Suggest leaving it empty, this parameter has been deprecated
uint32_t conv_limit_num; ///< suggest leaving it empty, this parameter has been deprecated
uint32_t pattern_num; ///< Number of ADC channels that will be used
adc_digi_pattern_config_t *adc_pattern; ///< List of configs for each ADC channel that will be used
uint32_t sample_freq_hz; /*!< Please refer to `soc/soc_caps.h` to know the ADC sampling frequency range*/
adc_digi_convert_mode_t conv_mode; ///< ADC DMA conversion mode, see `adc_digi_convert_mode_t`.
adc_digi_output_format_t format; ///< ADC DMA conversion output format, see `adc_digi_output_format_t`.
} adc_digi_configuration_t;
#endif // #if SOC_ADC_DMA_SUPPORTED
#ifdef __cplusplus
}
#endif
-171
View File
@@ -1,171 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "esp_err.h"
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "driver/dac_types_legacy.h"
#if !CONFIG_DAC_SUPPRESS_DEPRECATE_WARN
#warning "The legacy DAC driver is deprecated, please use `driver/dac_oneshot.h`, `driver/dac_cosine.h` or `driver/dac_continuous.h` instead"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Get the GPIO number of a specific DAC channel.
*
* @param channel Channel to get the gpio number
* @param gpio_num output buffer to hold the gpio number
* @return
* - ESP_OK if success
*/
esp_err_t dac_pad_get_io_num(dac_channel_t channel, gpio_num_t *gpio_num);
/**
* @brief Set DAC output voltage.
* DAC output is 8-bit. Maximum (255) corresponds to VDD3P3_RTC.
*
* @note Need to configure DAC pad before calling this function.
* DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
* @param channel DAC channel
* @param dac_value DAC output value
*
* @return
* - ESP_OK success
*/
esp_err_t dac_output_voltage(dac_channel_t channel, uint8_t dac_value);
/**
* @brief DAC pad output enable
*
* @param channel DAC channel
* @note DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
* I2S left channel will be mapped to DAC channel 1
* I2S right channel will be mapped to DAC channel 0
*/
esp_err_t dac_output_enable(dac_channel_t channel);
/**
* @brief DAC pad output disable
*
* @param channel DAC channel
* @note DAC channel 0 is attached to GPIO25, DAC channel 1 is attached to GPIO26
* @return
* - ESP_OK success
*/
esp_err_t dac_output_disable(dac_channel_t channel);
/**
* @brief Enable cosine wave generator output.
*
* @return
* - ESP_OK success
*/
esp_err_t dac_cw_generator_enable(void);
/**
* @brief Disable cosine wave generator output.
*
* @return
* - ESP_OK success
*/
esp_err_t dac_cw_generator_disable(void);
/**
* @brief Config the cosine wave generator function in DAC module.
*
* @param cw Configuration.
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG The parameter is NULL.
*/
esp_err_t dac_cw_generator_config(dac_cw_config_t *cw);
/*---------------------------------------------------------------
Digital controller setting
---------------------------------------------------------------*/
#if CONFIG_IDF_TARGET_ESP32
/**
* @brief Enable DAC output data from I2S
*
* @return
* - ESP_OK success
*/
esp_err_t dac_i2s_enable(void);
/**
* @brief Disable DAC output data from I2S
*
* @return
* - ESP_OK success
*/
esp_err_t dac_i2s_disable(void);
#endif // CONFIG_IDF_TARGET_ESP32
#if CONFIG_IDF_TARGET_ESP32S2
/**
* @brief DAC digital controller initialization.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_init(void);
/**
* @brief DAC digital controller deinitialization.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_deinit(void);
/**
* @brief Setting the DAC digital controller.
*
* @param cfg Pointer to digital controller parameter. See ``dac_digi_config_t``.
*
* @return
* - ESP_OK success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t dac_digi_controller_config(const dac_digi_config_t *cfg);
/**
* @brief DAC digital controller start output voltage.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_start(void);
/**
* @brief DAC digital controller stop output voltage.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_stop(void);
/**
* @brief Reset DAC digital controller FIFO.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_fifo_reset(void);
/**
* @brief Reset DAC digital controller.
* @return
* - ESP_OK success
*/
esp_err_t dac_digi_reset(void);
#endif // CONFIG_IDF_TARGET_ESP32S2
#ifdef __cplusplus
}
#endif
@@ -1,79 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stddef.h>
#include "sdkconfig.h"
#include "hal/dac_types.h"
#if CONFIG_IDF_TARGET_ESP32S2
#include "hal/adc_types.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief The multiple of the amplitude of the cosine wave generator. The max amplitude is VDD3P3_RTC.
*/
typedef enum {
DAC_CW_SCALE_1 = 0x0, /*!< 1/1. Default. */
DAC_CW_SCALE_2 = 0x1, /*!< 1/2. */
DAC_CW_SCALE_4 = 0x2, /*!< 1/4. */
DAC_CW_SCALE_8 = 0x3, /*!< 1/8. */
} dac_cw_scale_t;
/**
* @brief Set the phase of the cosine wave generator output.
*/
typedef enum {
DAC_CW_PHASE_0 = 0x2, /*!< Phase shift +0° */
DAC_CW_PHASE_180 = 0x3, /*!< Phase shift +180° */
} dac_cw_phase_t;
#if CONFIG_IDF_TARGET_ESP32S2
/**
* @brief DAC digital controller (DMA mode) work mode.
*/
typedef enum {
DAC_CONV_NORMAL, /*!< The data in the DMA buffer is simultaneously output to the enable channel of the DAC. */
DAC_CONV_ALTER, /*!< The data in the DMA buffer is alternately output to the enable channel of the DAC. */
DAC_CONV_MAX
} dac_digi_convert_mode_t;
/**
* @brief DAC digital controller (DMA mode) configuration parameters.
*/
typedef struct {
dac_digi_convert_mode_t mode; /*!<DAC digital controller (DMA mode) work mode. See ``dac_digi_convert_mode_t``. */
uint32_t interval; /*!<The number of interval clock cycles for the DAC digital controller to output voltage.
The unit is the divided clock. Range: 1 ~ 4095.
Expression: `dac_output_freq` = `controller_clk` / interval. Refer to ``adc_digi_clk_t``.
Note: The sampling rate of each channel is also related to the conversion mode (See ``dac_digi_convert_mode_t``) and pattern table settings. */
adc_digi_clk_t dig_clk; /*!<DAC digital controller clock divider settings. Refer to ``adc_digi_clk_t``.
Note: The clocks of the DAC digital controller use the ADC digital controller clock divider. */
} dac_digi_config_t;
#endif
/**
* @brief Config the cosine wave generator function in DAC module.
*/
typedef struct {
dac_channel_t en_ch; /*!< Enable the cosine wave generator of DAC channel. */
dac_cw_scale_t scale; /*!< Set the amplitude of the cosine wave generator output. */
dac_cw_phase_t phase; /*!< Set the phase of the cosine wave generator output. */
uint32_t freq; /*!< Set frequency of cosine wave generator output. Range: 130(130Hz) ~ 55000(100KHz). */
int8_t offset; /*!< Set the voltage value of the DC component of the cosine wave generator output.
Note: Unreasonable settings can cause waveform to be oversaturated. Range: -128 ~ 127. */
} dac_cw_config_t;
#ifdef __cplusplus
}
#endif
-383
View File
@@ -1,383 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* This file is for the backward compatible to the deprecated I2S APIs,
* The deprecated APIs will no longer supported in the future
* Please refer to "driver/i2s_std.h", "driver/i2s_pdm.h" and ""driver/i2s_tdm.h"" for the latest I2S driver
* Note that only one set of I2S APIs is allowed to be used at the same time
*/
#pragma once
#include "esp_types.h"
#include "esp_err.h"
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#include "driver/i2s_types_legacy.h"
#if SOC_I2S_SUPPORTS_ADC
#include "driver/adc.h"
#endif
#if !CONFIG_I2S_SUPPRESS_DEPRECATE_WARN
#warning "This set of I2S APIs has been deprecated, \
please include 'driver/i2s_std.h', 'driver/i2s_pdm.h' or 'driver/i2s_tdm.h' instead. \
if you want to keep using the old APIs and ignore this warning, \
you can enable 'Suppress legacy driver deprecated warning' option under 'I2S Configuration' menu in Kconfig"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Set I2S pin number
*
* @note
* The I2S peripheral output signals can be connected to multiple GPIO pads.
* However, the I2S peripheral input signal can only be connected to one GPIO pad.
*
* @param i2s_num I2S port number
*
* @param pin I2S Pin structure, or NULL to set 2-channel 8-bit internal DAC pin configuration (GPIO25 & GPIO26)
*
* Inside the pin configuration structure, set I2S_PIN_NO_CHANGE for any pin where
* the current configuration should not be changed.
*
* @note if *pin is set as NULL, this function will initialize both of the built-in DAC channels by default.
* if you don't want this to happen and you want to initialize only one of the DAC channels, you can call i2s_set_dac_mode instead.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_FAIL IO error
*/
esp_err_t i2s_set_pin(i2s_port_t i2s_num, const i2s_pin_config_t *pin);
#if SOC_I2S_SUPPORTS_PDM_RX
/**
* @brief Set PDM mode down-sample rate
* In PDM RX mode, there would be 2 rounds of downsample process in hardware.
* In the first downsample process, the sampling number can be 16 or 8.
* In the second downsample process, the sampling number is fixed as 8.
* So the clock frequency in PDM RX mode would be (fpcm * 64) or (fpcm * 128) accordingly.
* @param i2s_num I2S port number
* @param downsample i2s RX down sample rate for PDM mode.
*
* @note After calling this function, it would call i2s_set_clk inside to update the clock frequency.
* Please call this function after I2S driver has been initialized.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_NO_MEM Out of memory
*/
esp_err_t i2s_set_pdm_rx_down_sample(i2s_port_t i2s_num, i2s_pdm_dsr_t downsample);
#endif
#if SOC_I2S_SUPPORTS_PDM_TX
/**
* @brief Set TX PDM mode up-sample rate
* @note If you have set PDM mode while calling 'i2s_driver_install',
* default PDM TX upsample parameters have already been set,
* no need to call this function again if you don't have to change the default configuration
*
* @param i2s_num I2S port number
* @param upsample_cfg Set I2S PDM up-sample rate configuration
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_NO_MEM Out of memory
*/
esp_err_t i2s_set_pdm_tx_up_sample(i2s_port_t i2s_num, const i2s_pdm_tx_upsample_cfg_t *upsample_cfg);
#endif
/**
* @brief Install and start I2S driver.
*
* @param i2s_num I2S port number
*
* @param i2s_config I2S configurations - see i2s_config_t struct
*
* @param queue_size I2S event queue size/depth.
*
* @param i2s_queue I2S event queue handle, if set NULL, driver will not use an event queue.
*
* This function must be called before any I2S driver read/write operations.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_NO_MEM Out of memory
* - ESP_ERR_INVALID_STATE Current I2S port is in use
*/
esp_err_t i2s_driver_install(i2s_port_t i2s_num, const i2s_config_t *i2s_config, int queue_size, void *i2s_queue);
/**
* @brief Uninstall I2S driver.
*
* @param i2s_num I2S port number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_INVALID_STATE I2S port has been uninstalled by others (e.g. LCD i80)
*/
esp_err_t i2s_driver_uninstall(i2s_port_t i2s_num);
/**
* @brief Write data to I2S DMA transmit buffer.
*
* @param i2s_num I2S port number
*
* @param src Source address to write from
*
* @param size Size of data in bytes
*
* @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in.
*
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
* many ticks pass without space becoming available in the DMA
* transmit buffer, then the function will return (note that if the
* data is written to the DMA buffer in pieces, the overall operation
* may still take longer than this timeout.) Pass portMAX_DELAY for no
* timeout.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_write(i2s_port_t i2s_num, const void *src, size_t size, size_t *bytes_written, TickType_t ticks_to_wait);
/**
* @brief Write data to I2S DMA transmit buffer while expanding the number of bits per sample. For example, expanding 16-bit PCM to 32-bit PCM.
*
* @param i2s_num I2S port number
*
* @param src Source address to write from
*
* @param size Size of data in bytes
*
* @param src_bits Source audio bit
*
* @param aim_bits Bit wanted, no more than 32, and must be greater than src_bits
*
* @param[out] bytes_written Number of bytes written, if timeout, the result will be less than the size passed in.
*
* @param ticks_to_wait TX buffer wait timeout in RTOS ticks. If this
* many ticks pass without space becoming available in the DMA
* transmit buffer, then the function will return (note that if the
* data is written to the DMA buffer in pieces, the overall operation
* may still take longer than this timeout.) Pass portMAX_DELAY for no
* timeout.
*
* Format of the data in source buffer is determined by the I2S
* configuration (see i2s_config_t).
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_write_expand(i2s_port_t i2s_num, const void *src, size_t size, size_t src_bits, size_t aim_bits, size_t *bytes_written, TickType_t ticks_to_wait);
/**
* @brief Read data from I2S DMA receive buffer
*
* @param i2s_num I2S port number
*
* @param dest Destination address to read into
*
* @param size Size of data in bytes
*
* @param[out] bytes_read Number of bytes read, if timeout, bytes read will be less than the size passed in.
*
* @param ticks_to_wait RX buffer wait timeout in RTOS ticks. If this many ticks pass without bytes becoming available in the DMA receive buffer, then the function will return (note that if data is read from the DMA buffer in pieces, the overall operation may still take longer than this timeout.) Pass portMAX_DELAY for no timeout.
*
* @note If the built-in ADC mode is enabled, we should call i2s_adc_enable and i2s_adc_disable around the whole reading process,
* to prevent the data getting corrupted.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_read(i2s_port_t i2s_num, void *dest, size_t size, size_t *bytes_read, TickType_t ticks_to_wait);
/**
* @brief Set sample rate used for I2S RX and TX.
*
* The bit clock rate is determined by the sample rate and i2s_config_t configuration parameters (number of channels, bits_per_sample).
*
* `bit_clock = rate * (number of channels) * bits_per_sample`
*
* @param i2s_num I2S port number
*
* @param rate I2S sample rate (ex: 8000, 44100...)
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_NO_MEM Out of memory
*/
esp_err_t i2s_set_sample_rates(i2s_port_t i2s_num, uint32_t rate);
/**
* @brief Stop I2S driver
*
* There is no need to call i2s_stop() before calling i2s_driver_uninstall().
*
* Disables I2S TX/RX, until i2s_start() is called.
*
* @param i2s_num I2S port number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_stop(i2s_port_t i2s_num);
/**
* @brief Start I2S driver
*
* It is not necessary to call this function after i2s_driver_install() (it is started automatically), however it is necessary to call it after i2s_stop().
*
*
* @param i2s_num I2S port number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_start(i2s_port_t i2s_num);
/**
* @brief Zero the contents of the TX DMA buffer.
*
* Pushes zero-byte samples into the TX DMA buffer, until it is full.
*
* @param i2s_num I2S port number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_zero_dma_buffer(i2s_port_t i2s_num);
#if SOC_I2S_SUPPORTS_PCM
/**
* @brief Configure I2S a/u-law decompress or compress
*
* @note This function should be called after i2s driver installed
* Only take effecttive when the i2s 'communication_format' is set to 'I2S_COMM_FORMAT_STAND_PCM_SHORT' or 'I2S_COMM_FORMAT_STAND_PCM_LONG'
*
* @param i2s_num I2S port number
*
* @param pcm_cfg including mode selection and a/u-law decompress or compress configuration parameter
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_pcm_config(i2s_port_t i2s_num, const i2s_pcm_cfg_t *pcm_cfg);
#endif
/**
* @brief Set clock & bit width used for I2S RX and TX.
*
* Similar to i2s_set_sample_rates(), but also sets bit width.
*
* 1. stop i2s;
* 2. calculate mclk, bck, bck_factor
* 3. malloc dma buffer;
* 4. start i2s
*
* @param i2s_num I2S port number
*
* @param rate I2S sample rate (ex: 8000, 44100...)
*
* @param bits_cfg I2S bits configuration
* the low 16 bits is for data bits per sample in one channel (see 'i2s_bits_per_sample_t')
* the high 16 bits is for total bits in one channel (see 'i2s_bits_per_chan_t')
* high 16bits =0 means same as the bits per sample.
*
* @param ch I2S channel, (I2S_CHANNEL_MONO, I2S_CHANNEL_STEREO or specific channel in TDM mode)
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_NO_MEM Out of memory
*/
esp_err_t i2s_set_clk(i2s_port_t i2s_num, uint32_t rate, uint32_t bits_cfg, i2s_channel_t ch);
/**
* @brief get clock set on particular port number.
*
* @param i2s_num I2S port number
*
* @return
* - actual clock set by i2s driver
*/
float i2s_get_clk(i2s_port_t i2s_num);
#if SOC_I2S_SUPPORTS_ADC
/**
* @brief Set built-in ADC mode for I2S DMA, this function will initialize ADC pad,
* and set ADC parameters.
* @note In this mode, the ADC maximum sampling rate is 150KHz. Set the sampling rate through ``i2s_config_t``.
* @param adc_unit SAR ADC unit index
* @param adc_channel ADC channel index
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_set_adc_mode(adc_unit_t adc_unit, adc1_channel_t adc_channel);
/**
* @brief Start to use I2S built-in ADC mode
* @note This function would acquire the lock of ADC to prevent the data getting corrupted
* during the I2S peripheral is being used to do fully continuous ADC sampling.
*
* @param i2s_num i2s port index
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_INVALID_STATE Driver state error
*/
esp_err_t i2s_adc_enable(i2s_port_t i2s_num);
/**
* @brief Stop to use I2S built-in ADC mode
* @param i2s_num i2s port index
* @note This function would release the lock of ADC so that other tasks can use ADC.
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
* - ESP_ERR_INVALID_STATE Driver state error
*/
esp_err_t i2s_adc_disable(i2s_port_t i2s_num);
#endif // SOC_I2S_SUPPORTS_ADC
#if SOC_I2S_SUPPORTS_DAC
/**
* @brief Set I2S dac mode, I2S built-in DAC is disabled by default
*
* @param dac_mode DAC mode configurations - see i2s_dac_mode_t
*
* @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip.
* If either of the built-in DAC channel are enabled, the other one can not
* be used as RTC DAC function at the same time.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t i2s_set_dac_mode(i2s_dac_mode_t dac_mode);
#endif //SOC_I2S_SUPPORTS_DAC
#ifdef __cplusplus
}
#endif
@@ -1,251 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/**
* This file is for the backward compatible to the deprecated I2S APIs,
* The deprecated APIs will no longer supported in the future
* Please refer to "hal/i2s_types.h" for the latest I2S driver types
* Note that only one set of I2S APIs is allowed to be used at the same time
*/
#pragma once
#include "hal/i2s_types.h"
#include "driver/i2s_types.h"
#ifdef __cplusplus
extern "C" {
#endif
/******************** Deprecated Types **********************/
#define I2S_PIN_NO_CHANGE (-1) /*!< Used in i2s_pin_config_t for pins which should not be changed */
/**
* @brief I2S bit width per sample.
*/
typedef enum {
I2S_BITS_PER_SAMPLE_8BIT = 8, /*!< data bit-width: 8 */
I2S_BITS_PER_SAMPLE_16BIT = 16, /*!< data bit-width: 16 */
I2S_BITS_PER_SAMPLE_24BIT = 24, /*!< data bit-width: 24 */
I2S_BITS_PER_SAMPLE_32BIT = 32, /*!< data bit-width: 32 */
} i2s_bits_per_sample_t;
/**
* @brief I2S bit width per chan.
*/
typedef enum {
I2S_BITS_PER_CHAN_DEFAULT = (0), /*!< channel bit-width equals to data bit-width */
I2S_BITS_PER_CHAN_8BIT = (8), /*!< channel bit-width: 8 */
I2S_BITS_PER_CHAN_16BIT = (16), /*!< channel bit-width: 16 */
I2S_BITS_PER_CHAN_24BIT = (24), /*!< channel bit-width: 24 */
I2S_BITS_PER_CHAN_32BIT = (32), /*!< channel bit-width: 32 */
} i2s_bits_per_chan_t;
/**
* @brief I2S channel.
*/
typedef enum {
I2S_CHANNEL_MONO = 1, /*!< I2S channel (mono), one channel activated. In this mode, you only need to send one channel data but the fifo will copy same data for the other unactivated channels automatically, then both channels will transmit same data. */
I2S_CHANNEL_STEREO = 2, /*!< I2S channel (stereo), two (or more) channels activated. In this mode, these channels will transmit different data. */
#if SOC_I2S_SUPPORTS_TDM
// Bit map of activated chan.
// There are 16 channels in TDM mode.
// For TX module, only the activated channel send the audio data, the unactivated channel send a constant(configurable) or will be skipped if 'skip_msk' is set.
// For RX module, only receive the audio data in activated channels, the data in unactivated channels will be ignored.
// the bit map of activated channel can not exceed the maximum enabled channel number (i.e. 0x10000 << total_chan_num).
// e.g: active_chan_mask = (I2S_TDM_ACTIVE_CH0 | I2S_TDM_ACTIVE_CH3), here the active_chan_number is 2 and total_chan_num is not supposed to be smaller than 4.
I2S_TDM_ACTIVE_CH0 = (0x1 << 16), /*!< I2S channel 0 activated */
I2S_TDM_ACTIVE_CH1 = (0x1 << 17), /*!< I2S channel 1 activated */
I2S_TDM_ACTIVE_CH2 = (0x1 << 18), /*!< I2S channel 2 activated */
I2S_TDM_ACTIVE_CH3 = (0x1 << 19), /*!< I2S channel 3 activated */
I2S_TDM_ACTIVE_CH4 = (0x1 << 20), /*!< I2S channel 4 activated */
I2S_TDM_ACTIVE_CH5 = (0x1 << 21), /*!< I2S channel 5 activated */
I2S_TDM_ACTIVE_CH6 = (0x1 << 22), /*!< I2S channel 6 activated */
I2S_TDM_ACTIVE_CH7 = (0x1 << 23), /*!< I2S channel 7 activated */
I2S_TDM_ACTIVE_CH8 = (0x1 << 24), /*!< I2S channel 8 activated */
I2S_TDM_ACTIVE_CH9 = (0x1 << 25), /*!< I2S channel 9 activated */
I2S_TDM_ACTIVE_CH10 = (0x1 << 26), /*!< I2S channel 10 activated */
I2S_TDM_ACTIVE_CH11 = (0x1 << 27), /*!< I2S channel 11 activated */
I2S_TDM_ACTIVE_CH12 = (0x1 << 28), /*!< I2S channel 12 activated */
I2S_TDM_ACTIVE_CH13 = (0x1 << 29), /*!< I2S channel 13 activated */
I2S_TDM_ACTIVE_CH14 = (0x1 << 30), /*!< I2S channel 14 activated */
I2S_TDM_ACTIVE_CH15 = (0x1 << 31), /*!< I2S channel 15 activated */
#endif
} i2s_channel_t;
/**
* @brief I2S communication standard format
*/
typedef enum {
I2S_COMM_FORMAT_STAND_I2S = 0X01, /*!< I2S communication I2S Philips standard, data launch at second BCK*/
I2S_COMM_FORMAT_STAND_MSB = 0X02, /*!< I2S communication MSB alignment standard, data launch at first BCK*/
I2S_COMM_FORMAT_STAND_PCM_SHORT = 0x04, /*!< PCM Short standard, also known as DSP mode. The period of synchronization signal (WS) is 1 bck cycle.*/
I2S_COMM_FORMAT_STAND_PCM_LONG = 0x0C, /*!< PCM Long standard. The period of synchronization signal (WS) is channel_bit*bck cycles.*/
I2S_COMM_FORMAT_STAND_MAX, /*!< standard max*/
//old definition will be removed in the future.
I2S_COMM_FORMAT_I2S __attribute__((deprecated)) = 0x01, /*!< I2S communication format I2S, correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
I2S_COMM_FORMAT_I2S_MSB __attribute__((deprecated)) = 0x01, /*!< I2S format MSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_MSB) correspond to `I2S_COMM_FORMAT_STAND_I2S`*/
I2S_COMM_FORMAT_I2S_LSB __attribute__((deprecated)) = 0x02, /*!< I2S format LSB, (I2S_COMM_FORMAT_I2S |I2S_COMM_FORMAT_I2S_LSB) correspond to `I2S_COMM_FORMAT_STAND_MSB`*/
I2S_COMM_FORMAT_PCM __attribute__((deprecated)) = 0x04, /*!< I2S communication format PCM, correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
I2S_COMM_FORMAT_PCM_SHORT __attribute__((deprecated)) = 0x04, /*!< PCM Short, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_SHORT) correspond to `I2S_COMM_FORMAT_STAND_PCM_SHORT`*/
I2S_COMM_FORMAT_PCM_LONG __attribute__((deprecated)) = 0x08, /*!< PCM Long, (I2S_COMM_FORMAT_PCM | I2S_COMM_FORMAT_PCM_LONG) correspond to `I2S_COMM_FORMAT_STAND_PCM_LONG`*/
} i2s_comm_format_t;
/**
* @brief I2S channel format type
*/
typedef enum {
I2S_CHANNEL_FMT_RIGHT_LEFT, /*!< Separated left and right channel */
I2S_CHANNEL_FMT_ALL_RIGHT, /*!< Load right channel data in both two channels */
I2S_CHANNEL_FMT_ALL_LEFT, /*!< Load left channel data in both two channels */
I2S_CHANNEL_FMT_ONLY_RIGHT, /*!< Only load data in right channel (mono mode) */
I2S_CHANNEL_FMT_ONLY_LEFT, /*!< Only load data in left channel (mono mode) */
#if SOC_I2S_SUPPORTS_TDM
// Multiple channels are available with TDM feature
I2S_CHANNEL_FMT_MULTIPLE, /*!< More than two channels are used */
#endif
} i2s_channel_fmt_t;
/**
* @brief I2S Mode
*/
typedef enum {
I2S_MODE_MASTER = (0x1 << 0), /*!< Master mode*/
I2S_MODE_SLAVE = (0x1 << 1), /*!< Slave mode*/
I2S_MODE_TX = (0x1 << 2), /*!< TX mode*/
I2S_MODE_RX = (0x1 << 3), /*!< RX mode*/
#if SOC_I2S_SUPPORTS_DAC
//built-in DAC functions are only supported on I2S0 for ESP32 chip.
I2S_MODE_DAC_BUILT_IN = (0x1 << 4), /*!< Output I2S data to built-in DAC, no matter the data format is 16bit or 32 bit, the DAC module will only take the 8bits from MSB*/
#endif // SOC_I2S_SUPPORTS_DAC
#if SOC_I2S_SUPPORTS_ADC
I2S_MODE_ADC_BUILT_IN = (0x1 << 5), /*!< Input I2S data from built-in ADC, each data can be 12-bit width at most*/
#endif // SOC_I2S_SUPPORTS_ADC
// PDM functions are only supported on I2S0 (all chips).
I2S_MODE_PDM = (0x1 << 6), /*!< I2S PDM mode*/
} i2s_mode_t;
#if SOC_I2S_SUPPORTS_DAC
/**
* @brief I2S DAC mode for i2s_set_dac_mode.
*
* @note Built-in DAC functions are only supported on I2S0 for current ESP32 chip.
*/
typedef enum {
I2S_DAC_CHANNEL_DISABLE = 0, /*!< Disable I2S built-in DAC signals*/
I2S_DAC_CHANNEL_RIGHT_EN = 1, /*!< Enable I2S built-in DAC right channel, maps to DAC channel 0 on GPIO25*/
I2S_DAC_CHANNEL_LEFT_EN = 2, /*!< Enable I2S built-in DAC left channel, maps to DAC channel 1 on GPIO26*/
I2S_DAC_CHANNEL_BOTH_EN = 0x3, /*!< Enable both of the I2S built-in DAC channels.*/
I2S_DAC_CHANNEL_MAX = 0x4, /*!< I2S built-in DAC mode max index*/
} i2s_dac_mode_t;
#endif //SOC_I2S_SUPPORTS_DAC
/**
* @brief I2S event queue types
*/
typedef enum {
I2S_EVENT_DMA_ERROR, /*!< I2S DMA has no next descriptor for sending or receiving */
I2S_EVENT_TX_DONE, /*!< I2S DMA finished sending one DMA buffer */
I2S_EVENT_RX_DONE, /*!< I2S DMA finished receiving one DMA buffer */
I2S_EVENT_TX_Q_OVF, /*!< I2S DMA sending queue overflowed, the oldest data has been overwritten by the new data in the DMA buffer */
I2S_EVENT_RX_Q_OVF, /*!< I2S DMA receive queue overflowed, the oldest data has been overwritten by the new data in the DMA buffer */
} i2s_event_type_t;
/**
* @brief Event structure used in I2S event queue
*/
typedef struct {
i2s_event_type_t type; /*!< I2S event type */
size_t size; /*!< I2S data size for I2S_DATA event*/
} i2s_event_t;
/**
* @brief I2S GPIO pins configuration
*/
typedef struct {
int mck_io_num; /*!< MCK pin, output */
int bck_io_num; /*!< BCK pin, input in slave role, output in master role */
int ws_io_num; /*!< WS pin, input in slave role, output in master role */
int data_out_num; /*!< DATA pin, output */
int data_in_num; /*!< DATA pin, input */
} i2s_pin_config_t;
#if SOC_I2S_SUPPORTS_PCM
/**
* @brief I2S PCM configuration
*
*/
typedef struct {
i2s_pcm_compress_t pcm_type; /*!< I2S PCM a/u-law decompress or compress type */
} i2s_pcm_cfg_t;
#endif
#if SOC_I2S_SUPPORTS_PDM_TX
/**
* @brief Default I2S PDM Up-Sampling Rate configuration
*/
#define I2S_PDM_DEFAULT_UPSAMPLE_CONFIG(rate) { \
.sample_rate = rate, \
.fp = 960, \
.fs = (rate) / 100, \
}
/**
* @brief I2S PDM up-sample rate configuration
* @note TX PDM can only be set to the following two up-sampling rate configurations:
* 1: fp = 960, fs = sample_rate / 100, in this case, Fpdm = 128*48000
* 2: fp = 960, fs = 480, in this case, Fpdm = 128*Fpcm = 128*sample_rate
* If the pdm receiver do not care the pdm serial clock, it's recommended set Fpdm = 128*48000.
* Otherwise, the second configuration should be applied.
*/
typedef struct {
int sample_rate; /*!< I2S PDM sample rate */
int fp; /*!< I2S PDM TX up-sampling parameter. Normally it should be set to 960 */
int fs; /*!< I2S PDM TX up-sampling parameter. When it is set to 480, the pdm clock frequency Fpdm = 128 * sample_rate, when it is set to sample_rate / 100 Fpdm will be fixed to 128*48000 */
} i2s_pdm_tx_upsample_cfg_t;
#endif
/**
* @brief I2S driver configuration parameters
*
*/
typedef struct {
i2s_mode_t mode; /*!< I2S work mode */
uint32_t sample_rate; /*!< I2S sample rate */
i2s_bits_per_sample_t bits_per_sample; /*!< I2S sample bits in one channel */
i2s_channel_fmt_t channel_format; /*!< I2S channel format.*/
i2s_comm_format_t communication_format; /*!< I2S communication format */
int intr_alloc_flags; /*!< Flags used to allocate the interrupt. One or multiple (ORred) ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info */
union {
int dma_desc_num; /*!< The total number of descriptors used by I2S DMA to receive/transmit data */
int dma_buf_count __attribute__((deprecated)); /*!< This is an alias to 'dma_desc_num' for backward compatibility */
};
union {
int dma_frame_num; /*!< Frame number for one-time sampling. Frame here means the total data from all the channels in a WS cycle */
int dma_buf_len __attribute__((deprecated)); /*!< This is an alias to 'dma_frame_num' for backward compatibility */
};
bool use_apll; /*!< I2S using APLL as main I2S clock, enable it to get accurate clock */
bool tx_desc_auto_clear; /*!< I2S auto clear tx descriptor if there is underflow condition (helps in avoiding noise in case of data unavailability) */
int fixed_mclk; /*!< I2S using fixed MCLK output. If use_apll = true and fixed_mclk > 0, then the clock output for i2s is fixed and equal to the fixed_mclk value. If fixed_mclk set, mclk_multiple won't take effect */
i2s_mclk_multiple_t mclk_multiple; /*!< The multiple of I2S master clock(MCLK) to sample rate */
i2s_bits_per_chan_t bits_per_chan; /*!< I2S total bits in one channel only take effect when larger than 'bits_per_sample', default '0' means equal to 'bits_per_sample' */
#if SOC_I2S_SUPPORTS_TDM
i2s_channel_t chan_mask; /*!< I2S active channel bit mask, set value in `i2s_channel_t` to enable specific channel, the bit map of active channel can not exceed (0x1<<total_chan). */
uint32_t total_chan; /*!< I2S Total number of channels. If it is smaller than the biggest active channel number, it will be set to this number automatically. */
bool left_align; /*!< Set to enable left alignment */
bool big_edin; /*!< Set to enable big endian */
bool bit_order_msb; /*!< Set to enable msb order */
bool skip_msk; /*!< Set to enable skip mask. If it is enabled, only the data of the enabled channels will be sent, otherwise all data stored in DMA TX buffer will be sent */
#endif // SOC_I2S_SUPPORTS_TDM
} i2s_driver_config_t;
typedef i2s_driver_config_t i2s_config_t; // for backward compatible
#ifdef __cplusplus
}
#endif
-366
View File
@@ -1,366 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "sdkconfig.h"
#include "esp_err.h"
#include "driver/pcnt_types_legacy.h"
#if !CONFIG_PCNT_SUPPRESS_DEPRECATE_WARN
#warning "legacy pcnt driver is deprecated, please migrate to use driver/pulse_cnt.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Configure Pulse Counter unit
* @note
* This function will disable three events: PCNT_EVT_L_LIM, PCNT_EVT_H_LIM, PCNT_EVT_ZERO.
*
* @param pcnt_config Pointer of Pulse Counter unit configure parameter
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver already initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_unit_config(const pcnt_config_t *pcnt_config);
/**
* @brief Get pulse counter value
*
* @param pcnt_unit Pulse Counter unit number
* @param count Pointer to accept counter value
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_get_counter_value(pcnt_unit_t pcnt_unit, int16_t *count);
/**
* @brief Pause PCNT counter of PCNT unit
*
* @param pcnt_unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_counter_pause(pcnt_unit_t pcnt_unit);
/**
* @brief Resume counting for PCNT counter
*
* @param pcnt_unit PCNT unit number, select from pcnt_unit_t
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_counter_resume(pcnt_unit_t pcnt_unit);
/**
* @brief Clear and reset PCNT counter value to zero
*
* @param pcnt_unit PCNT unit number, select from pcnt_unit_t
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_counter_clear(pcnt_unit_t pcnt_unit);
/**
* @brief Enable PCNT interrupt for PCNT unit
* @note
* Each Pulse counter unit has five watch point events that share the same interrupt.
* Configure events with pcnt_event_enable() and pcnt_event_disable()
*
* @param pcnt_unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_intr_enable(pcnt_unit_t pcnt_unit);
/**
* @brief Disable PCNT interrupt for PCNT unit
*
* @param pcnt_unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_intr_disable(pcnt_unit_t pcnt_unit);
/**
* @brief Enable PCNT event of PCNT unit
*
* @param unit PCNT unit number
* @param evt_type Watch point event type.
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_event_enable(pcnt_unit_t unit, pcnt_evt_type_t evt_type);
/**
* @brief Disable PCNT event of PCNT unit
*
* @param unit PCNT unit number
* @param evt_type Watch point event type.
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_event_disable(pcnt_unit_t unit, pcnt_evt_type_t evt_type);
/**
* @brief Set PCNT event value of PCNT unit
*
* @param unit PCNT unit number
* @param evt_type Watch point event type.
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
*
* @param value Counter value for PCNT event
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_set_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value);
/**
* @brief Get PCNT event value of PCNT unit
*
* @param unit PCNT unit number
* @param evt_type Watch point event type.
* All enabled events share the same interrupt (one interrupt per pulse counter unit).
* @param value Pointer to accept counter value for PCNT event
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value);
/**
* @brief Get PCNT event status of PCNT unit
*
* @param unit PCNT unit number
* @param status Pointer to accept event status word
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_get_event_status(pcnt_unit_t unit, uint32_t *status);
/**
* @brief Unregister PCNT interrupt handler (registered by pcnt_isr_register), the handler is an ISR.
* The handler will be attached to the same CPU core that this function is running on.
* If the interrupt service is registered by pcnt_isr_service_install, please call pcnt_isr_service_uninstall instead
*
* @param handle handle to unregister the ISR service.
*
* @return
* - ESP_OK Success
* - ESP_ERR_NOT_FOUND Can not find the interrupt that matches the flags.
* - ESP_ERR_INVALID_ARG Function pointer error.
*/
esp_err_t pcnt_isr_unregister(pcnt_isr_handle_t handle);
/**
* @brief Register PCNT interrupt handler, the handler is an ISR.
* The handler will be attached to the same CPU core that this function is running on.
* Please do not use pcnt_isr_service_install if this function was called.
*
* @param fn Interrupt handler function.
* @param arg Parameter for handler function
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
* be returned here. Calling pcnt_isr_unregister to unregister this ISR service if needed,
* but only if the handle is not NULL.
*
* @return
* - ESP_OK Success
* - ESP_ERR_NOT_FOUND Can not find the interrupt that matches the flags.
* - ESP_ERR_INVALID_ARG Function pointer error.
*/
esp_err_t pcnt_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, pcnt_isr_handle_t *handle);
/**
* @brief Configure PCNT pulse signal input pin and control input pin
*
* @param unit PCNT unit number
* @param channel PCNT channel number
* @param pulse_io Pulse signal input GPIO
* @param ctrl_io Control signal input GPIO
*
* @note Set the signal input to PCNT_PIN_NOT_USED if unused.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_set_pin(pcnt_unit_t unit, pcnt_channel_t channel, int pulse_io, int ctrl_io);
/**
* @brief Enable PCNT input filter
*
* @param unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_filter_enable(pcnt_unit_t unit);
/**
* @brief Disable PCNT input filter
*
* @param unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_filter_disable(pcnt_unit_t unit);
/**
* @brief Set PCNT filter value
*
* @param unit PCNT unit number
* @param filter_val PCNT signal filter value, counter in APB_CLK cycles.
* Any pulses lasting shorter than this will be ignored when the filter is enabled.
* @note
* filter_val is a 10-bit value, so the maximum filter_val should be limited to 1023.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_set_filter_value(pcnt_unit_t unit, uint16_t filter_val);
/**
* @brief Get PCNT filter value
*
* @param unit PCNT unit number
* @param filter_val Pointer to accept PCNT filter value.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_get_filter_value(pcnt_unit_t unit, uint16_t *filter_val);
/**
* @brief Set PCNT counter mode
*
* @param unit PCNT unit number
* @param channel PCNT channel number
* @param pos_mode Counter mode when detecting positive edge
* @param neg_mode Counter mode when detecting negative edge
* @param hctrl_mode Counter mode when control signal is high level
* @param lctrl_mode Counter mode when control signal is low level
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_set_mode(pcnt_unit_t unit, pcnt_channel_t channel,
pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode,
pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode);
/**
* @brief Add ISR handler for specified unit.
*
* Call this function after using pcnt_isr_service_install() to
* install the PCNT driver's ISR handler service.
*
* The ISR handlers do not need to be declared with IRAM_ATTR,
* unless you pass the ESP_INTR_FLAG_IRAM flag when allocating the
* ISR in pcnt_isr_service_install().
*
* This ISR handler will be called from an ISR. So there is a stack
* size limit (configurable as "ISR stack size" in menuconfig). This
* limit is smaller compared to a global PCNT interrupt handler due
* to the additional level of indirection.
*
* @param unit PCNT unit number
* @param isr_handler Interrupt handler function.
* @param args Parameter for handler function
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_isr_handler_add(pcnt_unit_t unit, void(*isr_handler)(void *), void *args);
/**
* @brief Install PCNT ISR service.
* @note We can manage different interrupt service for each unit.
* This function will use the default ISR handle service, Calling pcnt_isr_service_uninstall to
* uninstall the default service if needed. Please do not use pcnt_isr_register if this function was called.
*
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_NO_MEM No memory to install this service
* - ESP_ERR_INVALID_STATE ISR service already installed
*/
esp_err_t pcnt_isr_service_install(int intr_alloc_flags);
/**
* @brief Uninstall PCNT ISR service, freeing related resources.
*/
void pcnt_isr_service_uninstall(void);
/**
* @brief Delete ISR handler for specified unit.
*
* @param unit PCNT unit number
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE pcnt driver has not been initialized
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit);
#ifdef __cplusplus
}
#endif
@@ -1,108 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "esp_intr_alloc.h"
#include "soc/soc_caps.h"
#include "hal/pcnt_types.h"
#ifdef __cplusplus
extern "C" {
#endif
#define PCNT_PIN_NOT_USED (-1) /*!< When selected for a pin, this pin will not be used */
/**
* @brief PCNT interrupt handle
*/
typedef intr_handle_t pcnt_isr_handle_t;
/**
* @brief PCNT port number, the max port number is (PCNT_PORT_MAX - 1).
*/
typedef enum {
PCNT_PORT_0, /*!< PCNT port 0 */
PCNT_PORT_MAX, /*!< PCNT port max */
} pcnt_port_t;
/**
* @brief Selection of all available PCNT units
*/
typedef enum {
PCNT_UNIT_0, /*!< PCNT unit 0 */
PCNT_UNIT_1, /*!< PCNT unit 1 */
PCNT_UNIT_2, /*!< PCNT unit 2 */
PCNT_UNIT_3, /*!< PCNT unit 3 */
#if SOC_PCNT_UNITS_PER_GROUP > 4
PCNT_UNIT_4, /*!< PCNT unit 4 */
PCNT_UNIT_5, /*!< PCNT unit 5 */
PCNT_UNIT_6, /*!< PCNT unit 6 */
PCNT_UNIT_7, /*!< PCNT unit 7 */
#endif
PCNT_UNIT_MAX,
} pcnt_unit_t;
/**
* @brief Selection of channels available for a single PCNT unit
*/
typedef enum {
PCNT_CHANNEL_0, /*!< PCNT channel 0 */
PCNT_CHANNEL_1, /*!< PCNT channel 1 */
PCNT_CHANNEL_MAX,
} pcnt_channel_t;
/**
* @brief Selection of counter's events the may trigger an interrupt
*/
typedef enum {
PCNT_EVT_THRES_1 = 1 << 2, /*!< PCNT watch point event: threshold1 value event */
PCNT_EVT_THRES_0 = 1 << 3, /*!< PCNT watch point event: threshold0 value event */
PCNT_EVT_L_LIM = 1 << 4, /*!< PCNT watch point event: Minimum counter value */
PCNT_EVT_H_LIM = 1 << 5, /*!< PCNT watch point event: Maximum counter value */
PCNT_EVT_ZERO = 1 << 6, /*!< PCNT watch point event: counter value zero event */
PCNT_EVT_MAX
} pcnt_evt_type_t;
/**
* @brief Selection of available modes that determine the counter's action depending on the state of the control signal's input GPIO
* @note Configuration covers two actions, one for high, and one for low level on the control input
*/
typedef pcnt_channel_level_action_t pcnt_ctrl_mode_t;
#define PCNT_MODE_KEEP PCNT_CHANNEL_LEVEL_ACTION_KEEP /*!< Control mode: won't change counter mode*/
#define PCNT_MODE_REVERSE PCNT_CHANNEL_LEVEL_ACTION_INVERSE /*!< Control mode: invert counter mode(increase -> decrease, decrease -> increase) */
#define PCNT_MODE_DISABLE PCNT_CHANNEL_LEVEL_ACTION_HOLD /*!< Control mode: Inhibit counter(counter value will not change in this condition) */
#define PCNT_MODE_MAX 3
/**
* @brief Selection of available modes that determine the counter's action on the edge of the pulse signal's input GPIO
* @note Configuration covers two actions, one for positive, and one for negative edge on the pulse input
*/
typedef pcnt_channel_edge_action_t pcnt_count_mode_t;
#define PCNT_COUNT_DIS PCNT_CHANNEL_EDGE_ACTION_HOLD /*!< Counter mode: Inhibit counter(counter value will not change in this condition) */
#define PCNT_COUNT_INC PCNT_CHANNEL_EDGE_ACTION_INCREASE /*!< Counter mode: Increase counter value */
#define PCNT_COUNT_DEC PCNT_CHANNEL_EDGE_ACTION_DECREASE /*!< Counter mode: Decrease counter value */
#define PCNT_COUNT_MAX 3
/**
* @brief Pulse Counter configuration for a single channel
*/
typedef struct {
int pulse_gpio_num; /*!< Pulse input GPIO number, if you want to use GPIO16, enter pulse_gpio_num = 16, a negative value will be ignored */
int ctrl_gpio_num; /*!< Control signal input GPIO number, a negative value will be ignored */
pcnt_ctrl_mode_t lctrl_mode; /*!< PCNT low control mode */
pcnt_ctrl_mode_t hctrl_mode; /*!< PCNT high control mode */
pcnt_count_mode_t pos_mode; /*!< PCNT positive edge count mode */
pcnt_count_mode_t neg_mode; /*!< PCNT negative edge count mode */
int16_t counter_h_lim; /*!< Maximum counter value */
int16_t counter_l_lim; /*!< Minimum counter value */
pcnt_unit_t unit; /*!< PCNT unit number */
pcnt_channel_t channel; /*!< the PCNT channel */
} pcnt_config_t;
#ifdef __cplusplus
}
#endif
@@ -1,77 +0,0 @@
/*
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "sdkconfig.h"
#include "esp_err.h"
#include "driver/temp_sensor_types_legacy.h"
#if !CONFIG_TEMP_SENSOR_SUPPRESS_DEPRECATE_WARN
#warning "legacy temperature sensor driver is deprecated, please migrate to driver/temperature_sensor.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Set parameter of temperature sensor.
* @param tsens
* @return
* - ESP_OK Success
*/
esp_err_t temp_sensor_set_config(temp_sensor_config_t tsens);
/**
* @brief Get parameter of temperature sensor.
* @param tsens
* @return
* - ESP_OK Success
*/
esp_err_t temp_sensor_get_config(temp_sensor_config_t *tsens);
/**
* @brief Start temperature sensor measure.
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE if temperature sensor is started already.
*/
esp_err_t temp_sensor_start(void);
/**
* @brief Stop temperature sensor measure.
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_STATE if temperature sensor is stopped already.
*/
esp_err_t temp_sensor_stop(void);
/**
* @brief Read temperature sensor raw data.
* @param tsens_out Pointer to raw data, Range: 0 ~ 255
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG `tsens_out` is NULL
* - ESP_ERR_INVALID_STATE temperature sensor dont start
*/
esp_err_t temp_sensor_read_raw(uint32_t *tsens_out);
/**
* @brief Read temperature sensor data that is converted to degrees Celsius.
* @note Should not be called from interrupt.
* @param celsius The measure output value.
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG ARG is NULL.
* - ESP_ERR_INVALID_STATE The ambient temperature is out of range.
*/
esp_err_t temp_sensor_read_celsius(float *celsius);
#ifdef __cplusplus
}
#endif
@@ -1,39 +0,0 @@
/*
* SPDX-FileCopyrightText: 2010-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include "esp_err.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef enum {
TSENS_DAC_L0 = 0, /*!< offset = -2, measure range: 50℃ ~ 125℃, error < 3℃. */
TSENS_DAC_L1, /*!< offset = -1, measure range: 20℃ ~ 100℃, error < 2℃. */
TSENS_DAC_L2, /*!< offset = 0, measure range:-10℃ ~ 80℃, error < 1℃. */
TSENS_DAC_L3, /*!< offset = 1, measure range:-30℃ ~ 50℃, error < 2℃. */
TSENS_DAC_L4, /*!< offset = 2, measure range:-40℃ ~ 20℃, error < 3℃. */
TSENS_DAC_MAX,
TSENS_DAC_DEFAULT = TSENS_DAC_L2,
} temp_sensor_dac_offset_t;
/**
* @brief Configuration for temperature sensor reading
*/
typedef struct {
temp_sensor_dac_offset_t dac_offset; /*!< The temperature measurement range is configured with a built-in temperature offset DAC. */
uint8_t clk_div; /*!< Default: 6 */
} temp_sensor_config_t;
#define TSENS_CONFIG_DEFAULT() {.dac_offset = TSENS_DAC_L2, \
.clk_div = 6}
#ifdef __cplusplus
}
#endif
-383
View File
@@ -1,383 +0,0 @@
/*
* SPDX-FileCopyrightText: 2010-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <stdint.h>
#include <stdbool.h>
#include "sdkconfig.h"
#include "esp_err.h"
#include "driver/timer_types_legacy.h"
#if !CONFIG_GPTIMER_SUPPRESS_DEPRECATE_WARN
#warning "legacy timer group driver is deprecated, please migrate to driver/gptimer.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Read the counter value of hardware timer.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param timer_val Pointer to accept timer counter value.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_get_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *timer_val);
/**
* @brief Read the counter value of hardware timer, in unit of a given scale.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param time Pointer, type of double*, to accept timer counter value, in seconds.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_get_counter_time_sec(timer_group_t group_num, timer_idx_t timer_num, double *time);
/**
* @brief Set counter value to hardware timer.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param load_val Counter value to write to the hardware timer.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t load_val);
/**
* @brief Start the counter of hardware timer.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_start(timer_group_t group_num, timer_idx_t timer_num);
/**
* @brief Pause the counter of hardware timer.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_pause(timer_group_t group_num, timer_idx_t timer_num);
/**
* @brief Set counting mode for hardware timer.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param counter_dir Counting direction of timer, count-up or count-down
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, timer_count_dir_t counter_dir);
/**
* @brief Enable or disable counter reload function when alarm event occurs.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param reload Counter reload mode.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload);
/**
* @brief Set hardware divider of the source clock to the timer group.
* By default, the source clock is APB clock running at 80 MHz.
* For more information, please check Chapter Reset and Clock in Chip Technical Reference Manual.
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param divider Timer clock divider value. The divider's range is from from 2 to 65536.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_divider(timer_group_t group_num, timer_idx_t timer_num, uint32_t divider);
/**
* @brief Set timer alarm value.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param alarm_value A 64-bit value to set the alarm value.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_value);
/**
* @brief Get timer alarm value.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param alarm_value Pointer of A 64-bit value to accept the alarm value.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *alarm_value);
/**
* @brief Enable or disable generation of timer alarm events.
*
* @param group_num Timer group, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param alarm_en To enable or disable timer alarm function.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_set_alarm(timer_group_t group_num, timer_idx_t timer_num, timer_alarm_t alarm_en);
/**
* @brief Add ISR handle callback for the corresponding timer.
*
* @param group_num Timer group number
* @param timer_num Timer index of timer group
* @param isr_handler Interrupt handler function, it is a callback function.
* @param arg Parameter for handler function
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
*
* @note This ISR handler will be called from an ISR.
* This ISR handler do not need to handle interrupt status, and should be kept short.
* If you want to realize some specific applications or write the whole ISR, you can
* call timer_isr_register(...) to register ISR.
*
* The callback should return a bool value to determine whether need to do YIELD at
* the end of the ISR.
*
* If the intr_alloc_flags value ESP_INTR_FLAG_IRAM is set,
* the handler function must be declared with IRAM_ATTR attribute
* and can only call functions in IRAM or ROM. It cannot call other timer APIs.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_isr_callback_add(timer_group_t group_num, timer_idx_t timer_num, timer_isr_t isr_handler, void *arg, int intr_alloc_flags);
/**
* @brief Remove ISR handle callback for the corresponding timer.
*
* @param group_num Timer group number
* @param timer_num Timer index of timer group
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_isr_callback_remove(timer_group_t group_num, timer_idx_t timer_num);
/**
* @brief Register Timer interrupt handler, the handler is an ISR.
* The handler will be attached to the same CPU core that this function is running on.
*
* @param group_num Timer group number
* @param timer_num Timer index of timer group
* @param fn Interrupt handler function.
* @param arg Parameter for handler function
* @param intr_alloc_flags Flags used to allocate the interrupt. One or multiple (ORred)
* ESP_INTR_FLAG_* values. See esp_intr_alloc.h for more info.
* @param handle Pointer to return handle. If non-NULL, a handle for the interrupt will
* be returned here.
*
* @note If use this function to register ISR, you need to write the whole ISR.
* In the interrupt handler, you need to call timer_spinlock_take(..) before
* your handling, and call timer_spinlock_give(...) after your handling.
*
* If the intr_alloc_flags value ESP_INTR_FLAG_IRAM is set,
* the handler function must be declared with IRAM_ATTR attribute
* and can only call functions in IRAM or ROM. It cannot call other timer APIs.
* Use direct register access to configure timers from inside the ISR in this case.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num, void (*fn)(void *), void *arg, int intr_alloc_flags, timer_isr_handle_t *handle);
/** @brief Initializes and configure the timer.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param config Pointer to timer initialization parameters.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, const timer_config_t *config);
/** @brief Deinitializes the timer.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_deinit(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Get timer configure value.
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index, 0 for hw_timer[0] & 1 for hw_timer[1]
* @param config Pointer of struct to accept timer parameters.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_get_config(timer_group_t group_num, timer_idx_t timer_num, timer_config_t *config);
/** @brief Enable timer group interrupt, by enable mask
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param intr_mask Timer interrupt enable mask.
* - TIMER_INTR_T0: t0 interrupt
* - TIMER_INTR_T1: t1 interrupt
* - TIMER_INTR_WDT: watchdog interrupt
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_group_intr_enable(timer_group_t group_num, timer_intr_t intr_mask);
/** @brief Disable timer group interrupt, by disable mask
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param intr_mask Timer interrupt disable mask.
* - TIMER_INTR_T0: t0 interrupt
* - TIMER_INTR_T1: t1 interrupt
* - TIMER_INTR_WDT: watchdog interrupt
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_group_intr_disable(timer_group_t group_num, timer_intr_t intr_mask);
/** @brief Enable timer interrupt
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_enable_intr(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Disable timer interrupt
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
*
* @return
* - ESP_OK Success
* - ESP_ERR_INVALID_ARG Parameter error
*/
esp_err_t timer_disable_intr(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Clear timer interrupt status, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
*
*/
void timer_group_clr_intr_status_in_isr(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Enable alarm interrupt, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
*
*/
void timer_group_enable_alarm_in_isr(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Get the current counter value, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
*
* @return
* - Counter value
*/
uint64_t timer_group_get_counter_value_in_isr(timer_group_t group_num, timer_idx_t timer_num);
/** @brief Set the alarm threshold for the timer, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
* @param alarm_val Alarm threshold.
*
*/
void timer_group_set_alarm_value_in_isr(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_val);
/** @brief Enable/disable a counter, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index.
* @param counter_en Enable/disable.
*
*/
void timer_group_set_counter_enable_in_isr(timer_group_t group_num, timer_idx_t timer_num, timer_start_t counter_en);
/** @brief Get interrupt status, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
*
* @return
* - Interrupt status
*/
uint32_t timer_group_get_intr_status_in_isr(timer_group_t group_num);
/** @brief Get auto reload enable status, just used in ISR
*
* @param group_num Timer group number, 0 for TIMERG0 or 1 for TIMERG1
* @param timer_num Timer index
*
* @return
* - True Auto reload enabled
* - False Auto reload disabled
*/
bool timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num);
#ifdef __cplusplus
}
#endif
@@ -1,144 +0,0 @@
/*
* SPDX-FileCopyrightText: 2010-2023 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "soc/soc_caps.h"
#include "soc/clk_tree_defs.h"
#include "hal/timer_types.h"
#include "esp_intr_alloc.h"
#include "esp_attr.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Timer-Group ID
*/
typedef enum {
TIMER_GROUP_0 = 0, /*!< Hw timer group 0 */
#if SOC_TIMER_GROUPS > 1
TIMER_GROUP_1 = 1, /*!< Hw timer group 1 */
#endif
TIMER_GROUP_MAX /*!< Maximum number of Hw timer groups */
} timer_group_t;
/**
* @brief Timer ID
*/
typedef enum {
TIMER_0 = 0, /*!< Select timer0 of GROUPx*/
#if SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1
TIMER_1 = 1, /*!< Select timer1 of GROUPx*/
#endif
TIMER_MAX,
} timer_idx_t;
/**
* @brief Interrupt types of the timer.
*/
typedef enum {
TIMER_INTR_T0 = 1 << 0, /*!< interrupt of timer 0 */
#if SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1
TIMER_INTR_T1 = 1 << 1, /*!< interrupt of timer 1 */
TIMER_INTR_WDT = 1 << 2, /*!< interrupt of watchdog */
#else
TIMER_INTR_WDT = 1 << 1, /*!< interrupt of watchdog */
#endif
TIMER_INTR_NONE = 0
} timer_intr_t;
/**
* @brief Timer count direction
*/
typedef enum {
TIMER_COUNT_DOWN = GPTIMER_COUNT_DOWN, /*!< Descending Count from cnt.high|cnt.low*/
TIMER_COUNT_UP = GPTIMER_COUNT_UP, /*!< Ascending Count from Zero*/
TIMER_COUNT_MAX /*!< Maximum number of timer count directions */
} timer_count_dir_t;
/**
* @brief Timer start/stop command
*/
typedef enum {
TIMER_PAUSE, /*!< Pause timer counter*/
TIMER_START, /*!< Start timer counter*/
} timer_start_t;
/**
* @brief Timer alarm command
*/
typedef enum {
TIMER_ALARM_DIS = 0, /*!< Disable timer alarm*/
TIMER_ALARM_EN = 1, /*!< Enable timer alarm*/
TIMER_ALARM_MAX
} timer_alarm_t;
/**
* @brief Timer interrupt type
*/
typedef enum {
TIMER_INTR_LEVEL = 0, /*!< Interrupt mode: level mode*/
TIMER_INTR_MAX
} timer_intr_mode_t;
/**
* @brief Timer autoreload command
*/
typedef enum {
TIMER_AUTORELOAD_DIS = 0, /*!< Disable auto-reload: hardware will not load counter value after an alarm event*/
TIMER_AUTORELOAD_EN = 1, /*!< Enable auto-reload: hardware will load counter value after an alarm event*/
TIMER_AUTORELOAD_MAX,
} timer_autoreload_t;
#if SOC_GPTIMER_SUPPORTED
/**
* @brief Timer group clock source
*/
typedef soc_periph_tg_clk_src_legacy_t timer_src_clk_t;
#else
/**
* @brief Default type
*/
typedef int timer_src_clk_t;
#endif
/**
* @brief Interrupt handler callback function
*
* @return
* - True Do task yield at the end of ISR
* - False Not do task yield at the end of ISR
*
* @note If you called FreeRTOS functions in callback, you need to return true or false based on
* the return value of argument `pxHigherPriorityTaskWoken`.
* For example, `xQueueSendFromISR` is called in callback, if the return value `pxHigherPriorityTaskWoken`
* of any FreeRTOS calls is pdTRUE, return true; otherwise return false.
*/
typedef bool (*timer_isr_t)(void *);
/**
* @brief Interrupt handle, used in order to free the isr after use.
*/
typedef intr_handle_t timer_isr_handle_t;
/**
* @brief Timer configurations
*/
typedef struct {
timer_alarm_t alarm_en; /*!< Timer alarm enable */
timer_start_t counter_en; /*!< Counter enable */
timer_intr_mode_t intr_type; /*!< Interrupt mode */
timer_count_dir_t counter_dir; /*!< Counter direction */
timer_autoreload_t auto_reload; /*!< Timer auto-reload */
timer_src_clk_t clk_src; /*!< Selects source clock. */
uint32_t divider; /*!< Counter clock divider */
} timer_config_t;
#ifdef __cplusplus
}
#endif
@@ -1,35 +0,0 @@
/*
* SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "freertos/FreeRTOS.h"
#include "hal/dac_ll.h"
#include "esp_err.h"
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
#define DAC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
#define DAC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
/*---------------------------------------------------------------
Digital controller setting
---------------------------------------------------------------*/
esp_err_t dac_i2s_enable(void)
{
DAC_ENTER_CRITICAL();
dac_ll_digi_enable_dma(true);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_i2s_disable(void)
{
DAC_ENTER_CRITICAL();
dac_ll_digi_enable_dma(false);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
@@ -1,135 +0,0 @@
/*
* SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "sdkconfig.h"
#include "freertos/FreeRTOS.h"
#include "driver/dac_types_legacy.h"
#include "hal/adc_ll.h"
#include "hal/dac_ll.h"
#include "esp_check.h"
#include "esp_pm.h"
static __attribute__((unused)) const char *TAG = "DAC";
extern portMUX_TYPE rtc_spinlock; //TODO: Will be placed in the appropriate position after the rtc module is finished.
#define DAC_ENTER_CRITICAL() portENTER_CRITICAL(&rtc_spinlock)
#define DAC_EXIT_CRITICAL() portEXIT_CRITICAL(&rtc_spinlock)
#ifdef CONFIG_PM_ENABLE
static esp_pm_lock_handle_t s_dac_digi_lock = NULL;
#endif //CONFIG_PM_ENABLE
/*---------------------------------------------------------------
Digital controller setting
---------------------------------------------------------------*/
esp_err_t dac_digi_init(void)
{
DAC_ENTER_CRITICAL();
dac_ll_digi_clk_inv(true);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_deinit(void)
{
#ifdef CONFIG_PM_ENABLE
if (s_dac_digi_lock) {
esp_pm_lock_delete(s_dac_digi_lock);
s_dac_digi_lock = NULL;
}
#endif
DAC_ENTER_CRITICAL();
dac_ll_digi_trigger_output(false);
dac_ll_digi_enable_dma(false);
dac_ll_digi_fifo_reset();
dac_ll_digi_reset();
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_controller_config(const dac_digi_config_t *cfg)
{
ESP_RETURN_ON_FALSE(cfg->mode <= DAC_CONV_ALTER, ESP_ERR_INVALID_ARG, TAG, "DAC mode error");
ESP_RETURN_ON_FALSE(cfg->interval > 0 && cfg->interval < 4096, ESP_ERR_INVALID_ARG, TAG, "DAC interval error");
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_num < 256, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_num error");
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_b > 0 && cfg->dig_clk.div_b < 64, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_b error");
ESP_RETURN_ON_FALSE(cfg->dig_clk.div_a < 64, ESP_ERR_INVALID_ARG, TAG, "DAC clk div_a error");
#ifdef CONFIG_PM_ENABLE
esp_err_t err;
if (s_dac_digi_lock == NULL) {
if (cfg->dig_clk.use_apll) {
err = esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "dac_dma", &s_dac_digi_lock);
} else {
err = esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "dac_dma", &s_dac_digi_lock);
}
if (err != ESP_OK) {
s_dac_digi_lock = NULL;
ESP_LOGE(TAG, "DAC-DMA pm lock error");
return err;
}
}
#endif //CONFIG_PM_ENABLE
DAC_ENTER_CRITICAL();
dac_ll_digi_set_convert_mode(cfg->mode == DAC_CONV_ALTER);
dac_ll_digi_set_trigger_interval(cfg->interval);
adc_ll_digi_controller_clk_div(cfg->dig_clk.div_num, cfg->dig_clk.div_b, cfg->dig_clk.div_a);
adc_ll_digi_clk_sel(cfg->dig_clk.use_apll ? ADC_DIGI_CLK_SRC_APLL : ADC_DIGI_CLK_SRC_DEFAULT);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_start(void)
{
#ifdef CONFIG_PM_ENABLE
ESP_RETURN_ON_FALSE(s_dac_digi_lock, ESP_FAIL, TAG, "Should start after call `dac_digi_controller_config`");
esp_pm_lock_acquire(s_dac_digi_lock);
#endif
DAC_ENTER_CRITICAL();
dac_ll_digi_enable_dma(true);
dac_ll_digi_trigger_output(true);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_stop(void)
{
#ifdef CONFIG_PM_ENABLE
if (s_dac_digi_lock) {
esp_pm_lock_release(s_dac_digi_lock);
}
#endif
DAC_ENTER_CRITICAL();
dac_ll_digi_trigger_output(false);
dac_ll_digi_enable_dma(false);
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_fifo_reset(void)
{
DAC_ENTER_CRITICAL();
dac_ll_digi_fifo_reset();
DAC_EXIT_CRITICAL();
return ESP_OK;
}
esp_err_t dac_digi_reset(void)
{
DAC_ENTER_CRITICAL();
dac_ll_digi_reset();
DAC_EXIT_CRITICAL();
return ESP_OK;
}
File diff suppressed because it is too large Load Diff
+4 -3
View File
@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
@@ -470,7 +470,7 @@ esp_err_t mcpwm_init(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num, const mcpw
uint32_t group_pre_scale = clk_src_hz / group_resolution;
uint32_t timer_pre_scale = group_resolution / timer_resolution;
esp_clk_tree_enable_src((soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT, true);
ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT, true));
MCPWM_CLOCK_SRC_ATOMIC() {
mcpwm_ll_group_set_clock_source(mcpwm_num, (soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT);
mcpwm_ll_group_set_clock_prescale(mcpwm_num, group_pre_scale);
@@ -868,7 +868,7 @@ esp_err_t mcpwm_capture_enable_channel(mcpwm_unit_t mcpwm_num, mcpwm_capture_cha
uint32_t group_resolution = mcpwm_group_get_resolution(mcpwm_num);
uint32_t group_pre_scale = clk_src_hz / group_resolution;
esp_clk_tree_enable_src((soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT, true);
ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT, true));
MCPWM_CLOCK_SRC_ATOMIC() {
mcpwm_ll_group_set_clock_source(mcpwm_num, (soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT);
mcpwm_ll_group_set_clock_prescale(mcpwm_num, group_pre_scale);
@@ -910,6 +910,7 @@ esp_err_t mcpwm_capture_disable_channel(mcpwm_unit_t mcpwm_num, mcpwm_capture_ch
mcpwm_ll_capture_enable_channel(hal->dev, cap_channel, false);
mcpwm_ll_intr_enable(hal->dev, MCPWM_LL_EVENT_CAPTURE(cap_channel), false);
mcpwm_critical_exit(mcpwm_num);
ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)MCPWM_CAPTURE_CLK_SRC_DEFAULT, false));
mcpwm_mutex_lock(mcpwm_num);
context[mcpwm_num].cap_isr_func[cap_channel].fn = NULL;
-574
View File
@@ -1,574 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "freertos/FreeRTOS.h"
#include "esp_log.h"
#include "esp_check.h"
#include "soc/soc_caps.h"
#include "esp_private/periph_ctrl.h"
#include "driver/pcnt_types_legacy.h"
#include "driver/gpio.h"
#include "hal/pcnt_hal.h"
#include "hal/pcnt_ll.h"
#include "hal/gpio_hal.h"
#include "soc/pcnt_periph.h"
#include "esp_rom_gpio.h"
#include "esp_private/gpio.h"
#define PCNT_CHANNEL_ERR_STR "PCNT CHANNEL ERROR"
#define PCNT_UNIT_ERR_STR "PCNT UNIT ERROR"
#define PCNT_GPIO_ERR_STR "PCNT GPIO NUM ERROR"
#define PCNT_ADDRESS_ERR_STR "PCNT ADDRESS ERROR"
#define PCNT_PARAM_ERR_STR "PCNT PARAM ERROR"
#define PCNT_COUNT_MODE_ERR_STR "PCNT COUNTER MODE ERROR"
#define PCNT_CTRL_MODE_ERR_STR "PCNT CTRL MODE ERROR"
#define PCNT_EVT_TYPE_ERR_STR "PCNT value type error"
#define PCNT_LIMT_VAL_ERR_STR "PCNT limit value error"
#define PCNT_NUM_ERR_STR "PCNT num error"
#define PCNT_DRIVER_ERR_STR "PCNT driver error"
#define PCNT_ENTER_CRITICAL(mux) portENTER_CRITICAL(mux)
#define PCNT_EXIT_CRITICAL(mux) portEXIT_CRITICAL(mux)
#if !SOC_RCC_IS_INDEPENDENT
#define PCNT_RCC_ATOMIC() PERIPH_RCC_ATOMIC()
#else
#define PCNT_RCC_ATOMIC()
#endif
static const char *TAG = "pcnt(legacy)";
#define PCNT_CHECK(a, str, ret_val) ESP_RETURN_ON_FALSE(a, ret_val, TAG, "%s", str)
typedef struct {
pcnt_hal_context_t hal; /*!< PCNT hal context*/
} pcnt_obj_t;
static pcnt_obj_t *p_pcnt_obj[PCNT_PORT_MAX] = {0};
#define PCNT_OBJ_CHECK(pcnt_port) { \
PCNT_CHECK((pcnt_port < PCNT_PORT_MAX), PCNT_NUM_ERR_STR, ESP_ERR_INVALID_ARG); \
PCNT_CHECK((p_pcnt_obj[pcnt_port]), PCNT_DRIVER_ERR_STR, ESP_ERR_INVALID_STATE); \
}
typedef struct {
void(*fn)(void *args); /*!< isr function */
void *args; /*!< isr function args */
} pcnt_isr_func_t;
static pcnt_isr_func_t *pcnt_isr_func = NULL;
static pcnt_isr_handle_t pcnt_isr_service = NULL;
static portMUX_TYPE pcnt_spinlock = portMUX_INITIALIZER_UNLOCKED;
esp_err_t pcnt_isr_register(void (*fun)(void *), void *arg, int intr_alloc_flags, pcnt_isr_handle_t *handle);
esp_err_t pcnt_isr_unregister(pcnt_isr_handle_t handle);
static inline esp_err_t _pcnt_set_mode(pcnt_port_t pcnt_port, pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(channel < PCNT_CHANNEL_MAX, PCNT_CHANNEL_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK((pos_mode < PCNT_COUNT_MAX) && (neg_mode < PCNT_COUNT_MAX), PCNT_COUNT_MODE_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK((hctrl_mode < PCNT_MODE_MAX) && (lctrl_mode < PCNT_MODE_MAX), PCNT_CTRL_MODE_ERR_STR, ESP_ERR_INVALID_ARG);
pcnt_ll_set_edge_action(p_pcnt_obj[pcnt_port]->hal.dev, unit, channel, pos_mode, neg_mode);
pcnt_ll_set_level_action(p_pcnt_obj[pcnt_port]->hal.dev, unit, channel, hctrl_mode, lctrl_mode);
return ESP_OK;
}
static inline esp_err_t _pcnt_set_pin(pcnt_port_t pcnt_port, pcnt_unit_t unit, pcnt_channel_t channel, int pulse_io, int ctrl_io)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(channel < PCNT_CHANNEL_MAX, PCNT_CHANNEL_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(GPIO_IS_VALID_GPIO(pulse_io) || pulse_io < 0, PCNT_GPIO_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(GPIO_IS_VALID_GPIO(ctrl_io) || ctrl_io < 0, PCNT_GPIO_ERR_STR, ESP_ERR_INVALID_ARG);
if (pulse_io >= 0) {
gpio_func_sel(pulse_io, PIN_FUNC_GPIO);
gpio_set_direction(pulse_io, GPIO_MODE_INPUT);
gpio_set_pull_mode(pulse_io, GPIO_PULLUP_ONLY);
esp_rom_gpio_connect_in_signal(pulse_io, pcnt_periph_signals.groups[pcnt_port].units[unit].channels[channel].pulse_sig, 0);
}
if (ctrl_io >= 0) {
gpio_func_sel(ctrl_io, PIN_FUNC_GPIO);
gpio_set_direction(ctrl_io, GPIO_MODE_INPUT);
gpio_set_pull_mode(ctrl_io, GPIO_PULLUP_ONLY);
esp_rom_gpio_connect_in_signal(ctrl_io, pcnt_periph_signals.groups[pcnt_port].units[unit].channels[channel].control_sig, 0);
}
return ESP_OK;
}
static inline esp_err_t _pcnt_get_counter_value(pcnt_port_t pcnt_port, pcnt_unit_t pcnt_unit, int16_t *count)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(count != NULL, PCNT_ADDRESS_ERR_STR, ESP_ERR_INVALID_ARG);
*count = pcnt_ll_get_count(p_pcnt_obj[pcnt_port]->hal.dev, pcnt_unit);
return ESP_OK;
}
static inline esp_err_t _pcnt_counter_pause(pcnt_port_t pcnt_port, pcnt_unit_t pcnt_unit)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
pcnt_ll_stop_count(p_pcnt_obj[pcnt_port]->hal.dev, pcnt_unit);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
static inline esp_err_t _pcnt_counter_resume(pcnt_port_t pcnt_port, pcnt_unit_t pcnt_unit)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
pcnt_ll_start_count(p_pcnt_obj[pcnt_port]->hal.dev, pcnt_unit);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
static inline esp_err_t _pcnt_counter_clear(pcnt_port_t pcnt_port, pcnt_unit_t pcnt_unit)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
pcnt_ll_clear_count(p_pcnt_obj[pcnt_port]->hal.dev, pcnt_unit);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
static inline esp_err_t _pcnt_intr_enable(pcnt_port_t pcnt_port, pcnt_unit_t pcnt_unit, bool enable)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
pcnt_ll_enable_intr(p_pcnt_obj[pcnt_port]->hal.dev, 1 << pcnt_unit, enable);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
static inline esp_err_t _pcnt_event_enable(pcnt_port_t pcnt_port, pcnt_unit_t unit, pcnt_evt_type_t evt_type, bool enable)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(evt_type < PCNT_EVT_MAX, PCNT_EVT_TYPE_ERR_STR, ESP_ERR_INVALID_ARG);
switch (evt_type) {
case PCNT_EVT_THRES_1:
pcnt_ll_enable_thres_event(p_pcnt_obj[pcnt_port]->hal.dev, unit, 1, enable);
break;
case PCNT_EVT_THRES_0:
pcnt_ll_enable_thres_event(p_pcnt_obj[pcnt_port]->hal.dev, unit, 0, enable);
break;
case PCNT_EVT_L_LIM:
pcnt_ll_enable_low_limit_event(p_pcnt_obj[pcnt_port]->hal.dev, unit, enable);
break;
case PCNT_EVT_H_LIM:
pcnt_ll_enable_high_limit_event(p_pcnt_obj[pcnt_port]->hal.dev, unit, enable);
break;
case PCNT_EVT_ZERO:
pcnt_ll_enable_zero_cross_event(p_pcnt_obj[pcnt_port]->hal.dev, unit, enable);
break;
default:
PCNT_CHECK(false, PCNT_EVT_TYPE_ERR_STR, ESP_ERR_INVALID_ARG);
break;
}
return ESP_OK;
}
static inline esp_err_t _pcnt_set_event_value(pcnt_port_t pcnt_port, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(evt_type < PCNT_EVT_MAX, PCNT_EVT_TYPE_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(!(evt_type == PCNT_EVT_L_LIM && value > 0), PCNT_LIMT_VAL_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(!(evt_type == PCNT_EVT_H_LIM && value < 0), PCNT_LIMT_VAL_ERR_STR, ESP_ERR_INVALID_ARG);
switch (evt_type) {
case PCNT_EVT_THRES_1:
pcnt_ll_set_thres_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, 1, value);
break;
case PCNT_EVT_THRES_0:
pcnt_ll_set_thres_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, 0, value);
break;
case PCNT_EVT_L_LIM:
pcnt_ll_set_low_limit_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, value);
break;
case PCNT_EVT_H_LIM:
pcnt_ll_set_high_limit_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, value);
break;
default:
break;
}
return ESP_OK;
}
static inline esp_err_t _pcnt_get_event_value(pcnt_port_t pcnt_port, pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(evt_type < PCNT_EVT_MAX, PCNT_EVT_TYPE_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(value != NULL, PCNT_ADDRESS_ERR_STR, ESP_ERR_INVALID_ARG);
switch (evt_type) {
case PCNT_EVT_THRES_1:
*value = pcnt_ll_get_thres_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, 1);
break;
case PCNT_EVT_THRES_0:
*value = pcnt_ll_get_thres_value(p_pcnt_obj[pcnt_port]->hal.dev, unit, 0);
break;
case PCNT_EVT_L_LIM:
*value = pcnt_ll_get_low_limit_value(p_pcnt_obj[pcnt_port]->hal.dev, unit);
break;
case PCNT_EVT_H_LIM:
*value = pcnt_ll_get_high_limit_value(p_pcnt_obj[pcnt_port]->hal.dev, unit);
break;
default:
break;
}
return ESP_OK;
}
static inline esp_err_t _pcnt_get_event_status(pcnt_port_t pcnt_port, pcnt_unit_t unit, uint32_t *status)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(status != NULL, PCNT_ADDRESS_ERR_STR, ESP_ERR_INVALID_ARG);
*status = pcnt_ll_get_unit_status(p_pcnt_obj[pcnt_port]->hal.dev, unit);
return ESP_OK;
}
static inline esp_err_t _pcnt_set_filter_value(pcnt_port_t pcnt_port, pcnt_unit_t unit, uint16_t filter_val)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(filter_val < 1024, PCNT_PARAM_ERR_STR, ESP_ERR_INVALID_ARG);
pcnt_ll_set_glitch_filter_thres(p_pcnt_obj[pcnt_port]->hal.dev, unit, filter_val);
return ESP_OK;
}
static inline esp_err_t _pcnt_get_filter_value(pcnt_port_t pcnt_port, pcnt_unit_t unit, uint16_t *filter_val)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(filter_val != NULL, PCNT_ADDRESS_ERR_STR, ESP_ERR_INVALID_ARG);
*filter_val = (uint16_t)pcnt_ll_get_glitch_filter_thres(p_pcnt_obj[pcnt_port]->hal.dev, unit);
return ESP_OK;
}
static inline esp_err_t _pcnt_filter_enable(pcnt_port_t pcnt_port, pcnt_unit_t unit, bool enable)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
pcnt_ll_enable_glitch_filter(p_pcnt_obj[pcnt_port]->hal.dev, unit, enable);
return ESP_OK;
}
static inline esp_err_t _pcnt_isr_handler_add(pcnt_port_t pcnt_port, pcnt_unit_t unit, void(*isr_handler)(void *), void *args)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_isr_func != NULL, "ISR service is not installed, call pcnt_install_isr_service() first", ESP_ERR_INVALID_STATE);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, "PCNT unit error", ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
_pcnt_intr_enable(PCNT_PORT_0, unit, false);
if (pcnt_isr_func) {
pcnt_isr_func[unit].fn = isr_handler;
pcnt_isr_func[unit].args = args;
}
_pcnt_intr_enable(PCNT_PORT_0, unit, true);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
static inline esp_err_t _pcnt_isr_handler_remove(pcnt_port_t pcnt_port, pcnt_unit_t unit)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_isr_func != NULL, "ISR service is not installed", ESP_ERR_INVALID_STATE);
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, "PCNT unit error", ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
_pcnt_intr_enable(PCNT_PORT_0, unit, false);
if (pcnt_isr_func) {
pcnt_isr_func[unit].fn = NULL;
pcnt_isr_func[unit].args = NULL;
}
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ESP_OK;
}
// pcnt interrupt service
static void IRAM_ATTR pcnt_intr_service(void *arg)
{
uint32_t status = 0;
pcnt_port_t pcnt_port = (pcnt_port_t)arg;
status = pcnt_ll_get_intr_status(p_pcnt_obj[pcnt_port]->hal.dev);
pcnt_ll_clear_intr_status(p_pcnt_obj[pcnt_port]->hal.dev, status);
while (status) {
int unit = __builtin_ffs(status) - 1;
status &= ~(1 << unit);
if (pcnt_isr_func[unit].fn != NULL) {
(pcnt_isr_func[unit].fn)(pcnt_isr_func[unit].args);
}
}
}
static inline esp_err_t _pcnt_isr_service_install(pcnt_port_t pcnt_port, int intr_alloc_flags)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_isr_func == NULL, "ISR service already installed", ESP_ERR_INVALID_STATE);
esp_err_t ret = ESP_FAIL;
pcnt_isr_func = (pcnt_isr_func_t *) calloc(SOC_PCNT_UNITS_PER_GROUP, sizeof(pcnt_isr_func_t));
if (pcnt_isr_func == NULL) {
ret = ESP_ERR_NO_MEM;
} else {
ret = pcnt_isr_register(pcnt_intr_service, (void *)pcnt_port, intr_alloc_flags, &pcnt_isr_service);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "pcnt isr registration failed, maybe you need `pcnt_isr_unregister` to unregister your isr");
free(pcnt_isr_func);
pcnt_isr_func = NULL;
}
}
return ret;
}
static inline esp_err_t _pcnt_isr_service_uninstall(pcnt_port_t pcnt_port)
{
PCNT_OBJ_CHECK(pcnt_port);
PCNT_CHECK(pcnt_isr_func != NULL, "ISR Service not installed yet.", ESP_ERR_INVALID_STATE);
esp_err_t ret = ESP_FAIL;
ret = pcnt_isr_unregister(pcnt_isr_service);
free(pcnt_isr_func);
pcnt_isr_func = NULL;
pcnt_isr_service = NULL;
return ret;
}
static inline esp_err_t _pcnt_unit_config(pcnt_port_t pcnt_port, const pcnt_config_t *pcnt_config)
{
PCNT_OBJ_CHECK(pcnt_port);
uint8_t unit = pcnt_config->unit;
uint8_t channel = pcnt_config->channel;
int input_io = pcnt_config->pulse_gpio_num;
int ctrl_io = pcnt_config->ctrl_gpio_num;
PCNT_CHECK(unit < SOC_PCNT_UNITS_PER_GROUP, PCNT_UNIT_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(channel < PCNT_CHANNEL_MAX, PCNT_CHANNEL_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK(input_io < 0 || (GPIO_IS_VALID_GPIO(input_io) && (input_io != ctrl_io)), "PCNT pulse input io error", ESP_ERR_INVALID_ARG);
PCNT_CHECK(ctrl_io < 0 || GPIO_IS_VALID_GPIO(ctrl_io), "PCNT ctrl io error", ESP_ERR_INVALID_ARG);
PCNT_CHECK((pcnt_config->pos_mode < PCNT_COUNT_MAX) && (pcnt_config->neg_mode < PCNT_COUNT_MAX), PCNT_COUNT_MODE_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK((pcnt_config->hctrl_mode < PCNT_MODE_MAX) && (pcnt_config->lctrl_mode < PCNT_MODE_MAX), PCNT_CTRL_MODE_ERR_STR, ESP_ERR_INVALID_ARG);
/*Enable hardware module*/
static bool pcnt_enable = false;
if (pcnt_enable == false) {
PCNT_RCC_ATOMIC() {
pcnt_ll_reset_register(pcnt_port);
pcnt_ll_enable_bus_clock(pcnt_port, true);
}
pcnt_enable = true;
}
/*Set counter range*/
_pcnt_set_event_value(pcnt_port, unit, PCNT_EVT_H_LIM, pcnt_config->counter_h_lim);
_pcnt_set_event_value(pcnt_port, unit, PCNT_EVT_L_LIM, pcnt_config->counter_l_lim);
/*Default value after reboot is positive, we disable these events like others*/
_pcnt_event_enable(pcnt_port, unit, PCNT_EVT_H_LIM, false);
_pcnt_event_enable(pcnt_port, unit, PCNT_EVT_L_LIM, false);
_pcnt_event_enable(pcnt_port, unit, PCNT_EVT_ZERO, false);
_pcnt_filter_enable(pcnt_port, unit, false);
/*set pulse input and control mode*/
_pcnt_set_mode(pcnt_port, unit, channel, pcnt_config->pos_mode, pcnt_config->neg_mode, pcnt_config->hctrl_mode, pcnt_config->lctrl_mode);
/*Set pulse input and control pins*/
_pcnt_set_pin(pcnt_port, unit, channel, input_io, ctrl_io);
return ESP_OK;
}
esp_err_t pcnt_deinit(pcnt_port_t pcnt_port)
{
PCNT_OBJ_CHECK(pcnt_port);
heap_caps_free(p_pcnt_obj[pcnt_port]);
p_pcnt_obj[pcnt_port] = NULL;
return ESP_OK;
}
esp_err_t pcnt_init(pcnt_port_t pcnt_port)
{
PCNT_CHECK((pcnt_port < PCNT_PORT_MAX), PCNT_NUM_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_CHECK((p_pcnt_obj[pcnt_port]) == NULL, "pcnt driver already initted", ESP_ERR_INVALID_STATE);
p_pcnt_obj[pcnt_port] = (pcnt_obj_t *)heap_caps_calloc(1, sizeof(pcnt_obj_t), MALLOC_CAP_DEFAULT);
if (p_pcnt_obj[pcnt_port] == NULL) {
ESP_LOGE(TAG, "PCNT driver malloc error");
return ESP_FAIL;
}
pcnt_hal_init(&(p_pcnt_obj[pcnt_port]->hal), pcnt_port);
return ESP_OK;
}
esp_err_t pcnt_unit_config(const pcnt_config_t *pcnt_config)
{
esp_err_t ret;
if ((p_pcnt_obj[PCNT_PORT_0]) == NULL) {
ret = pcnt_init(PCNT_PORT_0);
if (ret != ESP_OK) {
return ret;
}
}
return _pcnt_unit_config(PCNT_PORT_0, pcnt_config);
}
esp_err_t pcnt_set_mode(pcnt_unit_t unit, pcnt_channel_t channel, pcnt_count_mode_t pos_mode, pcnt_count_mode_t neg_mode, pcnt_ctrl_mode_t hctrl_mode, pcnt_ctrl_mode_t lctrl_mode)
{
return _pcnt_set_mode(PCNT_PORT_0, unit, channel, pos_mode, neg_mode, hctrl_mode, lctrl_mode);
}
esp_err_t pcnt_set_pin(pcnt_unit_t unit, pcnt_channel_t channel, int pulse_io, int ctrl_io)
{
return _pcnt_set_pin(PCNT_PORT_0, unit, channel, pulse_io, ctrl_io);
}
esp_err_t pcnt_get_counter_value(pcnt_unit_t pcnt_unit, int16_t *count)
{
return _pcnt_get_counter_value(PCNT_PORT_0, pcnt_unit, count);
}
esp_err_t pcnt_counter_pause(pcnt_unit_t pcnt_unit)
{
return _pcnt_counter_pause(PCNT_PORT_0, pcnt_unit);
}
esp_err_t pcnt_counter_resume(pcnt_unit_t pcnt_unit)
{
return _pcnt_counter_resume(PCNT_PORT_0, pcnt_unit);
}
esp_err_t pcnt_counter_clear(pcnt_unit_t pcnt_unit)
{
return _pcnt_counter_clear(PCNT_PORT_0, pcnt_unit);
}
esp_err_t pcnt_intr_enable(pcnt_unit_t pcnt_unit)
{
return _pcnt_intr_enable(PCNT_PORT_0, pcnt_unit, true);
}
esp_err_t pcnt_intr_disable(pcnt_unit_t pcnt_unit)
{
return _pcnt_intr_enable(PCNT_PORT_0, pcnt_unit, false);
}
esp_err_t pcnt_event_enable(pcnt_unit_t unit, pcnt_evt_type_t evt_type)
{
return _pcnt_event_enable(PCNT_PORT_0, unit, evt_type, true);
}
esp_err_t pcnt_event_disable(pcnt_unit_t unit, pcnt_evt_type_t evt_type)
{
return _pcnt_event_enable(PCNT_PORT_0, unit, evt_type, false);
}
esp_err_t pcnt_set_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t value)
{
return _pcnt_set_event_value(PCNT_PORT_0, unit, evt_type, value);
}
esp_err_t pcnt_get_event_value(pcnt_unit_t unit, pcnt_evt_type_t evt_type, int16_t *value)
{
return _pcnt_get_event_value(PCNT_PORT_0, unit, evt_type, value);
}
esp_err_t pcnt_get_event_status(pcnt_unit_t unit, uint32_t *status)
{
return _pcnt_get_event_status(PCNT_PORT_0, unit, status);
}
esp_err_t pcnt_set_filter_value(pcnt_unit_t unit, uint16_t filter_val)
{
return _pcnt_set_filter_value(PCNT_PORT_0, unit, filter_val);
}
esp_err_t pcnt_get_filter_value(pcnt_unit_t unit, uint16_t *filter_val)
{
return _pcnt_get_filter_value(PCNT_PORT_0, unit, filter_val);
}
esp_err_t pcnt_filter_enable(pcnt_unit_t unit)
{
return _pcnt_filter_enable(PCNT_PORT_0, unit, true);
}
esp_err_t pcnt_filter_disable(pcnt_unit_t unit)
{
return _pcnt_filter_enable(PCNT_PORT_0, unit, false);
}
esp_err_t pcnt_isr_unregister(pcnt_isr_handle_t handle)
{
esp_err_t ret = ESP_FAIL;
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
ret = esp_intr_free(handle);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ret;
}
esp_err_t pcnt_isr_register(void (*fun)(void *), void *arg, int intr_alloc_flags, pcnt_isr_handle_t *handle)
{
esp_err_t ret = ESP_FAIL;
PCNT_CHECK(fun != NULL, PCNT_ADDRESS_ERR_STR, ESP_ERR_INVALID_ARG);
PCNT_ENTER_CRITICAL(&pcnt_spinlock);
ret = esp_intr_alloc(pcnt_periph_signals.groups[0].irq, intr_alloc_flags, fun, arg, handle);
PCNT_EXIT_CRITICAL(&pcnt_spinlock);
return ret;
}
esp_err_t pcnt_isr_handler_add(pcnt_unit_t unit, void(*isr_handler)(void *), void *args)
{
return _pcnt_isr_handler_add(PCNT_PORT_0, unit, isr_handler, args);
}
esp_err_t pcnt_isr_handler_remove(pcnt_unit_t unit)
{
return _pcnt_isr_handler_remove(PCNT_PORT_0, unit);
}
esp_err_t pcnt_isr_service_install(int intr_alloc_flags)
{
return _pcnt_isr_service_install(PCNT_PORT_0, intr_alloc_flags);
}
void pcnt_isr_service_uninstall(void)
{
_pcnt_isr_service_uninstall(PCNT_PORT_0);
}
#if !CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that pulse_cnt driver is not running along with the legacy pcnt driver
*/
__attribute__((constructor))
static void check_pcnt_driver_conflict(void)
{
// This function was declared as weak here. pulse_cnt driver has one implementation.
// So if pulse_cnt driver is not linked in, then `pcnt_new_unit` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t pcnt_new_unit(const void *config, void **ret_unit);
if ((void *)pcnt_new_unit != NULL) {
ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
abort();
}
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/pulse_cnt.h`");
}
#endif //CONFIG_PCNT_SKIP_LEGACY_CONFLICT_CHECK
+2 -2
View File
@@ -440,7 +440,7 @@ esp_err_t rmt_set_source_clk(rmt_channel_t channel, rmt_source_clk_t base_clk)
{
ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR);
RMT_ENTER_CRITICAL();
esp_clk_tree_enable_src((soc_module_clk_t)base_clk, true);
ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)base_clk, true));
// `rmt_clock_source_t` and `rmt_source_clk_t` are binary compatible, as the underlying enum entries come from the same `soc_module_clk_t`
RMT_CLOCK_SRC_ATOMIC() {
rmt_ll_set_group_clock_src(rmt_contex.hal.regs, channel, (rmt_clock_source_t)base_clk, 1, 0, 0);
@@ -606,7 +606,7 @@ static esp_err_t rmt_internal_config(rmt_dev_t *dev, const rmt_config_t *rmt_par
#endif
}
esp_clk_tree_src_get_freq_hz((soc_module_clk_t)clk_src, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &rmt_source_clk_hz);
esp_clk_tree_enable_src((soc_module_clk_t)clk_src, true);
ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)clk_src, true));
RMT_CLOCK_SRC_ATOMIC() {
rmt_ll_set_group_clock_src(dev, channel, clk_src, 1, 0, 0);
rmt_ll_enable_group_clock(dev, true);
@@ -1,179 +0,0 @@
/*
* SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include "sdkconfig.h"
#include "esp_types.h"
#include "esp_log.h"
#include "esp_check.h"
#include "esp_compiler.h"
#include "freertos/FreeRTOS.h"
#include "esp_private/regi2c_ctrl.h"
#include "soc/regi2c_saradc.h"
#include "esp_efuse_rtc_calib.h"
#include "hal/temperature_sensor_ll.h"
#include "driver/temp_sensor_types_legacy.h"
#include "esp_private/periph_ctrl.h"
#include "esp_private/sar_periph_ctrl.h"
static const char *TAG = "tsens";
#define TSENS_ADC_FACTOR (0.4386)
#define TSENS_DAC_FACTOR (27.88)
#define TSENS_SYS_OFFSET (20.52)
typedef struct {
int index;
int offset;
int reg_val;
int range_min;
int range_max;
int error_max;
} tsens_dac_offset_t;
static const tsens_dac_offset_t dac_offset[TSENS_DAC_MAX] = {
/* DAC Offset reg_val min max error */
{TSENS_DAC_L0, -2, 5, 50, 125, 3},
{TSENS_DAC_L1, -1, 7, 20, 100, 2},
{TSENS_DAC_L2, 0, 15, -10, 80, 1},
{TSENS_DAC_L3, 1, 11, -30, 50, 2},
{TSENS_DAC_L4, 2, 10, -40, 20, 3},
};
typedef enum {
TSENS_HW_STATE_UNCONFIGURED,
TSENS_HW_STATE_CONFIGURED,
TSENS_HW_STATE_STARTED,
} tsens_hw_state_t;
static tsens_hw_state_t tsens_hw_state = TSENS_HW_STATE_UNCONFIGURED;
static float s_deltaT = NAN; // Unused number
static int s_tsens_range;
esp_err_t temp_sensor_set_config(temp_sensor_config_t tsens)
{
esp_err_t err = ESP_OK;
if (tsens_hw_state == TSENS_HW_STATE_STARTED) {
ESP_LOGE(TAG, "Do not configure the temp sensor when it's running!");
err = ESP_ERR_INVALID_STATE;
}
temperature_sensor_ll_set_clk_div(tsens.clk_div);
temp_sensor_sync_tsens_idx(tsens.dac_offset);
s_tsens_range = dac_offset[tsens.dac_offset].reg_val;
ESP_LOGI(TAG, "Config range [%d°C ~ %d°C], error < %d°C",
dac_offset[tsens.dac_offset].range_min,
dac_offset[tsens.dac_offset].range_max,
dac_offset[tsens.dac_offset].error_max);
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
return err;
}
esp_err_t temp_sensor_get_config(temp_sensor_config_t *tsens)
{
ESP_RETURN_ON_FALSE(tsens != NULL, ESP_ERR_INVALID_ARG, TAG, "no tsens specified");
tsens->dac_offset = temperature_sensor_ll_get_offset();
for (int i = TSENS_DAC_L0; i < TSENS_DAC_MAX; i++) {
if ((int)tsens->dac_offset == dac_offset[i].reg_val) {
tsens->dac_offset = dac_offset[i].index;
break;
}
}
tsens->clk_div = temperature_sensor_ll_get_clk_div();
return ESP_OK;
}
esp_err_t temp_sensor_start(void)
{
esp_err_t err = ESP_OK;
if (tsens_hw_state != TSENS_HW_STATE_CONFIGURED) {
ESP_LOGE(TAG, "Is already running or not be configured");
err = ESP_ERR_INVALID_STATE;
}
temperature_sensor_power_acquire();
temperature_sensor_ll_set_range(s_tsens_range);
temperature_sensor_ll_clk_sel(TEMPERATURE_SENSOR_CLK_SRC_DEFAULT);
tsens_hw_state = TSENS_HW_STATE_STARTED;
return err;
}
esp_err_t temp_sensor_stop(void)
{
temperature_sensor_power_release();
tsens_hw_state = TSENS_HW_STATE_CONFIGURED;
return ESP_OK;
}
esp_err_t temp_sensor_read_raw(uint32_t *tsens_out)
{
ESP_RETURN_ON_FALSE(tsens_out != NULL, ESP_ERR_INVALID_ARG, TAG, "no tsens_out specified");
if (tsens_hw_state != TSENS_HW_STATE_STARTED) {
ESP_LOGE(TAG, "Has not been started");
return ESP_ERR_INVALID_STATE;
}
ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-use-of-uninitialized-value") // False-positive detection. TODO GCC-366
*tsens_out = temperature_sensor_ll_get_raw_value();
ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-use-of-uninitialized-value")
return ESP_OK;
}
static esp_err_t read_delta_t_from_efuse(void)
{
ESP_RETURN_ON_ERROR(esp_efuse_rtc_calib_get_tsens_val(&s_deltaT), TAG, "Calibration error");
ESP_LOGD(TAG, "s_deltaT = %f", s_deltaT);
return ESP_OK;
}
static float parse_temp_sensor_raw_value(uint32_t tsens_raw)
{
if (isnan(s_deltaT)) { //suggests that the value is not initialized
read_delta_t_from_efuse();
}
float result = tsens_raw - s_deltaT / 10.0;
return result;
}
esp_err_t temp_sensor_read_celsius(float *celsius)
{
ESP_RETURN_ON_FALSE(celsius != NULL, ESP_ERR_INVALID_ARG, TAG, "celsius points to nothing");
if (tsens_hw_state != TSENS_HW_STATE_STARTED) {
ESP_LOGE(TAG, "Has not been started");
return ESP_ERR_INVALID_STATE;
}
temp_sensor_config_t tsens;
temp_sensor_get_config(&tsens);
bool range_changed;
uint16_t tsens_out = temp_sensor_get_raw_value(&range_changed);
*celsius = parse_temp_sensor_raw_value(tsens_out);
if (*celsius < TEMPERATURE_SENSOR_LL_MEASURE_MIN || *celsius > TEMPERATURE_SENSOR_LL_MEASURE_MAX) {
ESP_LOGE(TAG, "Exceeding temperature measure range.");
return ESP_ERR_INVALID_STATE;
}
if (range_changed) {
temp_sensor_get_config(&tsens);
}
return ESP_OK;
}
#if !CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that this legacy temp sensor driver is not running along with the new driver
*/
__attribute__((constructor))
static void check_legacy_temp_sensor_driver_conflict(void)
{
// This function was declared as weak here. temperature_sensor driver has one implementation.
// So if temperature_sensor driver is not linked in, then `temperature_sensor_install()` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t temperature_sensor_install(const void *tsens_config, void **ret_tsens);
if ((void *)temperature_sensor_install != NULL) {
ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
abort();
}
ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/temperature_sensor.h`");
}
#endif //CONFIG_TEMP_SENSOR_SKIP_LEGACY_CONFLICT_CHECK
-487
View File
@@ -1,487 +0,0 @@
/*
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <string.h>
#include "esp_log.h"
#include "esp_err.h"
#include "esp_check.h"
#include "esp_intr_alloc.h"
#include "freertos/FreeRTOS.h"
#include "driver/timer_types_legacy.h"
#include "hal/timer_hal.h"
#include "hal/timer_ll.h"
#include "hal/check.h"
#include "soc/timer_periph.h"
#include "soc/soc_caps.h"
#include "esp_clk_tree.h"
#include "soc/timer_group_reg.h"
#include "esp_private/esp_clk_tree_common.h"
#include "esp_private/periph_ctrl.h"
static const char *TIMER_TAG = "timer_group";
#define TIMER_GROUP_NUM_ERROR "TIMER GROUP NUM ERROR"
#define TIMER_NUM_ERROR "HW TIMER NUM ERROR"
#define TIMER_PARAM_ADDR_ERROR "HW TIMER PARAM ADDR ERROR"
#define TIMER_NEVER_INIT_ERROR "HW TIMER NEVER INIT ERROR"
#define TIMER_COUNT_DIR_ERROR "HW TIMER COUNTER DIR ERROR"
#define TIMER_AUTORELOAD_ERROR "HW TIMER AUTORELOAD ERROR"
#define TIMER_SCALE_ERROR "HW TIMER SCALE ERROR"
#define TIMER_ALARM_ERROR "HW TIMER ALARM ERROR"
#define DIVIDER_RANGE_ERROR "HW TIMER divider outside of [2, 65536] range error"
#define TIMER_ENTER_CRITICAL(mux) portENTER_CRITICAL_SAFE(mux);
#define TIMER_EXIT_CRITICAL(mux) portEXIT_CRITICAL_SAFE(mux);
#if SOC_PERIPH_CLK_CTRL_SHARED
#define GPTIMER_CLOCK_SRC_ATOMIC() PERIPH_RCC_ATOMIC()
#else
#define GPTIMER_CLOCK_SRC_ATOMIC()
#endif
typedef struct {
timer_isr_t fn; /*!< isr function */
void *args; /*!< isr function args */
timer_isr_handle_t timer_isr_handle; /*!< interrupt handle */
timer_group_t isr_timer_group; /*!< timer group of interrupt triggered */
} timer_isr_func_t;
typedef struct {
timer_hal_context_t hal;
timer_isr_func_t timer_isr_fun;
timer_src_clk_t clk_src;
gptimer_count_direction_t direction;
uint32_t divider;
uint64_t alarm_value;
bool alarm_en;
bool auto_reload_en;
bool counter_en;
} timer_obj_t;
static timer_obj_t *p_timer_obj[TIMER_GROUP_MAX][TIMER_MAX] = {0};
static portMUX_TYPE timer_spinlock[TIMER_GROUP_MAX] = { [0 ... TIMER_GROUP_MAX - 1] = portMUX_INITIALIZER_UNLOCKED, };
esp_err_t timer_get_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *timer_val)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_val != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
*timer_val = timer_hal_capture_and_get_counter_value(&p_timer_obj[group_num][timer_num]->hal);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_get_counter_time_sec(timer_group_t group_num, timer_idx_t timer_num, double *time)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(time != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
uint64_t timer_val = timer_hal_capture_and_get_counter_value(&p_timer_obj[group_num][timer_num]->hal);
uint32_t div = p_timer_obj[group_num][timer_num]->divider;
// get clock source frequency
uint32_t counter_src_hz = 0;
ESP_RETURN_ON_ERROR(esp_clk_tree_src_get_freq_hz((soc_module_clk_t)p_timer_obj[group_num][timer_num]->clk_src,
ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &counter_src_hz),
TIMER_TAG, "get clock source frequency failed");
*time = (double)timer_val * div / counter_src_hz;
return ESP_OK;
}
esp_err_t timer_set_counter_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t load_val)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_hal_set_counter_value(&(p_timer_obj[group_num][timer_num]->hal), load_val);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_start(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_counter(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, true);
p_timer_obj[group_num][timer_num]->counter_en = true;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_pause(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_counter(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, false);
p_timer_obj[group_num][timer_num]->counter_en = false;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_set_counter_mode(timer_group_t group_num, timer_idx_t timer_num, timer_count_dir_t counter_dir)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(counter_dir < TIMER_COUNT_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_COUNT_DIR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_set_count_direction(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, counter_dir);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_set_auto_reload(timer_group_t group_num, timer_idx_t timer_num, timer_autoreload_t reload)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(reload < TIMER_AUTORELOAD_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_AUTORELOAD_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_auto_reload(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, reload);
p_timer_obj[group_num][timer_num]->auto_reload_en = reload;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_set_divider(timer_group_t group_num, timer_idx_t timer_num, uint32_t divider)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(divider > 1 && divider < 65537, ESP_ERR_INVALID_ARG, TIMER_TAG, DIVIDER_RANGE_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_set_clock_prescale(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, divider);
p_timer_obj[group_num][timer_num]->divider = divider;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_set_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_value)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_set_alarm_value(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, alarm_value);
p_timer_obj[group_num][timer_num]->alarm_value = alarm_value;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_get_alarm_value(timer_group_t group_num, timer_idx_t timer_num, uint64_t *alarm_value)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(alarm_value != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
*alarm_value = p_timer_obj[group_num][timer_num]->alarm_value;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_set_alarm(timer_group_t group_num, timer_idx_t timer_num, timer_alarm_t alarm_en)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(alarm_en < TIMER_ALARM_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_ALARM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_alarm(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, alarm_en);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
static void IRAM_ATTR timer_isr_default(void *arg)
{
bool is_awoken = false;
timer_obj_t *timer_obj = (timer_obj_t *)arg;
if (timer_obj == NULL || timer_obj->timer_isr_fun.fn == NULL) {
return;
}
uint32_t timer_id = timer_obj->hal.timer_id;
timer_hal_context_t *hal = &timer_obj->hal;
TIMER_ENTER_CRITICAL(&timer_spinlock[timer_obj->timer_isr_fun.isr_timer_group]);
uint32_t intr_status = timer_ll_get_intr_status(hal->dev);
uint64_t old_alarm_value = timer_obj->alarm_value;
if (intr_status & TIMER_LL_EVENT_ALARM(timer_id)) {
// Clear interrupt status
timer_ll_clear_intr_status(hal->dev, TIMER_LL_EVENT_ALARM(timer_id));
// call user registered callback
is_awoken = timer_obj->timer_isr_fun.fn(timer_obj->timer_isr_fun.args);
// re-enable alarm if required
uint64_t new_alarm_value = timer_obj->alarm_value;
bool reenable_alarm = (new_alarm_value != old_alarm_value) || timer_obj->auto_reload_en;
timer_ll_enable_alarm(hal->dev, timer_id, reenable_alarm);
}
TIMER_EXIT_CRITICAL(&timer_spinlock[timer_obj->timer_isr_fun.isr_timer_group]);
if (is_awoken) {
portYIELD_FROM_ISR();
}
}
esp_err_t timer_enable_intr(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_intr(p_timer_obj[group_num][timer_num]->hal.dev, TIMER_LL_EVENT_ALARM(timer_num), true);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_disable_intr(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_intr(p_timer_obj[group_num][timer_num]->hal.dev, TIMER_LL_EVENT_ALARM(timer_num), false);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_isr_register(timer_group_t group_num, timer_idx_t timer_num,
void (*fn)(void *), void *arg, int intr_alloc_flags, timer_isr_handle_t *handle)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(fn != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
timer_hal_context_t *hal = &p_timer_obj[group_num][timer_num]->hal;
return esp_intr_alloc_intrstatus(timer_group_periph_signals.groups[group_num].timer_irq_id[timer_num],
intr_alloc_flags,
(uint32_t)timer_ll_get_intr_status_reg(hal->dev),
TIMER_LL_EVENT_ALARM(timer_num), fn, arg, handle);
}
esp_err_t timer_isr_callback_add(timer_group_t group_num, timer_idx_t timer_num, timer_isr_t isr_handler, void *args, int intr_alloc_flags)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
esp_err_t ret = ESP_OK;
timer_disable_intr(group_num, timer_num);
p_timer_obj[group_num][timer_num]->timer_isr_fun.fn = isr_handler;
p_timer_obj[group_num][timer_num]->timer_isr_fun.args = args;
p_timer_obj[group_num][timer_num]->timer_isr_fun.isr_timer_group = group_num;
ret = timer_isr_register(group_num, timer_num, timer_isr_default, (void *)p_timer_obj[group_num][timer_num],
intr_alloc_flags, &(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle));
ESP_RETURN_ON_ERROR(ret, TIMER_TAG, "register interrupt service failed");
timer_enable_intr(group_num, timer_num);
return ret;
}
esp_err_t timer_isr_callback_remove(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
timer_disable_intr(group_num, timer_num);
p_timer_obj[group_num][timer_num]->timer_isr_fun.fn = NULL;
p_timer_obj[group_num][timer_num]->timer_isr_fun.args = NULL;
esp_intr_free(p_timer_obj[group_num][timer_num]->timer_isr_fun.timer_isr_handle);
return ESP_OK;
}
esp_err_t timer_init(timer_group_t group_num, timer_idx_t timer_num, const timer_config_t *config)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(config != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(config->divider > 1 && config->divider < 65537, ESP_ERR_INVALID_ARG, TIMER_TAG, DIVIDER_RANGE_ERROR);
ESP_RETURN_ON_FALSE(config->intr_type < TIMER_INTR_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, "only support Level Interrupt");
if (p_timer_obj[group_num][timer_num] == NULL) {
p_timer_obj[group_num][timer_num] = (timer_obj_t *) heap_caps_calloc(1, sizeof(timer_obj_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num], ESP_ERR_NO_MEM, TIMER_TAG, "no mem for timer object");
}
timer_hal_context_t *hal = &p_timer_obj[group_num][timer_num]->hal;
PERIPH_RCC_ACQUIRE_ATOMIC(timer_group_periph_signals.groups[group_num].module, ref_count) {
if (ref_count == 0) {
timer_ll_enable_bus_clock(group_num, true);
timer_ll_reset_register(group_num);
}
}
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_hal_init(hal, group_num, timer_num);
timer_hal_set_counter_value(hal, 0);
timer_src_clk_t clk_src = TIMER_SRC_CLK_DEFAULT;
if (config->clk_src) {
clk_src = config->clk_src;
}
esp_clk_tree_enable_src((soc_module_clk_t)clk_src, true);
GPTIMER_CLOCK_SRC_ATOMIC() {
// although `clk_src` is of `timer_src_clk_t` type, but it's binary compatible with `gptimer_clock_source_t`,
// as the underlying enum entries come from the same `soc_module_clk_t`
timer_ll_set_clock_source(group_num, timer_num, (gptimer_clock_source_t)clk_src);
timer_ll_enable_clock(group_num, timer_num, true);
}
timer_ll_set_clock_prescale(hal->dev, timer_num, config->divider);
timer_ll_set_count_direction(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, config->counter_dir);
timer_ll_enable_intr(hal->dev, TIMER_LL_EVENT_ALARM(timer_num), false);
timer_ll_clear_intr_status(hal->dev, TIMER_LL_EVENT_ALARM(timer_num));
timer_ll_enable_alarm(hal->dev, timer_num, config->alarm_en);
timer_ll_enable_auto_reload(hal->dev, timer_num, config->auto_reload);
timer_ll_enable_counter(hal->dev, timer_num, config->counter_en);
p_timer_obj[group_num][timer_num]->clk_src = clk_src;
p_timer_obj[group_num][timer_num]->alarm_en = config->alarm_en;
p_timer_obj[group_num][timer_num]->auto_reload_en = config->auto_reload;
p_timer_obj[group_num][timer_num]->direction = config->counter_dir;
p_timer_obj[group_num][timer_num]->counter_en = config->counter_en;
p_timer_obj[group_num][timer_num]->divider = config->divider;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_deinit(timer_group_t group_num, timer_idx_t timer_num)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
timer_hal_context_t *hal = &p_timer_obj[group_num][timer_num]->hal;
// disable the source clock
GPTIMER_CLOCK_SRC_ATOMIC() {
timer_ll_enable_clock(group_num, hal->timer_id, false);
}
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_intr(hal->dev, TIMER_LL_EVENT_ALARM(timer_num), false);
timer_ll_clear_intr_status(hal->dev, TIMER_LL_EVENT_ALARM(timer_num));
timer_hal_deinit(hal);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
PERIPH_RCC_RELEASE_ATOMIC(timer_group_periph_signals.groups[group_num].module, ref_count) {
if (ref_count == 0) {
timer_ll_enable_bus_clock(group_num, false);
}
}
free(p_timer_obj[group_num][timer_num]);
p_timer_obj[group_num][timer_num] = NULL;
return ESP_OK;
}
esp_err_t timer_get_config(timer_group_t group_num, timer_idx_t timer_num, timer_config_t *config)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(timer_num < TIMER_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NUM_ERROR);
ESP_RETURN_ON_FALSE(config != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_PARAM_ADDR_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num][timer_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
config->alarm_en = p_timer_obj[group_num][timer_num]->alarm_en;
config->auto_reload = p_timer_obj[group_num][timer_num]->auto_reload_en;
config->counter_dir = p_timer_obj[group_num][timer_num]->direction;
config->counter_en = p_timer_obj[group_num][timer_num]->counter_en;
config->divider = p_timer_obj[group_num][timer_num]->divider;
config->intr_type = TIMER_INTR_LEVEL;
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_group_intr_enable(timer_group_t group_num, timer_intr_t en_mask)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_intr(p_timer_obj[group_num][0]->hal.dev, en_mask, true);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
esp_err_t timer_group_intr_disable(timer_group_t group_num, timer_intr_t disable_mask)
{
ESP_RETURN_ON_FALSE(group_num < TIMER_GROUP_MAX, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_GROUP_NUM_ERROR);
ESP_RETURN_ON_FALSE(p_timer_obj[group_num] != NULL, ESP_ERR_INVALID_ARG, TIMER_TAG, TIMER_NEVER_INIT_ERROR);
TIMER_ENTER_CRITICAL(&timer_spinlock[group_num]);
timer_ll_enable_intr(p_timer_obj[group_num][0]->hal.dev, disable_mask, false);
TIMER_EXIT_CRITICAL(&timer_spinlock[group_num]);
return ESP_OK;
}
uint32_t IRAM_ATTR timer_group_get_intr_status_in_isr(timer_group_t group_num)
{
uint32_t intr_status = 0;
if (p_timer_obj[group_num][TIMER_0] != NULL) {
intr_status = timer_ll_get_intr_status(TIMER_LL_GET_HW(group_num)) & TIMER_LL_EVENT_ALARM(0);
}
#if SOC_TIMER_GROUP_TIMERS_PER_GROUP > 1
else if (p_timer_obj[group_num][TIMER_1] != NULL) {
intr_status = timer_ll_get_intr_status(TIMER_LL_GET_HW(group_num)) & TIMER_LL_EVENT_ALARM(1);
}
#endif
return intr_status;
}
void IRAM_ATTR timer_group_clr_intr_status_in_isr(timer_group_t group_num, timer_idx_t timer_num)
{
timer_ll_clear_intr_status(p_timer_obj[group_num][timer_num]->hal.dev, TIMER_LL_EVENT_ALARM(timer_num));
}
void IRAM_ATTR timer_group_enable_alarm_in_isr(timer_group_t group_num, timer_idx_t timer_num)
{
timer_ll_enable_alarm(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, true);
}
uint64_t IRAM_ATTR timer_group_get_counter_value_in_isr(timer_group_t group_num, timer_idx_t timer_num)
{
timer_ll_trigger_soft_capture(p_timer_obj[group_num][timer_num]->hal.dev, timer_num);
uint64_t val = timer_ll_get_counter_value(p_timer_obj[group_num][timer_num]->hal.dev, timer_num);
return val;
}
void IRAM_ATTR timer_group_set_alarm_value_in_isr(timer_group_t group_num, timer_idx_t timer_num, uint64_t alarm_val)
{
timer_ll_set_alarm_value(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, alarm_val);
p_timer_obj[group_num][timer_num]->alarm_value = alarm_val;
}
void IRAM_ATTR timer_group_set_counter_enable_in_isr(timer_group_t group_num, timer_idx_t timer_num, timer_start_t counter_en)
{
timer_ll_enable_counter(p_timer_obj[group_num][timer_num]->hal.dev, timer_num, counter_en);
p_timer_obj[group_num][timer_num]->counter_en = counter_en;
}
bool IRAM_ATTR timer_group_get_auto_reload_in_isr(timer_group_t group_num, timer_idx_t timer_num)
{
return p_timer_obj[group_num][timer_num]->auto_reload_en;
}
#if !CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK
/**
* @brief This function will be called during start up, to check that this legacy timer group driver is not running along with the gptimer driver
*/
__attribute__((constructor))
static void check_legacy_timer_driver_conflict(void)
{
// This function was declared as weak here. gptimer driver has one implementation.
// So if gptimer driver is not linked in, then `gptimer_new_timer()` should be NULL at runtime.
extern __attribute__((weak)) esp_err_t gptimer_new_timer(const void *config, void **ret_timer);
if ((void *)gptimer_new_timer != NULL) {
ESP_EARLY_LOGE(TIMER_TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver");
abort();
}
ESP_EARLY_LOGW(TIMER_TAG, "legacy driver is deprecated, please migrate to `driver/gptimer.h`");
}
#endif //CONFIG_GPTIMER_SKIP_LEGACY_CONFLICT_CHECK
@@ -1,33 +1,5 @@
# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps
components/driver/test_apps/dac_test_apps/legacy_dac_driver:
disable:
- if: SOC_DAC_SUPPORTED != 1
depends_components:
- esp_adc
components/driver/test_apps/i2s_test_apps/legacy_i2s_adc_dac:
disable:
- if: SOC_I2S_SUPPORTS_ADC_DAC != 1
components/driver/test_apps/i2s_test_apps/legacy_i2s_driver:
disable:
- if: SOC_I2S_SUPPORTED != 1
components/driver/test_apps/legacy_adc_driver:
disable:
- if: SOC_ADC_SUPPORTED != 1
disable_test:
- if: IDF_TARGET == "esp32c61"
temporary: true
reason: lack of runners
depends_components:
- efuse
- esp_driver_i2s
- esp_driver_spi
depends_filepatterns:
- components/driver/deprecated/**/*adc*
components/driver/test_apps/legacy_i2c_driver:
disable:
- if: SOC_I2C_SUPPORTED != 1
@@ -42,22 +14,12 @@ components/driver/test_apps/legacy_mcpwm_driver:
depends_filepatterns:
- components/driver/deprecated/**/*mcpwm*
components/driver/test_apps/legacy_pcnt_driver:
disable:
- if: SOC_PCNT_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*pcnt*
components/driver/test_apps/legacy_rmt_driver:
disable:
- if: SOC_RMT_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*rmt*
components/driver/test_apps/legacy_rtc_temp_driver:
disable:
- if: SOC_TEMP_SENSOR_SUPPORTED != 1
components/driver/test_apps/legacy_sigma_delta_driver:
disable:
- if: SOC_SDM_SUPPORTED != 1
@@ -66,12 +28,6 @@ components/driver/test_apps/legacy_sigma_delta_driver:
depends_components:
- esp_driver_gpio
components/driver/test_apps/legacy_timer_driver:
disable:
- if: SOC_GPTIMER_SUPPORTED != 1
depends_filepatterns:
- components/driver/deprecated/**/*timer*
components/driver/test_apps/legacy_twai:
disable:
- if: SOC_TWAI_SUPPORTED != 1 or SOC_TWAI_SUPPORT_FD == 1
@@ -1,21 +0,0 @@
# This is the project CMakeLists.txt file for the test subproject
cmake_minimum_required(VERSION 3.16)
# "Trim" the build. Include the minimal set of components, main, and anything it depends on.
set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(dac_legacy_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py
--rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/
--elf-file ${CMAKE_BINARY_DIR}/dac_legacy_test.elf
find-refs
--from-sections=.iram0.text
--to-sections=.flash.text,.flash.rodata
--exit-code
DEPENDS ${elf}
)
endif()
@@ -1,2 +0,0 @@
| Supported Targets | ESP32 | ESP32-S2 |
| ----------------- | ----- | -------- |
@@ -1,8 +0,0 @@
set(srcs "test_app_main.c"
"test_legacy_dac.c")
# In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver esp_event esp_adc
WHOLE_ARCHIVE)
@@ -1,53 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "unity.h"
#include "unity_test_runner.h"
#include "esp_heap_caps.h"
// Some resources are lazy allocated in dac driver, the threshold is left for that case
#define TEST_MEMORY_LEAK_THRESHOLD (-300)
static size_t before_free_8bit;
static size_t before_free_32bit;
static void check_leak(size_t before_free, size_t after_free, const char *type)
{
ssize_t delta = after_free - before_free;
printf("MALLOC_CAP_%s: Before %u bytes free, After %u bytes free (delta %d)\n", type, before_free, after_free, delta);
TEST_ASSERT_MESSAGE(delta >= TEST_MEMORY_LEAK_THRESHOLD, "memory leak");
}
void setUp(void)
{
before_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
before_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
}
void tearDown(void)
{
size_t after_free_8bit = heap_caps_get_free_size(MALLOC_CAP_8BIT);
size_t after_free_32bit = heap_caps_get_free_size(MALLOC_CAP_32BIT);
check_leak(before_free_8bit, after_free_8bit, "8BIT");
check_leak(before_free_32bit, after_free_32bit, "32BIT");
}
void app_main(void)
{
// ____ _ ____ _____ _
// | _ \ / \ / ___| |_ _|__ ___| |_
// | | | |/ _ \| | | |/ _ \/ __| __|
// | |_| / ___ \ |___ | | __/\__ \ |_
// |____/_/ \_\____| |_|\___||___/\__|
printf(" ____ _ ____ _____ _ \n");
printf(" | _ \\ / \\ / ___| |_ _|__ ___| |_ \n");
printf(" | | | |/ _ \\| | | |/ _ \\/ __| __|\n");
printf(" | |_| / ___ \\ |___ | | __/\\__ \\ |_ \n");
printf(" |____/_/ \\_\\____| |_|\\___||___/\\__| (legacy)\n");
unity_run_menu();
}
@@ -1,183 +0,0 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
/*
Tests for the dac device driver
*/
#include <inttypes.h>
#include "esp_system.h"
#include "unity.h"
#include "unity_test_utils.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "soc/soc_caps.h"
#define CONFIG_ADC_SUPPRESS_DEPRECATE_WARN 1
#include "driver/adc.h"
#include "driver/dac.h"
#include "esp_adc_cal.h"
static const char *TAG = "test_dac";
#ifdef CONFIG_IDF_TARGET_ESP32
#define ADC_TEST_WIDTH ADC_WIDTH_BIT_12
#elif defined CONFIG_IDF_TARGET_ESP32S2
#define ADC_TEST_WIDTH ADC_WIDTH_BIT_13 //ESP32S2 only support 13 bit width
#endif
#define ADC_TEST_ATTEN ADC_ATTEN_DB_12
#if CONFIG_IDF_TARGET_ESP32
#define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_8 // GPIO25
#define DAC_TEST_CHANNEL_NUM DAC_CHAN_0 // GPIO25
#elif CONFIG_IDF_TARGET_ESP32S2
#define ADC_TEST_CHANNEL_NUM ADC2_CHANNEL_6 // GPIO17
#define DAC_TEST_CHANNEL_NUM DAC_CHAN_0 // GPIO17
#endif
#define DAC_OUT_MAX (200)
#define DAC_OUT_TIMES (10)
#define DAC_OUT_STEP (DAC_OUT_MAX / DAC_OUT_TIMES)
#define DAC_TEST_TIMES (100)
TEST_CASE("DAC_output(RTC)_check_by_adc", "[dac_legacy]")
{
gpio_num_t adc_gpio_num, dac_gpio_num;
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
//be sure to do the init before using adc2.
printf("adc2_init...\n");
TEST_ESP_OK(adc2_config_channel_atten(ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN));
vTaskDelay(2 * portTICK_PERIOD_MS);
printf("start conversion.\n");
int output_data = 0;
int read_raw = 0, read_old = 0;
for (int i = 0; i < DAC_OUT_TIMES; i++) {
TEST_ESP_OK(dac_output_voltage(DAC_TEST_CHANNEL_NUM, output_data));
output_data += DAC_OUT_STEP;
vTaskDelay(2 * portTICK_PERIOD_MS);
TEST_ESP_OK(adc2_get_raw(ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw));
ESP_LOGI(TAG, "DAC: %d - ADC: %d", output_data, read_raw);
if (read_old != 0) {
TEST_ASSERT_GREATER_THAN(read_old, read_raw);
}
read_old = read_raw;
}
TEST_ESP_OK(dac_output_disable(DAC_TEST_CHANNEL_NUM));
}
TEST_CASE("DAC_cw_generator_output(RTC)_check_by_adc", "[dac_legacy]")
{
gpio_num_t adc_gpio_num, dac_gpio_num;
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
dac_cw_config_t cw = {
.en_ch = DAC_TEST_CHANNEL_NUM,
.scale = DAC_CW_SCALE_2,
.phase = DAC_CW_PHASE_0,
.freq = 1000,
#if CONFIG_IDF_TARGET_ESP32
.offset = 64,
#elif CONFIG_IDF_TARGET_ESP32S2
.offset = 16,
#endif
};
TEST_ESP_OK(dac_cw_generator_config(&cw));
TEST_ESP_OK(dac_cw_generator_enable());
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
//be sure to do the init before using adc2.
printf("adc2_init...\n");
TEST_ESP_OK(adc2_config_channel_atten(ADC_TEST_CHANNEL_NUM, ADC_TEST_ATTEN));
vTaskDelay(2 * portTICK_PERIOD_MS);
printf("start conversion.\n");
int read_raw[3] = {0};
for (int i = 0; i < DAC_TEST_TIMES; i++) {
vTaskDelay(10 * portTICK_PERIOD_MS);
TEST_ESP_OK(adc2_get_raw(ADC_TEST_CHANNEL_NUM, ADC_TEST_WIDTH, &read_raw[0]));
ESP_LOGI(TAG, "ADC: %d", read_raw[0]);
read_raw[2] = read_raw[1];
read_raw[1] = read_raw[0];
}
TEST_ESP_OK(dac_cw_generator_disable());
TEST_ESP_OK(dac_output_disable(DAC_TEST_CHANNEL_NUM));
}
#if CONFIG_IDF_TARGET_ESP32S2
static int helper_calc_dac_output(int mV)
{
return mV * 0.07722;
}
static bool subtest_adc_dac(int mV_ref, esp_adc_cal_characteristics_t * chars)
{
dac_output_voltage(DAC_TEST_CHANNEL_NUM, helper_calc_dac_output(mV_ref));
vTaskDelay(pdMS_TO_TICKS(80));
int raw;
adc2_get_raw((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_WIDTH_BIT_13, &raw);
uint32_t voltage = esp_adc_cal_raw_to_voltage(raw, chars);
TEST_ASSERT_INT_WITHIN(200, mV_ref, voltage); // 200 mV error allowance, because both DAC and ADC have error
return true;
}
TEST_CASE("esp32s2_adc2-dac_with_adc2_calibration", "[dac_legacy]")
{
gpio_num_t adc_gpio_num, dac_gpio_num;
if (esp_adc_cal_check_efuse(ESP_ADC_CAL_VAL_EFUSE_TP) != ESP_OK) {
TEST_IGNORE_MESSAGE("Warning: This esp32s2 board does not support calibration. This test will be skipped.\n");
}
TEST_ESP_OK(adc2_pad_get_io_num(ADC_TEST_CHANNEL_NUM, &adc_gpio_num));
TEST_ESP_OK(dac_pad_get_io_num(DAC_TEST_CHANNEL_NUM, &dac_gpio_num));
printf("Please connect ADC2 CH%d-GPIO%d <--> DAC CH%d-GPIO%d.\n", ADC_TEST_CHANNEL_NUM, adc_gpio_num,
DAC_TEST_CHANNEL_NUM + 1, dac_gpio_num);
TEST_ESP_OK(dac_output_enable(DAC_TEST_CHANNEL_NUM));
esp_adc_cal_characteristics_t chars;
printf("Test 0dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_0);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_0, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(750, &chars);
printf("Test 2.5dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_2_5);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_2_5, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(1100, &chars);
printf("Test 6dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_6);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_6, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(800, &chars);
subtest_adc_dac(1250, &chars);
printf("Test 11dB atten...\n");
adc2_config_channel_atten((adc2_channel_t)ADC_TEST_CHANNEL_NUM, ADC_ATTEN_DB_12);
esp_adc_cal_characterize(ADC_UNIT_2, ADC_ATTEN_DB_12, ADC_WIDTH_BIT_13, 0, &chars);
printf("a %"PRIu32", b %"PRIu32"\n", chars.coeff_a, chars.coeff_b);
subtest_adc_dac(1500, &chars);
subtest_adc_dac(2500, &chars);
}
#endif
@@ -1,18 +0,0 @@
# SPDX-FileCopyrightText: 2021-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: CC0-1.0
import pytest
from pytest_embedded import Dut
from pytest_embedded_idf.utils import idf_parametrize
@pytest.mark.generic
@pytest.mark.parametrize(
'config',
[
'release',
],
indirect=True,
)
@idf_parametrize('target', ['esp32', 'esp32s2'], indirect=['target'])
def test_legacy_dac(dut: Dut) -> None:
dut.run_all_single_board_cases()

Some files were not shown because too many files have changed in this diff Show More