From f3087c8fb04541d3b87684bc32ad1fa74da4259e Mon Sep 17 00:00:00 2001 From: hongshuqing Date: Thu, 6 Jun 2024 21:42:23 +0800 Subject: [PATCH 01/70] fix: fix pll low temp bug --- components/esp_hw_support/port/esp32h2/pmu_sleep.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/components/esp_hw_support/port/esp32h2/pmu_sleep.c b/components/esp_hw_support/port/esp32h2/pmu_sleep.c index ab32613ab59..60492aa4de1 100644 --- a/components/esp_hw_support/port/esp32h2/pmu_sleep.c +++ b/components/esp_hw_support/port/esp32h2/pmu_sleep.c @@ -20,6 +20,8 @@ #include "hal/efuse_ll.h" #include "hal/efuse_hal.h" #include "esp_hw_log.h" +#include "soc/regi2c_bias.h" +#include "regi2c_ctrl.h" static __attribute__((unused)) const char *TAG = "pmu_sleep"; @@ -264,6 +266,8 @@ uint32_t pmu_sleep_start(uint32_t wakeup_opt, uint32_t reject_opt, uint32_t lslp bool pmu_sleep_finish(bool dslp) { (void)dslp; + // Restore registers lost during sleep + REGI2C_WRITE_MASK(I2C_BIAS, I2C_BIAS_DREG_0P8, 8); // fix low temp issue, need to increase this internal voltage return pmu_ll_hp_is_sleep_reject(PMU_instance()->hal->dev); } From ff25e646fb7ec627d12bb376cf2a3f88a7e12e6a Mon Sep 17 00:00:00 2001 From: Abhik Roy Date: Sun, 29 Sep 2024 14:24:25 +1000 Subject: [PATCH 02/70] fix(lwip): Fixed active DNS entries before clearing cache --- components/lwip/lwip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/lwip/lwip b/components/lwip/lwip index f150e2321ac..b15cd2de75d 160000 --- a/components/lwip/lwip +++ b/components/lwip/lwip @@ -1 +1 @@ -Subproject commit f150e2321ac09bb0fd35a7fcbc1b116fbf93434e +Subproject commit b15cd2de75d408f9f813367571143b9bcff20738 From 0abdd2024029442e4c5ff78e9e2d68cabc23b771 Mon Sep 17 00:00:00 2001 From: chenjianhua Date: Tue, 22 Oct 2024 11:13:20 +0800 Subject: [PATCH 03/70] fix(bt/bluedroid): Fixed error when memory debug enabled --- components/bt/common/osi/allocator.c | 3 ++ .../bt/common/osi/include/osi/allocator.h | 48 +++++-------------- components/bt/host/bluedroid/hci/hci_hal_h4.c | 4 ++ 3 files changed, 18 insertions(+), 37 deletions(-) diff --git a/components/bt/common/osi/allocator.c b/components/bt/common/osi/allocator.c index fba9cf0a9e0..86fb705b071 100644 --- a/components/bt/common/osi/allocator.c +++ b/components/bt/common/osi/allocator.c @@ -241,5 +241,8 @@ void *osi_calloc_func(size_t size) void osi_free_func(void *ptr) { +#if HEAP_MEMORY_DEBUG + osi_mem_dbg_clean(ptr, __func__, __LINE__); +#endif free(ptr); } diff --git a/components/bt/common/osi/include/osi/allocator.h b/components/bt/common/osi/include/osi/allocator.h index 25eca3431b1..d95040538d8 100644 --- a/components/bt/common/osi/include/osi/allocator.h +++ b/components/bt/common/osi/include/osi/allocator.h @@ -29,6 +29,15 @@ void *osi_malloc_func(size_t size); void *osi_calloc_func(size_t size); void osi_free_func(void *ptr); +// Memory alloc function without print and assertion +#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST +#define osi_malloc_base(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#define osi_calloc_base(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) +#else +#define osi_malloc_base(size) malloc((size)) +#define osi_calloc_base(size) calloc(1, (size)) +#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ + #if HEAP_MEMORY_DEBUG void osi_mem_dbg_init(void); @@ -41,33 +50,10 @@ void osi_men_dbg_set_section_start(uint8_t index); void osi_men_dbg_set_section_end(uint8_t index); uint32_t osi_mem_dbg_get_max_size_section(uint8_t index); -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST -#define osi_malloc(size) \ -({ \ - void *p; \ - p = heap_caps_malloc_prefer(size, 2, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ - osi_mem_dbg_record(p, size, __func__, __LINE__); \ - (void *)p; \ -}) - -#define osi_calloc(size) \ -({ \ - void *p; \ - p = heap_caps_calloc_prefer(1, size, 2, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, \ - MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL); \ - osi_mem_dbg_record(p, size, __func__, __LINE__); \ - (void *)p; \ -}) - -#else - #define osi_malloc(size) \ ({ \ void *p; \ - p = malloc((size)); \ + p = osi_malloc_base(size); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) @@ -75,14 +61,11 @@ uint32_t osi_mem_dbg_get_max_size_section(uint8_t index); #define osi_calloc(size) \ ({ \ void *p; \ - p = calloc(1, (size)); \ + p = osi_calloc_base(size); \ osi_mem_dbg_record(p, size, __func__, __LINE__); \ (void *)p; \ }) -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ - - #if 0 #define osi_malloc(size) \ do { \ @@ -122,15 +105,6 @@ do { \ #else -// Memory alloc function without print and assertion -#if HEAP_ALLOCATION_FROM_SPIRAM_FIRST -#define osi_malloc_base(size) heap_caps_malloc_prefer(size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#define osi_calloc_base(size) heap_caps_calloc_prefer(1, size, 2, MALLOC_CAP_DEFAULT|MALLOC_CAP_SPIRAM, MALLOC_CAP_DEFAULT|MALLOC_CAP_INTERNAL) -#else -#define osi_malloc_base(size) malloc((size)) -#define osi_calloc_base(size) calloc(1, (size)) -#endif /* #if HEAP_ALLOCATION_FROM_SPIRAM_FIRST */ - // Memory alloc function with print and assertion when fails #define osi_malloc(size) osi_malloc_func((size)) #define osi_calloc(size) osi_calloc_func((size)) diff --git a/components/bt/host/bluedroid/hci/hci_hal_h4.c b/components/bt/host/bluedroid/hci/hci_hal_h4.c index da3be907074..f5b16385eb5 100644 --- a/components/bt/host/bluedroid/hci/hci_hal_h4.c +++ b/components/bt/host/bluedroid/hci/hci_hal_h4.c @@ -593,7 +593,11 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len) } #endif pkt_size = BT_PKT_LINKED_HDR_SIZE + BT_HDR_SIZE + len; + #if HEAP_MEMORY_DEBUG + linked_pkt = (pkt_linked_item_t *) osi_calloc(pkt_size); + #else linked_pkt = (pkt_linked_item_t *) osi_calloc_base(pkt_size); + #endif if (!linked_pkt) { #if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE) hci_adv_credits_consumed(1); From a011ac0587f5cee989453ea5231fd3a8f805582b Mon Sep 17 00:00:00 2001 From: cjin Date: Fri, 18 Oct 2024 16:39:28 +0800 Subject: [PATCH 04/70] fix(ble): do not assert if ble sleep init failed --- components/bt/controller/esp32c5/bt.c | 24 +++++++++++++--------- components/bt/controller/esp32c6/bt.c | 28 +++++++++++++++----------- components/bt/controller/esp32h2/bt.c | 29 ++++++++++++++++----------- 3 files changed, 47 insertions(+), 34 deletions(-) diff --git a/components/bt/controller/esp32c5/bt.c b/components/bt/controller/esp32c5/bt.c index c0ed4fff553..de235b3fe02 100644 --- a/components/bt/controller/esp32c5/bt.c +++ b/components/bt/controller/esp32c5/bt.c @@ -184,7 +184,6 @@ const static uint32_t log_bufs_size[] = {CONFIG_BT_LE_LOG_CTRL_BUF1_SIZE, CONFIG static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; -#define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; @@ -404,7 +403,7 @@ static void sleep_modem_ble_mac_modem_state_deinit(void) } } -void sleep_modem_light_sleep_overhead_set(uint32_t overhead) +void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead) { r_esp_ble_set_wakeup_overhead(overhead); } @@ -424,16 +423,19 @@ esp_err_t controller_sleep_init(void) BLE_RTC_DELAY_US_MODEM_SLEEP); #endif /* FREERTOS_USE_TICKLESS_IDLE */ #endif // CONFIG_BT_LE_SLEEP_ENABLE - #ifdef CONFIG_PM_ENABLE rc = esp_pm_lock_create(ESP_PM_CPU_FREQ_MAX, 0, "bt", &s_pm_lock); if (rc != ESP_OK) { goto error; } -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE + +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Create a new regdma link for BLE related register restoration */ rc = sleep_modem_ble_mac_modem_state_init(0); - assert(rc == 0); + if (rc != ESP_OK) { + goto error; + } esp_sleep_enable_bt_wakeup(); ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer"); @@ -446,19 +448,21 @@ esp_err_t controller_sleep_init(void) sleep_modem_register_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ return rc; +#ifdef CONFIG_PM_ENABLE error: - -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD esp_sleep_disable_bt_wakeup(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#ifdef CONFIG_PM_ENABLE /*lock should release first and then delete*/ if (s_pm_lock != NULL) { esp_pm_lock_delete(s_pm_lock); @@ -471,7 +475,7 @@ esp_err_t controller_sleep_init(void) void controller_sleep_deinit(void) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); diff --git a/components/bt/controller/esp32c6/bt.c b/components/bt/controller/esp32c6/bt.c index 8bc3992e441..828efa09f6e 100644 --- a/components/bt/controller/esp32c6/bt.c +++ b/components/bt/controller/esp32c6/bt.c @@ -388,7 +388,6 @@ void esp_bt_read_ctrl_log_from_flash(bool output) static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; -#define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; @@ -612,7 +611,7 @@ static void sleep_modem_ble_mac_modem_state_deinit(void) } } -void sleep_modem_light_sleep_overhead_set(uint32_t overhead) +void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead) { r_esp_ble_set_wakeup_overhead(overhead); } @@ -639,17 +638,20 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE -#if CONFIG_BT_LE_SLEEP_ENABLE && SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD #error "CONFIG_MAC_BB_PD required for BLE light sleep to run properly" -#endif // CONFIG_BT_LE_SLEEP_ENABLE && SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD +#endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && !CONFIG_MAC_BB_PD /* Create a new regdma link for BLE related register restoration */ #if SOC_PM_RETENTION_HAS_CLOCK_BUG rc = sleep_modem_ble_mac_modem_state_init(1); #else rc = sleep_modem_ble_mac_modem_state_init(0); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG - assert(rc == 0); + if (rc != ESP_OK) { + goto error; + } esp_sleep_enable_bt_wakeup(); ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer"); @@ -662,19 +664,21 @@ esp_err_t controller_sleep_init(void) sleep_modem_register_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ return rc; +#ifdef CONFIG_PM_ENABLE error: - -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); #endif // SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD esp_sleep_disable_bt_wakeup(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#ifdef CONFIG_PM_ENABLE /*lock should release first and then delete*/ if (s_pm_lock != NULL) { esp_pm_lock_delete(s_pm_lock); @@ -687,7 +691,7 @@ esp_err_t controller_sleep_init(void) void controller_sleep_deinit(void) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE #if SOC_PM_RETENTION_HAS_CLOCK_BUG && CONFIG_MAC_BB_PD sleep_modem_unregister_mac_bb_module_prepare_callback(sleep_modem_mac_bb_power_down_prepare, sleep_modem_mac_bb_power_up_prepare); @@ -696,7 +700,7 @@ void controller_sleep_deinit(void) esp_sleep_disable_bt_wakeup(); sleep_modem_ble_mac_modem_state_deinit(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ #ifdef CONFIG_PM_ENABLE /* lock should be released first */ esp_pm_lock_delete(s_pm_lock); diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index 9a46b2ca6c2..8830a2018e7 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -385,7 +385,6 @@ void esp_bt_read_ctrl_log_from_flash(bool output) static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE static DRAM_ATTR esp_pm_lock_handle_t s_pm_lock = NULL; -#define BTDM_MIN_TIMER_UNCERTAINTY_US (200) #endif // CONFIG_PM_ENABLE static DRAM_ATTR modem_clock_lpclk_src_t s_bt_lpclk_src = MODEM_CLOCK_LPCLK_SRC_INVALID; @@ -604,7 +603,7 @@ static void sleep_modem_ble_mac_modem_state_deinit(void) } } -void sleep_modem_light_sleep_overhead_set(uint32_t overhead) +void IRAM_ATTR sleep_modem_light_sleep_overhead_set(uint32_t overhead) { r_esp_ble_set_wakeup_overhead(overhead); } @@ -631,13 +630,17 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } - rc = esp_deep_sleep_register_hook(&r_esp_ble_stop_wakeup_timing); - assert(rc == 0); -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE + if (rc != ESP_OK) { + goto error; + } +#endif //CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE /* Create a new regdma link for BLE related register restoration */ rc = sleep_modem_ble_mac_modem_state_init(0); - assert(rc == 0); + if (rc != ESP_OK) { + goto error; + } esp_sleep_enable_bt_wakeup(); ESP_LOGW(NIMBLE_PORT_LOG_TAG, "Enable light sleep, the wake up source is BLE timer"); @@ -645,15 +648,17 @@ esp_err_t controller_sleep_init(void) if (rc != ESP_OK) { goto error; } -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ return rc; +#ifdef CONFIG_PM_ENABLE error: - -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#endif // CONFIG_PM_ENABLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE esp_sleep_disable_bt_wakeup(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#ifdef CONFIG_PM_ENABLE esp_deep_sleep_deregister_hook(&r_esp_ble_stop_wakeup_timing); /*lock should release first and then delete*/ if (s_pm_lock != NULL) { @@ -667,12 +672,12 @@ esp_err_t controller_sleep_init(void) void controller_sleep_deinit(void) { -#if CONFIG_FREERTOS_USE_TICKLESS_IDLE +#if CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE r_ble_rtc_wake_up_state_clr(); esp_sleep_disable_bt_wakeup(); sleep_modem_ble_mac_modem_state_deinit(); esp_pm_unregister_inform_out_light_sleep_overhead_callback(sleep_modem_light_sleep_overhead_set); -#endif /* CONFIG_FREERTOS_USE_TICKLESS_IDLE */ +#endif /* CONFIG_BT_LE_SLEEP_ENABLE && CONFIG_FREERTOS_USE_TICKLESS_IDLE */ #ifdef CONFIG_PM_ENABLE esp_deep_sleep_deregister_hook(&r_esp_ble_stop_wakeup_timing); /* lock should be released first */ From 8406735635b15938e7b4ff18493678d241300f2f Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Thu, 24 Oct 2024 09:50:29 +0800 Subject: [PATCH 05/70] fix(lp_core): updated lp rom newlib API addresses --- .../esp32p4/ld/esp32p4lp.rom.newlib.ld | 118 +++++++++--------- .../lp_core_hp_uart/main/CMakeLists.txt | 7 +- .../main/lp_core/test_lp_rom_main.c | 85 +++++++++++++ .../lp_core_hp_uart/main/test_lp_core.c | 30 +++++ .../lp_core_hp_uart/pytest_lp_core_hp_uart.py | 9 ++ 5 files changed, 189 insertions(+), 60 deletions(-) create mode 100644 components/ulp/test_apps/lp_core/lp_core_hp_uart/main/lp_core/test_lp_rom_main.c diff --git a/components/esp_rom/esp32p4/ld/esp32p4lp.rom.newlib.ld b/components/esp_rom/esp32p4/ld/esp32p4lp.rom.newlib.ld index d4936c7833c..ab46640b20b 100644 --- a/components/esp_rom/esp32p4/ld/esp32p4lp.rom.newlib.ld +++ b/components/esp_rom/esp32p4/ld/esp32p4lp.rom.newlib.ld @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ /* ROM function interface esp32p4lp.rom.newlib.ld for esp32p4lp * * - * Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum 0751c805e21bd23f11b74dcc1f7e8007 + * Generated from ./target/esp32p4lp/interface-esp32p4lp.yml md5sum f827caf806e9f4faec384ffbde44b380 * * Compatible with ROM where ECO version equal or greater to 0. * @@ -18,60 +18,60 @@ ***************************************/ /* Functions */ -memset = 0x501000f0; -memcpy = 0x501000f4; -memmove = 0x501000f8; -memcmp = 0x501000fc; -strcpy = 0x50100100; -strncpy = 0x50100104; -strcmp = 0x50100108; -strncmp = 0x5010010c; -strlen = 0x50100110; -strstr = 0x50100114; -bzero = 0x50100118; -isalnum = 0x5010011c; -isalpha = 0x50100120; -isascii = 0x50100124; -isblank = 0x50100128; -iscntrl = 0x5010012c; -isdigit = 0x50100130; -islower = 0x50100134; -isgraph = 0x50100138; -isprint = 0x5010013c; -ispunct = 0x50100140; -isspace = 0x50100144; -isupper = 0x50100148; -toupper = 0x5010014c; -tolower = 0x50100150; -toascii = 0x50100154; -memccpy = 0x50100158; -memchr = 0x5010015c; -memrchr = 0x50100160; -strcasecmp = 0x50100164; -strcasestr = 0x50100168; -strcat = 0x5010016c; -strchr = 0x50100170; -strcspn = 0x50100174; -strcoll = 0x50100178; -strlcat = 0x5010017c; -strlcpy = 0x50100180; -strlwr = 0x50100184; -strncasecmp = 0x50100188; -strncat = 0x5010018c; -strnlen = 0x50100190; -strrchr = 0x50100194; -strsep = 0x50100198; -strspn = 0x5010019c; -strtok_r = 0x501001a0; -strupr = 0x501001a4; -longjmp = 0x501001a8; -setjmp = 0x501001ac; -abs = 0x501001b0; -div = 0x501001b4; -labs = 0x501001b8; -ldiv = 0x501001bc; -qsort = 0x501001c0; -atoi = 0x501001c4; -atol = 0x501001c8; -itoa = 0x501001cc; -utoa = 0x501001d0; +memset = 0x50100134; +memcpy = 0x50100138; +memmove = 0x5010013c; +memcmp = 0x50100140; +strcpy = 0x50100144; +strncpy = 0x50100148; +strcmp = 0x5010014c; +strncmp = 0x50100150; +strlen = 0x50100154; +strstr = 0x50100158; +bzero = 0x5010015c; +isalnum = 0x50100160; +isalpha = 0x50100164; +isascii = 0x50100168; +isblank = 0x5010016c; +iscntrl = 0x50100170; +isdigit = 0x50100174; +islower = 0x50100178; +isgraph = 0x5010017c; +isprint = 0x50100180; +ispunct = 0x50100184; +isspace = 0x50100188; +isupper = 0x5010018c; +toupper = 0x50100190; +tolower = 0x50100194; +toascii = 0x50100198; +memccpy = 0x5010019c; +memchr = 0x501001a0; +memrchr = 0x501001a4; +strcasecmp = 0x501001a8; +strcasestr = 0x501001ac; +strcat = 0x501001b0; +strchr = 0x501001b4; +strcspn = 0x501001b8; +strcoll = 0x501001bc; +strlcat = 0x501001c0; +strlcpy = 0x501001c4; +strlwr = 0x501001c8; +strncasecmp = 0x501001cc; +strncat = 0x501001d0; +strnlen = 0x501001d4; +strrchr = 0x501001d8; +strsep = 0x501001dc; +strspn = 0x501001e0; +strtok_r = 0x501001e4; +strupr = 0x501001e8; +longjmp = 0x501001ec; +setjmp = 0x501001f0; +abs = 0x501001f4; +div = 0x501001f8; +labs = 0x501001fc; +ldiv = 0x50100200; +qsort = 0x50100204; +atoi = 0x50100208; +atol = 0x5010020c; +itoa = 0x50100210; +utoa = 0x50100214; diff --git a/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/CMakeLists.txt b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/CMakeLists.txt index 9e6a9d16bbb..a1ca21afaf9 100644 --- a/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/CMakeLists.txt @@ -1,7 +1,8 @@ set(app_sources "test_app_main.c" "test_lp_core.c") set(lp_core_sources "lp_core/test_hello_main.c") set(lp_core_sources_panic "lp_core/test_panic_main.c") -set(lp_core_sources_shared_mem "lp_core/test_shared_mem_main.c") +set(lp_core_sources_shared_mem "lp_core/test_shared_mem_main.c") +set(lp_core_sources_lp_rom "lp_core/test_lp_rom_main.c") idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "lp_core" @@ -13,3 +14,7 @@ set(lp_core_exp_dep_srcs ${app_sources}) ulp_embed_binary(lp_core_test_app "${lp_core_sources}" "${lp_core_exp_dep_srcs}") ulp_embed_binary(lp_core_test_app_panic "${lp_core_sources_panic}" "${lp_core_exp_dep_srcs}") ulp_embed_binary(lp_core_test_app_shared_mem "${lp_core_sources_shared_mem}" "${lp_core_exp_dep_srcs}") + +if(CONFIG_ESP_ROM_HAS_LP_ROM) + ulp_embed_binary(lp_core_test_app_lp_rom "${lp_core_sources_lp_rom}" "${lp_core_exp_dep_srcs}") +endif() diff --git a/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/lp_core/test_lp_rom_main.c b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/lp_core/test_lp_rom_main.c new file mode 100644 index 00000000000..6a99e116f74 --- /dev/null +++ b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/lp_core/test_lp_rom_main.c @@ -0,0 +1,85 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include +#include +#include +#include "soc/soc.h" +#include "ulp_lp_core_print.h" +#include + +void assert_function_in_rom(void *func) +{ + if ((intptr_t)func < SOC_LP_ROM_LOW || (intptr_t)func > SOC_LP_ROM_HIGH) { + abort(); + } +} + +static void test_memset(void) +{ +#define TEST_MEMSET_VAL 0xAB + assert_function_in_rom(memset); + + lp_core_printf("Testing memset\n"); + uint8_t test_buf[100]; + + memset(test_buf, TEST_MEMSET_VAL, sizeof(test_buf)); + + for (int i = 0; i < sizeof(test_buf); i++) { + if (test_buf[i] != TEST_MEMSET_VAL) { + lp_core_printf("test_buf[%d]: 0x%X != 0x%X\n", i, test_buf[i], TEST_MEMSET_VAL); + abort(); + } + } +} + +static void test_memcpy(void) +{ +#define TEST_MEMCPY_VAL 0xAC +#define TEST_SIZE 100 + + assert_function_in_rom(memcpy); + lp_core_printf("Testing memcpy\n"); + uint8_t test_buf_a[TEST_SIZE]; + memset(test_buf_a, TEST_MEMCPY_VAL, TEST_SIZE); + + uint8_t test_buf_b[TEST_SIZE]; + + memcpy(test_buf_b, test_buf_a, TEST_SIZE); + + for (int i = 0; i < TEST_SIZE; i++) { + if (test_buf_b[i] != TEST_MEMCPY_VAL) { + lp_core_printf("test_buf_b[%d]: 0x%X != 0x%X\n", i, test_buf_b[i], TEST_MEMCPY_VAL); + abort(); + } + } +} + +static void test_abs(void) +{ + assert_function_in_rom(abs); + lp_core_printf("Testing abs\n"); + if (abs(-123) != 123) { + lp_core_printf("Failed abs() test\n"); + abort(); + } +} + +volatile bool lp_rom_test_finished; + +int main(void) +{ + // Test a misc of ROM functions to catch any regression with LD file updates + test_memset(); + test_memcpy(); + test_abs(); + + lp_core_printf("ULP: all tests passed\n"); + lp_rom_test_finished = true; + + return 0; +} diff --git a/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/test_lp_core.c b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/test_lp_core.c index e21d52afbda..3567f4a65f7 100644 --- a/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/test_lp_core.c +++ b/components/ulp/test_apps/lp_core/lp_core_hp_uart/main/test_lp_core.c @@ -19,6 +19,10 @@ #include "ulp_lp_core_memory_shared.h" #include "test_shared.h" +#if ESP_ROM_HAS_LP_ROM +#include "lp_core_test_app_lp_rom.h" +#endif + extern const uint8_t lp_core_main_bin_start[] asm("_binary_lp_core_test_app_bin_start"); extern const uint8_t lp_core_main_bin_end[] asm("_binary_lp_core_test_app_bin_end"); @@ -28,6 +32,11 @@ extern const uint8_t lp_core_panic_bin_end[] asm("_binary_lp_core_test_app_pan extern const uint8_t lp_core_shared_mem_bin_start[] asm("_binary_lp_core_test_app_shared_mem_bin_start"); extern const uint8_t lp_core_shared_mem_bin_end[] asm("_binary_lp_core_test_app_shared_mem_bin_end"); +#if ESP_ROM_HAS_LP_ROM +extern const uint8_t lp_core_lp_rom_bin_start[] asm("_binary_lp_core_test_app_lp_rom_bin_start"); +extern const uint8_t lp_core_lp_rom_bin_end[] asm("_binary_lp_core_test_app_lp_rom_bin_end"); +#endif + static void load_and_start_lp_core_firmware(ulp_lp_core_cfg_t* cfg, const uint8_t* firmware_start, const uint8_t* firmware_end) { TEST_ASSERT(ulp_lp_core_load_binary(firmware_start, @@ -93,3 +102,24 @@ TEST_CASE("LP-Core Shared-mem", "[lp_core]") printf("HP shared memory test passed\n"); } + +#if ESP_ROM_HAS_LP_ROM +TEST_CASE("LP-Core LP-ROM", "[lp_core]") +{ + /* Load ULP firmware and start the coprocessor */ + ulp_lp_core_cfg_t cfg = { + .wakeup_source = ULP_LP_CORE_WAKEUP_SOURCE_HP_CPU, + }; + + TEST_ASSERT(ulp_lp_core_load_binary(lp_core_lp_rom_bin_start, (lp_core_lp_rom_bin_end - lp_core_lp_rom_bin_start)) == ESP_OK); + + TEST_ASSERT(ulp_lp_core_run(&cfg) == ESP_OK); + // Actual test output on UART is checked by pytest, not unity test-case + // We simply wait to allow the lp-core to run once + while (!ulp_lp_rom_test_finished) { + vTaskDelay(100 / portTICK_PERIOD_MS); + } + + printf("LP ROM test passed\n"); +} +#endif diff --git a/components/ulp/test_apps/lp_core/lp_core_hp_uart/pytest_lp_core_hp_uart.py b/components/ulp/test_apps/lp_core/lp_core_hp_uart/pytest_lp_core_hp_uart.py index b21e6e3e358..1da72851654 100644 --- a/components/ulp/test_apps/lp_core/lp_core_hp_uart/pytest_lp_core_hp_uart.py +++ b/components/ulp/test_apps/lp_core/lp_core_hp_uart/pytest_lp_core_hp_uart.py @@ -47,3 +47,12 @@ def test_lp_core_shared_mem(dut: Dut) -> None: dut.expect_exact('ULP shared memory test passed') dut.expect_exact('HP shared memory test passed') + + +@pytest.mark.esp32p4 +@pytest.mark.generic +def test_lp_core_lp_rom(dut: Dut) -> None: + dut.expect_exact('Press ENTER to see the list of tests') + dut.write('"LP-Core LP-ROM"') + dut.expect_exact('ULP: all tests passed') + dut.expect_exact('LP ROM test passed') From 3881d4031dd08af3163edbbef21ea2f9e61a7c31 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Thu, 24 Oct 2024 14:11:05 +0800 Subject: [PATCH 06/70] fix(esp_hw_support): enable all supported slow clock at pmu_init --- components/esp_hw_support/port/esp32c5/pmu_param.c | 13 ++----------- components/esp_hw_support/port/esp32c6/pmu_param.c | 11 ++--------- components/esp_hw_support/port/esp32c61/pmu_param.c | 13 ++----------- components/esp_hw_support/port/esp32h2/pmu_param.c | 11 ++--------- components/esp_hw_support/port/esp32p4/pmu_param.c | 11 ++--------- 5 files changed, 10 insertions(+), 49 deletions(-) diff --git a/components/esp_hw_support/port/esp32c5/pmu_param.c b/components/esp_hw_support/port/esp32c5/pmu_param.c index 6f44a1b4e17..19888d4828a 100644 --- a/components/esp_hw_support/port/esp32c5/pmu_param.c +++ b/components/esp_hw_support/port/esp32c5/pmu_param.c @@ -336,23 +336,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - -#define PMU_LP_DEFAULT_XPD_RC32K (0) - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = PMU_LP_DEFAULT_XPD_RC32K, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 0, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32c6/pmu_param.c b/components/esp_hw_support/port/esp32c6/pmu_param.c index 23acfc34472..6b24a4c4d90 100644 --- a/components/esp_hw_support/port/esp32c6/pmu_param.c +++ b/components/esp_hw_support/port/esp32c6/pmu_param.c @@ -336,21 +336,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = 0, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 1, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32c61/pmu_param.c b/components/esp_hw_support/port/esp32c61/pmu_param.c index 4883b906772..33af14a9f2e 100644 --- a/components/esp_hw_support/port/esp32c61/pmu_param.c +++ b/components/esp_hw_support/port/esp32c61/pmu_param.c @@ -335,23 +335,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - -#define PMU_LP_DEFAULT_XPD_RC32K (0) - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = PMU_LP_DEFAULT_XPD_RC32K, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 0, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32h2/pmu_param.c b/components/esp_hw_support/port/esp32h2/pmu_param.c index 56f679a9145..f9de2ca5aeb 100644 --- a/components/esp_hw_support/port/esp32h2/pmu_param.c +++ b/components/esp_hw_support/port/esp32h2/pmu_param.c @@ -335,21 +335,14 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .mem_dslp = 0, \ .peri_pd_en = 0, \ }, \ .clk_power = { \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = 0, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 1, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ diff --git a/components/esp_hw_support/port/esp32p4/pmu_param.c b/components/esp_hw_support/port/esp32p4/pmu_param.c index c1c8896f37a..5d96c17e15e 100644 --- a/components/esp_hw_support/port/esp32p4/pmu_param.c +++ b/components/esp_hw_support/port/esp32p4/pmu_param.c @@ -241,13 +241,6 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm /** LP system default parameter */ - -#if CONFIG_ESP_SYSTEM_RTC_EXT_XTAL -# define PMU_SLOW_CLK_USE_EXT_XTAL (1) -#else -# define PMU_SLOW_CLK_USE_EXT_XTAL (0) -#endif - #define PMU_LP_ACTIVE_POWER_CONFIG_DEFAULT() { \ .dig_power = { \ .lp_pad_slp_sel = 0, \ @@ -258,8 +251,8 @@ const pmu_hp_system_retention_param_t * pmu_hp_system_retention_param_default(pm }, \ .clk_power = { \ .xpd_lppll = 0, \ - .xpd_xtal32k = PMU_SLOW_CLK_USE_EXT_XTAL, \ - .xpd_rc32k = 0, \ + .xpd_xtal32k = 1, \ + .xpd_rc32k = 1, \ .xpd_fosc = 1, \ .pd_osc = 0 \ } \ From d837cae2b027c38b6dfdf4061b22ce07d0fe8c08 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Tue, 8 Oct 2024 12:28:46 +0200 Subject: [PATCH 07/70] feat(hal/usb): Make USB-DWC HAL&LL configuration independent Previously, we included symbols from soc/usb_dwc_cfg.h and configured the HAL and LL according to it. Now we get the configuration in runtime from USB-DWC registers. Added missing definition for USB FS peripheral on ESP32-P4. --- .../hal/esp32p4/include/hal/usb_dwc_ll.h | 72 +++--- .../hal/esp32s2/include/hal/usb_dwc_ll.h | 68 +++--- .../hal/esp32s3/include/hal/usb_dwc_ll.h | 68 +++--- components/hal/include/hal/usb_dwc_hal.h | 45 ++-- components/hal/usb_dwc_hal.c | 103 +++++---- .../soc/esp32p4/include/soc/usb_dwc_cfg.h | 210 ++++++++++++------ .../soc/esp32p4/include/soc/usb_dwc_struct.h | 8 +- .../soc/esp32s2/include/soc/usb_dwc_struct.h | 4 +- .../soc/esp32s3/include/soc/usb_dwc_struct.h | 4 +- components/usb/hcd_dwc.c | 9 +- .../usb/test_apps/hcd/main/test_hcd_isoc.c | 10 +- 11 files changed, 344 insertions(+), 257 deletions(-) diff --git a/components/hal/esp32p4/include/hal/usb_dwc_ll.h b/components/hal/esp32p4/include/hal/usb_dwc_ll.h index f93db6623c8..fd0685a50dd 100644 --- a/components/hal/esp32p4/include/hal/usb_dwc_ll.h +++ b/components/hal/esp32p4/include/hal/usb_dwc_ll.h @@ -9,7 +9,6 @@ #include #include #include "soc/usb_dwc_struct.h" -#include "soc/usb_dwc_cfg.h" #include "hal/usb_dwc_types.h" #include "hal/misc.h" @@ -20,8 +19,7 @@ extern "C" { /* ----------------------------- Helper Macros ------------------------------ */ // Get USB hardware instance -// TODO: extend this macros when we have support for both FS and HS hardware on P4 -#define USB_DWC_LL_GET_HW(num) (&USB_DWC_HS) +#define USB_DWC_LL_GET_HW(num) (((num) == 1) ? &USB_DWC_FS : &USB_DWC_HS) /* ----------------------------------------------------------------------------- --------------------------------- DWC Constants -------------------------------- @@ -221,11 +219,9 @@ static inline void usb_dwc_ll_gusbcfg_set_timeout_cal(usb_dwc_dev_t *hw, uint8_t static inline void usb_dwc_ll_gusbcfg_set_utmi_phy(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE != 0) hw->gusbcfg_reg.phyif = 1; // 16 bits interface hw->gusbcfg_reg.ulpiutmisel = 0; // UTMI+ hw->gusbcfg_reg.physel = 0; // HS PHY -#endif // (OTG_HSPHY_INTERFACE != 0) } // --------------------------- GRSTCTL Register -------------------------------- @@ -352,24 +348,19 @@ static inline uint32_t usb_dwc_ll_gsnpsid_get_id(usb_dwc_dev_t *hw) // --------------------------- GHWCFGx Register -------------------------------- -/** - * @brief Get the hardware configuration registers of the DWC_OTG controller - * - * The hardware configuration regitsers are read only and indicate the various - * features of the DWC_OTG core. - * - * @param hw Start address of the DWC_OTG registers - * @param[out] ghwcfg1 Hardware configuration registesr 1 - * @param[out] ghwcfg2 Hardware configuration registesr 2 - * @param[out] ghwcfg3 Hardware configuration registesr 3 - * @param[out] ghwcfg4 Hardware configuration registesr 4 - */ -static inline void usb_dwc_ll_ghwcfg_get_hw_config(usb_dwc_dev_t *hw, uint32_t *ghwcfg1, uint32_t *ghwcfg2, uint32_t *ghwcfg3, uint32_t *ghwcfg4) +static inline unsigned usb_dwc_ll_ghwcfg_get_fifo_depth(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg3_reg.dfifodepth; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_hsphy_type(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg2_reg.hsphytype; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_channel_num(usb_dwc_dev_t *hw) { - *ghwcfg1 = hw->ghwcfg1_reg.val; - *ghwcfg2 = hw->ghwcfg2_reg.val; - *ghwcfg3 = hw->ghwcfg3_reg.val; - *ghwcfg4 = hw->ghwcfg4_reg.val; + return hw->ghwcfg2_reg.numhstchnl; } // --------------------------- HPTXFSIZ Register ------------------------------- @@ -434,47 +425,44 @@ static inline void usb_dwc_ll_hcfg_set_fsls_supp_only(usb_dwc_dev_t *hw) hw->hcfg_reg.fslssupp = 1; } -static inline void usb_dwc_ll_hcfg_set_fsls_pclk_sel(usb_dwc_dev_t *hw) -{ - hw->hcfg_reg.fslspclksel = 1; -} - /** - * @brief Sets some default values to HCFG to operate in Host mode with scatter/gather DMA + * @brief Set FSLS PHY clock * + * @attention This function should only be called if FSLS PHY is selected * @param[in] hw Start address of the DWC_OTG registers - * @param[in] speed Speed to initialize the host port at */ -static inline void usb_dwc_ll_hcfg_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +static inline void usb_dwc_ll_hcfg_set_fsls_phy_clock(usb_dwc_dev_t *hw) { - hw->hcfg_reg.descdma = 1; //Enable scatt/gatt -#if (OTG_HSPHY_INTERFACE == 0) /* Indicate to the OTG core what speed the PHY clock is at - Note: It seems like S2/S3 PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; //PHY clock on esp32-sx for FS/LS-only -#endif // (OTG_HSPHY_INTERFACE == 0) - hw->hcfg_reg.perschedena = 0; //Disable perio sched + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; } // ----------------------------- HFIR Register --------------------------------- -static inline void usb_dwc_ll_hfir_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +/** + * @brief Set Frame Interval + * + * @attention This function should only be called if FSLS PHY is selected + * @param[in] hw Start address of the DWC_OTG registers + */ +static inline void usb_dwc_ll_hfir_set_frame_interval(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE == 0) usb_dwc_hfir_reg_t hfir; hfir.val = hw->hfir_reg.val; - hfir.hfirrldctrl = 0; //Disable dynamic loading + hfir.hfirrldctrl = 0; // Disable dynamic loading /* Set frame interval to be equal to 1ms - Note: It seems like our PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; //esp32-sx targets only support FS or LS + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; hw->hfir_reg.val = hfir.val; -#endif // (OTG_HSPHY_INTERFACE == 0) } // ----------------------------- HFNUM Register -------------------------------- diff --git a/components/hal/esp32s2/include/hal/usb_dwc_ll.h b/components/hal/esp32s2/include/hal/usb_dwc_ll.h index 954a54bf803..7426be2efa7 100644 --- a/components/hal/esp32s2/include/hal/usb_dwc_ll.h +++ b/components/hal/esp32s2/include/hal/usb_dwc_ll.h @@ -220,11 +220,9 @@ static inline void usb_dwc_ll_gusbcfg_set_timeout_cal(usb_dwc_dev_t *hw, uint8_t static inline void usb_dwc_ll_gusbcfg_set_utmi_phy(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE != 0) hw->gusbcfg_reg.phyif = 1; // 16 bits interface hw->gusbcfg_reg.ulpiutmisel = 0; // UTMI+ hw->gusbcfg_reg.physel = 0; // HS PHY -#endif // (OTG_HSPHY_INTERFACE != 0) } // --------------------------- GRSTCTL Register -------------------------------- @@ -351,24 +349,19 @@ static inline uint32_t usb_dwc_ll_gsnpsid_get_id(usb_dwc_dev_t *hw) // --------------------------- GHWCFGx Register -------------------------------- -/** - * @brief Get the hardware configuration registers of the DWC_OTG controller - * - * The hardware configuration regitsers are read only and indicate the various - * features of the DWC_OTG core. - * - * @param hw Start address of the DWC_OTG registers - * @param[out] ghwcfg1 Hardware configuration registesr 1 - * @param[out] ghwcfg2 Hardware configuration registesr 2 - * @param[out] ghwcfg3 Hardware configuration registesr 3 - * @param[out] ghwcfg4 Hardware configuration registesr 4 - */ -static inline void usb_dwc_ll_ghwcfg_get_hw_config(usb_dwc_dev_t *hw, uint32_t *ghwcfg1, uint32_t *ghwcfg2, uint32_t *ghwcfg3, uint32_t *ghwcfg4) +static inline unsigned usb_dwc_ll_ghwcfg_get_fifo_depth(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg3_reg.dfifodepth; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_hsphy_type(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg2_reg.hsphytype; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_channel_num(usb_dwc_dev_t *hw) { - *ghwcfg1 = hw->ghwcfg1_reg.val; - *ghwcfg2 = hw->ghwcfg2_reg.val; - *ghwcfg3 = hw->ghwcfg3_reg.val; - *ghwcfg4 = hw->ghwcfg4_reg.val; + return hw->ghwcfg2_reg.numhstchnl; } // --------------------------- HPTXFSIZ Register ------------------------------- @@ -433,47 +426,44 @@ static inline void usb_dwc_ll_hcfg_set_fsls_supp_only(usb_dwc_dev_t *hw) hw->hcfg_reg.fslssupp = 1; } -static inline void usb_dwc_ll_hcfg_set_fsls_pclk_sel(usb_dwc_dev_t *hw) -{ - hw->hcfg_reg.fslspclksel = 1; -} - /** - * @brief Sets some default values to HCFG to operate in Host mode with scatter/gather DMA + * @brief Set FSLS PHY clock * + * @attention This function should only be called if FSLS PHY is selected * @param[in] hw Start address of the DWC_OTG registers - * @param[in] speed Speed to initialize the host port at */ -static inline void usb_dwc_ll_hcfg_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +static inline void usb_dwc_ll_hcfg_set_fsls_phy_clock(usb_dwc_dev_t *hw) { - hw->hcfg_reg.descdma = 1; //Enable scatt/gatt -#if (OTG_HSPHY_INTERFACE == 0) /* Indicate to the OTG core what speed the PHY clock is at - Note: It seems like S2/S3 PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; //PHY clock on esp32-sx for FS/LS-only -#endif // (OTG_HSPHY_INTERFACE == 0) - hw->hcfg_reg.perschedena = 0; //Disable perio sched + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; } // ----------------------------- HFIR Register --------------------------------- -static inline void usb_dwc_ll_hfir_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +/** + * @brief Set Frame Interval + * + * @attention This function should only be called if FSLS PHY is selected + * @param[in] hw Start address of the DWC_OTG registers + */ +static inline void usb_dwc_ll_hfir_set_frame_interval(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE == 0) usb_dwc_hfir_reg_t hfir; hfir.val = hw->hfir_reg.val; - hfir.hfirrldctrl = 0; //Disable dynamic loading + hfir.hfirrldctrl = 0; // Disable dynamic loading /* Set frame interval to be equal to 1ms - Note: It seems like our PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; //esp32-sx targets only support FS or LS + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; hw->hfir_reg.val = hfir.val; -#endif // (OTG_HSPHY_INTERFACE == 0) } // ----------------------------- HFNUM Register -------------------------------- diff --git a/components/hal/esp32s3/include/hal/usb_dwc_ll.h b/components/hal/esp32s3/include/hal/usb_dwc_ll.h index 954a54bf803..7426be2efa7 100644 --- a/components/hal/esp32s3/include/hal/usb_dwc_ll.h +++ b/components/hal/esp32s3/include/hal/usb_dwc_ll.h @@ -220,11 +220,9 @@ static inline void usb_dwc_ll_gusbcfg_set_timeout_cal(usb_dwc_dev_t *hw, uint8_t static inline void usb_dwc_ll_gusbcfg_set_utmi_phy(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE != 0) hw->gusbcfg_reg.phyif = 1; // 16 bits interface hw->gusbcfg_reg.ulpiutmisel = 0; // UTMI+ hw->gusbcfg_reg.physel = 0; // HS PHY -#endif // (OTG_HSPHY_INTERFACE != 0) } // --------------------------- GRSTCTL Register -------------------------------- @@ -351,24 +349,19 @@ static inline uint32_t usb_dwc_ll_gsnpsid_get_id(usb_dwc_dev_t *hw) // --------------------------- GHWCFGx Register -------------------------------- -/** - * @brief Get the hardware configuration registers of the DWC_OTG controller - * - * The hardware configuration regitsers are read only and indicate the various - * features of the DWC_OTG core. - * - * @param hw Start address of the DWC_OTG registers - * @param[out] ghwcfg1 Hardware configuration registesr 1 - * @param[out] ghwcfg2 Hardware configuration registesr 2 - * @param[out] ghwcfg3 Hardware configuration registesr 3 - * @param[out] ghwcfg4 Hardware configuration registesr 4 - */ -static inline void usb_dwc_ll_ghwcfg_get_hw_config(usb_dwc_dev_t *hw, uint32_t *ghwcfg1, uint32_t *ghwcfg2, uint32_t *ghwcfg3, uint32_t *ghwcfg4) +static inline unsigned usb_dwc_ll_ghwcfg_get_fifo_depth(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg3_reg.dfifodepth; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_hsphy_type(usb_dwc_dev_t *hw) +{ + return hw->ghwcfg2_reg.hsphytype; +} + +static inline unsigned usb_dwc_ll_ghwcfg_get_channel_num(usb_dwc_dev_t *hw) { - *ghwcfg1 = hw->ghwcfg1_reg.val; - *ghwcfg2 = hw->ghwcfg2_reg.val; - *ghwcfg3 = hw->ghwcfg3_reg.val; - *ghwcfg4 = hw->ghwcfg4_reg.val; + return hw->ghwcfg2_reg.numhstchnl; } // --------------------------- HPTXFSIZ Register ------------------------------- @@ -433,47 +426,44 @@ static inline void usb_dwc_ll_hcfg_set_fsls_supp_only(usb_dwc_dev_t *hw) hw->hcfg_reg.fslssupp = 1; } -static inline void usb_dwc_ll_hcfg_set_fsls_pclk_sel(usb_dwc_dev_t *hw) -{ - hw->hcfg_reg.fslspclksel = 1; -} - /** - * @brief Sets some default values to HCFG to operate in Host mode with scatter/gather DMA + * @brief Set FSLS PHY clock * + * @attention This function should only be called if FSLS PHY is selected * @param[in] hw Start address of the DWC_OTG registers - * @param[in] speed Speed to initialize the host port at */ -static inline void usb_dwc_ll_hcfg_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +static inline void usb_dwc_ll_hcfg_set_fsls_phy_clock(usb_dwc_dev_t *hw) { - hw->hcfg_reg.descdma = 1; //Enable scatt/gatt -#if (OTG_HSPHY_INTERFACE == 0) /* Indicate to the OTG core what speed the PHY clock is at - Note: It seems like S2/S3 PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; //PHY clock on esp32-sx for FS/LS-only -#endif // (OTG_HSPHY_INTERFACE == 0) - hw->hcfg_reg.perschedena = 0; //Disable perio sched + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hw->hcfg_reg.fslspclksel = (speed == USB_DWC_SPEED_FULL) ? 1 : 2; } // ----------------------------- HFIR Register --------------------------------- -static inline void usb_dwc_ll_hfir_set_defaults(usb_dwc_dev_t *hw, usb_dwc_speed_t speed) +/** + * @brief Set Frame Interval + * + * @attention This function should only be called if FSLS PHY is selected + * @param[in] hw Start address of the DWC_OTG registers + */ +static inline void usb_dwc_ll_hfir_set_frame_interval(usb_dwc_dev_t *hw) { -#if (OTG_HSPHY_INTERFACE == 0) usb_dwc_hfir_reg_t hfir; hfir.val = hw->hfir_reg.val; - hfir.hfirrldctrl = 0; //Disable dynamic loading + hfir.hfirrldctrl = 0; // Disable dynamic loading /* Set frame interval to be equal to 1ms - Note: It seems like our PHY has an implicit 8 divider applied when in LS mode, + Note: FSLS PHY has an implicit 8 divider applied when in LS mode, so the values of FSLSPclkSel and FrInt have to be adjusted accordingly. */ - hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; //esp32-sx targets only support FS or LS + usb_dwc_speed_t speed = (usb_dwc_speed_t)hw->hprt_reg.prtspd; + hfir.frint = (speed == USB_DWC_SPEED_FULL) ? 48000 : 6000; hw->hfir_reg.val = hfir.val; -#endif // (OTG_HSPHY_INTERFACE == 0) } // ----------------------------- HFNUM Register -------------------------------- diff --git a/components/hal/include/hal/usb_dwc_hal.h b/components/hal/include/hal/usb_dwc_hal.h index 33ac57be75e..d4c880571f7 100644 --- a/components/hal/include/hal/usb_dwc_hal.h +++ b/components/hal/include/hal/usb_dwc_hal.h @@ -171,13 +171,23 @@ typedef struct { * @brief HAL context structure */ typedef struct { - //Context - usb_dwc_dev_t *dev; /**< Pointer to base address of DWC_OTG registers */ - //Host Port related - uint32_t *periodic_frame_list; /**< Pointer to scheduling frame list */ - usb_hal_frame_list_len_t frame_list_len; /**< Length of the periodic scheduling frame list */ - //FIFO related - usb_dwc_hal_fifo_config_t fifo_config; /**< FIFO sizes configuration */ + // HW context + usb_dwc_dev_t *dev; /**< Pointer to base address of DWC_OTG registers */ + + // Host Port related + uint32_t *periodic_frame_list; /**< Pointer to scheduling frame list */ + usb_hal_frame_list_len_t frame_list_len; /**< Length of the periodic scheduling frame list */ + + // FIFO related + usb_dwc_hal_fifo_config_t fifo_config; /**< FIFO sizes configuration */ + + // Configuration of the USB-DWC core. Read from read-only HW registers + struct { + unsigned chan_num_total; /**< Total number of channels for this configuration */ + unsigned hsphy_type; /**< HS PHY type of this configuration */ + unsigned fifo_size; /**< Total FIFO size [in lines] in this configuration */ + } constant_config; + union { struct { uint32_t dbnc_lock_enabled: 1; /**< Debounce lock enabled */ @@ -188,11 +198,12 @@ typedef struct { }; uint32_t val; } flags; - //Channel related + + // Channel related struct { - int num_allocd; /**< Number of channels currently allocated */ - uint32_t chan_pend_intrs_msk; /**< Bit mask of channels with pending interrupts */ - usb_dwc_hal_chan_t *hdls[OTG_NUM_HOST_CHAN]; /**< Handles of each channel. Set to NULL if channel has not been allocated */ + int num_allocated; /**< Number of channels currently allocated */ + uint32_t chan_pend_intrs_msk; /**< Bit mask of channels with pending interrupts */ + usb_dwc_hal_chan_t **hdls; /**< Handles of each channel. Set to NULL if channel has not been allocated */ } channels; } usb_dwc_hal_context_t; @@ -208,16 +219,20 @@ typedef struct { * - Interrupt allocated but DISABLED (in case of an unknown interrupt state) * Exit: * - Checks to see if DWC_OTG is alive, and if HW version/config is correct - * - HAl context initialized + * - HAL context initialized + * - Read and save relevant USB-DWC configuration parameters * - Sets default values to some global and OTG registers (GAHBCFG and GUSBCFG) * - Umask global interrupt signal * - Put DWC_OTG into host mode. Require 25ms delay before this takes effect. * - State -> USB_DWC_HAL_PORT_STATE_OTG * - Interrupts cleared. Users can now enable their ISR * - * @param[inout] hal Context of the HAL layer + * @attention The user must allocate memory for channel handlers with + * `hal->channels.hdls = malloc(hal->constant_config.chan_num_total * sizeof(usb_dwc_hal_chan_t*))` + * @param[inout] hal Context of the HAL layer + * @param[in] port_id USB port ID */ -void usb_dwc_hal_init(usb_dwc_hal_context_t *hal); +void usb_dwc_hal_init(usb_dwc_hal_context_t *hal, int port_id); /** * @brief Deinitialize the HAL context @@ -241,7 +256,7 @@ void usb_dwc_hal_deinit(usb_dwc_hal_context_t *hal); * * @note This has nothing to do with a USB bus reset. It simply resets the peripheral * - * @param hal Context of the HAL layer + * @param[in] hal Context of the HAL layer */ void usb_dwc_hal_core_soft_reset(usb_dwc_hal_context_t *hal); diff --git a/components/hal/usb_dwc_hal.c b/components/hal/usb_dwc_hal.c index b6f3201b71a..3f437626375 100644 --- a/components/hal/usb_dwc_hal.c +++ b/components/hal/usb_dwc_hal.c @@ -10,7 +10,6 @@ #include // For abort() #include "sdkconfig.h" #include "soc/chip_revision.h" -#include "soc/usb_dwc_cfg.h" #include "soc/usb_dwc_periph.h" #include "hal/usb_dwc_hal.h" #include "hal/usb_dwc_ll.h" @@ -112,10 +111,8 @@ static void set_defaults(usb_dwc_hal_context_t *hal) usb_dwc_ll_gusbcfg_dis_hnp_cap(hal->dev); //Disable HNP usb_dwc_ll_gusbcfg_dis_srp_cap(hal->dev); //Disable SRP - // Check if this USB-DWC supports HS PHY, if yes, use it - uint32_t ghwcfg[4]; - usb_dwc_ll_ghwcfg_get_hw_config(hal->dev, &ghwcfg[0], &ghwcfg[1], &ghwcfg[2], &ghwcfg[3]); - if (((usb_dwc_ghwcfg2_reg_t)ghwcfg[1]).hsphytype != 0) { + // If this USB-DWC supports HS PHY, use it + if (hal->constant_config.hsphy_type != 0) { usb_dwc_ll_gusbcfg_set_timeout_cal(hal->dev, 5); // 5 PHY clocks for our HS PHY usb_dwc_ll_gusbcfg_set_utmi_phy(hal->dev); } @@ -128,16 +125,29 @@ static void set_defaults(usb_dwc_hal_context_t *hal) usb_dwc_ll_gusbcfg_force_host_mode(hal->dev); } -void usb_dwc_hal_init(usb_dwc_hal_context_t *hal) +void usb_dwc_hal_init(usb_dwc_hal_context_t *hal, int port_id) { - //Check if a peripheral is alive by reading the core ID registers - usb_dwc_dev_t *dev = USB_DWC_LL_GET_HW(0); + // Check if a peripheral is alive by reading the core ID registers + HAL_ASSERT(port_id < SOC_USB_OTG_PERIPH_NUM); + usb_dwc_dev_t *dev = USB_DWC_LL_GET_HW(port_id); uint32_t core_id = usb_dwc_ll_gsnpsid_get_id(dev); HAL_ASSERT(core_id == CORE_REG_GSNPSID); (void) core_id; //Suppress unused variable warning if asserts are disabled - //Initialize HAL context + + // Initialize HAL context memset(hal, 0, sizeof(usb_dwc_hal_context_t)); hal->dev = dev; + + // Save constant configuration of this USB-DWC instance + /* + * EPINFO_CTL is located at the end of FIFO, its size is fixed in HW. + * The reserved size is always the worst-case, which is device mode that requires 4 locations per EP direction (including EP0). + * Here we just read the FIFO size from HW register, to avoid any ambivalence + */ + hal->constant_config.fifo_size = usb_dwc_ll_ghwcfg_get_fifo_depth(dev); + hal->constant_config.hsphy_type = usb_dwc_ll_ghwcfg_get_hsphy_type(dev); + hal->constant_config.chan_num_total = usb_dwc_ll_ghwcfg_get_channel_num(dev); + set_defaults(hal); } @@ -154,32 +164,31 @@ void usb_dwc_hal_core_soft_reset(usb_dwc_hal_context_t *hal) { usb_dwc_ll_grstctl_core_soft_reset(hal->dev); while (usb_dwc_ll_grstctl_is_core_soft_reset_in_progress(hal->dev)) { - ; //Wait until core reset is done + ; // Wait until core reset is done } while (!usb_dwc_ll_grstctl_is_ahb_idle(hal->dev)) { - ; //Wait until AHB Master bus is idle before doing any other operations + ; // Wait until AHB Master bus is idle before doing any other operations } - //Set the default bits + + // Set the default bits in USB-DWC registers set_defaults(hal); - //Clear all the flags and channels + + // Clear all the flags and channels hal->periodic_frame_list = NULL; hal->flags.val = 0; - hal->channels.num_allocd = 0; + hal->channels.num_allocated = 0; hal->channels.chan_pend_intrs_msk = 0; - memset(hal->channels.hdls, 0, sizeof(usb_dwc_hal_chan_t *) * OTG_NUM_HOST_CHAN); + if (hal->channels.hdls) { + for (int i = 0; i < hal->constant_config.chan_num_total; i++) { + hal->channels.hdls[i] = NULL; + } + } } void usb_dwc_hal_set_fifo_bias(usb_dwc_hal_context_t *hal, const usb_hal_fifo_bias_t fifo_bias) { - /* - * EPINFO_CTL is located at the end of FIFO, its size is fixed in HW. - * The reserved size is always the worst-case, which is device mode that requires 4 locations per EP direction (including EP0). - * Here we just read the FIFO size from HW register, to avoid any ambivalence - */ - uint32_t ghwcfg1, ghwcfg2, ghwcfg3, ghwcfg4; - usb_dwc_ll_ghwcfg_get_hw_config(hal->dev, &ghwcfg1, &ghwcfg2, &ghwcfg3, &ghwcfg4); - const uint16_t fifo_size_lines = ((usb_dwc_ghwcfg3_reg_t)ghwcfg3).dfifodepth; - + HAL_ASSERT(hal->channels.hdls); + const uint16_t fifo_size_lines = hal->constant_config.fifo_size; /* * Recommended FIFO sizes (see 2.1.2.4 for programming guide) * @@ -190,23 +199,28 @@ void usb_dwc_hal_set_fifo_bias(usb_dwc_hal_context_t *hal, const usb_hal_fifo_bi * Recommended sizes fit 2 packets of each type. For S2 and S3 we can't fit even one MPS ISOC packet (1023 FS and 1024 HS). * So the calculations below are compromises between the available FIFO size and optimal performance. */ + + // Information for maintainers: this calculation is here for backward compatibility + // It should be removed when we allow HAL users to configure the FIFO sizes IDF-9042 + const int otg_dfifo_depth = hal->constant_config.hsphy_type ? 1024 : 256; + usb_dwc_hal_fifo_config_t fifo_config; switch (fifo_bias) { // Define minimum viable (fits at least 1 MPS) FIFO sizes for non-biased FIFO types // Allocate the remaining size to the biased FIFO type case USB_HAL_FIFO_BIAS_DEFAULT: - fifo_config.nptx_fifo_lines = OTG_DFIFO_DEPTH / 4; - fifo_config.ptx_fifo_lines = OTG_DFIFO_DEPTH / 8; + fifo_config.nptx_fifo_lines = otg_dfifo_depth / 4; + fifo_config.ptx_fifo_lines = otg_dfifo_depth / 8; fifo_config.rx_fifo_lines = fifo_size_lines - fifo_config.ptx_fifo_lines - fifo_config.nptx_fifo_lines; break; case USB_HAL_FIFO_BIAS_RX: - fifo_config.nptx_fifo_lines = OTG_DFIFO_DEPTH / 16; - fifo_config.ptx_fifo_lines = OTG_DFIFO_DEPTH / 8; + fifo_config.nptx_fifo_lines = otg_dfifo_depth / 16; + fifo_config.ptx_fifo_lines = otg_dfifo_depth / 8; fifo_config.rx_fifo_lines = fifo_size_lines - fifo_config.ptx_fifo_lines - fifo_config.nptx_fifo_lines; break; case USB_HAL_FIFO_BIAS_PTX: - fifo_config.rx_fifo_lines = OTG_DFIFO_DEPTH / 8 + 2; // 2 extra lines are allocated for status information. See USB-OTG Programming Guide, chapter 2.1.2.1 - fifo_config.nptx_fifo_lines = OTG_DFIFO_DEPTH / 16; + fifo_config.rx_fifo_lines = otg_dfifo_depth / 8 + 2; // 2 extra lines are allocated for status information. See USB-OTG Programming Guide, chapter 2.1.2.1 + fifo_config.nptx_fifo_lines = otg_dfifo_depth / 16; fifo_config.ptx_fifo_lines = fifo_size_lines - fifo_config.nptx_fifo_lines - fifo_config.rx_fifo_lines; break; default: @@ -215,7 +229,7 @@ void usb_dwc_hal_set_fifo_bias(usb_dwc_hal_context_t *hal, const usb_hal_fifo_bi HAL_ASSERT((fifo_config.rx_fifo_lines + fifo_config.nptx_fifo_lines + fifo_config.ptx_fifo_lines) <= fifo_size_lines); //Check that none of the channels are active - for (int i = 0; i < OTG_NUM_HOST_CHAN; i++) { + for (int i = 0; i < hal->constant_config.chan_num_total; i++) { if (hal->channels.hdls[i] != NULL) { HAL_ASSERT(!hal->channels.hdls[i]->flags.active); } @@ -254,11 +268,15 @@ static inline void debounce_lock_enable(usb_dwc_hal_context_t *hal) void usb_dwc_hal_port_enable(usb_dwc_hal_context_t *hal) { - usb_dwc_speed_t speed = usb_dwc_ll_hprt_get_speed(hal->dev); - //Host Configuration - usb_dwc_ll_hcfg_set_defaults(hal->dev, speed); - //Configure HFIR - usb_dwc_ll_hfir_set_defaults(hal->dev, speed); + // Host Configuration + usb_dwc_ll_hcfg_en_scatt_gatt_dma(hal->dev); // Enable Scatther-Gather DMA mode + usb_dwc_ll_hcfg_dis_perio_sched(hal->dev); // Disable Periodic Scheduler (for now) + + // Configure PHY clock: Only for USB-DWC with FSLS PHY + if (hal->constant_config.hsphy_type == 0) { + usb_dwc_ll_hcfg_set_fsls_phy_clock(hal->dev); + usb_dwc_ll_hfir_set_frame_interval(hal->dev); + } } // ----------------------------------------------------- Channel ------------------------------------------------------- @@ -267,17 +285,18 @@ void usb_dwc_hal_port_enable(usb_dwc_hal_context_t *hal) bool usb_dwc_hal_chan_alloc(usb_dwc_hal_context_t *hal, usb_dwc_hal_chan_t *chan_obj, void *chan_ctx) { + HAL_ASSERT(hal->channels.hdls); HAL_ASSERT(hal->flags.fifo_sizes_set); //FIFO sizes should be set before attempting to allocate a channel //Attempt to allocate channel - if (hal->channels.num_allocd == OTG_NUM_HOST_CHAN) { + if (hal->channels.num_allocated == hal->constant_config.chan_num_total) { return false; //Out of free channels } int chan_idx = -1; - for (int i = 0; i < OTG_NUM_HOST_CHAN; i++) { + for (int i = 0; i < hal->constant_config.chan_num_total; i++) { if (hal->channels.hdls[i] == NULL) { hal->channels.hdls[i] = chan_obj; chan_idx = i; - hal->channels.num_allocd++; + hal->channels.num_allocated++; break; } } @@ -299,6 +318,7 @@ bool usb_dwc_hal_chan_alloc(usb_dwc_hal_context_t *hal, usb_dwc_hal_chan_t *chan void usb_dwc_hal_chan_free(usb_dwc_hal_context_t *hal, usb_dwc_hal_chan_t *chan_obj) { + HAL_ASSERT(hal->channels.hdls); if (chan_obj->type == USB_DWC_XFER_TYPE_INTR || chan_obj->type == USB_DWC_XFER_TYPE_ISOCHRONOUS) { //Unschedule this channel for (int i = 0; i < hal->frame_list_len; i++) { @@ -311,8 +331,8 @@ void usb_dwc_hal_chan_free(usb_dwc_hal_context_t *hal, usb_dwc_hal_chan_t *chan_ usb_dwc_ll_haintmsk_dis_chan_intr(hal->dev, 1 << chan_obj->flags.chan_idx); //Deallocate channel hal->channels.hdls[chan_obj->flags.chan_idx] = NULL; - hal->channels.num_allocd--; - HAL_ASSERT(hal->channels.num_allocd >= 0); + hal->channels.num_allocated--; + HAL_ASSERT(hal->channels.num_allocated >= 0); } // ---------------- Channel Configuration ------------------ @@ -464,6 +484,7 @@ usb_dwc_hal_port_event_t usb_dwc_hal_decode_intr(usb_dwc_hal_context_t *hal) usb_dwc_hal_chan_t *usb_dwc_hal_get_chan_pending_intr(usb_dwc_hal_context_t *hal) { + HAL_ASSERT(hal->channels.hdls); int chan_num = __builtin_ffs(hal->channels.chan_pend_intrs_msk); if (chan_num) { hal->channels.chan_pend_intrs_msk &= ~(1 << (chan_num - 1)); //Clear the pending bit for that channel diff --git a/components/soc/esp32p4/include/soc/usb_dwc_cfg.h b/components/soc/esp32p4/include/soc/usb_dwc_cfg.h index 3b5b887568f..816cff4285c 100644 --- a/components/soc/esp32p4/include/soc/usb_dwc_cfg.h +++ b/components/soc/esp32p4/include/soc/usb_dwc_cfg.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -11,94 +11,170 @@ extern "C" { #endif /* +HS Instance: Configuration Set ID: 11 */ /* 3.1 Basic Config Parameters */ -#define OTG_MODE 0 -#define OTG_ARCHITECTURE 2 -#define OTG_SINGLE_POINT 1 -#define OTG_ENABLE_LPM 0 -#define OTG_EN_DED_TX_FIFO 1 -#define OTG_EN_DESC_DMA 1 -#define OTG_MULTI_PROC_INTRPT 1 +#define OTG20_MODE 0 +#define OTG20_ARCHITECTURE 2 +#define OTG20_SINGLE_POINT 1 +#define OTG20_ENABLE_LPM 0 +#define OTG20_EN_DED_TX_FIFO 1 +#define OTG20_EN_DESC_DMA 1 +#define OTG20_MULTI_PROC_INTRPT 1 /* 3.2 USB Physical Layer Interface Parameters */ -#define OTG_HSPHY_INTERFACE 3 -#define OTG_HSPHY_DWIDTH 2 -#define OTG_FSPHY_INTERFACE 2 -#define OTG_ENABLE_IC_USB 0 -#define OTG_ENABLE_HSIC 0 -#define OTG_I2C_INTERFACE 0 -#define OTG_ULPI_CARKIT 1 -#define OTG_ADP_SUPPORT 1 -#define OTG_BC_SUPPORT 0 -#define OTG_VENDOR_CTL_INTERFACE 1 +#define OTG20_HSPHY_INTERFACE 3 +#define OTG20_HSPHY_DWIDTH 2 +#define OTG20_FSPHY_INTERFACE 2 +#define OTG20_ENABLE_IC_USB 0 +#define OTG20_ENABLE_HSIC 0 +#define OTG20_I2C_INTERFACE 0 +#define OTG20_ULPI_CARKIT 1 +#define OTG20_ADP_SUPPORT 1 +#define OTG20_BC_SUPPORT 0 +#define OTG20_VENDOR_CTL_INTERFACE 1 /* 3.3 Device Endpoint Configuration Parameters */ -#define OTG_NUM_EPS 15 -#define OTG_NUM_IN_EPS 8 -#define OTG_NUM_CRL_EPS 1 +#define OTG20_NUM_EPS 15 +#define OTG20_NUM_IN_EPS 8 +#define OTG20_NUM_CRL_EPS 1 /* 3.4 Host Endpoint Configuration Parameters */ -#define OTG_NUM_HOST_CHAN 16 -#define OTG_EN_PERIO_HOST 1 +#define OTG20_NUM_HOST_CHAN 16 +#define OTG20_EN_PERIO_HOST 1 /* 3.5 Endpoint Channel FIFO Configuration Parameters */ -#define OTG_DFIFO_DEPTH 1024 -#define OTG_DFIFO_DYNAMIC 1 -#define OTG_RX_DFIFO_DEPTH 1024 -#define OTG_TX_HNPERIO_DFIFO_DEPTH 1024 -#define OTG_TX_HPERIO_DFIFO_DEPTH 1024 -#define OTG_NPERIO_TX_QUEUE_DEPTH 4 -#define OTG_PERIO_TX_QUEUE_DEPTH 4 +#define OTG20_DFIFO_DEPTH 1024 +#define OTG20_DFIFO_DYNAMIC 1 +#define OTG20_RX_DFIFO_DEPTH 1024 +#define OTG20_TX_HNPERIO_DFIFO_DEPTH 1024 +#define OTG20_TX_HPERIO_DFIFO_DEPTH 1024 +#define OTG20_NPERIO_TX_QUEUE_DEPTH 4 +#define OTG20_PERIO_TX_QUEUE_DEPTH 4 /* 3.6 Additional Configuration Options Parameters */ -#define OTG_TRANS_COUNT_WIDTH 17 -#define OTG_PACKET_COUNT_WIDTH 8 -#define OTG_RM_OPT_FEATURES 1 -#define OTG_EN_PWROPT 1 -#define OTG_SYNC_RESET_TYPE 0 -#define OTG_EN_IDDIG_FILTER 1 -#define OTG_EN_VBUSVALID_FILTER 1 -#define OTG_EN_A_VALID_FILTER 1 -#define OTG_EN_B_VALID_FILTER 1 -#define OTG_EN_SESSIONEND_FILTER 1 -#define OTG_EXCP_CNTL_XFER_FLOW 1 -#define OTG_PWR_CLAMP 0 -#define OTG_PWR_SWITCH_POLARITY 0 +#define OTG20_TRANS_COUNT_WIDTH 17 +#define OTG20_PACKET_COUNT_WIDTH 8 +#define OTG20_RM_OPT_FEATURES 1 +#define OTG20_EN_PWROPT 1 +#define OTG20_SYNC_RESET_TYPE 0 +#define OTG20_EN_IDDIG_FILTER 1 +#define OTG20_EN_VBUSVALID_FILTER 1 +#define OTG20_EN_A_VALID_FILTER 1 +#define OTG20_EN_B_VALID_FILTER 1 +#define OTG20_EN_SESSIONEND_FILTER 1 +#define OTG20_EXCP_CNTL_XFER_FLOW 1 +#define OTG20_PWR_CLAMP 0 +#define OTG20_PWR_SWITCH_POLARITY 0 /* 3.7 Endpoint Direction Parameters */ -#define OTG_EP_DIR_1 0 -#define OTG_EP_DIR_2 0 -#define OTG_EP_DIR_3 0 -#define OTG_EP_DIR_4 0 -#define OTG_EP_DIR_5 0 -#define OTG_EP_DIR_6 0 -#define OTG_EP_DIR_7 0 -#define OTG_EP_DIR_8 0 -#define OTG_EP_DIR_9 0 -#define OTG_EP_DIR_10 0 -#define OTG_EP_DIR_11 0 -#define OTG_EP_DIR_12 0 -#define OTG_EP_DIR_13 0 -#define OTG_EP_DIR_14 0 -#define OTG_EP_DIR_15 0 +#define OTG20_EP_DIR_1 0 +#define OTG20_EP_DIR_2 0 +#define OTG20_EP_DIR_3 0 +#define OTG20_EP_DIR_4 0 +#define OTG20_EP_DIR_5 0 +#define OTG20_EP_DIR_6 0 +#define OTG20_EP_DIR_7 0 +#define OTG20_EP_DIR_8 0 +#define OTG20_EP_DIR_9 0 +#define OTG20_EP_DIR_10 0 +#define OTG20_EP_DIR_11 0 +#define OTG20_EP_DIR_12 0 +#define OTG20_EP_DIR_13 0 +#define OTG20_EP_DIR_14 0 +#define OTG20_EP_DIR_15 0 /* 3.8 Device Periodic FIFO Depth Parameters */ /* 3.9 Device IN Endpoint FIFO Depth Parameters */ -#define OTG_TX_DINEP_DFIFO_DEPTH_0 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_1 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_2 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_3 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_4 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_5 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_6 512 -#define OTG_TX_DINEP_DFIFO_DEPTH_7 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_0 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_1 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_2 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_3 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_4 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_5 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_6 512 +#define OTG20_TX_DINEP_DFIFO_DEPTH_7 512 /* 3.10 UTMI-To-UTMI Bridge Component Parameters */ -#define DWC_U2UB_EN 0 +#define OTG20_U2UB_EN 0 + +/* +FS Instance: +Configuration Set ID: 1 +*/ + +/* 3.1 Basic Config Parameters */ +#define OTG11_MODE 0 +#define OTG11_ARCHITECTURE 2 +#define OTG11_SINGLE_POINT 1 +#define OTG11_ENABLE_LPM 0 +#define OTG11_EN_DED_TX_FIFO 1 +#define OTG11_EN_DESC_DMA 1 +#define OTG11_MULTI_PROC_INTRPT 0 + +/* 3.2 USB Physical Layer Interface Parameters */ +#define OTG11_HSPHY_INTERFACE 0 +#define OTG11_FSPHY_INTERFACE 1 +#define OTG11_ENABLE_IC_USB 0 +#define OTG11_I2C_INTERFACE 0 +#define OTG11_ADP_SUPPORT 0 +#define OTG11_BC_SUPPORT 0 + +/* 3.3 Device Endpoint Configuration Parameters */ +#define OTG11_NUM_EPS 6 +#define OTG11_NUM_IN_EPS 5 +#define OTG11_NUM_CRL_EPS 0 + +/* 3.4 Host Endpoint Configuration Parameters */ +#define OTG11_NUM_HOST_CHAN 8 +#define OTG11_EN_PERIO_HOST 1 + +/* 3.5 Endpoint Channel FIFO Configuration Parameters */ +#define OTG11_DFIFO_DEPTH 256 +#define OTG11_DFIFO_DYNAMIC 1 +#define OTG11_RX_DFIFO_DEPTH 256 +#define OTG11_TX_HNPERIO_DFIFO_DEPTH 256 +#define OTG11_TX_NPERIO_DFIFO_DEPTH 256 +#define OTG11_TX_HPERIO_DFIFO_DEPTH 256 +#define OTG11_NPERIO_TX_QUEUE_DEPTH 4 +#define OTG11_PERIO_TX_QUEUE_DEPTH 8 + +/* 3.6 Additional Configuration Options Parameters */ +#define OTG11_TRANS_COUNT_WIDTH 16 +#define OTG11_PACKET_COUNT_WIDTH 7 +#define OTG11_RM_OPT_FEATURES 1 +#define OTG11_EN_PWROPT 1 +#define OTG11_SYNC_RESET_TYPE 0 +#define OTG11_EN_IDDIG_FILTER 1 +#define OTG11_EN_VBUSVALID_FILTER 1 +#define OTG11_EN_A_VALID_FILTER 1 +#define OTG11_EN_B_VALID_FILTER 1 +#define OTG11_EN_SESSIONEND_FILTER 1 +#define OTG11_EXCP_CNTL_XFER_FLOW 1 +#define OTG11_PWR_CLAMP 0 +#define OTG11_PWR_SWITCH_POLARITY 0 + +/* 3.7 Endpoint Direction Parameters */ +#define OTG11_EP_DIR_1 0 +#define OTG11_EP_DIR_2 0 +#define OTG11_EP_DIR_3 0 +#define OTG11_EP_DIR_4 0 +#define OTG11_EP_DIR_5 0 +#define OTG11_EP_DIR_6 0 + +/* 3.8 Device Periodic FIFO Depth Parameters */ + +/* 3.9 Device IN Endpoint FIFO Depth Parameters */ +#define OTG11_TX_DINEP_DFIFO_DEPTH_1 256 +#define OTG11_TX_DINEP_DFIFO_DEPTH_2 256 +#define OTG11_TX_DINEP_DFIFO_DEPTH_3 256 +#define OTG11_TX_DINEP_DFIFO_DEPTH_4 256 + +/* 3.10 UTMI-To-UTMI Bridge Component Parameters */ +#define OTG11_U2UB_EN 0 #ifdef __cplusplus } diff --git a/components/soc/esp32p4/include/soc/usb_dwc_struct.h b/components/soc/esp32p4/include/soc/usb_dwc_struct.h index 206d566277e..f07575c52a6 100644 --- a/components/soc/esp32p4/include/soc/usb_dwc_struct.h +++ b/components/soc/esp32p4/include/soc/usb_dwc_struct.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -13,7 +13,10 @@ extern "C" { #endif /* -Registers and fields were generated based on a set of configuration options. +Registers and fields were generated based on a set of USB-DWC configuration options. +ESP32-P4 contains 2 instances of USB-DWC with different configurations, the structure below corresponds to the HS instance. +The FS instance contains a subset of registers from HS instance, the user (HAL) is responsible for accessing only existing fields. + See ESP32-P4 "usb_dwc_cfg.h" for more details. */ @@ -1368,6 +1371,7 @@ _Static_assert(sizeof(usb_dwc_dev_t) == 0xe08, "Invalid size of usb_dwc_dev_t st #endif extern usb_dwc_dev_t USB_DWC_HS; +extern usb_dwc_dev_t USB_DWC_FS; #ifdef __cplusplus } diff --git a/components/soc/esp32s2/include/soc/usb_dwc_struct.h b/components/soc/esp32s2/include/soc/usb_dwc_struct.h index c6da8d901f1..4d8f3e4a797 100644 --- a/components/soc/esp32s2/include/soc/usb_dwc_struct.h +++ b/components/soc/esp32s2/include/soc/usb_dwc_struct.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -88,7 +88,7 @@ typedef union { struct { uint32_t toutcal: 3; uint32_t phyif: 1; - uint32_t reserved_4: 1; + uint32_t ulpiutmisel: 1; uint32_t fsintf: 1; uint32_t physel: 1; uint32_t reserved_7: 1; diff --git a/components/soc/esp32s3/include/soc/usb_dwc_struct.h b/components/soc/esp32s3/include/soc/usb_dwc_struct.h index 70f73e37b7a..1910ca20493 100644 --- a/components/soc/esp32s3/include/soc/usb_dwc_struct.h +++ b/components/soc/esp32s3/include/soc/usb_dwc_struct.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -88,7 +88,7 @@ typedef union { struct { uint32_t toutcal: 3; uint32_t phyif: 1; - uint32_t reserved_4: 1; + uint32_t ulpiutmisel: 1; uint32_t fsintf: 1; uint32_t physel: 1; uint32_t reserved_7: 1; diff --git a/components/usb/hcd_dwc.c b/components/usb/hcd_dwc.c index b5018da8f8c..3cebc438bc9 100644 --- a/components/usb/hcd_dwc.c +++ b/components/usb/hcd_dwc.c @@ -1276,7 +1276,9 @@ esp_err_t hcd_port_init(int port_number, const hcd_port_config_t *port_config, h port_obj->callback = port_config->callback; port_obj->callback_arg = port_config->callback_arg; port_obj->context = port_config->context; - usb_dwc_hal_init(port_obj->hal); + usb_dwc_hal_init(port_obj->hal, 0); + port_obj->hal->channels.hdls = calloc(port_obj->hal->constant_config.chan_num_total, sizeof(usb_dwc_hal_chan_t*)); + HCD_CHECK_FROM_CRIT(port_obj->hal->channels.hdls != NULL, ESP_ERR_NO_MEM); port_obj->initialized = true; // Clear the frame list. We set the frame list register and enable periodic scheduling after a successful reset memset(port_obj->frame_list, 0, FRAME_LIST_LEN * sizeof(uint32_t)); @@ -1300,6 +1302,7 @@ esp_err_t hcd_port_deinit(hcd_port_handle_t port_hdl) ESP_ERR_INVALID_STATE); port->initialized = false; esp_intr_disable(s_hcd_obj->isr_hdl); + free(port->hal->channels.hdls); usb_dwc_hal_deinit(port->hal); HCD_EXIT_CRITICAL(); @@ -1412,14 +1415,14 @@ esp_err_t hcd_port_recover(hcd_port_handle_t port_hdl) && port->num_pipes_idle == 0 && port->num_pipes_queued == 0 && port->flags.val == 0 && port->task_waiting_port_notif == NULL, ESP_ERR_INVALID_STATE); + // We are about to do a soft reset on the peripheral. Disable the peripheral throughout esp_intr_disable(s_hcd_obj->isr_hdl); usb_dwc_hal_core_soft_reset(port->hal); port->state = HCD_PORT_STATE_NOT_POWERED; port->last_event = HCD_PORT_EVENT_NONE; port->flags.val = 0; - // Soft reset wipes all registers so we need to reinitialize the HAL - usb_dwc_hal_init(port->hal); + // Clear the frame list. We set the frame list register and enable periodic scheduling after a successful reset memset(port->frame_list, 0, FRAME_LIST_LEN * sizeof(uint32_t)); esp_intr_enable(s_hcd_obj->isr_hdl); diff --git a/components/usb/test_apps/hcd/main/test_hcd_isoc.c b/components/usb/test_apps/hcd/main/test_hcd_isoc.c index 1f6420bf81c..2f5f837af42 100644 --- a/components/usb/test_apps/hcd/main/test_hcd_isoc.c +++ b/components/usb/test_apps/hcd/main/test_hcd_isoc.c @@ -6,7 +6,7 @@ #include #include -#include "soc/usb_dwc_cfg.h" +#include "hal/usb_dwc_ll.h" // For USB-DWC configuration #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "unity.h" @@ -17,7 +17,7 @@ #define NUM_URBS 3 #define NUM_PACKETS_PER_URB 3 #define POST_ENQUEUE_DELAY_US 20 -#define ENQUEUE_DELAY (OTG_HSPHY_INTERFACE ? 100 : 500) // With this delay we want to enqueue the URBs at different times +#define ENQUEUE_DELAY (usb_dwc_ll_ghwcfg_get_hsphy_type(USB_DWC_LL_GET_HW(0)) ? 100 : 500) // With this delay we want to enqueue the URBs at different times /* Test HCD ISOC pipe URBs @@ -126,12 +126,12 @@ TEST_CASE("Test HCD isochronous pipe URBs all", "[isoc][full_speed][high_speed]" uint8_t dev_addr = test_hcd_enum_device(default_pipe); urb_t *urb_list[NUM_URBS]; - hcd_pipe_handle_t unused_pipes[OTG_NUM_HOST_CHAN]; + hcd_pipe_handle_t unused_pipes[16]; const usb_ep_desc_t *out_ep_desc = dev_isoc_get_out_ep_desc(port_speed); const int isoc_packet_size = USB_EP_DESC_GET_MPS(out_ep_desc); - // For all channels - for (int channel = 0; channel < OTG_NUM_HOST_CHAN - 1; channel++) { + // For all channels (except channel allocated for EP0) + for (int channel = 0; channel < usb_dwc_ll_ghwcfg_get_channel_num(USB_DWC_LL_GET_HW(0)) - 1; channel++) { // Allocate unused pipes, so the active isoc_out_pipe uses different channel index for (int ch = 0; ch < channel; ch++) { unused_pipes[ch] = test_hcd_pipe_alloc(port_hdl, out_ep_desc, dev_addr + 1, port_speed); From 000270a4f6dd184512dc542d9500e041fc80a91b Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Fri, 4 Oct 2024 18:15:09 +0200 Subject: [PATCH 08/70] fix(sysview): fix lp uart clock source --- components/app_trace/port/port_uart.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/components/app_trace/port/port_uart.c b/components/app_trace/port/port_uart.c index 053f235cdbf..c4146d09d3e 100644 --- a/components/app_trace/port/port_uart.c +++ b/components/app_trace/port/port_uart.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2017-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2017-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -218,6 +218,13 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data) hw_data->message_buff_overflow = false; hw_data->circular_buff_overflow = false; + assert((hw_data->port_num <= SOC_UART_NUM) && "Not possible to configure UART. Please check selected UART port"); + + int source_clk = UART_SCLK_DEFAULT; +#if SOC_UART_LP_NUM > 0 + if (hw_data->port_num >= SOC_UART_HP_NUM) + source_clk = LP_UART_SCLK_DEFAULT; +#endif const uart_config_t uart_config = { .baud_rate = CONFIG_APPTRACE_UART_BAUDRATE, @@ -225,7 +232,7 @@ static esp_err_t esp_apptrace_uart_init(esp_apptrace_uart_data_t *hw_data) .parity = UART_PARITY_DISABLE, .stop_bits = UART_STOP_BITS_1, .flow_ctrl = UART_HW_FLOWCTRL_DISABLE, - .source_clk = UART_SCLK_DEFAULT, + .source_clk = source_clk, }; ESP_LOGI(TAG, "UART baud rate: %i", CONFIG_APPTRACE_UART_BAUDRATE); // We won't use a buffer for sending data. From b02d7060f0a958ca9dbcb9dd69df8e3ace3a9d17 Mon Sep 17 00:00:00 2001 From: Linda Date: Fri, 11 Oct 2024 16:34:17 +0800 Subject: [PATCH 09/70] docs: update code example for I2C slave write --- docs/en/api-reference/peripherals/i2c.rst | 14 +++++++------- docs/zh_CN/api-reference/peripherals/i2c.rst | 17 ++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/docs/en/api-reference/peripherals/i2c.rst b/docs/en/api-reference/peripherals/i2c.rst index 7714f5e5161..ded149bb2e5 100644 --- a/docs/en/api-reference/peripherals/i2c.rst +++ b/docs/en/api-reference/peripherals/i2c.rst @@ -88,7 +88,7 @@ The I2C driver offers following services: Resource Allocation ^^^^^^^^^^^^^^^^^^^ -Both I2C master bus and I2C slave bus, when supported, are represented by :cpp:type:`i2c_bus_handle_t` in the driver. The available ports are managed in a resource pool that allocates a free port on request. +The I2C master bus is represented by :cpp:type:`i2c_master_bus_handle_t` in the driver. The available ports are managed in a resource pool that allocates a free port on request. Install I2C master bus and device ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -451,20 +451,20 @@ Simple example for writing data to FIFO: i2c_slave_config_t i2c_slv_config = { .addr_bit_len = I2C_ADDR_BIT_LEN_7, // 7-bit address .clk_source = I2C_CLK_SRC_DEFAULT, // set the clock source - .i2c_port = 0, // set I2C port number + .i2c_port = TEST_I2C_PORT, // set I2C port number .send_buf_depth = 256, // set TX buffer length - .scl_io_num = 2, // SCL GPIO number - .sda_io_num = 1, // SDA GPIO number + .scl_io_num = I2C_SLAVE_SCL_IO, // SCL GPIO number + .sda_io_num = I2C_SLAVE_SDA_IO, // SDA GPIO number .slave_addr = 0x58, // slave address }; - i2c_bus_handle_t i2c_bus_handle; - ESP_ERROR_CHECK(i2c_new_slave_device(&i2c_slv_config, &i2c_bus_handle)); + i2c_slave_dev_handle_t slave_handle; + ESP_ERROR_CHECK(i2c_new_slave_device(&i2c_slv_config, &slave_handle)); for (int i = 0; i < DATA_LENGTH; i++) { data_wr[i] = i; } - ESP_ERROR_CHECK(i2c_slave_transmit(i2c_bus_handle, data_wr, DATA_LENGTH, 10000)); + ESP_ERROR_CHECK(i2c_slave_transmit(slave_handle, data_wr, DATA_LENGTH, 10000)); I2C Slave Read ~~~~~~~~~~~~~~ diff --git a/docs/zh_CN/api-reference/peripherals/i2c.rst b/docs/zh_CN/api-reference/peripherals/i2c.rst index 392f3a7575a..51979a91ab6 100644 --- a/docs/zh_CN/api-reference/peripherals/i2c.rst +++ b/docs/zh_CN/api-reference/peripherals/i2c.rst @@ -1,4 +1,4 @@ -集成电路总线 (I2C) +I2C 接口 ================== :link_to_translation:`en:[English]` @@ -88,7 +88,7 @@ I2C 驱动程序提供以下服务: 资源分配 ^^^^^^^^^ -若系统支持 I2C 主机总线和 I2C 从机总线,则由驱动程序中的 :cpp:type:`i2c_bus_handle_t` 来表示。资源池管理可用的端口,并在有请求时分配空闲端口。 +若系统支持 I2C 主机总线,由驱动程序中的 :cpp:type:`i2c_master_bus_handle_t` 来表示。资源池管理可用的端口,并在有请求时分配空闲端口。 安装 I2C 主机总线和设备 ~~~~~~~~~~~~~~~~~~~~~~~ @@ -113,7 +113,6 @@ I2C 主机总线需要 :cpp:type:`i2c_master_bus_config_t` 指定的配置: - :cpp:member:`i2c_master_bus_config_t::enable_internal_pullup` 启用内部上拉电阻。注意:该设置无法在高速频率下拉高总线,此时建议使用合适的外部上拉电阻。 - :cpp:member:`i2c_master_bus_config_t::allow_pd` 配置驱动程序是否允许系统在睡眠模式下关闭外设电源。在进入睡眠之前,系统将备份 I2C 寄存器上下文,当系统退出睡眠模式时,这些上下文将被恢复。关闭外设可以节省更多功耗,但代价是消耗更多内存来保存寄存器上下文。你需要在功耗和内存消耗之间做权衡。此配置选项依赖于特定的硬件功能,如果在不支持的芯片上启用它,你将看到类似 ``not able to power down in light sleep`` 的错误消息。 - 如果在 :cpp:type:`i2c_master_bus_config_t` 中指定了配置,则可调用 :cpp:func:`i2c_new_master_bus` 来分配和初始化 I2C 主机总线。如果函数运行正确,则将返回一个 I2C 总线句柄。若没有可用的 I2C 端口,此函数将返回 :c:macro:`ESP_ERR_NOT_FOUND` 错误。 I2C 主机设备需要 :cpp:type:`i2c_device_config_t` 指定的配置: @@ -452,20 +451,20 @@ I2C 从机的发送 buffer 可作为 FIFO 来存储要发送的数据。在主 i2c_slave_config_t i2c_slv_config = { .addr_bit_len = I2C_ADDR_BIT_LEN_7, // 7 位地址 .clk_source = I2C_CLK_SRC_DEFAULT, // 设置时钟源 - .i2c_port = 0, // 设置 I2C 端口编号 + .i2c_port = TEST_I2C_PORT, // 设置 I2C 端口编号 .send_buf_depth = 256, // 设置 TX buffer 长度 - .scl_io_num = 2, // SCL 管脚编号 - .sda_io_num = 1, // SDA 管脚编号 + .scl_io_num = I2C_SLAVE_SCL_IO, // SCL 管脚编号 + .sda_io_num = I2C_SLAVE_SDA_IO, // SDA 管脚编号 .slave_addr = 0x58, // 从机地址 }; - i2c_bus_handle_t i2c_bus_handle; - ESP_ERROR_CHECK(i2c_new_slave_device(&i2c_slv_config, &i2c_bus_handle)); + i2c_slave_dev_handle_t slave_handle; + ESP_ERROR_CHECK(i2c_new_slave_device(&i2c_slv_config, &slave_handle)); for (int i = 0; i < DATA_LENGTH; i++) { data_wr[i] = i; } - ESP_ERROR_CHECK(i2c_slave_transmit(i2c_bus_handle, data_wr, DATA_LENGTH, 10000)); + ESP_ERROR_CHECK(i2c_slave_transmit(slave_handle, data_wr, DATA_LENGTH, 10000)); I2C 从机读取 ~~~~~~~~~~~~~ From 987f7661cdba37ec83e429f26cbfd088ddc32037 Mon Sep 17 00:00:00 2001 From: morris Date: Fri, 25 Oct 2024 11:03:34 +0800 Subject: [PATCH 10/70] fix(mipi_dsi): error logic in reading short packet --- components/hal/mipi_dsi_hal.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/hal/mipi_dsi_hal.c b/components/hal/mipi_dsi_hal.c index 06565f7c372..abd0fe2ca91 100644 --- a/components/hal/mipi_dsi_hal.c +++ b/components/hal/mipi_dsi_hal.c @@ -206,10 +206,10 @@ void mipi_dsi_hal_host_gen_read_short_packet(mipi_dsi_hal_context_t *hal, uint8_ while (!mipi_dsi_host_ll_gen_is_read_fifo_empty(hal->host)) { temp = mipi_dsi_host_ll_gen_read_payload_fifo(hal->host); for (int i = 0; i < 4; i++) { - if ((counter + i) < buffer_size) { - receive_buffer[counter + i] = (temp >> (8 * i)) & 0xFF; + if (counter < buffer_size) { + receive_buffer[counter] = (temp >> (8 * i)) & 0xFF; + counter++; } - counter++; } } } From 5a89693c3fd2389bed9c1a9b661600f02525414d Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Mon, 28 Oct 2024 09:53:29 +0800 Subject: [PATCH 11/70] fix(wifi/mesh): Fixed delete group id error in wifi mesh Closes https://github.com/espressif/esp-idf/issues/14735 --- components/esp_wifi/lib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 02217f5aed7..952d21c8d1b 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 02217f5aed73e6296fbb12137a1c36b207b0dab5 +Subproject commit 952d21c8d1b5de2d966e3a0010317c41b060baad From ad9021a844c8922f69f9214571e52f9181871f66 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Fri, 25 Oct 2024 16:44:40 +0800 Subject: [PATCH 12/70] fix(i2s): fix the crackle using apll with DFS feature Closes: https://github.com/espressif/esp-idf/issues/14707 --- components/driver/deprecated/i2s_legacy.c | 5 ----- components/esp_driver_dac/dac_continuous.c | 2 +- components/esp_driver_i2s/i2s_pdm.c | 5 ----- components/esp_driver_i2s/i2s_std.c | 5 ----- components/esp_driver_i2s/i2s_tdm.c | 5 ----- components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.release | 1 + components/esp_lcd/i80/esp_lcd_panel_io_i2s.c | 2 +- docs/en/api-reference/peripherals/dac.rst | 2 +- docs/en/api-reference/peripherals/i2s.rst | 2 +- docs/zh_CN/api-reference/peripherals/dac.rst | 2 +- docs/zh_CN/api-reference/peripherals/i2s.rst | 2 +- 11 files changed, 7 insertions(+), 26 deletions(-) diff --git a/components/driver/deprecated/i2s_legacy.c b/components/driver/deprecated/i2s_legacy.c index 36996697b28..5f4a033fcfc 100644 --- a/components/driver/deprecated/i2s_legacy.c +++ b/components/driver/deprecated/i2s_legacy.c @@ -1479,11 +1479,6 @@ static esp_err_t i2s_init_legacy(i2s_port_t i2s_num, int intr_alloc_flag) /* Create power management lock */ #ifdef CONFIG_PM_ENABLE esp_pm_lock_type_t pm_lock = ESP_PM_APB_FREQ_MAX; -#if SOC_I2S_SUPPORTS_APLL - if (p_i2s[i2s_num]->use_apll) { - pm_lock = ESP_PM_NO_LIGHT_SLEEP; - } -#endif // SOC_I2S_SUPPORTS_APLL ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_lock, 0, "i2s_driver", &p_i2s[i2s_num]->pm_lock), TAG, "I2S pm lock error"); #endif //CONFIG_PM_ENABLE diff --git a/components/esp_driver_dac/dac_continuous.c b/components/esp_driver_dac/dac_continuous.c index b3f8f9c25e0..c7e4ffb5eae 100644 --- a/components/esp_driver_dac/dac_continuous.c +++ b/components/esp_driver_dac/dac_continuous.c @@ -228,7 +228,7 @@ esp_err_t dac_continuous_new_channels(const dac_continuous_config_t *cont_cfg, d /* Create PM lock */ #if CONFIG_PM_ENABLE - esp_pm_lock_type_t pm_lock_type = cont_cfg->clk_src == DAC_DIGI_CLK_SRC_APLL ? ESP_PM_NO_LIGHT_SLEEP : ESP_PM_APB_FREQ_MAX; + esp_pm_lock_type_t pm_lock_type = ESP_PM_APB_FREQ_MAX; ESP_GOTO_ON_ERROR(esp_pm_lock_create(pm_lock_type, 0, "dac_driver", &handle->pm_lock), err3, TAG, "Failed to create DAC pm lock"); #endif handle->chan_cnt = __builtin_popcount(cont_cfg->chan_mask); diff --git a/components/esp_driver_i2s/i2s_pdm.c b/components/esp_driver_i2s/i2s_pdm.c index 9d10058af49..86d899a933f 100644 --- a/components/esp_driver_i2s/i2s_pdm.c +++ b/components/esp_driver_i2s/i2s_pdm.c @@ -199,11 +199,6 @@ esp_err_t i2s_channel_init_pdm_tx_mode(i2s_chan_handle_t handle, const i2s_pdm_t #ifdef CONFIG_PM_ENABLE esp_pm_lock_type_t pm_type = ESP_PM_APB_FREQ_MAX; -#if SOC_I2S_SUPPORTS_APLL - if (pdm_tx_cfg->clk_cfg.clk_src == I2S_CLK_SRC_APLL) { - pm_type = ESP_PM_NO_LIGHT_SLEEP; - } -#endif // SOC_I2S_SUPPORTS_APLL ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_type, 0, "i2s_driver", &handle->pm_lock), TAG, "I2S pm lock create failed"); #endif diff --git a/components/esp_driver_i2s/i2s_std.c b/components/esp_driver_i2s/i2s_std.c index 109aaa0bc51..564f2cd4f71 100644 --- a/components/esp_driver_i2s/i2s_std.c +++ b/components/esp_driver_i2s/i2s_std.c @@ -240,11 +240,6 @@ esp_err_t i2s_channel_init_std_mode(i2s_chan_handle_t handle, const i2s_std_conf #ifdef CONFIG_PM_ENABLE esp_pm_lock_type_t pm_type = ESP_PM_APB_FREQ_MAX; -#if SOC_I2S_SUPPORTS_APLL - if (std_cfg->clk_cfg.clk_src == I2S_CLK_SRC_APLL) { - pm_type = ESP_PM_NO_LIGHT_SLEEP; - } -#endif // SOC_I2S_SUPPORTS_APLL ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_type, 0, "i2s_driver", &handle->pm_lock), TAG, "I2S pm lock create failed"); #endif diff --git a/components/esp_driver_i2s/i2s_tdm.c b/components/esp_driver_i2s/i2s_tdm.c index 6d579105ed5..f0dce4d55a1 100644 --- a/components/esp_driver_i2s/i2s_tdm.c +++ b/components/esp_driver_i2s/i2s_tdm.c @@ -246,11 +246,6 @@ esp_err_t i2s_channel_init_tdm_mode(i2s_chan_handle_t handle, const i2s_tdm_conf #endif #ifdef CONFIG_PM_ENABLE esp_pm_lock_type_t pm_type = ESP_PM_APB_FREQ_MAX; -#if SOC_I2S_SUPPORTS_APLL - if (tdm_cfg->clk_cfg.clk_src == I2S_CLK_SRC_APLL) { - pm_type = ESP_PM_NO_LIGHT_SLEEP; - } -#endif // SOC_I2S_SUPPORTS_APLL ESP_RETURN_ON_ERROR(esp_pm_lock_create(pm_type, 0, "i2s_driver", &handle->pm_lock), TAG, "I2S pm lock create failed"); #endif diff --git a/components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.release b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.release index 998cfb51f82..7c7f2a2efa6 100644 --- a/components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.release +++ b/components/esp_driver_i2s/test_apps/i2s/sdkconfig.ci.release @@ -4,3 +4,4 @@ CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y +CONFIG_PM_DFS_INIT_AUTO=y diff --git a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c index e5cbf45a654..4c30053ced9 100644 --- a/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c +++ b/components/esp_lcd/i80/esp_lcd_panel_io_i2s.c @@ -666,7 +666,7 @@ static esp_err_t i2s_lcd_select_periph_clock(esp_lcd_i80_bus_handle_t bus, lcd_c // create pm lock based on different clock source // clock sources like PLL and XTAL will be turned off in light sleep #if CONFIG_PM_ENABLE - ESP_RETURN_ON_ERROR(esp_pm_lock_create(ESP_PM_NO_LIGHT_SLEEP, 0, "i80_bus_lcd", &bus->pm_lock), TAG, "create pm lock failed"); + ESP_RETURN_ON_ERROR(esp_pm_lock_create(ESP_PM_APB_FREQ_MAX, 0, "i80_bus_lcd", &bus->pm_lock), TAG, "create pm lock failed"); #endif return ESP_OK; } diff --git a/docs/en/api-reference/peripherals/dac.rst b/docs/en/api-reference/peripherals/dac.rst index 4cb3eb12b3d..06b5cc55f0e 100644 --- a/docs/en/api-reference/peripherals/dac.rst +++ b/docs/en/api-reference/peripherals/dac.rst @@ -96,7 +96,7 @@ Power Management When the power management is enabled (i.e., :ref:`CONFIG_PM_ENABLE` is on), the system will adjust or stop the clock source of DAC before entering Light-sleep mode, thus potential influence to the DAC signals may lead to false data conversion. -When using DAC driver in continuous mode, it can prevent the system from changing or stopping the clock source in DMA or cosine mode by acquiring a power management lock. When the clock source is generated from APB, the lock type will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`. When the clock source is APLL (only in DMA mode), it will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_NO_LIGHT_SLEEP`. Whenever the DAC is converting (i.e., DMA or cosine wave generator is working), the driver guarantees that the power management lock is acquired after calling :cpp:func:`dac_continuous_enable`. Likewise, the driver will release the lock when :cpp:func:`dac_continuous_disable` is called. +When using DAC driver in continuous mode, it can prevent the system from changing or stopping the clock source in DMA or cosine mode by acquiring a power management lock. The power lock type will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`. Whenever the DAC is converting (i.e., DMA or cosine wave generator is working), the driver guarantees that the power management lock is acquired after calling :cpp:func:`dac_continuous_enable`. Likewise, the driver will release the lock when :cpp:func:`dac_continuous_disable` is called. IRAM Safe ^^^^^^^^^ diff --git a/docs/en/api-reference/peripherals/i2s.rst b/docs/en/api-reference/peripherals/i2s.rst index e72b367441b..ea3dd9467bd 100644 --- a/docs/en/api-reference/peripherals/i2s.rst +++ b/docs/en/api-reference/peripherals/i2s.rst @@ -236,7 +236,7 @@ Power Management When the power management is enabled (i.e., :ref:`CONFIG_PM_ENABLE` is on), the system will adjust or stop the source clock of I2S before entering Light-sleep, thus potentially changing the I2S signals and leading to transmitting or receiving invalid data. -The I2S driver can prevent the system from changing or stopping the source clock by acquiring a power management lock. When the source clock is generated from APB, the lock type will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX` and when the source clock is APLL (if supported), it will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_NO_LIGHT_SLEEP`. Whenever the user is reading or writing via I2S (i.e., calling :cpp:func:`i2s_channel_read` or :cpp:func:`i2s_channel_write`), the driver guarantees that the power management lock is acquired. Likewise, the driver releases the lock after the reading or writing finishes. +The I2S driver can prevent the system from changing or stopping the source clock by acquiring a power management lock. The power lock type will be set to :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`. Whenever the user is reading or writing via I2S (i.e., calling :cpp:func:`i2s_channel_read` or :cpp:func:`i2s_channel_write`), the driver guarantees that the power management lock is acquired. Likewise, the driver releases the lock after the reading or writing finishes. .. only:: SOC_I2S_SUPPORT_SLEEP_RETENTION diff --git a/docs/zh_CN/api-reference/peripherals/dac.rst b/docs/zh_CN/api-reference/peripherals/dac.rst index 1c45cbf8c5d..d96ce61213d 100644 --- a/docs/zh_CN/api-reference/peripherals/dac.rst +++ b/docs/zh_CN/api-reference/peripherals/dac.rst @@ -96,7 +96,7 @@ DAC 外设中包含一个余弦波发生器,可以在通道上产生余弦波 启用电源管理时(即开启 :ref:`CONFIG_PM_ENABLE`),系统会在进入 Light-sleep 模式前调整或停止 DAC 时钟源,这可能会影响 DAC 信号,从而导致数据无法正确转换。 -在连续模式下使用 DAC 驱动时,可以通过获取电源管理锁来防止系统在 DMA 或余弦波模式下改变或停止时钟源。时钟源为 APB 时,锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`。时钟源为 APLL 时(仅在 DMA 模式下),锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_NO_LIGHT_SLEEP`。在进行 DAC 转换时(即 DMA 或余弦波发生器运行时),驱动程序会保证在调用 :cpp:func:`dac_continuous_enable` 后获取电源管理锁。同样地,在调用 :cpp:func:`dac_continuous_disable` 时,驱动程序会释放锁。 +在连续模式下使用 DAC 驱动时,可以通过获取电源管理锁来防止系统在 DMA 或余弦波模式下改变或停止时钟源。电源锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`。在进行 DAC 转换时(即 DMA 或余弦波发生器运行时),驱动程序会保证在调用 :cpp:func:`dac_continuous_enable` 后获取电源管理锁。同样地,在调用 :cpp:func:`dac_continuous_disable` 时,驱动程序会释放锁。 IRAM 安全 ^^^^^^^^^ diff --git a/docs/zh_CN/api-reference/peripherals/i2s.rst b/docs/zh_CN/api-reference/peripherals/i2s.rst index 36aec35a1c3..ae166b6fa27 100644 --- a/docs/zh_CN/api-reference/peripherals/i2s.rst +++ b/docs/zh_CN/api-reference/peripherals/i2s.rst @@ -236,7 +236,7 @@ I2S 驱动中的资源可分为三个级别: 电源管理启用(即开启 :ref:`CONFIG_PM_ENABLE`)时,系统将在进入 Light-sleep 前调整或停止 I2S 时钟源,这可能会影响 I2S 信号,从而导致传输或接收的数据无效。 -I2S 驱动可以获取电源管理锁,从而防止系统设置更改或时钟源被禁用。时钟源为 APB 时,锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`。时钟源为 APLL(若支持)时,锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_NO_LIGHT_SLEEP`。用户通过 I2S 读写时(即调用 :cpp:func:`i2s_channel_read` 或 :cpp:func:`i2s_channel_write`),驱动程序将获取电源管理锁,并在读写完成后释放锁。 +I2S 驱动可以获取电源管理锁,从而防止系统设置更改或时钟源被禁用。电源锁的类型将被设置为 :cpp:enumerator:`esp_pm_lock_type_t::ESP_PM_APB_FREQ_MAX`。用户通过 I2S 读写时(即调用 :cpp:func:`i2s_channel_read` 或 :cpp:func:`i2s_channel_write`),驱动程序将获取电源管理锁,并在读写完成后释放锁。 .. only:: SOC_I2S_SUPPORT_SLEEP_RETENTION From 4a22f982f333295db3bab02fbef82747043afe1b Mon Sep 17 00:00:00 2001 From: Simon Dean Date: Sat, 5 Oct 2024 21:15:58 +0100 Subject: [PATCH 13/70] enable openthread coap client for mtd --- .../openthread-core-esp32x-mtd-config.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/components/openthread/private_include/openthread-core-esp32x-mtd-config.h b/components/openthread/private_include/openthread-core-esp32x-mtd-config.h index f21c9ce01ea..dd247037d74 100644 --- a/components/openthread/private_include/openthread-core-esp32x-mtd-config.h +++ b/components/openthread/private_include/openthread-core-esp32x-mtd-config.h @@ -73,6 +73,24 @@ */ #define OPENTHREAD_CONFIG_NUM_MESSAGE_BUFFERS CONFIG_OPENTHREAD_NUM_MESSAGE_BUFFERS +/** + * @def OPENTHREAD_CONFIG_COAP_API_ENABLE + * + * Define to 1 to enable the CoAP API. + * + */ +#define OPENTHREAD_CONFIG_COAP_API_ENABLE 1 + +/** + * @def OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE + * + * Define to 1 to enable platform NETIF support. + * + */ +#ifndef OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE +#define OPENTHREAD_CONFIG_PLATFORM_NETIF_ENABLE 1 +#endif + /** * @def OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE * From e5d246ef27477fb7ad3e1cfd4e0abdc41f256277 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 1 Oct 2024 14:20:20 +0530 Subject: [PATCH 14/70] feat(hal): esp32c5: Add hal layer for key manager --- .../esp_rom/esp32c5/include/esp32c5/rom/km.h | 63 ++++ components/hal/esp32c5/include/hal/huk_ll.h | 118 ++++++ .../hal/esp32c5/include/hal/key_mgr_ll.h | 356 ++++++++++++++++++ .../include/hal/mspi_timing_tuning_ll.h | 8 + .../hal/{esp32p4 => }/include/hal/huk_hal.h | 2 +- .../{esp32p4 => }/include/hal/key_mgr_hal.h | 10 +- .../esp32c5/include/soc/Kconfig.soc_caps.in | 8 + components/soc/esp32c5/include/soc/soc_caps.h | 4 + .../soc/esp32c5/register/soc/keymng_reg.h | 33 ++ 9 files changed, 596 insertions(+), 6 deletions(-) create mode 100644 components/esp_rom/esp32c5/include/esp32c5/rom/km.h create mode 100644 components/hal/esp32c5/include/hal/huk_ll.h create mode 100644 components/hal/esp32c5/include/hal/key_mgr_ll.h rename components/hal/{esp32p4 => }/include/hal/huk_hal.h (96%) rename components/hal/{esp32p4 => }/include/hal/key_mgr_hal.h (94%) diff --git a/components/esp_rom/esp32c5/include/esp32c5/rom/km.h b/components/esp_rom/esp32c5/include/esp32c5/rom/km.h new file mode 100644 index 00000000000..2fe74e77a56 --- /dev/null +++ b/components/esp_rom/esp32c5/include/esp32c5/rom/km.h @@ -0,0 +1,63 @@ +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#ifndef _KM_H +#define _KM_H + +#include "soc/soc_caps.h" +#if SOC_KEY_MANAGER_SUPPORTED + +#include +#include "soc/soc.h" +#include "ets_sys.h" + +#if __cplusplus +extern "C" { +#endif + +/* huk mode type */ +typedef enum { + HUK_MODE_RECOVER = 0, + HUK_MODE_GEN = 1, +} huk_mode_t; + +/** + * @brief Recover efuse key or key manager key if flash encryption is enabled + * + * @param do_log : if km process print log + * + * @return ETS_OK when key is recovered, ETS_FAILED when key not recovered + */ +ETS_STATUS esp_rom_check_recover_key(int do_log); + +/** + * @brief Configure huk mode + * + * @param mode : HUK_MODE_RECOVER or HUK_MODE_GEN + * + * @param huk_info : uint8_t pointer to the buffer which will feed the huk info or + * gain the huk info + * + * @return ETS_OK when huk configuration is done, else ETS_FAILED + */ +ETS_STATUS esp_rom_km_huk_conf(huk_mode_t mode, uint8_t *huk_info); + +/** + * @brief Get huk risk. The risk level of HUK is 0-6: the higher the risk level is, + * the more error bits there are in the PUF SRAM. 7: Error level, HUK is invalid + * + * @param None + * + * @return The huk risk + */ +int esp_rom_km_huk_risk(void); + +#ifdef __cplusplus +} +#endif +#endif /* SOC_KEY_MANAGER_SUPPORTED */ + +#endif /* _KM_H */ diff --git a/components/hal/esp32c5/include/hal/huk_ll.h b/components/hal/esp32c5/include/hal/huk_ll.h new file mode 100644 index 00000000000..37215ae35ea --- /dev/null +++ b/components/hal/esp32c5/include/hal/huk_ll.h @@ -0,0 +1,118 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/******************************************************************************* + * NOTICE + * The hal is not public api, don't use it in application code. + ******************************************************************************/ + +#pragma once + +#include "soc/soc_caps.h" + +#if SOC_KEY_MANAGER_SUPPORTED + +#include +#include +#include + +#include "hal/huk_types.h" +#include "soc/huk_reg.h" +#include "soc/soc_caps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* @brief Configure the HUK mode */ +static inline void huk_ll_configure_mode(const esp_huk_mode_t huk_mode) +{ + REG_SET_FIELD(HUK_CONF_REG, HUK_MODE, huk_mode); +} + +static inline void huk_ll_write_info(const uint8_t *buffer, const size_t size) +{ + memcpy((uint8_t *)HUK_INFO_MEM, buffer, size); +} + +static inline void huk_ll_read_info(uint8_t *buffer, const size_t size) +{ + memcpy(buffer, (uint8_t *)HUK_INFO_MEM, size); +} + +/* @brief Start the HUK at IDLE state */ +static inline void huk_ll_start(void) +{ + REG_SET_FIELD(HUK_START_REG, HUK_START, 1); +} + +/* @brief Continue HUK operation at LOAD/GAIN state */ +static inline void huk_ll_continue(void) +{ + REG_SET_FIELD(HUK_START_REG, HUK_CONTINUE, 1); +} + +/* @bried Enable or Disable the HUK interrupts */ +static inline void huk_ll_configure_interrupt(const esp_huk_interrupt_type_t intr, const bool en) +{ + switch(intr) { + case ESP_HUK_INT_PREP_DONE: + REG_SET_FIELD(HUK_INT_ENA_REG, HUK_PREP_DONE_INT_ENA, en); + case ESP_HUK_INT_PROC_DONE: + REG_SET_FIELD(HUK_INT_ENA_REG, HUK_PROC_DONE_INT_ENA, en); + case ESP_HUK_INT_POST_DONE: + REG_SET_FIELD(HUK_INT_ENA_REG, HUK_POST_DONE_INT_ENA, en); + default: + return; + } +} + +/* @bried Clear the HUK interrupts */ +static inline void huk_ll_clear_int(const esp_huk_interrupt_type_t intr) +{ + switch(intr) { + case ESP_HUK_INT_PREP_DONE: + REG_SET_FIELD(HUK_INT_CLR_REG, HUK_PREP_DONE_INT_CLR, 1); + case ESP_HUK_INT_PROC_DONE: + REG_SET_FIELD(HUK_INT_CLR_REG, HUK_PROC_DONE_INT_CLR, 1); + case ESP_HUK_INT_POST_DONE: + REG_SET_FIELD(HUK_INT_CLR_REG, HUK_POST_DONE_INT_CLR, 1); + default: + return; + } +} + +/** + * @brief Read state of Hardware Unique Key Generator + * + * @return esp_huk_state_t + */ +static inline esp_huk_state_t huk_ll_get_state(void) +{ + return (esp_huk_state_t) REG_GET_FIELD(HUK_STATE_REG, HUK_STATE); +} + +/** + * @brief Get the HUK generation status + */ +static inline esp_huk_gen_status_t huk_ll_get_gen_status(void) +{ + return (esp_huk_gen_status_t) REG_GET_FIELD(HUK_STATUS_REG, HUK_STATUS); +} + +/** + * @brief Read the HUK date information + */ +static inline uint32_t huk_ll_get_date_info(void) +{ + // Only the least significant 28 bits have desired information + return (uint32_t)(0x0FFFFFFF & REG_READ(HUK_DATE_REG)); +} + +#ifdef __cplusplus +} +#endif +#endif diff --git a/components/hal/esp32c5/include/hal/key_mgr_ll.h b/components/hal/esp32c5/include/hal/key_mgr_ll.h new file mode 100644 index 00000000000..1076555f02b --- /dev/null +++ b/components/hal/esp32c5/include/hal/key_mgr_ll.h @@ -0,0 +1,356 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/******************************************************************************* + * NOTICE + * The hal is not public api, don't use it in application code. + ******************************************************************************/ + +#pragma once + +#include +#include +#include + +#include "hal/assert.h" +#include "hal/key_mgr_types.h" +#include "soc/keymng_reg.h" +#include "soc/pcr_struct.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Read state of Key Manager + * + * @return esp_key_mgr_state_t + */ +static inline esp_key_mgr_state_t key_mgr_ll_get_state(void) +{ + return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE); +} + +/** + * @brief Enable the bus clock for Key Manager peripheral + * Note: Please use key_mgr_ll_enable_bus_clock which requires the critical section + * and do not use _key_mgr_ll_enable_bus_clock + * @param true to enable, false to disable + */ +static inline void _key_mgr_ll_enable_bus_clock(bool enable) +{ + // Set the force power down bit to 0 to enable key manager + PCR.km_pd_ctrl.km_mem_force_pd = 0; + // Enable key manager clock + PCR.km_conf.km_clk_en = 1; +} + +/// use a macro to wrap the function, force the caller to use it in a critical section +/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance +#define key_mgr_ll_enable_bus_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_bus_clock(__VA_ARGS__) + +/** + * @brief Enable the peripheral clock for Key Manager + * + * Note: Please use key_mgr_ll_enable_peripheral_clock which requires the critical section + * and do not use _key_mgr_ll_enable_peripheral_clock + * @param true to enable, false to disable + */ +static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) +{ + ; /* Nothing to do here, Kept for compatibility with other SoC */ +} + +#define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__) + +/** + * @brief Reset the Key Manager peripheral */ +static inline void _key_mgr_ll_reset_register(void) +{ + PCR.km_conf.km_rst_en = 1; + PCR.km_conf.km_rst_en = 0; + // Wait for key manager to be ready + while (!PCR.km_conf.km_ready) { + }; + + while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { + }; + +} + +/// use a macro to wrap the function, force the caller to use it in a critical section +/// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance +#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_reset_register(__VA_ARGS__) + +/* @brief Start the key manager at IDLE state */ +static inline void key_mgr_ll_start(void) +{ + REG_SET_BIT(KEYMNG_START_REG, KEYMNG_START); +} + +/* @brief Continue key manager operation at LOAD/GAIN state */ +static inline void key_mgr_ll_continue(void) +{ + REG_SET_BIT(KEYMNG_START_REG, KEYMNG_CONTINUE); +} + +/* @brief Enable or Disable the KEY_MGR interrupts */ +static inline void key_mgr_ll_configure_interrupt(const esp_key_mgr_interrupt_type_t intr, bool en) +{ + switch(intr) { + case ESP_KEY_MGR_INT_PREP_DONE: + REG_SET_FIELD(KEYMNG_INT_ENA_REG, KEYMNG_PREP_DONE_INT_ENA, en); + break; + case ESP_KEY_MGR_INT_PROC_DONE: + REG_SET_FIELD(KEYMNG_INT_ENA_REG, KEYMNG_PROC_DONE_INT_ENA, en); + break; + case ESP_KEY_MGR_INT_POST_DONE: + REG_SET_FIELD(KEYMNG_INT_ENA_REG, KEYMNG_POST_DONE_INT_ENA, en); + break; + default: + return; + } +} + +/* @brief Clear the KEY_MGR interrupts */ +static inline void key_mgr_ll_clear_int(const esp_key_mgr_interrupt_type_t intr) +{ + switch(intr) { + case ESP_KEY_MGR_INT_PREP_DONE: + REG_SET_FIELD(KEYMNG_INT_CLR_REG, KEYMNG_PREP_DONE_INT_CLR, 1); + break; + case ESP_KEY_MGR_INT_PROC_DONE: + REG_SET_FIELD(KEYMNG_INT_CLR_REG, KEYMNG_PROC_DONE_INT_CLR, 1); + break; + case ESP_KEY_MGR_INT_POST_DONE: + REG_SET_FIELD(KEYMNG_INT_CLR_REG, KEYMNG_POST_DONE_INT_CLR, 1); + break; + default: + return; + } +} + +/** + * @brief Set the key manager to use the software provided init key + */ +static inline void key_mgr_ll_use_sw_init_key(void) +{ + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_SW_INIT_KEY); +} + +/** + * @brief Configure the key manager key usage policy for a particular key type + * + */ +static inline void key_mgr_ll_set_key_usage(const esp_key_mgr_key_type_t key_type, const esp_key_mgr_key_usage_t key_usage) +{ + switch (key_type) { + case ESP_KEY_MGR_ECDSA_KEY: + if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA); + } else { + REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA); + } + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: + case ESP_KEY_MGR_XTS_AES_256_KEY: + if (key_usage == ESP_KEY_MGR_USE_EFUSE_KEY) { + REG_SET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_FLASH); + } else { + REG_CLR_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_FLASH); + } + break; + + default: + HAL_ASSERT(false && "Unsupported mode"); + return; + } +} + +static inline esp_key_mgr_key_usage_t key_mgr_ll_get_key_usage(esp_key_mgr_key_type_t key_type) +{ + switch (key_type) { + case ESP_KEY_MGR_ECDSA_KEY: + return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_ECDSA)); + break; + + case ESP_KEY_MGR_XTS_AES_128_KEY: + case ESP_KEY_MGR_XTS_AES_256_KEY: + return (esp_key_mgr_key_usage_t) (REG_GET_BIT(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY_FLASH)); + break; + + default: + HAL_ASSERT(false && "Unsupported mode"); + return ESP_KEY_MGR_USAGE_INVALID; + } + return ESP_KEY_MGR_USAGE_INVALID; +} + +/** + * @brief Set the lock for the use_sw_init_key_reg + * After this lock has been set, + * The Key manager configuration about the use of software init key cannot be changed + */ +static inline void key_mgr_ll_lock_use_sw_init_key_reg(void) +{ + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_SW_INIT_KEY_LOCK); +} + +/** + * @brief Set the lock for the use_sw_init_key_reg + * After this lock has been set, + * The Key manager configuration about whether to use a particular key from efuse or key manager cannot be changed. + */ +static inline void key_mgr_ll_lock_use_efuse_key_reg(esp_key_mgr_key_type_t key_type) +{ + switch(key_type) { + case ESP_KEY_MGR_ECDSA_KEY: + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA); + break; + case ESP_KEY_MGR_XTS_AES_128_KEY: + case ESP_KEY_MGR_XTS_AES_256_KEY: + REG_SET_BIT(KEYMNG_LOCK_REG, KEYMNG_USE_EFUSE_KEY_LOCK_FLASH); + break; + default: + HAL_ASSERT(false && "Unsupported mode"); + return; + } +} + +/* @brief Configure the key purpose to be used by the Key Manager for key generator operation */ +static inline void key_mgr_ll_set_key_purpose(const esp_key_mgr_key_purpose_t key_purpose) +{ + REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KEY_PURPOSE, key_purpose); +} + +/** + * @brief Configure the mode which is used by the Key Manager for the generator key deployment process + */ +static inline void key_mgr_ll_set_key_generator_mode(const esp_key_mgr_key_generator_mode_t mode) +{ + REG_SET_FIELD(KEYMNG_CONF_REG, KEYMNG_KGEN_MODE, mode); +} + +/** + * @brief Read the key manager process result + * @return 1 for Success + * 0 for failure + */ +static inline bool key_mgr_ll_is_result_success(void) +{ + return REG_GET_FIELD(KEYMNG_RESULT_REG, KEYMNG_PROC_RESULT); +} + +/** + * @brief Check if the deployed key is valid or not + * @return 1 for Success + * 0 for failure + */ +static inline bool key_mgr_ll_is_key_deployment_valid(const esp_key_mgr_key_type_t key_type) +{ + switch (key_type) { + + case ESP_KEY_MGR_ECDSA_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_ECDSA_VLD); + break; + + case ESP_KEY_MGR_XTS_AES_128_KEY: + case ESP_KEY_MGR_XTS_AES_256_KEY: + return REG_GET_FIELD(KEYMNG_KEY_VLD_REG, KEYMNG_KEY_FLASH_VLD); + break; + + default: + HAL_ASSERT(false && "Unsupported mode"); + return 0; + } +} + +/* + * @brief Write the SW init key in the key manager registers + * + * @input + * sw_init_key_buf Init key buffer, this should be a readable buffer of data_len size which should contain the sw init key. The buffer must be 32 bit aligned + * data_len Length of the init key buffer + */ +static inline void key_mgr_ll_write_sw_init_key(const uint8_t *sw_init_key_buf, const size_t data_len) +{ + memcpy((uint8_t *)KEYMNG_SW_INIT_KEY_MEM, sw_init_key_buf, data_len); +} + +/* + * @brief Write the Assist info in the key manager registers + * + * @input + * assist_info_buf Assist info buffer, this should be a readable buffer of data_len size which should contain the assist info. The buffer must be 32 bit aligned + * data_len Length of the assist info buffer + */ +static inline void key_mgr_ll_write_assist_info(const uint8_t *assist_info_buf, const size_t data_len) +{ + memcpy((uint8_t *)KEYMNG_ASSIST_INFO_MEM, assist_info_buf, data_len); +} + +/* + * @brief Read the Assist info from the key manager registers + * + * @input + * assist_info_buf Assist info buffer, this should be a writable buffer of size KEY_MGR_ASSIST_INFO_LEN. The buffer must be 32 bit aligned + */ +static inline void key_mgr_ll_read_assist_info( uint8_t *assist_info_buf) +{ + memcpy(assist_info_buf, (uint8_t *)KEYMNG_ASSIST_INFO_MEM, KEY_MGR_ASSIST_INFO_LEN); +} + +/* + * @brief Write the Public info in the key manager registers + * @input + * public_info_buf Public info buffer, this should be a readable buffer of data_len size which should contain the public info. The buffer must be 32 bit aligned + * data_len Length of the public info buffer + */ +static inline void key_mgr_ll_write_public_info(const uint8_t *public_info_buf, const size_t data_len) +{ + memcpy((uint8_t *)KEYMNG_PUBLIC_INFO_MEM, public_info_buf, data_len); +} + +/* + * @brief Read the Public info in the key manager registers + * @input + * public_info_buf Public info buffer, this should be a writable buffer of read_len, The buffer must be 32 bit aligned + * read_len Length of the public info buffer + */ +static inline void key_mgr_ll_read_public_info(uint8_t *public_info_buf, const size_t read_len) +{ + memcpy(public_info_buf, (uint8_t *)KEYMNG_PUBLIC_INFO_MEM, read_len); +} + +static inline bool key_mgr_ll_is_huk_valid(void) +{ + return REG_GET_FIELD(KEYMNG_HUK_VLD_REG, KEYMNG_HUK_VALID); +} + +/* @brief Set the XTS-AES (Flash Encryption) key length for the Key Manager */ +static inline void key_mgr_ll_set_xts_aes_key_len(const esp_key_mgr_xts_aes_key_len_t key_len) +{ + REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN, key_len); +} + +/* @brief Get the XTS-AES (Flash Encryption) key length for the Key Manager */ +static inline esp_key_mgr_xts_aes_key_len_t key_mgr_ll_get_xts_aes_key_len(void) +{ + return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_FLASH_KEY_LEN); +} + +/** + * @brief Read the Key Manager date information + */ +static inline uint32_t key_mgr_ll_get_date_info(void) +{ + // Only the least significant 28 bits have desired information + return (uint32_t)(0x0FFFFFFF & REG_READ(KEYMNG_DATE_REG)); +} + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h b/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h index 9a01d99830e..c94ca974668 100644 --- a/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h +++ b/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h @@ -63,6 +63,14 @@ static inline __attribute__((always_inline)) void mspi_ll_enable_bus_clock(bool PCR.mspi_conf.mspi_clk_en = enable; } +/** + * Reset the MSPI clock + */ +static inline __attribute__((always_inline)) void _mspi_timing_ll_reset_mspi(void) +{ + PCR.mspi_conf.mspi_rst_en = 1; + PCR.mspi_conf.mspi_rst_en = 0; +} #ifdef __cplusplus } diff --git a/components/hal/esp32p4/include/hal/huk_hal.h b/components/hal/include/hal/huk_hal.h similarity index 96% rename from components/hal/esp32p4/include/hal/huk_hal.h rename to components/hal/include/hal/huk_hal.h index 796f2b8f943..e158f1fc664 100644 --- a/components/hal/esp32p4/include/hal/huk_hal.h +++ b/components/hal/include/hal/huk_hal.h @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ -// The HAL layer for Hardware Unique Key (HUK) Genarator +// The HAL layer for Hardware Unique Key (HUK) Generator #pragma once diff --git a/components/hal/esp32p4/include/hal/key_mgr_hal.h b/components/hal/include/hal/key_mgr_hal.h similarity index 94% rename from components/hal/esp32p4/include/hal/key_mgr_hal.h rename to components/hal/include/hal/key_mgr_hal.h index 3bed3fa3fd1..8a3ca092dca 100644 --- a/components/hal/esp32p4/include/hal/key_mgr_hal.h +++ b/components/hal/include/hal/key_mgr_hal.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -37,11 +37,11 @@ void key_mgr_hal_set_key_usage(const esp_key_mgr_key_type_t key_type, const esp_ */ esp_key_mgr_key_usage_t key_mgr_hal_get_key_usage(const esp_key_mgr_key_type_t key_type); -/* @brief Configure the key purpose to be used by the Key Manager for key generator opearation */ +/* @brief Configure the key purpose to be used by the Key Manager for key generator operation */ void key_mgr_hal_set_key_purpose(const esp_key_mgr_key_purpose_t key_purpose); /** - * @bfief Configure the mode which is used by the Key Manager for the generator key deployement process + * @bfief Configure the mode which is used by the Key Manager for the generator key deployment process */ void key_mgr_hal_set_key_generator_mode(const esp_key_mgr_key_generator_mode_t mode); @@ -131,11 +131,11 @@ uint32_t key_mgr_hal_get_date_info(void); /** * @brief Set the Key Manager date information - * Only the least siginificant 28 bits shall be considered + * Only the least significant 28 bits shall be considered */ void key_mgr_hal_set_date_info(const uint32_t date_info); #ifdef __cplusplus } #endif -#endif +#endif /* SOC_KEY_MANAGER_SUPPORTED */ diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index e7456fe6470..70fab9c6755 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -1179,6 +1179,14 @@ config SOC_EFUSE_ECDSA_KEY bool default y +config SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY + bool + default y + +config SOC_KEY_MANAGER_FE_KEY_DEPLOY + bool + default y + config SOC_SECURE_BOOT_V2_ECC bool default y diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index bf0f144012f..edafca62797 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -499,6 +499,10 @@ // #define SOC_EFUSE_DIS_ICACHE 1 #define SOC_EFUSE_ECDSA_KEY 1 +/*-------------------------- Key Manager CAPS----------------------------*/ +#define SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY 1 /*!< Key manager responsible to deploy ECDSA key */ +#define SOC_KEY_MANAGER_FE_KEY_DEPLOY 1 /*!< Key manager responsible to deploy Flash Encryption key */ + /*-------------------------- Secure Boot CAPS----------------------------*/ #define SOC_SECURE_BOOT_V2_ECC 1 #define SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS 3 diff --git a/components/soc/esp32c5/register/soc/keymng_reg.h b/components/soc/esp32c5/register/soc/keymng_reg.h index 48324b814cb..66ab3903733 100644 --- a/components/soc/esp32c5/register/soc/keymng_reg.h +++ b/components/soc/esp32c5/register/soc/keymng_reg.h @@ -147,6 +147,22 @@ extern "C" { #define KEYMNG_USE_EFUSE_KEY_M (KEYMNG_USE_EFUSE_KEY_V << KEYMNG_USE_EFUSE_KEY_S) #define KEYMNG_USE_EFUSE_KEY_V 0x0000001FU #define KEYMNG_USE_EFUSE_KEY_S 0 + +/* KEYMNG_USE_EFUSE_KEY_ECDSA : R/W ;bitpos:[0] ;default: 1'd0 ; */ +/*description: Set this bit to choose efuse key instead of key manager deployed key for ecdsa.*/ +#define KEYMNG_USE_EFUSE_KEY_ECDSA (BIT(0)) +#define KEYMNG_USE_EFUSE_KEY_ECDSA_M ((KEYMNG_USE_EFUSE_KEY_ECDSA_V)<<(KEYMNG_USE_EFUSE_KEY_ECDSA_S)) +#define KEYMNG_USE_EFUSE_KEY_ECDSA_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_ECDSA_S 0 + +/* KEYMNG_USE_EFUSE_KEY_FLASH : R/W ;bitpos:[1] ;default: 1'd0 ; */ +/*description: Set this bit to choose efuse key instead of key manager deployed key for flash.*/ +#define KEYMNG_USE_EFUSE_KEY_FLASH (BIT(1)) +#define KEYMNG_USE_EFUSE_KEY_FLASH_M ((KEYMNG_USE_EFUSE_KEY_FLASH_V)<<(KEYMNG_USE_EFUSE_KEY_FLASH_S)) +#define KEYMNG_USE_EFUSE_KEY_FLASH_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_FLASH_S 1 + + /** KEYMNG_RND_SWITCH_CYCLE : R/W; bitpos: [9:5]; default: 15; * The core clock cycle number to sample one rng input data. Please set it bigger than * the clock cycle ratio: T_rng/T_km @@ -191,6 +207,23 @@ extern "C" { #define KEYMNG_USE_EFUSE_KEY_LOCK_M (KEYMNG_USE_EFUSE_KEY_LOCK_V << KEYMNG_USE_EFUSE_KEY_LOCK_S) #define KEYMNG_USE_EFUSE_KEY_LOCK_V 0x0000001FU #define KEYMNG_USE_EFUSE_KEY_LOCK_S 0 + +/* KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA : R/W1 ;bitpos:[0] ;default: 1'd0 ; */ +/*description: Write 1 to lock reg_use_efuse_key for esdsa*/ + +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA (BIT(0)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_M ((KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V)<<(KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_S)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_LOCK_ECDSA_S 0 + +/* KEYMNG_USE_EFUSE_KEY_LOCK_FLASH : R/W1 ;bitpos:[1] ;default: 1'd0 ; */ +/*description: Write 1 to lock reg_use_efuse_key for FLASH*/ + +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH (BIT(1)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_M ((KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V)<<(KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_S)) +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_V 0x1 +#define KEYMNG_USE_EFUSE_KEY_LOCK_FLASH_S 1 + /** KEYMNG_RND_SWITCH_CYCLE_LOCK : R/W1; bitpos: [5]; default: 0; * Write 1 to lock reg_rnd_switch_cycle. */ From 82db0feab2d6e51556f0f76a46cffb677ed6017e Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 1 Oct 2024 22:10:57 +0530 Subject: [PATCH 15/70] fix(security): Update key manager specific initializations for esp32c5 --- .../include/esp_flash_encrypt.h | 2 ++ .../flash_encryption_secure_features.c | 34 +++++++------------ .../src/flash_encryption/flash_encrypt.c | 3 +- components/esp_security/src/init.c | 12 ++----- components/hal/ecdsa_hal.c | 12 +------ .../hal/esp32c5/include/hal/key_mgr_ll.h | 5 ++- .../include/hal/mspi_timing_tuning_ll.h | 7 ++-- 7 files changed, 27 insertions(+), 48 deletions(-) diff --git a/components/bootloader_support/include/esp_flash_encrypt.h b/components/bootloader_support/include/esp_flash_encrypt.h index e942d7f54d7..efc061edf50 100644 --- a/components/bootloader_support/include/esp_flash_encrypt.h +++ b/components/bootloader_support/include/esp_flash_encrypt.h @@ -184,12 +184,14 @@ void esp_flash_encryption_init_checks(void); */ esp_err_t esp_flash_encryption_enable_secure_features(void); +#if CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY /** @brief Enable the key manager for flash encryption * * @return * - ESP_OK - On success */ esp_err_t esp_flash_encryption_enable_key_mgr(void); +#endif // CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY #endif /* BOOTLOADER_BUILD && CONFIG_SECURE_FLASH_ENC_ENABLED */ diff --git a/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c b/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c index 03af18a1dbf..ad90f306c01 100644 --- a/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c +++ b/components/bootloader_support/src/esp32c5/flash_encryption_secure_features.c @@ -11,9 +11,8 @@ #include "esp_efuse_table.h" #include "esp_log.h" #include "sdkconfig.h" -#include "soc/keymng_reg.h" -#include "soc/pcr_reg.h" -#include "soc/pcr_struct.h" +#include "hal/key_mgr_ll.h" +#include "hal/mspi_timing_tuning_ll.h" static __attribute__((unused)) const char *TAG = "flash_encrypt"; @@ -62,30 +61,21 @@ esp_err_t esp_flash_encryption_enable_secure_features(void) return ESP_OK; } -// TODO: Update to use LL APIs once key manager support added in IDF-8621 esp_err_t esp_flash_encryption_enable_key_mgr(void) { - // Set the force power down bit to 0 to enable key manager - PCR.km_pd_ctrl.km_mem_force_pd = 0; - // Reset the key manager - PCR.km_conf.km_clk_en = 1; - PCR.km_conf.km_rst_en = 1; - PCR.km_conf.km_rst_en = 0; + // Enable and reset key manager + // To suppress build errors about spinlock's __DECLARE_RCC_ATOMIC_ENV + int __DECLARE_RCC_ATOMIC_ENV __attribute__ ((unused)); + key_mgr_ll_enable_bus_clock(true); + key_mgr_ll_enable_peripheral_clock(true); + key_mgr_ll_reset_register(); - // Wait for key manager to be ready - while (!PCR.km_conf.km_ready) { + while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { }; - // Wait for key manager state machine to be idle - while (REG_READ(KEYMNG_STATE_REG) != 0) { - }; - - // Set the key manager to use efuse key - REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY, 2); - - // Reset MSPI to re-load the flash encryption key - REG_SET_BIT(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); - REG_CLR_BIT(PCR_MSPI_CLK_CONF_REG, PCR_MSPI_AXI_RST_EN); + // Force Key Manager to use eFuse key for XTS-AES operation + key_mgr_ll_set_key_usage(ESP_KEY_MGR_XTS_AES_128_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); + _mspi_timing_ll_reset_mspi(); return ESP_OK; } diff --git a/components/bootloader_support/src/flash_encryption/flash_encrypt.c b/components/bootloader_support/src/flash_encryption/flash_encrypt.c index 92bc72b21f6..810cd36c2d1 100644 --- a/components/bootloader_support/src/flash_encryption/flash_encrypt.c +++ b/components/bootloader_support/src/flash_encryption/flash_encrypt.c @@ -258,8 +258,7 @@ esp_err_t esp_flash_encrypt_contents(void) REG_WRITE(SENSITIVE_XTS_AES_KEY_UPDATE_REG, 1); #endif -// TODO: Remove C5 target config after key manager LL support- see IDF-8621 -#if CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY || CONFIG_IDF_TARGET_ESP32C5 +#if CONFIG_SOC_KEY_MANAGER_FE_KEY_DEPLOY esp_flash_encryption_enable_key_mgr(); #endif diff --git a/components/esp_security/src/init.c b/components/esp_security/src/init.c index d00d0e9647f..d12e1fe3265 100644 --- a/components/esp_security/src/init.c +++ b/components/esp_security/src/init.c @@ -20,23 +20,15 @@ __attribute__((unused)) static const char *TAG = "esp_security"; static void esp_key_mgr_init(void) { - // The following operation makes the Key Manager to use eFuse key for ECDSA and XTS-AES operation by default - // This is to keep the default behavior same as the other chips - // If the Key Manager configuration is already locked then following operation does not have any effect + // The following code initializes the key manager. #if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY || SOC_KEY_MANAGER_FE_KEY_DEPLOY // Enable key manager clock // Using ll APIs which do not require critical section _key_mgr_ll_enable_bus_clock(true); _key_mgr_ll_enable_peripheral_clock(true); - + _key_mgr_ll_reset_register(); while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { }; -#if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY - key_mgr_ll_set_key_usage(ESP_KEY_MGR_ECDSA_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); -#endif -#if SOC_KEY_MANAGER_FE_KEY_DEPLOY - key_mgr_ll_set_key_usage(ESP_KEY_MGR_XTS_AES_128_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); -#endif #endif /* SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY || SOC_KEY_MANAGER_FE_KEY_DEPLOY */ } diff --git a/components/hal/ecdsa_hal.c b/components/hal/ecdsa_hal.c index 237a461f6d7..bec830e3914 100644 --- a/components/hal/ecdsa_hal.c +++ b/components/hal/ecdsa_hal.c @@ -14,13 +14,8 @@ #include "esp_random.h" #endif -// Need to remove in IDF-8621 -#if CONFIG_IDF_TARGET_ESP32C5 -#include "soc/keymng_reg.h" -#endif - #ifdef SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY -#include "hal/key_mgr_hal.h" +#include "hal/key_mgr_ll.h" #endif #define ECDSA_HAL_P192_COMPONENT_LEN 24 @@ -32,11 +27,6 @@ static void configure_ecdsa_periph(ecdsa_hal_config_t *conf) if (conf->use_km_key == 0) { efuse_hal_set_ecdsa_key(conf->efuse_key_blk); -// Need to remove in IDF-8621 -#if CONFIG_IDF_TARGET_ESP32C5 - REG_SET_FIELD(KEYMNG_STATIC_REG, KEYMNG_USE_EFUSE_KEY, 1); -#endif - #if SOC_KEY_MANAGER_ECDSA_KEY_DEPLOY // Force Key Manager to use eFuse key for XTS-AES operation key_mgr_ll_set_key_usage(ESP_KEY_MGR_ECDSA_KEY, ESP_KEY_MGR_USE_EFUSE_KEY); diff --git a/components/hal/esp32c5/include/hal/key_mgr_ll.h b/components/hal/esp32c5/include/hal/key_mgr_ll.h index 1076555f02b..f46c7c2e4cd 100644 --- a/components/hal/esp32c5/include/hal/key_mgr_ll.h +++ b/components/hal/esp32c5/include/hal/key_mgr_ll.h @@ -67,7 +67,10 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) #define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__) /** - * @brief Reset the Key Manager peripheral */ + * @brief Reset the Key Manager peripheral + * Note: Please use key_mgr_ll_reset_register which requires the critical section + * and do not use _key_mgr_ll_reset_register + */ static inline void _key_mgr_ll_reset_register(void) { PCR.km_conf.km_rst_en = 1; diff --git a/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h b/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h index c94ca974668..2d4416657fb 100644 --- a/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h +++ b/components/hal/esp32c5/include/hal/mspi_timing_tuning_ll.h @@ -68,8 +68,11 @@ static inline __attribute__((always_inline)) void mspi_ll_enable_bus_clock(bool */ static inline __attribute__((always_inline)) void _mspi_timing_ll_reset_mspi(void) { - PCR.mspi_conf.mspi_rst_en = 1; - PCR.mspi_conf.mspi_rst_en = 0; + PCR.mspi_clk_conf.mspi_axi_rst_en = 1; + PCR.mspi_clk_conf.mspi_axi_rst_en = 0; + // Wait for mspi to be ready + while (!PCR.mspi_conf.mspi_ready) { + }; } #ifdef __cplusplus From b0664a6f2ee54594505f2624a82deb3b66a099b5 Mon Sep 17 00:00:00 2001 From: Aditya Patwardhan Date: Tue, 1 Oct 2024 23:03:07 +0530 Subject: [PATCH 16/70] fix(hal): Fix key_mgr_ll_reset_register API the key_mgr_ll_reset_register API now waits till key manager state is IDLE --- .../hal/esp32p4/include/hal/key_mgr_ll.h | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/components/hal/esp32p4/include/hal/key_mgr_ll.h b/components/hal/esp32p4/include/hal/key_mgr_ll.h index 15923a67ffa..3aa13bc3631 100644 --- a/components/hal/esp32p4/include/hal/key_mgr_ll.h +++ b/components/hal/esp32p4/include/hal/key_mgr_ll.h @@ -54,19 +54,35 @@ static inline void _key_mgr_ll_enable_peripheral_clock(bool enable) #define key_mgr_ll_enable_peripheral_clock(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_enable_peripheral_clock(__VA_ARGS__) /** - * @brief Reset the Key Manager peripheral */ -static inline void key_mgr_ll_reset_register(void) + * @brief Read state of Key Manager + * + * @return esp_key_mgr_state_t + */ +static inline esp_key_mgr_state_t key_mgr_ll_get_state(void) +{ + return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE); +} + +/** + * @brief Reset the Key Manager peripheral + * Note: Please use key_mgr_ll_reset_register which requires the critical section + * and do not use _key_mgr_ll_reset_register + */ +static inline void _key_mgr_ll_reset_register(void) { HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 1; HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_km = 0; // Clear reset on parent crypto, otherwise Key Manager is held in reset HP_SYS_CLKRST.hp_rst_en2.reg_rst_en_crypto = 0; + + while (key_mgr_ll_get_state() != ESP_KEY_MGR_STATE_IDLE) { + }; } /// use a macro to wrap the function, force the caller to use it in a critical section /// the critical section needs to declare the __DECLARE_RCC_ATOMIC_ENV variable in advance -#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; key_mgr_ll_reset_register(__VA_ARGS__) +#define key_mgr_ll_reset_register(...) (void)__DECLARE_RCC_ATOMIC_ENV; _key_mgr_ll_reset_register(__VA_ARGS__) /* @brief Start the key manager at IDLE state */ static inline void key_mgr_ll_start(void) @@ -323,16 +339,6 @@ static inline esp_key_mgr_xts_aes_key_len_t key_mgr_ll_get_xts_aes_key_len(void) return (esp_key_mgr_xts_aes_key_len_t) REG_GET_FIELD(KEYMNG_STATIC_REG, KEYMNG_XTS_AES_KEY_LEN); } -/** - * @brief Read state of Key Manager - * - * @return esp_key_mgr_state_t - */ -static inline esp_key_mgr_state_t key_mgr_ll_get_state(void) -{ - return (esp_key_mgr_state_t) REG_GET_FIELD(KEYMNG_STATE_REG, KEYMNG_STATE); -} - /** * @brief Read the Key Manager date information */ From 7fdfa6c22776d79f639c99f5fbb5f8f1f3011639 Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Thu, 24 Oct 2024 14:38:13 +0800 Subject: [PATCH 17/70] fix(esp_hw_support): disable unused clock sources after rtc clock switching complete --- components/esp_system/port/soc/esp32c5/clk.c | 6 ++++++ components/esp_system/port/soc/esp32c6/clk.c | 9 +++++++++ components/esp_system/port/soc/esp32c61/clk.c | 6 ++++++ components/esp_system/port/soc/esp32h2/clk.c | 9 +++++++++ components/esp_system/port/soc/esp32p4/clk.c | 9 +++++++++ 5 files changed, 39 insertions(+) diff --git a/components/esp_system/port/soc/esp32c5/clk.c b/components/esp_system/port/soc/esp32c5/clk.c index 7bf484cab4e..3060995a569 100644 --- a/components/esp_system/port/soc/esp32c5/clk.c +++ b/components/esp_system/port/soc/esp32c5/clk.c @@ -164,6 +164,12 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. diff --git a/components/esp_system/port/soc/esp32c6/clk.c b/components/esp_system/port/soc/esp32c6/clk.c index 23a8ddab32f..36e023cd561 100644 --- a/components/esp_system/port/soc/esp32c6/clk.c +++ b/components/esp_system/port/soc/esp32c6/clk.c @@ -185,6 +185,15 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_RC32K) { + rtc_clk_rc32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. diff --git a/components/esp_system/port/soc/esp32c61/clk.c b/components/esp_system/port/soc/esp32c61/clk.c index 035cc1c87f3..7e865037ab6 100644 --- a/components/esp_system/port/soc/esp32c61/clk.c +++ b/components/esp_system/port/soc/esp32c61/clk.c @@ -148,6 +148,12 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. diff --git a/components/esp_system/port/soc/esp32h2/clk.c b/components/esp_system/port/soc/esp32h2/clk.c index 02aa13411a0..026fd5c19ea 100644 --- a/components/esp_system/port/soc/esp32h2/clk.c +++ b/components/esp_system/port/soc/esp32h2/clk.c @@ -184,6 +184,15 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K && rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_OSC_SLOW) { + rtc_clk_32k_enable(false); + } + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_RC32K) { + rtc_clk_rc32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. diff --git a/components/esp_system/port/soc/esp32p4/clk.c b/components/esp_system/port/soc/esp32p4/clk.c index fabbfe22ed0..bb9a6e0aa51 100644 --- a/components/esp_system/port/soc/esp32p4/clk.c +++ b/components/esp_system/port/soc/esp32p4/clk.c @@ -189,6 +189,15 @@ static void select_rtc_slow_clk(soc_rtc_slow_clk_src_t rtc_slow_clk_src) } rtc_clk_slow_src_set(rtc_slow_clk_src); + // Disable unused clock sources after clock source switching is complete. + // Regardless of the clock source selection, the internal 136K clock source will always keep on. + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_XTAL32K) { + rtc_clk_32k_enable(false); + } + if (rtc_slow_clk_src != SOC_RTC_SLOW_CLK_SRC_RC32K) { + rtc_clk_rc32k_enable(false); + } + if (SLOW_CLK_CAL_CYCLES > 0) { /* TODO: 32k XTAL oscillator has some frequency drift at startup. * Improve calibration routine to wait until the frequency is stable. From 7df8467be5aee332a9a9d90b7fc37638875795cd Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Thu, 24 Oct 2024 13:39:05 +0800 Subject: [PATCH 18/70] feat(ledc): added a multi device test for testing ledc output in sleep --- .../test_apps/ledc/main/CMakeLists.txt | 5 +- .../test_apps/ledc/main/idf_component.yml | 3 + .../test_apps/ledc/main/test_ledc_sleep.c | 64 ++++++++++++++++++- .../test_apps/ledc/main/test_ledc_utils.h | 3 +- .../test_apps/ledc/pytest_ledc.py | 16 +++++ 5 files changed, 87 insertions(+), 4 deletions(-) create mode 100644 components/esp_driver_ledc/test_apps/ledc/main/idf_component.yml diff --git a/components/esp_driver_ledc/test_apps/ledc/main/CMakeLists.txt b/components/esp_driver_ledc/test_apps/ledc/main/CMakeLists.txt index 0348cc26f6c..8aeea8c40d0 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/CMakeLists.txt +++ b/components/esp_driver_ledc/test_apps/ledc/main/CMakeLists.txt @@ -1,8 +1,11 @@ set(srcs "test_app_main.c" "test_ledc.c" - "test_ledc_sleep.c" "test_ledc_utils.c") +if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED) + list(APPEND srcs "test_ledc_sleep.c") +endif() + # 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( diff --git a/components/esp_driver_ledc/test_apps/ledc/main/idf_component.yml b/components/esp_driver_ledc/test_apps/ledc/main/idf_component.yml new file mode 100644 index 00000000000..f5001494e21 --- /dev/null +++ b/components/esp_driver_ledc/test_apps/ledc/main/idf_component.yml @@ -0,0 +1,3 @@ +dependencies: + test_utils: + path: ${IDF_PATH}/tools/unit-test-app/components/test_utils diff --git a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.c b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.c index 55d3e99a212..c3c57a4e032 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.c +++ b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_sleep.c @@ -5,6 +5,7 @@ */ #include "unity.h" +#include "test_utils.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "driver/ledc.h" @@ -15,6 +16,7 @@ #include "esp_private/esp_pmu.h" #include "soc/ledc_periph.h" #include "esp_private/sleep_retention.h" +#include "esp_rom_uart.h" // Note. Test cases in this file cannot run one after another without reset @@ -51,7 +53,7 @@ static void test_ledc_sleep_retention(bool allow_pd) #endif TEST_ESP_OK(esp_sleep_enable_timer_wakeup(2 * 1000 * 1000)); - printf("go to light sleep for 2 seconds\n"); + printf("Go to light sleep for 2 seconds\n"); TEST_ESP_OK(esp_light_sleep_start()); printf("Waked up! Let's see if LEDC peripheral can still work...\n"); @@ -59,7 +61,7 @@ static void test_ledc_sleep_retention(bool allow_pd) TEST_ESP_OK(sleep_cpu_configure(false)); #endif - printf("check if the sleep happened as expected\r\n"); + printf("Check if the sleep happened as expected\r\n"); TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); #if SOC_PMU_SUPPORTED // check if the TOP power domain on/off as desired @@ -97,3 +99,61 @@ TEST_CASE("ledc can output after light sleep (LEDC power domain pd)", "[ledc]") sleep_retention_module_deinit(module); } #endif + +#if SOC_PCNT_SUPPORTED +static const ledc_clk_src_t test_ledc_clk_in_slp[] = { + LEDC_USE_RC_FAST_CLK, +#if SOC_LEDC_SUPPORT_XTAL_CLOCK + LEDC_USE_XTAL_CLK, +#endif +}; + +static const int test_clks_num = sizeof(test_ledc_clk_in_slp) / sizeof(test_ledc_clk_in_slp[0]); + +static void ledc_output_monitor(void) +{ + setup_testbench(); + + for (int i = 0; i < test_clks_num; i++) { + unity_wait_for_signal("Go to light sleep for 3 seconds"); + vTaskDelay(500 / portTICK_PERIOD_MS); + int pulse_count = wave_count(1000); + uint32_t acceptable_delta = (test_ledc_clk_in_slp[i] == (ledc_clk_src_t)LEDC_USE_RC_FAST_CLK) ? 20 : 5; // RC_FAST as the clk src has a bigger error range is reasonable + TEST_ASSERT_UINT32_WITHIN(acceptable_delta, TEST_PWM_LOW_FREQ, pulse_count); + unity_wait_for_signal("Waked up!"); + } + + tear_testbench(); +} + +static void ledc_output_in_sleep(void) +{ + TEST_ESP_OK(esp_sleep_enable_timer_wakeup(3 * 1000 * 1000)); + + ledc_channel_config_t ledc_ch_config = initialize_channel_config(); + ledc_ch_config.speed_mode = LEDC_LOW_SPEED_MODE; + ledc_ch_config.sleep_mode = LEDC_SLEEP_MODE_KEEP_ALIVE; + TEST_ESP_OK(ledc_channel_config(&ledc_ch_config)); + + for (int i = 0; i < test_clks_num; i++) { + ledc_timer_config_t ledc_time_config = create_default_timer_config(); + ledc_time_config.speed_mode = LEDC_LOW_SPEED_MODE; + ledc_time_config.clk_cfg = test_ledc_clk_in_slp[i]; + ledc_time_config.freq_hz = TEST_PWM_LOW_FREQ; + TEST_ESP_OK(ledc_timer_config(&ledc_time_config)); + + TEST_ESP_OK(ledc_update_duty(ledc_ch_config.speed_mode, ledc_ch_config.channel)); + + unity_send_signal("Go to light sleep for 3 seconds"); + esp_rom_output_tx_wait_idle(CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM); // wait until the signal sent + TEST_ESP_OK(esp_light_sleep_start()); + unity_send_signal("Waked up!"); + + TEST_ESP_OK(ledc_timer_pause(ledc_time_config.speed_mode, ledc_time_config.timer_num)); + ledc_time_config.deconfigure = 1; + TEST_ESP_OK(ledc_timer_config(&ledc_time_config)); + } +} + +TEST_CASE_MULTIPLE_DEVICES("ledc can output during light sleep", "[ledc][test_env=generic_multi_device]", ledc_output_in_sleep, ledc_output_monitor); +#endif // SOC_PCNT_SUPPORTED diff --git a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.h b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.h index 23043b2f721..d3c3c7e6436 100644 --- a/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.h +++ b/components/esp_driver_ledc/test_apps/ledc/main/test_ledc_utils.h @@ -9,7 +9,8 @@ #define PULSE_IO 5 -#define TEST_PWM_FREQ 2000 +#define TEST_PWM_FREQ 2000 +#define TEST_PWM_LOW_FREQ 200 #if SOC_LEDC_SUPPORT_HS_MODE #define TEST_SPEED_MODE LEDC_HIGH_SPEED_MODE diff --git a/components/esp_driver_ledc/test_apps/ledc/pytest_ledc.py b/components/esp_driver_ledc/test_apps/ledc/pytest_ledc.py index 0b7ae925e90..22687a67fc9 100644 --- a/components/esp_driver_ledc/test_apps/ledc/pytest_ledc.py +++ b/components/esp_driver_ledc/test_apps/ledc/pytest_ledc.py @@ -32,3 +32,19 @@ def test_ledc(dut: IdfDut) -> None: ) def test_ledc_psram(dut: IdfDut) -> None: dut.run_all_single_board_cases(reset=True) + + +@pytest.mark.supported_targets +@pytest.mark.temp_skip_ci(targets=['esp32s3', 'esp32c61'], + reason='s3 multi device runner has no psram, c61 lack of runner IDF-10949') +@pytest.mark.generic_multi_device +@pytest.mark.parametrize( + 'count, config', + [ + (2, 'iram_safe',), + (2, 'release',), + ], + indirect=True +) +def test_ledc_multi_device(case_tester) -> None: # type: ignore + case_tester.run_all_multi_dev_cases(reset=True) From d998d76627563c04e3db2e534cd514f3a35f0b46 Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 28 Oct 2024 10:17:21 +0100 Subject: [PATCH 19/70] change(version): Update version to v5.5-dev --- .gitlab/ci/common.yml | 8 ++++---- components/esp_common/include/esp_idf_version.h | 2 +- tools/cmake/version.cmake | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index 1813baefd8b..0868139e2ed 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -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.4:1" - ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v5.4:1-1" - TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.4:1" + ESP_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-env-v5.5:1" + ESP_IDF_DOC_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/esp-idf-doc-env-v5.5:1-1" + TARGET_TEST_ENV_IMAGE: "${CI_DOCKER_REGISTRY}/target-test-env-v5.5: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.4.txt" + CI_PYTHON_CONSTRAINT_FILE: "espidf.constraints.v5.5.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. diff --git a/components/esp_common/include/esp_idf_version.h b/components/esp_common/include/esp_idf_version.h index 74aea26b783..d5051726975 100644 --- a/components/esp_common/include/esp_idf_version.h +++ b/components/esp_common/include/esp_idf_version.h @@ -13,7 +13,7 @@ extern "C" { /** Major version number (X.x.x) */ #define ESP_IDF_VERSION_MAJOR 5 /** Minor version number (x.X.x) */ -#define ESP_IDF_VERSION_MINOR 4 +#define ESP_IDF_VERSION_MINOR 5 /** Patch version number (x.x.X) */ #define ESP_IDF_VERSION_PATCH 0 diff --git a/tools/cmake/version.cmake b/tools/cmake/version.cmake index 6293abcca1f..d2ea49e4b8e 100644 --- a/tools/cmake/version.cmake +++ b/tools/cmake/version.cmake @@ -1,5 +1,5 @@ set(IDF_VERSION_MAJOR 5) -set(IDF_VERSION_MINOR 4) +set(IDF_VERSION_MINOR 5) set(IDF_VERSION_PATCH 0) set(ENV{IDF_VERSION} "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}") From 52496491f8c92a606ebb50fa9cdcaba976371d9e Mon Sep 17 00:00:00 2001 From: Ivan Grokhotkov Date: Mon, 28 Oct 2024 10:34:21 +0100 Subject: [PATCH 20/70] change(ci): update LATEST_GIT_TAG to v5.5-dev --- .gitlab/ci/common.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/ci/common.yml b/.gitlab/ci/common.yml index 0868139e2ed..332a88438a8 100644 --- a/.gitlab/ci/common.yml +++ b/.gitlab/ci/common.yml @@ -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.4-dev + LATEST_GIT_TAG: v5.5-dev SUBMODULE_FETCH_TOOL: "tools/ci/ci_fetch_submodule.py" # by default we will fetch all submodules From 33d3c60b269f8d598527e09f12f574a0e252ce6f Mon Sep 17 00:00:00 2001 From: wuzhenghui Date: Sat, 12 Oct 2024 11:29:35 +0800 Subject: [PATCH 21/70] fix(esp_hw_support): skip some wakeup steps if sleep is rejected 1. Skip esp_timer time compensation to avoid introducing errors into rtc_timer 2. Ignore sleep_time_overhead_out measurements when sleep is rejected --- components/esp_hw_support/sleep_modes.c | 49 +++++++++++++------------ 1 file changed, 25 insertions(+), 24 deletions(-) diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 5bd82fdd367..9fc2886769e 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -1132,12 +1132,14 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_CLK_READY, (void *)0); if (!deep_sleep) { - s_config.ccount_ticks_record = esp_cpu_get_cycle_count(); + if (result == ESP_OK) { + s_config.ccount_ticks_record = esp_cpu_get_cycle_count(); #if SOC_PM_RETENTION_SW_TRIGGER_REGDMA - if (pd_flags & PMU_SLEEP_PD_TOP) { - sleep_retention_do_system_retention(false); - } + if (pd_flags & PMU_SLEEP_PD_TOP) { + sleep_retention_do_system_retention(false); + } #endif + } misc_modules_wake_prepare(pd_flags); } @@ -1298,7 +1300,7 @@ static esp_err_t esp_light_sleep_inner(uint32_t pd_flags, #endif // If SPI flash was powered down, wait for it to become ready - if (pd_flags & RTC_SLEEP_PD_VDDSDIO) { + if (!reject && (pd_flags & RTC_SLEEP_PD_VDDSDIO)) { #if SOC_PM_SUPPORT_TOP_PD if (pd_flags & PMU_SLEEP_PD_TOP) { uint32_t flash_ready_hw_waited_time_us = pmu_sleep_get_wakup_retention_cost(); @@ -1524,33 +1526,28 @@ esp_err_t esp_light_sleep_start(void) // Enter sleep, then wait for flash to be ready on wakeup err = esp_light_sleep_inner(pd_flags, flash_enable_time_us); } -#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW - if (err != ESP_OK) { - esp_sleep_cpu_skip_retention(); - } -#endif // light sleep wakeup flag only makes sense after a successful light sleep s_light_sleep_wakeup = (err == ESP_OK); // System timer has been stopped for the duration of the sleep, correct for that. uint64_t rtc_ticks_at_end = rtc_time_get(); - uint64_t rtc_time_diff = rtc_time_slowclk_to_us(rtc_ticks_at_end - s_config.rtc_ticks_at_sleep_start, s_config.rtc_clk_cal_period); -#if CONFIG_ESP_SLEEP_DEBUG - if (s_sleep_ctx != NULL) { - s_sleep_ctx->sleep_out_rtc_time_stamp = rtc_ticks_at_end; - } + if (s_light_sleep_wakeup) { + uint64_t rtc_time_diff = rtc_time_slowclk_to_us(rtc_ticks_at_end - s_config.rtc_ticks_at_sleep_start, s_config.rtc_clk_cal_period); + /** + * If sleep duration is too small(less than 1 rtc_slow_clk cycle), rtc_time_diff will be zero. + * In this case, just ignore the time compensation and keep esp_timer monotonic. + */ + if (rtc_time_diff > 0) { + esp_timer_private_set(high_res_time_at_start + rtc_time_diff); + } + esp_set_time_from_rtc(); + } else { +#if !CONFIG_FREERTOS_UNICORE && ESP_SLEEP_POWER_DOWN_CPU && SOC_PM_CPU_RETENTION_BY_SW + esp_sleep_cpu_skip_retention(); #endif - - /** - * If sleep duration is too small(less than 1 rtc_slow_clk cycle), rtc_time_diff will be zero. - * In this case, just ignore the time compensation and keep esp_timer monotonic. - */ - if (rtc_time_diff > 0) { - esp_timer_private_set(high_res_time_at_start + rtc_time_diff); } - esp_set_time_from_rtc(); esp_clk_private_unlock(); esp_timer_private_unlock(); @@ -1585,14 +1582,18 @@ esp_err_t esp_light_sleep_start(void) #endif // CONFIG_ESP_TASK_WDT_USE_ESP_TIMER esp_sleep_execute_event_callbacks(SLEEP_EVENT_SW_EXIT_SLEEP, (void *)0); - s_config.sleep_time_overhead_out = (esp_cpu_get_cycle_count() - s_config.ccount_ticks_record) / (esp_clk_cpu_freq() / 1000000ULL); #if CONFIG_ESP_SLEEP_DEBUG if (s_sleep_ctx != NULL) { + s_sleep_ctx->sleep_out_rtc_time_stamp = rtc_ticks_at_end; s_sleep_ctx->sleep_request_result = err; } #endif + if (s_light_sleep_wakeup) { + s_config.sleep_time_overhead_out = (esp_cpu_get_cycle_count() - s_config.ccount_ticks_record) / (esp_clk_cpu_freq() / 1000000ULL); + } + portEXIT_CRITICAL(&s_config.lock); return err; } From d092c1ba55d3ff4932572ba4e69c21d963e422e2 Mon Sep 17 00:00:00 2001 From: xuxiao Date: Mon, 21 Oct 2024 17:50:35 +0800 Subject: [PATCH 22/70] feat(wifi): add wifi support for esp32c5 eco1 --- components/esp_phy/lib | 2 +- .../esp_rom/esp32c5/ld/esp32c5.rom.phy.ld | 12 ++++++--- .../esp_rom/esp32c5/ld/esp32c5.rom.pp.ld | 26 ++++++++++++------- components/esp_wifi/lib | 2 +- .../wifi/iperf/sdkconfig.defaults.esp32c5 | 2 +- 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/components/esp_phy/lib b/components/esp_phy/lib index 8fd02ff780e..27f09b16e73 160000 --- a/components/esp_phy/lib +++ b/components/esp_phy/lib @@ -1 +1 @@ -Subproject commit 8fd02ff780e977e76e7ed78619629c8344f0fc50 +Subproject commit 27f09b16e732518b52c2ad4ff3ccfadefb21a809 diff --git a/components/esp_rom/esp32c5/ld/esp32c5.rom.phy.ld b/components/esp_rom/esp32c5/ld/esp32c5.rom.phy.ld index 9bd20793bee..3c61a264b03 100644 --- a/components/esp_rom/esp32c5/ld/esp32c5.rom.phy.ld +++ b/components/esp_rom/esp32c5/ld/esp32c5.rom.phy.ld @@ -284,10 +284,14 @@ phy_wifi_set_tx_gain = 0x400014f4; phy_bt_get_tx_tab_ = 0x400014f8; phy_bt_set_tx_gain = 0x400014fc; phy_bt_tx_gain_init = 0x40001500; -phy_pbus_xpd_rx_off = 0x40002518; -phy_i2c_writeReg_Mask = 0x4000787e; -phy_pbus_xpd_rx_on = 0x40002628; -phy_pbus_xpd_tx_on = 0x4000274c; +phy_pbus_xpd_rx_off = 0x40001528; +phy_i2c_writeReg_Mask = 0x4000152c; +phy_pbus_xpd_rx_on = 0x40001530; +phy_pbus_xpd_tx_on = 0x40001534; +phy_get_romfuncs = 0x40001538; +phy_chip_set_chan_ana_ = 0x4000153c; +phy_pbus_xpd_tx_off = 0x40001540; /* Data (.data, .bss, .rodata) */ phy_rom_phyFuns = 0x4085fb80; phy_param_rom = 0x4085fc70; +phy_rom_phyFuns_eco1 = 0x4085fc6c; diff --git a/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld b/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld index 96c501f990e..b63edf3cf51 100644 --- a/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld +++ b/components/esp_rom/esp32c5/ld/esp32c5.rom.pp.ld @@ -32,7 +32,7 @@ hal_mac_tx_clr_mplen = 0x40000c10; hal_mac_get_txq_state = 0x40000c14; hal_mac_clr_txq_state = 0x40000c18; hal_mac_get_txq_complete = 0x40000c1c; -/*hal_mac_deinit_twt_tx = 0x40000c20;*/ +hal_mac_deinit_twt_tx = 0x40000c20; hal_mac_is_dma_enable = 0x40000c24; /*hal_he_get_bss_color = 0x40000c28;*/ hal_he_set_ersu = 0x40000c2c; @@ -62,7 +62,7 @@ ic_get_he_rts_threshold_bytes = 0x40000c88; lmacAdjustTimestamp = 0x40000c8c; lmacDiscardAgedMSDU = 0x40000c90; lmacDiscardMSDU = 0x40000c94; -/*lmacEndFrameExchangeSequence = 0x40000c98;*/ +lmacEndFrameExchangeSequence = 0x40000c98; lmacIsIdle = 0x40000c9c; lmacIsLongFrame = 0x40000ca0; lmacMSDUAged = 0x40000ca4; @@ -74,19 +74,19 @@ lmacReachLongLimit = 0x40000cb8; lmacReachShortLimit = 0x40000cbc; lmacRecycleMPDU = 0x40000cc0; lmacRxDone = 0x40000cc4; -/*lmacSetTxFrame = 0x40000cc8;*/ +lmacSetTxFrame = 0x40000cc8; lmacTxDone = 0x40000ccc; lmacTxFrame = 0x40000cd0; lmacDisableTransmit = 0x40000cd4; lmacDiscardFrameExchangeSequence = 0x40000cd8; lmacProcessCollision = 0x40000cdc; lmacProcessAckTimeout = 0x40000ce0; -/*lmacProcessShortRetryFail = 0x40000ce4;*/ +lmacProcessShortRetryFail = 0x40000ce4; lmacProcessCollisions_task = 0x40000ce8; lmacProcessTxRtsError = 0x40000cec; lmacProcessTxError = 0x40000cf0; lmacProcessCtsTimeout = 0x40000cf4; -/*lmacProcessLongRetryFail = 0x40000cf8;*/ +lmacProcessLongRetryFail = 0x40000cf8; lmacRetryTxFrame = 0x40000cfc; lmacEndRetryAMPDUFail = 0x40000d00; lmacProcessTxSuccess = 0x40000d04; @@ -145,13 +145,13 @@ pm_disconnected_wake = 0x40000dd4; /*pm_tx_data_process = 0x40000dd8;*/ pm_is_twt_awake = 0x40000ddc; pm_enable_twt_keep_alive = 0x40000de0; -/*pm_twt_on_tsf_timer = 0x40000de4;*/ +pm_twt_on_tsf_timer = 0x40000de4; pm_twt_process = 0x40000de8; pm_is_twt_start = 0x40000dec; pm_twt_set_target_wdev_time = 0x40000df0; pm_twt_set_target_tsf = 0x40000df4; pm_enable_twt_keep_alive_timer = 0x40000df8; -/*pm_mac_try_enable_modem_state = 0x40000dfc;*/ +pm_mac_try_enable_modem_state = 0x40000dfc; pm_beacon_monitor_tbtt_timeout_process = 0x40000e00; /*pm_update_next_tbtt = 0x40000e04;*/ pm_twt_disallow_tx = 0x40000e08; @@ -209,11 +209,11 @@ ppDisableQueue = 0x40000ed4; ppCalVHTDeliNum = 0x40000ed8; ppCalTxVHTSMPDULength = 0x40000edc; ppCheckTxRTS = 0x40000ee0; -/*ppProcessLifeTime = 0x40000ee4;*/ +ppProcessLifeTime = 0x40000ee4; ppProcTxCallback = 0x40000ee8; ppCalPreFecPaddingFactor = 0x40000eec; ppCalDeliNum = 0x40000ef0; -/*ppRemoveHTC = 0x40000ef4;*/ +ppRemoveHTC = 0x40000ef4; ppCheckTxHEAMPDUlength = 0x40000ef8; ppCertSetRate = 0x40000efc; ppSelectTxFormat = 0x40000f00; @@ -260,7 +260,7 @@ trcAmpduSetState = 0x40000fa0; trc_set_bf_report_rate = 0x40000fa4; trc_onPPTxDone = 0x40000fa8; wDevCheckBlockError = 0x40000fac; -/*wDev_AppendRxBlocks = 0x40000fb0;*/ +wDev_AppendRxBlocks = 0x40000fb0; wDev_DiscardFrame = 0x40000fb4; wDev_GetNoiseFloor = 0x40000fb8; wDev_IndicateAmpdu = 0x40000fbc; @@ -335,6 +335,12 @@ is_use_muedca = 0x400010cc; pwr_hal_clear_mac_modem_state_wakeup_protect_signal = 0x400010d0; get_estimated_batime = 0x400010d4; get_sublen_offset = 0x400010d8; +pm_coex_schm_overall_period_get = 0x40001504; +ppRemoveHEAMPDUflags = 0x4000150c; +tsf_hal_get_tbtt_interval = 0x40001510; +pm_get_tbtt_count = 0x4000151c; +tsf_hal_get_time = 0x40001520; +tsf_hal_get_counter_value = 0x40001524; /* Data (.data, .bss, .rodata) */ our_instances_ptr = 0x4004ffe0; pTxRx = 0x4085ff74; diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 952d21c8d1b..9532814f141 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 952d21c8d1b5de2d966e3a0010317c41b060baad +Subproject commit 9532814f14186bd643b2d8a65c957ed985a5ddee diff --git a/examples/wifi/iperf/sdkconfig.defaults.esp32c5 b/examples/wifi/iperf/sdkconfig.defaults.esp32c5 index 7c3a67ad310..338b88f5700 100644 --- a/examples/wifi/iperf/sdkconfig.defaults.esp32c5 +++ b/examples/wifi/iperf/sdkconfig.defaults.esp32c5 @@ -12,7 +12,7 @@ CONFIG_ESP_WIFI_AMPDU_RX_ENABLED=y CONFIG_ESP_WIFI_RX_BA_WIN=22 CONFIG_ESP_WIFI_NVS_ENABLED=n -CONFIG_LWIP_TCP_SND_BUF_DEFAULT=57600 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=50400 CONFIG_LWIP_TCP_WND_DEFAULT=65535 CONFIG_LWIP_TCP_RECVMBOX_SIZE=48 CONFIG_LWIP_UDP_RECVMBOX_SIZE=64 From 21b38e8b9707dc8bdf47e04711e72c812946b82a Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Fri, 13 Sep 2024 14:14:49 +0800 Subject: [PATCH 23/70] feat(i2c_oled): adapt i2c_oled example to LVGL v9 This commit simplified the example and removed esp_lvgl_port component. And adapted example to LVGL v9. Closes https://github.com/espressif/esp-idf/issues/14179 --- .../lcd/i2c_oled/main/i2c_oled_example_main.c | 140 ++++++++++++++---- .../lcd/i2c_oled/main/idf_component.yml | 3 +- .../lcd/i2c_oled/main/lvgl_demo_ui.c | 10 +- .../lcd/i2c_oled/sdkconfig.defaults | 5 +- 4 files changed, 124 insertions(+), 34 deletions(-) diff --git a/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c b/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c index 1276da8aefe..098c62d66ce 100644 --- a/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c +++ b/examples/peripherals/lcd/i2c_oled/main/i2c_oled_example_main.c @@ -5,14 +5,16 @@ */ #include +#include +#include #include "freertos/FreeRTOS.h" #include "freertos/task.h" +#include "esp_timer.h" #include "esp_lcd_panel_io.h" #include "esp_lcd_panel_ops.h" #include "esp_err.h" #include "esp_log.h" #include "driver/i2c_master.h" -#include "esp_lvgl_port.h" #include "lvgl.h" #if CONFIG_EXAMPLE_LCD_CONTROLLER_SH1107 @@ -46,8 +48,81 @@ static const char *TAG = "example"; #define EXAMPLE_LCD_CMD_BITS 8 #define EXAMPLE_LCD_PARAM_BITS 8 +#define EXAMPLE_LVGL_TICK_PERIOD_MS 5 +#define EXAMPLE_LVGL_TASK_STACK_SIZE (4 * 1024) +#define EXAMPLE_LVGL_TASK_PRIORITY 2 +#define EXAMPLE_LVGL_PALETTE_SIZE 8 + +// To use LV_COLOR_FORMAT_I1, we need an extra buffer to hold the converted data +static uint8_t oled_buffer[EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES / 8]; +// LVGL library is not thread-safe, this example will call LVGL APIs from different tasks, so use a mutex to protect it +static _lock_t lvgl_api_lock; + extern void example_lvgl_demo_ui(lv_disp_t *disp); +static bool example_notify_lvgl_flush_ready(esp_lcd_panel_io_handle_t io_panel, esp_lcd_panel_io_event_data_t *edata, void *user_ctx) +{ + lv_display_t *disp = (lv_display_t *)user_ctx; + lv_display_flush_ready(disp); + return false; +} + +static void example_lvgl_flush_cb(lv_display_t *disp, const lv_area_t *area, uint8_t *px_map) +{ + esp_lcd_panel_handle_t panel_handle = lv_display_get_user_data(disp); + + // This is necessary because LVGL reserves 2 x 4 bytes in the buffer, as these are assumed to be used as a palette. Skip the palette here + // More information about the monochrome, please refer to https://docs.lvgl.io/9.2/porting/display.html#monochrome-displays + px_map += EXAMPLE_LVGL_PALETTE_SIZE; + + uint16_t hor_res = lv_display_get_physical_horizontal_resolution(disp); + int x1 = area->x1; + int x2 = area->x2; + int y1 = area->y1; + int y2 = area->y2; + + for (int y = y1; y <= y2; y++) { + for (int x = x1; x <= x2; x++) { + /* The order of bits is MSB first + MSB LSB + bits 7 6 5 4 3 2 1 0 + pixels 0 1 2 3 4 5 6 7 + Left Right + */ + bool chroma_color = (px_map[(hor_res >> 3) * y + (x >> 3)] & 1 << (7 - x % 8)); + + /* Write to the buffer as required for the display. + * It writes only 1-bit for monochrome displays mapped vertically.*/ + uint8_t *buf = oled_buffer + hor_res * (y >> 3) + (x); + if (chroma_color) { + (*buf) &= ~(1 << (y % 8)); + } else { + (*buf) |= (1 << (y % 8)); + } + } + } + // pass the draw buffer to the driver + esp_lcd_panel_draw_bitmap(panel_handle, x1, y1, x2 + 1, y2 + 1, oled_buffer); +} + +static void example_increase_lvgl_tick(void *arg) +{ + /* Tell LVGL how many milliseconds has elapsed */ + lv_tick_inc(EXAMPLE_LVGL_TICK_PERIOD_MS); +} + +static void example_lvgl_port_task(void *arg) +{ + ESP_LOGI(TAG, "Starting LVGL task"); + uint32_t time_till_next_ms = 0; + while (1) { + _lock_acquire(&lvgl_api_lock); + time_till_next_ms = lv_timer_handler(); + _lock_release(&lvgl_api_lock); + usleep(1000 * time_till_next_ms); + } +} + void app_main(void) { ESP_LOGI(TAG, "Initialize I2C bus"); @@ -107,33 +182,48 @@ void app_main(void) #endif ESP_LOGI(TAG, "Initialize LVGL"); - const lvgl_port_cfg_t lvgl_cfg = ESP_LVGL_PORT_INIT_CONFIG(); - lvgl_port_init(&lvgl_cfg); - - const lvgl_port_display_cfg_t disp_cfg = { - .io_handle = io_handle, - .panel_handle = panel_handle, - .buffer_size = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES, - .double_buffer = true, - .hres = EXAMPLE_LCD_H_RES, - .vres = EXAMPLE_LCD_V_RES, - .monochrome = true, - .rotation = { - .swap_xy = false, - .mirror_x = false, - .mirror_y = false, - } + lv_init(); + // create a lvgl display + lv_display_t *display = lv_display_create(EXAMPLE_LCD_H_RES, EXAMPLE_LCD_V_RES); + // associate the i2c panel handle to the display + lv_display_set_user_data(display, panel_handle); + // create draw buffer + void *buf = NULL; + ESP_LOGI(TAG, "Allocate separate LVGL draw buffers"); + // LVGL reserves 2 x 4 bytes in the buffer, as these are assumed to be used as a palette. + size_t draw_buffer_sz = EXAMPLE_LCD_H_RES * EXAMPLE_LCD_V_RES / 8 + EXAMPLE_LVGL_PALETTE_SIZE; + buf = heap_caps_calloc(1, draw_buffer_sz, MALLOC_CAP_INTERNAL); + assert(buf); + + // LVGL9 suooprt new monochromatic format. + lv_display_set_color_format(display, LV_COLOR_FORMAT_I1); + // initialize LVGL draw buffers + lv_display_set_buffers(display, buf, NULL, draw_buffer_sz, LV_DISPLAY_RENDER_MODE_FULL); + // set the callback which can copy the rendered image to an area of the display + lv_display_set_flush_cb(display, example_lvgl_flush_cb); + + ESP_LOGI(TAG, "Register io panel event callback for LVGL flush ready notification"); + const esp_lcd_panel_io_callbacks_t cbs = { + .on_color_trans_done = example_notify_lvgl_flush_ready, }; - lv_disp_t *disp = lvgl_port_add_disp(&disp_cfg); + /* Register done callback */ + esp_lcd_panel_io_register_event_callbacks(io_handle, &cbs, display); - /* Rotation of the screen */ - lv_disp_set_rotation(disp, LV_DISP_ROT_NONE); + ESP_LOGI(TAG, "Use esp_timer as LVGL tick timer"); + const esp_timer_create_args_t lvgl_tick_timer_args = { + .callback = &example_increase_lvgl_tick, + .name = "lvgl_tick" + }; + esp_timer_handle_t lvgl_tick_timer = NULL; + ESP_ERROR_CHECK(esp_timer_create(&lvgl_tick_timer_args, &lvgl_tick_timer)); + ESP_ERROR_CHECK(esp_timer_start_periodic(lvgl_tick_timer, EXAMPLE_LVGL_TICK_PERIOD_MS * 1000)); + + ESP_LOGI(TAG, "Create LVGL task"); + xTaskCreate(example_lvgl_port_task, "LVGL", EXAMPLE_LVGL_TASK_STACK_SIZE, NULL, EXAMPLE_LVGL_TASK_PRIORITY, NULL); ESP_LOGI(TAG, "Display LVGL Scroll Text"); // Lock the mutex due to the LVGL APIs are not thread-safe - if (lvgl_port_lock(0)) { - example_lvgl_demo_ui(disp); - // Release the mutex - lvgl_port_unlock(); - } + _lock_acquire(&lvgl_api_lock); + example_lvgl_demo_ui(display); + _lock_release(&lvgl_api_lock); } diff --git a/examples/peripherals/lcd/i2c_oled/main/idf_component.yml b/examples/peripherals/lcd/i2c_oled/main/idf_component.yml index e7c49c66f6e..b8408dba26b 100644 --- a/examples/peripherals/lcd/i2c_oled/main/idf_component.yml +++ b/examples/peripherals/lcd/i2c_oled/main/idf_component.yml @@ -1,4 +1,3 @@ dependencies: - lvgl/lvgl: "8.3.0" + lvgl/lvgl: "9.2.0" esp_lcd_sh1107: "^1" - esp_lvgl_port: "^1" diff --git a/examples/peripherals/lcd/i2c_oled/main/lvgl_demo_ui.c b/examples/peripherals/lcd/i2c_oled/main/lvgl_demo_ui.c index 251ef5bc977..743711ea527 100644 --- a/examples/peripherals/lcd/i2c_oled/main/lvgl_demo_ui.c +++ b/examples/peripherals/lcd/i2c_oled/main/lvgl_demo_ui.c @@ -1,18 +1,18 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: CC0-1.0 */ #include "lvgl.h" -void example_lvgl_demo_ui(lv_disp_t *disp) +void example_lvgl_demo_ui(lv_display_t *disp) { - lv_obj_t *scr = lv_disp_get_scr_act(disp); + lv_obj_t *scr = lv_display_get_screen_active(disp); lv_obj_t *label = lv_label_create(scr); lv_label_set_long_mode(label, LV_LABEL_LONG_SCROLL_CIRCULAR); /* Circular scroll */ lv_label_set_text(label, "Hello Espressif, Hello LVGL."); - /* Size of the screen (if you use rotation 90 or 270, please set disp->driver->ver_res) */ - lv_obj_set_width(label, disp->driver->hor_res); + /* Size of the screen (if you use rotation 90 or 270, please use lv_display_get_vertical_resolution) */ + lv_obj_set_width(label, lv_display_get_horizontal_resolution(disp)); lv_obj_align(label, LV_ALIGN_TOP_MID, 0, 0); } diff --git a/examples/peripherals/lcd/i2c_oled/sdkconfig.defaults b/examples/peripherals/lcd/i2c_oled/sdkconfig.defaults index d92efacc716..dd302d9c638 100644 --- a/examples/peripherals/lcd/i2c_oled/sdkconfig.defaults +++ b/examples/peripherals/lcd/i2c_oled/sdkconfig.defaults @@ -1,5 +1,6 @@ # This file was generated using idf.py save-defconfig. It can be edited manually. # Espressif IoT Development Framework (ESP-IDF) Project Minimal Configuration # -CONFIG_LV_USE_USER_DATA=y -CONFIG_LV_COLOR_DEPTH_1=y +CONFIG_LV_CONF_SKIP=y +CONFIG_LV_USE_OBSERVER=y +CONFIG_LV_USE_SYSMON=y From 901812c589bdeb410d03617071bb6dc84dd9cdbd Mon Sep 17 00:00:00 2001 From: xuxiao Date: Tue, 29 Oct 2024 12:00:39 +0800 Subject: [PATCH 24/70] fix(ci): disable esp32c5 adc ci test --- .../templates/known_generate_test_child_pipeline_warnings.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/ci/dynamic_pipelines/templates/known_generate_test_child_pipeline_warnings.yml b/tools/ci/dynamic_pipelines/templates/known_generate_test_child_pipeline_warnings.yml index 70ff179d234..e0e3f61f174 100644 --- a/tools/ci/dynamic_pipelines/templates/known_generate_test_child_pipeline_warnings.yml +++ b/tools/ci/dynamic_pipelines/templates/known_generate_test_child_pipeline_warnings.yml @@ -21,6 +21,7 @@ no_runner_tags: - esp32c2,jtag,xtal_40mhz - esp32c3,flash_multi - esp32c3,sdcard_sdmode + - esp32c5,adc - esp32c5,generic - esp32c5,jtag - esp32c5,wifi_ap From c0e1ecd31098fd964988ddd22960e127148c58a4 Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Thu, 17 Oct 2024 12:42:16 +0800 Subject: [PATCH 25/70] docs(size): mention disabling console output to reduce binary size --- docs/en/api-guides/performance/size.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/en/api-guides/performance/size.rst b/docs/en/api-guides/performance/size.rst index f88f8a38bc9..65aa9504df4 100644 --- a/docs/en/api-guides/performance/size.rst +++ b/docs/en/api-guides/performance/size.rst @@ -255,6 +255,23 @@ VFS * Enabling :ref:`CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH` can reduce the IRAM usage and binary size by placing the entirety of the heap functionalities in flash memory. :CONFIG_ESP_ROM_HAS_HEAP_TLSF: * Enabling :ref:`CONFIG_HEAP_TLSF_USE_ROM_IMPL` can reduce the IRAM usage and binary size by linking in the TLSF library of ROM implementation. + +.. only:: SOC_USB_SERIAL_JTAG_SUPPORTED + + Console + @@@@@@@@ + + For targets that support USB-Serial-JTAG, both the USB-Serial-JTAG and UART console output are enabled by default. If you only need one console, you can reduce the binary size and RAM usage by doing the following: + + 1. Disable the secondary console by setting :ref:`CONFIG_ESP_CONSOLE_SECONDARY` to ``CONFIG_ESP_CONSOLE_SECONDARY_NONE``. + 2. Set :ref:`CONFIG_ESP_CONSOLE_UART` to use one of the following: + + * ``UART`` reduces the binary size by around 2.5 KB. + * ``USB-Serial-JTAG`` reduces the binary size by around 10 KB and DRAM usage by around 1.5 KB. + + Please note that these size reductions assume the UART/USB-Serial-JTAG driver code is not pulled into the app, if you already use these drivers for other purposes then the savings will be smaller. + + Bootloader Size --------------- From 31b665c6282098239a24a09ad4e962470e687109 Mon Sep 17 00:00:00 2001 From: shenmengjing Date: Thu, 11 Jul 2024 16:57:09 +0800 Subject: [PATCH 26/70] docs: Provide CN translation for isp.rst --- .../peripherals/camera_driver.rst | 1 - docs/en/api-reference/peripherals/isp.rst | 370 ++++---- .../peripherals/camera_driver.rst | 1 - docs/zh_CN/api-reference/peripherals/isp.rst | 827 +++++++++++++++++- 4 files changed, 1015 insertions(+), 184 deletions(-) diff --git a/docs/en/api-reference/peripherals/camera_driver.rst b/docs/en/api-reference/peripherals/camera_driver.rst index f1ac880171e..9023d0a9570 100644 --- a/docs/en/api-reference/peripherals/camera_driver.rst +++ b/docs/en/api-reference/peripherals/camera_driver.rst @@ -221,4 +221,3 @@ API Reference .. include-build-file:: inc/esp_cam_ctlr_types.inc .. include-build-file:: inc/esp_cam_ctlr_csi.inc .. include-build-file:: inc/esp_cam_ctlr_isp_dvp.inc -.. include-build-file:: inc/isp_core.inc diff --git a/docs/en/api-reference/peripherals/isp.rst b/docs/en/api-reference/peripherals/isp.rst index 13e7ff499a0..865e0d5d5d2 100644 --- a/docs/en/api-reference/peripherals/isp.rst +++ b/docs/en/api-reference/peripherals/isp.rst @@ -1,24 +1,29 @@ -Image Signal Processor -====================== +Image Signal Processor (ISP) +============================ + +:link_to_translation:`zh_CN:[中文]` Introduction ------------ -{IDF_TARGET_NAME} includes an Image Signal Processor (ISP), which is a feature pipeline that consists of many image processing algorithms. ISP receives image data from the DVP camera or MIPI-CSI camera, or system memory, and writes the processed image data to the system memory through DMA. The ISP is designed to work with other camera controller modules and cannot operate independently. +{IDF_TARGET_NAME} includes an Image Signal Processor (ISP), which is a feature pipeline that consists of many image processing algorithms. ISP receives image data from the DVP camera or MIPI-CSI camera, or system memory, and writes the processed image data to the system memory through DMA. The ISP is designed to work with other camera controller modules and can not operate independently. Terminology ----------- .. list:: - - MIPI-CSI: Camera serial interface, a high-speed serial interface for cameras compliant with MIPI specifications - - DVP: Digital video parallel interface, generally composed of vsync, hsync, de, and data signals - - RAW: Unprocessed data directly output from an image sensor, typically divided into R, Gr, Gb, and B four channels classified into RAW8, RAW10, RAW12, etc., based on bit width - - RGB: Colored image format composed of red, green, and blue colors classified into RGB888, RGB565, etc., based on the bit width of each color - - YUV: Colored image format composed of luminance and chrominance classified into YUV444, YUV422, YUV420, etc., based on the data arrangement - - AF: Auto-focus - - AWB: Auto-white balance - - BF: Bayer noise filter - - CCM: Color correction matrix + + - MIPI-CSI: Camera serial interface, a high-speed serial interface for cameras compliant with MIPI specifications + - DVP: Digital video parallel interface, generally composed of vsync, hsync, de, and data signals + - RAW: Unprocessed data directly output from an image sensor, typically divided into R, Gr, Gb, and B four channels classified into RAW8, RAW10, RAW12, etc., based on bit width + - RGB: Colored image format composed of red, green, and blue colors classified into RGB888, RGB565, etc., based on the bit width of each color + - YUV: Colored image format composed of luminance and chrominance classified into YUV444, YUV422, YUV420, etc., based on the data arrangement + - AF: Auto focus + - AWB: Auto white balance + - AE: Auto exposure + - HIST: Histogram + - BF: Bayer noise filter + - CCM: Color correction matrix ISP Pipeline ------------ @@ -38,7 +43,7 @@ ISP Pipeline isp_header [label = "ISP Header"]; isp_tail [label = "ISP Tail"]; isp_chs [label = "Contrast &\n Hue & Saturation", width = 150, height = 70]; - isp_yuv [label = "YUV Limit\nYUB2RGB", width = 120, height = 70]; + isp_yuv [label = "YUV Limit\n YUB2RGB", width = 120, height = 70]; isp_header -> BF -> Demosaic -> CCM -> Gamma -> RGB2YUV -> SHARP -> isp_chs -> isp_yuv -> isp_tail; @@ -49,7 +54,7 @@ ISP Pipeline CCM -> AWB Gamma -> AE RGB2YUV -> HIST - SHARP -> AF + RGB2YUV -> AF } Functional Overview @@ -57,21 +62,21 @@ Functional Overview The ISP driver offers following services: -- `Resource Allocation <#isp-resource-allocation>`__ - covers how to allocate ISP resources with properly set of configurations. It also covers how to recycle the resources when they finished working. -- `Enable and disable ISP processor <#isp-enable-disable>`__ - covers how to enable and disable an ISP processor. -- `Get AF statistics in one shot or continuous way <#isp-af-statistics>`__ - covers how to get AF statistics one-shot or continuously. -- `Get AE statistics in one shot or continuous way <#isp-ae-statistics>`__ - covers how to get AE statistics one-shot or continuously. -- `Get AWB statistics in one shot or continuous way <#isp-awb-statistics>`__ - covers how to get AWB white patches statistics one-shot or continuously. -- `Get histogram statistics in one shot or continuous way <#isp-hist-statistics>`__ - covers how to get histogram statistics one-shot or continuously. -- `Enable BF function <#isp_bf>`__ - covers how to enable and configure BF function. -- `Configure CCM <#isp-ccm-config>`__ - covers how to configure the Color Correction Matrix. -- `Configure Demosaic <#isp-demosaic>`__ - covers how to config the Demosaic function. -- `Enable Gamma Correction <#isp-gamma-correction>`__ - covers how to enable and configure gamma correction. -- `Configure Sharpen <#isp-sharpen>`__ - covers how to config the Sharpen function. -- `Register callback <#isp-callback>`__ - covers how to hook user specific code to ISP driver event callback function. -- `Thread Safety <#isp-thread-safety>`__ - lists which APIs are guaranteed to be thread safe by the driver. -- `Kconfig Options <#isp-kconfig-options>`__ - lists the supported Kconfig options that can bring different effects to the driver. -- `IRAM SAFE <#isp-iram-safe>`__ - describes tips on how to make the ISP interrupt and control functions work better along with a disabled cache. +- :ref:`isp-resource-allocation` - covers how to allocate ISP resources with properly set of configurations. It also covers how to recycle the resources when they finished working. +- :ref:`isp-enable-disable` - covers how to enable and disable an ISP processor. +- :ref:`isp-af-statistics` - covers how to get AF statistics one-shot or continuously. +- :ref:`isp-awb-statistics` - covers how to get AWB white patches statistics one-shot or continuously. +- :ref:`isp-ae-statistics` - covers how to get AE statistics one-shot or continuously. +- :ref:`isp-hist-statistics` - covers how to get histogram statistics one-shot or continuously. +- :ref:`isp-bf` - covers how to enable and configure BF function. +- :ref:`isp-ccm-config` - covers how to configure the CCM. +- :ref:`isp-demosaic` - covers how to configure the Demosaic function. +- :ref:`isp-gamma-correction` - covers how to enable and configure gamma correction. +- :ref:`isp-sharpen` - covers how to configure the sharpening function. +- :ref:`isp-callback` - covers how to hook user specific code to ISP driver event callback function. +- :ref:`isp-thread-safety` - lists which APIs are guaranteed to be thread safe by the driver. +- :ref:`isp-kconfig-options` - lists the supported Kconfig options that can bring different effects to the driver. +- :ref:`isp-iram-safe` - describes tips on how to make the ISP interrupt and control functions work better along with a disabled cache. .. _isp-resource-allocation: @@ -83,9 +88,9 @@ Install ISP Driver ISP driver requires the configuration that specified by :cpp:type:`esp_isp_processor_cfg_t`. -If the configurations in :cpp:type:`esp_isp_processor_cfg_t` is specified, users can call :cpp:func:`esp_isp_new_processor` to allocate and initialize an ISP processor. This function will return an ISP processor handle if it runs correctly. You can take following code as reference. +If the configurations in :cpp:type:`esp_isp_processor_cfg_t` is specified, users can call :cpp:func:`esp_isp_new_processor` to allocate and initialize an ISP processor. This function will return an ISP processor handle if it runs correctly. You can take following code as reference: -.. code:: c +.. code-block:: c esp_isp_processor_cfg_t isp_config = { .clk_src = ISP_CLK_SRC_DEFAULT, @@ -95,17 +100,17 @@ If the configurations in :cpp:type:`esp_isp_processor_cfg_t` is specified, users isp_proc_handle_t isp_proc = NULL; ESP_ERROR_CHECK(esp_isp_new_processor(&isp_config, &isp_proc)); -You can use the created handle to do driver enable / disable the ISP driver and do other ISP module installation. +You can use the created handle to enable/disable the ISP driver and do other ISP module installation. -Install ISP Auto-Focus (AF) Driver +Install ISP Auto Focus (AF) Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ISP auto-focus (AF) driver requires the configuration that specified by :cpp:type:`esp_isp_af_config_t`. +ISP auto focus (AF) driver requires the configuration that specified by :cpp:type:`esp_isp_af_config_t`. -If the configurations in :cpp:type:`esp_isp_af_config_t` is specified, users can call :cpp:func:`esp_isp_new_af_controller` to allocate and initialize an ISP AF processor. This function will return an ISP AF processor handle if it runs correctly. You can take following code as reference. +If the configurations in :cpp:type:`esp_isp_af_config_t` is specified, users can call :cpp:func:`esp_isp_new_af_controller` to allocate and initialize an ISP AF controller. This function will return an ISP AF controller handle if it runs correctly. You can take following code as reference: -.. code:: c +.. code-block:: c esp_isp_af_config_t af_config = { .edge_thresh = 128, @@ -113,16 +118,16 @@ If the configurations in :cpp:type:`esp_isp_af_config_t` is specified, users can isp_af_ctlr_t af_ctrlr = NULL; ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr)); -You can use the created handle to do driver enable / disable the ISP AF driver and ISP AF Env module installation. +You can use the created handle to enable/disable the ISP AF driver and install ISP AF environment detector module. -Install ISP Auto-White-Balance (AWB) Driver +Install ISP Auto White Balance (AWB) Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ISP auto-white-balance (AWB) driver requires the configuration specified by :cpp:type:`esp_isp_awb_config_t`. +ISP auto white balance (AWB) driver requires the configuration specified by :cpp:type:`esp_isp_awb_config_t`. -If an :cpp:type:`esp_isp_awb_config_t` configuration is specified, you can call :cpp:func:`esp_isp_new_awb_controller` to allocate and initialize an ISP AWB processor. This function will return an ISP AWB processor handle on success. You can take following code as reference. +If an :cpp:type:`esp_isp_awb_config_t` configuration is specified, you can call :cpp:func:`esp_isp_new_awb_controller` to allocate and initialize an ISP AWB controller. This function will return an ISP AWB controller handle on success. You can take following code as reference: -.. code:: c +.. code-block:: c isp_awb_ctlr_t awb_ctlr = NULL; uint32_t image_width = 800; @@ -136,14 +141,14 @@ If an :cpp:type:`esp_isp_awb_config_t` configuration is specified, you can call The AWB handle created in this step is required by other AWB APIs and AWB scheme. -Install ISP Auto-Exposure (AE) Driver +Install ISP Auto Exposure (AE) Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -ISP auto-exposure (AE) driver requires the configuration that specified by :cpp:type:`esp_isp_ae_config_t`. +ISP auto exposure (AE) driver requires the configuration that specified by :cpp:type:`esp_isp_ae_config_t`. -If the configurations in :cpp:type:`esp_isp_ae_config_t` is specified, users can call :cpp:func:`esp_isp_new_ae_controller` to allocate and initialize an ISP AE processor. This function will return an ISP AE processor handle if it runs correctly. You can take following code as reference. +If the configurations in :cpp:type:`esp_isp_ae_config_t` is specified, call :cpp:func:`esp_isp_new_ae_controller` to allocate and initialize an ISP AE controller. This function will return an ISP AE controller handle if it runs correctly. You can take following code as reference. -.. code:: c +.. code-block:: c esp_isp_ae_config_t ae_config = { .sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, @@ -152,20 +157,20 @@ If the configurations in :cpp:type:`esp_isp_ae_config_t` is specified, users can isp_ae_ctlr_t ae_ctlr = NULL; ESP_ERROR_CHECK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctlr)); -You can use the created handle to do driver enable / disable the ISP AE driver and ISP AE environment detector setup. +You can use the created handle to enable/disable the ISP AE driver and do ISP AE environment detector setup. -Install ISP histogram (HIST) Driver +Install ISP Histogram (HIST) Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ISP histogram (HIST) driver requires the configuration that specified by :cpp:type:`esp_isp_hist_config_t`. -If the configurations in :cpp:type:`esp_isp_hist_config_t` is specified, users can call :cpp:func:`esp_isp_new_hist_controller` to allocate and initialize an ISP Histogram processor. This function will return an ISP HIST processor handle if it runs correctly. You can take following code as reference. +If the configurations in :cpp:type:`esp_isp_hist_config_t` is specified, users can call :cpp:func:`esp_isp_new_hist_controller` to allocate and initialize an ISP Histogram controller. This function will return an ISP HIST controller handle if it runs correctly. You can take following code as reference. .. list:: - - The sum of all subwindows weight's decimal value should be 256 or the statistics will be small, and integer value should be 0. - - The sum of all RGB coefficients' decimal value should be 256 or the statistics will be small, and integer value should be 0. - - The segment_threshold must be 0 ~ 255 and in order + - The sum of all subwindow weights' decimal values should be 256; otherwise, the statistics will be small. The integer value should be 0. + - The sum of all RGB coefficients' decimal values should be 256; otherwise, the statistics will be small. The integer value should be 0. + - The segment_threshold must be 0–255 and in order. .. code:: c @@ -195,20 +200,20 @@ If the configurations in :cpp:type:`esp_isp_hist_config_t` is specified, users c isp_hist_ctlr_t hist_ctlr_ctlr = NULL; ESP_ERROR_CHECK(esp_isp_new_hist_controller(isp_proc, &hist_config, &hist_ctlr)); -You can use the created handle to do driver enable / disable the ISP HIST driver setup. +You can use the created handle to enable/disable the ISP HIST driver setup. -Uninstall ISP Driver(s) +Uninstall ISP Drivers ~~~~~~~~~~~~~~~~~~~~~~~ -If a previously installed ISP driver(s) are not needed, it's recommended to recycle the resource by following APIs to release the underlying hardware: +If previously installed ISP drivers are no longer needed, it's recommended to recycle the resource by following APIs to release the underlying hardware: .. list:: - :cpp:func:`esp_isp_del_processor`, for ISP processor. - - :cpp:func:`esp_isp_del_af_controller`, for ISP AF processor. - - :cpp:func:`esp_isp_del_awb_controller`, for ISP AWB processor. - - :cpp:func:`esp_isp_del_ae_controller`, for ISP AE processor. - - :cpp:func:`esp_isp_del_hist_controller`, for ISP Histogram processor. + - :cpp:func:`esp_isp_del_af_controller`, for ISP AF controller. + - :cpp:func:`esp_isp_del_awb_controller`, for ISP AWB controller. + - :cpp:func:`esp_isp_del_ae_controller`, for ISP AE controller. + - :cpp:func:`esp_isp_del_hist_controller`, for ISP Histogram controller. .. _isp-enable-disable: @@ -224,10 +229,10 @@ Before doing ISP pipeline, you need to enable the ISP processor first, by callin Calling :cpp:func:`esp_isp_disable` does the opposite, that is, put the driver back to the **init** state. -ISP AF Processor -~~~~~~~~~~~~~~~~ +ISP AF Controller +~~~~~~~~~~~~~~~~~ -Before doing ISP AF, you need to enable the ISP AF processor first, by calling :cpp:func:`esp_isp_af_controller_enable`. This function: +Before doing ISP AF, you need to enable the ISP AF controller first, by calling :cpp:func:`esp_isp_af_controller_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -238,13 +243,14 @@ Calling :cpp:func:`esp_isp_af_controller_disable` does the opposite, that is, pu AF One-shot and Continuous Statistics ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Calling :cpp:func:`esp_isp_af_controller_get_oneshot_statistics` to get oneshot AF statistics result. You can take following code as reference. +Calling :cpp:func:`esp_isp_af_controller_get_oneshot_statistics` to get one-shot AF statistics result. You can take following code as reference. -Aside from the above oneshot API, the ISP AF driver also provides a way to start AF statistics continuously. Calling :cpp:func:`esp_isp_af_controller_start_continuous_statistics` to start the continuous statistics and :cpp:func:`esp_isp_af_controller_stop_continuous_statistics` to stop it. +Aside from the above one-shot API, the ISP AF driver also provides a way to start AF statistics continuously. Calling :cpp:func:`esp_isp_af_controller_start_continuous_statistics` to start the continuous statistics and :cpp:func:`esp_isp_af_controller_stop_continuous_statistics` to stop it. -Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_statistics_done` or :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_change` callback to get the statistics result. See how to register in `Register Event Callbacks <#isp-callback>`__ +Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_statistics_done` or :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_change` callbacks to get the statistics result. See how to register in :ref:`isp-callback`. .. note:: + When you use the continuous statistics, AF Environment Detector will be invalid. .. code:: c @@ -256,7 +262,7 @@ Note that if you want to use the continuous statistics, you need to register the ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr)); ESP_ERROR_CHECK(esp_isp_af_controller_enable(af_ctrlr)); isp_af_result_t result = {}; - /* Trigger the AF statistics and get its result for one time with timeout value 2000ms. */ + /* Trigger the AF statistics and get its result for one time with timeout value 2000 ms */ ESP_ERROR_CHECK(esp_isp_af_controller_get_oneshot_statistics(af_ctrlr, 2000, &result)); /* Start continuous AF statistics */ @@ -267,17 +273,17 @@ Note that if you want to use the continuous statistics, you need to register the /* Stop continuous AF statistics */ ESP_ERROR_CHECK(esp_isp_af_controller_stop_continuous_statistics(af_ctrlr)); - /* Disable the af controller */ + /* Disable the AF controller */ ESP_ERROR_CHECK(esp_isp_af_controller_disable(af_ctrlr)); - /* Delete the af controller and free the resources */ + /* Delete the AF controller and free the resources */ ESP_ERROR_CHECK(esp_isp_del_af_controller(af_ctrlr)); Set AF Environment Detector ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Calling :cpp:func:`esp_isp_af_controller_set_env_detector` to set an ISP AF environment detector. You can take following code as reference. +Calling :cpp:func:`esp_isp_af_controller_set_env_detector` to set an ISP AF environment detector. You can take following code as reference: -.. code:: c +.. code-block:: c esp_isp_af_env_config_t env_config = { .interval = 10, @@ -289,18 +295,77 @@ Calling :cpp:func:`esp_isp_af_controller_set_env_detector` to set an ISP AF envi Set AF Environment Detector Threshold ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Calling :cpp:func:`esp_isp_af_env_detector_set_threshold` to set the threshold of an ISP AF environment detector. +Calling :cpp:func:`esp_isp_af_controller_set_env_detector_threshold` to set the threshold of an ISP AF environment detector. -.. code:: c +.. code-block:: c int definition_thresh = 0; int luminance_thresh = 0; ESP_ERROR_CHECK(esp_isp_af_env_detector_set_threshold(env_detector, definition_thresh, luminance_thresh)); -ISP AE Processor ----------------- +ISP AWB Controller +~~~~~~~~~~~~~~~~~~ -Before doing ISP AE, you need to enable the ISP AE processor first, by calling :cpp:func:`esp_isp_ae_controller_enable`. This function: +Before doing ISP AWB, you need to enable the ISP AWB controller first, by calling :cpp:func:`esp_isp_awb_controller_enable`. This function: + +* Switches the driver state from **init** to **enable**. + +Calling :cpp:func:`esp_isp_awb_controller_disable` does the opposite, that is, put the driver back to the **init** state. + +.. _isp-awb-statistics: + +AWB One-shot and Continuous Statistics +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Calling :cpp:func:`esp_isp_awb_controller_get_oneshot_statistics` to get oneshot AWB statistics result of white patches. You can take following code as reference. + +Aside from the above one-shot API, the ISP AWB driver also provides a way to start AWB statistics continuously. Calling :cpp:func:`esp_isp_awb_controller_start_continuous_statistics` starts the continuous statistics and :cpp:func:`esp_isp_awb_controller_stop_continuous_statistics` stops it. + +Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` callback to get the statistics result. See how to register it in :ref:`isp-callback`. + +.. code-block:: c + + bool example_isp_awb_on_statistics_done_cb(isp_awb_ctlr_t awb_ctlr, const esp_isp_awb_evt_data_t *edata, void *user_data); + // ... + isp_awb_ctlr_t awb_ctlr = NULL; + uint32_t image_width = 800; + uint32_t image_height = 600; + /* The AWB configuration, please refer to the API comment for how to tune these parameters */ + esp_isp_awb_config_t awb_config = { + .sample_point = ISP_AWB_SAMPLE_POINT_AFTER_CCM, + ... + }; + isp_awb_stat_result_t stat_res = {}; + /* Create the AWB controller */ + ESP_ERROR_CHECK(esp_isp_new_awb_controller(isp_proc, &awb_config, &awb_ctlr)); + /* Register the AWB callback */ + esp_isp_awb_cbs_t awb_cb = { + .on_statistics_done = example_isp_awb_on_statistics_done_cb, + }; + ESP_ERROR_CHECK(esp_isp_awb_register_event_callbacks(awb_ctlr, &awb_cb, NULL)); + /* Enable the AWB controller */ + ESP_ERROR_CHECK(esp_isp_awb_controller_enable(awb_ctlr)); + + /* Get one-shot AWB statistics result */ + ESP_ERROR_CHECK(esp_isp_awb_controller_get_oneshot_statistics(awb_ctlr, -1, &stat_res)); + + /* Start continuous AWB statistics, note that continuous statistics requires `on_statistics_done` callback */ + ESP_ERROR_CHECK(esp_isp_awb_controller_start_continuous_statistics(awb_ctlr)); + // You can do other stuffs here, the statistics result can be obtained in the callback + // ...... + // vTaskDelay(pdMS_TO_TICKS(1000)); + /* Stop continuous AWB statistics */ + ESP_ERROR_CHECK(esp_isp_awb_controller_stop_continuous_statistics(awb_ctlr)); + + /* Disable the AWB controller */ + ESP_ERROR_CHECK(esp_isp_awb_controller_disable(awb_ctlr)); + /* Delete the AWB controller and free the resources */ + ESP_ERROR_CHECK(esp_isp_del_awb_controller(awb_ctlr)); + +ISP AE Controller +~~~~~~~~~~~~~~~~~ + +Before doing ISP AE, you need to enable the ISP AE controller first, by calling :cpp:func:`esp_isp_ae_controller_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -313,16 +378,17 @@ AE One-shot and Continuous Statistics Calling :cpp:func:`esp_isp_ae_controller_get_oneshot_statistics` to get oneshot AE statistics result. You can take following code as reference. -When you use AE oneshot statistics, the AE continuous mode need to be disabled otherwise the result may be overwritten by the environment detector. After oneshot operation finishes, you need to restart continuous mode again. +When using AE oneshot statistics, the AE continuous mode need to be disabled otherwise the result may be overwritten by the environment detector. After oneshot operation finishes, you need to restart continuous mode again. Aside from the above oneshot API, the ISP AE driver also provides a way to start AE statistics continuously. Calling :cpp:func:`esp_isp_ae_controller_start_continuous_statistics` to start the continuous statistics and :cpp:func:`esp_isp_ae_controller_stop_continuous_statistics` to stop it. -Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_statistics_done` or :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_change` callback to get the statistics result. See how to register in `Register Event Callbacks <#isp-callback>`__ +Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` or :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` callback to get the statistics result. See how to register in :ref:`isp-callback`. .. note:: - When using oneshot statistics, the AE Environment Detector will be temporarily disabled and will automatically recover once the oneshot is complete. -.. code:: c + When using oneshot statistics, the AE environment detector will be temporarily disabled and will automatically recover once the oneshot is completed. + +.. code-block:: c esp_isp_ae_config_t ae_config = { .sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, @@ -331,7 +397,7 @@ Note that if you want to use the continuous statistics, you need to register the ESP_ERROR_CHECK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctlr)); ESP_ERROR_CHECK(esp_isp_ae_controller_enable(ae_ctlr)); isp_ae_result_t result = {}; - /* Trigger the AE statistics and get its result for one time with timeout value 2000ms. */ + /* Trigger the AE statistics and get its result for one time with timeout value 2000 ms. */ ESP_ERROR_CHECK(esp_isp_ae_controller_get_oneshot_statistics(ae_ctlr, 2000, &result)); /* Start continuous AE statistics */ @@ -342,9 +408,9 @@ Note that if you want to use the continuous statistics, you need to register the /* Stop continuous AE statistics */ ESP_ERROR_CHECK(esp_isp_ae_controller_stop_continuous_statistics(ae_ctlr)); - /* Disable the ae controller */ + /* Disable the AE controller */ ESP_ERROR_CHECK(esp_isp_ae_controller_disable(ae_ctlr)); - /* Delete the ae controller and free the resources */ + /* Delete the AE controller and free the resources */ ESP_ERROR_CHECK(esp_isp_del_ae_controller(ae_ctlr)); Set AE Environment Detector @@ -362,7 +428,7 @@ Calling :cpp:func:`esp_isp_ae_controller_set_env_detector` to set an ISP AE envi Set AE Environment Detector Threshold ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Calling :cpp:func:`esp_isp_ae_controller_set_env_detector_threshold` to set the thresholds(1-255) of an ISP AE environment detector. +Calling :cpp:func:`esp_isp_ae_controller_set_env_detector_threshold` to set the thresholds (1-255) of an ISP AE environment detector. .. code:: c @@ -372,71 +438,12 @@ Calling :cpp:func:`esp_isp_ae_controller_set_env_detector_threshold` to set the }; ESP_ERROR_CHECK(esp_isp_ae_controller_set_env_detector_threshold(ae_ctlr, env_thresh)); -ISP AWB Processor -~~~~~~~~~~~~~~~~~ - -Before doing ISP AWB, you need to enable the ISP AWB processor first, by calling :cpp:func:`esp_isp_awb_controller_enable`. This function: - -* Switches the driver state from **init** to **enable**. - -Calling :cpp:func:`esp_isp_awb_controller_disable` does the opposite, that is, put the driver back to the **init** state. - -.. _isp-awb-statistics: - -AWB One-shot and Continuous Statistics -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -Calling :cpp:func:`esp_isp_awb_controller_get_oneshot_statistics` to get oneshot AWB statistics result of white patches. You can take following code as reference. - -Aside from the above oneshot API, the ISP AWB driver also provides a way to start AWB statistics continuously. Calling :cpp:func:`esp_isp_awb_controller_start_continuous_statistics` starts the continuous statistics and :cpp:func:`esp_isp_awb_controller_stop_continuous_statistics` stops it. - -Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` callback to get the statistics result. See how to register it in `Register Event Callbacks <#isp-callback>`__ - -.. code:: c - - bool example_isp_awb_on_statistics_done_cb(isp_awb_ctlr_t awb_ctlr, const esp_isp_awb_evt_data_t *edata, void *user_data); - // ... - isp_awb_ctlr_t awb_ctlr = NULL; - uint32_t image_width = 800; - uint32_t image_height = 600; - /* The AWB configuration, please refer to the API comment for how to tune these parameters */ - esp_isp_awb_config_t awb_config = { - .sample_point = ISP_AWB_SAMPLE_POINT_AFTER_CCM, - ... - }; - isp_awb_stat_result_t stat_res = {}; - /* Create the awb controller */ - ESP_ERROR_CHECK(esp_isp_new_awb_controller(isp_proc, &awb_config, &awb_ctlr)); - /* Register AWB callback */ - esp_isp_awb_cbs_t awb_cb = { - .on_statistics_done = example_isp_awb_on_statistics_done_cb, - }; - ESP_ERROR_CHECK(esp_isp_awb_register_event_callbacks(awb_ctlr, &awb_cb, NULL)); - /* Enabled the awb controller */ - ESP_ERROR_CHECK(esp_isp_awb_controller_enable(awb_ctlr)); - - /* Get oneshot AWB statistics result */ - ESP_ERROR_CHECK(esp_isp_awb_controller_get_oneshot_statistics(awb_ctlr, -1, &stat_res)); - - /* Start continuous AWB statistics, note that continuous statistics requires `on_statistics_done` callback */ - ESP_ERROR_CHECK(esp_isp_awb_controller_start_continuous_statistics(awb_ctlr)); - // You can do other stuffs here, the statistics result can be obtained in the callback - // ...... - // vTaskDelay(pdMS_TO_TICKS(1000)); - /* Stop continuous AWB statistics */ - ESP_ERROR_CHECK(esp_isp_awb_controller_stop_continuous_statistics(awb_ctlr)); - - /* Disable the awb controller */ - ESP_ERROR_CHECK(esp_isp_awb_controller_disable(awb_ctlr)); - /* Delete the awb controller and free the resources */ - ESP_ERROR_CHECK(esp_isp_del_awb_controller(awb_ctlr)); - .. _isp-hist: -ISP histogram Processor ------------------------ +ISP Histogram Controller +~~~~~~~~~~~~~~~~~~~~~~~~ -Before doing ISP histogram statistics, you need to enable the ISP histogram processor first, by calling :cpp:func:`esp_isp_hist_controller_enable`. This function: +Before doing ISP histogram statistics, you need to enable the ISP histogram controller first, by calling :cpp:func:`esp_isp_hist_controller_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -451,7 +458,7 @@ Calling :cpp:func:`esp_isp_hist_controller_get_oneshot_statistics` to get onesho Aside from the above oneshot API, the ISP histogram driver also provides a way to start histogram statistics continuously. Calling :cpp:func:`esp_isp_hist_controller_start_continuous_statistics` starts the continuous statistics and :cpp:func:`esp_isp_hist_controller_stop_continuous_statistics` stops it. -Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` callback to get the statistics result. See how to register it in `Register Event Callbacks <#isp-callback>`__ +Note that if you want to use the continuous statistics, you need to register the :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` callback to get the statistics result. See how to register it in :ref:`isp-callback`. .. code:: c @@ -471,16 +478,16 @@ Note that if you want to use the continuous statistics, you need to register the esp_isp_hist_controller_enable(hist_ctlr); -.. _isp_bf: +.. _isp-bf: -ISP BF Processor -~~~~~~~~~~~~~~~~ +ISP BF Controller +~~~~~~~~~~~~~~~~~ This pipeline is used for doing image input denoising under bayer mode. Calling :cpp:func:`esp_isp_bf_configure` to configure BF function, you can take following code as reference. -.. code:: c +.. code-block:: c esp_isp_bf_config_t bf_config = { .denoising_level = 5, @@ -496,7 +503,7 @@ Calling :cpp:func:`esp_isp_bf_configure` to configure BF function, you can take :cpp:member:`esp_isp_bf_config_t::bf_template` is used for bayer denoise. You can set the :cpp:member:`esp_isp_bf_config_t::bf_template` with a Gaussian filter template or an average filter template. -After calling :cpp:func:`esp_isp_bf_configure`, you need to enable the ISP BF processor, by calling :cpp:func:`esp_isp_bf_enable`. This function: +After calling :cpp:func:`esp_isp_bf_configure`, you need to enable the ISP BF controller, by calling :cpp:func:`esp_isp_bf_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -504,8 +511,8 @@ Calling :cpp:func:`esp_isp_bf_disable` does the opposite, that is, put the drive .. _isp-color: -ISP Color Processor -~~~~~~~~~~~~~~~~~~~ +ISP Color Controller +~~~~~~~~~~~~~~~~~~~~ This pipeline is used to adjust the image contrast, saturation, hue and brightness. @@ -529,7 +536,7 @@ Calling :cpp:func:`esp_isp_color_configure` to configure color function, you can - Contrast value should be 0 ~ {IDF_TARGET_SOC_ISP_COLOR_CONTRAST_MAX}, default {IDF_TARGET_SOC_ISP_COLOR_CONTRAST_DEFAULT} - Saturation value should be 0 ~ {IDF_TARGET_SOC_ISP_COLOR_SATURATION_MAX}, default {IDF_TARGET_SOC_ISP_COLOR_SATURATION_DEFAULT} - Hue value should be 0 ~ {IDF_TARGET_SOC_ISP_COLOR_HUE_MAX}, default {IDF_TARGET_SOC_ISP_COLOR_HUE_DEFAULT} - - Brightness value should be -{IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MIN} ~ {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MAX}, default {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_DEFAULT} + - Brightness value should be {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MIN} ~ {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MAX}, default {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_DEFAULT} .. code:: c @@ -548,7 +555,7 @@ Calling :cpp:func:`esp_isp_color_configure` to configure color function, you can ESP_ERROR_CHECK(esp_isp_color_configure(isp_proc, &color_config)); ESP_ERROR_CHECK(esp_isp_color_enable(isp_proc)); -After calling :cpp:func:`esp_isp_color_configure`, you need to enable the ISP color processor, by calling :cpp:func:`esp_isp_color_enable`. This function: +After calling :cpp:func:`esp_isp_color_configure`, you need to enable the ISP color controller, by calling :cpp:func:`esp_isp_color_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -559,13 +566,11 @@ Calling :cpp:func:`esp_isp_color_disable` does the opposite, that is, put the dr Configure CCM ^^^^^^^^^^^^^ -Color Correction Matrix can scale the color ratio of RGB888 pixels. It can be used for adjusting the image color via some algorithms, for example, used for white balance by inputting the AWB computed result, or used as a Filter with some filter algorithms. +Color correction matrix can scale the color ratio of RGB888 pixels. It can be used for adjusting the image color via some algorithms, for example, used for white balance by inputting the AWB computed result, or used as a filter with some filter algorithms. To adjust the color correction matrix, here is the formula: - - -:: +.. code-block:: none [ R' ] [ RR RG RB ] [ R ] [ G' ] = [ GR GG GB ] * [ G ] @@ -597,8 +602,8 @@ To adjust the color correction matrix, here is the formula: .. _isp-demosaic: -ISP Demosaic Processor -~~~~~~~~~~~~~~~~~~~~~~ +ISP Demosaic Controller +~~~~~~~~~~~~~~~~~~~~~~~ This pipeline is used for doing image demosaic algorithm to convert RAW image to RGB mode. @@ -617,7 +622,7 @@ Calling :cpp:func:`esp_isp_demosaic_configure` to configure Demosaic function, y ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &sharpen_config)); ESP_ERROR_CHECK(esp_isp_demosaic_enable(isp_proc)); -After calling :cpp:func:`esp_isp_demosaic_configure`, you need to enable the ISP Sharpen processor, by calling :cpp:func:`esp_isp_demosaic_enable`. This function: +After calling :cpp:func:`esp_isp_demosaic_configure`, you need to enable the ISP Demosaic controller, by calling :cpp:func:`esp_isp_demosaic_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -630,9 +635,9 @@ Calling :cpp:func:`esp_isp_demosaic_disable` does the opposite, that is, put the Enable Gamma Correction ^^^^^^^^^^^^^^^^^^^^^^^ -The human visual system is non-linearly sensitive to the physical luminance. Adding gamma correction to the ISP pipeline to transforms RGB coordinates into a space in which coordinates are proportional to subjective brightness. +The human visual system is non-linearly sensitive to the physical luminance. Adding gamma correction to the ISP pipeline to transform RGB coordinates into a space in which coordinates are proportional to subjective brightness. -The driver provides a helper API :cpp:func:`esp_isp_gamma_fill_curve_points` to fill :cpp:type:`isp_gamma_curve_points_t`, which is a group of points used to describe the gamma correction curve. Or you can manually declare the points as your desired 'gamma' correction curve. Each R / G / B component can have its own gamma correction curve, you can set the configuration by calling :cpp:func:`esp_isp_gamma_configure`. +The driver provides a helper API :cpp:func:`esp_isp_gamma_fill_curve_points` to fill :cpp:type:`isp_gamma_curve_points_t`, which is a group of points used to describe the gamma correction curve. Or you can manually declare the points as your desired gamma correction curve. Each R/G/B component can have its own gamma correction curve, you can set the configuration by calling :cpp:func:`esp_isp_gamma_configure`. A typical code example is: @@ -660,8 +665,8 @@ A typical code example is: .. _isp-sharpen: -ISP Sharpen Processor -~~~~~~~~~~~~~~~~~~~~~ +ISP Sharpen Controller +~~~~~~~~~~~~~~~~~~~~~~ This pipeline is used for doing image input sharpening under YUV mode. @@ -683,7 +688,7 @@ Calling :cpp:func:`esp_isp_sharpen_configure` to configure Sharpen function, you :cpp:member:`esp_isp_sharpen_config_t::sharpen_template` is used for sharpening. You can set the :cpp:member:`esp_isp_sharpen_config_t::sharpen_template` with a Gaussian filter template or an average filter template. -After calling :cpp:func:`esp_isp_sharpen_configure`, you need to enable the ISP Sharpen processor, by calling :cpp:func:`esp_isp_sharpen_enable`. This function: +After calling :cpp:func:`esp_isp_sharpen_configure`, you need to enable the ISP Sharpen controller, by calling :cpp:func:`esp_isp_sharpen_enable`. This function: * Switches the driver state from **init** to **enable**. @@ -696,19 +701,21 @@ Calling :cpp:func:`esp_isp_sharpen_disable` does the opposite, that is, put the Register Event Callbacks ^^^^^^^^^^^^^^^^^^^^^^^^ + After an ISP module starts up, it can generate a specific event dynamically. + You can save your own context to callback function as well, via the parameter ``user_data``. The user data will be directly passed to the callback function. .. note:: - The below mentioned callback functions are called within an ISR context, you must ensure that the functions do not attempt to block (e.g., by making sure that only FreeRTOS APIs with ``ISR`` suffix are called from within the function). + The below-mentioned callback functions are called within an ISR context. You must ensure that the functions do not attempt to block (e.g., by making sure that only FreeRTOS APIs with ``ISR`` suffix are called from within the function). Register ISP Processor Event Callbacks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ After the ISP processor is enabled, it can generate multiple events of multiple ISP submodules dynamically. You can hook your functions to the interrupt service routine by calling :cpp:func:`esp_isp_register_event_callbacks`. All supported event callbacks are listed in :cpp:type:`esp_isp_evt_cbs_t`: -- :cpp:member:`esp_isp_evt_cbs_t::on_sharpen_frame_done`. sets a callback function for sharpen frame done. It will be called after the ISP sharpen submodule finishes its operation for one frame. The function prototype is declared in :cpp:type:`esp_isp_sharpen_callback_t`. +- :cpp:member:`esp_isp_evt_cbs_t::on_sharpen_frame_done` sets a callback function for sharpen frame done. It will be called after the ISP sharpen submodule finishes its operation for one frame. The function prototype is declared in :cpp:type:`esp_isp_sharpen_callback_t`. Register ISP AF Environment Detector Event Callbacks ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -723,7 +730,7 @@ Register ISP AWB Statistics Done Event Callbacks After the ISP AWB controller finished statistics of white patches, it can generate a specific event dynamically. If you want to be informed when the statistics done event takes place, please hook your function to the interrupt service routine by calling :cpp:func:`esp_isp_awb_register_event_callbacks`. All supported event callbacks are listed in :cpp:type:`esp_isp_awb_cbs_t`: -- :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` sets a callback function when finished statistics of the white patches. The function prototype is declared in :cpp:type:`esp_isp_awb_callback_t`. +- :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` sets a callback function when finishing statistics of the white patches. The function prototype is declared in :cpp:type:`esp_isp_awb_callback_t`. Register ISP AE Environment Detector Event Callbacks @@ -731,8 +738,8 @@ Register ISP AE Environment Detector Event Callbacks After the ISP AE environment detector starts up, it can generate a specific event dynamically. If you have some functions that should be called when the event happens, please hook your function to the interrupt service routine by calling :cpp:func:`esp_isp_ae_env_detector_register_event_callbacks`. All supported event callbacks are listed in :cpp:type:`esp_isp_ae_env_detector_evt_cbs_t`: -- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` sets a callback function for environment statistics done. . The function prototype is declared in :cpp:type:`esp_isp_ae_env_detector_callback_t`. -- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` sets a callback function for environment change. . The function prototype is declared in :cpp:type:`esp_isp_ae_env_detector_callback_t`. +- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` sets a callback function for environment statistics done. The function prototype is declared in :cpp:type:`esp_isp_ae_env_detector_callback_t`. +- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` sets a callback function for environment change. The function prototype is declared in :cpp:type:`esp_isp_ae_env_detector_callback_t`. Register ISP HIST Statistics Done Event Callbacks @@ -740,14 +747,14 @@ Register ISP HIST Statistics Done Event Callbacks After the ISP HIST controller finished statistics of brightness, it can generate a specific event dynamically. If you want to be informed when the statistics done event takes place, please hook your function to the interrupt service routine by calling :cpp:func:`esp_isp_hist_register_event_callbacks`. All supported event callbacks are listed in :cpp:type:`esp_isp_hist_cbs_t`: -- :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` sets a callback function when finished statistics of the brightness. . The function prototype is declared in :cpp:type:`esp_isp_hist_callback_t`. +- :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` sets a callback function when finishing statistics of the brightness. The function prototype is declared in :cpp:type:`esp_isp_hist_callback_t`. .. _isp-thread-safety: Thread Safety ^^^^^^^^^^^^^ -The factory function +The following factory function are guaranteed to be thread safe by the driver: .. list:: @@ -762,14 +769,14 @@ The factory function - :cpp:func:`esp_isp_new_hist_controller` - :cpp:func:`esp_isp_del_hist_controller` -are guaranteed to be thread safe by the driver, which means, user can call them from different RTOS tasks without protection by extra locks. Other APIs are not guaranteed to be thread-safe. +These functions can be called from different RTOS tasks without protection by extra locks. Other APIs are not guaranteed to be thread-safe. .. _isp-kconfig-options: Kconfig Options ^^^^^^^^^^^^^^^ -- :ref:`CONFIG_ISP_ISR_IRAM_SAFE` controls whether the default ISR handler should be masked when the cache is disabled +- :ref:`CONFIG_ISP_ISR_IRAM_SAFE` controls whether the default ISR handler should be masked when the cache is disabled. .. _isp-iram-safe: @@ -788,12 +795,12 @@ This allows the interrupt to run while the cache is disabled, but comes at the c Kconfig option :ref:`CONFIG_ISP_CTRL_FUNC_IN_IRAM` will: -- Place some of ISP control functions into IRAM, function list: +- Place some of the ISP control functions into IRAM, including: -.. list:: + .. list:: - - :cpp:func:`esp_isp_sharpen_configure` - - :cpp:func:`esp_isp_demosaic_configure` + - :cpp:func:`esp_isp_sharpen_configure` + - :cpp:func:`esp_isp_demosaic_configure` Application Examples -------------------- @@ -804,8 +811,6 @@ API Reference ------------- .. include-build-file:: inc/isp.inc -.. include-build-file:: inc/components/hal/include/hal/isp_types.inc -.. include-build-file:: inc/components/esp_driver_isp/include/driver/isp_types.inc .. include-build-file:: inc/isp_af.inc .. include-build-file:: inc/isp_ae.inc .. include-build-file:: inc/isp_awb.inc @@ -816,3 +821,6 @@ API Reference .. include-build-file:: inc/isp_gamma.inc .. include-build-file:: inc/isp_hist.inc .. include-build-file:: inc/isp_color.inc +.. include-build-file:: inc/isp_core.inc +.. include-build-file:: inc/components/esp_driver_isp/include/driver/isp_types.inc +.. include-build-file:: inc/components/hal/include/hal/isp_types.inc diff --git a/docs/zh_CN/api-reference/peripherals/camera_driver.rst b/docs/zh_CN/api-reference/peripherals/camera_driver.rst index d5dda32ca7c..80c473f7930 100644 --- a/docs/zh_CN/api-reference/peripherals/camera_driver.rst +++ b/docs/zh_CN/api-reference/peripherals/camera_driver.rst @@ -221,4 +221,3 @@ API 参考 .. include-build-file:: inc/esp_cam_ctlr_types.inc .. include-build-file:: inc/esp_cam_ctlr_csi.inc .. include-build-file:: inc/esp_cam_ctlr_isp_dvp.inc -.. include-build-file:: inc/isp_core.inc diff --git a/docs/zh_CN/api-reference/peripherals/isp.rst b/docs/zh_CN/api-reference/peripherals/isp.rst index 3770b5e0b23..466c4a18d61 100644 --- a/docs/zh_CN/api-reference/peripherals/isp.rst +++ b/docs/zh_CN/api-reference/peripherals/isp.rst @@ -1 +1,826 @@ -.. include:: ../../../en/api-reference/peripherals/isp.rst +图像信号处理器 (ISP) +==================== + +:link_to_translation:`en:[English]` + +简介 +---- + +{IDF_TARGET_NAME} 内含图像信号处理器 (ISP),是由众多图像处理算法组成的流水线。ISP 从 DVP 摄像头、MIPI-CSI 摄像头或系统存储处接收图像数据,并通过 DMA 将处理后的图像数据写入系统存储。ISP 需要与其他摄像头控制器模块协同工作,无法独立工作。 + +术语表 +------ + +.. list:: + + - MIPI-CSI:符合 MIPI 规范的高速串行摄像头接口 + - DVP:数字视频并行接口,通常由 vsync、hsync、de 和 data 信号组成 + - RAW:直接从图像传感器输出的未处理数据,通常分为 R、Gr、Gb 和 B 四个通道,按位宽分为 RAW8、RAW10、RAW12 等不同格式 + - RGB:由红、绿、蓝三种颜色组成的彩色图像格式,按每种颜色的位宽分为 RGB888、RGB565 等格式 + - YUV:由亮度和色度组成的彩色图像格式,按数据排列方式分为 YUV444、YUV422、YUV420 等格式 + - AF:自动对焦 + - AWB:自动白平衡 + - AE:自动曝光 + - HIST:直方图 + - BF:拜耳域降噪 + - CCM:色彩校正矩阵 + +ISP 流水线 +---------- + +.. blockdiag:: + :scale: 100% + :caption: ISP 流水线 + :align: center + + blockdiag isp_pipeline { + orientation = portrait; + node_height = 30; + node_width = 120; + span_width = 100; + default_fontsize = 16; + + isp_header [label = "ISP Header"]; + isp_tail [label = "ISP Tail"]; + isp_chs [label = "对比度 &\n 色调 & 饱和度", width = 150, height = 70]; + isp_yuv [label = "YUV 限制\n YUB2RGB", width = 120, height = 70]; + + isp_header -> BF -> 去马赛克 -> CCM -> gamma 校正 -> RGB 转 YUV -> 锐化 -> isp_chs -> isp_yuv -> isp_tail; + + BF -> HIST + 去马赛克 -> AWB + 去马赛克 -> AE + 去马赛克 -> HIST + CCM -> AWB + gamma 校正 -> AE + RGB 转 YUV -> HIST + RGB 转 YUV -> AF + } + +功能概述 +-------- + +ISP 驱动程序提供以下服务: + +- :ref:`isp-resource-allocation` - 涵盖如何通过正确的配置来分配 ISP 资源,以及完成工作后如何回收资源。 +- :ref:`isp-enable-disable` - 涵盖如何启用和禁用 ISP 处理器。 +- :ref:`isp-af-statistics` - 涵盖如何单次或连续获取 AF 统计信息。 +- :ref:`isp-awb-statistics` - 涵盖如何单次或连续获取 AWB 白块统计信息。 +- :ref:`isp-ae-statistics` - 涵盖如何单次或连续获取 AE 统计信息。 +- :ref:`isp-hist-statistics` - 涵盖如何单次或连续获取直方图统计信息。 +- :ref:`isp-bf` - 涵盖如何启用和配置 BF 功能。 +- :ref:`isp-ccm-config` - 涵盖如何配置 CCM。 +- :ref:`isp-demosaic` - 涵盖如何配置去马赛克功能。 +- :ref:`isp-gamma-correction` - 涵盖如何启用和配置 gamma 校正。 +- :ref:`isp-sharpen` - 涵盖如何配置锐化功能。 +- :ref:`isp-callback` - 涵盖如何将用户特定代码挂接到 ISP 驱动事件回调。 +- :ref:`isp-thread-safety` - 列出了驱动程序中线程安全的 API。 +- :ref:`isp-kconfig-options` - 列出了支持的 Kconfig 选项,这些选项可以对驱动程序产生不同影响。 +- :ref:`isp-iram-safe` - 描述了当 cache 被禁用时,如何使 ISP 中断和控制功能正常工作。 + +.. _isp-resource-allocation: + +资源分配 +^^^^^^^^ + +安装 ISP 驱动程序 +~~~~~~~~~~~~~~~~~ + +ISP 驱动程序需要由 :cpp:type:`esp_isp_processor_cfg_t` 指定配置。 + +指定 :cpp:type:`esp_isp_processor_cfg_t` 中的配置后,可以调用 :cpp:func:`esp_isp_new_processor` 来分配和初始化 ISP 处理器。如果函数运行正常,将返回一个 ISP 处理器句柄。请参考以下代码: + +.. code-block:: c + + esp_isp_processor_cfg_t isp_config = { + .clk_src = ISP_CLK_SRC_DEFAULT, + ... + }; + + isp_proc_handle_t isp_proc = NULL; + ESP_ERROR_CHECK(esp_isp_new_processor(&isp_config, &isp_proc)); + +使用上述句柄,可以启用/禁用 ISP 驱动程序,也可以安装其他 ISP 模块。 + + +安装 ISP 自动对焦 (AF) 驱动程序 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP 自动对焦 (AF) 驱动程序需要由 :cpp:type:`esp_isp_af_config_t` 指定配置。 + +指定 :cpp:type:`esp_isp_af_config_t` 中的配置后,可以调用 :cpp:func:`esp_isp_new_af_controller` 来分配和初始化 ISP AF 控制器。如果函数运行正常,将返回一个 ISP AF 控制器句柄。请参考以下代码: + +.. code-block:: c + + esp_isp_af_config_t af_config = { + .edge_thresh = 128, + }; + isp_af_ctlr_t af_ctrlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr)); + +使用上述句柄,可以启用/禁用 ISP AF 驱动程序,也可以安装 ISP AF 环境检测模块。 + +安装 ISP 自动白平衡 (AWB) 驱动程序 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP 自动白平衡 (AWB) 驱动程序需要由 :cpp:type:`esp_isp_awb_config_t` 指定配置。 + +指定 :cpp:type:`esp_isp_awb_config_t` 中的配置后,可以调用 :cpp:func:`esp_isp_new_awb_controller` 来分配和初始化 ISP AWB 控制器。如果函数运行正常,将返回一个 ISP AWB 控制器句柄。请参考以下代码: + +.. code-block:: c + + isp_awb_ctlr_t awb_ctlr = NULL; + uint32_t image_width = 800; + uint32_t image_height = 600; + /* AWB 配置,请参考 API 注释来调整参数 */ + esp_isp_awb_config_t awb_config = { + .sample_point = ISP_AWB_SAMPLE_POINT_AFTER_CCM, + ... + }; + ESP_ERROR_CHECK(esp_isp_new_awb_controller(isp_proc, &awb_config, &awb_ctlr)); + +其他 AWB API 和 AWB 方案也需要此步骤中创建的 AWB 句柄。 + +安装 ISP 自动曝光 (AE) 驱动程序 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP 自动曝光 (AE) 驱动程序需要由 :cpp:type:`esp_isp_ae_config_t` 指定配置。 + +指定 :cpp:type:`esp_isp_ae_config_t` 中的配置后,可以调用 :cpp:func:`esp_isp_new_ae_controller` 来分配和初始化 ISP AE 控制器。如果函数运行正常,将返回一个 ISP AE 控制器句柄。请参考以下代码: + +.. code-block:: c + + esp_isp_ae_config_t ae_config = { + .sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, + ... + }; + isp_ae_ctlr_t ae_ctlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctlr)); + +使用上述句柄,可以启用/禁用 ISP AE 驱动程序,也可以设置 ISP AE 环境检测器。 + +安装 ISP 直方图 (HIST) 驱动程序 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP 直方图 (HIST) 驱动程序需要由 :cpp:type:`esp_isp_hist_config_t` 指定配置。 + +指定 :cpp:type:`esp_isp_hist_config_t` 中的配置后,可以调用 :cpp:func:`esp_isp_new_hist_controller` 来分配和初始化 ISP 直方图控制器。如果此函数运行正常,将返回一个 ISP HIST 控制器句柄。请参考以下代码。 + +.. list:: + + - 所有子窗口权重的十进制值之和应为 256,否则统计数据将较小,并且整数值应为 0。 + - 所有 RGB 系数的十进制值之和应为 256,否则统计数据将较小,并且整数值应为 0。 + - segment_threshold 必须在 0~255 之间且按顺序排列。 + +.. code:: c + + esp_isp_hist_config_t hist_cfg = { + .segment_threshold = {16, 32, 48, 64, 80, 96, 112, 128, 144, 160, 176, 192, 208, 224, 240}, + .hist_mode = ISP_HIST_SAMPLING_RGB, + .rgb_coefficient.coeff_r = { + .integer = 0, + .decimal = 86, + }, + .rgb_coefficient.coeff_g = { + .integer = 0, + .decimal = 85, + }, + .rgb_coefficient.coeff_b = { + .integer = 0, + .decimal = 85, + }, + .window_weight = { + {{16, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, + {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, + {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, + {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, + {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, {{10, 0}}, + }, + }; + isp_hist_ctlr_t hist_ctlr_ctlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_hist_controller(isp_proc, &hist_config, &hist_ctlr)); + +使用上述句柄,可以启用/禁用 ISP HIST 驱动程序的设置。 + +卸载 ISP 驱动程序 +~~~~~~~~~~~~~~~~~ + +如果不再需要先前安装的 ISP 驱动程序,建议通过调用 API 来回收资源,并释放底层硬件: + +.. list:: + + - :cpp:func:`esp_isp_del_processor`,用于 ISP 核心处理器。 + - :cpp:func:`esp_isp_del_af_controller`,用于 ISP AF 控制器。 + - :cpp:func:`esp_isp_del_awb_controller`,用于 ISP AWB 控制器。 + - :cpp:func:`esp_isp_del_ae_controller`,用于 ISP AE 控制器。 + - :cpp:func:`esp_isp_del_hist_controller`,用于 ISP 直方图控制器。 + +.. _isp-enable-disable: + +启用和禁用 ISP +^^^^^^^^^^^^^^ + +ISP +~~~ + +在进行 ISP 流水线操作之前,需要先调用 :cpp:func:`esp_isp_enable` 函数来启用 ISP 处理器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +ISP AF 控制器 +~~~~~~~~~~~~~ + +在进行 ISP AF 操作之前,需要先调用 :cpp:func:`esp_isp_af_controller_enable` 函数来启用 ISP AF 控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_af_controller_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-af-statistics: + +单次与连续 AF 数据统计 +^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_af_controller_get_oneshot_statistics` 可获取单次 AF 统计结果,请参考以下代码。 + +除此之外,ISP AF 驱动程序还可以连续获取 AF 统计信息。调用 :cpp:func:`esp_isp_af_controller_start_continuous_statistics` 可启动连续统计,调用 :cpp:func:`esp_isp_af_controller_stop_continuous_statistics` 可停止统计。 + +若想启用连续统计,需要先注册回调函数 :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_statistics_done` 或 :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_change` 以获取统计数据。有关如何注册回调函数,请参见 :ref:`isp-callback`。 + +.. note:: + + 使用连续统计时,AF 环境检测器将失效。 + +.. code-block:: c + + esp_isp_af_config_t af_config = { + .edge_thresh = 128, + }; + isp_af_ctlr_t af_ctrlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr)); + ESP_ERROR_CHECK(esp_isp_af_controller_enable(af_ctrlr)); + isp_af_result_t result = {}; + /* 触发单次 AF 统计并获取结果,超时时长为 2000 ms */ + ESP_ERROR_CHECK(esp_isp_af_controller_get_oneshot_statistics(af_ctrlr, 2000, &result)); + + /* 启动连续 AF 数据统计 */ + ESP_ERROR_CHECK(esp_isp_af_controller_start_continuous_statistics(af_ctrlr)); + // 可在此进行其他操作,统计结果可从回调函数中获取 + // ...... + // vTaskDelay(pdMS_TO_TICKS(1000)); + /* 停止连续 AF 数据统计 */ + ESP_ERROR_CHECK(esp_isp_af_controller_stop_continuous_statistics(af_ctrlr)); + + /* 禁用 AF 控制器 */ + ESP_ERROR_CHECK(esp_isp_af_controller_disable(af_ctrlr)); + /* 删除 AF 控制器并释放资源 */ + ESP_ERROR_CHECK(esp_isp_del_af_controller(af_ctrlr)); + +设置 AF 环境检测器 +^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_af_controller_set_env_detector` 来设置 ISP AF 环境检测器,请参考以下代码: + +.. code-block:: c + + esp_isp_af_env_config_t env_config = { + .interval = 10, + }; + isp_af_ctlr_t af_ctrlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_af_controller(isp_proc, &af_config, &af_ctrlr)); + ESP_ERROR_CHECK(esp_isp_af_controller_set_env_detector(af_ctrlr, &env_config)); + +设置 AF 环境检测器阈值 +^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_af_controller_set_env_detector_threshold` 来设置 ISP AF 环境检测器的阈值。 + +.. code-block:: c + + int definition_thresh = 0; + int luminance_thresh = 0; + ESP_ERROR_CHECK(esp_isp_af_env_detector_set_threshold(env_detector, definition_thresh, luminance_thresh)); + +ISP AWB 控制器 +~~~~~~~~~~~~~~ + +在进行 ISP AWB 操作之前,需要先调用 :cpp:func:`esp_isp_awb_controller_enable` 以启用 ISP AWB 控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_awb_controller_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-awb-statistics: + +单次与连续 AWB 数据统计 +^^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_awb_controller_get_oneshot_statistics` 可获取单次 AWB 白块统计结果,请参考以下代码。 + +除此之外,ISP AWB 驱动程序还可以连续获取 AWB 统计信息。调用 :cpp:func:`esp_isp_awb_controller_start_continuous_statistics` 可启动连续统计,调用 :cpp:func:`esp_isp_awb_controller_stop_continuous_statistics` 可停止统计。 + +若想启用连续统计,需要先注册回调函数 :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` 以获取统计结果。有关如何注册回调函数,请参见 :ref:`isp-callback`。 + +.. code-block:: c + + bool example_isp_awb_on_statistics_done_cb(isp_awb_ctlr_t awb_ctlr, const esp_isp_awb_evt_data_t *edata, void *user_data); + // ... + isp_awb_ctlr_t awb_ctlr = NULL; + uint32_t image_width = 800; + uint32_t image_height = 600; + /* AWB 配置,请参考 API 注释来调整参数 */ + esp_isp_awb_config_t awb_config = { + .sample_point = ISP_AWB_SAMPLE_POINT_AFTER_CCM, + ... + }; + isp_awb_stat_result_t stat_res = {}; + /* 创建 AWB 控制器 */ + ESP_ERROR_CHECK(esp_isp_new_awb_controller(isp_proc, &awb_config, &awb_ctlr)); + /* 注册 AWB 回调函数 */ + esp_isp_awb_cbs_t awb_cb = { + .on_statistics_done = example_isp_awb_on_statistics_done_cb, + }; + ESP_ERROR_CHECK(esp_isp_awb_register_event_callbacks(awb_ctlr, &awb_cb, NULL)); + /* 启用 AWB 控制器 */ + ESP_ERROR_CHECK(esp_isp_awb_controller_enable(awb_ctlr)); + + /* 获取单次 AWB 统计结果 */ + ESP_ERROR_CHECK(esp_isp_awb_controller_get_oneshot_statistics(awb_ctlr, -1, &stat_res)); + + /* 启动连续 AWB 数据统计,注意在此之前需要先注册 `on_statistics_done` 回调函数 */ + ESP_ERROR_CHECK(esp_isp_awb_controller_start_continuous_statistics(awb_ctlr)); + // 可在此进行其他操作,统计结果可从回调函数中获取 + // ...... + // vTaskDelay(pdMS_TO_TICKS(1000)); + /* 停止连续 AWB 数据统计 */ + ESP_ERROR_CHECK(esp_isp_awb_controller_stop_continuous_statistics(awb_ctlr)); + + /* 禁用 AWB 控制器 */ + ESP_ERROR_CHECK(esp_isp_awb_controller_disable(awb_ctlr)); + /* 删除 AWB 控制器并释放资源 */ + ESP_ERROR_CHECK(esp_isp_del_awb_controller(awb_ctlr)); + +ISP AE 控制器 +~~~~~~~~~~~~~ + +在进行 ISP AE 操作之前,需要先调用 :cpp:func:`esp_isp_ae_controller_enable` 来启用 ISP AE 控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_ae_controller_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-ae-statistics: + +单次与连续 AE 数据统计 +^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_ae_controller_get_oneshot_statistics` 可获取单次 AE 统计结果,请参考以下代码。 + +使用单次 AE 数据统计时,需要禁用连续 AE 模式,否则结果可能会被环境检测器覆盖。完成单次操作后,请重新启动连续模式。 + +除了上述单次统计 API 外,ISP AE 驱动程序还可以连续获取 AE 统计信息。调用 :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` 可启动连续统计,调用 :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` 可停止统计。 + +若想启用连续统计,需要先注册回调函数 :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` 或 :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` 以获取统计数据。有关如何注册回调函数,请参见 :ref:`isp-callback`。 + +.. note:: + + 使用单次统计时,AE 环境检测器将暂时失效,并在完成单次操作后自动恢复。 + +.. code-block:: c + + esp_isp_ae_config_t ae_config = { + .sample_point = ISP_AE_SAMPLE_POINT_AFTER_DEMOSAIC, + }; + isp_ae_ctlr_t ae_ctlr = NULL; + ESP_ERROR_CHECK(esp_isp_new_ae_controller(isp_proc, &ae_config, &ae_ctlr)); + ESP_ERROR_CHECK(esp_isp_ae_controller_enable(ae_ctlr)); + isp_ae_result_t result = {}; + /* 触发单次 AE 统计并获取结果,超时时长为 2000 ms */ + ESP_ERROR_CHECK(esp_isp_ae_controller_get_oneshot_statistics(ae_ctlr, 2000, &result)); + + /* 启动连续 AE 数据统计 */ + ESP_ERROR_CHECK(esp_isp_ae_controller_start_continuous_statistics(ae_ctlr)); + // 可在此进行其他操作,统计结果可从回调函数中获取 + // ...... + // vTaskDelay(pdMS_TO_TICKS(1000)); + /* 停止连续 AE 数据统计 */ + ESP_ERROR_CHECK(esp_isp_ae_controller_stop_continuous_statistics(ae_ctlr)); + + /* 禁用 AE 控制器 */ + ESP_ERROR_CHECK(esp_isp_ae_controller_disable(ae_ctlr)); + /* 删除 AE 控制器并释放资源 */ + ESP_ERROR_CHECK(esp_isp_del_ae_controller(ae_ctlr)); + +设置 AE 环境检测器 +^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_ae_controller_set_env_detector` 来设置 ISP AE 环境检测器,请参考以下代码: + +.. code:: c + + esp_isp_ae_env_config_t env_config = { + .interval = 10, + }; + ESP_ERROR_CHECK(esp_isp_ae_controller_set_env_detector(ae_ctlr, &env_config)); + +设置 AE 环境检测器阈值 +^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_ae_controller_set_env_detector_threshold` 来设置 ISP AE 环境检测器的阈值 (1-255)。 + +.. code:: c + + esp_isp_ae_env_thresh_t env_thresh = { + .low_thresh = 110, + .high_thresh = 130, + }; + ESP_ERROR_CHECK(esp_isp_ae_controller_set_env_detector_threshold(ae_ctlr, env_thresh)); + +.. _isp-hist: + +ISP 直方图控制器 +~~~~~~~~~~~~~~~~ + +在进行 ISP 直方图统计之前,需要先调用 :cpp:func:`esp_isp_hist_controller_enable` 以启用 ISP 直方图控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_hist_controller_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-hist-statistics: + +单次与连续直方图数据统计 +^^^^^^^^^^^^^^^^^^^^^^^^ + +调用 :cpp:func:`esp_isp_hist_controller_get_oneshot_statistics` 可获取单次直方图统计结果,请参考以下代码。 + +除此之外,ISP 直方图驱动程序还可以连续获取直方图统计信息。调用 :cpp:func:`esp_isp_hist_controller_start_continuous_statistics` 可启动连续统计,调用 :cpp:func:`esp_isp_hist_controller_stop_continuous_statistics` 可停止连续统计。 + +若想启用连续统计,需要先注册回调函数 :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` 以获取统计结果。有关如何注册回调函数,请参见 :ref:`isp-callback`。 + +.. code:: c + + static bool s_hist_scheme_on_statistics_done_callback(isp_hist_ctlr_t awb_ctrlr, const esp_isp_hist_evt_data_t *edata, void *user_data) + { + for(int i = 0; i < 16; i++) { + esp_rom_printf(DRAM_STR("val %d is %x\n"), i, edata->hist_result.hist_value[i]); // 获取直方图统计值 + } + return true; + } + + esp_isp_hist_cbs_t hist_cbs = { + .on_statistics_done = s_hist_scheme_on_statistics_done_callback, + }; + + esp_isp_hist_register_event_callbacks(hist_ctlr, &hist_cbs, hist_ctlr); + esp_isp_hist_controller_enable(hist_ctlr); + + +.. _isp-bf: + +ISP BF 控制器 +~~~~~~~~~~~~~ + +此流水线用于在拜耳模式下进行图像输入降噪。 + +可调用 :cpp:func:`esp_isp_bf_configure` 函数配置 BF 功能,请参考以下代码: + +.. code-block:: c + + esp_isp_bf_config_t bf_config = { + .denoising_level = 5, + .bf_template = { + {1, 2, 1}, + {2, 4, 2}, + {1, 2, 1}, + }, + ... + }; + ESP_ERROR_CHECK(esp_isp_bf_configure(isp_proc, &bf_config)); + ESP_ERROR_CHECK(esp_isp_bf_enable(isp_proc)); + +:cpp:member:`esp_isp_bf_config_t::bf_template` 用于拜耳域降噪。可以通过高斯滤波器模板或均值滤波器模板来设置 :cpp:member:`esp_isp_bf_config_t::bf_template`。 + +调用 :cpp:func:`esp_isp_bf_configure` 后,需要通过调用 :cpp:func:`esp_isp_bf_enable` 来启用 ISP BF 控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_bf_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-color: + +ISP 色彩控制器 +~~~~~~~~~~~~~~ + +该流水线用于调整图像的对比度、饱和度、色调和亮度。 + +可调用 :cpp:func:`esp_isp_color_configure` 函数配置色彩功能,请参考以下代码。 + +{IDF_TARGET_SOC_ISP_COLOR_CONTRAST_MAX:default="1.0", esp32p4="1.0"} +{IDF_TARGET_SOC_ISP_COLOR_CONTRAST_DEFAULT:default="1.0", esp32p4="1.0"} + +{IDF_TARGET_SOC_ISP_COLOR_SATURATION_MAX:default="1.0", esp32p4="1.0"} +{IDF_TARGET_SOC_ISP_COLOR_SATURATION_DEFAULT:default="1.0", esp32p4="1.0"} + +{IDF_TARGET_SOC_ISP_COLOR_HUE_MAX:default="360", esp32p4="360"} +{IDF_TARGET_SOC_ISP_COLOR_HUE_DEFAULT:default="0", esp32p4="0"} + +{IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MIN:default="-127", esp32p4="-127"} +{IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MAX:default="128", esp32p4="128"} +{IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_DEFAULT:default="0", esp32p4="0"} + +.. list:: + + - 对比度应为 0 ~ {IDF_TARGET_SOC_ISP_COLOR_CONTRAST_MAX},默认值为 {IDF_TARGET_SOC_ISP_COLOR_CONTRAST_DEFAULT} + - 饱和度应为 0 ~ {IDF_TARGET_SOC_ISP_COLOR_SATURATION_MAX},默认值为 {IDF_TARGET_SOC_ISP_COLOR_SATURATION_DEFAULT} + - 色调应为 0 ~ {IDF_TARGET_SOC_ISP_COLOR_HUE_MAX},默认值为 {IDF_TARGET_SOC_ISP_COLOR_HUE_DEFAULT} + - 亮度应为 {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MIN} ~ {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_MAX},默认值为 {IDF_TARGET_SOC_ISP_COLOR_BRIGHTNESS_DEFAULT} + +.. code:: c + + esp_isp_color_config_t color_config = { + .color_contrast = { + .integer = 1, + .decimal = 0, + }, + .color_saturation = { + .integer = 1, + .decimal = 0, + }, + .color_hue = 0, + .color_brightness = 0, + }; + ESP_ERROR_CHECK(esp_isp_color_configure(isp_proc, &color_config)); + ESP_ERROR_CHECK(esp_isp_color_enable(isp_proc)); + +调用 :cpp:func:`esp_isp_color_configure` 后,需要通过调用 :cpp:func:`esp_isp_color_enable` 来启用 ISP 色彩控制器。此函数: + +* 将驱动程序状态从 **init** 切换为 **enable**。 + +调用 :cpp:func:`esp_isp_color_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +.. _isp-ccm-config: + +配置 CCM +^^^^^^^^ + +色彩校正矩阵可以调整 RGB888 像素格式的颜色比例,可用于通过算法调整图像颜色(例如,使用 AWB 计算结果进行白平衡),或者通过滤波算法用作过滤器。 + +调整色彩校正矩阵的公式如下: + +.. code-block:: none + + [ R' ] [ RR RG RB ] [ R ] + [ G' ] = [ GR GG GB ] * [ G ] + [ B' ] [ BR BG BB ] [ B ] + +可以参考以下代码进行配置: + +.. code-block:: c + + // ... + // 配置 CCM + esp_isp_ccm_config_t ccm_cfg = { + .matrix = { + 1.0, 0.0, 0.0, + 0.0, 1.0, 0.0, + 0.0, 0.0, 1.0 + }, + .saturation = false, + ... + }; + ESP_ERROR_CHECK(esp_isp_ccm_configure(isp_proc, &ccm_cfg)); + // 启用 CCM 模块后,配置好的 CCM 将应用到图像上 + ESP_ERROR_CHECK(esp_isp_ccm_enable(isp_proc)); + // CCM 也可以在启用后进行配置 + ccm_cfg.matrix[0][0] = 2.0; + ESP_ERROR_CHECK(esp_isp_ccm_configure(isp_proc, &ccm_cfg)); + // 如果不再需要 CCM,则禁用它 + ESP_ERROR_CHECK(esp_isp_ccm_disable(isp_proc)); + +.. _isp-demosaic: + +ISP 去马赛克控制器 +~~~~~~~~~~~~~~~~~~~~~~ + +此流水线用于执行图像去马赛克算法,将 RAW 图像转换为 RGB 模式。 + +可调用 :cpp:func:`esp_isp_demosaic_configure` 来配置去马赛克功能,请参考以下代码: + +.. code:: c + + esp_isp_demosaic_config_t demosaic_config = { + .grad_ratio = { + .integer = 2, + .decimal = 5, + }, + ... + }; + + ESP_ERROR_CHECK(esp_isp_demosaic_configure(isp_proc, &sharpen_config)); + ESP_ERROR_CHECK(esp_isp_demosaic_enable(isp_proc)); + +调用 :cpp:func:`esp_isp_demosaic_configure` 后,需要通过调用 :cpp:func:`esp_isp_demosaic_enable` 来启用 ISP 去马赛克控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_demosaic_disable` 会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +即使驱动程序处于 **init** 状态,也可以调用 :cpp:func:`esp_isp_demosaic_configure`,但去马赛克配置只有在 **enable** 状态下才会生效。 + +.. _isp-gamma-correction: + +启用 gamma 校正 +^^^^^^^^^^^^^^^ + +人眼的视觉系统对物理亮度的感知是非线性的。将 gamma 校正添加到 ISP 流水线中,可以将 RGB 坐标转换为坐标与主观亮度成正比的空间。 + +驱动程序提供了帮助函数 :cpp:func:`esp_isp_gamma_fill_curve_points`,用于填充 :cpp:type:`isp_gamma_curve_points_t`,这是描述 gamma 校正曲线的点集合。也可以通过手动声明点来获得期望的 gamma 校正曲线。每个 R/G/B 分量有自己的 gamma 校正曲线,可以通过调用 :cpp:func:`esp_isp_gamma_configure` 来配置。 + +以下是一个典型的代码示例: + +.. code:: c + + #include + + // 设置相机 gamma 为 0.7,gamma 校正曲线为 y = 256 * (x / 256) ^ 0.7 + static uint32_t s_gamma_curve(uint32_t x) + { + return pow((double)x / 256, 0.7) * 256; + } + + isp_gamma_curve_points_t pts = {}; + ESP_ERROR_CHECK(esp_isp_gamma_fill_curve_points(s_gamma_curve, &pts)); + ESP_ERROR_CHECK(esp_isp_gamma_configure(isp_proc, COLOR_COMPONENT_R, &pts)); + ESP_ERROR_CHECK(esp_isp_gamma_configure(isp_proc, COLOR_COMPONENT_G, &pts)); + ESP_ERROR_CHECK(esp_isp_gamma_configure(isp_proc, COLOR_COMPONENT_B, &pts)); + + // 配置完曲线参数后启用 gamma 模块 + ESP_ERROR_CHECK(esp_isp_gamma_enable(isp_proc)); + + // 如果不再需要,则禁用 gamma + ESP_ERROR_CHECK(esp_isp_gamma_disable(isp_proc)); + +.. _isp-sharpen: + +ISP 锐化控制器 +~~~~~~~~~~~~~~ + +此流水线用于在 YUV 模式下锐化输入图像。 + +调用 :cpp:func:`esp_isp_sharpen_configure` 来配置锐化功能,请参考以下代码。 + +.. code:: c + + esp_isp_sharpen_config_t sharpen_config = { + .h_thresh = 255, + .sharpen_template = { + {1, 2, 1}, + {2, 4, 2}, + {1, 2, 1}, + }, + ... + }; + ESP_ERROR_CHECK(esp_isp_sharpen_configure(isp_proc, &sharpen_config)); + ESP_ERROR_CHECK(esp_isp_sharpen_enable(isp_proc)); + +调用 :cpp:member:`esp_isp_sharpen_config_t::sharpen_template` 进行锐化。可以通过高斯滤波器模板或均值滤波器模板来设置 :cpp:member:`esp_isp_sharpen_config_t::sharpen_template`。 + +调用 :cpp:func:`esp_isp_sharpen_configure` 后,需要通过调用 :cpp:func:`esp_isp_sharpen_enable` 以启用 ISP 锐化控制器。此函数: + +* 将驱动程序状态从 **init** 切换到 **enable**。 + +调用 :cpp:func:`esp_isp_sharpen_disable` 函数会执行相反的操作,即将驱动程序恢复到 **init** 状态。 + +即使驱动程序处于 **init** 状态,也可以调用 :cpp:func:`esp_isp_sharpen_configure`,但锐化配置只有在 **enable** 状态下才会生效。 + + +.. _isp-callback: + +注册事件回调函数 +^^^^^^^^^^^^^^^^ + +ISP 模块启动后,会动态生成特定事件。 + +你也可以通过参数 ``user_data`` 将自己的上下文保存到回调函数中,用户数据将直接传递给回调函数。 + +.. note:: + + 下文中提到的回调函数在 ISR 上下文中被调用,必须确保这些函数不会尝试阻塞(例如,确保只从函数中调用带有 ``ISR`` 后缀的 FreeRTOS API)。 + +注册 ISP 处理器事件回调函数 +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +启用 ISP 处理器后,会动态生成多个 ISP 子模块的事件。可以通过调用 :cpp:func:`esp_isp_register_event_callbacks` 将函数挂接到中断服务例程。所有支持的事件回调函数可参见 :cpp:type:`esp_isp_evt_cbs_t`: + +- :cpp:member:`esp_isp_evt_cbs_t::on_sharpen_frame_done` 在完成锐化帧后设置回调函数。ISP 锐化子模块完成一帧的操作后会调用此函数。函数原型在 :cpp:type:`esp_isp_sharpen_callback_t` 中声明。 + +注册 ISP AF 环境检测器事件回调函数 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP AF 环境检测器启动后,将动态生成特定事件。若想在事件发生时调用某些函数,请通过调用 :cpp:func:`esp_isp_af_env_detector_register_event_callbacks` 将目标函数挂接到中断服务程序中。所有支持的事件回调函数可参见 :cpp:type:`esp_isp_af_env_detector_evt_cbs_t`: + +- :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_statistics_done` 为环境统计完成事件设置回调函数。该函数原型在 :cpp:type:`esp_isp_af_env_detector_callback_t` 中声明。 +- :cpp:member:`esp_isp_af_env_detector_evt_cbs_t::on_env_change` 为环境变化事件设置回调函数。该函数原型在 :cpp:type:`esp_isp_af_env_detector_callback_t` 中声明。 + +注册 ISP AWB 统计完成事件回调函数 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP AWB 控制器完成白块数据统计后,将动态生成特定事件。若想在统计完成时收到通知,请通过调用 :cpp:func:`esp_isp_awb_register_event_callbacks` 将目标函数挂接到中断服务程序中。所有支持的事件回调函数可参见 :cpp:type:`esp_isp_awb_cbs_t`: + +- :cpp:member:`esp_isp_awb_cbs_t::on_statistics_done` 在白块数据统计完成后设置回调函数。该函数原型在 :cpp:type:`esp_isp_awb_callback_t` 中声明。 + + +注册 ISP AE 环境检测器事件回调函数 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP AE 环境检测器启动后,将动态生成特定事件。若想在事件发生时调用某些函数,请通过调用 :cpp:func:`esp_isp_ae_env_detector_register_event_callbacks` 将目标函数挂接到中断服务程序中。所有支持的事件回调函数可参见 :cpp:type:`esp_isp_ae_env_detector_evt_cbs_t`: + +- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_statistics_done` 为环境统计完成事件设置回调函数。该函数原型在 :cpp:type:`esp_isp_ae_env_detector_callback_t` 中声明。 +- :cpp:member:`esp_isp_ae_env_detector_evt_cbs_t::on_env_change` 为环境变化事件设置回调函数。该函数原型在 :cpp:type:`esp_isp_ae_env_detector_callback_t` 中声明。 + + +注册 ISP HIST 统计完成事件回调函数 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +ISP HIST 控制器完成亮度统计后,将动态生成特定事件。若想在统计完成时收到通知,请通过调用 :cpp:func:`esp_isp_hist_register_event_callbacks` 将目标函数挂挂接到中断服务程序。所有支持的事件回调函数可参见 :cpp:type:`esp_isp_hist_cbs_t`: + +- :cpp:member:`esp_isp_hist_cbs_t::on_statistics_done` 在完成亮度统计时设置回调函数。该函数原型在 :cpp:type:`esp_isp_hist_callback_t` 中声明。 + +.. _isp-thread-safety: + +线程安全 +^^^^^^^^ + +驱动程序会确保以下工厂函数的线程安全: + +.. list:: + + - :cpp:func:`esp_isp_new_processor` + - :cpp:func:`esp_isp_del_processor` + - :cpp:func:`esp_isp_new_af_controller` + - :cpp:func:`esp_isp_del_af_controller` + - :cpp:func:`esp_isp_new_awb_controller` + - :cpp:func:`esp_isp_del_awb_controller` + - :cpp:func:`esp_isp_new_ae_controller` + - :cpp:func:`esp_isp_del_ae_controller` + - :cpp:func:`esp_isp_new_hist_controller` + - :cpp:func:`esp_isp_del_hist_controller` + +使用时,可以直接从不同的 RTOS 任务中调用此类函数,无需额外锁保护。其他 API 无法确保线程安全。 + +.. _isp-kconfig-options: + +Kconfig 选项 +^^^^^^^^^^^^ + +- :ref:`CONFIG_ISP_ISR_IRAM_SAFE` 控制默认的 ISR 句柄在 cache 被禁用时是否可以正常工作。 + +.. _isp-iram-safe: + +IRAM 安全 +^^^^^^^^^ + +默认情况下,当 cache 因写入或擦除 flash 等原因而被禁用时,ISP 的中断将会延迟。 + +Kconfig 选项 :ref:`CONFIG_ISP_ISR_IRAM_SAFE` 支持: + +- 即使 cache 被禁用也能启用中断 +- 将 ISR 使用的所有函数放入 IRAM +- 将驱动程序对象放入 DRAM(以防意外映射到 PSRAM) + +启用上述 Kconfig 选项,保证 cache 被禁用时中断可以正常运行,但这会增加 IRAM 使用量。启用此选项后,当 cache 被禁用时,ISR 回调函数将继续运行。因此,必须确保回调函数及其上下文也是 IRAM 安全的。 + +Kconfig 选项 :ref:`CONFIG_ISP_CTRL_FUNC_IN_IRAM` 支持: + +- 将一些 ISP 控制函数放入 IRAM,函数列表请参见: + + .. list:: + + - :cpp:func:`esp_isp_sharpen_configure` + - :cpp:func:`esp_isp_demosaic_configure` + +应用示例 +-------- + +* :example:`peripherals/isp/multi_pipelines` 演示了如何使用 ISP 流水线处理来自摄像头传感器的图像信号,并通过 DSI 外设在 LCD 屏幕上显示视频。 + +API 参考 +-------- + +.. include-build-file:: inc/isp.inc +.. include-build-file:: inc/isp_af.inc +.. include-build-file:: inc/isp_ae.inc +.. include-build-file:: inc/isp_awb.inc +.. include-build-file:: inc/isp_bf.inc +.. include-build-file:: inc/isp_ccm.inc +.. include-build-file:: inc/isp_demosaic.inc +.. include-build-file:: inc/isp_sharpen.inc +.. include-build-file:: inc/isp_gamma.inc +.. include-build-file:: inc/isp_hist.inc +.. include-build-file:: inc/isp_color.inc +.. include-build-file:: inc/isp_core.inc +.. include-build-file:: inc/components/esp_driver_isp/include/driver/isp_types.inc +.. include-build-file:: inc/components/hal/include/hal/isp_types.inc From e8f01afef7862e556df54d43f657de3bd0dc6111 Mon Sep 17 00:00:00 2001 From: "C.S.M" Date: Tue, 29 Oct 2024 17:05:14 +0800 Subject: [PATCH 27/70] test(spi_flash): Fix some failing test related to spi flash --- .../spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c | 4 ++++ .../test_apps/esp_flash_stress/pytest_esp_flash_stress.py | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c b/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c index 032c053adda..b75e3b7eafa 100644 --- a/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c +++ b/components/spi_flash/test_apps/esp_flash/main/test_esp_flash_drv.c @@ -595,7 +595,11 @@ TEST_CASE_MULTI_FLASH_IGNORE("Test esp_flash_write can toggle QE bit", test_togg #endif //CONFIG_ESPTOOLPY_OCT_FLASH // This table could be chip specific in the future. +#if CONFIG_IDF_TARGET_ESP32C2 +uint8_t flash_frequency_table[5] = {5, 10, 20, 40}; +#else uint8_t flash_frequency_table[6] = {5, 10, 20, 26, 40, 80}; +#endif #define TEST_FLASH_SPEED_MIN 5 void test_permutations_part(const flashtest_config_t* config, esp_partition_t* part, void* source_buf, size_t length) { diff --git a/components/spi_flash/test_apps/esp_flash_stress/pytest_esp_flash_stress.py b/components/spi_flash/test_apps/esp_flash_stress/pytest_esp_flash_stress.py index 1e855dbcb97..686f4de6955 100644 --- a/components/spi_flash/test_apps/esp_flash_stress/pytest_esp_flash_stress.py +++ b/components/spi_flash/test_apps/esp_flash_stress/pytest_esp_flash_stress.py @@ -52,5 +52,5 @@ def test_esp_flash_stress_rom_xip_psram(dut: Dut) -> None: ], indirect=True, ) -def test_flash_auto_suspend(dut: Dut) -> None: +def test_flash_auto_suspend_stress(dut: Dut) -> None: dut.run_all_single_board_cases() From 949fc7f2c9780199f9a7156d01d8643d8f16bbfd Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Tue, 29 Oct 2024 10:09:42 +0200 Subject: [PATCH 28/70] fix(examples): Fix pytest_otatool for C2 Test for C2 has to be run with flash_4mb --- examples/system/ota/otatool/pytest_otatool.py | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/examples/system/ota/otatool/pytest_otatool.py b/examples/system/ota/otatool/pytest_otatool.py index c0770347369..a8fe39976a2 100644 --- a/examples/system/ota/otatool/pytest_otatool.py +++ b/examples/system/ota/otatool/pytest_otatool.py @@ -8,7 +8,11 @@ from pytest_embedded import Dut -def _real_test_func(dut: Dut) -> None: +@pytest.mark.parametrize('config', [ + pytest.param('default', marks=[pytest.mark.supported_targets, pytest.mark.generic, pytest.mark.temp_skip(targets=['esp32c2'], reason='must have 4MB')]), + pytest.param('default', marks=[pytest.mark.esp32c2, pytest.mark.generic, pytest.mark.flash_4mb]), +], indirect=True) +def test_otatool_example(dut: Dut) -> None: # Verify factory firmware dut.expect('OTA Tool Example') dut.expect('Example end') @@ -24,16 +28,3 @@ def _real_test_func(dut: Dut) -> None: binary_path = flash_file[1] break subprocess.check_call([sys.executable, script_path, '--binary', binary_path]) - - -@pytest.mark.supported_targets -@pytest.mark.generic -def test_otatool_example(dut: Dut) -> None: - _real_test_func(dut) - - -@pytest.mark.esp32c2 -@pytest.mark.generic -@pytest.mark.flash_4mb -def test_otatool_example_c2_4mb(dut: Dut) -> None: - _real_test_func(dut) From 8f7672e117294cb5adffdfcf3b1aae1ba3e9040c Mon Sep 17 00:00:00 2001 From: zhanghaipeng Date: Wed, 16 Oct 2024 20:49:57 +0800 Subject: [PATCH 29/70] fix(bt/ble): Update esp32 libbtdm_app.a (17db8bd) - Added a verification step for the Access Address within the CONNECT_IND PDU --- components/bt/controller/esp32/Kconfig.in | 9 +++++++++ components/bt/controller/lib_esp32 | 2 +- components/bt/include/esp32/include/esp_bt.h | 10 +++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/components/bt/controller/esp32/Kconfig.in b/components/bt/controller/esp32/Kconfig.in index 0fd0b6e4137..80f8bb2d6e8 100644 --- a/components/bt/controller/esp32/Kconfig.in +++ b/components/bt/controller/esp32/Kconfig.in @@ -444,6 +444,15 @@ config BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX minimize collision of scan request PDUs from nultiple scanners. If scan backoff is disabled, in active scanning, scan request PDU will be sent every time when HW receives scannable ADV PDU. +config BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS + bool "Enable enhanced Access Address check in CONNECT_IND" + default n + help + Enabling this option will add stricter verification of the Access Address in the CONNECT_IND PDU. + This improves security by ensuring that only connection requests with valid Access Addresses are accepted. + If disabled, only basic checks are applied, improving compatibility. + + config BTDM_BLE_ADV_REPORT_FLOW_CTRL_SUPP bool "BLE adv report flow control supported" depends on (BTDM_CTRL_MODE_BTDM || BTDM_CTRL_MODE_BLE_ONLY) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index c3f6258cfbd..171c4a7653d 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit c3f6258cfbd776d51e30bd6168f42b0cf5d73ea8 +Subproject commit 171c4a7653d2ef56edecaa832bdd4faedd403d77 diff --git a/components/bt/include/esp32/include/esp_bt.h b/components/bt/include/esp32/include/esp_bt.h index 43c475e7e6d..4aa60073d3e 100644 --- a/components/bt/include/esp32/include/esp_bt.h +++ b/components/bt/include/esp32/include/esp_bt.h @@ -55,7 +55,7 @@ extern "C" { * * @note Please do not modify this value */ -#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240926 +#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20241015 /** * @brief Bluetooth Controller mode @@ -193,6 +193,12 @@ the advertising packet will be discarded until the memory is restored. */ #define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE) +#ifdef CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS +#else +#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0 +#endif + /** * @brief Default Bluetooth Controller configuration */ @@ -222,6 +228,7 @@ the advertising packet will be discarded until the memory is restored. */ .dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \ .ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \ .ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \ + .ble_aa_check = BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \ .magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \ } @@ -275,6 +282,7 @@ typedef struct { uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig */ bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig */ uint8_t ble_llcp_disc_flag; /*!< BLE disconnect flag when instant passed. Configurable in menuconfig */ + bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the CONNECT_IND PDU; false otherwise. Configurable in menuconfig */ uint32_t magic; /*!< Magic number */ } esp_bt_controller_config_t; From 1cd9dd5001b8afed71216acc32e79caaff925976 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 17 Oct 2024 18:17:36 +0800 Subject: [PATCH 30/70] refactor(touch): refactor touch low-level for s2 & s3 --- components/hal/CMakeLists.txt | 7 +- .../hal/esp32p4/include/hal/touch_sensor_ll.h | 40 +- .../esp32s2/include/hal/touch_sensor_hal.h | 26 +- .../hal/esp32s2/include/hal/touch_sensor_ll.h | 913 +++++++++++++---- components/hal/esp32s2/touch_sensor_hal.c | 14 +- .../esp32s3/include/hal/touch_sensor_hal.h | 26 +- .../hal/esp32s3/include/hal/touch_sensor_ll.h | 938 ++++++++++++++---- components/hal/esp32s3/touch_sensor_hal.c | 15 +- .../hal/touch_sens_hal.h} | 24 +- components/hal/include/hal/touch_sens_types.h | 131 +++ components/hal/include/hal/touch_sensor_hal.h | 1 + .../hal/include/hal/touch_sensor_types.h | 19 +- .../touch_sensor_hal.c => touch_sens_hal.c} | 32 +- .../esp32s2/include/soc/Kconfig.soc_caps.in | 4 + components/soc/esp32s2/include/soc/soc_caps.h | 1 + .../esp32s3/include/soc/Kconfig.soc_caps.in | 4 + components/soc/esp32s3/include/soc/soc_caps.h | 1 + .../esp32s3/register/soc/rtc_cntl_struct.h | 8 +- 18 files changed, 1662 insertions(+), 542 deletions(-) rename components/hal/{esp32p4/include/hal/touch_sensor_hal.h => include/hal/touch_sens_hal.h} (76%) create mode 100644 components/hal/include/hal/touch_sens_types.h rename components/hal/{esp32p4/touch_sensor_hal.c => touch_sens_hal.c} (75%) diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index ba107dbf84f..698bd8adffb 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -282,10 +282,15 @@ if(NOT BOOTLOADER_BUILD) endif() if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) - list(APPEND srcs "${target}/touch_sensor_hal.c") + # Source files for legacy touch driver if(CONFIG_SOC_TOUCH_SENSOR_VERSION LESS 3) + list(APPEND srcs "${target}/touch_sensor_hal.c") list(APPEND srcs "touch_sensor_hal.c") endif() + # Source files for touch driver-ng (currently only support ver2 & ver3) + if(CONFIG_SOC_TOUCH_SENSOR_VERSION GREATER 1) + list(APPEND srcs "touch_sens_hal.c") + endif() endif() if(${target} STREQUAL "esp32") diff --git a/components/hal/esp32p4/include/hal/touch_sensor_ll.h b/components/hal/esp32p4/include/hal/touch_sensor_ll.h index 37280c3b5d2..8425e15b300 100644 --- a/components/hal/esp32p4/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32p4/include/hal/touch_sensor_ll.h @@ -25,6 +25,7 @@ #include "soc/pmu_struct.h" #include "soc/soc_caps.h" #include "hal/touch_sensor_types.h" +#include "hal/touch_sens_types.h" #ifdef __cplusplus extern "C" { @@ -222,10 +223,9 @@ static inline void touch_ll_force_done_curr_measurement(void) * The measurement action can be triggered by the hardware timer, as well as by the software instruction. * @note * The timer should be triggered - * @param is_sleep Whether in sleep state */ __attribute__((always_inline)) -static inline void touch_ll_start_fsm_repeated_timer(bool is_sleep) +static inline void touch_ll_start_fsm_repeated_timer(void) { /** * Touch timer trigger measurement and always wait measurement done. @@ -238,10 +238,9 @@ static inline void touch_ll_start_fsm_repeated_timer(bool is_sleep) /** * Stop touch sensor FSM timer. * The measurement action can be triggered by the hardware timer, as well as by the software instruction. - * @param is_sleep Whether in sleep state */ __attribute__((always_inline)) -static inline void touch_ll_stop_fsm_repeated_timer(bool is_sleep) +static inline void touch_ll_stop_fsm_repeated_timer(void) { PMU.touch_pwr_cntl.sleep_timer_en = 0; touch_ll_force_done_curr_measurement(); @@ -326,7 +325,7 @@ static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) * @return * - ESP_OK on success */ -static inline void touch_ll_set_channel_mask(uint16_t enable_mask) +static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) { // Channel shift workaround: the lowest bit takes no effect uint16_t mask = (enable_mask << 1) & TOUCH_PAD_BIT_MASK_ALL; @@ -502,7 +501,7 @@ static inline uint32_t touch_ll_get_current_meas_channel(void) * * @param int_mask interrupt mask */ -static inline void touch_ll_intr_enable(uint32_t int_mask) +static inline void touch_ll_interrupt_enable(uint32_t int_mask) { uint32_t mask = LP_TOUCH.int_ena.val; mask |= (int_mask & TOUCH_LL_INTR_MASK_ALL); @@ -514,7 +513,7 @@ static inline void touch_ll_intr_enable(uint32_t int_mask) * * @param int_mask interrupt mask */ -static inline void touch_ll_intr_disable(uint32_t int_mask) +static inline void touch_ll_interrupt_disable(uint32_t int_mask) { uint32_t mask = LP_TOUCH.int_ena.val; mask &= ~(int_mask & TOUCH_LL_INTR_MASK_ALL); @@ -527,7 +526,7 @@ static inline void touch_ll_intr_disable(uint32_t int_mask) * @param int_mask Pad mask to clear interrupts */ __attribute__((always_inline)) -static inline void touch_ll_intr_clear(touch_pad_intr_mask_t int_mask) +static inline void touch_ll_interrupt_clear(touch_pad_intr_mask_t int_mask) { LP_TOUCH.int_clr.val = int_mask; } @@ -545,28 +544,23 @@ static inline uint32_t touch_ll_get_intr_status_mask(void) } /** - * Enable the timeout check for all touch sensor channels measurements. + * Set the timeout to enable or disable the check for all touch sensor channels measurements. * When the touch reading of a touch channel exceeds the measurement threshold, * If enable: a timeout interrupt will be generated and it will go to the next channel measurement. * If disable: the FSM is always on the channel, until the measurement of this channel is over. * * @param timeout_cycles The maximum time cycles of the measurement on one channel. + * Set to 0 to disable the timeout. + * Set to non-zero to enable the timeout and set the timeout cycles. */ -static inline void touch_ll_timeout_enable(uint32_t timeout_cycles) +static inline void touch_ll_set_timeout(uint32_t timeout_cycles) { - LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_num = timeout_cycles; - LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_en = 1; -} - -/** - * Disable the timeout check for all touch sensor channels measurements. - * When the touch reading of a touch channel exceeds the measurement threshold, - * If enable: a timeout interrupt will be generated and it will go to the next channel measurement. - * If disable: the FSM is always on the channel, until the measurement of this channel is over. - */ -static inline void touch_ll_timeout_disable(void) -{ - LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_en = 0; + if (timeout_cycles) { + LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_num = timeout_cycles; + LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_en = 1; + } else { + LP_ANA_PERI.touch_scan_ctrl2.touch_timeout_en = 0; + } } /** diff --git a/components/hal/esp32s2/include/hal/touch_sensor_hal.h b/components/hal/esp32s2/include/hal/touch_sensor_hal.h index b42532c78f9..382a52f9378 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_hal.h @@ -278,14 +278,10 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info); /** * Enable touch sensor filter and detection algorithm. * For more details on the detection algorithm, please refer to the application documentation. + * + * @param enable set true to enable the filter */ -#define touch_hal_filter_enable() touch_ll_filter_enable() - -/** - * Disable touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - */ -#define touch_hal_filter_disable() touch_ll_filter_disable() +#define touch_hal_filter_enable(enable) touch_ll_filter_enable(enable) /************************ Denoise register setting ************************/ @@ -326,7 +322,7 @@ void touch_hal_denoise_enable(void); * This denoise function filters out interference introduced on all channels, * such as noise introduced by the power supply and external EMI. */ -#define touch_hal_denoise_disable() touch_ll_denoise_disable() +#define touch_hal_denoise_disable() touch_ll_denoise_enable(false) /** * Set internal reference capacitance of denoise channel. @@ -391,7 +387,7 @@ void touch_hal_denoise_enable(void); * * @param pad_num Touch sensor channel number. */ -#define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_sheild_driver(driver_level) +#define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_shield_driver(driver_level) /** * Get max equivalent capacitance for shield channel. @@ -400,7 +396,7 @@ void touch_hal_denoise_enable(void); * * @param pad_num Touch sensor channel number. */ -#define touch_hal_waterproof_get_sheild_driver(driver_level) touch_ll_waterproof_get_sheild_driver(driver_level) +#define touch_hal_waterproof_get_sheild_driver(driver_level) touch_ll_waterproof_get_shield_driver(driver_level) /** * Set parameter of waterproof function. @@ -430,7 +426,7 @@ void touch_hal_waterproof_enable(void); /** * Disable parameter of waterproof function. */ -#define touch_hal_waterproof_disable() touch_ll_waterproof_disable() +#define touch_hal_waterproof_disable() touch_ll_waterproof_enable(false) /************************ Proximity register setting ************************/ @@ -550,13 +546,9 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable); /** * Enable proximity function for sleep pad. + * @param enable the proximity sensing */ -#define touch_hal_sleep_enable_approach() touch_ll_sleep_enable_proximity_sensing() - -/** - * Disable proximity function for sleep pad. - */ -#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_proximity_sensing() +#define touch_hal_sleep_enable_approach(enable) touch_ll_sleep_enable_proximity_sensing(enable) /** * Read benchmark of touch sensor for sleep pad. diff --git a/components/hal/esp32s2/include/hal/touch_sensor_ll.h b/components/hal/esp32s2/include/hal/touch_sensor_ll.h index 0cc5069d2f2..bf4628cee08 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_ll.h @@ -17,25 +17,714 @@ #include #include #include "hal/misc.h" +#include "hal/assert.h" #include "soc/touch_sensor_periph.h" #include "soc/soc_caps.h" #include "soc/sens_struct.h" #include "soc/rtc_cntl_struct.h" #include "soc/rtc_io_struct.h" #include "hal/touch_sensor_types.h" +#include "hal/touch_sens_types.h" #ifdef __cplusplus extern "C" { #endif #define TOUCH_LL_READ_RAW 0x0 -#define TOUCH_LL_READ_BENCHMARK 0x2 +#define TOUCH_LL_READ_BENCHMARK 0x2 #define TOUCH_LL_READ_SMOOTH 0x3 + #define TOUCH_LL_TIMER_FORCE_DONE 0x3 #define TOUCH_LL_TIMER_DONE 0x0 -#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0xFF) /*! 0); + SENS.touch_thresh[touch_num - 1].thresh = thresh; +} + +/** + * Set the power on wait cycle + * + * @param wait_cycles + */ +static inline void touch_ll_set_power_on_wait_cycle(uint32_t wait_cycles) +{ + //the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, wait_cycles); //wait volt stable +} + +// HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time); +/** + * Set touch sensor touch sensor charge and discharge times of every measurement on a pad. + * + * @param charge_times The times of charge and discharge in each measure process of touch channels. + * The timer frequency is RTC_FAST (about 16M). Range: 0 ~ 0xffff. + */ +static inline void touch_ll_set_charge_times( uint16_t charge_times) +{ + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, charge_times); +} + +/** + * Set touch sensor sleep time. + * + * @param interval_ticks The touch sensor will sleep for some cycles after each measurement. + * interval_ticks decide the interval between each measurement. + * t_sleep = interval_ticks / (RTC_SLOW_CLK frequency). + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + */ +static inline void touch_ll_set_measure_interval_ticks(uint16_t interval_ticks) +{ + // touch sensor sleep cycle Time = interval_ticks / RTC_SLOW_CLK + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, interval_ticks); +} + +static inline void touch_ll_set_charge_speed(uint32_t touch_num, touch_charge_speed_t charge_speed) +{ + RTCIO.touch_pad[touch_num].dac = charge_speed; +} + +static inline void touch_ll_set_charge_voltage_high_limit(touch_volt_lim_h_t high_lim) +{ + RTCCNTL.touch_ctrl2.touch_drefh = (uint32_t)high_lim & 0x3; + RTCCNTL.touch_ctrl2.touch_drange = (uint32_t)high_lim >> 2; +} + +static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_lim) +{ + RTCCNTL.touch_ctrl2.touch_drefl = low_lim; +} + +static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) +{ + RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; +} + +static inline void touch_ll_set_idle_channel_connection(touch_idle_conn_t idle_conn) +{ + RTCCNTL.touch_scan_ctrl.touch_inactive_connection = idle_conn; +} + +/** + * Enable touch sensor channel. Register touch channel into touch sensor measurement group. + * The working mode of the touch sensor is simultaneous measurement. + * This function will set the measure bits according to the given bitmask. + * + * @note If set this mask, the FSM timer should be stop firstly. + * @note The touch sensor that in scan map, should be deinit GPIO function firstly. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM1 -> BIT(1) + * @return + * - ESP_OK on success + */ +static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) +{ + RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = enable_mask; + SENS.sar_touch_conf.touch_outen = enable_mask; +} + +/** + * Set the timeout to enable or disable the check for all touch sensor channels measurements. + * When the touch reading of a touch channel exceeds the measurement threshold, + * If enable: a timeout interrupt will be generated and it will go to the next channel measurement. + * If disable: the FSM is always on the channel, until the measurement of this channel is over. + * + * @param timeout_cycles The maximum time cycles of the measurement on one channel. + * Set to 0 to disable the timeout. + * Set to non-zero to enable the timeout and set the timeout cycles. + */ +static inline void touch_ll_set_timeout(uint32_t timeout_cycles) +{ + if (timeout_cycles) { + RTCCNTL.touch_timeout_ctrl.touch_timeout_num = timeout_cycles; + RTCCNTL.touch_timeout_ctrl.touch_timeout_en = 1; + } else { + RTCCNTL.touch_timeout_ctrl.touch_timeout_en = 0; + } +} + +/** + * Clear all touch sensor channels active status. + * + * @note Generally no manual removal is required. + */ +static inline void touch_ll_clear_active_channel_status(void) +{ + SENS.sar_touch_conf.touch_status_clr = 1; +} + +/** + * Select touch sensor dbias to save power in sleep mode. + * + * @note If change the dbias, the reading of touch sensor will changed. Users should make sure the threshold. + */ +static inline void touch_ll_set_bias_type(touch_bias_type_t bias_type) +{ + RTCCNTL.touch_ctrl2.touch_dbias = bias_type; +} + +/********************************* FSM Operation ******************************/ +/** + * Touch timer trigger measurement and always wait measurement done. + * Force done for touch timer ensures that the timer always can get the measurement done signal. + * @note The `force done` signal should last as least one slow clock tick + */ +__attribute__((always_inline)) +static inline void touch_ll_force_done_curr_measurement(void) +{ + RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_FORCE_DONE; + RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_DONE; +} + +/** + * Enable touch sensor FSM timer trigger (continuous) mode or software trigger (oneshot) mode. + * + * @param enable Enable FSM timer mode. + * True: the FSM will trigger scanning repeatedly under the control of the hardware timer (continuous mode) + * False: the FSM will trigger scanning once under the control of the software (continuous mode) + */ +__attribute__((always_inline)) +static inline void touch_ll_enable_fsm_timer(bool enable) +{ + touch_ll_force_done_curr_measurement(); + // Set 0 to start by timer, otherwise by software + RTCCNTL.touch_ctrl2.touch_start_force = !enable; +} + +/** + * Start touch sensor FSM timer to run FSM repeatedly + * The measurement action can be triggered by the hardware timer, as well as by the software instruction. + * @note + * The timer should be triggered + */ +__attribute__((always_inline)) +static inline void touch_ll_start_fsm_repeated_timer(void) +{ + /** + * Touch timer trigger measurement and always wait measurement done. + * Force done for touch timer ensures that the timer always can get the measurement done signal. + */ + touch_ll_force_done_curr_measurement(); + RTCCNTL.touch_ctrl2.touch_slp_timer_en = 1; +} + +/** + * Stop touch sensor FSM timer. + * The measurement action can be triggered by the hardware timer, as well as by the software instruction. + */ +__attribute__((always_inline)) +static inline void touch_ll_stop_fsm_repeated_timer(void) +{ + RTCCNTL.touch_ctrl2.touch_slp_timer_en = 0; + touch_ll_force_done_curr_measurement(); +} + +/** + * Is the FSM repeated timer enabled. + * @note when the timer is enabled, RTC clock should not be power down + * + * @return + * - true: enabled + * - false: disabled + */ +static inline bool touch_ll_is_fsm_repeated_timer_enabled(void) +{ + return (bool)RTCCNTL.touch_ctrl2.touch_slp_timer_en; +} + + +/** + * Enable the touch sensor FSM start signal from software + */ +__attribute__((always_inline)) +static inline void touch_ll_trigger_oneshot_measurement(void) +{ + RTCCNTL.touch_ctrl2.touch_start_en = 1; + RTCCNTL.touch_ctrl2.touch_start_en = 0; +} + +/** + * @brief Power on the channel by mask + * + * @param chan_mask The channel mask that needs to power on + */ +__attribute__((always_inline)) +static inline void touch_ll_channel_sw_measure_mask(uint16_t chan_mask) +{ + (void) chan_mask; + // Only for compatibility +} + +/****************************** Benchmark Operation ***************************/ +/** + * Force reset benchmark to raw data of touch sensor. + * + * @note If call this API, make sure enable clock gate(`touch_ll_clkgate`) first. + * @param chan_mask touch channel mask + */ +__attribute__((always_inline)) +static inline void touch_ll_reset_chan_benchmark(uint32_t chan_mask) +{ + SENS.sar_touch_chn_st.touch_channel_clr = chan_mask; +} + +static inline void touch_ll_sleep_reset_benchmark(void) +{ + RTCCNTL.touch_approach.touch_slp_channel_clr = 1; +} + +/************************************** Data **********************************/ +/** + * Get the data of the touch channel according to the types + * + * @param touch_num touch pad index + * @param type data type + * 0/1: TOUCH_LL_READ_RAW, raw data of touch channel + * 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel, + * the benchmark value is the maximum during the first measurement period + * 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data. + * @param data pointer to the data + */ +__attribute__((always_inline)) +static inline void touch_ll_read_chan_data(uint32_t touch_num, uint8_t type, uint32_t *data) +{ + HAL_ASSERT(type <= TOUCH_LL_READ_SMOOTH); + HAL_ASSERT(touch_num > 0); + SENS.sar_touch_conf.touch_data_sel = type; + *data = SENS.sar_touch_status[touch_num - 1].touch_pad_data; +} + +/****************************** Filter Configuration **************************/ + +/** + * Enable or disable touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + */ +static inline void touch_ll_filter_enable(bool enable) +{ + RTCCNTL.touch_filter_ctrl.touch_filter_en = enable; +} + +/** + * Set filter mode. The input of the filter is the raw value of touch reading, + * and the output of the filter is involved in the judgment of the touch state. + * + * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. + */ +static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) +{ + RTCCNTL.touch_filter_ctrl.touch_filter_mode = mode; +} + +/** + * Set jitter filter step size. + * If filter mode is jitter, should set filter step for jitter. + * Range: 0 ~ 15 + * + * @param step The step size of the data change. + */ +static inline void touch_ll_filter_set_jitter_step(uint32_t step) +{ + RTCCNTL.touch_filter_ctrl.touch_jitter_step = step; +} + +/** + * Set the denoise coefficient regarding the denoise level. + * + * @param denoise_lvl Range [0 ~ 4]. 0 = no noise resistance, otherwise higher denoise_lvl means more noise resistance. + */ +static inline void touch_ll_filter_set_denoise_level(int denoise_lvl) +{ + HAL_ASSERT(denoise_lvl >= 0 && denoise_lvl <= 4); + bool always_update = denoise_lvl == 0; + // Map denoise level to actual noise threshold coefficients + uint32_t noise_thresh = denoise_lvl == 4 ? 3 : 3 - denoise_lvl; + + RTCCNTL.touch_filter_ctrl.touch_noise_thres = always_update ? 0 : noise_thresh; + RTCCNTL.touch_filter_ctrl.config2 = always_update ? 0 : noise_thresh; + RTCCNTL.touch_filter_ctrl.config1 = 0xF; +} + +/** + * Set the hysteresis value of the active threshold + * While the touch data is greater than active_threshold + hysteresis and last for several ticks, the channel is activated, + * and while the touch data is smaller than active_threshold - hysteresis and last for several ticks, the channel is inactivated + * + * @param hysteresis The hysteresis value of active threshold + */ +static inline void touch_ll_filter_set_active_hysteresis(uint32_t hysteresis) +{ + RTCCNTL.touch_filter_ctrl.config3 = hysteresis; +} + +/** + * Set filter mode. The input to the filter is raw data and the output is the smooth data. + * The smooth data is used to determine the touch status. + * + * @param mode Filter mode type. Refer to ``touch_smooth_mode_t``. + */ +static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) +{ + RTCCNTL.touch_filter_ctrl.touch_smooth_lvl = mode; +} + +/** + * Set debounce count, such as `n`. If the measured values continue to exceed + * the threshold for `n+1` times, it is determined that the touch sensor state changes. + * + * @param dbc_cnt Debounce count value. + */ +static inline void touch_ll_filter_set_debounce(uint32_t dbc_cnt) +{ + RTCCNTL.touch_filter_ctrl.touch_debounce = dbc_cnt; +} + +/**************************** Sleep Configurations ****************************/ +/** + * Set the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * The threshold is the original value of the trigger state minus the benchmark value. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + */ +static inline void touch_ll_sleep_set_threshold(uint32_t touch_thres) +{ + RTCCNTL.touch_slp_thres.touch_slp_th = touch_thres; +} + +/** + * Set touch channel number for sleep channel. + * + * @note Only one touch sensor channel is supported in deep sleep mode. + * @param touch_num Touch sensor channel number. + */ +static inline void touch_ll_sleep_set_channel_num(uint32_t touch_num) +{ + RTCCNTL.touch_slp_thres.touch_slp_pad = touch_num; +} + +/** + * Enable proximity sensing function for sleep channel. + */ +static inline void touch_ll_sleep_enable_proximity_sensing(bool enable) +{ + RTCCNTL.touch_slp_thres.touch_slp_approach_en = enable; +} + +/************************* Waterproof Configurations **************************/ +/** + * Enable parameter of waterproof function. + * + * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. + * Guard pad is used to detect the large area of water covering the touch panel. + * Shield pad is used to shield the influence of water droplets covering the touch panel. + * It is generally designed as a grid and is placed around the touch buttons. + * @param enable Enable or disable waterproof function. + */ +static inline void touch_ll_waterproof_enable(bool enable) +{ + RTCCNTL.touch_scan_ctrl.touch_shield_pad_en = enable; +} + +/** + * Set touch channel use for guard channel. + * + * @param pad_num Touch sensor channel number. + */ +static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num) +{ + RTCCNTL.touch_scan_ctrl.touch_out_ring = pad_num; +} + +/** + * Set max equivalent capacitance for shield channel. + * The equivalent capacitance of the shielded channel can be calculated + * from the reading of denoise channel. + * + * @param pad_num Touch sensor channel number. + */ +static inline void touch_ll_waterproof_set_shield_driver(touch_pad_shield_driver_t driver_level) +{ + RTCCNTL.touch_scan_ctrl.touch_bufdrv = driver_level; +} + +/****************************** Proximity Sensing *****************************/ +/** + * Set the proximity sensing channel to the specific touch channel + * To disable the proximity channel, point this pad to `TOUCH_LL_NULL_CHANNEL` + * + * @param prox_chan proximity sensing channel. + * @param touch_num The touch channel that supposed to be used as proximity sensing channel + */ +static inline void touch_ll_set_proximity_sensing_channel(uint8_t prox_chan, uint32_t touch_num) +{ + switch (prox_chan) { + case 0: + SENS.sar_touch_conf.touch_approach_pad0 = touch_num; + break; + case 1: + SENS.sar_touch_conf.touch_approach_pad1 = touch_num; + break; + case 2: + SENS.sar_touch_conf.touch_approach_pad2 = touch_num; + break; + default: + // invalid proximity channel + abort(); + } +} + +/** + * Set the total scan times of the proximity sensing channel. + * + * @param scan_times The total scan times of the proximity sensing channel + */ +static inline void touch_ll_proximity_set_total_scan_times(uint32_t scan_times) +{ + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time, scan_times); +} + +/** + * Get the total scan times of the proximity sensing channel. + * + * @return + * - The total scan times of the proximity sensing channel + */ +__attribute__((always_inline)) +static inline uint32_t touch_ll_proximity_get_total_scan_times(void) +{ + return HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time); +} + +/** + * Get the current scan count for proximity channel. + * + * @param touch_num Touch channel number. + * @return + * - Current scan count for proximity channel + */ +__attribute__((always_inline)) +static inline uint32_t touch_ll_proximity_get_curr_scan_cnt(uint32_t touch_num) +{ + if (SENS.sar_touch_conf.touch_approach_pad0 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad0_cnt); + } else if (SENS.sar_touch_conf.touch_approach_pad1 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad1_cnt); + } else if (SENS.sar_touch_conf.touch_approach_pad2 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad2_cnt); + } + return 0; +} + +/******************************* Denoise Channel ******************************/ +/** + * Enable denoise function. + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * This denoise function filters out interference introduced on all channels, + * such as noise introduced by the power supply and external EMI. + * @param enable enable the denoise channel + */ +static inline void touch_ll_denoise_enable(bool enable) +{ + RTCCNTL.touch_scan_ctrl.touch_denoise_en = enable; +} + +/** + * Set internal reference capacitance of denoise channel. + * Select the appropriate internal reference capacitance value so that + * the reading of denoise channel is closest to the reading of the channel being measured. + * + * @param capacitance Reference capacitance level. + */ +static inline void touch_ll_denoise_set_reference_cap(touch_denoise_chan_cap_t capacitance) +{ + RTCCNTL.touch_ctrl2.touch_refc = capacitance; +} + +/** + * Set denoise resolution of denoise channel. + * Determined by measuring the noise amplitude of the denoise channel. + * + * @param resolution Denoise resolution of denoise channel. + */ +static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_res_t resolution) +{ + RTCCNTL.touch_scan_ctrl.touch_denoise_res = resolution; +} + +/** + * Read denoise measure value (TOUCH_PAD_NUM0). + * + * @param denoise value of denoise. + */ +static inline void touch_ll_denoise_read_data(uint32_t *data) +{ + *data = SENS.sar_touch_status0.touch_denoise_data; +} +/******************************************************************************/ +/* Legacy APIs */ +/******************************************************************************/ /** * Set touch sensor touch sensor times of charge and discharge. * @@ -85,11 +774,11 @@ static inline void touch_ll_get_sleep_time(uint16_t *sleep_time) } /** - * Set touch sensor high voltage threshold of chanrge. + * Set touch sensor high voltage threshold of charge. * The touch sensor measures the channel capacitance value by charging and discharging the channel. * So the high threshold should be less than the supply voltage. * - * @param refh The high voltage threshold of chanrge. + * @param refh The high voltage threshold of charge. */ static inline void touch_ll_set_voltage_high(touch_high_volt_t refh) { @@ -97,11 +786,11 @@ static inline void touch_ll_set_voltage_high(touch_high_volt_t refh) } /** - * Get touch sensor high voltage threshold of chanrge. + * Get touch sensor high voltage threshold of charge. * The touch sensor measures the channel capacitance value by charging and discharging the channel. * So the high threshold should be less than the supply voltage. * - * @param refh The high voltage threshold of chanrge. + * @param refh The high voltage threshold of charge. */ static inline void touch_ll_get_voltage_high(touch_high_volt_t *refh) { @@ -131,11 +820,11 @@ static inline void touch_ll_get_voltage_low(touch_low_volt_t *refl) } /** - * Set touch sensor high voltage attenuation of chanrge. The actual charge threshold is high voltage threshold minus attenuation value. + * Set touch sensor high voltage attenuation of charge. The actual charge threshold is high voltage threshold minus attenuation value. * The touch sensor measures the channel capacitance value by charging and discharging the channel. * So the high threshold should be less than the supply voltage. * - * @param refh The high voltage threshold of chanrge. + * @param refh The high voltage threshold of charge. */ static inline void touch_ll_set_voltage_attenuation(touch_volt_atten_t atten) { @@ -143,11 +832,11 @@ static inline void touch_ll_set_voltage_attenuation(touch_volt_atten_t atten) } /** - * Get touch sensor high voltage attenuation of chanrge. The actual charge threshold is high voltage threshold minus attenuation value. + * Get touch sensor high voltage attenuation of charge. The actual charge threshold is high voltage threshold minus attenuation value. * The touch sensor measures the channel capacitance value by charging and discharging the channel. * So the high threshold should be less than the supply voltage. * - * @param refh The high voltage threshold of chanrge. + * @param refh The high voltage threshold of charge. */ static inline void touch_ll_get_voltage_attenuation(touch_volt_atten_t *atten) { @@ -412,20 +1101,6 @@ static inline uint32_t IRAM_ATTR touch_ll_read_raw_data(touch_pad_t touch_num) return SENS.sar_touch_status[touch_num - 1].touch_pad_data; } -/** - * Get touch sensor measure status. No block. - * - * @return - * - If touch sensors measure done. - */ -__attribute__((always_inline)) -static inline bool touch_ll_is_measure_done(void) -{ - return (bool)SENS.sar_touch_chn_st.touch_meas_done; -} - -/************************* esp32s2 only *************************/ - /** * Reset the whole of touch module. * @@ -468,17 +1143,6 @@ static inline void touch_ll_get_idle_channel_connect(touch_pad_conn_type_t *type *type = (touch_pad_conn_type_t)(RTCCNTL.touch_scan_ctrl.touch_inactive_connection); } -/** - * Get the current measure channel. Touch sensor measurement is cyclic scan mode. - * - * @return - * - touch channel number - */ -static inline touch_pad_t IRAM_ATTR touch_ll_get_current_meas_channel(void) -{ - return (touch_pad_t)(SENS.sar_touch_status0.touch_scan_curr); -} - /** * Enable touch sensor interrupt by bitmask. * @@ -673,17 +1337,6 @@ static inline void touch_ll_reset_benchmark(touch_pad_t touch_num) } } -/** - * Set filter mode. The input of the filter is the raw value of touch reading, - * and the output of the filter is involved in the judgment of the touch state. - * - * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. - */ -static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) -{ - RTCCNTL.touch_filter_ctrl.touch_filter_mode = mode; -} - /** * Get filter mode. The input of the filter is the raw value of touch reading, * and the output of the filter is involved in the judgment of the touch state. @@ -695,17 +1348,6 @@ static inline void touch_ll_filter_get_filter_mode(touch_filter_mode_t *mode) *mode = (touch_filter_mode_t)RTCCNTL.touch_filter_ctrl.touch_filter_mode; } -/** - * Set filter mode. The input to the filter is raw data and the output is the smooth data. - * The smooth data is used to determine the touch status. - * - * @param mode Filter mode type. Refer to `touch_smooth_mode_t`. - */ -static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) -{ - RTCCNTL.touch_filter_ctrl.touch_smooth_lvl = mode; -} - /** * Get filter mode. The smooth data is used to determine the touch status. * @@ -716,17 +1358,6 @@ static inline void touch_ll_filter_get_smooth_mode(touch_smooth_mode_t *mode) *mode = (touch_smooth_mode_t)(RTCCNTL.touch_filter_ctrl.touch_smooth_lvl); } -/** - * Set debounce count, such as `n`. If the measured values continue to exceed - * the threshold for `n+1` times, it is determined that the touch sensor state changes. - * - * @param dbc_cnt Debounce count value. - */ -static inline void touch_ll_filter_set_debounce(uint32_t dbc_cnt) -{ - RTCCNTL.touch_filter_ctrl.touch_debounce = dbc_cnt; -} - /** * Get debounce count. * @@ -764,18 +1395,6 @@ static inline void touch_ll_filter_get_noise_thres(uint32_t *noise_thr) *noise_thr = RTCCNTL.touch_filter_ctrl.touch_noise_thres; } -/** - * Set jitter filter step size. - * If filter mode is jitter, should set filter step for jitter. - * Range: 0 ~ 15 - * - * @param step The step size of the data change. - */ -static inline void touch_ll_filter_set_jitter_step(uint32_t step) -{ - RTCCNTL.touch_filter_ctrl.touch_jitter_step = step; -} - /** * Get jitter filter step size. * If filter mode is jitter, should set filter step for jitter. @@ -788,52 +1407,8 @@ static inline void touch_ll_filter_get_jitter_step(uint32_t *step) *step = RTCCNTL.touch_filter_ctrl.touch_jitter_step; } -/** - * Enable touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - */ -static inline void touch_ll_filter_enable(void) -{ - RTCCNTL.touch_filter_ctrl.touch_filter_en = 1; -} - -/** - * Disable touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - */ -static inline void touch_ll_filter_disable(void) -{ - RTCCNTL.touch_filter_ctrl.touch_filter_en = 0; -} - /************************ Denoise register setting ************************/ -/** - * Enable denoise function. - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * This denoise function filters out interference introduced on all channels, - * such as noise introduced by the power supply and external EMI. - */ -static inline void touch_ll_denoise_enable(void) -{ - RTCCNTL.touch_scan_ctrl.touch_denoise_en = 1; -} - -/** - * Enable denoise function. - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * This denoise function filters out interference introduced on all channels, - * such as noise introduced by the power supply and external EMI. - */ -static inline void touch_ll_denoise_disable(void) -{ - RTCCNTL.touch_scan_ctrl.touch_denoise_en = 0; -} - /** * Set internal reference capacitance of denoise channel. * Select the appropriate internal reference capacitance value so that @@ -880,16 +1455,6 @@ static inline void touch_ll_denoise_get_grade(touch_pad_denoise_grade_t *grade) *grade = (touch_pad_denoise_grade_t)(RTCCNTL.touch_scan_ctrl.touch_denoise_res); } -/** - * Read denoise measure value (TOUCH_PAD_NUM0). - * - * @param denoise value of denoise. - */ -static inline void touch_ll_denoise_read_data(uint32_t *data) -{ - *data = SENS.sar_touch_status0.touch_denoise_data; -} - /************************ Waterproof register setting ************************/ /** @@ -912,18 +1477,6 @@ static inline void touch_ll_waterproof_get_guard_pad(touch_pad_t *pad_num) *pad_num = (touch_pad_t)(RTCCNTL.touch_scan_ctrl.touch_out_ring); } -/** - * Set max equivalent capacitance for shield channel. - * The equivalent capacitance of the shielded channel can be calculated - * from the reading of denoise channel. - * - * @param pad_num Touch sensor channel number. - */ -static inline void touch_ll_waterproof_set_sheild_driver(touch_pad_shield_driver_t driver_level) -{ - RTCCNTL.touch_scan_ctrl.touch_bufdrv = driver_level; -} - /** * Get max equivalent capacitance for shield channel. * The equivalent capacitance of the shielded channel can be calculated @@ -931,32 +1484,11 @@ static inline void touch_ll_waterproof_set_sheild_driver(touch_pad_shield_driver * * @param pad_num Touch sensor channel number. */ -static inline void touch_ll_waterproof_get_sheild_driver(touch_pad_shield_driver_t *driver_level) +static inline void touch_ll_waterproof_get_shield_driver(touch_pad_shield_driver_t *driver_level) { *driver_level = (touch_pad_shield_driver_t)(RTCCNTL.touch_scan_ctrl.touch_bufdrv); } -/** - * Enable parameter of waterproof function. - * - * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. - * Guard pad is used to detect the large area of water covering the touch panel. - * Shield pad is used to shield the influence of water droplets covering the touch panel. - * It is generally designed as a grid and is placed around the touch buttons. - */ -static inline void touch_ll_waterproof_enable(void) -{ - RTCCNTL.touch_scan_ctrl.touch_shield_pad_en = 1; -} - -/** - * Disable parameter of waterproof function. - */ -static inline void touch_ll_waterproof_disable(void) -{ - RTCCNTL.touch_scan_ctrl.touch_shield_pad_en = 0; -} - /************************ Proximity register setting ************************/ /** @@ -1038,18 +1570,6 @@ static inline bool touch_ll_proximity_pad_check(touch_pad_t touch_num) } /************** sleep pad setting ***********************/ - -/** - * Set touch channel number for sleep pad. - * - * @note Only one touch sensor channel is supported in deep sleep mode. - * @param touch_num Touch sensor channel number. - */ -static inline void touch_ll_sleep_set_channel_num(touch_pad_t touch_num) -{ - RTCCNTL.touch_slp_thres.touch_slp_pad = touch_num; -} - /** * Get touch channel number for sleep pad. * @@ -1061,18 +1581,6 @@ static inline void touch_ll_sleep_get_channel_num(touch_pad_t *touch_num) *touch_num = (touch_pad_t)(RTCCNTL.touch_slp_thres.touch_slp_pad); } -/** - * Set the trigger threshold of touch sensor in deep sleep. - * The threshold determines the sensitivity of the touch sensor. - * The threshold is the original value of the trigger state minus the benchmark value. - * - * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. - */ -static inline void touch_ll_sleep_set_threshold(uint32_t touch_thres) -{ - RTCCNTL.touch_slp_thres.touch_slp_th = touch_thres; -} - /** * Get the trigger threshold of touch sensor in deep sleep. * The threshold determines the sensitivity of the touch sensor. @@ -1085,22 +1593,6 @@ static inline void touch_ll_sleep_get_threshold(uint32_t *touch_thres) *touch_thres = RTCCNTL.touch_slp_thres.touch_slp_th; } -/** - * Enable proximity function for sleep pad. - */ -static inline void touch_ll_sleep_enable_proximity_sensing(void) -{ - RTCCNTL.touch_slp_thres.touch_slp_approach_en = 1; -} - -/** - * Disable proximity function for sleep pad. - */ -static inline void touch_ll_sleep_disable_proximity_sensing(void) -{ - RTCCNTL.touch_slp_thres.touch_slp_approach_en = 0; -} - /** * Get proximity function status for sleep pad. */ @@ -1134,11 +1626,6 @@ static inline void touch_ll_sleep_read_data(uint32_t *raw_data) *raw_data = SENS.sar_touch_status[touch_num - 1].touch_pad_data; } -static inline void touch_ll_sleep_reset_benchmark(void) -{ - RTCCNTL.touch_approach.touch_slp_channel_clr = 1; -} - /** * Select touch sensor dbias to save power in sleep mode. * diff --git a/components/hal/esp32s2/touch_sensor_hal.c b/components/hal/esp32s2/touch_sensor_hal.c index 78bc17819e0..dd1d1c400f5 100644 --- a/components/hal/esp32s2/touch_sensor_hal.c +++ b/components/hal/esp32s2/touch_sensor_hal.c @@ -48,12 +48,12 @@ void touch_hal_deinit(void) touch_ll_clear_trigger_status_mask(); touch_ll_intr_disable(TOUCH_PAD_INTR_MASK_ALL); touch_ll_timeout_disable(); - touch_ll_waterproof_disable(); - touch_ll_denoise_disable(); + touch_ll_waterproof_enable(false); + touch_ll_denoise_enable(false); touch_pad_t prox_pad[SOC_TOUCH_PROXIMITY_CHANNEL_NUM] = {[0 ... (SOC_TOUCH_PROXIMITY_CHANNEL_NUM - 1)] = 0}; touch_ll_proximity_set_channel_num((const touch_pad_t *)prox_pad); touch_ll_sleep_set_channel_num(0); - touch_ll_sleep_disable_proximity_sensing(); + touch_ll_sleep_enable_proximity_sensing(false); touch_ll_reset(); // Reset the touch sensor FSM. } @@ -90,25 +90,25 @@ void touch_hal_denoise_get_config(touch_pad_denoise_t *denoise) void touch_hal_denoise_enable(void) { touch_ll_clear_channel_mask(1U << SOC_TOUCH_DENOISE_CHANNEL); - touch_ll_denoise_enable(); + touch_ll_denoise_enable(true); } void touch_hal_waterproof_set_config(const touch_pad_waterproof_t *waterproof) { touch_ll_waterproof_set_guard_pad(waterproof->guard_ring_pad); - touch_ll_waterproof_set_sheild_driver(waterproof->shield_driver); + touch_ll_waterproof_set_shield_driver(waterproof->shield_driver); } void touch_hal_waterproof_get_config(touch_pad_waterproof_t *waterproof) { touch_ll_waterproof_get_guard_pad(&waterproof->guard_ring_pad); - touch_ll_waterproof_get_sheild_driver(&waterproof->shield_driver); + touch_ll_waterproof_get_shield_driver(&waterproof->shield_driver); } void touch_hal_waterproof_enable(void) { touch_ll_clear_channel_mask(1U << SOC_TOUCH_SHIELD_CHANNEL); - touch_ll_waterproof_enable(); + touch_ll_waterproof_enable(true); } bool touch_hal_enable_proximity(touch_pad_t touch_num, bool enabled) diff --git a/components/hal/esp32s3/include/hal/touch_sensor_hal.h b/components/hal/esp32s3/include/hal/touch_sensor_hal.h index c80f624fde1..e9edc58c51d 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_hal.h @@ -278,14 +278,10 @@ void touch_hal_filter_get_config(touch_filter_config_t *filter_info); /** * Enable touch sensor filter and detection algorithm. * For more details on the detection algorithm, please refer to the application documentation. + * + * @param enable set true to enable the filter */ -#define touch_hal_filter_enable() touch_ll_filter_enable() - -/** - * Disable touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - */ -#define touch_hal_filter_disable() touch_ll_filter_disable() +#define touch_hal_filter_enable(enable) touch_ll_filter_enable(enable) /************************ Denoise register setting ************************/ @@ -326,7 +322,7 @@ void touch_hal_denoise_enable(void); * This denoise function filters out interference introduced on all channels, * such as noise introduced by the power supply and external EMI. */ -#define touch_hal_denoise_disable() touch_ll_denoise_disable() +#define touch_hal_denoise_disable() touch_ll_denoise_enable(false) /** * Set internal reference capacitance of denoise channel. @@ -391,7 +387,7 @@ void touch_hal_denoise_enable(void); * * @param pad_num Touch sensor channel number. */ -#define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_sheild_driver(driver_level) +#define touch_hal_waterproof_set_sheild_driver(driver_level) touch_ll_waterproof_set_shield_driver(driver_level) /** * Get max equivalent capacitance for shield channel. @@ -400,7 +396,7 @@ void touch_hal_denoise_enable(void); * * @param pad_num Touch sensor channel number. */ -#define touch_hal_waterproof_get_sheild_driver(driver_level) touch_ll_waterproof_get_sheild_driver(driver_level) +#define touch_hal_waterproof_get_sheild_driver(driver_level) touch_ll_waterproof_get_shield_driver(driver_level) /** * Set parameter of waterproof function. @@ -430,7 +426,7 @@ void touch_hal_waterproof_enable(void); /** * Disable parameter of waterproof function. */ -#define touch_hal_waterproof_disable() touch_ll_waterproof_disable() +#define touch_hal_waterproof_disable() touch_ll_waterproof_enable(false) /************************ Proximity register setting ************************/ @@ -550,13 +546,9 @@ void touch_hal_sleep_channel_enable(touch_pad_t pad_num, bool enable); /** * Enable proximity function for sleep pad. + * @param enable the proximity sensing */ -#define touch_hal_sleep_enable_approach() touch_ll_sleep_enable_proximity_sensing() - -/** - * Disable proximity function for sleep pad. - */ -#define touch_hal_sleep_disable_approach() touch_ll_sleep_disable_proximity_sensing() +#define touch_hal_sleep_enable_approach(enable) touch_ll_sleep_enable_proximity_sensing(enable) /** * Read benchmark of touch sensor for sleep pad. diff --git a/components/hal/esp32s3/include/hal/touch_sensor_ll.h b/components/hal/esp32s3/include/hal/touch_sensor_ll.h index d3dde4edd35..0e22458f8b8 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_ll.h @@ -17,25 +17,724 @@ #include #include #include "hal/misc.h" +#include "hal/assert.h" #include "soc/touch_sensor_periph.h" #include "soc/rtc_cntl_struct.h" #include "soc/rtc_io_struct.h" #include "soc/sens_struct.h" #include "soc/soc_caps.h" #include "hal/touch_sensor_types.h" +#include "hal/touch_sens_types.h" #ifdef __cplusplus extern "C" { #endif +#define TOUCH_LL_READ_RAW 0x0 +#define TOUCH_LL_READ_BENCHMARK 0x2 +#define TOUCH_LL_READ_SMOOTH 0x3 + +#define TOUCH_LL_TIMER_FORCE_DONE 0x3 +#define TOUCH_LL_TIMER_DONE 0x0 + +#define TOUCH_LL_INTR_MASK_SCAN_DONE BIT(4) +#define TOUCH_LL_INTR_MASK_DONE BIT(6) +#define TOUCH_LL_INTR_MASK_ACTIVE BIT(7) +#define TOUCH_LL_INTR_MASK_INACTIVE BIT(8) +#define TOUCH_LL_INTR_MASK_TIMEOUT BIT(18) +#define TOUCH_LL_INTR_MASK_PROX_DONE BIT(20) +#define TOUCH_LL_INTR_MASK_ALL (TOUCH_LL_INTR_MASK_SCAN_DONE | \ + TOUCH_LL_INTR_MASK_DONE | \ + TOUCH_LL_INTR_MASK_ACTIVE | \ + TOUCH_LL_INTR_MASK_INACTIVE | \ + TOUCH_LL_INTR_MASK_TIMEOUT | \ + TOUCH_LL_INTR_MASK_PROX_DONE) + +#define TOUCH_LL_FULL_CHANNEL_MASK ((uint16_t)((1U << SOC_TOUCH_SENSOR_NUM) - 1)) +#define TOUCH_LL_NULL_CHANNEL (0) // Null Channel id. Used for disabling some functions like sleep/proximity/waterproof + +#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0xFF) // The timer frequency is 8Mhz, the max value is 0xff +#define TOUCH_LL_ACTIVE_THRESH_MAX (0x3FFFFF) // Max channel active threshold +#define TOUCH_LL_TIMEOUT_MAX (0x3FFFFF) // Max timeout value + +/** + * Enable/disable clock gate of touch sensor. + * + * @param enable true/false. + */ +static inline void touch_ll_enable_clock_gate(bool enable) +{ + RTCCNTL.touch_ctrl2.touch_clkgate_en = enable; //enable touch clock for FSM. or force enable. +} + +/** + * Enable/disable clock gate of touch sensor. + * + * @param enable true/false. + */ +static inline void touch_ll_reset_module(void) +{ + RTCCNTL.touch_ctrl2.touch_reset = 1; + RTCCNTL.touch_ctrl2.touch_reset = 0; // Should be set 0. +} + +/*********************************** Interrupts *******************************/ +/** + * Enable touch sensor interrupt by bitmask. + * + * @param int_mask interrupt mask + */ +static inline void touch_ll_interrupt_enable(uint32_t int_mask) +{ + uint32_t mask = RTCCNTL.int_ena_w1ts.val; + mask |= (int_mask & TOUCH_LL_INTR_MASK_ALL); + RTCCNTL.int_ena_w1ts.val = mask; +} + +/** + * Disable touch sensor interrupt by bitmask. + * + * @param int_mask interrupt mask + */ +static inline void touch_ll_interrupt_disable(uint32_t int_mask) +{ + uint32_t mask = int_mask & TOUCH_LL_INTR_MASK_ALL; + RTCCNTL.int_ena_w1tc.val = mask; +} + +/** + * Clear touch sensor interrupt by bitmask. + * + * @param int_mask Pad mask to clear interrupts + */ +__attribute__((always_inline)) +static inline void touch_ll_interrupt_clear(uint32_t int_mask) +{ + RTCCNTL.int_clr.val = int_mask & TOUCH_LL_INTR_MASK_ALL; +} + +/** + * Get the bitmask of touch sensor interrupt status. + * + * @return type interrupt type + */ +__attribute__((always_inline)) +static inline uint32_t touch_ll_get_intr_status_mask(void) +{ + uint32_t intr_st = RTCCNTL.int_st.val; + return intr_st & TOUCH_LL_INTR_MASK_ALL; +} + +/********************************* Status Info ********************************/ +/** + * Get the current measure channel. Touch sensor measurement is cyclic scan mode. + * + * @return + * - touch channel number + */ +__attribute__((always_inline)) +static inline uint32_t IRAM_ATTR touch_ll_get_current_meas_channel(void) +{ + return SENS.sar_touch_status0.touch_scan_curr; +} + +/** + * Get touch sensor measure status. No block. + * + * @return + * - If touch sensors measure done. + */ +__attribute__((always_inline)) +static inline bool touch_ll_is_measure_done(void) +{ + return (bool)SENS.sar_touch_chn_st.touch_meas_done; +} + +/** + * Get the touch sensor active channel mask, usually used in ISR to decide which channels are 'touched'. + * + * @param active_mask The touch channel status. e.g. Touch1 trigger status is `status_mask & (BIT1)`. + */ +__attribute__((always_inline)) +static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask) +{ + *active_mask = SENS.sar_touch_chn_st.touch_pad_active; +} + +/**************************** Measurement Configuration ***********************/ +/** + * @brief Enable or disable the channel that will be scanned. + * @note The shield channel should not be enabled to scan here + * + * @param chan_mask The channel mask to be enabled or disabled + * @param enable Enable or disable the channel mask + */ +__attribute__((always_inline)) +static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) +{ + uint16_t mask = chan_mask & TOUCH_PAD_BIT_MASK_ALL; + uint16_t prev_mask = RTCCNTL.touch_scan_ctrl.touch_scan_pad_map; + if (enable) { + RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = prev_mask | mask; + } else { + RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = prev_mask & (~mask); + } +} + +/** + * Set touch sensor threshold of charge cycles that triggers pad active state. + * The threshold determines the sensitivity of the touch sensor. + * The threshold is the original value of the trigger state minus the benchmark value. + * + * @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered. + * @param touch_num The touch pad id + * @param thresh The threshold of charge cycles + */ +static inline void touch_ll_set_chan_active_threshold(uint32_t touch_num, uint32_t thresh) +{ + HAL_ASSERT(touch_num > 0); + SENS.touch_thresh[touch_num - 1].thresh = thresh; +} + +/** + * Set the power on wait cycle + * + * @param wait_cycles + */ +static inline void touch_ll_set_power_on_wait_cycle(uint32_t wait_cycles) +{ + //the waiting cycles (in 8MHz) between TOUCH_START and TOUCH_XPD + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, wait_cycles); //wait volt stable +} + +// HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time); +/** + * Set touch sensor touch sensor charge and discharge times of every measurement on a pad. + * + * @param charge_times The times of charge and discharge in each measure process of touch channels. + * The timer frequency is RTC_FAST (about 16M). Range: 0 ~ 0xffff. + */ +static inline void touch_ll_set_charge_times( uint16_t charge_times) +{ + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, charge_times); +} + +/** + * Set touch sensor sleep time. + * + * @param interval_ticks The touch sensor will sleep for some cycles after each measurement. + * interval_ticks decide the interval between each measurement. + * t_sleep = interval_ticks / (RTC_SLOW_CLK frequency). + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + */ +static inline void touch_ll_set_measure_interval_ticks(uint16_t interval_ticks) +{ + // touch sensor sleep cycle Time = interval_ticks / RTC_SLOW_CLK + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, interval_ticks); +} + +static inline void touch_ll_set_charge_speed(uint32_t touch_num, touch_charge_speed_t charge_speed) +{ +#define CHARGE_SPEED_MASK(val, num) ((val) << (29 - (num) * 3)) + uint32_t speed_mask = 0; + if (touch_num < 10) { + speed_mask = RTCCNTL.touch_dac.val; + speed_mask &= ~CHARGE_SPEED_MASK(0x07, touch_num); // clear the old value + RTCCNTL.touch_dac.val = speed_mask | CHARGE_SPEED_MASK(charge_speed, touch_num); + } else { + speed_mask = RTCCNTL.touch_dac1.val; + speed_mask &= ~CHARGE_SPEED_MASK(0x07, touch_num - 10); // clear the old value + RTCCNTL.touch_dac1.val = speed_mask | CHARGE_SPEED_MASK(charge_speed, touch_num - 10); + } +#undef CHARGE_SPEED_MASK +} + +static inline void touch_ll_set_charge_voltage_high_limit(touch_volt_lim_h_t high_lim) +{ + RTCCNTL.touch_ctrl2.touch_drefh = (uint32_t)high_lim & 0x3; + RTCCNTL.touch_ctrl2.touch_drange = (uint32_t)high_lim >> 2; +} + +static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_lim) +{ + RTCCNTL.touch_ctrl2.touch_drefl = low_lim; +} + +static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) +{ + RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; +} + +static inline void touch_ll_set_idle_channel_connection(touch_idle_conn_t idle_conn) +{ + RTCCNTL.touch_scan_ctrl.touch_inactive_connection = idle_conn; +} + +/** + * Enable touch sensor channel. Register touch channel into touch sensor measurement group. + * The working mode of the touch sensor is simultaneous measurement. + * This function will set the measure bits according to the given bitmask. + * + * @note If set this mask, the FSM timer should be stop firstly. + * @note The touch sensor that in scan map, should be deinit GPIO function firstly. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM1 -> BIT(1) + * @return + * - ESP_OK on success + */ +static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) +{ + RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = enable_mask; + SENS.sar_touch_conf.touch_outen = enable_mask; +} + +/** + * Set the timeout to enable or disable the check for all touch sensor channels measurements. + * When the touch reading of a touch channel exceeds the measurement threshold, + * If enable: a timeout interrupt will be generated and it will go to the next channel measurement. + * If disable: the FSM is always on the channel, until the measurement of this channel is over. + * + * @param timeout_cycles The maximum time cycles of the measurement on one channel. + * Set to 0 to disable the timeout. + * Set to non-zero to enable the timeout and set the timeout cycles. + */ +static inline void touch_ll_set_timeout(uint32_t timeout_cycles) +{ + if (timeout_cycles) { + RTCCNTL.touch_timeout_ctrl.touch_timeout_num = timeout_cycles; + RTCCNTL.touch_timeout_ctrl.touch_timeout_en = 1; + } else { + RTCCNTL.touch_timeout_ctrl.touch_timeout_en = 0; + } +} + +/** + * Clear all touch sensor channels active status. + * + * @note Generally no manual removal is required. + */ +static inline void touch_ll_clear_active_channel_status(void) +{ + SENS.sar_touch_conf.touch_status_clr = 1; +} + + +/** + * Select touch sensor dbias to save power in sleep mode. + * + * @note If change the dbias, the reading of touch sensor will changed. Users should make sure the threshold. + */ +static inline void touch_ll_set_bias_type(touch_bias_type_t bias_type) +{ + RTCCNTL.touch_ctrl2.touch_dbias = bias_type; +} + +/********************************* FSM Operation ******************************/ +/** + * Touch timer trigger measurement and always wait measurement done. + * Force done for touch timer ensures that the timer always can get the measurement done signal. + * @note The `force done` signal should last as least one slow clock tick + */ +__attribute__((always_inline)) +static inline void touch_ll_force_done_curr_measurement(void) +{ + RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_FORCE_DONE; + RTCCNTL.touch_ctrl2.touch_timer_force_done = TOUCH_LL_TIMER_DONE; +} + +/** + * Enable touch sensor FSM timer trigger (continuous) mode or software trigger (oneshot) mode. + * + * @param enable Enable FSM timer mode. + * True: the FSM will trigger scanning repeatedly under the control of the hardware timer (continuous mode) + * False: the FSM will trigger scanning once under the control of the software (continuous mode) + */ +__attribute__((always_inline)) +static inline void touch_ll_enable_fsm_timer(bool enable) +{ + touch_ll_force_done_curr_measurement(); + // Set 0 to start by timer, otherwise by software + RTCCNTL.touch_ctrl2.touch_start_force = !enable; +} + +/** + * Start touch sensor FSM timer to run FSM repeatedly + * The measurement action can be triggered by the hardware timer, as well as by the software instruction. + * @note + * The timer should be triggered + */ +__attribute__((always_inline)) +static inline void touch_ll_start_fsm_repeated_timer(void) +{ + /** + * Touch timer trigger measurement and always wait measurement done. + * Force done for touch timer ensures that the timer always can get the measurement done signal. + */ + touch_ll_force_done_curr_measurement(); + RTCCNTL.touch_ctrl2.touch_slp_timer_en = 1; +} + +/** + * Stop touch sensor FSM timer. + * The measurement action can be triggered by the hardware timer, as well as by the software instruction. + */ +__attribute__((always_inline)) +static inline void touch_ll_stop_fsm_repeated_timer(void) +{ + RTCCNTL.touch_ctrl2.touch_slp_timer_en = 0; + touch_ll_force_done_curr_measurement(); +} + +/** + * Is the FSM repeated timer enabled. + * @note when the timer is enabled, RTC clock should not be power down + * + * @return + * - true: enabled + * - false: disabled + */ +static inline bool touch_ll_is_fsm_repeated_timer_enabled(void) +{ + return (bool)RTCCNTL.touch_ctrl2.touch_slp_timer_en; +} + +/** + * Enable the touch sensor FSM start signal from software + */ +__attribute__((always_inline)) +static inline void touch_ll_trigger_oneshot_measurement(void) +{ + RTCCNTL.touch_ctrl2.touch_start_en = 1; + RTCCNTL.touch_ctrl2.touch_start_en = 0; +} + +/** + * @brief Power on the channel by mask + * + * @param chan_mask The channel mask that needs to power on + */ +__attribute__((always_inline)) +static inline void touch_ll_channel_sw_measure_mask(uint16_t chan_mask) +{ + (void) chan_mask; + // Only for compatibility +} + +/****************************** Benchmark Operation ***************************/ +/** + * Force reset benchmark to raw data of touch sensor. + * + * @note If call this API, make sure enable clock gate(`touch_ll_clkgate`) first. + * @param chan_mask touch channel mask + */ +__attribute__((always_inline)) +static inline void touch_ll_reset_chan_benchmark(uint32_t chan_mask) +{ + SENS.sar_touch_chn_st.touch_channel_clr = chan_mask; +} + +static inline void touch_ll_sleep_reset_benchmark(void) +{ + RTCCNTL.touch_approach.touch_slp_channel_clr = 1; +} + +/************************************** Data **********************************/ +/** + * Get the data of the touch channel according to the types + * + * @param touch_num touch pad index + * @param type data type + * 0/1: TOUCH_LL_READ_RAW, raw data of touch channel + * 2: TOUCH_LL_READ_BENCHMARK, benchmark value of touch channel, + * the benchmark value is the maximum during the first measurement period + * 3: TOUCH_LL_READ_SMOOTH, the smoothed data that obtained by filtering the raw data. + * @param data pointer to the data + */ +__attribute__((always_inline)) +static inline void touch_ll_read_chan_data(uint32_t touch_num, uint8_t type, uint32_t *data) +{ + HAL_ASSERT(type <= TOUCH_LL_READ_SMOOTH); + HAL_ASSERT(touch_num > 0); + SENS.sar_touch_conf.touch_data_sel = type; + *data = SENS.sar_touch_status[touch_num - 1].touch_pad_data; +} + +/****************************** Filter Configuration **************************/ + +/** + * Enable or disable touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + */ +static inline void touch_ll_filter_enable(bool enable) +{ + RTCCNTL.touch_filter_ctrl.touch_filter_en = enable; +} + + +/** + * Set filter mode. The input of the filter is the raw value of touch reading, + * and the output of the filter is involved in the judgment of the touch state. + * + * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. + */ +static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) +{ + RTCCNTL.touch_filter_ctrl.touch_filter_mode = mode; +} + +/** + * Set jitter filter step size. + * If filter mode is jitter, should set filter step for jitter. + * Range: 0 ~ 15 + * + * @param step The step size of the data change. + */ +static inline void touch_ll_filter_set_jitter_step(uint32_t step) +{ + RTCCNTL.touch_filter_ctrl.touch_jitter_step = step; +} + +/** + * Set the denoise coefficient regarding the denoise level. + * + * @param denoise_lvl Range [0 ~ 4]. 0 = no noise resistance, otherwise higher denoise_lvl means more noise resistance. + */ +static inline void touch_ll_filter_set_denoise_level(int denoise_lvl) +{ + HAL_ASSERT(denoise_lvl >= 0 && denoise_lvl <= 4); + bool always_update = denoise_lvl == 0; + // Map denoise level to actual noise threshold coefficients + uint32_t noise_thresh = denoise_lvl == 4 ? 3 : 3 - denoise_lvl; + + RTCCNTL.touch_filter_ctrl.touch_bypass_noise_thres = always_update; + RTCCNTL.touch_filter_ctrl.touch_noise_thres = always_update ? 0 : noise_thresh; + + RTCCNTL.touch_filter_ctrl.touch_bypass_nn_thres = always_update; + RTCCNTL.touch_filter_ctrl.config2 = always_update ? 0 : noise_thresh; + RTCCNTL.touch_filter_ctrl.config1 = 0xF; +} + +/** + * Set the hysteresis value of the active threshold + * While the touch data is greater than active_threshold + hysteresis and last for several ticks, the channel is activated, + * and while the touch data is smaller than active_threshold - hysteresis and last for several ticks, the channel is inactivated + * + * @param hysteresis The hysteresis value of active threshold + */ +static inline void touch_ll_filter_set_active_hysteresis(uint32_t hysteresis) +{ + RTCCNTL.touch_filter_ctrl.config3 = hysteresis; +} + +/** + * Set filter mode. The input to the filter is raw data and the output is the smooth data. + * The smooth data is used to determine the touch status. + * + * @param mode Filter mode type. Refer to ``touch_smooth_mode_t``. + */ +static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) +{ + RTCCNTL.touch_filter_ctrl.touch_smooth_lvl = mode; +} + +/** + * Set debounce count, such as `n`. If the measured values continue to exceed + * the threshold for `n+1` times, it is determined that the touch sensor state changes. + * + * @param dbc_cnt Debounce count value. + */ +static inline void touch_ll_filter_set_debounce(uint32_t dbc_cnt) +{ + RTCCNTL.touch_filter_ctrl.touch_debounce = dbc_cnt; +} + +/**************************** Sleep Configurations ****************************/ +/** + * Set the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * The threshold is the original value of the trigger state minus the benchmark value. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + */ +static inline void touch_ll_sleep_set_threshold(uint32_t touch_thres) +{ + RTCCNTL.touch_slp_thres.touch_slp_th = touch_thres; +} + +/** + * Set touch channel number for sleep channel. + * + * @note Only one touch sensor channel is supported in deep sleep mode. + * @param touch_num Touch sensor channel number. + */ +static inline void touch_ll_sleep_set_channel_num(uint32_t touch_num) +{ + RTCCNTL.touch_slp_thres.touch_slp_pad = touch_num; +} + +/** + * Enable proximity sensing function for sleep channel. + */ +static inline void touch_ll_sleep_enable_proximity_sensing(bool enable) +{ + RTCCNTL.touch_slp_thres.touch_slp_approach_en = enable; +} + +/************************* Waterproof Configurations **************************/ +/** + * Enable parameter of waterproof function. + * + * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. + * Guard pad is used to detect the large area of water covering the touch panel. + * Shield pad is used to shield the influence of water droplets covering the touch panel. + * It is generally designed as a grid and is placed around the touch buttons. + * @param enable Enable or disable waterproof function. + */ +static inline void touch_ll_waterproof_enable(bool enable) +{ + RTCCNTL.touch_scan_ctrl.touch_shield_pad_en = enable; +} + +/** + * Set touch channel use for guard channel. + * + * @param pad_num Touch sensor channel number. + */ +static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num) +{ + RTCCNTL.touch_scan_ctrl.touch_out_ring = pad_num; +} + +/** + * Set max equivalent capacitance for shield channel. + * The equivalent capacitance of the shielded channel can be calculated + * from the reading of denoise channel. + * + * @param pad_num Touch sensor channel number. + */ +static inline void touch_ll_waterproof_set_shield_driver(touch_pad_shield_driver_t driver_level) +{ + RTCCNTL.touch_scan_ctrl.touch_bufdrv = driver_level; +} -#define TOUCH_LL_READ_RAW 0x0 -#define TOUCH_LL_READ_BENCHMARK 0x2 -#define TOUCH_LL_READ_SMOOTH 0x3 -#define TOUCH_LL_TIMER_FORCE_DONE 0x3 -#define TOUCH_LL_TIMER_DONE 0x0 +/****************************** Proximity Sensing *****************************/ +/** + * Set the proximity sensing channel to the specific touch channel + * To disable the proximity channel, point this pad to `TOUCH_LL_NULL_CHANNEL` + * + * @param prox_chan proximity sensing channel. + * @param touch_num The touch channel that supposed to be used as proximity sensing channel + */ +static inline void touch_ll_set_proximity_sensing_channel(uint8_t prox_chan, uint32_t touch_num) +{ + switch (prox_chan) { + case 0: + SENS.sar_touch_conf.touch_approach_pad0 = touch_num; + break; + case 1: + SENS.sar_touch_conf.touch_approach_pad1 = touch_num; + break; + case 2: + SENS.sar_touch_conf.touch_approach_pad2 = touch_num; + break; + default: + // invalid proximity channel + abort(); + } +} + +/** + * Set the total scan times of the proximity sensing channel. + * + * @param scan_times The total scan times of the proximity sensing channel + */ +static inline void touch_ll_proximity_set_total_scan_times(uint32_t scan_times) +{ + HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time, scan_times); +} + +/** + * Get the total scan times of the proximity sensing channel. + * + * @return + * - The total scan times of the proximity sensing channel + */ +__attribute__((always_inline)) +static inline uint32_t touch_ll_proximity_get_total_scan_times(void) +{ + return HAL_FORCE_READ_U32_REG_FIELD(RTCCNTL.touch_approach, touch_approach_meas_time); +} + +/** + * Get the current scan count for proximity channel. + * + * @param touch_num Touch channel number. + * @return + * - Current scan count for proximity channel + */ +__attribute__((always_inline)) +static inline uint32_t touch_ll_proximity_get_curr_scan_cnt(uint32_t touch_num) +{ + if (SENS.sar_touch_conf.touch_approach_pad0 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad0_cnt); + } else if (SENS.sar_touch_conf.touch_approach_pad1 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad1_cnt); + } else if (SENS.sar_touch_conf.touch_approach_pad2 == touch_num) { + return HAL_FORCE_READ_U32_REG_FIELD(SENS.sar_touch_appr_status, touch_approach_pad2_cnt); + } + return 0; +} + +/******************************* Denoise Channel ******************************/ +/** + * Enable denoise function. + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * This denoise function filters out interference introduced on all channels, + * such as noise introduced by the power supply and external EMI. + * @param enable enable the denoise channel + */ +static inline void touch_ll_denoise_enable(bool enable) +{ + RTCCNTL.touch_scan_ctrl.touch_denoise_en = enable; +} + +/** + * Set internal reference capacitance of denoise channel. + * Select the appropriate internal reference capacitance value so that + * the reading of denoise channel is closest to the reading of the channel being measured. + * + * @param capacitance Reference capacitance level. + */ +static inline void touch_ll_denoise_set_reference_cap(touch_denoise_chan_cap_t capacitance) +{ + RTCCNTL.touch_ctrl2.touch_refc = capacitance; +} + +/** + * Set denoise resolution of denoise channel. + * Determined by measuring the noise amplitude of the denoise channel. + * + * @param resolution Denoise resolution of denoise channel. + */ +static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_res_t resolution) +{ + RTCCNTL.touch_scan_ctrl.touch_denoise_res = resolution; +} -#define TOUCH_LL_PAD_MEASURE_WAIT_MAX (0xFF) /*!guard_ring_pad); - touch_ll_waterproof_set_sheild_driver(waterproof->shield_driver); + touch_ll_waterproof_set_shield_driver(waterproof->shield_driver); } void touch_hal_waterproof_get_config(touch_pad_waterproof_t *waterproof) { touch_ll_waterproof_get_guard_pad(&waterproof->guard_ring_pad); - touch_ll_waterproof_get_sheild_driver(&waterproof->shield_driver); + touch_ll_waterproof_get_shield_driver(&waterproof->shield_driver); } void touch_hal_waterproof_enable(void) { touch_ll_clear_channel_mask(1U << SOC_TOUCH_SHIELD_CHANNEL); - touch_ll_waterproof_enable(); + touch_ll_waterproof_enable(true); } bool touch_hal_enable_proximity(touch_pad_t touch_num, bool enabled) diff --git a/components/hal/esp32p4/include/hal/touch_sensor_hal.h b/components/hal/include/hal/touch_sens_hal.h similarity index 76% rename from components/hal/esp32p4/include/hal/touch_sensor_hal.h rename to components/hal/include/hal/touch_sens_hal.h index bc6d03f503b..a86953acbca 100644 --- a/components/hal/esp32p4/include/hal/touch_sensor_hal.h +++ b/components/hal/include/hal/touch_sens_hal.h @@ -10,22 +10,35 @@ * See readme.md in hal/include/hal/readme.md ******************************************************************************/ -// The HAL layer for touch sensor (ESP32-P4 specific part) #pragma once +#include "soc/soc_caps.h" +#if SOC_TOUCH_SENSOR_VERSION > 1 #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sens_types.h" +#endif // SOC_TOUCH_SENSOR_SUPPORTED #ifdef __cplusplus extern "C" { #endif +#if SOC_TOUCH_SENSOR_VERSION > 1 + /** * @brief Sample configurations of the touch sensor * */ typedef struct { +#if SOC_TOUCH_SENSOR_VERSION == 2 // S2/S3 + uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ + touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad */ + touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while charging a touch pad */ + touch_idle_conn_t idle_conn; /*!< The connection of the idle touch channels. + * The idle touch channel is a channel which is enabled but not under measuring. + */ + touch_bias_type_t bias_type; +#elif SOC_TOUCH_SENSOR_VERSION == 3 // P4 uint32_t div_num; /*!< The division from the source clock to the sampling frequency */ uint32_t charge_times; /*!< The charge and discharge times of the sample configuration, the read data are positive correlation to the charge_times */ uint8_t rc_filter_res; /*!< The resistance of the RC filter of the sample configuration, range [0, 3], while 0 = 0K, 1 = 1.5K, 2 = 3K, 3 = 4.5K */ @@ -34,6 +47,9 @@ typedef struct { uint8_t high_drv; /*!< High speed touch driver */ uint8_t bias_volt; /*!< The Internal LDO voltage, which decide the bias voltage of the sample wave, range [0,15] */ bool bypass_shield_output; /*!< Whether to bypass the shield output */ +#else +#error "Unsupported touch sensor version" +#endif } touch_hal_sample_config_t; /** @@ -47,7 +63,9 @@ typedef struct { * Set to '0' to ignore the measurement time limitation, otherwise please set a proper time considering the configurations * of the sample configurations below. */ +#if SOC_TOUCH_SENSOR_VERSION == 3 touch_out_mode_t output_mode; /*!< Touch channel counting mode of the binarized touch output */ +#endif // SOC_TOUCH_SENSOR_VERSION == 3 uint32_t sample_cfg_num; /*!< The sample configuration number that used for sampling */ touch_hal_sample_config_t *sample_cfg; /*!< The array of the sample configuration configurations, the length should be specified in `touch_hal_sample_config_t::sample_cfg_num` */ } touch_hal_config_t; @@ -74,6 +92,8 @@ void touch_hal_save_sleep_config(int deep_slp_chan, const touch_hal_config_t *de */ void touch_hal_prepare_deep_sleep(void); +#endif // SOC_TOUCH_SENSOR_SUPPORTED + #ifdef __cplusplus } #endif diff --git a/components/hal/include/hal/touch_sens_types.h b/components/hal/include/hal/touch_sens_types.h new file mode 100644 index 00000000000..d763a748a74 --- /dev/null +++ b/components/hal/include/hal/touch_sens_types.h @@ -0,0 +1,131 @@ +/* + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "esp_bit_defs.h" +#include "soc/soc_caps.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Touch sensor upper charging voltage limit + */ +typedef enum { + TOUCH_VOLT_LIM_H_0V9, /*!< Touch sensor upper voltage limit is 0.9V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V0, /*!< Touch sensor upper voltage limit is 1.0V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V1, /*!< Touch sensor upper voltage limit is 1.1V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V2, /*!< Touch sensor upper voltage limit is 1.2V while charging a touch pad */ + // No 1V3 + TOUCH_VOLT_LIM_H_1V4, /*!< Touch sensor upper voltage limit is 1.4V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V5, /*!< Touch sensor upper voltage limit is 1.5V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V6, /*!< Touch sensor upper voltage limit is 1.6V while charging a touch pad */ + TOUCH_VOLT_LIM_H_1V7, /*!< Touch sensor upper voltage limit is 1.7V while charging a touch pad */ + // No 1V8 + TOUCH_VOLT_LIM_H_1V9, /*!< Touch sensor upper voltage limit is 1.9V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V0, /*!< Touch sensor upper voltage limit is 2.0V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V1, /*!< Touch sensor upper voltage limit is 2.1V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V2, /*!< Touch sensor upper voltage limit is 2.2V while charging a touch pad */ + // No 2V3 + TOUCH_VOLT_LIM_H_2V4, /*!< Touch sensor upper voltage limit is 2.4V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V5, /*!< Touch sensor upper voltage limit is 2.5V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V6, /*!< Touch sensor upper voltage limit is 2.6V while charging a touch pad */ + TOUCH_VOLT_LIM_H_2V7, /*!< Touch sensor upper voltage limit is 2.7V while charging a touch pad */ +} touch_volt_lim_h_t; + +/** + * @brief Touch sensor lower discharging voltage limit + */ +typedef enum { + TOUCH_VOLT_LIM_L_0V5, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ + TOUCH_VOLT_LIM_L_0V6, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ + TOUCH_VOLT_LIM_L_0V7, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ + TOUCH_VOLT_LIM_L_0V8, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ +} touch_volt_lim_l_t; + +/** + * @brief Touch sensor charge and discharge speed + */ +typedef enum { + TOUCH_CHARGE_SPEED_0 = 0, /*!< Touch sensor charge and discharge speed, no charge, always zero */ + TOUCH_CHARGE_SPEED_1 = 1, /*!< Touch sensor charge and discharge speed, slowest */ + TOUCH_CHARGE_SPEED_2 = 2, /*!< Touch sensor charge and discharge speed */ + TOUCH_CHARGE_SPEED_3 = 3, /*!< Touch sensor charge and discharge speed */ + TOUCH_CHARGE_SPEED_4 = 4, /*!< Touch sensor charge and discharge speed */ + TOUCH_CHARGE_SPEED_5 = 5, /*!< Touch sensor charge and discharge speed */ + TOUCH_CHARGE_SPEED_6 = 6, /*!< Touch sensor charge and discharge speed */ + TOUCH_CHARGE_SPEED_7 = 7, /*!< Touch sensor charge and discharge speed, fastest */ +} touch_charge_speed_t; + +/** + * @brief Touch sensor initial voltage before charging + */ +typedef enum { + TOUCH_INIT_CHARGE_VOLT_LOW = 0, /*!< Tie the initial charge voltage to low */ + TOUCH_INIT_CHARGE_VOLT_HIGH = 1,/*!< Tie the initial charge voltage to high */ +} touch_init_charge_volt_t; + +/** Touch channel idle state configuration */ +typedef enum { + TOUCH_IDLE_CONN_HIGHZ = 0, /*!< The idle (enabled but not measuring) touch channel is in high resistance state */ + TOUCH_IDLE_CONN_GND = 1, /*!< The idle (enabled but not measuring) touch channel is connected to the ground */ +} touch_idle_conn_t; + +/** + * @brief Touch sensor denoise channel internal reference capacitance + * + */ +typedef enum { + TOUCH_DENOISE_CHAN_CAP_L0 = 0, /*!< Denoise channel internal reference capacitance is 5pf */ + TOUCH_DENOISE_CHAN_CAP_L1 = 1, /*!< Denoise channel internal reference capacitance is 6.4pf */ + TOUCH_DENOISE_CHAN_CAP_L2 = 2, /*!< Denoise channel internal reference capacitance is 7.8pf */ + TOUCH_DENOISE_CHAN_CAP_L3 = 3, /*!< Denoise channel internal reference capacitance is 9.2pf */ + TOUCH_DENOISE_CHAN_CAP_L4 = 4, /*!< Denoise channel internal reference capacitance is 10.6pf */ + TOUCH_DENOISE_CHAN_CAP_L5 = 5, /*!< Denoise channel internal reference capacitance is 12.0pf */ + TOUCH_DENOISE_CHAN_CAP_L6 = 6, /*!< Denoise channel internal reference capacitance is 13.4pf */ + TOUCH_DENOISE_CHAN_CAP_L7 = 7, /*!< Denoise channel internal reference capacitance is 14.8pf */ +} touch_denoise_chan_cap_t; + +/** + * @brief Touch sensor denoise channel noise suppression resolution + * + */ +typedef enum { + TOUCH_DENOISE_CHAN_RES_BIT12 = 0, /*!< Denoise channel noise suppression resolution is 12bit */ + TOUCH_DENOISE_CHAN_RES_BIT10 = 1, /*!< Denoise channel noise suppression resolution is 10bit */ + TOUCH_DENOISE_CHAN_RES_BIT8 = 2, /*!< Denoise channel noise suppression resolution is 8bit */ + TOUCH_DENOISE_CHAN_RES_BIT4 = 3, /*!< Denoise channel noise suppression resolution is 4bit */ +} touch_denoise_chan_res_t; + +/** + * @brief Touch sensor bias type + * + */ +typedef enum { + TOUCH_BIAS_TYPE_BANDGAP, /*!< Use bandgap-bias to charge/discharge the touch channel, which is more stable but power-consuming */ + TOUCH_BIAS_TYPE_SELF, /*!< Use self-bias to charge/discharge the touch channel, which is less stable but power-saving */ +} touch_bias_type_t; + +/** + * @brief Touch channel counting mode of the binarized touch output + * + */ +typedef enum { + TOUCH_PAD_OUT_AS_DATA, /*!< Counting the output of touch channel as data. + * The value will be smaller than actual value but more sensitive when the frequency of touch_out is close to the source clock + * Normally we treat the output as data when it is lower than the sample clock + */ + TOUCH_PAD_OUT_AS_CLOCK, /*!< Counting the output of touch channel as clock. + * The value is accurate but less sensitive when the frequency of touch_out is close to the source clock + * Normally we treat the output as clock when it is higher than the sample clock + */ +} touch_out_mode_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/hal/include/hal/touch_sensor_hal.h b/components/hal/include/hal/touch_sensor_hal.h index be45ca89ab6..a0352a864db 100644 --- a/components/hal/include/hal/touch_sensor_hal.h +++ b/components/hal/include/hal/touch_sensor_hal.h @@ -14,6 +14,7 @@ #pragma once +#include "soc/soc_caps.h" #if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sensor_ll.h" #include "hal/touch_sensor_types.h" diff --git a/components/hal/include/hal/touch_sensor_types.h b/components/hal/include/hal/touch_sensor_types.h index dac11762f3e..c5428372c94 100644 --- a/components/hal/include/hal/touch_sensor_types.h +++ b/components/hal/include/hal/touch_sensor_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -275,23 +275,6 @@ typedef enum { TOUCH_PAD_SMOOTH_MAX, } touch_smooth_mode_t; -#if SOC_TOUCH_SENSOR_VERSION == 3 -/** - * @brief Touch channel counting mode of the binarized touch output - * - */ -typedef enum { - TOUCH_PAD_OUT_AS_DATA, /*!< Counting the output of touch channel as data. - * The value will be smaller than actual value but more sensitive when the frequency of touch_out is close to the source clock - * Normally we treat the output as data when it is lower than the sample clock - */ - TOUCH_PAD_OUT_AS_CLOCK, /*!< Counting the output of touch channel as clock. - * The value is accurate but less sensitive when the frequency of touch_out is close to the source clock - * Normally we treat the output as clock when it is higher than the sample clock - */ -} touch_out_mode_t; -#endif - /** Touch sensor filter configuration */ typedef struct touch_filter_config { touch_filter_mode_t mode; /*! -#include "soc/soc_pins.h" -#include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_hal.h" -#include "hal/touch_sensor_types.h" #include "soc/soc_caps.h" +#include "hal/touch_sensor_ll.h" +#include "hal/touch_sens_hal.h" +#include "hal/touch_sens_types.h" + typedef struct { int deep_slp_chan; @@ -26,16 +26,19 @@ void touch_hal_config_controller(const touch_hal_config_t *cfg) { HAL_ASSERT(cfg); touch_ll_sleep_set_channel_num(TOUCH_LL_NULL_CHANNEL); - touch_ll_set_out_mode(cfg->output_mode); touch_ll_set_power_on_wait_cycle(cfg->power_on_wait_ticks); touch_ll_set_measure_interval_ticks(cfg->meas_interval_ticks); - if (cfg->timeout_ticks) { - touch_ll_timeout_enable(cfg->timeout_ticks); - } else { - touch_ll_timeout_disable(); - } + touch_ll_set_timeout(cfg->timeout_ticks); +#if SOC_TOUCH_SENSOR_VERSION == 2 + touch_ll_set_charge_times(cfg->sample_cfg->charge_times); + touch_ll_set_charge_voltage_high_limit(cfg->sample_cfg->charge_volt_lim_h); + touch_ll_set_charge_voltage_low_limit(cfg->sample_cfg->charge_volt_lim_l); + touch_ll_set_idle_channel_connection(cfg->sample_cfg->idle_conn); + touch_ll_set_bias_type(cfg->sample_cfg->bias_type); +#elif SOC_TOUCH_SENSOR_VERSION == 3 touch_ll_sample_cfg_set_engaged_num(cfg->sample_cfg_num); + touch_ll_set_out_mode(cfg->output_mode); for (int i = 0; i < cfg->sample_cfg_num; i++) { touch_ll_set_clock_div(i, cfg->sample_cfg[i].div_num); touch_ll_set_charge_times(i, cfg->sample_cfg[i].charge_times); @@ -44,6 +47,9 @@ void touch_hal_config_controller(const touch_hal_config_t *cfg) touch_ll_sample_cfg_bypass_shield_output(i, cfg->sample_cfg[i].bypass_shield_output); touch_ll_sample_cfg_set_bias_voltage(i, cfg->sample_cfg[i].bias_volt); } +#else + HAL_ASSERT(0); // Unsupported touch sensor version +#endif } void touch_hal_save_sleep_config(int deep_slp_chan, const touch_hal_config_t *deep_slp_cfg) @@ -67,8 +73,8 @@ static void s_touch_hal_apply_sleep_config(void) } /* Whether to enable touch sensor wake-up the chip from deep sleep */ if (s_touch_slp_obj.deep_slp_chan >= 0) { - touch_ll_sleep_set_channel_num(s_touch_slp_obj.deep_slp_chan); - touch_ll_set_channel_mask(BIT(s_touch_slp_obj.deep_slp_chan)); + // touch_ll_sleep_set_channel_num(s_touch_slp_obj.deep_slp_chan); + // touch_ll_enable_channel_mask(BIT(s_touch_slp_obj.deep_slp_chan)); } else { touch_ll_sleep_set_channel_num(TOUCH_LL_NULL_CHANNEL); } @@ -78,5 +84,5 @@ void touch_hal_prepare_deep_sleep(void) { s_touch_hal_apply_sleep_config(); touch_ll_sleep_reset_benchmark(); - touch_ll_intr_clear(TOUCH_LL_INTR_MASK_ALL); + touch_ll_interrupt_clear(TOUCH_LL_INTR_MASK_ALL); } diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index 686747c9f8d..506be9789f5 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -827,6 +827,10 @@ config SOC_TOUCH_SUPPORT_PROX_SENSING bool default y +config SOC_TOUCH_SUPPORT_DENOISE_CHAN + bool + default y + config SOC_TOUCH_PROXIMITY_CHANNEL_NUM int default 3 diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 3e50662f734..bc81df14366 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -345,6 +345,7 @@ #define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */ #define SOC_TOUCH_SUPPORT_WATERPROOF (1) /*!< Touch sensor supports waterproof */ #define SOC_TOUCH_SUPPORT_PROX_SENSING (1) /*!< Touch sensor supports proximity sensing */ +#define SOC_TOUCH_SUPPORT_DENOISE_CHAN (1) /*!< Touch sensor supports denoise channel */ #define SOC_TOUCH_PROXIMITY_CHANNEL_NUM (3) /*!< Support touch proximity channel number. */ #define SOC_TOUCH_SAMPLE_CFG_NUM (1U) /*!< The sample configuration number in total, each sampler can be used to sample on one frequency */ diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index 0c228dc8416..f87cc98a224 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -1003,6 +1003,10 @@ config SOC_TOUCH_SUPPORT_PROX_SENSING bool default y +config SOC_TOUCH_SUPPORT_DENOISE_CHAN + bool + default y + config SOC_TOUCH_PROXIMITY_CHANNEL_NUM int default 3 diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index 6e8194fbf97..d87dbe088c5 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -385,6 +385,7 @@ #define SOC_TOUCH_SUPPORT_SLEEP_WAKEUP (1) /*!< Touch sensor supports sleep awake */ #define SOC_TOUCH_SUPPORT_WATERPROOF (1) /*!< Touch sensor supports waterproof */ #define SOC_TOUCH_SUPPORT_PROX_SENSING (1) /*!< Touch sensor supports proximity sensing */ +#define SOC_TOUCH_SUPPORT_DENOISE_CHAN (1) /*!< Touch sensor supports denoise channel */ #define SOC_TOUCH_PROXIMITY_CHANNEL_NUM (3) /*!< Support touch proximity sensing channel number. */ #define SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED (1) /*!< Support touch proximity sensing measure done interrupt type. */ diff --git a/components/soc/esp32s3/register/soc/rtc_cntl_struct.h b/components/soc/esp32s3/register/soc/rtc_cntl_struct.h index 7ef1825ebdf..a92633ec86b 100644 --- a/components/soc/esp32s3/register/soc/rtc_cntl_struct.h +++ b/components/soc/esp32s3/register/soc/rtc_cntl_struct.h @@ -798,14 +798,14 @@ typedef volatile struct rtc_cntl_dev_s { union { struct { uint32_t reserved0 : 7; - uint32_t touch_bypass_neg_noise_thres : 1; + uint32_t touch_bypass_nn_thres : 1; uint32_t touch_bypass_noise_thres : 1; uint32_t touch_smooth_lvl : 2; uint32_t touch_jitter_step : 4; /*touch jitter step*/ - uint32_t config1: 4; - uint32_t config2: 2; + uint32_t config1 : 4; + uint32_t config2 : 2; uint32_t touch_noise_thres : 2; - uint32_t config3: 2; + uint32_t config3 : 2; uint32_t touch_debounce : 3; /*debounce counter*/ uint32_t touch_filter_mode : 3; /*0: IIR ? 1: IIR ? 2: IIR 1/8 3: Jitter*/ uint32_t touch_filter_en : 1; /*touch filter enable*/ From 6856aec19e44af39c329f4848b0c72051f698de2 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 17 Oct 2024 18:18:54 +0800 Subject: [PATCH 31/70] refactor(touch): refactor the legacy s2 & s3 touch driver --- components/driver/Kconfig | 11 + .../touch_sensor_v1/main/test_touch_v1.c | 5 +- .../touch_sensor_v2/main/test_touch_v2.c | 5 +- .../esp32/include/driver/touch_sensor.h | 380 +---------- .../include/driver/touch_sensor_legacy.h | 385 +++++++++++ .../esp32s2/include/driver/touch_sensor.h | 645 +---------------- .../include/driver/touch_sensor_legacy.h | 646 ++++++++++++++++++ .../touch_sensor/esp32s2/touch_sensor.c | 26 +- .../esp32s3/include/driver/touch_sensor.h | 645 +---------------- .../include/driver/touch_sensor_legacy.h | 646 ++++++++++++++++++ .../touch_sensor/esp32s3/touch_sensor.c | 26 +- .../driver/touch_sensor/touch_sensor_common.c | 1 - .../include/touch_element/touch_element.h | 12 +- 13 files changed, 1757 insertions(+), 1676 deletions(-) create mode 100644 components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h create mode 100644 components/driver/touch_sensor/esp32s2/include/driver/touch_sensor_legacy.h create mode 100644 components/driver/touch_sensor/esp32s3/include/driver/touch_sensor_legacy.h diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 68634c78f92..2698ac746aa 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -152,4 +152,15 @@ menu "Driver Configurations" and don't want to see related deprecation warnings, you can enable this option. endmenu # Legacy Temperature Sensor Driver Configurationss + menu "Legacy Touch Sensor Driver Configurations" + depends on SOC_TOUCH_SENSOR_SUPPORTED + config TOUCH_SUPPRESS_DEPRECATE_WARN + bool "Suppress legacy driver deprecated warning" + default n + help + whether to suppress the deprecation warnings when using legacy touch sensor driver + (driver/touch_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. + endmenu # Legacy Touch Sensor Driver Configurationss + endmenu # Driver configurations diff --git a/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c b/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c index 5e7096a399f..2580ed1d0cd 100644 --- a/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c +++ b/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c @@ -10,20 +10,19 @@ #include "sdkconfig.h" #include "esp_system.h" -#include "driver/touch_pad.h" #include "unity.h" #include "esp_system.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" #include "esp_log.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/rtc_cntl_struct.h" +#include "soc/soc_caps.h" #include "soc/sens_reg.h" #include "soc/sens_struct.h" #include "soc/rtc_cntl_reg.h" #include "soc/rtc_cntl_struct.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_io_struct.h" +#include "driver/touch_sensor_legacy.h" #include "esp_rom_sys.h" #if CONFIG_PM_ENABLE #include "esp_pm.h" diff --git a/components/driver/test_apps/touch_sensor_v2/main/test_touch_v2.c b/components/driver/test_apps/touch_sensor_v2/main/test_touch_v2.c index 78b1d78a74c..479ffe702f1 100644 --- a/components/driver/test_apps/touch_sensor_v2/main/test_touch_v2.c +++ b/components/driver/test_apps/touch_sensor_v2/main/test_touch_v2.c @@ -12,7 +12,6 @@ #include #include #include "esp_system.h" -#include "driver/touch_pad.h" #include "unity.h" #include "esp_system.h" #include "freertos/FreeRTOS.h" @@ -20,8 +19,7 @@ #include "freertos/semphr.h" #include "freertos/queue.h" #include "esp_log.h" -#include "soc/rtc_cntl_reg.h" -#include "soc/rtc_cntl_struct.h" +#include "soc/soc_caps.h" #include "soc/sens_reg.h" #include "soc/sens_struct.h" #include "soc/rtc_cntl_reg.h" @@ -30,6 +28,7 @@ #include "soc/rtc_io_struct.h" #include "soc/syscon_reg.h" #include "driver/rtc_io.h" +#include "driver/touch_sensor_legacy.h" #include "esp_rom_sys.h" static const char *TAG = "test_touch"; diff --git a/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h b/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h index 737faf02490..c6204a6d6de 100644 --- a/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h +++ b/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h @@ -1,385 +1,11 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#ifdef __cplusplus -extern "C" { -#endif +#include "driver/touch_sensor_legacy.h" -#include "driver/touch_sensor_common.h" - -/** - * @brief Configure touch pad interrupt threshold. - * - * @note If FSM mode is set to TOUCH_FSM_MODE_TIMER, this function will be blocked for one measurement cycle and wait for data to be valid. - * - * @param touch_num touch pad index - * @param threshold interrupt threshold, - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG if argument wrong - * - ESP_FAIL if touch pad not initialized - */ -esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold); - -/** - * @brief get touch sensor counter value. - * Each touch sensor has a counter to count the number of charge/discharge cycles. - * When the pad is not 'touched', we can get a number of the counter. - * When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance. - * - * @note This API requests hardware measurement once. If IIR filter mode is enabled, - * please use 'touch_pad_read_raw_data' interface instead. - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief get filtered touch sensor counter value by IIR filter. - * - * @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered. - * This function can be called from ISR - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief get raw data (touch sensor counter value) from IIR filter process. - * Need not request hardware measurements. - * - * @note touch_pad_filter_start has to be called before calling touch_pad_read_raw_data. - * This function can be called from ISR - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief Callback function that is called after each IIR filter calculation. - * @note This callback is called in timer task in each filtering cycle. - * @note This callback should not be blocked. - * @param raw_value The latest raw data(touch sensor counter value) that - * points to all channels(raw_value[0..TOUCH_PAD_MAX-1]). - * @param filtered_value The latest IIR filtered data(calculated from raw data) that - * points to all channels(filtered_value[0..TOUCH_PAD_MAX-1]). - * - */ -typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value); - -/** - * @brief Register the callback function that is called after each IIR filter calculation. - * @note The 'read_cb' callback is called in timer task in each filtering cycle. - * @param read_cb Pointer to filtered callback function. - * If the argument passed in is NULL, the callback will stop. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG set error - */ -esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb); - -/** - * @brief Register touch-pad ISR. - * The handler will be attached to the same CPU core that this function is running on. - * @param fn Pointer to ISR handler - * @param arg Parameter for ISR - * @return - * - ESP_OK Success ; - * - ESP_ERR_INVALID_ARG GPIO error - * - ESP_ERR_NO_MEM No memory - */ -esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg); - -/** - * @brief Set the clock cycles of each measurement - * @note This function will specify the clock cycles of each measurement - * and the clock is sourced from SOC_MOD_CLK_RTC_FAST, its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX - * The touch sensor will record the charge and discharge times during these clock cycles as the final result (raw value) - * @note If clock cycles is too small, it may lead to inaccurate results. - * - * @param clock_cycle The clock cycles of each measurement - * measure_time = clock_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX - * @return - * - ESP_OK Set the clock cycle success - */ -esp_err_t touch_pad_set_measurement_clock_cycles(uint16_t clock_cycle); - -/** - * @brief Get the clock cycles of each measurement - * - * @param clock_cycle The clock cycles of each measurement - * @return - * - ESP_OK Get the clock cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_clock_cycles(uint16_t *clock_cycle); - -/** - * @brief Set the interval between two measurements - * @note The touch sensor will sleep between two measurements - * This function is to set the interval cycle - * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX - * - * @param interval_cycle The interval between two measurements - * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @return - * - ESP_OK Set interval cycle success - */ -esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); - -/** - * @brief Get the interval between two measurements - * - * @param interval_cycle The interval between two measurements - * @return - * - ESP_OK Get interval cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); - -/** - * @brief Set touch sensor measurement and sleep time. - * Excessive total time will slow down the touch response. - * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. - * @note The touch sensor will count the number of charge/discharge cycles over a fixed period of time (specified as the second parameter). - * That means the number of cycles (raw value) will decrease as the capacity of the touch pad is increasing. - * @note The greater the duty cycle of the measurement time, the more system power is consumed. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_cycle The duration of the touch sensor measurement. - * t_meas = meas_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle) -__attribute__((deprecated("please use 'touch_pad_set_measurement_clock_cycles' and 'touch_pad_set_measurement_interval' instead"))); - -/** - * @brief Get touch sensor measurement and sleep time - * @param sleep_cycle Pointer to accept sleep cycle number - * @param meas_cycle Pointer to accept measurement cycle count. - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle) -__attribute__((deprecated("please use 'touch_pad_get_measurement_clock_cycles' and 'touch_pad_get_measurement_interval' instead"))); - -/** - * @brief Trigger a touch sensor measurement, only support in SW mode of FSM - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_sw_start(void); - -/** - * @brief Set touch sensor interrupt threshold - * @param touch_num touch pad index - * @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode. - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold); - -/** - * @brief Get touch sensor interrupt threshold - * @param touch_num touch pad index - * @param threshold pointer to accept threshold - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold); - -/** - * @brief Set touch sensor interrupt trigger mode. - * Interrupt can be triggered either when counter result is less than - * threshold or when counter result is more than threshold. - * @param mode touch sensor interrupt trigger mode - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode); - -/** - * @brief Get touch sensor interrupt trigger mode - * @param mode pointer to accept touch sensor interrupt trigger mode - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode); - -/** - * @brief Set touch sensor interrupt trigger source. There are two sets of touch signals. - * Set1 and set2 can be mapped to several touch signals. Either set will be triggered - * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated - * if set1 is triggered, or only if both sets are triggered. - * @param src touch sensor interrupt trigger source - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src); - -/** - * @brief Get touch sensor interrupt trigger source - * @param src pointer to accept touch sensor interrupt trigger source - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src); - -/** - * @brief Set touch sensor group mask. - * Touch pad module has two sets of signals, 'Touched' signal is triggered only if - * at least one of touch pad in this group is "touched". - * This function will set the register bits according to the given bitmask. - * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value - * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value - * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); - -/** - * @brief Get touch sensor group mask. - * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value - * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value - * @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask); - -/** - * @brief Clear touch sensor group mask. - * Touch pad module has two sets of signals, Interrupt is triggered only if - * at least one of touch pad in this group is "touched". - * This function will clear the register bits according to the given bitmask. - * @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value - * @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value - * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); - -/** - * @brief To enable touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_enable(void); - -/** - * @brief To disable touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_disable(void); - -/** - * @brief To clear touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_clear(void); - -/** - * @brief set touch pad filter calibration period, in ms. - * Need to call touch_pad_filter_start before all touch filter APIs - * @param new_period_ms filter period, in ms - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - * - ESP_ERR_INVALID_ARG parameter error - */ -esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms); - -/** - * @brief get touch pad filter calibration period, in ms - * Need to call touch_pad_filter_start before all touch filter APIs - * @param p_period_ms pointer to accept period - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - * - ESP_ERR_INVALID_ARG parameter error - */ -esp_err_t touch_pad_get_filter_period(uint32_t *p_period_ms); - -/** - * @brief start touch pad filter function - * This API will start a filter to process the noise in order to prevent false triggering - * when detecting slight change of capacitance. - * Need to call touch_pad_filter_start before all touch filter APIs - * - * @note This filter uses FreeRTOS timer, which is dispatched from a task with - * priority 1 by default on CPU 0. So if some application task with higher priority - * takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected. - * You can adjust FreeRTOS timer task priority in menuconfig. - * @param filter_period_ms filter calibration period, in ms - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter error - * - ESP_ERR_NO_MEM No memory for driver - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); - -/** - * @brief stop touch pad filter function - * Need to call touch_pad_filter_start before all touch filter APIs - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_stop(void); - -/** - * @brief delete touch pad filter driver and release the memory - * Need to call touch_pad_filter_start before all touch filter APIs - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_delete(void); - -#ifdef __cplusplus -} -#endif +// Keep for compatibility diff --git a/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h b/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h new file mode 100644 index 00000000000..c1a6f759f27 --- /dev/null +++ b/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h @@ -0,0 +1,385 @@ +/* + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#ifdef __cplusplus +extern "C" { +#endif + +#include "driver/touch_sensor_common.h" + +/** + * @brief Configure touch pad interrupt threshold. + * + * @note If FSM mode is set to TOUCH_FSM_MODE_TIMER, this function will be blocked for one measurement cycle and wait for data to be valid. + * + * @param touch_num touch pad index + * @param threshold interrupt threshold, + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG if argument wrong + * - ESP_FAIL if touch pad not initialized + */ +esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold); + +/** + * @brief get touch sensor counter value. + * Each touch sensor has a counter to count the number of charge/discharge cycles. + * When the pad is not 'touched', we can get a number of the counter. + * When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance. + * + * @note This API requests hardware measurement once. If IIR filter mode is enabled, + * please use 'touch_pad_read_raw_data' interface instead. + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief get filtered touch sensor counter value by IIR filter. + * + * @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered. + * This function can be called from ISR + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief get raw data (touch sensor counter value) from IIR filter process. + * Need not request hardware measurements. + * + * @note touch_pad_filter_start has to be called before calling touch_pad_read_raw_data. + * This function can be called from ISR + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief Callback function that is called after each IIR filter calculation. + * @note This callback is called in timer task in each filtering cycle. + * @note This callback should not be blocked. + * @param raw_value The latest raw data(touch sensor counter value) that + * points to all channels(raw_value[0..TOUCH_PAD_MAX-1]). + * @param filtered_value The latest IIR filtered data(calculated from raw data) that + * points to all channels(filtered_value[0..TOUCH_PAD_MAX-1]). + * + */ +typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value); + +/** + * @brief Register the callback function that is called after each IIR filter calculation. + * @note The 'read_cb' callback is called in timer task in each filtering cycle. + * @param read_cb Pointer to filtered callback function. + * If the argument passed in is NULL, the callback will stop. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG set error + */ +esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb); + +/** + * @brief Register touch-pad ISR. + * The handler will be attached to the same CPU core that this function is running on. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @return + * - ESP_OK Success ; + * - ESP_ERR_INVALID_ARG GPIO error + * - ESP_ERR_NO_MEM No memory + */ +esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg); + +/** + * @brief Set the clock cycles of each measurement + * @note This function will specify the clock cycles of each measurement + * and the clock is sourced from SOC_MOD_CLK_RTC_FAST, its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX + * The touch sensor will record the charge and discharge times during these clock cycles as the final result (raw value) + * @note If clock cycles is too small, it may lead to inaccurate results. + * + * @param clock_cycle The clock cycles of each measurement + * measure_time = clock_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX + * @return + * - ESP_OK Set the clock cycle success + */ +esp_err_t touch_pad_set_measurement_clock_cycles(uint16_t clock_cycle); + +/** + * @brief Get the clock cycles of each measurement + * + * @param clock_cycle The clock cycles of each measurement + * @return + * - ESP_OK Get the clock cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_clock_cycles(uint16_t *clock_cycle); + +/** + * @brief Set the interval between two measurements + * @note The touch sensor will sleep between two measurements + * This function is to set the interval cycle + * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX + * + * @param interval_cycle The interval between two measurements + * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @return + * - ESP_OK Set interval cycle success + */ +esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); + +/** + * @brief Get the interval between two measurements + * + * @param interval_cycle The interval between two measurements + * @return + * - ESP_OK Get interval cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); + +/** + * @brief Set touch sensor measurement and sleep time. + * Excessive total time will slow down the touch response. + * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. + * @note The touch sensor will count the number of charge/discharge cycles over a fixed period of time (specified as the second parameter). + * That means the number of cycles (raw value) will decrease as the capacity of the touch pad is increasing. + * @note The greater the duty cycle of the measurement time, the more system power is consumed. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_cycle The duration of the touch sensor measurement. + * t_meas = meas_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle) +__attribute__((deprecated("please use 'touch_pad_set_measurement_clock_cycles' and 'touch_pad_set_measurement_interval' instead"))); + +/** + * @brief Get touch sensor measurement and sleep time + * @param sleep_cycle Pointer to accept sleep cycle number + * @param meas_cycle Pointer to accept measurement cycle count. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle) +__attribute__((deprecated("please use 'touch_pad_get_measurement_clock_cycles' and 'touch_pad_get_measurement_interval' instead"))); + +/** + * @brief Trigger a touch sensor measurement, only support in SW mode of FSM + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_sw_start(void); + +/** + * @brief Set touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold); + +/** + * @brief Get touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold pointer to accept threshold + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold); + +/** + * @brief Set touch sensor interrupt trigger mode. + * Interrupt can be triggered either when counter result is less than + * threshold or when counter result is more than threshold. + * @param mode touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode); + +/** + * @brief Get touch sensor interrupt trigger mode + * @param mode pointer to accept touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode); + +/** + * @brief Set touch sensor interrupt trigger source. There are two sets of touch signals. + * Set1 and set2 can be mapped to several touch signals. Either set will be triggered + * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated + * if set1 is triggered, or only if both sets are triggered. + * @param src touch sensor interrupt trigger source + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src); + +/** + * @brief Get touch sensor interrupt trigger source + * @param src pointer to accept touch sensor interrupt trigger source + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src); + +/** + * @brief Set touch sensor group mask. + * Touch pad module has two sets of signals, 'Touched' signal is triggered only if + * at least one of touch pad in this group is "touched". + * This function will set the register bits according to the given bitmask. + * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief Get touch sensor group mask. + * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask); + +/** + * @brief Clear touch sensor group mask. + * Touch pad module has two sets of signals, Interrupt is triggered only if + * at least one of touch pad in this group is "touched". + * This function will clear the register bits according to the given bitmask. + * @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief To enable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_enable(void); + +/** + * @brief To disable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_disable(void); + +/** + * @brief To clear touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_clear(void); + +/** + * @brief set touch pad filter calibration period, in ms. + * Need to call touch_pad_filter_start before all touch filter APIs + * @param new_period_ms filter period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms); + +/** + * @brief get touch pad filter calibration period, in ms + * Need to call touch_pad_filter_start before all touch filter APIs + * @param p_period_ms pointer to accept period + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_get_filter_period(uint32_t *p_period_ms); + +/** + * @brief start touch pad filter function + * This API will start a filter to process the noise in order to prevent false triggering + * when detecting slight change of capacitance. + * Need to call touch_pad_filter_start before all touch filter APIs + * + * @note This filter uses FreeRTOS timer, which is dispatched from a task with + * priority 1 by default on CPU 0. So if some application task with higher priority + * takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected. + * You can adjust FreeRTOS timer task priority in menuconfig. + * @param filter_period_ms filter calibration period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter error + * - ESP_ERR_NO_MEM No memory for driver + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); + +/** + * @brief stop touch pad filter function + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_stop(void); + +/** + * @brief delete touch pad filter driver and release the memory + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_delete(void); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor.h b/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor.h index 06f835879f0..adb40726ae3 100644 --- a/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor.h +++ b/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor.h @@ -1,646 +1,17 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include "driver/touch_sensor_common.h" +#include "sdkconfig.h" +#include "driver/touch_sensor_legacy.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Set touch sensor FSM start - * @note Start FSM after the touch sensor FSM mode is set. - * @note Call this function will reset benchmark of all touch channels. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_fsm_start(void); - -/** - * @brief Stop touch sensor FSM. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_fsm_stop(void); - -/** - * @brief Trigger a touch sensor measurement, only support in SW mode of FSM - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_sw_start(void); - -/** - * @brief Set charge and discharge times of each measurement - * @note This function will specify the charge and discharge times in each measurement period - * The clock is sourced from SOC_MOD_CLK_RTC_FAST, and its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX - * The touch sensor will record the total clock cycles of all the charge and discharge cycles as the final result (raw value) - * @note If the charge and discharge times is too small, it may lead to inaccurate results. - * - * @param charge_discharge_times Charge and discharge times, range: 0 ~ 0xffff. - * No exact typical value can be recommended because the capacity is influenced by the hardware design and how finger touches, - * but suggest adjusting this value to make the measurement time around 1 ms. - * @return - * - ESP_OK Set charge and discharge times success - */ -esp_err_t touch_pad_set_charge_discharge_times(uint16_t charge_discharge_times); - -/** - * @brief Get charge and discharge times of each measurement - * - * @param charge_discharge_times Charge and discharge times - * @return - * - ESP_OK Get charge_discharge_times success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_charge_discharge_times(uint16_t *charge_discharge_times); - -/** - * @brief Set the interval between two measurements - * @note The touch sensor will sleep between two measurements - * This function is to set the interval cycle - * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX - * - * @param interval_cycle The interval between two measurements - * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @return - * - ESP_OK Set interval cycle success - */ -esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); - -/** - * @brief Get the interval between two measurements - * - * @param interval_cycle The interval between two measurements - * @return - * - ESP_OK Get interval cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); - -/** - * @brief Set touch sensor times of charge and discharge and sleep time. - * Excessive total time will slow down the touch response. - * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. - * @note The touch sensor will measure time of a fixed number of charge/discharge cycles (specified as the second parameter). - * That means the time (raw value) will increase as the capacity of the touch pad is increasing. - * The time (raw value) here is the number of clock cycles which is sourced from SOC_MOD_CLK_RTC_FAST and at (SOC_CLK_RC_FAST_FREQ_APPROX) Hz as default - * @note The greater the duty cycle of the measurement time, the more system power is consumed. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_times The times of charge and discharge in each measurement of touch channels. Range: 0 ~ 0xffff. - * Recommended typical value: Modify this value to make the measurement time around 1 ms. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_times) -__attribute__((deprecated("please use 'touch_pad_set_charge_discharge_times' and 'touch_pad_set_measurement_interval' instead"))); - -/** - * @brief Get touch sensor times of charge and discharge and sleep time - * @param sleep_cycle Pointer to accept sleep cycle number - * @param meas_times Pointer to accept measurement times count. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_times) -__attribute__((deprecated("please use 'touch_pad_get_charge_discharge_times' and 'touch_pad_get_measurement_interval' instead"))); - -/** - * @brief Set the connection type of touch channels in idle status. - * When a channel is in measurement mode, other initialized channels are in idle mode. - * The touch channel is generally adjacent to the trace, so the connection state of the idle channel - * affects the stability and sensitivity of the test channel. - * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. - * The `CONN_GND`(grounding) setting increases the stability of touch channels. - * @param type Select idle channel connect to high resistance state or ground. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_idle_channel_connect(touch_pad_conn_type_t type); - -/** - * @brief Get the connection type of touch channels in idle status. - * When a channel is in measurement mode, other initialized channels are in idle mode. - * The touch channel is generally adjacent to the trace, so the connection state of the idle channel - * affects the stability and sensitivity of the test channel. - * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. - * The `CONN_GND`(grounding) setting increases the stability of touch channels. - * @param type Pointer to connection type. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type); - -/** - * @brief Set the trigger threshold of touch sensor. - * The threshold determines the sensitivity of the touch sensor. - * The threshold is the original value of the trigger state minus the benchmark value. - * @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered. - * @param touch_num touch pad index - * @param threshold threshold of touch sensor. Should be less than the max change value of touch. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint32_t threshold); - -/** - * @brief Get touch sensor trigger threshold - * @param touch_num touch pad index - * @param threshold pointer to accept threshold - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint32_t *threshold); - -/** - * @brief Register touch channel into touch sensor scan group. - * The working mode of the touch sensor is cyclically scanned. - * This function will set the scan bits according to the given bitmask. - * @note If set this mask, the FSM timer should be stop firsty. - * @note The touch sensor that in scan map, should be deinit GPIO function firstly by `touch_pad_io_init`. - * @param enable_mask bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_channel_mask(uint16_t enable_mask); - -/** - * @brief Get the touch sensor scan group bit mask. - * @param enable_mask Pointer to bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_channel_mask(uint16_t *enable_mask); - -/** - * @brief Clear touch channel from touch sensor scan group. - * The working mode of the touch sensor is cyclically scanned. - * This function will clear the scan bits according to the given bitmask. - * @note If clear all mask, the FSM timer should be stop firsty. - * @param enable_mask bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_clear_channel_mask(uint16_t enable_mask); - -/** - * @brief Configure parameter for each touch channel. - * @note Touch num 0 is denoise channel, please use `touch_pad_denoise_enable` to set denoise function - * @param touch_num touch pad index - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG if argument wrong - * - ESP_FAIL if touch pad not initialized - */ -esp_err_t touch_pad_config(touch_pad_t touch_num); - -/** - * @brief Reset the FSM of touch module. - * @note Call this function after `touch_pad_fsm_stop`. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_reset(void); - -/** - * @brief Get the current measure channel. - * @note Should be called when touch sensor measurement is in cyclic scan mode. - * @return - * - touch channel number - */ -touch_pad_t touch_pad_get_current_meas_channel(void); - -/** - * @brief Get the touch sensor interrupt status mask. - * @return - * - touch interrupt bit - */ -uint32_t touch_pad_read_intr_status_mask(void); - -/** - * @brief Enable touch sensor interrupt by bitmask. - * @note This API can be called in ISR handler. - * @param int_mask Pad mask to enable interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask); - -/** - * @brief Disable touch sensor interrupt by bitmask. - * @note This API can be called in ISR handler. - * @param int_mask Pad mask to disable interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_disable(touch_pad_intr_mask_t int_mask); - -/** - * @brief Clear touch sensor interrupt by bitmask. - * @param int_mask Pad mask to clear interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_clear(touch_pad_intr_mask_t int_mask); - -/** - * @brief Register touch-pad ISR. - * The handler will be attached to the same CPU core that this function is running on. - * @param fn Pointer to ISR handler - * @param arg Parameter for ISR - * @param intr_mask Enable touch sensor interrupt handler by bitmask. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Arguments error - * - ESP_ERR_NO_MEM No memory - */ -esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_mask_t intr_mask); - -/** - * @brief Enable/disable the timeout check and set timeout threshold for all touch sensor channels measurements. - * If enable: When the touch reading of a touch channel exceeds the measurement threshold, a timeout interrupt will be generated. - * If disable: the FSM does not check if the channel under measurement times out. - * - * @note The threshold compared with touch readings. - * @note In order to avoid abnormal short circuit of some touch channels. This function should be turned on. - * Ensure the normal operation of other touch channels. - * - * @param enable true(default): Enable the timeout check; false: Disable the timeout check. - * @param threshold For all channels, the maximum value that will not be exceeded during normal operation. - * -* @return - * - ESP_OK Success - */ -esp_err_t touch_pad_timeout_set(bool enable, uint32_t threshold); - -/** - * @brief Call this interface after timeout to make the touch channel resume normal work. Point on the next channel to measure. - * If this API is not called, the touch FSM will stop the measurement after timeout interrupt. - * - * @note Call this API after finishes the exception handling by user. - * - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_timeout_resume(void); - -/** - * @brief get raw data of touch sensor. - * @note After the initialization is complete, the "raw_data" is max value. You need to wait for a measurement - * cycle before you can read the correct touch value. - * @param touch_num touch pad index - * @param raw_data pointer to accept touch sensor value - * @return - * - ESP_OK Success - * - ESP_FAIL Touch channel 0 haven't this parameter. - */ - -esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data); - -/** - * @brief get benchmark of touch sensor. - * @note After initialization, the benchmark value is the maximum during the first measurement period. - * @param touch_num touch pad index - * @param benchmark pointer to accept touch sensor benchmark value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter. - */ -esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark); - -/** - * @brief Get smoothed data that obtained by filtering the raw data. - * - * @param touch_num touch pad index - * @param smooth pointer to smoothed data - */ -esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth); - -/** - * @brief Force reset benchmark to raw data of touch sensor. - * @param touch_num touch pad index - * - TOUCH_PAD_MAX Reset basaline of all channels - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num); - -/** - * @brief set parameter of touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @param filter_info select filter type and threshold of detection algorithm - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_set_config(const touch_filter_config_t *filter_info); - -/** - * @brief get parameter of touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @param filter_info select filter type and threshold of detection algorithm - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info); - -/** - * @brief enable touch sensor filter for detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_enable(void); - -/** - * @brief disable touch sensor filter for detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_disable(void); - -/** - * @brief set parameter of denoise pad (TOUCH_PAD_NUM0). - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * The noise reduction function filters out interference introduced simultaneously on all channels, - * such as noise introduced by power supplies and external EMI. - * @param denoise parameter of denoise - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_set_config(const touch_pad_denoise_t *denoise); - -/** - * @brief get parameter of denoise pad (TOUCH_PAD_NUM0). - * @param denoise Pointer to parameter of denoise - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_get_config(touch_pad_denoise_t *denoise); - -/** - * @brief enable denoise function. - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * The noise reduction function filters out interference introduced simultaneously on all channels, - * such as noise introduced by power supplies and external EMI. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_enable(void); - -/** - * @brief disable denoise function. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_disable(void); - -/** - * @brief Get denoise measure value (TOUCH_PAD_NUM0). - * @param data Pointer to receive denoise value - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_read_data(uint32_t *data); - -/** - * @brief set parameter of waterproof function. - * - * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. - * Guard pad is used to detect the large area of water covering the touch panel. - * Shield pad is used to shield the influence of water droplets covering the touch panel. - * It is generally designed as a grid and is placed around the touch buttons. - * - * @param waterproof parameter of waterproof - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof); - -/** - * @brief get parameter of waterproof function. - * @param waterproof parameter of waterproof - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof); - -/** - * @brief Enable parameter of waterproof function. - * Should be called after function ``touch_pad_waterproof_set_config``. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_enable(void); - -/** - * @brief Disable parameter of waterproof function. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_disable(void); - -/** - * @brief Enable/disable proximity function of touch channels. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note Supports up to three touch channels configured as proximity sensors. - * @param touch_num touch pad index - * @param enabled true: enable the proximity function; false: disable the proximity function - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - * - ESP_ERR_NOT_SUPPORTED: Don't support configured. - */ -esp_err_t touch_pad_proximity_enable(touch_pad_t touch_num, bool enabled); - -/** - * @brief Set measure count of proximity channel. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. - * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. - * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - */ -esp_err_t touch_pad_proximity_set_count(touch_pad_t touch_num, uint32_t count); - -/** - * @brief Get measure count of proximity channel. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. - * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. - * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - */ -esp_err_t touch_pad_proximity_get_count(touch_pad_t touch_num, uint32_t *count); - -/** - * @brief Get the accumulated measurement of the proximity sensor. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * @param touch_num touch pad index - * @param measure_out If the accumulation process does not end, the `measure_out` is the process value. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch num is not proximity - */ -esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_out); - -/** - * @brief Get parameter of touch sensor sleep channel. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note After the sleep channel is configured, Please use special functions for sleep channel. - * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. - * - * @param slp_config touch sleep pad config. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_get_info(touch_pad_sleep_channel_t *slp_config); - -/** - * @brief Enable/Disable sleep channel function for touch sensor. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note ESP32S2 only support one sleep channel. - * @note After the sleep channel is configured, Please use special functions for sleep channel. - * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param enable true: enable sleep pad for touch sensor; false: disable sleep pad for touch sensor; - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_enable(touch_pad_t pad_num, bool enable); - -/** - * @brief Enable/Disable proximity function for sleep channel. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note ESP32S2 only support one sleep channel. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param enable true: enable proximity for sleep channel; false: disable proximity for sleep channel; - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool enable); - -/** - * @brief Set the trigger threshold of touch sensor in deep sleep. - * The threshold determines the sensitivity of the touch sensor. - * - * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param touch_thres touch sleep pad threshold - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thres); - -/** - * @brief Get the trigger threshold of touch sensor in deep sleep. - * The threshold determines the sensitivity of the touch sensor. - * - * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param touch_thres touch sleep pad threshold - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres); - -/** - * @brief Read benchmark of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param benchmark pointer to accept touch sensor benchmark value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark); - -/** - * @brief Read smoothed data of touch sensor sleep channel. - * Smoothed data is filtered from the raw data. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param smooth_data pointer to accept touch sensor smoothed data - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_smooth(touch_pad_t pad_num, uint32_t *smooth_data); - -/** - * @brief Read raw data of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param raw_data pointer to accept touch sensor raw data - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data); - -/** - * @brief Reset benchmark of touch sensor sleep channel. - * - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_reset_benchmark(void); - -/** - * @brief Read proximity count of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param proximity_cnt pointer to accept touch sensor proximity count value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_proximity_cnt(touch_pad_t pad_num, uint32_t *proximity_cnt); - -/** - * @brief Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption. - * If this function is not called, the working frequency of touch in the deep sleep state is the same as that in the wake-up state. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_times The times of charge and discharge in each measure process of touch channels. - * The timer frequency is 8Mhz. Range: 0 ~ 0xffff. - * Recommended typical value: Modify this value to make the measurement time around 1ms. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times); - -#ifdef __cplusplus -} +#if !CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN +#warning "This set of Touch APIs has been deprecated, \ +please include 'driver/touch_sens.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 'Touch Configuration' menu in Kconfig" #endif diff --git a/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor_legacy.h b/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor_legacy.h new file mode 100644 index 00000000000..96ce7130674 --- /dev/null +++ b/components/driver/touch_sensor/esp32s2/include/driver/touch_sensor_legacy.h @@ -0,0 +1,646 @@ +/* + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "driver/touch_sensor_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set touch sensor FSM start + * @note Start FSM after the touch sensor FSM mode is set. + * @note Call this function will reset benchmark of all touch channels. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_fsm_start(void); + +/** + * @brief Stop touch sensor FSM. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_fsm_stop(void); + +/** + * @brief Trigger a touch sensor measurement, only support in SW mode of FSM + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_sw_start(void); + +/** + * @brief Set charge and discharge times of each measurement + * @note This function will specify the charge and discharge times in each measurement period + * The clock is sourced from SOC_MOD_CLK_RTC_FAST, and its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX + * The touch sensor will record the total clock cycles of all the charge and discharge cycles as the final result (raw value) + * @note If the charge and discharge times is too small, it may lead to inaccurate results. + * + * @param charge_discharge_times Charge and discharge times, range: 0 ~ 0xffff. + * No exact typical value can be recommended because the capacity is influenced by the hardware design and how finger touches, + * but suggest adjusting this value to make the measurement time around 1 ms. + * @return + * - ESP_OK Set charge and discharge times success + */ +esp_err_t touch_pad_set_charge_discharge_times(uint16_t charge_discharge_times); + +/** + * @brief Get charge and discharge times of each measurement + * + * @param charge_discharge_times Charge and discharge times + * @return + * - ESP_OK Get charge_discharge_times success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_charge_discharge_times(uint16_t *charge_discharge_times); + +/** + * @brief Set the interval between two measurements + * @note The touch sensor will sleep between two measurements + * This function is to set the interval cycle + * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX + * + * @param interval_cycle The interval between two measurements + * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @return + * - ESP_OK Set interval cycle success + */ +esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); + +/** + * @brief Get the interval between two measurements + * + * @param interval_cycle The interval between two measurements + * @return + * - ESP_OK Get interval cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); + +/** + * @brief Set touch sensor times of charge and discharge and sleep time. + * Excessive total time will slow down the touch response. + * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. + * @note The touch sensor will measure time of a fixed number of charge/discharge cycles (specified as the second parameter). + * That means the time (raw value) will increase as the capacity of the touch pad is increasing. + * The time (raw value) here is the number of clock cycles which is sourced from SOC_MOD_CLK_RTC_FAST and at (SOC_CLK_RC_FAST_FREQ_APPROX) Hz as default + * @note The greater the duty cycle of the measurement time, the more system power is consumed. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_times The times of charge and discharge in each measurement of touch channels. Range: 0 ~ 0xffff. + * Recommended typical value: Modify this value to make the measurement time around 1 ms. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_times) +__attribute__((deprecated("please use 'touch_pad_set_charge_discharge_times' and 'touch_pad_set_measurement_interval' instead"))); + +/** + * @brief Get touch sensor times of charge and discharge and sleep time + * @param sleep_cycle Pointer to accept sleep cycle number + * @param meas_times Pointer to accept measurement times count. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_times) +__attribute__((deprecated("please use 'touch_pad_get_charge_discharge_times' and 'touch_pad_get_measurement_interval' instead"))); + +/** + * @brief Set the connection type of touch channels in idle status. + * When a channel is in measurement mode, other initialized channels are in idle mode. + * The touch channel is generally adjacent to the trace, so the connection state of the idle channel + * affects the stability and sensitivity of the test channel. + * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. + * The `CONN_GND`(grounding) setting increases the stability of touch channels. + * @param type Select idle channel connect to high resistance state or ground. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_idle_channel_connect(touch_pad_conn_type_t type); + +/** + * @brief Get the connection type of touch channels in idle status. + * When a channel is in measurement mode, other initialized channels are in idle mode. + * The touch channel is generally adjacent to the trace, so the connection state of the idle channel + * affects the stability and sensitivity of the test channel. + * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. + * The `CONN_GND`(grounding) setting increases the stability of touch channels. + * @param type Pointer to connection type. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type); + +/** + * @brief Set the trigger threshold of touch sensor. + * The threshold determines the sensitivity of the touch sensor. + * The threshold is the original value of the trigger state minus the benchmark value. + * @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered. + * @param touch_num touch pad index + * @param threshold threshold of touch sensor. Should be less than the max change value of touch. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint32_t threshold); + +/** + * @brief Get touch sensor trigger threshold + * @param touch_num touch pad index + * @param threshold pointer to accept threshold + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint32_t *threshold); + +/** + * @brief Register touch channel into touch sensor scan group. + * The working mode of the touch sensor is cyclically scanned. + * This function will set the scan bits according to the given bitmask. + * @note If set this mask, the FSM timer should be stop firsty. + * @note The touch sensor that in scan map, should be deinit GPIO function firstly by `touch_pad_io_init`. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_channel_mask(uint16_t enable_mask); + +/** + * @brief Get the touch sensor scan group bit mask. + * @param enable_mask Pointer to bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_channel_mask(uint16_t *enable_mask); + +/** + * @brief Clear touch channel from touch sensor scan group. + * The working mode of the touch sensor is cyclically scanned. + * This function will clear the scan bits according to the given bitmask. + * @note If clear all mask, the FSM timer should be stop firsty. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_clear_channel_mask(uint16_t enable_mask); + +/** + * @brief Configure parameter for each touch channel. + * @note Touch num 0 is denoise channel, please use `touch_pad_denoise_enable` to set denoise function + * @param touch_num touch pad index + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG if argument wrong + * - ESP_FAIL if touch pad not initialized + */ +esp_err_t touch_pad_config(touch_pad_t touch_num); + +/** + * @brief Reset the FSM of touch module. + * @note Call this function after `touch_pad_fsm_stop`. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_reset(void); + +/** + * @brief Get the current measure channel. + * @note Should be called when touch sensor measurement is in cyclic scan mode. + * @return + * - touch channel number + */ +touch_pad_t touch_pad_get_current_meas_channel(void); + +/** + * @brief Get the touch sensor interrupt status mask. + * @return + * - touch interrupt bit + */ +uint32_t touch_pad_read_intr_status_mask(void); + +/** + * @brief Enable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. + * @param int_mask Pad mask to enable interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask); + +/** + * @brief Disable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. + * @param int_mask Pad mask to disable interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_disable(touch_pad_intr_mask_t int_mask); + +/** + * @brief Clear touch sensor interrupt by bitmask. + * @param int_mask Pad mask to clear interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_clear(touch_pad_intr_mask_t int_mask); + +/** + * @brief Register touch-pad ISR. + * The handler will be attached to the same CPU core that this function is running on. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @param intr_mask Enable touch sensor interrupt handler by bitmask. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Arguments error + * - ESP_ERR_NO_MEM No memory + */ +esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_mask_t intr_mask); + +/** + * @brief Enable/disable the timeout check and set timeout threshold for all touch sensor channels measurements. + * If enable: When the touch reading of a touch channel exceeds the measurement threshold, a timeout interrupt will be generated. + * If disable: the FSM does not check if the channel under measurement times out. + * + * @note The threshold compared with touch readings. + * @note In order to avoid abnormal short circuit of some touch channels. This function should be turned on. + * Ensure the normal operation of other touch channels. + * + * @param enable true(default): Enable the timeout check; false: Disable the timeout check. + * @param threshold For all channels, the maximum value that will not be exceeded during normal operation. + * +* @return + * - ESP_OK Success + */ +esp_err_t touch_pad_timeout_set(bool enable, uint32_t threshold); + +/** + * @brief Call this interface after timeout to make the touch channel resume normal work. Point on the next channel to measure. + * If this API is not called, the touch FSM will stop the measurement after timeout interrupt. + * + * @note Call this API after finishes the exception handling by user. + * + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_timeout_resume(void); + +/** + * @brief get raw data of touch sensor. + * @note After the initialization is complete, the "raw_data" is max value. You need to wait for a measurement + * cycle before you can read the correct touch value. + * @param touch_num touch pad index + * @param raw_data pointer to accept touch sensor value + * @return + * - ESP_OK Success + * - ESP_FAIL Touch channel 0 haven't this parameter. + */ + +esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data); + +/** + * @brief get benchmark of touch sensor. + * @note After initialization, the benchmark value is the maximum during the first measurement period. + * @param touch_num touch pad index + * @param benchmark pointer to accept touch sensor benchmark value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter. + */ +esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark); + +/** + * @brief Get smoothed data that obtained by filtering the raw data. + * + * @param touch_num touch pad index + * @param smooth pointer to smoothed data + */ +esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth); + +/** + * @brief Force reset benchmark to raw data of touch sensor. + * @param touch_num touch pad index + * - TOUCH_PAD_MAX Reset basaline of all channels + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num); + +/** + * @brief set parameter of touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @param filter_info select filter type and threshold of detection algorithm + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_set_config(const touch_filter_config_t *filter_info); + +/** + * @brief get parameter of touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @param filter_info select filter type and threshold of detection algorithm + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info); + +/** + * @brief enable touch sensor filter for detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_enable(void); + +/** + * @brief disable touch sensor filter for detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_disable(void); + +/** + * @brief set parameter of denoise pad (TOUCH_PAD_NUM0). + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * The noise reduction function filters out interference introduced simultaneously on all channels, + * such as noise introduced by power supplies and external EMI. + * @param denoise parameter of denoise + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_set_config(const touch_pad_denoise_t *denoise); + +/** + * @brief get parameter of denoise pad (TOUCH_PAD_NUM0). + * @param denoise Pointer to parameter of denoise + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_get_config(touch_pad_denoise_t *denoise); + +/** + * @brief enable denoise function. + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * The noise reduction function filters out interference introduced simultaneously on all channels, + * such as noise introduced by power supplies and external EMI. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_enable(void); + +/** + * @brief disable denoise function. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_disable(void); + +/** + * @brief Get denoise measure value (TOUCH_PAD_NUM0). + * @param data Pointer to receive denoise value + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_read_data(uint32_t *data); + +/** + * @brief set parameter of waterproof function. + * + * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. + * Guard pad is used to detect the large area of water covering the touch panel. + * Shield pad is used to shield the influence of water droplets covering the touch panel. + * It is generally designed as a grid and is placed around the touch buttons. + * + * @param waterproof parameter of waterproof + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof); + +/** + * @brief get parameter of waterproof function. + * @param waterproof parameter of waterproof + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof); + +/** + * @brief Enable parameter of waterproof function. + * Should be called after function ``touch_pad_waterproof_set_config``. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_enable(void); + +/** + * @brief Disable parameter of waterproof function. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_disable(void); + +/** + * @brief Enable/disable proximity function of touch channels. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note Supports up to three touch channels configured as proximity sensors. + * @param touch_num touch pad index + * @param enabled true: enable the proximity function; false: disable the proximity function + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + * - ESP_ERR_NOT_SUPPORTED: Don't support configured. + */ +esp_err_t touch_pad_proximity_enable(touch_pad_t touch_num, bool enabled); + +/** + * @brief Set measure count of proximity channel. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. + * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. + * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + */ +esp_err_t touch_pad_proximity_set_count(touch_pad_t touch_num, uint32_t count); + +/** + * @brief Get measure count of proximity channel. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. + * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. + * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + */ +esp_err_t touch_pad_proximity_get_count(touch_pad_t touch_num, uint32_t *count); + +/** + * @brief Get the accumulated measurement of the proximity sensor. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * @param touch_num touch pad index + * @param measure_out If the accumulation process does not end, the `measure_out` is the process value. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch num is not proximity + */ +esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_out); + +/** + * @brief Get parameter of touch sensor sleep channel. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note After the sleep channel is configured, Please use special functions for sleep channel. + * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. + * + * @param slp_config touch sleep pad config. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_get_info(touch_pad_sleep_channel_t *slp_config); + +/** + * @brief Enable/Disable sleep channel function for touch sensor. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note ESP32S2 only support one sleep channel. + * @note After the sleep channel is configured, Please use special functions for sleep channel. + * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param enable true: enable sleep pad for touch sensor; false: disable sleep pad for touch sensor; + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_enable(touch_pad_t pad_num, bool enable); + +/** + * @brief Enable/Disable proximity function for sleep channel. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note ESP32S2 only support one sleep channel. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param enable true: enable proximity for sleep channel; false: disable proximity for sleep channel; + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool enable); + +/** + * @brief Set the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param touch_thres touch sleep pad threshold + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thres); + +/** + * @brief Get the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param touch_thres touch sleep pad threshold + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres); + +/** + * @brief Read benchmark of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param benchmark pointer to accept touch sensor benchmark value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark); + +/** + * @brief Read smoothed data of touch sensor sleep channel. + * Smoothed data is filtered from the raw data. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param smooth_data pointer to accept touch sensor smoothed data + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_smooth(touch_pad_t pad_num, uint32_t *smooth_data); + +/** + * @brief Read raw data of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param raw_data pointer to accept touch sensor raw data + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data); + +/** + * @brief Reset benchmark of touch sensor sleep channel. + * + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_reset_benchmark(void); + +/** + * @brief Read proximity count of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param proximity_cnt pointer to accept touch sensor proximity count value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_proximity_cnt(touch_pad_t pad_num, uint32_t *proximity_cnt); + +/** + * @brief Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption. + * If this function is not called, the working frequency of touch in the deep sleep state is the same as that in the wake-up state. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_times The times of charge and discharge in each measure process of touch channels. + * The timer frequency is 8Mhz. Range: 0 ~ 0xffff. + * Recommended typical value: Modify this value to make the measurement time around 1ms. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/touch_sensor/esp32s2/touch_sensor.c b/components/driver/touch_sensor/esp32s2/touch_sensor.c index 42ed7c6291d..72c232742df 100644 --- a/components/driver/touch_sensor/esp32s2/touch_sensor.c +++ b/components/driver/touch_sensor/esp32s2/touch_sensor.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,7 +16,7 @@ #include "freertos/timers.h" #include "esp_intr_alloc.h" #include "driver/rtc_io.h" -#include "driver/touch_pad.h" +#include "driver/touch_sensor_common.h" #include "esp_private/rtc_ctrl.h" #include "driver/gpio.h" #include "sdkconfig.h" @@ -405,7 +405,7 @@ esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info) esp_err_t touch_pad_filter_enable(void) { TOUCH_ENTER_CRITICAL(); - touch_hal_filter_enable(); + touch_hal_filter_enable(true); TOUCH_EXIT_CRITICAL(); return ESP_OK; } @@ -413,7 +413,7 @@ esp_err_t touch_pad_filter_enable(void) esp_err_t touch_pad_filter_disable(void) { TOUCH_ENTER_CRITICAL(); - touch_hal_filter_disable(); + touch_hal_filter_enable(false); TOUCH_EXIT_CRITICAL(); return ESP_OK; } @@ -596,9 +596,9 @@ esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool ena TOUCH_ENTER_CRITICAL(); if (enable) { - touch_hal_sleep_enable_approach(); + touch_hal_sleep_enable_approach(true); } else { - touch_hal_sleep_disable_approach(); + touch_hal_sleep_enable_approach(false); } TOUCH_EXIT_CRITICAL(); return ESP_OK; @@ -684,3 +684,17 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m touch_hal_sleep_channel_set_work_time(sleep_cycle, meas_times); return ESP_OK; } + +/** + * @brief This function will be called during start up, to check that the new touch driver is not running along with the legacy touch driver + */ +static __attribute__((constructor)) void check_touch_driver_conflict(void) +{ + extern __attribute__((weak)) esp_err_t touch_del_channel(void *handle); + /* If the new I2S driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ + if ((void *)touch_del_channel != NULL) { + ESP_EARLY_LOGE("legacy_touch_driver", "CONFLICT! The new touch driver can't work along with the legacy touch driver"); + abort(); + } + ESP_EARLY_LOGW("legacy_touch_driver", "legacy touch driver is deprecated, please migrate to use driver/touch_sens.h"); +} diff --git a/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor.h b/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor.h index 06f835879f0..adb40726ae3 100644 --- a/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor.h +++ b/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor.h @@ -1,646 +1,17 @@ /* - * SPDX-FileCopyrightText: 2019-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include "driver/touch_sensor_common.h" +#include "sdkconfig.h" +#include "driver/touch_sensor_legacy.h" -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @brief Set touch sensor FSM start - * @note Start FSM after the touch sensor FSM mode is set. - * @note Call this function will reset benchmark of all touch channels. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_fsm_start(void); - -/** - * @brief Stop touch sensor FSM. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_fsm_stop(void); - -/** - * @brief Trigger a touch sensor measurement, only support in SW mode of FSM - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_sw_start(void); - -/** - * @brief Set charge and discharge times of each measurement - * @note This function will specify the charge and discharge times in each measurement period - * The clock is sourced from SOC_MOD_CLK_RTC_FAST, and its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX - * The touch sensor will record the total clock cycles of all the charge and discharge cycles as the final result (raw value) - * @note If the charge and discharge times is too small, it may lead to inaccurate results. - * - * @param charge_discharge_times Charge and discharge times, range: 0 ~ 0xffff. - * No exact typical value can be recommended because the capacity is influenced by the hardware design and how finger touches, - * but suggest adjusting this value to make the measurement time around 1 ms. - * @return - * - ESP_OK Set charge and discharge times success - */ -esp_err_t touch_pad_set_charge_discharge_times(uint16_t charge_discharge_times); - -/** - * @brief Get charge and discharge times of each measurement - * - * @param charge_discharge_times Charge and discharge times - * @return - * - ESP_OK Get charge_discharge_times success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_charge_discharge_times(uint16_t *charge_discharge_times); - -/** - * @brief Set the interval between two measurements - * @note The touch sensor will sleep between two measurements - * This function is to set the interval cycle - * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX - * - * @param interval_cycle The interval between two measurements - * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @return - * - ESP_OK Set interval cycle success - */ -esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); - -/** - * @brief Get the interval between two measurements - * - * @param interval_cycle The interval between two measurements - * @return - * - ESP_OK Get interval cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); - -/** - * @brief Set touch sensor times of charge and discharge and sleep time. - * Excessive total time will slow down the touch response. - * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. - * @note The touch sensor will measure time of a fixed number of charge/discharge cycles (specified as the second parameter). - * That means the time (raw value) will increase as the capacity of the touch pad is increasing. - * The time (raw value) here is the number of clock cycles which is sourced from SOC_MOD_CLK_RTC_FAST and at (SOC_CLK_RC_FAST_FREQ_APPROX) Hz as default - * @note The greater the duty cycle of the measurement time, the more system power is consumed. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_times The times of charge and discharge in each measurement of touch channels. Range: 0 ~ 0xffff. - * Recommended typical value: Modify this value to make the measurement time around 1 ms. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_times) -__attribute__((deprecated("please use 'touch_pad_set_charge_discharge_times' and 'touch_pad_set_measurement_interval' instead"))); - -/** - * @brief Get touch sensor times of charge and discharge and sleep time - * @param sleep_cycle Pointer to accept sleep cycle number - * @param meas_times Pointer to accept measurement times count. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_times) -__attribute__((deprecated("please use 'touch_pad_get_charge_discharge_times' and 'touch_pad_get_measurement_interval' instead"))); - -/** - * @brief Set the connection type of touch channels in idle status. - * When a channel is in measurement mode, other initialized channels are in idle mode. - * The touch channel is generally adjacent to the trace, so the connection state of the idle channel - * affects the stability and sensitivity of the test channel. - * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. - * The `CONN_GND`(grounding) setting increases the stability of touch channels. - * @param type Select idle channel connect to high resistance state or ground. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_idle_channel_connect(touch_pad_conn_type_t type); - -/** - * @brief Get the connection type of touch channels in idle status. - * When a channel is in measurement mode, other initialized channels are in idle mode. - * The touch channel is generally adjacent to the trace, so the connection state of the idle channel - * affects the stability and sensitivity of the test channel. - * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. - * The `CONN_GND`(grounding) setting increases the stability of touch channels. - * @param type Pointer to connection type. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type); - -/** - * @brief Set the trigger threshold of touch sensor. - * The threshold determines the sensitivity of the touch sensor. - * The threshold is the original value of the trigger state minus the benchmark value. - * @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered. - * @param touch_num touch pad index - * @param threshold threshold of touch sensor. Should be less than the max change value of touch. - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint32_t threshold); - -/** - * @brief Get touch sensor trigger threshold - * @param touch_num touch pad index - * @param threshold pointer to accept threshold - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint32_t *threshold); - -/** - * @brief Register touch channel into touch sensor scan group. - * The working mode of the touch sensor is cyclically scanned. - * This function will set the scan bits according to the given bitmask. - * @note If set this mask, the FSM timer should be stop firsty. - * @note The touch sensor that in scan map, should be deinit GPIO function firstly by `touch_pad_io_init`. - * @param enable_mask bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_channel_mask(uint16_t enable_mask); - -/** - * @brief Get the touch sensor scan group bit mask. - * @param enable_mask Pointer to bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_channel_mask(uint16_t *enable_mask); - -/** - * @brief Clear touch channel from touch sensor scan group. - * The working mode of the touch sensor is cyclically scanned. - * This function will clear the scan bits according to the given bitmask. - * @note If clear all mask, the FSM timer should be stop firsty. - * @param enable_mask bitmask of touch sensor scan group. - * e.g. TOUCH_PAD_NUM14 -> BIT(14) - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_clear_channel_mask(uint16_t enable_mask); - -/** - * @brief Configure parameter for each touch channel. - * @note Touch num 0 is denoise channel, please use `touch_pad_denoise_enable` to set denoise function - * @param touch_num touch pad index - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG if argument wrong - * - ESP_FAIL if touch pad not initialized - */ -esp_err_t touch_pad_config(touch_pad_t touch_num); - -/** - * @brief Reset the FSM of touch module. - * @note Call this function after `touch_pad_fsm_stop`. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_reset(void); - -/** - * @brief Get the current measure channel. - * @note Should be called when touch sensor measurement is in cyclic scan mode. - * @return - * - touch channel number - */ -touch_pad_t touch_pad_get_current_meas_channel(void); - -/** - * @brief Get the touch sensor interrupt status mask. - * @return - * - touch interrupt bit - */ -uint32_t touch_pad_read_intr_status_mask(void); - -/** - * @brief Enable touch sensor interrupt by bitmask. - * @note This API can be called in ISR handler. - * @param int_mask Pad mask to enable interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask); - -/** - * @brief Disable touch sensor interrupt by bitmask. - * @note This API can be called in ISR handler. - * @param int_mask Pad mask to disable interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_disable(touch_pad_intr_mask_t int_mask); - -/** - * @brief Clear touch sensor interrupt by bitmask. - * @param int_mask Pad mask to clear interrupts - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_clear(touch_pad_intr_mask_t int_mask); - -/** - * @brief Register touch-pad ISR. - * The handler will be attached to the same CPU core that this function is running on. - * @param fn Pointer to ISR handler - * @param arg Parameter for ISR - * @param intr_mask Enable touch sensor interrupt handler by bitmask. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Arguments error - * - ESP_ERR_NO_MEM No memory - */ -esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_mask_t intr_mask); - -/** - * @brief Enable/disable the timeout check and set timeout threshold for all touch sensor channels measurements. - * If enable: When the touch reading of a touch channel exceeds the measurement threshold, a timeout interrupt will be generated. - * If disable: the FSM does not check if the channel under measurement times out. - * - * @note The threshold compared with touch readings. - * @note In order to avoid abnormal short circuit of some touch channels. This function should be turned on. - * Ensure the normal operation of other touch channels. - * - * @param enable true(default): Enable the timeout check; false: Disable the timeout check. - * @param threshold For all channels, the maximum value that will not be exceeded during normal operation. - * -* @return - * - ESP_OK Success - */ -esp_err_t touch_pad_timeout_set(bool enable, uint32_t threshold); - -/** - * @brief Call this interface after timeout to make the touch channel resume normal work. Point on the next channel to measure. - * If this API is not called, the touch FSM will stop the measurement after timeout interrupt. - * - * @note Call this API after finishes the exception handling by user. - * - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_timeout_resume(void); - -/** - * @brief get raw data of touch sensor. - * @note After the initialization is complete, the "raw_data" is max value. You need to wait for a measurement - * cycle before you can read the correct touch value. - * @param touch_num touch pad index - * @param raw_data pointer to accept touch sensor value - * @return - * - ESP_OK Success - * - ESP_FAIL Touch channel 0 haven't this parameter. - */ - -esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data); - -/** - * @brief get benchmark of touch sensor. - * @note After initialization, the benchmark value is the maximum during the first measurement period. - * @param touch_num touch pad index - * @param benchmark pointer to accept touch sensor benchmark value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter. - */ -esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark); - -/** - * @brief Get smoothed data that obtained by filtering the raw data. - * - * @param touch_num touch pad index - * @param smooth pointer to smoothed data - */ -esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth); - -/** - * @brief Force reset benchmark to raw data of touch sensor. - * @param touch_num touch pad index - * - TOUCH_PAD_MAX Reset basaline of all channels - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num); - -/** - * @brief set parameter of touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @param filter_info select filter type and threshold of detection algorithm - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_set_config(const touch_filter_config_t *filter_info); - -/** - * @brief get parameter of touch sensor filter and detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @param filter_info select filter type and threshold of detection algorithm - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info); - -/** - * @brief enable touch sensor filter for detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_enable(void); - -/** - * @brief disable touch sensor filter for detection algorithm. - * For more details on the detection algorithm, please refer to the application documentation. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_filter_disable(void); - -/** - * @brief set parameter of denoise pad (TOUCH_PAD_NUM0). - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * The noise reduction function filters out interference introduced simultaneously on all channels, - * such as noise introduced by power supplies and external EMI. - * @param denoise parameter of denoise - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_set_config(const touch_pad_denoise_t *denoise); - -/** - * @brief get parameter of denoise pad (TOUCH_PAD_NUM0). - * @param denoise Pointer to parameter of denoise - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_get_config(touch_pad_denoise_t *denoise); - -/** - * @brief enable denoise function. - * T0 is an internal channel that does not have a corresponding external GPIO. - * T0 will work simultaneously with the measured channel Tn. Finally, the actual - * measured value of Tn is the value after subtracting lower bits of T0. - * The noise reduction function filters out interference introduced simultaneously on all channels, - * such as noise introduced by power supplies and external EMI. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_enable(void); - -/** - * @brief disable denoise function. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_disable(void); - -/** - * @brief Get denoise measure value (TOUCH_PAD_NUM0). - * @param data Pointer to receive denoise value - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_denoise_read_data(uint32_t *data); - -/** - * @brief set parameter of waterproof function. - * - * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. - * Guard pad is used to detect the large area of water covering the touch panel. - * Shield pad is used to shield the influence of water droplets covering the touch panel. - * It is generally designed as a grid and is placed around the touch buttons. - * - * @param waterproof parameter of waterproof - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof); - -/** - * @brief get parameter of waterproof function. - * @param waterproof parameter of waterproof - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof); - -/** - * @brief Enable parameter of waterproof function. - * Should be called after function ``touch_pad_waterproof_set_config``. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_enable(void); - -/** - * @brief Disable parameter of waterproof function. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_waterproof_disable(void); - -/** - * @brief Enable/disable proximity function of touch channels. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note Supports up to three touch channels configured as proximity sensors. - * @param touch_num touch pad index - * @param enabled true: enable the proximity function; false: disable the proximity function - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - * - ESP_ERR_NOT_SUPPORTED: Don't support configured. - */ -esp_err_t touch_pad_proximity_enable(touch_pad_t touch_num, bool enabled); - -/** - * @brief Set measure count of proximity channel. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. - * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. - * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - */ -esp_err_t touch_pad_proximity_set_count(touch_pad_t touch_num, uint32_t count); - -/** - * @brief Get measure count of proximity channel. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * - * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. - * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. - * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. - * @return - * - ESP_OK: Configured correctly. - * - ESP_ERR_INVALID_ARG: Touch channel number error. - */ -esp_err_t touch_pad_proximity_get_count(touch_pad_t touch_num, uint32_t *count); - -/** - * @brief Get the accumulated measurement of the proximity sensor. - * The proximity sensor measurement is the accumulation of touch channel measurements. - * @param touch_num touch pad index - * @param measure_out If the accumulation process does not end, the `measure_out` is the process value. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch num is not proximity - */ -esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_out); - -/** - * @brief Get parameter of touch sensor sleep channel. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note After the sleep channel is configured, Please use special functions for sleep channel. - * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. - * - * @param slp_config touch sleep pad config. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_get_info(touch_pad_sleep_channel_t *slp_config); - -/** - * @brief Enable/Disable sleep channel function for touch sensor. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note ESP32S2 only support one sleep channel. - * @note After the sleep channel is configured, Please use special functions for sleep channel. - * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param enable true: enable sleep pad for touch sensor; false: disable sleep pad for touch sensor; - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_enable(touch_pad_t pad_num, bool enable); - -/** - * @brief Enable/Disable proximity function for sleep channel. - * The touch sensor can works in sleep mode to wake up sleep. - * - * @note ESP32S2 only support one sleep channel. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param enable true: enable proximity for sleep channel; false: disable proximity for sleep channel; - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool enable); - -/** - * @brief Set the trigger threshold of touch sensor in deep sleep. - * The threshold determines the sensitivity of the touch sensor. - * - * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param touch_thres touch sleep pad threshold - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thres); - -/** - * @brief Get the trigger threshold of touch sensor in deep sleep. - * The threshold determines the sensitivity of the touch sensor. - * - * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. - * - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param touch_thres touch sleep pad threshold - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres); - -/** - * @brief Read benchmark of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param benchmark pointer to accept touch sensor benchmark value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark); - -/** - * @brief Read smoothed data of touch sensor sleep channel. - * Smoothed data is filtered from the raw data. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param smooth_data pointer to accept touch sensor smoothed data - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_smooth(touch_pad_t pad_num, uint32_t *smooth_data); - -/** - * @brief Read raw data of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param raw_data pointer to accept touch sensor raw data - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data); - -/** - * @brief Reset benchmark of touch sensor sleep channel. - * - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_reset_benchmark(void); - -/** - * @brief Read proximity count of touch sensor sleep channel. - * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. - * @param proximity_cnt pointer to accept touch sensor proximity count value - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter is NULL - */ -esp_err_t touch_pad_sleep_channel_read_proximity_cnt(touch_pad_t pad_num, uint32_t *proximity_cnt); - -/** - * @brief Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption. - * If this function is not called, the working frequency of touch in the deep sleep state is the same as that in the wake-up state. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_times The times of charge and discharge in each measure process of touch channels. - * The timer frequency is 8Mhz. Range: 0 ~ 0xffff. - * Recommended typical value: Modify this value to make the measurement time around 1ms. - * @return - * - ESP_OK Success - */ -esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times); - -#ifdef __cplusplus -} +#if !CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN +#warning "This set of Touch APIs has been deprecated, \ +please include 'driver/touch_sens.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 'Touch Configuration' menu in Kconfig" #endif diff --git a/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor_legacy.h b/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor_legacy.h new file mode 100644 index 00000000000..96ce7130674 --- /dev/null +++ b/components/driver/touch_sensor/esp32s3/include/driver/touch_sensor_legacy.h @@ -0,0 +1,646 @@ +/* + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "driver/touch_sensor_common.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Set touch sensor FSM start + * @note Start FSM after the touch sensor FSM mode is set. + * @note Call this function will reset benchmark of all touch channels. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_fsm_start(void); + +/** + * @brief Stop touch sensor FSM. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_fsm_stop(void); + +/** + * @brief Trigger a touch sensor measurement, only support in SW mode of FSM + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_sw_start(void); + +/** + * @brief Set charge and discharge times of each measurement + * @note This function will specify the charge and discharge times in each measurement period + * The clock is sourced from SOC_MOD_CLK_RTC_FAST, and its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX + * The touch sensor will record the total clock cycles of all the charge and discharge cycles as the final result (raw value) + * @note If the charge and discharge times is too small, it may lead to inaccurate results. + * + * @param charge_discharge_times Charge and discharge times, range: 0 ~ 0xffff. + * No exact typical value can be recommended because the capacity is influenced by the hardware design and how finger touches, + * but suggest adjusting this value to make the measurement time around 1 ms. + * @return + * - ESP_OK Set charge and discharge times success + */ +esp_err_t touch_pad_set_charge_discharge_times(uint16_t charge_discharge_times); + +/** + * @brief Get charge and discharge times of each measurement + * + * @param charge_discharge_times Charge and discharge times + * @return + * - ESP_OK Get charge_discharge_times success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_charge_discharge_times(uint16_t *charge_discharge_times); + +/** + * @brief Set the interval between two measurements + * @note The touch sensor will sleep between two measurements + * This function is to set the interval cycle + * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX + * + * @param interval_cycle The interval between two measurements + * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @return + * - ESP_OK Set interval cycle success + */ +esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); + +/** + * @brief Get the interval between two measurements + * + * @param interval_cycle The interval between two measurements + * @return + * - ESP_OK Get interval cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); + +/** + * @brief Set touch sensor times of charge and discharge and sleep time. + * Excessive total time will slow down the touch response. + * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. + * @note The touch sensor will measure time of a fixed number of charge/discharge cycles (specified as the second parameter). + * That means the time (raw value) will increase as the capacity of the touch pad is increasing. + * The time (raw value) here is the number of clock cycles which is sourced from SOC_MOD_CLK_RTC_FAST and at (SOC_CLK_RC_FAST_FREQ_APPROX) Hz as default + * @note The greater the duty cycle of the measurement time, the more system power is consumed. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_times The times of charge and discharge in each measurement of touch channels. Range: 0 ~ 0xffff. + * Recommended typical value: Modify this value to make the measurement time around 1 ms. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_times) +__attribute__((deprecated("please use 'touch_pad_set_charge_discharge_times' and 'touch_pad_set_measurement_interval' instead"))); + +/** + * @brief Get touch sensor times of charge and discharge and sleep time + * @param sleep_cycle Pointer to accept sleep cycle number + * @param meas_times Pointer to accept measurement times count. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_times) +__attribute__((deprecated("please use 'touch_pad_get_charge_discharge_times' and 'touch_pad_get_measurement_interval' instead"))); + +/** + * @brief Set the connection type of touch channels in idle status. + * When a channel is in measurement mode, other initialized channels are in idle mode. + * The touch channel is generally adjacent to the trace, so the connection state of the idle channel + * affects the stability and sensitivity of the test channel. + * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. + * The `CONN_GND`(grounding) setting increases the stability of touch channels. + * @param type Select idle channel connect to high resistance state or ground. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_idle_channel_connect(touch_pad_conn_type_t type); + +/** + * @brief Get the connection type of touch channels in idle status. + * When a channel is in measurement mode, other initialized channels are in idle mode. + * The touch channel is generally adjacent to the trace, so the connection state of the idle channel + * affects the stability and sensitivity of the test channel. + * The `CONN_HIGHZ`(high resistance) setting increases the sensitivity of touch channels. + * The `CONN_GND`(grounding) setting increases the stability of touch channels. + * @param type Pointer to connection type. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_idle_channel_connect(touch_pad_conn_type_t *type); + +/** + * @brief Set the trigger threshold of touch sensor. + * The threshold determines the sensitivity of the touch sensor. + * The threshold is the original value of the trigger state minus the benchmark value. + * @note If set "TOUCH_PAD_THRESHOLD_MAX", the touch is never be triggered. + * @param touch_num touch pad index + * @param threshold threshold of touch sensor. Should be less than the max change value of touch. + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint32_t threshold); + +/** + * @brief Get touch sensor trigger threshold + * @param touch_num touch pad index + * @param threshold pointer to accept threshold + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint32_t *threshold); + +/** + * @brief Register touch channel into touch sensor scan group. + * The working mode of the touch sensor is cyclically scanned. + * This function will set the scan bits according to the given bitmask. + * @note If set this mask, the FSM timer should be stop firsty. + * @note The touch sensor that in scan map, should be deinit GPIO function firstly by `touch_pad_io_init`. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_channel_mask(uint16_t enable_mask); + +/** + * @brief Get the touch sensor scan group bit mask. + * @param enable_mask Pointer to bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_channel_mask(uint16_t *enable_mask); + +/** + * @brief Clear touch channel from touch sensor scan group. + * The working mode of the touch sensor is cyclically scanned. + * This function will clear the scan bits according to the given bitmask. + * @note If clear all mask, the FSM timer should be stop firsty. + * @param enable_mask bitmask of touch sensor scan group. + * e.g. TOUCH_PAD_NUM14 -> BIT(14) + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_clear_channel_mask(uint16_t enable_mask); + +/** + * @brief Configure parameter for each touch channel. + * @note Touch num 0 is denoise channel, please use `touch_pad_denoise_enable` to set denoise function + * @param touch_num touch pad index + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG if argument wrong + * - ESP_FAIL if touch pad not initialized + */ +esp_err_t touch_pad_config(touch_pad_t touch_num); + +/** + * @brief Reset the FSM of touch module. + * @note Call this function after `touch_pad_fsm_stop`. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_reset(void); + +/** + * @brief Get the current measure channel. + * @note Should be called when touch sensor measurement is in cyclic scan mode. + * @return + * - touch channel number + */ +touch_pad_t touch_pad_get_current_meas_channel(void); + +/** + * @brief Get the touch sensor interrupt status mask. + * @return + * - touch interrupt bit + */ +uint32_t touch_pad_read_intr_status_mask(void); + +/** + * @brief Enable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. + * @param int_mask Pad mask to enable interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_enable(touch_pad_intr_mask_t int_mask); + +/** + * @brief Disable touch sensor interrupt by bitmask. + * @note This API can be called in ISR handler. + * @param int_mask Pad mask to disable interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_disable(touch_pad_intr_mask_t int_mask); + +/** + * @brief Clear touch sensor interrupt by bitmask. + * @param int_mask Pad mask to clear interrupts + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_clear(touch_pad_intr_mask_t int_mask); + +/** + * @brief Register touch-pad ISR. + * The handler will be attached to the same CPU core that this function is running on. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @param intr_mask Enable touch sensor interrupt handler by bitmask. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Arguments error + * - ESP_ERR_NO_MEM No memory + */ +esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg, touch_pad_intr_mask_t intr_mask); + +/** + * @brief Enable/disable the timeout check and set timeout threshold for all touch sensor channels measurements. + * If enable: When the touch reading of a touch channel exceeds the measurement threshold, a timeout interrupt will be generated. + * If disable: the FSM does not check if the channel under measurement times out. + * + * @note The threshold compared with touch readings. + * @note In order to avoid abnormal short circuit of some touch channels. This function should be turned on. + * Ensure the normal operation of other touch channels. + * + * @param enable true(default): Enable the timeout check; false: Disable the timeout check. + * @param threshold For all channels, the maximum value that will not be exceeded during normal operation. + * +* @return + * - ESP_OK Success + */ +esp_err_t touch_pad_timeout_set(bool enable, uint32_t threshold); + +/** + * @brief Call this interface after timeout to make the touch channel resume normal work. Point on the next channel to measure. + * If this API is not called, the touch FSM will stop the measurement after timeout interrupt. + * + * @note Call this API after finishes the exception handling by user. + * + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_timeout_resume(void); + +/** + * @brief get raw data of touch sensor. + * @note After the initialization is complete, the "raw_data" is max value. You need to wait for a measurement + * cycle before you can read the correct touch value. + * @param touch_num touch pad index + * @param raw_data pointer to accept touch sensor value + * @return + * - ESP_OK Success + * - ESP_FAIL Touch channel 0 haven't this parameter. + */ + +esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint32_t *raw_data); + +/** + * @brief get benchmark of touch sensor. + * @note After initialization, the benchmark value is the maximum during the first measurement period. + * @param touch_num touch pad index + * @param benchmark pointer to accept touch sensor benchmark value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch channel 0 haven't this parameter. + */ +esp_err_t touch_pad_read_benchmark(touch_pad_t touch_num, uint32_t *benchmark); + +/** + * @brief Get smoothed data that obtained by filtering the raw data. + * + * @param touch_num touch pad index + * @param smooth pointer to smoothed data + */ +esp_err_t touch_pad_filter_read_smooth(touch_pad_t touch_num, uint32_t *smooth); + +/** + * @brief Force reset benchmark to raw data of touch sensor. + * @param touch_num touch pad index + * - TOUCH_PAD_MAX Reset basaline of all channels + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_reset_benchmark(touch_pad_t touch_num); + +/** + * @brief set parameter of touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @param filter_info select filter type and threshold of detection algorithm + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_set_config(const touch_filter_config_t *filter_info); + +/** + * @brief get parameter of touch sensor filter and detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @param filter_info select filter type and threshold of detection algorithm + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info); + +/** + * @brief enable touch sensor filter for detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_enable(void); + +/** + * @brief disable touch sensor filter for detection algorithm. + * For more details on the detection algorithm, please refer to the application documentation. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_filter_disable(void); + +/** + * @brief set parameter of denoise pad (TOUCH_PAD_NUM0). + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * The noise reduction function filters out interference introduced simultaneously on all channels, + * such as noise introduced by power supplies and external EMI. + * @param denoise parameter of denoise + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_set_config(const touch_pad_denoise_t *denoise); + +/** + * @brief get parameter of denoise pad (TOUCH_PAD_NUM0). + * @param denoise Pointer to parameter of denoise + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_get_config(touch_pad_denoise_t *denoise); + +/** + * @brief enable denoise function. + * T0 is an internal channel that does not have a corresponding external GPIO. + * T0 will work simultaneously with the measured channel Tn. Finally, the actual + * measured value of Tn is the value after subtracting lower bits of T0. + * The noise reduction function filters out interference introduced simultaneously on all channels, + * such as noise introduced by power supplies and external EMI. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_enable(void); + +/** + * @brief disable denoise function. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_disable(void); + +/** + * @brief Get denoise measure value (TOUCH_PAD_NUM0). + * @param data Pointer to receive denoise value + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_denoise_read_data(uint32_t *data); + +/** + * @brief set parameter of waterproof function. + * + * The waterproof function includes a shielded channel (TOUCH_PAD_NUM14) and a guard channel. + * Guard pad is used to detect the large area of water covering the touch panel. + * Shield pad is used to shield the influence of water droplets covering the touch panel. + * It is generally designed as a grid and is placed around the touch buttons. + * + * @param waterproof parameter of waterproof + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_set_config(const touch_pad_waterproof_t *waterproof); + +/** + * @brief get parameter of waterproof function. + * @param waterproof parameter of waterproof + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_get_config(touch_pad_waterproof_t *waterproof); + +/** + * @brief Enable parameter of waterproof function. + * Should be called after function ``touch_pad_waterproof_set_config``. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_enable(void); + +/** + * @brief Disable parameter of waterproof function. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_waterproof_disable(void); + +/** + * @brief Enable/disable proximity function of touch channels. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note Supports up to three touch channels configured as proximity sensors. + * @param touch_num touch pad index + * @param enabled true: enable the proximity function; false: disable the proximity function + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + * - ESP_ERR_NOT_SUPPORTED: Don't support configured. + */ +esp_err_t touch_pad_proximity_enable(touch_pad_t touch_num, bool enabled); + +/** + * @brief Set measure count of proximity channel. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. + * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. + * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + */ +esp_err_t touch_pad_proximity_set_count(touch_pad_t touch_num, uint32_t count); + +/** + * @brief Get measure count of proximity channel. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * + * @note All proximity channels use the same `count` value. So please pass the parameter `TOUCH_PAD_MAX`. + * @param touch_num Touch pad index. In this version, pass the parameter `TOUCH_PAD_MAX`. + * @param count The cumulative times of measurements for proximity pad. Range: 0 ~ 255. + * @return + * - ESP_OK: Configured correctly. + * - ESP_ERR_INVALID_ARG: Touch channel number error. + */ +esp_err_t touch_pad_proximity_get_count(touch_pad_t touch_num, uint32_t *count); + +/** + * @brief Get the accumulated measurement of the proximity sensor. + * The proximity sensor measurement is the accumulation of touch channel measurements. + * @param touch_num touch pad index + * @param measure_out If the accumulation process does not end, the `measure_out` is the process value. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch num is not proximity + */ +esp_err_t touch_pad_proximity_get_data(touch_pad_t touch_num, uint32_t *measure_out); + +/** + * @brief Get parameter of touch sensor sleep channel. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note After the sleep channel is configured, Please use special functions for sleep channel. + * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. + * + * @param slp_config touch sleep pad config. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_get_info(touch_pad_sleep_channel_t *slp_config); + +/** + * @brief Enable/Disable sleep channel function for touch sensor. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note ESP32S2 only support one sleep channel. + * @note After the sleep channel is configured, Please use special functions for sleep channel. + * e.g. The user should uses `touch_pad_sleep_channel_read_data` instead of `touch_pad_read_raw_data` to obtain the sleep channel reading. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param enable true: enable sleep pad for touch sensor; false: disable sleep pad for touch sensor; + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_enable(touch_pad_t pad_num, bool enable); + +/** + * @brief Enable/Disable proximity function for sleep channel. + * The touch sensor can works in sleep mode to wake up sleep. + * + * @note ESP32S2 only support one sleep channel. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param enable true: enable proximity for sleep channel; false: disable proximity for sleep channel; + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool enable); + +/** + * @brief Set the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param touch_thres touch sleep pad threshold + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_set_threshold(touch_pad_t pad_num, uint32_t touch_thres); + +/** + * @brief Get the trigger threshold of touch sensor in deep sleep. + * The threshold determines the sensitivity of the touch sensor. + * + * @note In general, the touch threshold during sleep can use the threshold parameter parameters before sleep. + * + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param touch_thres touch sleep pad threshold + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_get_threshold(touch_pad_t pad_num, uint32_t *touch_thres); + +/** + * @brief Read benchmark of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param benchmark pointer to accept touch sensor benchmark value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_benchmark(touch_pad_t pad_num, uint32_t *benchmark); + +/** + * @brief Read smoothed data of touch sensor sleep channel. + * Smoothed data is filtered from the raw data. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param smooth_data pointer to accept touch sensor smoothed data + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_smooth(touch_pad_t pad_num, uint32_t *smooth_data); + +/** + * @brief Read raw data of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param raw_data pointer to accept touch sensor raw data + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_data(touch_pad_t pad_num, uint32_t *raw_data); + +/** + * @brief Reset benchmark of touch sensor sleep channel. + * + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_reset_benchmark(void); + +/** + * @brief Read proximity count of touch sensor sleep channel. + * @param pad_num Set touch channel number for sleep pad. Only one touch sensor channel is supported in deep sleep mode. + * @param proximity_cnt pointer to accept touch sensor proximity count value + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter is NULL + */ +esp_err_t touch_pad_sleep_channel_read_proximity_cnt(touch_pad_t pad_num, uint32_t *proximity_cnt); + +/** + * @brief Change the operating frequency of touch pad in deep sleep state. Reducing the operating frequency can effectively reduce power consumption. + * If this function is not called, the working frequency of touch in the deep sleep state is the same as that in the wake-up state. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / (RTC_SLOW_CLK frequency). + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_times The times of charge and discharge in each measure process of touch channels. + * The timer frequency is 8Mhz. Range: 0 ~ 0xffff. + * Recommended typical value: Modify this value to make the measurement time around 1ms. + * @return + * - ESP_OK Success + */ +esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t meas_times); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/touch_sensor/esp32s3/touch_sensor.c b/components/driver/touch_sensor/esp32s3/touch_sensor.c index d749996017b..3a2e645d7fb 100644 --- a/components/driver/touch_sensor/esp32s3/touch_sensor.c +++ b/components/driver/touch_sensor/esp32s3/touch_sensor.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,7 +16,7 @@ #include "freertos/timers.h" #include "esp_intr_alloc.h" #include "driver/rtc_io.h" -#include "driver/touch_pad.h" +#include "driver/touch_sensor_common.h" #include "esp_private/rtc_ctrl.h" #include "driver/gpio.h" #include "sdkconfig.h" @@ -379,7 +379,7 @@ esp_err_t touch_pad_filter_get_config(touch_filter_config_t *filter_info) esp_err_t touch_pad_filter_enable(void) { TOUCH_ENTER_CRITICAL(); - touch_hal_filter_enable(); + touch_hal_filter_enable(true); TOUCH_EXIT_CRITICAL(); return ESP_OK; } @@ -387,7 +387,7 @@ esp_err_t touch_pad_filter_enable(void) esp_err_t touch_pad_filter_disable(void) { TOUCH_ENTER_CRITICAL(); - touch_hal_filter_disable(); + touch_hal_filter_enable(false); TOUCH_EXIT_CRITICAL(); return ESP_OK; } @@ -569,9 +569,9 @@ esp_err_t touch_pad_sleep_channel_enable_proximity(touch_pad_t pad_num, bool ena TOUCH_ENTER_CRITICAL(); if (enable) { - touch_hal_sleep_enable_approach(); + touch_hal_sleep_enable_approach(true); } else { - touch_hal_sleep_disable_approach(); + touch_hal_sleep_enable_approach(false); } TOUCH_EXIT_CRITICAL(); return ESP_OK; @@ -656,3 +656,17 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m touch_hal_sleep_channel_set_work_time(sleep_cycle, meas_times); return ESP_OK; } + +/** + * @brief This function will be called during start up, to check that the new touch driver is not running along with the legacy touch driver + */ +static __attribute__((constructor)) void check_touch_driver_conflict(void) +{ + extern __attribute__((weak)) esp_err_t touch_del_channel(void *handle); + /* If the new I2S driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ + if ((void *)touch_del_channel != NULL) { + ESP_EARLY_LOGE("legacy_touch_driver", "CONFLICT! The new touch driver can't work along with the legacy touch driver"); + abort(); + } + ESP_EARLY_LOGW("legacy_touch_driver", "legacy touch driver is deprecated, please migrate to use driver/touch_sens.h"); +} diff --git a/components/driver/touch_sensor/touch_sensor_common.c b/components/driver/touch_sensor/touch_sensor_common.c index cbe1d4dced8..b2846d473d3 100644 --- a/components/driver/touch_sensor/touch_sensor_common.c +++ b/components/driver/touch_sensor/touch_sensor_common.c @@ -16,7 +16,6 @@ #include "freertos/timers.h" #include "esp_intr_alloc.h" #include "driver/rtc_io.h" -#include "driver/touch_pad.h" #include "esp_private/rtc_ctrl.h" #include "driver/gpio.h" #include "hal/touch_sensor_types.h" diff --git a/components/touch_element/include/touch_element/touch_element.h b/components/touch_element/include/touch_element/touch_element.h index 902c23e94b2..fa32d8f42c1 100644 --- a/components/touch_element/include/touch_element/touch_element.h +++ b/components/touch_element/include/touch_element/touch_element.h @@ -1,12 +1,12 @@ /* - * SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2016-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include "driver/touch_sensor.h" +#include "driver/touch_sensor_legacy.h" #ifdef __cplusplus extern "C" { @@ -274,9 +274,9 @@ esp_err_t touch_element_waterproof_remove(touch_elem_handle_t element_handle); * @return * - ESP_OK: Successfully initialized touch sleep * - ESP_ERR_INVALID_STATE: Touch element is not installed or touch sleep has been installed - * - ESP_ERR_INVALID_ARG: inputed argument is NULL + * - ESP_ERR_INVALID_ARG: inputted argument is NULL * - ESP_ERR_NO_MEM: no memory for touch sleep struct - * - ESP_ERR_NOT_SUPPORTED: inputed wakeup_elem_handle is not touch_button_handle_t type, currently only touch_button_handle_t supported + * - ESP_ERR_NOT_SUPPORTED: inputted wakeup_elem_handle is not touch_button_handle_t type, currently only touch_button_handle_t supported */ esp_err_t touch_element_enable_light_sleep(const touch_elem_sleep_config_t *sleep_config); @@ -305,9 +305,9 @@ esp_err_t touch_element_disable_light_sleep(void); * @return * - ESP_OK: Successfully initialized touch sleep * - ESP_ERR_INVALID_STATE: Touch element is not installed or touch sleep has been installed - * - ESP_ERR_INVALID_ARG: inputed argument is NULL + * - ESP_ERR_INVALID_ARG: inputted argument is NULL * - ESP_ERR_NO_MEM: no memory for touch sleep struct - * - ESP_ERR_NOT_SUPPORTED: inputed wakeup_elem_handle is not touch_button_handle_t type, currently only touch_button_handle_t supported + * - ESP_ERR_NOT_SUPPORTED: inputted wakeup_elem_handle is not touch_button_handle_t type, currently only touch_button_handle_t supported */ esp_err_t touch_element_enable_deep_sleep(touch_elem_handle_t wakeup_elem_handle, const touch_elem_sleep_config_t *sleep_config); From 1ccb534dc728b83946b325ee5e1ee15e8ff860db Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 17 Oct 2024 18:20:17 +0800 Subject: [PATCH 32/70] feat(touch): support s2 & s3 in touch driver-ng --- .../esp_driver_touch_sens/CMakeLists.txt | 9 +- .../common/touch_sens_common.c | 81 +-- .../common/touch_sens_private.h | 5 +- .../include/driver/touch_version_types.h | 373 +++++++++++++- .../hw_ver2/touch_version_specific.c | 470 ++++++++++++++++++ .../include/driver/touch_version_types.h | 95 +--- .../hw_ver3/touch_version_specific.c | 14 +- .../include/driver/touch_sens.h | 20 + .../include/driver/touch_sens_types.h | 67 ++- .../include/esp_private/touch_sens_helper.h | 45 ++ .../test_apps/.build-test-rules.yml | 6 +- .../test_apps/touch_sens/README.md | 4 +- .../touch_sens/main/test_touch_sens_common.c | 35 +- .../test_apps/touch_sens/pytest_touch_sens.py | 3 +- components/esp_hw_support/sleep_modes.c | 28 +- 15 files changed, 1099 insertions(+), 156 deletions(-) create mode 100644 components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c create mode 100644 components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h diff --git a/components/esp_driver_touch_sens/CMakeLists.txt b/components/esp_driver_touch_sens/CMakeLists.txt index e2a0c6040f8..d7f47492ad3 100644 --- a/components/esp_driver_touch_sens/CMakeLists.txt +++ b/components/esp_driver_touch_sens/CMakeLists.txt @@ -8,10 +8,11 @@ set(srcs) set(public_inc) if(CONFIG_SOC_TOUCH_SENSOR_SUPPORTED) - if(CONFIG_SOC_TOUCH_SENSOR_VERSION EQUAL 3) - list(APPEND srcs "hw_ver3/touch_version_specific.c" - "common/touch_sens_common.c") - list(APPEND public_inc "include" "hw_ver3/include") + set(version_folder "hw_ver${CONFIG_SOC_TOUCH_SENSOR_VERSION}") + if(CONFIG_SOC_TOUCH_SENSOR_VERSION GREATER 1) + list(APPEND srcs "common/touch_sens_common.c" + "${version_folder}/touch_version_specific.c") + list(APPEND public_inc "include" "${version_folder}/include") endif() endif() diff --git a/components/esp_driver_touch_sens/common/touch_sens_common.c b/components/esp_driver_touch_sens/common/touch_sens_common.c index f5119c72372..a89f6b05ac6 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_common.c +++ b/components/esp_driver_touch_sens/common/touch_sens_common.c @@ -21,6 +21,7 @@ #include "soc/interrupts.h" #include "esp_intr_alloc.h" #endif +#include "esp_private/touch_sens_helper.h" #if CONFIG_TOUCH_ENABLE_DEBUG_LOG // The local log level must be defined before including esp_log.h @@ -112,7 +113,7 @@ esp_err_t touch_sensor_del_controller(touch_sensor_handle_t sens_handle) ESP_GOTO_ON_ERROR(esp_intr_free(sens_handle->intr_handle), err, TAG, "Failed to deregister the interrupt handler"); #endif TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); - touch_ll_intr_disable(TOUCH_LL_INTR_MASK_ALL); + touch_ll_interrupt_disable(TOUCH_LL_INTR_MASK_ALL); touch_ll_clear_active_channel_status(); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); @@ -133,6 +134,7 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i TOUCH_NULL_POINTER_CHECK(chan_cfg); TOUCH_NULL_POINTER_CHECK(ret_chan_handle); TOUCH_CHANNEL_CHECK(chan_id); + ESP_RETURN_ON_FALSE(g_touch == sens_handle, ESP_ERR_INVALID_ARG, TAG, "The input touch sensor handle is unmatched"); esp_err_t ret = ESP_OK; @@ -145,18 +147,18 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i ESP_GOTO_ON_FALSE(sens_handle->ch[chan_id], ESP_ERR_NO_MEM, err2, TAG, "No memory for touch channel"); sens_handle->ch[chan_id]->id = chan_id; sens_handle->ch[chan_id]->base = sens_handle; - sens_handle->ch[chan_id]->is_prox_chan = false; + sens_handle->ch[chan_id]->prox_id = 0; /* Init the channel */ ESP_GOTO_ON_ERROR(touch_priv_config_channel(sens_handle->ch[chan_id], chan_cfg), err1, TAG, "Failed to configure the touch channel %d", chan_id); touch_channel_pin_init(chan_id); + + touch_chan_benchmark_config_t bm_cfg = {.do_reset = true}; TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); -#if SOC_TOUCH_SENSOR_VERSION == 2 - touch_ll_reset_chan_benchmark(1 << chan_id); -#endif sens_handle->chan_mask |= 1 << chan_id; - touch_ll_set_channel_mask(sens_handle->chan_mask); + /* Reset the benchmark to overwrite the legacy benchmark during the deep sleep */ + touch_priv_config_benchmark(sens_handle->ch[chan_id], &bm_cfg); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); *ret_chan_handle = sens_handle->ch[chan_id]; @@ -180,18 +182,32 @@ esp_err_t touch_sensor_del_channel(touch_channel_handle_t chan_handle) xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); -#if SOC_TOUCH_SENSOR_VERSION == 2 - if (sens_handle->guard_chan == chan_handle || (BIT(chan_handle->id) & sens_handle->shield_chan_mask)) { +#if SOC_TOUCH_SUPPORT_WATERPROOF + if (sens_handle->shield_chan == chan_handle) { ESP_GOTO_ON_ERROR(touch_sensor_config_waterproof(sens_handle, NULL), err, TAG, "Failed to disable waterproof on this channel"); + } else if (sens_handle->guard_chan == chan_handle) { + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_ll_waterproof_set_guard_chan(TOUCH_LL_NULL_CHANNEL); + sens_handle->guard_chan = NULL; + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } - if (sens_handle->sleep_chan == chan_handle) { - ESP_GOTO_ON_ERROR(touch_sensor_config_sleep_channel(sens_handle, NULL), err, TAG, "Failed to disable sleep function on this channel"); +#endif // SOC_TOUCH_SUPPORT_WATERPROOF +#if SOC_TOUCH_SUPPORT_SLEEP_WAKEUP + if (sens_handle->deep_slp_chan == chan_handle) { + ESP_GOTO_ON_ERROR(touch_sensor_config_sleep_wakeup(sens_handle, NULL), err, TAG, "Failed to disable sleep function on this channel"); + } +#endif +#if SOC_TOUCH_SUPPORT_PROX_SENSING + if (chan_handle->prox_id > 0) { + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + chan_handle->prox_id = 0; + touch_ll_set_proximity_sensing_channel(chan_handle->prox_id - 1, TOUCH_LL_NULL_CHANNEL); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } #endif int id = chan_handle->id; TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); sens_handle->chan_mask &= ~(1UL << id); - touch_ll_set_channel_mask(sens_handle->chan_mask); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); free(g_touch->ch[id]); @@ -230,13 +246,14 @@ esp_err_t touch_sensor_enable(touch_sensor_handle_t sens_handle) sens_handle->is_enabled = true; TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); - touch_ll_intr_clear(TOUCH_LL_INTR_MASK_ALL); - touch_ll_intr_enable(TOUCH_LL_INTR_MASK_ALL); + touch_ll_enable_channel_mask(sens_handle->chan_mask); + touch_ll_interrupt_clear(TOUCH_LL_INTR_MASK_ALL); + touch_ll_interrupt_enable(TOUCH_LL_INTR_MASK_ALL); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); #if SOC_TOUCH_SUPPORT_PROX_SENSING /* Reset the cached data of proximity channel */ FOR_EACH_TOUCH_CHANNEL(i) { - if (sens_handle->ch[i] && sens_handle->ch[i]->is_prox_chan) { + if (sens_handle->ch[i] && sens_handle->ch[i]->prox_id > 0) { sens_handle->ch[i]->prox_cnt = 0; memset(sens_handle->ch[i]->prox_val, 0, sizeof(sens_handle->ch[i]->prox_val[0]) * TOUCH_SAMPLE_CFG_NUM); } @@ -257,7 +274,8 @@ esp_err_t touch_sensor_disable(touch_sensor_handle_t sens_handle) ESP_GOTO_ON_FALSE(sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Touch sensor has not enabled"); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); - touch_ll_intr_disable(TOUCH_LL_INTR_MASK_ALL); + touch_ll_interrupt_disable(TOUCH_LL_INTR_MASK_ALL); + touch_ll_enable_channel_mask(0); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); sens_handle->is_enabled = false; @@ -294,13 +312,8 @@ esp_err_t touch_sensor_start_continuous_scanning(touch_sensor_handle_t sens_hand TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); sens_handle->is_started = true; -#if SOC_TOUCH_SENSOR_VERSION <= 2 - touch_ll_set_fsm_mode(TOUCH_FSM_MODE_TIMER); - touch_ll_start_fsm(); -#else touch_ll_enable_fsm_timer(true); - touch_ll_start_fsm_repeated_timer(false); -#endif + touch_ll_start_fsm_repeated_timer(); TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); err: @@ -316,13 +329,8 @@ esp_err_t touch_sensor_stop_continuous_scanning(touch_sensor_handle_t sens_handl ESP_GOTO_ON_FALSE_ISR(sens_handle->is_started, ESP_ERR_INVALID_STATE, err, TAG, "Continuous scanning not started yet"); TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); -#if SOC_TOUCH_SENSOR_VERSION <= 2 - touch_ll_stop_fsm(); - touch_ll_set_fsm_mode(TOUCH_FSM_MODE_SW); -#else - touch_ll_stop_fsm_repeated_timer(false); + touch_ll_stop_fsm_repeated_timer(); touch_ll_enable_fsm_timer(false); -#endif sens_handle->is_started = false; TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); @@ -351,7 +359,6 @@ esp_err_t touch_sensor_trigger_oneshot_scanning(touch_sensor_handle_t sens_handl } xSemaphoreTake(sens_handle->mutex, ticks); TickType_t end_tick = xTaskGetTickCount() + ticks; - // TODO: extract the following implementation into version specific source file when supporting other targets TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); touch_ll_enable_fsm_timer(false); TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); @@ -426,3 +433,21 @@ esp_err_t touch_channel_config_benchmark(touch_channel_handle_t chan_handle, con touch_priv_config_benchmark(chan_handle, benchmark_cfg); return ESP_OK; } + +/******************************************************************************/ +/* Scope: Private APIs */ +/******************************************************************************/ +esp_err_t touch_sensor_get_channel_info(touch_channel_handle_t chan_handle, touch_chan_info_t *chan_info) +{ + TOUCH_NULL_POINTER_CHECK(chan_handle); + TOUCH_NULL_POINTER_CHECK(chan_info); + xSemaphoreTake(chan_handle->base->mutex, portMAX_DELAY); + chan_info->chan_id = chan_handle->id; + chan_info->chan_gpio = touch_sensor_channel_io_map[chan_handle->id]; + chan_info->flags.is_dp_slp = chan_handle == chan_handle->base->deep_slp_chan; + chan_info->flags.is_proxi = chan_handle->prox_id > 0; + chan_info->flags.is_guard = chan_handle == chan_handle->base->guard_chan; + chan_info->flags.is_shield = chan_handle == chan_handle->base->shield_chan; + xSemaphoreGive(chan_handle->base->mutex); + return ESP_OK; +} diff --git a/components/esp_driver_touch_sens/common/touch_sens_private.h b/components/esp_driver_touch_sens/common/touch_sens_private.h index 325acb775e5..5b0ce8b2c8b 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_private.h +++ b/components/esp_driver_touch_sens/common/touch_sens_private.h @@ -14,7 +14,7 @@ #include "freertos/FreeRTOS.h" #include "freertos/semphr.h" #include "soc/soc_caps.h" -#include "hal/touch_sensor_hal.h" +#include "hal/touch_sens_hal.h" #include "driver/touch_sens_types.h" #include "esp_memory_utils.h" #include "esp_check.h" @@ -85,6 +85,7 @@ struct touch_sensor_s { bool immersion_proof; /*!< Flag to indicate whether to disable scanning when the guard ring is triggered */ bool proximity_en; /*!< Flag to indicate whether the proximity sensing feature is enabled */ bool timeout_en; /*!< Flag to indicate whether the measurement timeout feature (hardware timeout) is enabled */ + bool denoise_en; /*!< Flag to indicate whether the denoise channel feature is enabled */ }; /** @@ -94,7 +95,7 @@ struct touch_sensor_s { struct touch_channel_s { touch_sensor_handle_t base; /*!< The touch sensor controller handle */ int id; /*!< Touch channel id, the range is target-specific */ - bool is_prox_chan; /*!< Flag to indicate whether this is a proximity channel */ + int prox_id; /*!< The proximity channel id + 1. It is 0 if not a proximity channel */ uint32_t prox_cnt; /*!< Cache the proximity measurement count, only takes effect when the channel is a proximity channel. * When this count reaches `touch_proximity_config_t::scan_times`, * this field will be cleared and call the `on_proximity_meas_done` callback. diff --git a/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h b/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h index 3eb0d2167e9..a57587f7e03 100644 --- a/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h +++ b/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h @@ -9,4 +9,375 @@ * Version 2 includes ESP32-S2 and ESP32-S3 */ -#error "'esp_driver_touch_sens' does not support for ESP32-S2 and ESP32-S3 yet" +#pragma once + +#include "soc/soc_caps.h" +#include "driver/touch_sens_types.h" +#include "esp_err.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define TOUCH_MIN_CHAN_ID 1 /*!< The minimum available channel id of the touch pad */ +#define TOUCH_MAX_CHAN_ID 14 /*!< The maximum available channel id of the touch pad */ + +#define TOUCH_SHIELD_CHAN_ID 14 /*!< The touch channel that can be used as the shield channel */ + +/** + * @brief Helper macro to the default configurations of the touch sensor controller + * + * @param[in] sample_cfg_number The number of the sample configurations, which can only be 1 here because there is only one sample configuration + * @param[in] sample_cfg_ptr The pointer to the sample configurations + */ +#define TOUCH_SENSOR_DEFAULT_BASIC_CONFIG(sample_cfg_number, sample_cfg_ptr) { \ + .power_on_wait_us = 256, \ + .meas_interval_us = 32.0, \ + .max_meas_time_us = 0, \ + .sample_cfg_num = sample_cfg_number, \ + .sample_cfg = sample_cfg_ptr, \ +} + +/** + * @brief Helper macro to the default sample configurations + * @note This default configuration uses `sample frequency = clock frequency / 1` + * + * @param[in] chg_times The charge times of the touch channel + * @param[in] volt_low The low voltage limit of the touch channel + * @param[in] volt_high The high voltage limit of the touch channel + */ +#define TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(chg_times, volt_low, volt_high) { \ + .charge_times = chg_times, \ + .charge_volt_lim_h = volt_high, \ + .charge_volt_lim_l = volt_low, \ + .idle_conn = TOUCH_IDLE_CONN_GND, \ + .bias_type = TOUCH_BIAS_TYPE_SELF, \ +} + +/** + * @brief Helper macro to the default filter configurations + * + */ +#define TOUCH_SENSOR_DEFAULT_FILTER_CONFIG() { \ + .benchmark = { \ + .filter_mode = TOUCH_BM_IIR_FILTER_4, \ + .jitter_step = 4, \ + .denoise_lvl = 1, \ + }, \ + .data = { \ + .smooth_filter = TOUCH_SMOOTH_IIR_FILTER_2, \ + .active_hysteresis = 2, \ + .debounce_cnt = 2, \ + }, \ +} + +/** + * @brief The data type of the touch channel + * + */ +typedef enum { + TOUCH_CHAN_DATA_TYPE_RAW, /*!< The raw data of the touch channel */ + TOUCH_CHAN_DATA_TYPE_SMOOTH, /*!< The smooth data of the touch channel */ + TOUCH_CHAN_DATA_TYPE_BENCHMARK, /*!< The benchmark of the touch channel */ + TOUCH_CHAN_DATA_TYPE_PROXIMITY, /*!< The proximity data of the proximity channel */ +} touch_chan_data_type_t; + +/** + * @brief Sample configurations of the touch sensor + * + */ +typedef struct { + uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ + touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad */ + touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while charging a touch pad */ + touch_idle_conn_t idle_conn; /*!< The connection of the idle touch channels. + * The idle touch channel is a channel which is enabled but not under measuring. + */ + touch_bias_type_t bias_type; /*!< The type of the touch sensor bias */ +} touch_sensor_sample_config_t; + +/** + * @brief Configurations of the touch sensor controller + * + */ +typedef struct { + uint32_t power_on_wait_us; /*!< The waiting time between the channels power on and able to measure, to ensure the data stability */ + float meas_interval_us; /*!< Measurement interval of each channels */ + uint32_t max_meas_time_us; /*!< The maximum time of measuring one channel, if the time exceeds this value, the timeout interrupt will be triggered. + * Set to '0' to ignore the measurement time limitation, otherwise please set a proper time considering the configurations + * of this sample configurations below. + */ + /* Touch sensor sample configuration */ + uint32_t sample_cfg_num; /*!< The sample configuration number that used for sampling, CANNOT exceed TOUCH_SAMPLE_CFG_NUM */ + touch_sensor_sample_config_t *sample_cfg; /*!< The array of this sample configuration configurations, the length should be specified in `touch_sensor_config_t::sample_cfg_num` */ +} touch_sensor_config_t; + +/** + * @brief Configurations of the touch sensor channel + * + */ +typedef struct { + uint32_t active_thresh[TOUCH_SAMPLE_CFG_NUM]; /*!< The active threshold of each sample configuration, + * while the touch channel smooth value minus benchmark value exceed this threshold, + * will be regarded as activated + */ + touch_charge_speed_t charge_speed; /*!< The speed of charging and discharging the touch pad, the higher the speed, the faster charging and discharging */ + touch_init_charge_volt_t init_charge_volt; /*!< The initial voltage before charging/discharging a touch pad */ +} touch_channel_config_t; + +/** + * @brief Configurations of the touch sensor filter + * + */ +typedef struct { + /** + * @brief Benchmark configuration + */ + struct { + touch_benchmark_filter_mode_t filter_mode; /*!< Benchmark filter mode. IIR filter and Jitter filter can be selected, + * TOUCH_BM_IIR_FILTER_16 is recommended + */ + uint32_t jitter_step; /*!< Jitter filter step size, only takes effect when the `filter_mode` is TOUCH_BM_JITTER_FILTER. Range: [0 ~ 15] */ + int denoise_lvl; /*!< The denoise level, which determines the noise bouncing range that won't trigger benchmark update. + * Range: [0 ~ 4]. The greater the denoise_lvl is, more noise resistance will be. Specially, `0` stands for no denoise + * Typically, recommend to set this field to 1. + */ + } benchmark; /*!< Benchmark filter */ + /** + * @brief Data configuration + */ + struct { + touch_smooth_filter_mode_t smooth_filter; /*!< Smooth data IIR filter mode */ + uint32_t active_hysteresis; /*!< The hysteresis threshold to judge whether the touch channel is active + * If the channel data exceed the 'touch_channel_config_t::active_thresh + active_hysteresis' + * The channel will be activated. If the channel data is below to + * 'touch_channel_config_t::active_thresh - active_hysteresis' the channel will be inactivated. + */ + uint32_t debounce_cnt; /*!< The debounce count of the touch channel. + * Only when the channel data exceed the `touch_channel_config_t::active_thresh + active_hysteresis` for `debounce_cnt` times + * The channel will be activated. And only if the channel data is below to the `touch_channel_config_t::active_thresh - active_hysteresis` + * for `debounce_cnt` times, the channel will be inactivated. + * (The unit of `debounce_cnt` is the tick of the slow clock source) + */ + } data; /*!< Channel data filter */ +} touch_sensor_filter_config_t; + +/** + * @brief Touch sensor configuration during the deep sleep + * @note Currently it is the same as the normal controller configuration. + * The deep sleep configuration only takes effect when the chip entered sleep, + * so that to update a more power efficient configuration. + * + */ +typedef touch_sensor_config_t touch_sensor_config_dslp_t; + +/** + * @brief Configuration of the touch sensor sleep function + * + */ +typedef struct { + touch_sleep_wakeup_level_t slp_wakeup_lvl; /*!< The sleep level that can be woke up by touch sensor. */ + touch_channel_handle_t deep_slp_chan; /*!< The touch channel handle that supposed to work in the deep sleep. It can wake up the chip + * from deep sleep when this channel is activated. + * Only effective when the `touch_sleep_config_t::slp_wakeup_lvl` is `TOUCH_DEEP_SLEEP_WAKEUP` + */ + uint32_t deep_slp_thresh[TOUCH_SAMPLE_CFG_NUM]; /*!< The active threshold of the deep sleep channel during deep sleep, + * while the sleep channel exceed this threshold, it will be regarded as activated + * Only effective when the `touch_sleep_config_t::slp_wakeup_lvl` is `TOUCH_DEEP_SLEEP_WAKEUP` + */ + touch_sensor_config_dslp_t *deep_slp_sens_cfg; /*!< Specify the touch sensor configuration during the deep sleep. + * Note that these configurations will no take effect immediately, + * they will be set automatically while the chip prepare to enter sleep. + * Set NULL to not change the configurations before entering sleep. + * The sleep configuration mainly aims at lower down the charging and measuring times, + * so that to save power consumption during the sleep. + * Only effective when the `touch_sleep_config_t::slp_wakeup_lvl` is `TOUCH_DEEP_SLEEP_WAKEUP` + */ +} touch_sleep_config_t; + +/** + * @brief Configuration of the touch sensor waterproof function + * + */ +typedef struct { + touch_channel_handle_t guard_chan; /*!< The guard channel of that used for immersion detect. Set NULL if you don't need the guard channel. + * Typically, the guard channel is a ring that surrounds the touch panels, + * it is used to detect the large area that covered by water. + * While large area of water covers the touch panel, the guard channel will be activated. + */ + touch_channel_handle_t shield_chan; /*!< The shield channel that used for water droplets shield, can't be NULL. + * The shield channel can only be the No.14 channel on touch version 2. + * Typically, the shield channel uses grid layout which covers the touch area, + * it is used to shield the influence of water droplets covering both the touch panel and the shield channel. + * The shield channel will be paralleled to the current measuring channel (except the guard channel) to reduce the influence of water droplets. + */ + uint32_t shield_drv; /*!< The shield channel driver, which controls the drive capability of shield channel, range: 0 ~ 7 + * The larger the parasitic capacitance on the shielding channel, the higher the drive capability needs to be set. + */ + struct { + uint32_t immersion_proof: 1; /*!< Enable to protect the touch sensor pad when immersion detected. + * It will temporary disable the touch scanning if the guard channel triggered, and enable again if guard channel released. + * So that to avoid the fake touch when the touch panel is immersed in water. + */ + } flags; /*!< Flags of the water proof function */ +} touch_waterproof_config_t; + +/** + * @brief Configuration of the touch sensor proximity function + * + */ +typedef struct { + touch_channel_handle_t proximity_chan[TOUCH_PROXIMITY_CHAN_NUM]; /*!< The touch channel handles that will be configured as proximity sensing channels */ + uint32_t scan_times; /*!< The total scan times of EACH sample configuration, all sample configurations share a same `scan_times`. + * The measurement result of each scanning will be accumulated together to get the final result. + */ +} touch_proximity_config_t; + +/** + * @brief Configuration of denoise channel + * + */ +typedef struct { + touch_charge_speed_t charge_speed; /*!< The speed of charging and discharging the denoise touch channel, the higher the speed, the faster charging and discharging */ + touch_init_charge_volt_t init_charge_volt; /*!< The initial voltage before starting charging/discharging the denoise channel */ + touch_denoise_chan_cap_t ref_cap; /*!< The reference capacitance of the denoise channel. */ + touch_denoise_chan_res_t resolution; /*!< The noise suppression resolution of the denoise channel. + * The higher the resolution, the better the suppression effect, + * but at the same time, the attenuation of other touch channel sampling values also increases. + */ +} touch_denoise_chan_config_t; + +/** + * @brief Base event structure used in touch event queue + */ +typedef struct { + touch_channel_handle_t chan; /*!< the current triggered touch channel handle */ + int chan_id; /*!< the current triggered touch channel number */ + uint32_t status_mask; /*!< the current channel triggered status. + * For the bits in the status mask, + * if the bit is set, the corresponding channel is active + * if the bit is cleared, the corresponding channel is inactive + */ +} touch_base_event_data_t; + +/** + * @brief Measure done event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_meas_done_event_data_t; + +/** + * @brief Scan done event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_scan_done_event_data_t; + +/** + * @brief Active event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_active_event_data_t; + +/** + * @brief Inactive event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_inactive_event_data_t; + +/** + * @brief Proximity sensing measure done event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_prox_done_event_data_t; + +/** + * @brief Timeout event data + * @note Currently same as base event data + * + */ +typedef touch_base_event_data_t touch_timeout_event_data_t; + +/** + * @brief Touch sensor callbacks + * @note Set NULL for the used callbacks. + * + */ +typedef struct { + /** + * @brief Touch sensor on active event callback. + * Callback when any touch channel is activated. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor active event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_active)(touch_sensor_handle_t sens_handle, const touch_active_event_data_t *event, void *user_ctx); + /** + * @brief Touch sensor on inactive event callback. + * Callback when any touch channel is inactivated. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor inactive event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_inactive)(touch_sensor_handle_t sens_handle, const touch_inactive_event_data_t *event, void *user_ctx); + /** + * @brief Touch sensor on measure done event callback. + * Callback when the measurement of all the sample configurations on the current touch channel is done. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor measure done event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_measure_done)(touch_sensor_handle_t sens_handle, const touch_meas_done_event_data_t *event, void *user_ctx); + /** + * @brief Touch sensor on scan done event callback. + * Callback when finished scanning all the registered touch channels. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor scan done event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_scan_done)(touch_sensor_handle_t sens_handle, const touch_scan_done_event_data_t *event, void *user_ctx); + /** + * @brief Touch sensor on measurement timeout event callback. + * Callback when measure the current touch channel timeout. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor timeout event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_timeout)(touch_sensor_handle_t sens_handle, const touch_timeout_event_data_t *event, void *user_ctx); + /** + * @brief Touch sensor on proximity sensing measurement done event callback. + * Callback when proximity sensing measurement of the current channel is done. + * @param[in] sens_handle Touch sensor controller handle, created from `touch_sensor_new_controller()` + * @param[in] event Touch sensor proximity sensing measure done event data + * @param[in] user_ctx User registered context, passed from `touch_sensor_register_callbacks()` + * + * @return Whether a high priority task has been waken up by this callback function + */ + bool (*on_proximity_meas_done)(touch_sensor_handle_t sens_handle, const touch_prox_done_event_data_t *event, void *user_ctx); +} touch_event_callbacks_t; + +/** + * @brief Touch sensor benchmark configurations, to set or reset the benchmark of the channel + * + */ +typedef struct { + bool do_reset; /*!< Whether to reset the benchmark to the channel's latest smooth data */ +} touch_chan_benchmark_config_t; + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c new file mode 100644 index 00000000000..27af1aa834f --- /dev/null +++ b/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c @@ -0,0 +1,470 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/** + * @brief This file is only applicable to the touch hardware version2 + * Version 2 includes ESP32-S2 and ESP32-S3 + */ + +#include +#include +#include "freertos/FreeRTOS.h" +#include "freertos/semphr.h" +#include "soc/soc_caps.h" +#include "soc/clk_tree_defs.h" +#include "soc/touch_sensor_periph.h" +#include "soc/rtc.h" +#include "hal/hal_utils.h" +#include "driver/touch_sens.h" +#include "esp_private/rtc_ctrl.h" +#include "esp_private/periph_ctrl.h" +#include "esp_clk_tree.h" +#include "esp_sleep.h" +#include "../../common/touch_sens_private.h" +#if CONFIG_TOUCH_ENABLE_DEBUG_LOG +// The local log level must be defined before including esp_log.h +// Set the maximum log level for this source file +#define LOG_LOCAL_LEVEL ESP_LOG_DEBUG +#endif +#include "esp_check.h" + +#define TOUCH_DENOISE_CHAN_ID 0 /*!< The touch channel that can be used as the denoise channel */ + +static const char *TAG = "touch"; + +portMUX_TYPE g_touch_spinlock = portMUX_INITIALIZER_UNLOCKED; + +/****************************************************************************** + * Scope: touch driver private * + ******************************************************************************/ + +void touch_priv_enable_module(bool enable) +{ + TOUCH_ENTER_CRITICAL(TOUCH_RTC_LOCK); + touch_ll_enable_clock_gate(enable); + // Reset the benchmark after finished the scanning + touch_ll_reset_chan_benchmark(TOUCH_LL_FULL_CHANNEL_MASK); + TOUCH_EXIT_CRITICAL(TOUCH_RTC_LOCK); +} + +void IRAM_ATTR touch_priv_default_intr_handler(void *arg) +{ + /* If the touch controller object has not been allocated, return directly */ + if (!g_touch) { + return; + } + bool need_yield = false; + uint32_t status = touch_ll_get_intr_status_mask(); + g_touch->is_meas_timeout = false; + touch_ll_interrupt_clear(status); + touch_base_event_data_t data; + touch_ll_get_active_channel_mask(&data.status_mask); + data.chan = g_touch->ch[touch_ll_get_current_meas_channel()]; + /* If the channel is not registered, return directly */ + if (!data.chan) { + return; + } + data.chan_id = data.chan->id; + + if (status & TOUCH_LL_INTR_MASK_DONE) { +#if !SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED + /* For the target like ESP32-S2 that don't support proximity done interrupt, + Simulate the interrupt by software by judge the scan times. */ + if (data.chan->prox_id > 0 && + touch_ll_proximity_get_total_scan_times() == touch_ll_proximity_get_curr_scan_cnt(data.chan_id)) { + /* Set the proximity scan done flag to simulate a proximity done interrupt */ + status |= TOUCH_LL_INTR_MASK_PROX_DONE; + } +#endif + if (g_touch->cbs.on_measure_done) { + need_yield |= g_touch->cbs.on_measure_done(g_touch, &data, g_touch->user_ctx); + } + } + if (status & TOUCH_LL_INTR_MASK_SCAN_DONE) { +#if CONFIG_IDF_TARGET_ESP32S2 + /* Workaround for the fake scan done interrupt. + (Only happens when both channel 13 and 14 are enabled) + The scan done interrupt will be triggered twice for channel 13 and 14, + but we only hope it be triggered after channel 14 measurement done. */ + bool fake_scan_done = data.chan_id == 13 && (g_touch->chan_mask >> 13 == 0x03); + if (g_touch->cbs.on_scan_done && !fake_scan_done) +#else + if (g_touch->cbs.on_scan_done) +#endif + { + need_yield |= g_touch->cbs.on_scan_done(g_touch, &data, g_touch->user_ctx); + } + } + if (status & TOUCH_LL_INTR_MASK_PROX_DONE) { + /* Accumulated proximity sensing data is stored in the benchmark data register. + Read it out to latch the last proximity sensing data. */ + touch_ll_read_chan_data(data.chan_id, TOUCH_LL_READ_BENCHMARK, &data.chan->prox_val[0]); + // TODO: support to judge by software if the proximity channel triggered + if (g_touch->cbs.on_proximity_meas_done) { + need_yield |= g_touch->cbs.on_proximity_meas_done(g_touch, &data, g_touch->user_ctx); + } + } + if (status & TOUCH_LL_INTR_MASK_ACTIVE) { + /* When the guard ring activated, disable the scanning of other channels to avoid fake touch */ + TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + if (g_touch->waterproof_en && data.chan == g_touch->guard_chan) { + touch_ll_enable_scan_mask(~BIT(data.chan->id), false); + } + TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + if (g_touch->cbs.on_active) { + need_yield |= g_touch->cbs.on_active(g_touch, &data, g_touch->user_ctx); + } + } + if (status & TOUCH_LL_INTR_MASK_INACTIVE) { + /* When the guard ring inactivated, enable the scanning of other channels again */ + TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + if (g_touch->waterproof_en && data.chan == g_touch->guard_chan) { + touch_ll_enable_scan_mask(g_touch->chan_mask & (~BIT(g_touch->shield_chan->id)), true); + } + TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + if (g_touch->cbs.on_inactive) { + need_yield |= g_touch->cbs.on_inactive(g_touch, &data, g_touch->user_ctx); + } + } + if (status & TOUCH_LL_INTR_MASK_TIMEOUT) { + g_touch->is_meas_timeout = true; + touch_ll_force_done_curr_measurement(); + if ((g_touch->cbs.on_timeout)) { + need_yield |= g_touch->cbs.on_timeout(g_touch, &data, g_touch->user_ctx); + } + } + + if (need_yield) { + portYIELD_FROM_ISR(); + } +} + +static esp_err_t s_touch_convert_to_hal_config(touch_sensor_handle_t sens_handle, const touch_sensor_config_t *sens_cfg, touch_hal_config_t *hal_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_cfg); + TOUCH_NULL_POINTER_CHECK(hal_cfg); + + ESP_RETURN_ON_FALSE(sens_cfg->sample_cfg_num && sens_cfg->sample_cfg, ESP_ERR_INVALID_ARG, TAG, + "at least one sample configuration required"); + ESP_RETURN_ON_FALSE(sens_cfg->sample_cfg_num <= TOUCH_SAMPLE_CFG_NUM, ESP_ERR_INVALID_ARG, TAG, + "at most %d sample configurations supported", (int)(TOUCH_SAMPLE_CFG_NUM)); + + /* Get the source clock frequency for the first time */ + if (!sens_handle->src_freq_hz) { + /* Touch sensor actually uses dynamic fast clock LP_DYN_FAST_CLK, but it will only switch to the slow clock during sleep, + * This driver only designed for wakeup case (sleep case should use ULP driver), so we only need to consider RTC_FAST here */ + esp_clk_tree_src_get_freq_hz(SOC_MOD_CLK_RTC_FAST, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &sens_handle->src_freq_hz); + ESP_LOGD(TAG, "touch rtc clock source: RTC_FAST, frequency: %"PRIu32" Hz", sens_handle->src_freq_hz); + } + + uint32_t src_freq_mhz = sens_handle->src_freq_hz / 1000000; + hal_cfg->power_on_wait_ticks = (uint32_t)sens_cfg->power_on_wait_us * src_freq_mhz; + hal_cfg->power_on_wait_ticks = hal_cfg->power_on_wait_ticks > TOUCH_LL_PAD_MEASURE_WAIT_MAX ? + TOUCH_LL_PAD_MEASURE_WAIT_MAX : hal_cfg->power_on_wait_ticks; + hal_cfg->meas_interval_ticks = (uint32_t)(sens_cfg->meas_interval_us * src_freq_mhz); + hal_cfg->timeout_ticks = (uint32_t)sens_cfg->max_meas_time_us * src_freq_mhz; + ESP_RETURN_ON_FALSE(hal_cfg->timeout_ticks <= TOUCH_LL_TIMEOUT_MAX, ESP_ERR_INVALID_ARG, TAG, + "max_meas_time_ms should within %"PRIu32, TOUCH_LL_TIMEOUT_MAX / src_freq_mhz); + hal_cfg->sample_cfg_num = sens_cfg->sample_cfg_num; // Only one sample cfg + hal_cfg->sample_cfg = (touch_hal_sample_config_t *)sens_cfg->sample_cfg; + return ESP_OK; +} + +esp_err_t touch_priv_config_controller(touch_sensor_handle_t sens_handle, const touch_sensor_config_t *sens_cfg) +{ +#if CONFIG_TOUCH_ENABLE_DEBUG_LOG + esp_log_level_set(TAG, ESP_LOG_DEBUG); +#endif + /* Check and convert the configuration to hal configurations */ + touch_hal_config_t hal_cfg = {}; + ESP_RETURN_ON_ERROR(s_touch_convert_to_hal_config(sens_handle, sens_cfg, &hal_cfg), + TAG, "parse the configuration failed due to the invalid configuration"); + sens_handle->sample_cfg_num = 1; // Only have one set of sampling configuration + + /* Configure the hardware */ + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_hal_config_controller(&hal_cfg); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + + return ESP_OK; +} + +esp_err_t touch_priv_config_channel(touch_channel_handle_t chan_handle, const touch_channel_config_t *chan_cfg) +{ + // Check the validation of the channel active threshold + ESP_RETURN_ON_FALSE(chan_cfg->active_thresh[0] <= TOUCH_LL_ACTIVE_THRESH_MAX, ESP_ERR_INVALID_ARG, + TAG, "the active threshold out of range 0~%d", TOUCH_LL_ACTIVE_THRESH_MAX); + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_ll_set_chan_active_threshold(chan_handle->id, chan_cfg->active_thresh[0]); + touch_ll_set_charge_speed(chan_handle->id, chan_cfg->charge_speed); + touch_ll_set_init_charge_voltage(chan_handle->id, chan_cfg->init_charge_volt); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + return ESP_OK; +} + +esp_err_t touch_priv_deinit_controller(touch_sensor_handle_t sens_handle) +{ + /* Disable the additional functions */ + if (sens_handle->proximity_en) { + touch_sensor_config_proximity_sensing(sens_handle, NULL); + } + if (sens_handle->sleep_en) { + touch_sensor_config_sleep_wakeup(sens_handle, NULL); + } + if (sens_handle->waterproof_en) { + touch_sensor_config_waterproof(sens_handle, NULL); + } + if (sens_handle->denoise_en) { + touch_sensor_config_denoise_channel(sens_handle, NULL); + } + return ESP_OK; +} + +esp_err_t IRAM_ATTR touch_priv_channel_read_data(touch_channel_handle_t chan_handle, touch_chan_data_type_t type, uint32_t *data) +{ + ESP_RETURN_ON_FALSE_ISR(type >= TOUCH_CHAN_DATA_TYPE_RAW && type <= TOUCH_CHAN_DATA_TYPE_PROXIMITY, + ESP_ERR_INVALID_ARG, TAG, "The channel data type is invalid"); + ESP_RETURN_ON_FALSE_ISR(type != TOUCH_CHAN_DATA_TYPE_PROXIMITY || chan_handle->prox_id > 0, ESP_ERR_INVALID_ARG, TAG, "This is not a proximity sensing channel"); + TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + switch (type) { + default: // fall through + case TOUCH_CHAN_DATA_TYPE_RAW: + touch_ll_read_chan_data(chan_handle->id, TOUCH_LL_READ_RAW, data); + break; + case TOUCH_CHAN_DATA_TYPE_SMOOTH: + touch_ll_read_chan_data(chan_handle->id, TOUCH_LL_READ_SMOOTH, data); + break; + case TOUCH_CHAN_DATA_TYPE_BENCHMARK: + touch_ll_read_chan_data(chan_handle->id, TOUCH_LL_READ_BENCHMARK, data); + break; + case TOUCH_CHAN_DATA_TYPE_PROXIMITY: + /* Get the proximity value from the stored data. + * The proximity value are updated in the isr when proximity scanning is done */ + *data = chan_handle->prox_val[0]; + break; + } + TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); + return ESP_OK; +} + +void touch_priv_config_benchmark(touch_channel_handle_t chan_handle, const touch_chan_benchmark_config_t *benchmark_cfg) +{ + if (benchmark_cfg->do_reset) { + touch_ll_reset_chan_benchmark(BIT(chan_handle->id)); + } +} + +/****************************************************************************** + * Scope: public APIs * + ******************************************************************************/ + +esp_err_t touch_sensor_config_filter(touch_sensor_handle_t sens_handle, const touch_sensor_filter_config_t *filter_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_handle); + if (filter_cfg) { + ESP_RETURN_ON_FALSE(filter_cfg->benchmark.denoise_lvl >= 0 && filter_cfg->benchmark.denoise_lvl <= 4, + ESP_ERR_INVALID_ARG, TAG, "denoise_lvl is out of range"); + } + + esp_err_t ret = ESP_OK; + xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + + if (filter_cfg) { + touch_ll_filter_enable(true); + /* Configure the benchmark filter and update strategy */ + touch_ll_filter_set_filter_mode(filter_cfg->benchmark.filter_mode); + if (filter_cfg->benchmark.filter_mode == TOUCH_BM_JITTER_FILTER) { + touch_ll_filter_set_jitter_step(filter_cfg->benchmark.jitter_step); + } + touch_ll_filter_set_denoise_level(filter_cfg->benchmark.denoise_lvl); + /* Configure the touch data filter */ + touch_ll_filter_set_smooth_mode(filter_cfg->data.smooth_filter); + touch_ll_filter_set_active_hysteresis(filter_cfg->data.active_hysteresis); + touch_ll_filter_set_debounce(filter_cfg->data.debounce_cnt); + } else { + touch_ll_filter_enable(false); + } + + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + xSemaphoreGive(sens_handle->mutex); + return ret; +} + +esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, const touch_sleep_config_t *sleep_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_handle); + + esp_err_t ret = ESP_OK; + int dp_slp_chan_id = -1; + touch_hal_config_t hal_cfg = {}; + touch_hal_config_t *hal_cfg_ptr = NULL; + + xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); + + if (sleep_cfg) { + ESP_GOTO_ON_FALSE(sleep_cfg->slp_wakeup_lvl == TOUCH_LIGHT_SLEEP_WAKEUP || sleep_cfg->slp_wakeup_lvl == TOUCH_DEEP_SLEEP_WAKEUP, + ESP_ERR_INVALID_ARG, err, TAG, "Invalid sleep level"); + /* Enabled touch sensor as wake-up source */ + esp_sleep_enable_touchpad_wakeup(); +#if SOC_PM_SUPPORT_RTC_PERIPH_PD + // Keep ESP_PD_DOMAIN_RTC_PERIPH power domain on during the light/deep sleep, so that to keep the touch sensor working + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON); +#endif // SOC_PM_SUPPORT_RC_FAST_PD + + /* If set the deep sleep channel (i.e., enable deep sleep wake-up), + configure the deep sleep related settings. */ + if (sleep_cfg->slp_wakeup_lvl == TOUCH_DEEP_SLEEP_WAKEUP) { + ESP_GOTO_ON_FALSE(sleep_cfg->deep_slp_chan, ESP_ERR_INVALID_ARG, err, TAG, "deep sleep waken channel can't be NULL"); + dp_slp_chan_id = sleep_cfg->deep_slp_chan->id; + + /* Check and convert the configuration to hal configurations */ + if (sleep_cfg->deep_slp_sens_cfg) { + hal_cfg_ptr = &hal_cfg; + ESP_GOTO_ON_ERROR(s_touch_convert_to_hal_config(sens_handle, sleep_cfg->deep_slp_sens_cfg, hal_cfg_ptr), + err, TAG, "parse the configuration failed due to the invalid configuration"); + } + sens_handle->sleep_en = true; + sens_handle->deep_slp_chan = sleep_cfg->deep_slp_chan; + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_ll_sleep_set_threshold(sleep_cfg->deep_slp_thresh[0]); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + } + + } else { + /* Disable the touch sensor as wake-up source */ + esp_sleep_disable_wakeup_source(ESP_SLEEP_WAKEUP_TOUCHPAD); +#if SOC_PM_SUPPORT_RTC_PERIPH_PD + esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_AUTO); +#endif // SOC_PM_SUPPORT_RC_FAST_PD + sens_handle->deep_slp_chan = NULL; + sens_handle->sleep_en = false; + } + + /* Save or update the sleep config */ + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_hal_save_sleep_config(dp_slp_chan_id, hal_cfg_ptr); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + +err: + xSemaphoreGive(sens_handle->mutex); + return ret; +} + +// Water proof can be enabled separately +esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, const touch_waterproof_config_t *wp_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_handle); + + esp_err_t ret = ESP_OK; + xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + + ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); + + if (wp_cfg) { + ESP_GOTO_ON_FALSE(wp_cfg->shield_chan && wp_cfg->shield_chan->id == 14, ESP_ERR_INVALID_ARG, err, TAG, "Shield channel must be channel 14"); + // Check the validation of the waterproof configuration + TOUCH_NULL_POINTER_CHECK(wp_cfg->shield_chan); + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + sens_handle->waterproof_en = true; + sens_handle->guard_chan = wp_cfg->guard_chan; + sens_handle->shield_chan = wp_cfg->shield_chan; + touch_ll_waterproof_set_guard_chan(wp_cfg->guard_chan ? wp_cfg->guard_chan->id : TOUCH_LL_NULL_CHANNEL); + // need to disable the scanning of the shield channel + touch_ll_enable_scan_mask(BIT(wp_cfg->shield_chan->id), false); + touch_ll_waterproof_set_shield_driver(wp_cfg->shield_drv); + touch_ll_waterproof_enable(true); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + } else { + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + touch_ll_waterproof_enable(false); + touch_ll_waterproof_set_guard_chan(TOUCH_LL_NULL_CHANNEL); + touch_ll_enable_scan_mask(BIT(sens_handle->shield_chan->id), true); + touch_ll_waterproof_set_shield_driver(0); + sens_handle->guard_chan = NULL; + sens_handle->shield_chan = NULL; + sens_handle->waterproof_en = false; + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + } +err: + xSemaphoreGive(sens_handle->mutex); + return ret; +} + +esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handle, const touch_proximity_config_t *prox_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_handle); + + esp_err_t ret = ESP_OK; + xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + + ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); + + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + + /* Reset proximity sensing part of all channels */ + FOR_EACH_TOUCH_CHANNEL(i) { + if (sens_handle->ch[i]) { + sens_handle->ch[i]->prox_id = 0; + sens_handle->ch[i]->prox_cnt = 0; + memset(sens_handle->ch[i]->prox_val, 0, sizeof(sens_handle->ch[i]->prox_val[0]) * TOUCH_SAMPLE_CFG_NUM); + } + } + + if (prox_cfg) { + sens_handle->proximity_en = true; + for (int i = 0; i < TOUCH_PROXIMITY_CHAN_NUM; i++) { + if (prox_cfg->proximity_chan[i]) { + prox_cfg->proximity_chan[i]->prox_id = i + 1; + touch_ll_set_proximity_sensing_channel(i, prox_cfg->proximity_chan[i]->id); + } else { + touch_ll_set_proximity_sensing_channel(i, TOUCH_LL_NULL_CHANNEL); + } + } + touch_ll_proximity_set_total_scan_times(prox_cfg->scan_times); + } else { + for (int i = 0; i < TOUCH_PROXIMITY_CHAN_NUM; i++) { + touch_ll_set_proximity_sensing_channel(i, TOUCH_LL_NULL_CHANNEL); + } + sens_handle->proximity_en = false; + } + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + +err: + xSemaphoreGive(sens_handle->mutex); + return ret; +} + +esp_err_t touch_sensor_config_denoise_channel(touch_sensor_handle_t sens_handle, const touch_denoise_chan_config_t *denoise_cfg) +{ + TOUCH_NULL_POINTER_CHECK(sens_handle); + esp_err_t ret = ESP_OK; + xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + + ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); + + if (denoise_cfg) { + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + sens_handle->denoise_en = true; + sens_handle->chan_mask |= BIT(TOUCH_DENOISE_CHAN_ID); + touch_ll_set_charge_speed(TOUCH_DENOISE_CHAN_ID, denoise_cfg->charge_speed); + touch_ll_set_init_charge_voltage(TOUCH_DENOISE_CHAN_ID, denoise_cfg->init_charge_volt); + touch_ll_denoise_set_reference_cap(denoise_cfg->ref_cap); + touch_ll_denoise_set_resolution(denoise_cfg->resolution); + touch_ll_denoise_enable(true); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + } else { + TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); + sens_handle->denoise_en = false; + sens_handle->chan_mask &= ~BIT(TOUCH_DENOISE_CHAN_ID); + touch_ll_denoise_enable(false); + TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); + } +err: + xSemaphoreGive(sens_handle->mutex); + return ret; +} diff --git a/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h b/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h index cf15c14be8a..ddd68131842 100644 --- a/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h +++ b/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h @@ -25,6 +25,9 @@ extern "C" { /** * @brief Helper macro to the default configurations of the touch sensor controller * + * @param[in] sample_cfg_number The number of sample configurations, which should be less than or equal to `SOC_TOUCH_SAMPLE_CFG_NUM` + * Given multiple sample configurations to enable the frequency hopping + * @param[in] sample_cfg_array The pointer to the sample configurations array */ #define TOUCH_SENSOR_DEFAULT_BASIC_CONFIG(sample_cfg_number, sample_cfg_array) { \ .power_on_wait_us = 256, \ @@ -39,6 +42,9 @@ extern "C" { * @brief Helper macro to the default sample configurations * @note This default configuration uses `sample frequency = clock frequency / 1` * + * @param[in] _div_num The division of the final data, used to scaling the final data + * @param[in] coarse_freq_tune The coarse frequency tuning value + * @param[in] fine_freq_tune The fine frequency tuning value */ #define TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(_div_num, coarse_freq_tune, fine_freq_tune) { \ .div_num = _div_num, \ @@ -51,6 +57,10 @@ extern "C" { .bypass_shield_output = false, \ } +/** + * @brief Helper macro to the default filter configurations + * + */ #define TOUCH_SENSOR_DEFAULT_FILTER_CONFIG() { \ .benchmark = { \ .filter_mode = TOUCH_BM_IIR_FILTER_4, \ @@ -60,6 +70,7 @@ extern "C" { .data = { \ .smooth_filter = TOUCH_SMOOTH_IIR_FILTER_2, \ .active_hysteresis = 2, \ + .debounce_cnt = 2, \ }, \ } @@ -73,68 +84,6 @@ typedef enum { TOUCH_CHAN_DATA_TYPE_PROXIMITY, /*!< The proximity data of the proximity channel */ } touch_chan_data_type_t; -/** - * @brief The chip sleep level that allows the touch sensor to wake-up - * - */ -typedef enum { - TOUCH_LIGHT_SLEEP_WAKEUP, /*!< Only enable the touch sensor to wake up the chip from light sleep */ - TOUCH_DEEP_SLEEP_WAKEUP, /*!< Enable the touch sensor to wake up the chip from deep sleep or light sleep */ -} touch_sleep_wakeup_level_t; - -/** - * @brief Touch sensor shield channel drive capability level - * - */ -typedef enum { - TOUCH_SHIELD_CAP_40PF, /*!< The max equivalent capacitance in shield channel is 40pf */ - TOUCH_SHIELD_CAP_80PF, /*!< The max equivalent capacitance in shield channel is 80pf */ - TOUCH_SHIELD_CAP_120PF, /*!< The max equivalent capacitance in shield channel is 120pf */ - TOUCH_SHIELD_CAP_160PF, /*!< The max equivalent capacitance in shield channel is 160pf */ - TOUCH_SHIELD_CAP_200PF, /*!< The max equivalent capacitance in shield channel is 200pf */ - TOUCH_SHIELD_CAP_240PF, /*!< The max equivalent capacitance in shield channel is 240pf */ - TOUCH_SHIELD_CAP_280PF, /*!< The max equivalent capacitance in shield channel is 280pf */ - TOUCH_SHIELD_CAP_320PF, /*!< The max equivalent capacitance in shield channel is 320pf */ -} touch_chan_shield_cap_t; - -/** - * @brief Touch channel Infinite Impulse Response (IIR) filter or Jitter filter for benchmark - * @note Recommended filter coefficient selection is `IIR_16`. - */ -typedef enum { - TOUCH_BM_IIR_FILTER_4, /*!< IIR Filter for benchmark, 1/4 raw_value + 3/4 benchmark */ - TOUCH_BM_IIR_FILTER_8, /*!< IIR Filter for benchmark, 1/8 raw_value + 7/8 benchmark */ - TOUCH_BM_IIR_FILTER_16, /*!< IIR Filter for benchmark, 1/16 raw_value + 15/16 benchmark (typical) */ - TOUCH_BM_IIR_FILTER_32, /*!< IIR Filter for benchmark, 1/32 raw_value + 31/32 benchmark */ - TOUCH_BM_IIR_FILTER_64, /*!< IIR Filter for benchmark, 1/64 raw_value + 63/64 benchmark */ - TOUCH_BM_IIR_FILTER_128, /*!< IIR Filter for benchmark, 1/128 raw_value + 127/128 benchmark */ - TOUCH_BM_JITTER_FILTER, /*!< Jitter Filter for benchmark, raw value +/- jitter_step */ -} touch_benchmark_filter_mode_t; - -/** - * @brief Touch channel Infinite Impulse Response (IIR) filter for smooth data - * - */ -typedef enum { - TOUCH_SMOOTH_NO_FILTER, /*!< No filter adopted for smooth data, smooth data equals raw data */ - TOUCH_SMOOTH_IIR_FILTER_2, /*!< IIR filter adopted for smooth data, smooth data equals 1/2 raw data + 1/2 last smooth data (typical) */ - TOUCH_SMOOTH_IIR_FILTER_4, /*!< IIR filter adopted for smooth data, smooth data equals 1/4 raw data + 3/4 last smooth data */ - TOUCH_SMOOTH_IIR_FILTER_8, /*!< IIR filter adopted for smooth data, smooth data equals 1/8 raw data + 7/8 last smooth data */ -} touch_smooth_filter_mode_t; - -/** - * @brief Interrupt events - * - */ -typedef enum { - TOUCH_INTR_EVENT_ACTIVE, /*!< Touch channel active event */ - TOUCH_INTR_EVENT_INACTIVE, /*!< Touch channel inactive event */ - TOUCH_INTR_EVENT_MEASURE_DONE, /*!< Touch channel measure done event */ - TOUCH_INTR_EVENT_SCAN_DONE, /*!< All touch channels scan done event */ - TOUCH_INTR_EVENT_TIMEOUT, /*!< Touch channel measurement timeout event */ - TOUCH_INTR_EVENT_PROXIMITY_DONE, /*!< Proximity channel measurement done event */ -} touch_intr_event_t; - /** * @brief Sample configurations of the touch sensor * @@ -162,7 +111,7 @@ typedef struct { * of this sample configurations below. */ touch_out_mode_t output_mode; /*!< Touch channel counting mode of the binarized touch output */ - uint32_t sample_cfg_num; /*!< The sample configuration number that used for sampling */ + uint32_t sample_cfg_num; /*!< The sample configuration number that used for sampling, CANNOT exceed TOUCH_SAMPLE_CFG_NUM */ touch_sensor_sample_config_t *sample_cfg; /*!< The array of this sample configuration configurations, the length should be specified in `touch_sensor_config_t::sample_cfg_num` */ } touch_sensor_config_t; @@ -224,7 +173,7 @@ typedef struct { typedef touch_sensor_config_t touch_sensor_config_dslp_t; /** - * @brief Configure the touch sensor sleep function + * @brief Configuration of the touch sensor sleep function * */ typedef struct { @@ -248,7 +197,7 @@ typedef struct { } touch_sleep_config_t; /** - * @brief Configure the touch sensor waterproof function + * @brief Configuration of the touch sensor waterproof function * */ typedef struct { @@ -274,7 +223,7 @@ typedef struct { } touch_waterproof_config_t; /** - * @brief Configure the touch sensor proximity function + * @brief Configuration of the touch sensor proximity function * */ typedef struct { @@ -292,13 +241,13 @@ typedef struct { * @brief Base event structure used in touch event queue */ typedef struct { - touch_channel_handle_t chan; /*!< the current triggered touch channel handle */ - int chan_id; /*!< the current triggered touch channel number */ - uint32_t status_mask; /*!< the current channel triggered status. - * For the bits in the status mask, - * if the bit is set, the corresponding channel is active - * if the bit is cleared, the corresponding channel is inactive - */ + touch_channel_handle_t chan; /*!< the current triggered touch channel handle */ + int chan_id; /*!< the current triggered touch channel number */ + uint32_t status_mask; /*!< the current channel triggered status. + * For the bits in the status mask, + * if the bit is set, the corresponding channel is active + * if the bit is cleared, the corresponding channel is inactive + */ } touch_base_event_data_t; /** diff --git a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c index e9335d39652..a98c71d4fa8 100644 --- a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c +++ b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c @@ -44,10 +44,6 @@ void touch_priv_enable_module(bool enable) TOUCH_ENTER_CRITICAL(TOUCH_RTC_LOCK); touch_ll_enable_module_clock(enable); touch_ll_enable_out_gate(enable); -#if SOC_TOUCH_SENSOR_VERSION >= 2 - // Reset the benchmark after finished the scanning - touch_ll_reset_chan_benchmark(TOUCH_LL_FULL_CHANNEL_MASK); -#endif TOUCH_EXIT_CRITICAL(TOUCH_RTC_LOCK); } @@ -60,7 +56,7 @@ void IRAM_ATTR touch_priv_default_intr_handler(void *arg) bool need_yield = false; uint32_t status = touch_ll_get_intr_status_mask(); g_touch->is_meas_timeout = false; - touch_ll_intr_clear(status); + touch_ll_interrupt_clear(status); touch_base_event_data_t data; touch_ll_get_active_channel_mask(&data.status_mask); data.chan = g_touch->ch[touch_ll_get_current_meas_channel()]; @@ -253,7 +249,7 @@ esp_err_t touch_priv_channel_read_data(touch_channel_handle_t chan_handle, touch TOUCH_EXIT_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); } } else { - if (!chan_handle->is_prox_chan) { + if (!chan_handle->prox_id) { ESP_EARLY_LOGW(TAG, "This is not a proximity sensing channel"); } TOUCH_ENTER_CRITICAL_SAFE(TOUCH_PERIPH_LOCK); @@ -436,8 +432,8 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl /* Reset proximity sensing part of all channels */ FOR_EACH_TOUCH_CHANNEL(i) { - if (sens_handle->ch[i] && sens_handle->ch[i]->is_prox_chan) { - sens_handle->ch[i]->is_prox_chan = false; + if (sens_handle->ch[i] && sens_handle->ch[i]->prox_id > 0) { + sens_handle->ch[i]->prox_id = 0; sens_handle->ch[i]->prox_cnt = 0; for (int i = 0; i < TOUCH_SAMPLE_CFG_NUM; i++) { sens_handle->ch[i]->prox_val[i] = 0; @@ -450,7 +446,7 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl uint8_t sample_cfg_num = sens_handle->sample_cfg_num; for (int i = 0; i < TOUCH_PROXIMITY_CHAN_NUM; i++) { if (prox_cfg->proximity_chan[i]) { - prox_cfg->proximity_chan[i]->is_prox_chan = true; + prox_cfg->proximity_chan[i]->prox_id = i + 1; touch_ll_set_proximity_sensing_channel(i, prox_cfg->proximity_chan[i]->id); } else { touch_ll_set_proximity_sensing_channel(i, TOUCH_LL_NULL_CHANNEL); diff --git a/components/esp_driver_touch_sens/include/driver/touch_sens.h b/components/esp_driver_touch_sens/include/driver/touch_sens.h index cba510baef9..c1e22d57137 100644 --- a/components/esp_driver_touch_sens/include/driver/touch_sens.h +++ b/components/esp_driver_touch_sens/include/driver/touch_sens.h @@ -61,6 +61,8 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i /** * @brief Delete the touch channel * @note This function can be called when the touch sensor controller is NOT enabled (i.e. INIT state). + * @note If the channel has been enabled other sub-features like proximity sensing, sleep wakeup, waterproof, denoise. + * The attached sub-features will be disabled while deleting the channel. * * @param[in] chan_handle Touch channel handle * @return @@ -289,6 +291,24 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, const touch_sleep_config_t *sleep_cfg); #endif +#if SOC_TOUCH_SUPPORT_DENOISE_CHAN +/** + * @brief Configure the touch denoise channel + * @note The denoise channel is used to suppress the internal background noise. + * Once the denoise channel enabled, the measured data of the other touch channels + * will minus the data of the denoise channel automatically. + * So the channel data will be attenuated after enabling the denoise channel. + * + * @param[in] sens_handle Touch sensor controller handle + * @param[in] denoise_cfg Denoise channel configurations, set NULL to disable the touch channel + * @return + * - ESP_OK: Configure the denoise channel success + * - ESP_ERR_INVALID_ARG: The sensor handle is NULL or invalid denoise configuration + * - ESP_ERR_INVALID_STATE: The touch sensor is enabled + */ +esp_err_t touch_sensor_config_denoise_channel(touch_sensor_handle_t sens_handle, const touch_denoise_chan_config_t *denoise_cfg); +#endif + #ifdef __cplusplus } #endif diff --git a/components/esp_driver_touch_sens/include/driver/touch_sens_types.h b/components/esp_driver_touch_sens/include/driver/touch_sens_types.h index 3b802cc6ccd..d9fa24512c3 100644 --- a/components/esp_driver_touch_sens/include/driver/touch_sens_types.h +++ b/components/esp_driver_touch_sens/include/driver/touch_sens_types.h @@ -10,7 +10,7 @@ #include #include #include "soc/soc_caps.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sens_types.h" #ifdef __cplusplus extern "C" { @@ -22,6 +22,71 @@ extern "C" { #define TOUCH_PROXIMITY_CHAN_NUM SOC_TOUCH_PROXIMITY_CHANNEL_NUM /*!< The supported proximity channel number in proximity sensing mode */ #endif +/** + * @brief The chip sleep level that allows the touch sensor to wake-up + * + */ +typedef enum { + TOUCH_LIGHT_SLEEP_WAKEUP, /*!< Only enable the touch sensor to wake up the chip from light sleep */ + TOUCH_DEEP_SLEEP_WAKEUP, /*!< Enable the touch sensor to wake up the chip from deep sleep or light sleep */ +} touch_sleep_wakeup_level_t; + +/** + * @brief Touch sensor shield channel drive capability level + * + */ +typedef enum { + TOUCH_SHIELD_CAP_40PF, /*!< The max equivalent capacitance in shield channel is 40pf */ + TOUCH_SHIELD_CAP_80PF, /*!< The max equivalent capacitance in shield channel is 80pf */ + TOUCH_SHIELD_CAP_120PF, /*!< The max equivalent capacitance in shield channel is 120pf */ + TOUCH_SHIELD_CAP_160PF, /*!< The max equivalent capacitance in shield channel is 160pf */ + TOUCH_SHIELD_CAP_200PF, /*!< The max equivalent capacitance in shield channel is 200pf */ + TOUCH_SHIELD_CAP_240PF, /*!< The max equivalent capacitance in shield channel is 240pf */ + TOUCH_SHIELD_CAP_280PF, /*!< The max equivalent capacitance in shield channel is 280pf */ + TOUCH_SHIELD_CAP_320PF, /*!< The max equivalent capacitance in shield channel is 320pf */ +} touch_chan_shield_cap_t; + +/** + * @brief Touch channel Infinite Impulse Response (IIR) filter or Jitter filter for benchmark + * @note Recommended filter coefficient selection is `IIR_16`. + */ +typedef enum { + TOUCH_BM_IIR_FILTER_4, /*!< IIR Filter for benchmark, 1/4 raw_value + 3/4 benchmark */ + TOUCH_BM_IIR_FILTER_8, /*!< IIR Filter for benchmark, 1/8 raw_value + 7/8 benchmark */ + TOUCH_BM_IIR_FILTER_16, /*!< IIR Filter for benchmark, 1/16 raw_value + 15/16 benchmark (typical) */ + TOUCH_BM_IIR_FILTER_32, /*!< IIR Filter for benchmark, 1/32 raw_value + 31/32 benchmark */ + TOUCH_BM_IIR_FILTER_64, /*!< IIR Filter for benchmark, 1/64 raw_value + 63/64 benchmark */ + TOUCH_BM_IIR_FILTER_128, /*!< IIR Filter for benchmark, 1/128 raw_value + 127/128 benchmark */ +#if SOC_TOUCH_SENSOR_VERSION == 2 + TOUCH_BM_IIR_FILTER_256, /*!< IIR Filter for benchmark, 1/256 raw_value + 255/256 benchmark */ +#endif + TOUCH_BM_JITTER_FILTER, /*!< Jitter Filter for benchmark, raw value +/- jitter_step */ +} touch_benchmark_filter_mode_t; + +/** + * @brief Touch channel Infinite Impulse Response (IIR) filter for smooth data + * + */ +typedef enum { + TOUCH_SMOOTH_NO_FILTER, /*!< No filter adopted for smooth data, smooth data equals raw data */ + TOUCH_SMOOTH_IIR_FILTER_2, /*!< IIR filter adopted for smooth data, smooth data equals 1/2 raw data + 1/2 last smooth data (typical) */ + TOUCH_SMOOTH_IIR_FILTER_4, /*!< IIR filter adopted for smooth data, smooth data equals 1/4 raw data + 3/4 last smooth data */ + TOUCH_SMOOTH_IIR_FILTER_8, /*!< IIR filter adopted for smooth data, smooth data equals 1/8 raw data + 7/8 last smooth data */ +} touch_smooth_filter_mode_t; + +/** + * @brief Interrupt events + * + */ +typedef enum { + TOUCH_INTR_EVENT_ACTIVE, /*!< Touch channel active event */ + TOUCH_INTR_EVENT_INACTIVE, /*!< Touch channel inactive event */ + TOUCH_INTR_EVENT_MEASURE_DONE, /*!< Touch channel measure done event */ + TOUCH_INTR_EVENT_SCAN_DONE, /*!< All touch channels scan done event */ + TOUCH_INTR_EVENT_TIMEOUT, /*!< Touch channel measurement timeout event */ + TOUCH_INTR_EVENT_PROXIMITY_DONE, /*!< Proximity channel measurement done event */ +} touch_intr_event_t; + typedef struct touch_sensor_s *touch_sensor_handle_t; /*!< The handle of touch sensor controller */ typedef struct touch_channel_s *touch_channel_handle_t; /*!< The handle of touch channel */ diff --git a/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h b/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h new file mode 100644 index 00000000000..9760ae187ea --- /dev/null +++ b/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include +#include "esp_err.h" +#include "driver/touch_sens_types.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @brief Touch channel information + * + */ +typedef struct { + int chan_id; /*!< Touch channel number */ + int chan_gpio; /*!< Corresponding GPIO of this channel */ + struct { + uint32_t is_dp_slp: 1; /*!< Whether this channel can wakeup from deep sleep */ + uint32_t is_proxi: 1; /*!< Whether this channel is used for proximity sensing */ + uint32_t is_guard: 1; /*!< Whether this channel is used for waterproof guard channel */ + uint32_t is_shield: 1; /*!< Whether this channel is used for waterproof shield channel */ + } flags; /*!< Channel sub-feature flags */ +} touch_chan_info_t; + +/** + * @brief Get the touch channel information by the channel handle + * + * @param[in] chan_handle Touch channel handle + * @param[out] chan_info Touch channel information + * @return + * - ESP_OK: Success to get the channel information + * - ESP_ERR_INVALID_ARG: NULL pointer + */ +esp_err_t touch_sensor_get_channel_info(touch_channel_handle_t chan_handle, touch_chan_info_t *chan_info); + +#ifdef __cplusplus +} +#endif diff --git a/components/esp_driver_touch_sens/test_apps/.build-test-rules.yml b/components/esp_driver_touch_sens/test_apps/.build-test-rules.yml index 16e6ca03696..142c609d4bc 100644 --- a/components/esp_driver_touch_sens/test_apps/.build-test-rules.yml +++ b/components/esp_driver_touch_sens/test_apps/.build-test-rules.yml @@ -1,6 +1,8 @@ components/esp_driver_touch_sens/test_apps/touch_sens: disable: - - if: SOC_TOUCH_SENSOR_VERSION != 3 - temporary: currently driver ng only support version 3 + - if: SOC_TOUCH_SENSOR_SUPPORTED != 1 + - if: SOC_TOUCH_SENSOR_VERSION == 1 + temporary: true + reason: currently driver ng does not support version 1 depends_components: - esp_driver_touch_sens diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/README.md b/components/esp_driver_touch_sens/test_apps/touch_sens/README.md index f8ea707124d..9b5055b84a8 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/README.md +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/README.md @@ -1,3 +1,3 @@ -| Supported Targets | ESP32-P4 | -| ----------------- | -------- | +| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | -------- | -------- | -------- | diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c index 226b8549fa2..9cb166c502a 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c @@ -10,29 +10,36 @@ #include "unity.h" #include "driver/touch_sens.h" #include "hal/touch_sensor_ll.h" +#include "esp_private/touch_sens_helper.h" #include "esp_log.h" #include "esp_attr.h" static touch_sensor_sample_config_t s_sample_cfg[TOUCH_SAMPLE_CFG_NUM] = { +#if SOC_TOUCH_SENSOR_VERSION == 2 + TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(500, TOUCH_VOLT_LIM_L_0V5, TOUCH_VOLT_LIM_H_2V2), +#elif SOC_TOUCH_SENSOR_VERSION == 3 TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(1, 1, 1), -#if TOUCH_SAMPLE_CFG_NUM > 1 TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(2, 1, 1), -#endif -#if TOUCH_SAMPLE_CFG_NUM > 2 TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(4, 1, 1), +#else +#error "Target not support" #endif }; static touch_channel_config_t s_chan_cfg = { +#if SOC_TOUCH_SENSOR_VERSION == 2 + .active_thresh = { + 2000, + }, + .charge_speed = TOUCH_CHARGE_SPEED_7, + .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, +#elif SOC_TOUCH_SENSOR_VERSION == 3 .active_thresh = { 5000, -#if TOUCH_SAMPLE_CFG_NUM > 1 2500, -#endif -#if TOUCH_SAMPLE_CFG_NUM > 2 1000, -#endif }, +#endif }; TEST_CASE("touch_sens_install_uninstall_test", "[touch]") @@ -119,7 +126,13 @@ static bool TEST_TCH_IRAM_ATTR s_test_touch_on_inactive_callback(touch_sensor_ha static void s_test_touch_simulate_touch(touch_sensor_handle_t touch, touch_channel_handle_t touch_chan, bool active) { +#if SOC_TOUCH_SENSOR_VERSION == 2 + touch_chan_info_t chan_info = {}; + touch_sensor_get_channel_info(touch_chan, &chan_info); + touch_ll_set_charge_speed(chan_info.chan_id, active ? TOUCH_CHARGE_SPEED_4 : TOUCH_CHARGE_SPEED_7); +#elif SOC_TOUCH_SENSOR_VERSION == 3 touch_ll_set_internal_capacitor(active ? 0x7f : 0); +#endif } static void s_test_touch_log_data(touch_channel_handle_t touch_chan, uint32_t sample_cfg_num, const char *tag) @@ -146,15 +159,21 @@ TEST_CASE("touch_sens_active_inactive_test", "[touch]") /* Configuring the filter */ touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG(); TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg)); - TEST_ESP_OK(touch_sensor_new_channel(touch, 0, &s_chan_cfg, &touch_chan)); + TEST_ESP_OK(touch_sensor_new_channel(touch, 1, &s_chan_cfg, &touch_chan)); +#if SOC_TOUCH_SENSOR_VERSION == 3 /* Connect the touch channels to the internal capacitor */ touch_ll_enable_internal_capacitor(true); +#endif // SOC_TOUCH_SENSOR_VERSION == 3 s_test_touch_do_initial_scanning(touch, 3); /* Read benchmark */ uint32_t benchmark[TOUCH_SAMPLE_CFG_NUM] = {0}; TEST_ESP_OK(touch_channel_read_data(touch_chan, TOUCH_CHAN_DATA_TYPE_BENCHMARK, benchmark)); + /* Test whether success to finish the initial scanning */ + for (int i = 0; i < TOUCH_SAMPLE_CFG_NUM; i++) { + TEST_ASSERT_GREATER_THAN(0, benchmark[i]); + } /* Re-configure the threshold according to the benchmark */ touch_channel_config_t chan_cfg = s_test_get_chan_cfg_by_benchmark(benchmark, TOUCH_SAMPLE_CFG_NUM, TEST_ACTIVE_THRESH_RATIO); TEST_ESP_OK(touch_sensor_reconfig_channel(touch_chan, &chan_cfg)); diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/pytest_touch_sens.py b/components/esp_driver_touch_sens/test_apps/touch_sens/pytest_touch_sens.py index 871cdb6baf0..c1205a91175 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/pytest_touch_sens.py +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/pytest_touch_sens.py @@ -4,8 +4,9 @@ from pytest_embedded import Dut +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 @pytest.mark.esp32p4 -@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='esp32p4 runners do not support touch pins') @pytest.mark.generic @pytest.mark.parametrize( 'config', diff --git a/components/esp_hw_support/sleep_modes.c b/components/esp_hw_support/sleep_modes.c index 5bd82fdd367..108a05c568e 100644 --- a/components/esp_hw_support/sleep_modes.c +++ b/components/esp_hw_support/sleep_modes.c @@ -62,6 +62,7 @@ #include "hal/uart_hal.h" #if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sensor_hal.h" +#include "hal/touch_sens_hal.h" #endif #if CONFIG_SPIRAM && CONFIG_ESP_LDO_RESERVE_PSRAM @@ -301,7 +302,7 @@ static void ext0_wakeup_prepare(void); static void ext1_wakeup_prepare(void); #endif static esp_err_t timer_wakeup_prepare(int64_t sleep_duration); -#if SOC_TOUCH_SENSOR_SUPPORTED && SOC_TOUCH_SENSOR_VERSION != 1 +#if SOC_TOUCH_SENSOR_VERSION >= 2 static void touch_wakeup_prepare(void); #endif #if SOC_GPIO_SUPPORT_DEEPSLEEP_WAKEUP && SOC_DEEP_SLEEP_SUPPORTED @@ -881,11 +882,7 @@ static esp_err_t IRAM_ATTR esp_sleep_start(uint32_t pd_flags, esp_sleep_mode_t m /* In light sleep, the RTC_PERIPH power domain should be in the power-on state (Power on the touch circuit in light sleep), * otherwise the touch sensor FSM will be cleared, causing touch sensor false triggering. */ -#if SOC_TOUCH_SENSOR_VERSION == 3 bool keep_rtc_power_on = touch_ll_is_fsm_repeated_timer_enabled(); -#else - bool keep_rtc_power_on = touch_ll_get_fsm_state(); -#endif if (keep_rtc_power_on) { // Check if the touch sensor is working properly. pd_flags &= ~RTC_SLEEP_PD_RTC_PERIPH; } @@ -1711,26 +1708,7 @@ static esp_err_t timer_wakeup_prepare(int64_t sleep_duration) return ESP_OK; } -#if SOC_TOUCH_SENSOR_VERSION == 2 -/* In deep sleep mode, only the sleep channel is supported, and other touch channels should be turned off. */ -static void touch_wakeup_prepare(void) -{ - uint16_t sleep_cycle = 0; - uint16_t meas_times = 0; - touch_pad_t touch_num = TOUCH_PAD_NUM0; - touch_ll_sleep_get_channel_num(&touch_num); // Check if the sleep pad is enabled. - if ((touch_num > TOUCH_PAD_NUM0) && (touch_num < TOUCH_PAD_MAX) && touch_ll_get_fsm_state()) { - touch_ll_stop_fsm(); - touch_ll_clear_channel_mask(TOUCH_PAD_BIT_MASK_ALL); - touch_ll_intr_clear(TOUCH_PAD_INTR_MASK_ALL); // Clear state from previous wakeup - touch_hal_sleep_channel_get_work_time(&sleep_cycle, &meas_times); - touch_ll_set_meas_times(meas_times); - touch_ll_set_sleep_time(sleep_cycle); - touch_ll_set_channel_mask(BIT(touch_num)); - touch_ll_start_fsm(); - } -} -#elif SOC_TOUCH_SENSOR_VERSION == 3 +#if SOC_TOUCH_SENSOR_VERSION >= 2 static void touch_wakeup_prepare(void) { touch_hal_prepare_deep_sleep(); From c007ec5f179811a9c695b545e5a301754aadcd6f Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Thu, 17 Oct 2024 18:23:22 +0800 Subject: [PATCH 33/70] feat(touch): update doc and example for touch version 2 --- .../touch_sensor_v1/main/test_touch_v1.c | 2 +- .../esp32/include/driver/touch_sensor.h | 378 ++++++++++++++++- .../include/driver/touch_sensor_legacy.h | 385 ------------------ .../driver/touch_sensor/esp32/touch_sensor.c | 2 +- .../touch_sensor/esp32s2/touch_sensor.c | 8 +- .../touch_sensor/esp32s3/touch_sensor.c | 8 +- .../include/driver/touch_sensor_common.h | 2 +- .../driver/touch_sensor/touch_sensor_common.c | 2 +- .../common/touch_sens_common.c | 43 +- .../common/touch_sens_private.h | 12 +- .../include/driver/touch_version_types.h | 10 +- .../hw_ver2/touch_version_specific.c | 23 +- .../include/driver/touch_version_types.h | 4 +- .../hw_ver3/touch_version_specific.c | 17 +- .../include/driver/touch_sens_types.h | 56 --- .../include/esp_private/touch_sens_helper.h | 2 +- .../touch_sens/main/test_touch_sens_common.c | 10 +- components/esp_hw_support/include/esp_sleep.h | 2 +- .../hal/esp32/include/hal/touch_sensor_hal.h | 2 +- .../hal/esp32/include/hal/touch_sensor_ll.h | 2 +- components/hal/esp32/touch_sensor_hal.c | 2 +- .../hal/esp32p4/include/hal/touch_sensor_ll.h | 31 +- .../esp32s2/include/hal/touch_sensor_hal.h | 2 +- .../hal/esp32s2/include/hal/touch_sensor_ll.h | 65 ++- components/hal/esp32s2/touch_sensor_hal.c | 2 +- .../esp32s3/include/hal/touch_sensor_hal.h | 2 +- .../hal/esp32s3/include/hal/touch_sensor_ll.h | 65 ++- components/hal/esp32s3/touch_sensor_hal.c | 2 +- components/hal/include/hal/touch_sens_hal.h | 44 +- components/hal/include/hal/touch_sens_types.h | 92 +++-- components/hal/include/hal/touch_sensor_hal.h | 4 +- ...or_types.h => touch_sensor_legacy_types.h} | 0 components/hal/touch_sens_hal.c | 4 +- components/hal/touch_sensor_hal.c | 2 +- .../soc/esp32s3/register/soc/rtc_cntl_reg.h | 10 +- .../include/ulp_riscv_touch_ulp_core.h | 2 +- docs/conf_common.py | 4 +- docs/docs_not_updated/esp32p4.txt | 2 - docs/doxygen/Doxyfile | 1 - docs/doxygen/Doxyfile_esp32 | 1 + docs/doxygen/Doxyfile_esp32s2 | 5 +- docs/doxygen/Doxyfile_esp32s3 | 5 +- .../peripherals/cap_touch_sens.rst | 102 ++--- .../peripherals/cap_touch_sens/esp32p4.inc | 64 +++ .../peripherals/cap_touch_sens/esp32s2.inc | 64 +++ .../peripherals/cap_touch_sens/esp32s3.inc | 64 +++ docs/en/api-reference/peripherals/index.rst | 4 +- .../peripherals/touch_element.rst | 6 +- .../api-reference/peripherals/touch_pad.rst | 16 +- .../peripherals/cap_touch_sens.rst | 112 +++-- .../peripherals/cap_touch_sens/esp32p4.inc | 64 +++ .../peripherals/cap_touch_sens/esp32s2.inc | 64 +++ .../peripherals/cap_touch_sens/esp32s3.inc | 64 +++ .../zh_CN/api-reference/peripherals/index.rst | 4 +- .../peripherals/touch_element.rst | 6 +- .../api-reference/peripherals/touch_pad.rst | 16 +- examples/peripherals/.build-test-rules.yml | 21 +- .../CMakeLists.txt | 0 .../README.md | 4 +- .../main/CMakeLists.txt | 2 +- .../main/touch_sens_basic_example_main.c} | 77 ++-- .../main/touch_sens_example_config.h | 54 +++ .../pytest_touch_sens_basic.py} | 3 +- .../touch_pad_interrupt/CMakeLists.txt | 6 - .../touch_pad_interrupt/README.md | 60 --- .../touch_pad_interrupt/main/CMakeLists.txt | 2 - .../main/tp_interrupt_main.c | 211 ---------- .../pytest_touch_pad_interrupt_v2.py | 15 - .../touch_pad_read/CMakeLists.txt | 6 - .../touch_sensor_v2/touch_pad_read/README.md | 50 --- .../touch_pad_read/main/CMakeLists.txt | 2 - .../touch_pad_read/main/tp_read_main.c | 90 ---- .../pytest_touch_pad_read_v2.py | 13 - .../system/deep_sleep/main/Kconfig.projbuild | 2 +- .../system/deep_sleep/main/touch_wakeup.c | 2 +- examples/system/deep_sleep/sdkconfig.defaults | 1 + .../touch/main/ulp_riscv_touch_example_main.c | 2 +- .../ulp/ulp_riscv/touch/sdkconfig.defaults | 1 + 78 files changed, 1307 insertions(+), 1284 deletions(-) delete mode 100644 components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h rename components/hal/include/hal/{touch_sensor_types.h => touch_sensor_legacy_types.h} (100%) create mode 100644 docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc create mode 100644 docs/en/api-reference/peripherals/cap_touch_sens/esp32s2.inc create mode 100644 docs/en/api-reference/peripherals/cap_touch_sens/esp32s3.inc create mode 100644 docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc create mode 100644 docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s2.inc create mode 100644 docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s3.inc rename examples/peripherals/touch_sensor/{touch_sensor_v3 => touch_sens_basic}/CMakeLists.txt (100%) rename examples/peripherals/touch_sensor/{touch_sensor_v3 => touch_sens_basic}/README.md (97%) rename examples/peripherals/touch_sensor/{touch_sensor_v3 => touch_sens_basic}/main/CMakeLists.txt (58%) rename examples/peripherals/touch_sensor/{touch_sensor_v3/main/touch_sens_v3_example_main.c => touch_sens_basic/main/touch_sens_basic_example_main.c} (71%) create mode 100644 examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_example_config.h rename examples/peripherals/touch_sensor/{touch_sensor_v3/pytest_touch_sens_v3.py => touch_sens_basic/pytest_touch_sens_basic.py} (82%) delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/CMakeLists.txt delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/README.md delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/CMakeLists.txt delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/tp_interrupt_main.c delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/pytest_touch_pad_interrupt_v2.py delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/CMakeLists.txt delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/README.md delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/CMakeLists.txt delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c delete mode 100644 examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/pytest_touch_pad_read_v2.py diff --git a/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c b/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c index 2580ed1d0cd..45bd9c3750f 100644 --- a/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c +++ b/components/driver/test_apps/touch_sensor_v1/main/test_touch_v1.c @@ -22,7 +22,7 @@ #include "soc/rtc_cntl_struct.h" #include "soc/rtc_io_reg.h" #include "soc/rtc_io_struct.h" -#include "driver/touch_sensor_legacy.h" +#include "driver/touch_sensor.h" #include "esp_rom_sys.h" #if CONFIG_PM_ENABLE #include "esp_pm.h" diff --git a/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h b/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h index c6204a6d6de..c1a6f759f27 100644 --- a/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h +++ b/components/driver/touch_sensor/esp32/include/driver/touch_sensor.h @@ -6,6 +6,380 @@ #pragma once -#include "driver/touch_sensor_legacy.h" +#ifdef __cplusplus +extern "C" { +#endif -// Keep for compatibility +#include "driver/touch_sensor_common.h" + +/** + * @brief Configure touch pad interrupt threshold. + * + * @note If FSM mode is set to TOUCH_FSM_MODE_TIMER, this function will be blocked for one measurement cycle and wait for data to be valid. + * + * @param touch_num touch pad index + * @param threshold interrupt threshold, + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG if argument wrong + * - ESP_FAIL if touch pad not initialized + */ +esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold); + +/** + * @brief get touch sensor counter value. + * Each touch sensor has a counter to count the number of charge/discharge cycles. + * When the pad is not 'touched', we can get a number of the counter. + * When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance. + * + * @note This API requests hardware measurement once. If IIR filter mode is enabled, + * please use 'touch_pad_read_raw_data' interface instead. + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief get filtered touch sensor counter value by IIR filter. + * + * @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered. + * This function can be called from ISR + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief get raw data (touch sensor counter value) from IIR filter process. + * Need not request hardware measurements. + * + * @note touch_pad_filter_start has to be called before calling touch_pad_read_raw_data. + * This function can be called from ISR + * + * @param touch_num touch pad index + * @param touch_value pointer to accept touch sensor value + * + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG Touch pad parameter error + * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. + * - ESP_FAIL Touch pad not initialized + */ +esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint16_t *touch_value); + +/** + * @brief Callback function that is called after each IIR filter calculation. + * @note This callback is called in timer task in each filtering cycle. + * @note This callback should not be blocked. + * @param raw_value The latest raw data(touch sensor counter value) that + * points to all channels(raw_value[0..TOUCH_PAD_MAX-1]). + * @param filtered_value The latest IIR filtered data(calculated from raw data) that + * points to all channels(filtered_value[0..TOUCH_PAD_MAX-1]). + * + */ +typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value); + +/** + * @brief Register the callback function that is called after each IIR filter calculation. + * @note The 'read_cb' callback is called in timer task in each filtering cycle. + * @param read_cb Pointer to filtered callback function. + * If the argument passed in is NULL, the callback will stop. + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG set error + */ +esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb); + +/** + * @brief Register touch-pad ISR. + * The handler will be attached to the same CPU core that this function is running on. + * @param fn Pointer to ISR handler + * @param arg Parameter for ISR + * @return + * - ESP_OK Success ; + * - ESP_ERR_INVALID_ARG GPIO error + * - ESP_ERR_NO_MEM No memory + */ +esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg); + +/** + * @brief Set the clock cycles of each measurement + * @note This function will specify the clock cycles of each measurement + * and the clock is sourced from SOC_MOD_CLK_RTC_FAST, its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX + * The touch sensor will record the charge and discharge times during these clock cycles as the final result (raw value) + * @note If clock cycles is too small, it may lead to inaccurate results. + * + * @param clock_cycle The clock cycles of each measurement + * measure_time = clock_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX + * @return + * - ESP_OK Set the clock cycle success + */ +esp_err_t touch_pad_set_measurement_clock_cycles(uint16_t clock_cycle); + +/** + * @brief Get the clock cycles of each measurement + * + * @param clock_cycle The clock cycles of each measurement + * @return + * - ESP_OK Get the clock cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_clock_cycles(uint16_t *clock_cycle); + +/** + * @brief Set the interval between two measurements + * @note The touch sensor will sleep between two measurements + * This function is to set the interval cycle + * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX + * + * @param interval_cycle The interval between two measurements + * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @return + * - ESP_OK Set interval cycle success + */ +esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); + +/** + * @brief Get the interval between two measurements + * + * @param interval_cycle The interval between two measurements + * @return + * - ESP_OK Get interval cycle success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); + +/** + * @brief Set touch sensor measurement and sleep time. + * Excessive total time will slow down the touch response. + * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. + * @note The touch sensor will count the number of charge/discharge cycles over a fixed period of time (specified as the second parameter). + * That means the number of cycles (raw value) will decrease as the capacity of the touch pad is increasing. + * @note The greater the duty cycle of the measurement time, the more system power is consumed. + * + * @param sleep_cycle The touch sensor will sleep after each measurement. + * sleep_cycle decide the interval between each measurement. + * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. + * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. + * @param meas_cycle The duration of the touch sensor measurement. + * t_meas = meas_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle) +__attribute__((deprecated("please use 'touch_pad_set_measurement_clock_cycles' and 'touch_pad_set_measurement_interval' instead"))); + +/** + * @brief Get touch sensor measurement and sleep time + * @param sleep_cycle Pointer to accept sleep cycle number + * @param meas_cycle Pointer to accept measurement cycle count. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG The input parameter is NULL + */ +esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle) +__attribute__((deprecated("please use 'touch_pad_get_measurement_clock_cycles' and 'touch_pad_get_measurement_interval' instead"))); + +/** + * @brief Trigger a touch sensor measurement, only support in SW mode of FSM + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_sw_start(void); + +/** + * @brief Set touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode. + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold); + +/** + * @brief Get touch sensor interrupt threshold + * @param touch_num touch pad index + * @param threshold pointer to accept threshold + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold); + +/** + * @brief Set touch sensor interrupt trigger mode. + * Interrupt can be triggered either when counter result is less than + * threshold or when counter result is more than threshold. + * @param mode touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode); + +/** + * @brief Get touch sensor interrupt trigger mode + * @param mode pointer to accept touch sensor interrupt trigger mode + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode); + +/** + * @brief Set touch sensor interrupt trigger source. There are two sets of touch signals. + * Set1 and set2 can be mapped to several touch signals. Either set will be triggered + * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated + * if set1 is triggered, or only if both sets are triggered. + * @param src touch sensor interrupt trigger source + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src); + +/** + * @brief Get touch sensor interrupt trigger source + * @param src pointer to accept touch sensor interrupt trigger source + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src); + +/** + * @brief Set touch sensor group mask. + * Touch pad module has two sets of signals, 'Touched' signal is triggered only if + * at least one of touch pad in this group is "touched". + * This function will set the register bits according to the given bitmask. + * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief Get touch sensor group mask. + * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value + * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value + * @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask); + +/** + * @brief Clear touch sensor group mask. + * Touch pad module has two sets of signals, Interrupt is triggered only if + * at least one of touch pad in this group is "touched". + * This function will clear the register bits according to the given bitmask. + * @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value + * @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value + * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value + * @return + * - ESP_OK on success + * - ESP_ERR_INVALID_ARG if argument is wrong + */ +esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); + +/** + * @brief To enable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_enable(void); + +/** + * @brief To disable touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_disable(void); + +/** + * @brief To clear touch pad interrupt + * @return + * - ESP_OK on success + */ +esp_err_t touch_pad_intr_clear(void); + +/** + * @brief set touch pad filter calibration period, in ms. + * Need to call touch_pad_filter_start before all touch filter APIs + * @param new_period_ms filter period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms); + +/** + * @brief get touch pad filter calibration period, in ms + * Need to call touch_pad_filter_start before all touch filter APIs + * @param p_period_ms pointer to accept period + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + * - ESP_ERR_INVALID_ARG parameter error + */ +esp_err_t touch_pad_get_filter_period(uint32_t *p_period_ms); + +/** + * @brief start touch pad filter function + * This API will start a filter to process the noise in order to prevent false triggering + * when detecting slight change of capacitance. + * Need to call touch_pad_filter_start before all touch filter APIs + * + * @note This filter uses FreeRTOS timer, which is dispatched from a task with + * priority 1 by default on CPU 0. So if some application task with higher priority + * takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected. + * You can adjust FreeRTOS timer task priority in menuconfig. + * @param filter_period_ms filter calibration period, in ms + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_ARG parameter error + * - ESP_ERR_NO_MEM No memory for driver + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); + +/** + * @brief stop touch pad filter function + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_stop(void); + +/** + * @brief delete touch pad filter driver and release the memory + * Need to call touch_pad_filter_start before all touch filter APIs + * @return + * - ESP_OK Success + * - ESP_ERR_INVALID_STATE driver state error + */ +esp_err_t touch_pad_filter_delete(void); + +#ifdef __cplusplus +} +#endif diff --git a/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h b/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h deleted file mode 100644 index c1a6f759f27..00000000000 --- a/components/driver/touch_sensor/esp32/include/driver/touch_sensor_legacy.h +++ /dev/null @@ -1,385 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -#include "driver/touch_sensor_common.h" - -/** - * @brief Configure touch pad interrupt threshold. - * - * @note If FSM mode is set to TOUCH_FSM_MODE_TIMER, this function will be blocked for one measurement cycle and wait for data to be valid. - * - * @param touch_num touch pad index - * @param threshold interrupt threshold, - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG if argument wrong - * - ESP_FAIL if touch pad not initialized - */ -esp_err_t touch_pad_config(touch_pad_t touch_num, uint16_t threshold); - -/** - * @brief get touch sensor counter value. - * Each touch sensor has a counter to count the number of charge/discharge cycles. - * When the pad is not 'touched', we can get a number of the counter. - * When the pad is 'touched', the value in counter will get smaller because of the larger equivalent capacitance. - * - * @note This API requests hardware measurement once. If IIR filter mode is enabled, - * please use 'touch_pad_read_raw_data' interface instead. - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief get filtered touch sensor counter value by IIR filter. - * - * @note touch_pad_filter_start has to be called before calling touch_pad_read_filtered. - * This function can be called from ISR - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read_filtered(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief get raw data (touch sensor counter value) from IIR filter process. - * Need not request hardware measurements. - * - * @note touch_pad_filter_start has to be called before calling touch_pad_read_raw_data. - * This function can be called from ISR - * - * @param touch_num touch pad index - * @param touch_value pointer to accept touch sensor value - * - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG Touch pad parameter error - * - ESP_ERR_INVALID_STATE This touch pad hardware connection is error, the value of "touch_value" is 0. - * - ESP_FAIL Touch pad not initialized - */ -esp_err_t touch_pad_read_raw_data(touch_pad_t touch_num, uint16_t *touch_value); - -/** - * @brief Callback function that is called after each IIR filter calculation. - * @note This callback is called in timer task in each filtering cycle. - * @note This callback should not be blocked. - * @param raw_value The latest raw data(touch sensor counter value) that - * points to all channels(raw_value[0..TOUCH_PAD_MAX-1]). - * @param filtered_value The latest IIR filtered data(calculated from raw data) that - * points to all channels(filtered_value[0..TOUCH_PAD_MAX-1]). - * - */ -typedef void (* filter_cb_t)(uint16_t *raw_value, uint16_t *filtered_value); - -/** - * @brief Register the callback function that is called after each IIR filter calculation. - * @note The 'read_cb' callback is called in timer task in each filtering cycle. - * @param read_cb Pointer to filtered callback function. - * If the argument passed in is NULL, the callback will stop. - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG set error - */ -esp_err_t touch_pad_set_filter_read_cb(filter_cb_t read_cb); - -/** - * @brief Register touch-pad ISR. - * The handler will be attached to the same CPU core that this function is running on. - * @param fn Pointer to ISR handler - * @param arg Parameter for ISR - * @return - * - ESP_OK Success ; - * - ESP_ERR_INVALID_ARG GPIO error - * - ESP_ERR_NO_MEM No memory - */ -esp_err_t touch_pad_isr_register(intr_handler_t fn, void *arg); - -/** - * @brief Set the clock cycles of each measurement - * @note This function will specify the clock cycles of each measurement - * and the clock is sourced from SOC_MOD_CLK_RTC_FAST, its default frequency is SOC_CLK_RC_FAST_FREQ_APPROX - * The touch sensor will record the charge and discharge times during these clock cycles as the final result (raw value) - * @note If clock cycles is too small, it may lead to inaccurate results. - * - * @param clock_cycle The clock cycles of each measurement - * measure_time = clock_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX - * @return - * - ESP_OK Set the clock cycle success - */ -esp_err_t touch_pad_set_measurement_clock_cycles(uint16_t clock_cycle); - -/** - * @brief Get the clock cycles of each measurement - * - * @param clock_cycle The clock cycles of each measurement - * @return - * - ESP_OK Get the clock cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_clock_cycles(uint16_t *clock_cycle); - -/** - * @brief Set the interval between two measurements - * @note The touch sensor will sleep between two measurements - * This function is to set the interval cycle - * And the interval is clocked from SOC_MOD_CLK_RTC_SLOW, its default frequency is SOC_CLK_RC_SLOW_FREQ_APPROX - * - * @param interval_cycle The interval between two measurements - * sleep_time = interval_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @return - * - ESP_OK Set interval cycle success - */ -esp_err_t touch_pad_set_measurement_interval(uint16_t interval_cycle); - -/** - * @brief Get the interval between two measurements - * - * @param interval_cycle The interval between two measurements - * @return - * - ESP_OK Get interval cycle success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_measurement_interval(uint16_t *interval_cycle); - -/** - * @brief Set touch sensor measurement and sleep time. - * Excessive total time will slow down the touch response. - * Too small measurement time will not be sampled enough, resulting in inaccurate measurements. - * @note The touch sensor will count the number of charge/discharge cycles over a fixed period of time (specified as the second parameter). - * That means the number of cycles (raw value) will decrease as the capacity of the touch pad is increasing. - * @note The greater the duty cycle of the measurement time, the more system power is consumed. - * - * @param sleep_cycle The touch sensor will sleep after each measurement. - * sleep_cycle decide the interval between each measurement. - * t_sleep = sleep_cycle / SOC_CLK_RC_SLOW_FREQ_APPROX. - * The approximate frequency value of RTC_SLOW_CLK can be obtained using rtc_clk_slow_freq_get_hz function. - * @param meas_cycle The duration of the touch sensor measurement. - * t_meas = meas_cycle / SOC_CLK_RC_FAST_FREQ_APPROX, the maximum measure time is 0xffff / SOC_CLK_RC_FAST_FREQ_APPROX - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_set_meas_time(uint16_t sleep_cycle, uint16_t meas_cycle) -__attribute__((deprecated("please use 'touch_pad_set_measurement_clock_cycles' and 'touch_pad_set_measurement_interval' instead"))); - -/** - * @brief Get touch sensor measurement and sleep time - * @param sleep_cycle Pointer to accept sleep cycle number - * @param meas_cycle Pointer to accept measurement cycle count. - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG The input parameter is NULL - */ -esp_err_t touch_pad_get_meas_time(uint16_t *sleep_cycle, uint16_t *meas_cycle) -__attribute__((deprecated("please use 'touch_pad_get_measurement_clock_cycles' and 'touch_pad_get_measurement_interval' instead"))); - -/** - * @brief Trigger a touch sensor measurement, only support in SW mode of FSM - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_sw_start(void); - -/** - * @brief Set touch sensor interrupt threshold - * @param touch_num touch pad index - * @param threshold threshold of touchpad count, refer to touch_pad_set_trigger_mode to see how to set trigger mode. - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_thresh(touch_pad_t touch_num, uint16_t threshold); - -/** - * @brief Get touch sensor interrupt threshold - * @param touch_num touch pad index - * @param threshold pointer to accept threshold - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_get_thresh(touch_pad_t touch_num, uint16_t *threshold); - -/** - * @brief Set touch sensor interrupt trigger mode. - * Interrupt can be triggered either when counter result is less than - * threshold or when counter result is more than threshold. - * @param mode touch sensor interrupt trigger mode - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_trigger_mode(touch_trigger_mode_t mode); - -/** - * @brief Get touch sensor interrupt trigger mode - * @param mode pointer to accept touch sensor interrupt trigger mode - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_trigger_mode(touch_trigger_mode_t *mode); - -/** - * @brief Set touch sensor interrupt trigger source. There are two sets of touch signals. - * Set1 and set2 can be mapped to several touch signals. Either set will be triggered - * if at least one of its touch signal is 'touched'. The interrupt can be configured to be generated - * if set1 is triggered, or only if both sets are triggered. - * @param src touch sensor interrupt trigger source - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_trigger_source(touch_trigger_src_t src); - -/** - * @brief Get touch sensor interrupt trigger source - * @param src pointer to accept touch sensor interrupt trigger source - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_trigger_source(touch_trigger_src_t *src); - -/** - * @brief Set touch sensor group mask. - * Touch pad module has two sets of signals, 'Touched' signal is triggered only if - * at least one of touch pad in this group is "touched". - * This function will set the register bits according to the given bitmask. - * @param set1_mask bitmask of touch sensor signal group1, it's a 10-bit value - * @param set2_mask bitmask of touch sensor signal group2, it's a 10-bit value - * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_set_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); - -/** - * @brief Get touch sensor group mask. - * @param set1_mask pointer to accept bitmask of touch sensor signal group1, it's a 10-bit value - * @param set2_mask pointer to accept bitmask of touch sensor signal group2, it's a 10-bit value - * @param en_mask pointer to accept bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_get_group_mask(uint16_t *set1_mask, uint16_t *set2_mask, uint16_t *en_mask); - -/** - * @brief Clear touch sensor group mask. - * Touch pad module has two sets of signals, Interrupt is triggered only if - * at least one of touch pad in this group is "touched". - * This function will clear the register bits according to the given bitmask. - * @param set1_mask bitmask touch sensor signal group1, it's a 10-bit value - * @param set2_mask bitmask touch sensor signal group2, it's a 10-bit value - * @param en_mask bitmask of touch sensor work enable, it's a 10-bit value - * @return - * - ESP_OK on success - * - ESP_ERR_INVALID_ARG if argument is wrong - */ -esp_err_t touch_pad_clear_group_mask(uint16_t set1_mask, uint16_t set2_mask, uint16_t en_mask); - -/** - * @brief To enable touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_enable(void); - -/** - * @brief To disable touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_disable(void); - -/** - * @brief To clear touch pad interrupt - * @return - * - ESP_OK on success - */ -esp_err_t touch_pad_intr_clear(void); - -/** - * @brief set touch pad filter calibration period, in ms. - * Need to call touch_pad_filter_start before all touch filter APIs - * @param new_period_ms filter period, in ms - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - * - ESP_ERR_INVALID_ARG parameter error - */ -esp_err_t touch_pad_set_filter_period(uint32_t new_period_ms); - -/** - * @brief get touch pad filter calibration period, in ms - * Need to call touch_pad_filter_start before all touch filter APIs - * @param p_period_ms pointer to accept period - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - * - ESP_ERR_INVALID_ARG parameter error - */ -esp_err_t touch_pad_get_filter_period(uint32_t *p_period_ms); - -/** - * @brief start touch pad filter function - * This API will start a filter to process the noise in order to prevent false triggering - * when detecting slight change of capacitance. - * Need to call touch_pad_filter_start before all touch filter APIs - * - * @note This filter uses FreeRTOS timer, which is dispatched from a task with - * priority 1 by default on CPU 0. So if some application task with higher priority - * takes a lot of CPU0 time, then the quality of data obtained from this filter will be affected. - * You can adjust FreeRTOS timer task priority in menuconfig. - * @param filter_period_ms filter calibration period, in ms - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_ARG parameter error - * - ESP_ERR_NO_MEM No memory for driver - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_start(uint32_t filter_period_ms); - -/** - * @brief stop touch pad filter function - * Need to call touch_pad_filter_start before all touch filter APIs - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_stop(void); - -/** - * @brief delete touch pad filter driver and release the memory - * Need to call touch_pad_filter_start before all touch filter APIs - * @return - * - ESP_OK Success - * - ESP_ERR_INVALID_STATE driver state error - */ -esp_err_t touch_pad_filter_delete(void); - -#ifdef __cplusplus -} -#endif diff --git a/components/driver/touch_sensor/esp32/touch_sensor.c b/components/driver/touch_sensor/esp32/touch_sensor.c index e73d6dc6a12..fd54c452a03 100644 --- a/components/driver/touch_sensor/esp32/touch_sensor.c +++ b/components/driver/touch_sensor/esp32/touch_sensor.c @@ -27,7 +27,7 @@ #define INVARIANTS #endif #include "sys/queue.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "hal/touch_sensor_hal.h" typedef struct { diff --git a/components/driver/touch_sensor/esp32s2/touch_sensor.c b/components/driver/touch_sensor/esp32s2/touch_sensor.c index 72c232742df..2c46fa1eb3c 100644 --- a/components/driver/touch_sensor/esp32s2/touch_sensor.c +++ b/components/driver/touch_sensor/esp32s2/touch_sensor.c @@ -22,7 +22,7 @@ #include "sdkconfig.h" #include "esp_check.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "hal/touch_sensor_hal.h" #ifndef NDEBUG @@ -690,9 +690,9 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m */ static __attribute__((constructor)) void check_touch_driver_conflict(void) { - extern __attribute__((weak)) esp_err_t touch_del_channel(void *handle); - /* If the new I2S driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ - if ((void *)touch_del_channel != NULL) { + extern __attribute__((weak)) esp_err_t touch_sensor_new_controller(const void*, void *); + /* If the new Touch driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ + if ((void *)touch_sensor_new_controller != NULL) { ESP_EARLY_LOGE("legacy_touch_driver", "CONFLICT! The new touch driver can't work along with the legacy touch driver"); abort(); } diff --git a/components/driver/touch_sensor/esp32s3/touch_sensor.c b/components/driver/touch_sensor/esp32s3/touch_sensor.c index 3a2e645d7fb..e29091618e3 100644 --- a/components/driver/touch_sensor/esp32s3/touch_sensor.c +++ b/components/driver/touch_sensor/esp32s3/touch_sensor.c @@ -22,7 +22,7 @@ #include "sdkconfig.h" #include "esp_check.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "hal/touch_sensor_hal.h" #ifndef NDEBUG @@ -662,9 +662,9 @@ esp_err_t touch_pad_sleep_channel_set_work_time(uint16_t sleep_cycle, uint16_t m */ static __attribute__((constructor)) void check_touch_driver_conflict(void) { - extern __attribute__((weak)) esp_err_t touch_del_channel(void *handle); - /* If the new I2S driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ - if ((void *)touch_del_channel != NULL) { + extern __attribute__((weak)) esp_err_t touch_sensor_new_controller(const void*, void *); + /* If the new Touch driver is linked, the weak function will point to the actual function in the new driver, otherwise it is NULL*/ + if ((void *)touch_sensor_new_controller != NULL) { ESP_EARLY_LOGE("legacy_touch_driver", "CONFLICT! The new touch driver can't work along with the legacy touch driver"); abort(); } diff --git a/components/driver/touch_sensor/include/driver/touch_sensor_common.h b/components/driver/touch_sensor/include/driver/touch_sensor_common.h index af02b2a2fc1..848b4c2149e 100644 --- a/components/driver/touch_sensor/include/driver/touch_sensor_common.h +++ b/components/driver/touch_sensor/include/driver/touch_sensor_common.h @@ -8,7 +8,7 @@ #include "esp_err.h" #include "esp_intr_alloc.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #ifdef __cplusplus extern "C" { diff --git a/components/driver/touch_sensor/touch_sensor_common.c b/components/driver/touch_sensor/touch_sensor_common.c index b2846d473d3..1c901dc0be3 100644 --- a/components/driver/touch_sensor/touch_sensor_common.c +++ b/components/driver/touch_sensor/touch_sensor_common.c @@ -18,7 +18,7 @@ #include "driver/rtc_io.h" #include "esp_private/rtc_ctrl.h" #include "driver/gpio.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "hal/touch_sensor_hal.h" static const char *TOUCH_TAG = "TOUCH_SENSOR"; diff --git a/components/esp_driver_touch_sens/common/touch_sens_common.c b/components/esp_driver_touch_sens/common/touch_sens_common.c index a89f6b05ac6..f13f47848d3 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_common.c +++ b/components/esp_driver_touch_sens/common/touch_sens_common.c @@ -28,6 +28,7 @@ // Set the maximum log level for this source file #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG #endif +#include "esp_log.h" #include "esp_check.h" #include "touch_sens_private.h" @@ -73,7 +74,7 @@ esp_err_t touch_sensor_new_controller(const touch_sensor_config_t *sens_cfg, tou g_touch = (touch_sensor_handle_t)heap_caps_calloc(1, sizeof(struct touch_sensor_s), TOUCH_MEM_ALLOC_CAPS); ESP_RETURN_ON_FALSE(g_touch, ESP_ERR_NO_MEM, TAG, "No memory for touch sensor struct"); - g_touch->mutex = xSemaphoreCreateMutexWithCaps(TOUCH_MEM_ALLOC_CAPS); + g_touch->mutex = xSemaphoreCreateRecursiveMutexWithCaps(TOUCH_MEM_ALLOC_CAPS); ESP_GOTO_ON_FALSE(g_touch->mutex, ESP_ERR_NO_MEM, err, TAG, "No memory for mutex semaphore"); touch_priv_enable_module(true); @@ -100,7 +101,7 @@ esp_err_t touch_sensor_del_controller(touch_sensor_handle_t sens_handle) esp_err_t ret = ESP_OK; // Take the semaphore to make sure the touch has stopped - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Touch sensor has not disabled"); FOR_EACH_TOUCH_CHANNEL(i) { ESP_GOTO_ON_FALSE(!sens_handle->ch[i], ESP_ERR_INVALID_STATE, err, TAG, "There are still some touch channels not deleted"); @@ -121,7 +122,7 @@ esp_err_t touch_sensor_del_controller(touch_sensor_handle_t sens_handle) s_touch_free_resource(sens_handle); err: if (g_touch && g_touch->mutex) { - xSemaphoreGive(g_touch->mutex); + xSemaphoreGiveRecursive(g_touch->mutex); } return ret; } @@ -138,7 +139,7 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i ESP_RETURN_ON_FALSE(g_touch == sens_handle, ESP_ERR_INVALID_ARG, TAG, "The input touch sensor handle is unmatched"); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err2, TAG, "Please disable the touch sensor first"); ESP_GOTO_ON_FALSE(!sens_handle->ch[chan_id], ESP_ERR_INVALID_STATE, err2, TAG, "The channel %d has been registered", chan_id); @@ -163,13 +164,13 @@ esp_err_t touch_sensor_new_channel(touch_sensor_handle_t sens_handle, int chan_i *ret_chan_handle = sens_handle->ch[chan_id]; - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; err1: free(sens_handle->ch[chan_id]); sens_handle->ch[chan_id] = NULL; err2: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -179,7 +180,7 @@ esp_err_t touch_sensor_del_channel(touch_channel_handle_t chan_handle) esp_err_t ret = ESP_OK; touch_sensor_handle_t sens_handle = chan_handle->base; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); #if SOC_TOUCH_SUPPORT_WATERPROOF @@ -213,7 +214,7 @@ esp_err_t touch_sensor_del_channel(touch_channel_handle_t chan_handle) free(g_touch->ch[id]); g_touch->ch[id] = NULL; err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -224,13 +225,13 @@ esp_err_t touch_sensor_reconfig_controller(touch_sensor_handle_t sens_handle, co ESP_RETURN_ON_FALSE(sens_cfg->meas_interval_us >= 0, ESP_ERR_INVALID_ARG, TAG, "interval_us should be a positive value"); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); ESP_GOTO_ON_ERROR(touch_priv_config_controller(sens_handle, sens_cfg), err, TAG, "Configure touch controller failed"); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -270,7 +271,7 @@ esp_err_t touch_sensor_disable(touch_sensor_handle_t sens_handle) TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Touch sensor has not enabled"); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); @@ -280,7 +281,7 @@ esp_err_t touch_sensor_disable(touch_sensor_handle_t sens_handle) sens_handle->is_enabled = false; err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -291,13 +292,13 @@ esp_err_t touch_sensor_reconfig_channel(touch_channel_handle_t chan_handle, cons esp_err_t ret = ESP_OK; touch_sensor_handle_t sens_handle = chan_handle->base; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); ESP_GOTO_ON_ERROR(touch_priv_config_channel(chan_handle, chan_cfg), err, TAG, "Configure touch channel failed"); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -357,7 +358,7 @@ esp_err_t touch_sensor_trigger_oneshot_scanning(touch_sensor_handle_t sens_handl ticks = 1; } } - xSemaphoreTake(sens_handle->mutex, ticks); + xSemaphoreTakeRecursive(sens_handle->mutex, ticks); TickType_t end_tick = xTaskGetTickCount() + ticks; TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); touch_ll_enable_fsm_timer(false); @@ -386,7 +387,7 @@ esp_err_t touch_sensor_trigger_oneshot_scanning(touch_sensor_handle_t sens_handl TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); sens_handle->is_started = false; TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); @@ -407,7 +408,7 @@ esp_err_t touch_sensor_register_callbacks(touch_sensor_handle_t sens_handle, con #endif esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -415,7 +416,7 @@ esp_err_t touch_sensor_register_callbacks(touch_sensor_handle_t sens_handle, con sens_handle->user_ctx = user_ctx; err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -441,13 +442,13 @@ esp_err_t touch_sensor_get_channel_info(touch_channel_handle_t chan_handle, touc { TOUCH_NULL_POINTER_CHECK(chan_handle); TOUCH_NULL_POINTER_CHECK(chan_info); - xSemaphoreTake(chan_handle->base->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(chan_handle->base->mutex, portMAX_DELAY); chan_info->chan_id = chan_handle->id; chan_info->chan_gpio = touch_sensor_channel_io_map[chan_handle->id]; - chan_info->flags.is_dp_slp = chan_handle == chan_handle->base->deep_slp_chan; + chan_info->flags.can_wake_dp_slp = chan_handle == chan_handle->base->deep_slp_chan; chan_info->flags.is_proxi = chan_handle->prox_id > 0; chan_info->flags.is_guard = chan_handle == chan_handle->base->guard_chan; chan_info->flags.is_shield = chan_handle == chan_handle->base->shield_chan; - xSemaphoreGive(chan_handle->base->mutex); + xSemaphoreGiveRecursive(chan_handle->base->mutex); return ESP_OK; } diff --git a/components/esp_driver_touch_sens/common/touch_sens_private.h b/components/esp_driver_touch_sens/common/touch_sens_private.h index 5b0ce8b2c8b..895af66991b 100644 --- a/components/esp_driver_touch_sens/common/touch_sens_private.h +++ b/components/esp_driver_touch_sens/common/touch_sens_private.h @@ -32,13 +32,19 @@ extern "C" { /* IRAM safe caps */ #if CONFIG_TOUCH_ISR_IRAM_SAFE || CONFIG_TOUCH_CTRL_FUNC_IN_IRAM -#define TOUCH_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_LOWMED) -#define TOUCH_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) +#define _TOUCH_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_IRAM | ESP_INTR_FLAG_LOWMED) +#define TOUCH_MEM_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) #else -#define TOUCH_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_SHARED | ESP_INTR_FLAG_LOWMED) +#define _TOUCH_INTR_ALLOC_FLAGS (ESP_INTR_FLAG_LOWMED) #define TOUCH_MEM_ALLOC_CAPS MALLOC_CAP_DEFAULT #endif //CONFIG_TOUCH_ISR_IRAM_SAFE +#if SOC_TOUCH_SENSOR_VERSION == 3 +#define TOUCH_INTR_ALLOC_FLAGS (_TOUCH_INTR_ALLOC_FLAGS) +#else +#define TOUCH_INTR_ALLOC_FLAGS (_TOUCH_INTR_ALLOC_FLAGS | ESP_INTR_FLAG_SHARED) +#endif + /* DMA caps */ #define TOUCH_DMA_ALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA) diff --git a/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h b/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h index a57587f7e03..fddd88857e9 100644 --- a/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h +++ b/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h @@ -88,12 +88,12 @@ typedef enum { */ typedef struct { uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ - touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad */ - touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while charging a touch pad */ + touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad. i.e., the touch controller won't charge the touch pad higher than this high voltage limitation. */ + touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while discharging a touch pad. i.e., the touch controller won't discharge the touch pad lower than this low voltage limitation. */ touch_idle_conn_t idle_conn; /*!< The connection of the idle touch channels. - * The idle touch channel is a channel which is enabled but not under measuring. + * The idle touch channel is a channel which is enabled and power-on but not under measuring. */ - touch_bias_type_t bias_type; /*!< The type of the touch sensor bias */ + touch_bias_type_t bias_type; /*!< The type of the touch sensor bias. Which affects the charge/discharge stability and power consumption */ } touch_sensor_sample_config_t; /** @@ -241,7 +241,7 @@ typedef struct { touch_charge_speed_t charge_speed; /*!< The speed of charging and discharging the denoise touch channel, the higher the speed, the faster charging and discharging */ touch_init_charge_volt_t init_charge_volt; /*!< The initial voltage before starting charging/discharging the denoise channel */ touch_denoise_chan_cap_t ref_cap; /*!< The reference capacitance of the denoise channel. */ - touch_denoise_chan_res_t resolution; /*!< The noise suppression resolution of the denoise channel. + touch_denoise_chan_resolution_t resolution; /*!< The noise suppression resolution of the denoise channel. * The higher the resolution, the better the suppression effect, * but at the same time, the attenuation of other touch channel sampling values also increases. */ diff --git a/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c index 27af1aa834f..e7dcc63fe02 100644 --- a/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c +++ b/components/esp_driver_touch_sens/hw_ver2/touch_version_specific.c @@ -29,6 +29,7 @@ // Set the maximum log level for this source file #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG #endif +#include "esp_log.h" #include "esp_check.h" #define TOUCH_DENOISE_CHAN_ID 0 /*!< The touch channel that can be used as the denoise channel */ @@ -223,7 +224,7 @@ esp_err_t touch_priv_deinit_controller(touch_sensor_handle_t sens_handle) return ESP_OK; } -esp_err_t IRAM_ATTR touch_priv_channel_read_data(touch_channel_handle_t chan_handle, touch_chan_data_type_t type, uint32_t *data) +esp_err_t touch_priv_channel_read_data(touch_channel_handle_t chan_handle, touch_chan_data_type_t type, uint32_t *data) { ESP_RETURN_ON_FALSE_ISR(type >= TOUCH_CHAN_DATA_TYPE_RAW && type <= TOUCH_CHAN_DATA_TYPE_PROXIMITY, ESP_ERR_INVALID_ARG, TAG, "The channel data type is invalid"); @@ -270,7 +271,7 @@ esp_err_t touch_sensor_config_filter(touch_sensor_handle_t sens_handle, const to } esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); if (filter_cfg) { @@ -290,7 +291,7 @@ esp_err_t touch_sensor_config_filter(touch_sensor_handle_t sens_handle, const to } TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -303,7 +304,7 @@ esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, co touch_hal_config_t hal_cfg = {}; touch_hal_config_t *hal_cfg_ptr = NULL; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); if (sleep_cfg) { @@ -351,7 +352,7 @@ esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, co TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -361,7 +362,7 @@ esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, cons TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -391,7 +392,7 @@ esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, cons TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -400,7 +401,7 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -435,7 +436,7 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -443,7 +444,7 @@ esp_err_t touch_sensor_config_denoise_channel(touch_sensor_handle_t sens_handle, { TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -465,6 +466,6 @@ esp_err_t touch_sensor_config_denoise_channel(touch_sensor_handle_t sens_handle, TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } diff --git a/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h b/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h index ddd68131842..00f185337e2 100644 --- a/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h +++ b/components/esp_driver_touch_sens/hw_ver3/include/driver/touch_version_types.h @@ -89,7 +89,9 @@ typedef enum { * */ typedef struct { - uint32_t div_num; /*!< Division of the touch output pulse, `touch_out_pulse / div_num = charge_times` */ + uint32_t div_num; /*!< Division of the touch output pulse. + * It is proportional to the gain of the read data, the greater the div_num, the higher gain of the read data. + * If the read data is exceeded the maximum range, please reduce the div_num. */ uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ uint8_t rc_filter_res; /*!< The resistance of the RC filter of this sample configuration, range [0, 3], while 0 = 0K, 1 = 1.5K, 2 = 3K, 3 = 4.5K */ uint8_t rc_filter_cap; /*!< The capacitance of the RC filter of this sample configuration, range [0, 127], while 0 = 0pF, 1 = 20fF, ..., 127 = 2.54pF */ diff --git a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c index a98c71d4fa8..bf2ca48f38d 100644 --- a/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c +++ b/components/esp_driver_touch_sens/hw_ver3/touch_version_specific.c @@ -29,6 +29,7 @@ // Set the maximum log level for this source file #define LOG_LOCAL_LEVEL ESP_LOG_DEBUG #endif +#include "esp_log.h" #include "esp_check.h" static const char *TAG = "touch"; @@ -283,7 +284,7 @@ esp_err_t touch_sensor_config_filter(touch_sensor_handle_t sens_handle, const to } esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); TOUCH_ENTER_CRITICAL(TOUCH_PERIPH_LOCK); if (filter_cfg) { @@ -303,7 +304,7 @@ esp_err_t touch_sensor_config_filter(touch_sensor_handle_t sens_handle, const to } TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -319,7 +320,7 @@ esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, co }; touch_hal_config_t *hal_cfg_ptr = NULL; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); if (sleep_cfg) { @@ -370,7 +371,7 @@ esp_err_t touch_sensor_config_sleep_wakeup(touch_sensor_handle_t sens_handle, co TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -380,7 +381,7 @@ esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, cons TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -415,7 +416,7 @@ esp_err_t touch_sensor_config_waterproof(touch_sensor_handle_t sens_handle, cons TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); } err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } @@ -424,7 +425,7 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl TOUCH_NULL_POINTER_CHECK(sens_handle); esp_err_t ret = ESP_OK; - xSemaphoreTake(sens_handle->mutex, portMAX_DELAY); + xSemaphoreTakeRecursive(sens_handle->mutex, portMAX_DELAY); ESP_GOTO_ON_FALSE(!sens_handle->is_enabled, ESP_ERR_INVALID_STATE, err, TAG, "Please disable the touch sensor first"); @@ -465,6 +466,6 @@ esp_err_t touch_sensor_config_proximity_sensing(touch_sensor_handle_t sens_handl TOUCH_EXIT_CRITICAL(TOUCH_PERIPH_LOCK); err: - xSemaphoreGive(sens_handle->mutex); + xSemaphoreGiveRecursive(sens_handle->mutex); return ret; } diff --git a/components/esp_driver_touch_sens/include/driver/touch_sens_types.h b/components/esp_driver_touch_sens/include/driver/touch_sens_types.h index d9fa24512c3..50ee1ae0c33 100644 --- a/components/esp_driver_touch_sens/include/driver/touch_sens_types.h +++ b/components/esp_driver_touch_sens/include/driver/touch_sens_types.h @@ -31,62 +31,6 @@ typedef enum { TOUCH_DEEP_SLEEP_WAKEUP, /*!< Enable the touch sensor to wake up the chip from deep sleep or light sleep */ } touch_sleep_wakeup_level_t; -/** - * @brief Touch sensor shield channel drive capability level - * - */ -typedef enum { - TOUCH_SHIELD_CAP_40PF, /*!< The max equivalent capacitance in shield channel is 40pf */ - TOUCH_SHIELD_CAP_80PF, /*!< The max equivalent capacitance in shield channel is 80pf */ - TOUCH_SHIELD_CAP_120PF, /*!< The max equivalent capacitance in shield channel is 120pf */ - TOUCH_SHIELD_CAP_160PF, /*!< The max equivalent capacitance in shield channel is 160pf */ - TOUCH_SHIELD_CAP_200PF, /*!< The max equivalent capacitance in shield channel is 200pf */ - TOUCH_SHIELD_CAP_240PF, /*!< The max equivalent capacitance in shield channel is 240pf */ - TOUCH_SHIELD_CAP_280PF, /*!< The max equivalent capacitance in shield channel is 280pf */ - TOUCH_SHIELD_CAP_320PF, /*!< The max equivalent capacitance in shield channel is 320pf */ -} touch_chan_shield_cap_t; - -/** - * @brief Touch channel Infinite Impulse Response (IIR) filter or Jitter filter for benchmark - * @note Recommended filter coefficient selection is `IIR_16`. - */ -typedef enum { - TOUCH_BM_IIR_FILTER_4, /*!< IIR Filter for benchmark, 1/4 raw_value + 3/4 benchmark */ - TOUCH_BM_IIR_FILTER_8, /*!< IIR Filter for benchmark, 1/8 raw_value + 7/8 benchmark */ - TOUCH_BM_IIR_FILTER_16, /*!< IIR Filter for benchmark, 1/16 raw_value + 15/16 benchmark (typical) */ - TOUCH_BM_IIR_FILTER_32, /*!< IIR Filter for benchmark, 1/32 raw_value + 31/32 benchmark */ - TOUCH_BM_IIR_FILTER_64, /*!< IIR Filter for benchmark, 1/64 raw_value + 63/64 benchmark */ - TOUCH_BM_IIR_FILTER_128, /*!< IIR Filter for benchmark, 1/128 raw_value + 127/128 benchmark */ -#if SOC_TOUCH_SENSOR_VERSION == 2 - TOUCH_BM_IIR_FILTER_256, /*!< IIR Filter for benchmark, 1/256 raw_value + 255/256 benchmark */ -#endif - TOUCH_BM_JITTER_FILTER, /*!< Jitter Filter for benchmark, raw value +/- jitter_step */ -} touch_benchmark_filter_mode_t; - -/** - * @brief Touch channel Infinite Impulse Response (IIR) filter for smooth data - * - */ -typedef enum { - TOUCH_SMOOTH_NO_FILTER, /*!< No filter adopted for smooth data, smooth data equals raw data */ - TOUCH_SMOOTH_IIR_FILTER_2, /*!< IIR filter adopted for smooth data, smooth data equals 1/2 raw data + 1/2 last smooth data (typical) */ - TOUCH_SMOOTH_IIR_FILTER_4, /*!< IIR filter adopted for smooth data, smooth data equals 1/4 raw data + 3/4 last smooth data */ - TOUCH_SMOOTH_IIR_FILTER_8, /*!< IIR filter adopted for smooth data, smooth data equals 1/8 raw data + 7/8 last smooth data */ -} touch_smooth_filter_mode_t; - -/** - * @brief Interrupt events - * - */ -typedef enum { - TOUCH_INTR_EVENT_ACTIVE, /*!< Touch channel active event */ - TOUCH_INTR_EVENT_INACTIVE, /*!< Touch channel inactive event */ - TOUCH_INTR_EVENT_MEASURE_DONE, /*!< Touch channel measure done event */ - TOUCH_INTR_EVENT_SCAN_DONE, /*!< All touch channels scan done event */ - TOUCH_INTR_EVENT_TIMEOUT, /*!< Touch channel measurement timeout event */ - TOUCH_INTR_EVENT_PROXIMITY_DONE, /*!< Proximity channel measurement done event */ -} touch_intr_event_t; - typedef struct touch_sensor_s *touch_sensor_handle_t; /*!< The handle of touch sensor controller */ typedef struct touch_channel_s *touch_channel_handle_t; /*!< The handle of touch channel */ diff --git a/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h b/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h index 9760ae187ea..637a90336a1 100644 --- a/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h +++ b/components/esp_driver_touch_sens/include/esp_private/touch_sens_helper.h @@ -22,7 +22,7 @@ typedef struct { int chan_id; /*!< Touch channel number */ int chan_gpio; /*!< Corresponding GPIO of this channel */ struct { - uint32_t is_dp_slp: 1; /*!< Whether this channel can wakeup from deep sleep */ + uint32_t can_wake_dp_slp: 1;/*!< Whether this channel can wakeup from deep sleep */ uint32_t is_proxi: 1; /*!< Whether this channel is used for proximity sensing */ uint32_t is_guard: 1; /*!< Whether this channel is used for waterproof guard channel */ uint32_t is_shield: 1; /*!< Whether this channel is used for waterproof shield channel */ diff --git a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c index 9cb166c502a..64481e69729 100644 --- a/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c +++ b/components/esp_driver_touch_sens/test_apps/touch_sens/main/test_touch_sens_common.c @@ -55,20 +55,20 @@ TEST_CASE("touch_sens_install_uninstall_test", "[touch]") touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG(); TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg)); - for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++) { + for (int i = TOUCH_MIN_CHAN_ID; i <= TOUCH_MAX_CHAN_ID; i++) { TEST_ESP_OK(touch_sensor_new_channel(touch, i, &s_chan_cfg, &touch_chan[i])); } touch_channel_handle_t fault_chan = NULL; TEST_ASSERT(touch_sensor_new_channel(touch, TOUCH_TOTAL_CHAN_NUM, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_ARG); - TEST_ASSERT(touch_sensor_new_channel(touch, 0, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_STATE); + TEST_ASSERT(touch_sensor_new_channel(touch, TOUCH_MIN_CHAN_ID, &s_chan_cfg, &fault_chan) == ESP_ERR_INVALID_STATE); TEST_ESP_OK(touch_sensor_enable(touch)); - TEST_ASSERT(touch_sensor_del_channel(touch_chan[0]) == ESP_ERR_INVALID_STATE); + TEST_ASSERT(touch_sensor_del_channel(touch_chan[TOUCH_MIN_CHAN_ID]) == ESP_ERR_INVALID_STATE); TEST_ESP_OK(touch_sensor_disable(touch)); TEST_ASSERT(touch_sensor_del_controller(touch) == ESP_ERR_INVALID_STATE); - for (int i = 0; i < TOUCH_TOTAL_CHAN_NUM; i++) { + for (int i = TOUCH_MIN_CHAN_ID; i <= TOUCH_MAX_CHAN_ID; i++) { TEST_ESP_OK(touch_sensor_del_channel(touch_chan[i])); } TEST_ESP_OK(touch_sensor_del_controller(touch)); @@ -159,7 +159,7 @@ TEST_CASE("touch_sens_active_inactive_test", "[touch]") /* Configuring the filter */ touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG(); TEST_ESP_OK(touch_sensor_config_filter(touch, &filter_cfg)); - TEST_ESP_OK(touch_sensor_new_channel(touch, 1, &s_chan_cfg, &touch_chan)); + TEST_ESP_OK(touch_sensor_new_channel(touch, TOUCH_MIN_CHAN_ID, &s_chan_cfg, &touch_chan)); #if SOC_TOUCH_SENSOR_VERSION == 3 /* Connect the touch channels to the internal capacitor */ touch_ll_enable_internal_capacitor(true); diff --git a/components/esp_hw_support/include/esp_sleep.h b/components/esp_hw_support/include/esp_sleep.h index 7b9be75b0f5..8efa3d78bf5 100644 --- a/components/esp_hw_support/include/esp_sleep.h +++ b/components/esp_hw_support/include/esp_sleep.h @@ -9,7 +9,7 @@ #include #include "esp_err.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "hal/gpio_types.h" #include "soc/soc_caps.h" diff --git a/components/hal/esp32/include/hal/touch_sensor_hal.h b/components/hal/esp32/include/hal/touch_sensor_hal.h index 5cd1688df12..dd91614088f 100644 --- a/components/hal/esp32/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32/include/hal/touch_sensor_hal.h @@ -15,7 +15,7 @@ #pragma once #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include_next "hal/touch_sensor_hal.h" diff --git a/components/hal/esp32/include/hal/touch_sensor_ll.h b/components/hal/esp32/include/hal/touch_sensor_ll.h index 8d1c945024b..f154f16b0e7 100644 --- a/components/hal/esp32/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32/include/hal/touch_sensor_ll.h @@ -21,7 +21,7 @@ #include "soc/sens_struct.h" #include "soc/rtc_io_struct.h" #include "soc/rtc_cntl_struct.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #ifdef __cplusplus diff --git a/components/hal/esp32/touch_sensor_hal.c b/components/hal/esp32/touch_sensor_hal.c index d74a6686ddc..b663dedaa07 100644 --- a/components/hal/esp32/touch_sensor_hal.c +++ b/components/hal/esp32/touch_sensor_hal.c @@ -7,7 +7,7 @@ // The HAL layer for Touch sensor (common part) #include "hal/touch_sensor_hal.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" void touch_hal_init(void) { diff --git a/components/hal/esp32p4/include/hal/touch_sensor_ll.h b/components/hal/esp32p4/include/hal/touch_sensor_ll.h index 8425e15b300..d2e99b03f16 100644 --- a/components/hal/esp32p4/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32p4/include/hal/touch_sensor_ll.h @@ -24,7 +24,6 @@ #include "soc/touch_struct.h" #include "soc/pmu_struct.h" #include "soc/soc_caps.h" -#include "hal/touch_sensor_types.h" #include "hal/touch_sens_types.h" #ifdef __cplusplus @@ -174,17 +173,6 @@ static inline void touch_ll_enable_fsm_timer(bool enable) LP_ANA_PERI.touch_mux0.touch_start_force = !enable; } -/** - * Get touch sensor FSM mode. - * The measurement action can be triggered by the hardware timer, as well as by the software instruction. - * - * @param mode FSM mode. - */ -static inline void touch_ll_get_fsm_mode(touch_fsm_mode_t *mode) -{ - *mode = (touch_fsm_mode_t)LP_ANA_PERI.touch_mux0.touch_fsm_en; -} - /** * Is touch sensor FSM using hardware timer to trigger scanning. * The measurement action can be triggered by the hardware timer, as well as by the software instruction. @@ -254,6 +242,7 @@ static inline void touch_ll_stop_fsm_repeated_timer(void) * - true: enabled * - true: disabled */ +__attribute__((always_inline)) static inline bool touch_ll_is_fsm_repeated_timer_enabled(void) { return (bool)(PMU.touch_pwr_cntl.sleep_timer_en); @@ -304,7 +293,7 @@ __attribute__((always_inline)) static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) { // Channel shift workaround: the lowest bit takes no effect - uint16_t mask = (chan_mask << 1) & TOUCH_PAD_BIT_MASK_ALL; + uint16_t mask = (chan_mask << 1) & TOUCH_LL_FULL_CHANNEL_MASK; uint16_t prev_mask = LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map; if (enable) { LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = prev_mask | mask; @@ -328,7 +317,7 @@ static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) static inline void touch_ll_enable_channel_mask(uint16_t enable_mask) { // Channel shift workaround: the lowest bit takes no effect - uint16_t mask = (enable_mask << 1) & TOUCH_PAD_BIT_MASK_ALL; + uint16_t mask = (enable_mask << 1) & TOUCH_LL_FULL_CHANNEL_MASK; LP_ANA_PERI.touch_scan_ctrl1.touch_scan_pad_map = mask; LP_ANA_PERI.touch_filter2.touch_outen = mask; } @@ -478,7 +467,7 @@ static inline void touch_ll_set_clock_div(uint8_t sample_cfg_id, uint32_t div_nu * * @param type Select idle channel connect to high resistance state or ground. (No effect) */ -static inline void touch_ll_set_idle_channel_connect(touch_pad_conn_type_t type) +static inline void touch_ll_set_idle_channel_connect(touch_idle_conn_t type) { (void)type; } @@ -526,7 +515,7 @@ static inline void touch_ll_interrupt_disable(uint32_t int_mask) * @param int_mask Pad mask to clear interrupts */ __attribute__((always_inline)) -static inline void touch_ll_interrupt_clear(touch_pad_intr_mask_t int_mask) +static inline void touch_ll_interrupt_clear(uint32_t int_mask) { LP_TOUCH.int_clr.val = int_mask; } @@ -659,9 +648,9 @@ static inline void touch_ll_reset_chan_benchmark(uint32_t chan_mask) * Set filter mode. The input of the filter is the raw value of touch reading, * and the output of the filter is involved in the judgment of the touch state. * - * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. + * @param mode Filter mode type. Refer to ``touch_benchmark_filter_mode_t``. */ -static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) +static inline void touch_ll_filter_set_filter_mode(touch_benchmark_filter_mode_t mode) { LP_ANA_PERI.touch_filter1.touch_filter_mode = mode; } @@ -670,9 +659,9 @@ static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) * Set filter mode. The input to the filter is raw data and the output is the smooth data. * The smooth data is used to determine the touch status. * - * @param mode Filter mode type. Refer to ``touch_smooth_mode_t``. + * @param mode Filter mode type. Refer to ``touch_smooth_filter_mode_t``. */ -static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) +static inline void touch_ll_filter_set_smooth_mode(touch_smooth_filter_mode_t mode) { LP_ANA_PERI.touch_filter1.touch_smooth_lvl = mode; } @@ -797,7 +786,7 @@ static inline void touch_ll_waterproof_set_shield_chan_mask(uint32_t mask) * * @param driver_level The driver level of the touch buff */ -static inline void touch_ll_waterproof_set_shield_driver(touch_pad_shield_driver_t driver_level) +static inline void touch_ll_waterproof_set_shield_driver(touch_chan_shield_cap_t driver_level) { LP_ANA_PERI.touch_ana_para.touch_touch_buf_drv = driver_level; } diff --git a/components/hal/esp32s2/include/hal/touch_sensor_hal.h b/components/hal/esp32s2/include/hal/touch_sensor_hal.h index 382a52f9378..6d2770d4ee2 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_hal.h @@ -15,7 +15,7 @@ #pragma once #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include_next "hal/touch_sensor_hal.h" diff --git a/components/hal/esp32s2/include/hal/touch_sensor_ll.h b/components/hal/esp32s2/include/hal/touch_sensor_ll.h index bf4628cee08..1b2bda597e8 100644 --- a/components/hal/esp32s2/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s2/include/hal/touch_sensor_ll.h @@ -16,6 +16,7 @@ #include #include +#include "esp_bit_defs.h" #include "hal/misc.h" #include "hal/assert.h" #include "soc/touch_sensor_periph.h" @@ -23,7 +24,6 @@ #include "soc/sens_struct.h" #include "soc/rtc_cntl_struct.h" #include "soc/rtc_io_struct.h" -#include "hal/touch_sensor_types.h" #include "hal/touch_sens_types.h" #ifdef __cplusplus @@ -137,7 +137,7 @@ static inline uint32_t touch_ll_get_intr_status_mask(void) * - touch channel number */ __attribute__((always_inline)) -static inline uint32_t IRAM_ATTR touch_ll_get_current_meas_channel(void) +static inline uint32_t touch_ll_get_current_meas_channel(void) { return SENS.sar_touch_status0.touch_scan_curr; } @@ -176,7 +176,7 @@ static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask) __attribute__((always_inline)) static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) { - uint16_t mask = chan_mask & TOUCH_PAD_BIT_MASK_ALL; + uint16_t mask = chan_mask & TOUCH_LL_FULL_CHANNEL_MASK; uint16_t prev_mask = RTCCNTL.touch_scan_ctrl.touch_scan_pad_map; if (enable) { RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = prev_mask | mask; @@ -211,7 +211,6 @@ static inline void touch_ll_set_power_on_wait_cycle(uint32_t wait_cycles) HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, wait_cycles); //wait volt stable } -// HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time); /** * Set touch sensor touch sensor charge and discharge times of every measurement on a pad. * @@ -237,27 +236,56 @@ static inline void touch_ll_set_measure_interval_ticks(uint16_t interval_ticks) HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, interval_ticks); } +/** + * Set the Touch pad charge speed. + * + * @param touch_num Touch channel number + * @param charge_speed Charge speed of this touch channel + */ static inline void touch_ll_set_charge_speed(uint32_t touch_num, touch_charge_speed_t charge_speed) { RTCIO.touch_pad[touch_num].dac = charge_speed; } +/** + * Set the upper limitation of the touch channel voltage while charging + * + * @param high_lim The high(upper) limitation of charge + */ static inline void touch_ll_set_charge_voltage_high_limit(touch_volt_lim_h_t high_lim) { RTCCNTL.touch_ctrl2.touch_drefh = (uint32_t)high_lim & 0x3; RTCCNTL.touch_ctrl2.touch_drange = (uint32_t)high_lim >> 2; } +/** + * Set the lower limitation of the touch channel voltage while discharging + * + * @param low_lim The lower limitation of discharge + */ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_lim) { RTCCNTL.touch_ctrl2.touch_drefl = low_lim; } +/** + * Set the initial charge voltage of touch channel + * i.e., the touch pad measurement start from a low voltage or a high voltage + * + * @param touch_num Touch channel number + * @param init_charge_volt The initial charge voltage + */ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) { RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; } +/** + * Set the connection of the idle channel + * The idle channel is the channel that is enabled and powered on but not under measurement. + * + * @param idle_conn + */ static inline void touch_ll_set_idle_channel_connection(touch_idle_conn_t idle_conn) { RTCCNTL.touch_scan_ctrl.touch_inactive_connection = idle_conn; @@ -385,6 +413,7 @@ static inline void touch_ll_stop_fsm_repeated_timer(void) * - true: enabled * - false: disabled */ +__attribute__((always_inline)) static inline bool touch_ll_is_fsm_repeated_timer_enabled(void) { return (bool)RTCCNTL.touch_ctrl2.touch_slp_timer_en; @@ -467,9 +496,9 @@ static inline void touch_ll_filter_enable(bool enable) * Set filter mode. The input of the filter is the raw value of touch reading, * and the output of the filter is involved in the judgment of the touch state. * - * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. + * @param mode Filter mode type. Refer to ``touch_benchmark_filter_mode_t``. */ -static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) +static inline void touch_ll_filter_set_filter_mode(touch_benchmark_filter_mode_t mode) { RTCCNTL.touch_filter_ctrl.touch_filter_mode = mode; } @@ -490,12 +519,21 @@ static inline void touch_ll_filter_set_jitter_step(uint32_t step) * Set the denoise coefficient regarding the denoise level. * * @param denoise_lvl Range [0 ~ 4]. 0 = no noise resistance, otherwise higher denoise_lvl means more noise resistance. + * 0 = no noise resistance + * 1 = noise resistance is 1/4 benchmark + * 2 = noise resistance is 3/8 benchmark + * 3 = noise resistance is 1/2 benchmark + * 4 = noise resistance is 1 benchmark */ static inline void touch_ll_filter_set_denoise_level(int denoise_lvl) { HAL_ASSERT(denoise_lvl >= 0 && denoise_lvl <= 4); bool always_update = denoise_lvl == 0; - // Map denoise level to actual noise threshold coefficients + /* Map denoise level to actual noise threshold coefficients + denoise_lvl=1 -> noise_thresh=2, 1/4 benchmark + denoise_lvl=2 -> noise_thresh=1, 3/8 benchmark + denoise_lvl=3 -> noise_thresh=0, 1/2 benchmark + denoise_lvl=4 -> noise_thresh=3, 1 benchmark */ uint32_t noise_thresh = denoise_lvl == 4 ? 3 : 3 - denoise_lvl; RTCCNTL.touch_filter_ctrl.touch_noise_thres = always_update ? 0 : noise_thresh; @@ -519,9 +557,9 @@ static inline void touch_ll_filter_set_active_hysteresis(uint32_t hysteresis) * Set filter mode. The input to the filter is raw data and the output is the smooth data. * The smooth data is used to determine the touch status. * - * @param mode Filter mode type. Refer to ``touch_smooth_mode_t``. + * @param mode Filter mode type. Refer to ``touch_smooth_filter_mode_t``. */ -static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) +static inline void touch_ll_filter_set_smooth_mode(touch_smooth_filter_mode_t mode) { RTCCNTL.touch_filter_ctrl.touch_smooth_lvl = mode; } @@ -599,9 +637,9 @@ static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num) * The equivalent capacitance of the shielded channel can be calculated * from the reading of denoise channel. * - * @param pad_num Touch sensor channel number. + * @param pad_num Touch sensor channel number. Refer to ``touch_chan_shield_cap_t`` */ -static inline void touch_ll_waterproof_set_shield_driver(touch_pad_shield_driver_t driver_level) +static inline void touch_ll_waterproof_set_shield_driver(touch_chan_shield_cap_t driver_level) { RTCCNTL.touch_scan_ctrl.touch_bufdrv = driver_level; } @@ -707,7 +745,7 @@ static inline void touch_ll_denoise_set_reference_cap(touch_denoise_chan_cap_t c * * @param resolution Denoise resolution of denoise channel. */ -static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_res_t resolution) +static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_resolution_t resolution) { RTCCNTL.touch_scan_ctrl.touch_denoise_res = resolution; } @@ -723,8 +761,9 @@ static inline void touch_ll_denoise_read_data(uint32_t *data) } /******************************************************************************/ -/* Legacy APIs */ +/* Legacy APIs (to be removed in esp-idf v6.0) */ /******************************************************************************/ +#include "hal/touch_sensor_legacy_types.h" /** * Set touch sensor touch sensor times of charge and discharge. * diff --git a/components/hal/esp32s2/touch_sensor_hal.c b/components/hal/esp32s2/touch_sensor_hal.c index dd1d1c400f5..c8f3789c8ae 100644 --- a/components/hal/esp32s2/touch_sensor_hal.c +++ b/components/hal/esp32s2/touch_sensor_hal.c @@ -9,7 +9,7 @@ #include "soc/soc_pins.h" #include "soc/touch_sensor_pins.h" #include "hal/touch_sensor_hal.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" static int s_sleep_cycle = -1; static int s_meas_times = -1; diff --git a/components/hal/esp32s3/include/hal/touch_sensor_hal.h b/components/hal/esp32s3/include/hal/touch_sensor_hal.h index e9edc58c51d..dc8f6fefdc1 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_hal.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_hal.h @@ -15,7 +15,7 @@ #pragma once #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include_next "hal/touch_sensor_hal.h" diff --git a/components/hal/esp32s3/include/hal/touch_sensor_ll.h b/components/hal/esp32s3/include/hal/touch_sensor_ll.h index 0e22458f8b8..b42083a1f21 100644 --- a/components/hal/esp32s3/include/hal/touch_sensor_ll.h +++ b/components/hal/esp32s3/include/hal/touch_sensor_ll.h @@ -16,6 +16,7 @@ #include #include +#include "esp_bit_defs.h" #include "hal/misc.h" #include "hal/assert.h" #include "soc/touch_sensor_periph.h" @@ -23,7 +24,6 @@ #include "soc/rtc_io_struct.h" #include "soc/sens_struct.h" #include "soc/soc_caps.h" -#include "hal/touch_sensor_types.h" #include "hal/touch_sens_types.h" #ifdef __cplusplus @@ -132,7 +132,7 @@ static inline uint32_t touch_ll_get_intr_status_mask(void) * - touch channel number */ __attribute__((always_inline)) -static inline uint32_t IRAM_ATTR touch_ll_get_current_meas_channel(void) +static inline uint32_t touch_ll_get_current_meas_channel(void) { return SENS.sar_touch_status0.touch_scan_curr; } @@ -171,7 +171,7 @@ static inline void touch_ll_get_active_channel_mask(uint32_t *active_mask) __attribute__((always_inline)) static inline void touch_ll_enable_scan_mask(uint16_t chan_mask, bool enable) { - uint16_t mask = chan_mask & TOUCH_PAD_BIT_MASK_ALL; + uint16_t mask = chan_mask & TOUCH_LL_FULL_CHANNEL_MASK; uint16_t prev_mask = RTCCNTL.touch_scan_ctrl.touch_scan_pad_map; if (enable) { RTCCNTL.touch_scan_ctrl.touch_scan_pad_map = prev_mask | mask; @@ -206,7 +206,6 @@ static inline void touch_ll_set_power_on_wait_cycle(uint32_t wait_cycles) HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl2, touch_xpd_wait, wait_cycles); //wait volt stable } -// HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_meas_num, meas_time); /** * Set touch sensor touch sensor charge and discharge times of every measurement on a pad. * @@ -232,6 +231,12 @@ static inline void touch_ll_set_measure_interval_ticks(uint16_t interval_ticks) HAL_FORCE_MODIFY_U32_REG_FIELD(RTCCNTL.touch_ctrl1, touch_sleep_cycles, interval_ticks); } +/** + * Set the Touch pad charge speed. + * + * @param touch_num Touch channel number + * @param charge_speed Charge speed of this touch channel + */ static inline void touch_ll_set_charge_speed(uint32_t touch_num, touch_charge_speed_t charge_speed) { #define CHARGE_SPEED_MASK(val, num) ((val) << (29 - (num) * 3)) @@ -248,22 +253,45 @@ static inline void touch_ll_set_charge_speed(uint32_t touch_num, touch_charge_sp #undef CHARGE_SPEED_MASK } +/** + * Set the upper limitation of the touch channel voltage while charging + * + * @param high_lim The high(upper) limitation of charge + */ static inline void touch_ll_set_charge_voltage_high_limit(touch_volt_lim_h_t high_lim) { RTCCNTL.touch_ctrl2.touch_drefh = (uint32_t)high_lim & 0x3; RTCCNTL.touch_ctrl2.touch_drange = (uint32_t)high_lim >> 2; } +/** + * Set the lower limitation of the touch channel voltage while discharging + * + * @param low_lim The lower limitation of discharge + */ static inline void touch_ll_set_charge_voltage_low_limit(touch_volt_lim_l_t low_lim) { RTCCNTL.touch_ctrl2.touch_drefl = low_lim; } +/** + * Set the initial charge voltage of touch channel + * i.e., the touch pad measurement start from a low voltage or a high voltage + * + * @param touch_num Touch channel number + * @param init_charge_volt The initial charge voltage + */ static inline void touch_ll_set_init_charge_voltage(uint32_t touch_num, touch_init_charge_volt_t init_charge_volt) { RTCIO.touch_pad[touch_num].tie_opt = init_charge_volt; } +/** + * Set the connection of the idle channel + * The idle channel is the channel that is enabled and powered on but not under measurement. + * + * @param idle_conn + */ static inline void touch_ll_set_idle_channel_connection(touch_idle_conn_t idle_conn) { RTCCNTL.touch_scan_ctrl.touch_inactive_connection = idle_conn; @@ -392,6 +420,7 @@ static inline void touch_ll_stop_fsm_repeated_timer(void) * - true: enabled * - false: disabled */ +__attribute__((always_inline)) static inline bool touch_ll_is_fsm_repeated_timer_enabled(void) { return (bool)RTCCNTL.touch_ctrl2.touch_slp_timer_en; @@ -474,9 +503,9 @@ static inline void touch_ll_filter_enable(bool enable) * Set filter mode. The input of the filter is the raw value of touch reading, * and the output of the filter is involved in the judgment of the touch state. * - * @param mode Filter mode type. Refer to ``touch_filter_mode_t``. + * @param mode Filter mode type. Refer to ``touch_benchmark_filter_mode_t``. */ -static inline void touch_ll_filter_set_filter_mode(touch_filter_mode_t mode) +static inline void touch_ll_filter_set_filter_mode(touch_benchmark_filter_mode_t mode) { RTCCNTL.touch_filter_ctrl.touch_filter_mode = mode; } @@ -497,12 +526,21 @@ static inline void touch_ll_filter_set_jitter_step(uint32_t step) * Set the denoise coefficient regarding the denoise level. * * @param denoise_lvl Range [0 ~ 4]. 0 = no noise resistance, otherwise higher denoise_lvl means more noise resistance. + * 0 = no noise resistance + * 1 = noise resistance is 1/4 benchmark + * 2 = noise resistance is 3/8 benchmark + * 3 = noise resistance is 1/2 benchmark + * 4 = noise resistance is 1 benchmark */ static inline void touch_ll_filter_set_denoise_level(int denoise_lvl) { HAL_ASSERT(denoise_lvl >= 0 && denoise_lvl <= 4); bool always_update = denoise_lvl == 0; - // Map denoise level to actual noise threshold coefficients + /* Map denoise level to actual noise threshold coefficients + denoise_lvl=1 -> noise_thresh=2, 1/4 benchmark + denoise_lvl=2 -> noise_thresh=1, 3/8 benchmark + denoise_lvl=3 -> noise_thresh=0, 1/2 benchmark + denoise_lvl=4 -> noise_thresh=3, 1 benchmark */ uint32_t noise_thresh = denoise_lvl == 4 ? 3 : 3 - denoise_lvl; RTCCNTL.touch_filter_ctrl.touch_bypass_noise_thres = always_update; @@ -529,9 +567,9 @@ static inline void touch_ll_filter_set_active_hysteresis(uint32_t hysteresis) * Set filter mode. The input to the filter is raw data and the output is the smooth data. * The smooth data is used to determine the touch status. * - * @param mode Filter mode type. Refer to ``touch_smooth_mode_t``. + * @param mode Filter mode type. Refer to ``touch_smooth_filter_mode_t``. */ -static inline void touch_ll_filter_set_smooth_mode(touch_smooth_mode_t mode) +static inline void touch_ll_filter_set_smooth_mode(touch_smooth_filter_mode_t mode) { RTCCNTL.touch_filter_ctrl.touch_smooth_lvl = mode; } @@ -609,9 +647,9 @@ static inline void touch_ll_waterproof_set_guard_chan(uint32_t pad_num) * The equivalent capacitance of the shielded channel can be calculated * from the reading of denoise channel. * - * @param pad_num Touch sensor channel number. + * @param pad_num Touch sensor channel number. Refer to ``touch_chan_shield_cap_t`` */ -static inline void touch_ll_waterproof_set_shield_driver(touch_pad_shield_driver_t driver_level) +static inline void touch_ll_waterproof_set_shield_driver(touch_chan_shield_cap_t driver_level) { RTCCNTL.touch_scan_ctrl.touch_bufdrv = driver_level; } @@ -717,7 +755,7 @@ static inline void touch_ll_denoise_set_reference_cap(touch_denoise_chan_cap_t c * * @param resolution Denoise resolution of denoise channel. */ -static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_res_t resolution) +static inline void touch_ll_denoise_set_resolution(touch_denoise_chan_resolution_t resolution) { RTCCNTL.touch_scan_ctrl.touch_denoise_res = resolution; } @@ -733,8 +771,9 @@ static inline void touch_ll_denoise_read_data(uint32_t *data) } /******************************************************************************/ -/* Legacy APIs */ +/* Legacy APIs (to be removed in esp-idf v6.0) */ /******************************************************************************/ +#include "hal/touch_sensor_legacy_types.h" /** * Set touch sensor touch sensor times of charge and discharge. * diff --git a/components/hal/esp32s3/touch_sensor_hal.c b/components/hal/esp32s3/touch_sensor_hal.c index c68e4d094ec..4ae025a5b0d 100644 --- a/components/hal/esp32s3/touch_sensor_hal.c +++ b/components/hal/esp32s3/touch_sensor_hal.c @@ -9,7 +9,7 @@ #include "soc/soc_pins.h" #include "hal/touch_sensor_hal.h" #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "soc/soc_caps.h" static int s_sleep_cycle = -1; diff --git a/components/hal/include/hal/touch_sens_hal.h b/components/hal/include/hal/touch_sens_hal.h index a86953acbca..f10992363a9 100644 --- a/components/hal/include/hal/touch_sens_hal.h +++ b/components/hal/include/hal/touch_sens_hal.h @@ -25,21 +25,33 @@ extern "C" { #if SOC_TOUCH_SENSOR_VERSION > 1 +#if SOC_TOUCH_SENSOR_VERSION == 2 + /** - * @brief Sample configurations of the touch sensor - * + * @brief Sample configurations of the touch sensor V2 */ typedef struct { -#if SOC_TOUCH_SENSOR_VERSION == 2 // S2/S3 - uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ - touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad */ - touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while charging a touch pad */ - touch_idle_conn_t idle_conn; /*!< The connection of the idle touch channels. - * The idle touch channel is a channel which is enabled but not under measuring. - */ - touch_bias_type_t bias_type; -#elif SOC_TOUCH_SENSOR_VERSION == 3 // P4 - uint32_t div_num; /*!< The division from the source clock to the sampling frequency */ + uint32_t charge_times; /*!< The charge and discharge times of this sample configuration, the read data are positive correlation to the charge_times */ + touch_volt_lim_h_t charge_volt_lim_h; /*!< The upper voltage limit while charging a touch pad. i.e., the touch controller won't charge the touch pad higher than this high voltage limitation. */ + touch_volt_lim_l_t charge_volt_lim_l; /*!< The lower voltage limit while discharging a touch pad. i.e., the touch controller won't discharge the touch pad lower than this low voltage limitation. */ + touch_idle_conn_t idle_conn; /*!< The connection of the idle touch channels. + * The idle touch channel is a channel which is enabled and power-on but not under measuring. + */ + touch_bias_type_t bias_type; /*!< The type of the touch sensor bias. Which affects the charge/discharge stability and power consumption */ +} touch_hal_sample_config_v2_t; + +/** + * @brief Alias of touch_hal_sample_config_v2_t for compatibility + */ +typedef touch_hal_sample_config_v2_t touch_hal_sample_config_t; + +#elif SOC_TOUCH_SENSOR_VERSION == 3 + +/** + * @brief Sample configurations of the touch sensor V3 + */ +typedef struct { + uint32_t div_num; /*!< The division of the touch output signal. It is proportional to the gain of the read data */ uint32_t charge_times; /*!< The charge and discharge times of the sample configuration, the read data are positive correlation to the charge_times */ uint8_t rc_filter_res; /*!< The resistance of the RC filter of the sample configuration, range [0, 3], while 0 = 0K, 1 = 1.5K, 2 = 3K, 3 = 4.5K */ uint8_t rc_filter_cap; /*!< The capacitance of the RC filter of the sample configuration, range [0, 127], while 0 = 0pF, 1 = 20fF, ..., 127 = 2.54pF */ @@ -47,10 +59,16 @@ typedef struct { uint8_t high_drv; /*!< High speed touch driver */ uint8_t bias_volt; /*!< The Internal LDO voltage, which decide the bias voltage of the sample wave, range [0,15] */ bool bypass_shield_output; /*!< Whether to bypass the shield output */ +} touch_hal_sample_config_v3_t; + +/** + * @brief Alias of touch_hal_sample_config_v3_t for compatibility + */ +typedef touch_hal_sample_config_v3_t touch_hal_sample_config_t; + #else #error "Unsupported touch sensor version" #endif -} touch_hal_sample_config_t; /** * @brief Configurations of the touch sensor controller diff --git a/components/hal/include/hal/touch_sens_types.h b/components/hal/include/hal/touch_sens_types.h index d763a748a74..65c3b92d6d2 100644 --- a/components/hal/include/hal/touch_sens_types.h +++ b/components/hal/include/hal/touch_sens_types.h @@ -1,18 +1,60 @@ /* - * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #pragma once -#include "esp_bit_defs.h" #include "soc/soc_caps.h" #ifdef __cplusplus extern "C" { #endif +/** + * @brief Touch sensor shield channel drive capability level + * + */ +typedef enum { + TOUCH_SHIELD_CAP_40PF, /*!< The max equivalent capacitance in shield channel is 40pf */ + TOUCH_SHIELD_CAP_80PF, /*!< The max equivalent capacitance in shield channel is 80pf */ + TOUCH_SHIELD_CAP_120PF, /*!< The max equivalent capacitance in shield channel is 120pf */ + TOUCH_SHIELD_CAP_160PF, /*!< The max equivalent capacitance in shield channel is 160pf */ + TOUCH_SHIELD_CAP_200PF, /*!< The max equivalent capacitance in shield channel is 200pf */ + TOUCH_SHIELD_CAP_240PF, /*!< The max equivalent capacitance in shield channel is 240pf */ + TOUCH_SHIELD_CAP_280PF, /*!< The max equivalent capacitance in shield channel is 280pf */ + TOUCH_SHIELD_CAP_320PF, /*!< The max equivalent capacitance in shield channel is 320pf */ +} touch_chan_shield_cap_t; + +/** + * @brief Touch channel Infinite Impulse Response (IIR) filter or Jitter filter for benchmark + * @note Recommended filter coefficient selection is `IIR_16`. + */ +typedef enum { + TOUCH_BM_IIR_FILTER_4, /*!< IIR Filter for benchmark, 1/4 raw_value + 3/4 benchmark */ + TOUCH_BM_IIR_FILTER_8, /*!< IIR Filter for benchmark, 1/8 raw_value + 7/8 benchmark */ + TOUCH_BM_IIR_FILTER_16, /*!< IIR Filter for benchmark, 1/16 raw_value + 15/16 benchmark (typical) */ + TOUCH_BM_IIR_FILTER_32, /*!< IIR Filter for benchmark, 1/32 raw_value + 31/32 benchmark */ + TOUCH_BM_IIR_FILTER_64, /*!< IIR Filter for benchmark, 1/64 raw_value + 63/64 benchmark */ + TOUCH_BM_IIR_FILTER_128, /*!< IIR Filter for benchmark, 1/128 raw_value + 127/128 benchmark */ +#if SOC_TOUCH_SENSOR_VERSION == 2 + TOUCH_BM_IIR_FILTER_256, /*!< IIR Filter for benchmark, 1/256 raw_value + 255/256 benchmark */ +#endif + TOUCH_BM_JITTER_FILTER, /*!< Jitter Filter for benchmark, raw value +/- jitter_step */ +} touch_benchmark_filter_mode_t; + +/** + * @brief Touch channel Infinite Impulse Response (IIR) filter for smooth data + * + */ +typedef enum { + TOUCH_SMOOTH_NO_FILTER, /*!< No filter adopted for smooth data, smooth data equals raw data */ + TOUCH_SMOOTH_IIR_FILTER_2, /*!< IIR filter adopted for smooth data, smooth data equals 1/2 raw data + 1/2 last smooth data (typical) */ + TOUCH_SMOOTH_IIR_FILTER_4, /*!< IIR filter adopted for smooth data, smooth data equals 1/4 raw data + 3/4 last smooth data */ + TOUCH_SMOOTH_IIR_FILTER_8, /*!< IIR filter adopted for smooth data, smooth data equals 1/8 raw data + 7/8 last smooth data */ +} touch_smooth_filter_mode_t; + /** * @brief Touch sensor upper charging voltage limit */ @@ -42,10 +84,10 @@ typedef enum { * @brief Touch sensor lower discharging voltage limit */ typedef enum { - TOUCH_VOLT_LIM_L_0V5, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ - TOUCH_VOLT_LIM_L_0V6, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ - TOUCH_VOLT_LIM_L_0V7, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ - TOUCH_VOLT_LIM_L_0V8, /*!< Touch sensor lower voltage limit is 0.5V while charging a touch pad */ + TOUCH_VOLT_LIM_L_0V5, /*!< Touch sensor lower voltage limit is 0.5V while discharging a touch pad */ + TOUCH_VOLT_LIM_L_0V6, /*!< Touch sensor lower voltage limit is 0.6V while discharging a touch pad */ + TOUCH_VOLT_LIM_L_0V7, /*!< Touch sensor lower voltage limit is 0.7V while discharging a touch pad */ + TOUCH_VOLT_LIM_L_0V8, /*!< Touch sensor lower voltage limit is 0.8V while discharging a touch pad */ } touch_volt_lim_l_t; /** @@ -70,41 +112,40 @@ typedef enum { TOUCH_INIT_CHARGE_VOLT_HIGH = 1,/*!< Tie the initial charge voltage to high */ } touch_init_charge_volt_t; -/** Touch channel idle state configuration */ +/** + * @brief Touch channel idle state configuration + */ typedef enum { - TOUCH_IDLE_CONN_HIGHZ = 0, /*!< The idle (enabled but not measuring) touch channel is in high resistance state */ + TOUCH_IDLE_CONN_HIGHZ = 0, /*!< The idle (enabled but not measuring) touch channel is at high resistance state */ TOUCH_IDLE_CONN_GND = 1, /*!< The idle (enabled but not measuring) touch channel is connected to the ground */ } touch_idle_conn_t; /** * @brief Touch sensor denoise channel internal reference capacitance - * */ typedef enum { - TOUCH_DENOISE_CHAN_CAP_L0 = 0, /*!< Denoise channel internal reference capacitance is 5pf */ - TOUCH_DENOISE_CHAN_CAP_L1 = 1, /*!< Denoise channel internal reference capacitance is 6.4pf */ - TOUCH_DENOISE_CHAN_CAP_L2 = 2, /*!< Denoise channel internal reference capacitance is 7.8pf */ - TOUCH_DENOISE_CHAN_CAP_L3 = 3, /*!< Denoise channel internal reference capacitance is 9.2pf */ - TOUCH_DENOISE_CHAN_CAP_L4 = 4, /*!< Denoise channel internal reference capacitance is 10.6pf */ - TOUCH_DENOISE_CHAN_CAP_L5 = 5, /*!< Denoise channel internal reference capacitance is 12.0pf */ - TOUCH_DENOISE_CHAN_CAP_L6 = 6, /*!< Denoise channel internal reference capacitance is 13.4pf */ - TOUCH_DENOISE_CHAN_CAP_L7 = 7, /*!< Denoise channel internal reference capacitance is 14.8pf */ + TOUCH_DENOISE_CHAN_CAP_5PF = 0, /*!< Denoise channel internal reference capacitance is 5.0pf */ + TOUCH_DENOISE_CHAN_CAP_6PF = 1, /*!< Denoise channel internal reference capacitance is 6.4pf */ + TOUCH_DENOISE_CHAN_CAP_7PF = 2, /*!< Denoise channel internal reference capacitance is 7.8pf */ + TOUCH_DENOISE_CHAN_CAP_9PF = 3, /*!< Denoise channel internal reference capacitance is 9.2pf */ + TOUCH_DENOISE_CHAN_CAP_10PF = 4, /*!< Denoise channel internal reference capacitance is 10.6pf */ + TOUCH_DENOISE_CHAN_CAP_12PF = 5, /*!< Denoise channel internal reference capacitance is 12.0pf */ + TOUCH_DENOISE_CHAN_CAP_13PF = 6, /*!< Denoise channel internal reference capacitance is 13.4pf */ + TOUCH_DENOISE_CHAN_CAP_14PF = 7, /*!< Denoise channel internal reference capacitance is 14.8pf */ } touch_denoise_chan_cap_t; /** * @brief Touch sensor denoise channel noise suppression resolution - * */ typedef enum { - TOUCH_DENOISE_CHAN_RES_BIT12 = 0, /*!< Denoise channel noise suppression resolution is 12bit */ - TOUCH_DENOISE_CHAN_RES_BIT10 = 1, /*!< Denoise channel noise suppression resolution is 10bit */ - TOUCH_DENOISE_CHAN_RES_BIT8 = 2, /*!< Denoise channel noise suppression resolution is 8bit */ - TOUCH_DENOISE_CHAN_RES_BIT4 = 3, /*!< Denoise channel noise suppression resolution is 4bit */ -} touch_denoise_chan_res_t; + TOUCH_DENOISE_CHAN_RESOLUTION_BIT12 = 0, /*!< Denoise channel noise suppression resolution is 12bit */ + TOUCH_DENOISE_CHAN_RESOLUTION_BIT10 = 1, /*!< Denoise channel noise suppression resolution is 10bit */ + TOUCH_DENOISE_CHAN_RESOLUTION_BIT8 = 2, /*!< Denoise channel noise suppression resolution is 8bit */ + TOUCH_DENOISE_CHAN_RESOLUTION_BIT4 = 3, /*!< Denoise channel noise suppression resolution is 4bit */ +} touch_denoise_chan_resolution_t; /** * @brief Touch sensor bias type - * */ typedef enum { TOUCH_BIAS_TYPE_BANDGAP, /*!< Use bandgap-bias to charge/discharge the touch channel, which is more stable but power-consuming */ @@ -112,8 +153,7 @@ typedef enum { } touch_bias_type_t; /** - * @brief Touch channel counting mode of the binarized touch output - * + * @brief Touch channel binarized output counting mode */ typedef enum { TOUCH_PAD_OUT_AS_DATA, /*!< Counting the output of touch channel as data. diff --git a/components/hal/include/hal/touch_sensor_hal.h b/components/hal/include/hal/touch_sensor_hal.h index a0352a864db..23f9ba863a0 100644 --- a/components/hal/include/hal/touch_sensor_hal.h +++ b/components/hal/include/hal/touch_sensor_hal.h @@ -10,14 +10,14 @@ * See readme.md in hal/include/hal/readme.md ******************************************************************************/ -// The HAL layer for touch sensor (common part) +// The legacy HAL layer for touch sensor (common part) #pragma once #include "soc/soc_caps.h" #if SOC_TOUCH_SENSOR_SUPPORTED #include "hal/touch_sensor_ll.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #endif #ifdef __cplusplus diff --git a/components/hal/include/hal/touch_sensor_types.h b/components/hal/include/hal/touch_sensor_legacy_types.h similarity index 100% rename from components/hal/include/hal/touch_sensor_types.h rename to components/hal/include/hal/touch_sensor_legacy_types.h diff --git a/components/hal/touch_sens_hal.c b/components/hal/touch_sens_hal.c index 2c947747996..35262325c24 100644 --- a/components/hal/touch_sens_hal.c +++ b/components/hal/touch_sens_hal.c @@ -73,8 +73,8 @@ static void s_touch_hal_apply_sleep_config(void) } /* Whether to enable touch sensor wake-up the chip from deep sleep */ if (s_touch_slp_obj.deep_slp_chan >= 0) { - // touch_ll_sleep_set_channel_num(s_touch_slp_obj.deep_slp_chan); - // touch_ll_enable_channel_mask(BIT(s_touch_slp_obj.deep_slp_chan)); + touch_ll_sleep_set_channel_num(s_touch_slp_obj.deep_slp_chan); + touch_ll_enable_channel_mask(BIT(s_touch_slp_obj.deep_slp_chan)); } else { touch_ll_sleep_set_channel_num(TOUCH_LL_NULL_CHANNEL); } diff --git a/components/hal/touch_sensor_hal.c b/components/hal/touch_sensor_hal.c index f69f0163bcb..3121f03e2d5 100644 --- a/components/hal/touch_sensor_hal.c +++ b/components/hal/touch_sensor_hal.c @@ -7,7 +7,7 @@ // The HAL layer for Touch Sensor (common part) #include "hal/touch_sensor_hal.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #include "soc/soc_caps.h" void touch_hal_config(touch_pad_t touch_num) diff --git a/components/soc/esp32s3/register/soc/rtc_cntl_reg.h b/components/soc/esp32s3/register/soc/rtc_cntl_reg.h index 00958eb0dba..5a1fa823249 100644 --- a/components/soc/esp32s3/register/soc/rtc_cntl_reg.h +++ b/components/soc/esp32s3/register/soc/rtc_cntl_reg.h @@ -3061,12 +3061,12 @@ ork.*/ #define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_M (BIT(8)) #define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_V 0x1 #define RTC_CNTL_TOUCH_BYPASS_NOISE_THRES_S 8 -/* RTC_CNTL_TOUCH_BYPASS_NEG_THRES : R/W ;bitpos:[7] ;default: 1'b0 ; */ +/* RTC_CNTL_TOUCH_BYPASS_NN_THRES : R/W ;bitpos:[7] ;default: 1'b0 ; */ /*description: */ -#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES (BIT(7)) -#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_M (BIT(7)) -#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_V 0x1 -#define RTC_CNTL_TOUCH_BYPASS_NEG_THRES_S 7 +#define RTC_CNTL_TOUCH_BYPASS_NN_THRES (BIT(7)) +#define RTC_CNTL_TOUCH_BYPASS_NN_THRES_M (BIT(7)) +#define RTC_CNTL_TOUCH_BYPASS_NN_THRES_V 0x1 +#define RTC_CNTL_TOUCH_BYPASS_NN_THRES_S 7 #define RTC_CNTL_USB_CONF_REG (DR_REG_RTCCNTL_BASE + 0x120) /* RTC_CNTL_SW_HW_USB_PHY_SEL : R/W ;bitpos:[20] ;default: 1'b0 ; */ diff --git a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h b/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h index 2556e766350..043c7d50728 100644 --- a/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h +++ b/components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h @@ -8,7 +8,7 @@ #include "esp_err.h" #include "ulp_riscv_register_ops.h" -#include "hal/touch_sensor_types.h" +#include "hal/touch_sensor_legacy_types.h" #ifdef __cplusplus extern "C" { diff --git a/docs/conf_common.py b/docs/conf_common.py index c7c26263d85..61d09aa29ee 100644 --- a/docs/conf_common.py +++ b/docs/conf_common.py @@ -207,7 +207,7 @@ 'api-reference/peripherals/ds.rst', 'api-reference/peripherals/temp_sensor.rst', 'api-reference/system/async_memcpy.rst', - 'api-reference/peripherals/touch_pad.rst', + 'api-reference/peripherals/cap_touch_sens.rst', 'api-reference/peripherals/touch_element.rst', 'api-guides/RF_calibration.rst', 'api-guides/phy.rst'] + FTDI_JTAG_DOCS + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_DOCS @@ -215,7 +215,7 @@ ESP32S3_DOCS = ['hw-reference/esp32s3/**', 'api-reference/system/ipc.rst', 'api-guides/flash_psram_config.rst', - 'api-reference/peripherals/touch_pad.rst', + 'api-reference/peripherals/cap_touch_sens.rst', 'api-reference/peripherals/sd_pullup_requirements.rst', 'api-guides/RF_calibration.rst', 'api-guides/phy.rst'] + USB_OTG_DFU_DOCS + USB_OTG_CONSOLE_DOCS + QEMU_DOCS diff --git a/docs/docs_not_updated/esp32p4.txt b/docs/docs_not_updated/esp32p4.txt index 158999f510a..fff012c1189 100644 --- a/docs/docs_not_updated/esp32p4.txt +++ b/docs/docs_not_updated/esp32p4.txt @@ -6,8 +6,6 @@ api-guides/usb-otg-console.rst api-guides/esp-wifi-mesh.rst api-guides/dfu.rst api-guides/wifi-security.rst -api-reference/peripherals/touch_element.rst -api-reference/peripherals/touch_pad.rst api-reference/peripherals/adc_calibration.rst api-reference/peripherals/parlio.rst api-reference/peripherals/sd_pullup_requirements.rst diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 8a3c7d78c24..8a6d91db279 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -261,7 +261,6 @@ INPUT = \ $(PROJECT_PATH)/components/hal/include/hal/spi_types.h \ $(PROJECT_PATH)/components/hal/include/hal/temperature_sensor_types.h \ $(PROJECT_PATH)/components/hal/include/hal/timer_types.h \ - $(PROJECT_PATH)/components/hal/include/hal/touch_sensor_types.h \ $(PROJECT_PATH)/components/hal/include/hal/twai_types.h \ $(PROJECT_PATH)/components/hal/include/hal/uart_types.h \ $(PROJECT_PATH)/components/hal/include/hal/efuse_hal.h \ diff --git a/docs/doxygen/Doxyfile_esp32 b/docs/doxygen/Doxyfile_esp32 index 1b098c71ccd..cc46952c97c 100644 --- a/docs/doxygen/Doxyfile_esp32 +++ b/docs/doxygen/Doxyfile_esp32 @@ -1,5 +1,6 @@ INPUT += \ $(PROJECT_PATH)/components/driver/touch_sensor/$(IDF_TARGET)/include/driver/touch_sensor.h \ + $(PROJECT_PATH)/components/hal/include/hal/touch_sensor_legacy_types.h \ $(PROJECT_PATH)/components/esp_psram/include/esp32/himem.h \ $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/dac_channel.h \ $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/rtc_io_channel.h \ diff --git a/docs/doxygen/Doxyfile_esp32s2 b/docs/doxygen/Doxyfile_esp32s2 index 1601d5562d1..c212f7d4dba 100644 --- a/docs/doxygen/Doxyfile_esp32s2 +++ b/docs/doxygen/Doxyfile_esp32s2 @@ -1,8 +1,9 @@ INPUT += \ - $(PROJECT_PATH)/components/driver/touch_sensor/$(IDF_TARGET)/include/driver/touch_sensor.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens_types.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h \ $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/dac_channel.h \ $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/rtc_io_channel.h \ - $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/touch_sensor_channel.h \ $(PROJECT_PATH)/components/ulp/ulp_fsm/include/$(IDF_TARGET)/ulp.h \ $(PROJECT_PATH)/components/touch_element/include/touch_element/touch_button.h \ $(PROJECT_PATH)/components/touch_element/include/touch_element/touch_element.h \ diff --git a/docs/doxygen/Doxyfile_esp32s3 b/docs/doxygen/Doxyfile_esp32s3 index f16dad3a422..20235266c32 100644 --- a/docs/doxygen/Doxyfile_esp32s3 +++ b/docs/doxygen/Doxyfile_esp32s3 @@ -1,7 +1,8 @@ INPUT += \ - $(PROJECT_PATH)/components/driver/touch_sensor/$(IDF_TARGET)/include/driver/touch_sensor.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/include/driver/touch_sens_types.h \ + $(PROJECT_PATH)/components/esp_driver_touch_sens/hw_ver2/include/driver/touch_version_types.h \ $(PROJECT_PATH)/components/esp_lcd/rgb/include/esp_lcd_panel_rgb.h \ - $(PROJECT_PATH)/components/soc/$(IDF_TARGET)/include/soc/touch_sensor_channel.h \ $(PROJECT_PATH)/components/ulp/ulp_fsm/include/$(IDF_TARGET)/ulp.h \ $(PROJECT_PATH)/components/touch_element/include/touch_element/touch_button.h \ $(PROJECT_PATH)/components/touch_element/include/touch_element/touch_element.h \ diff --git a/docs/en/api-reference/peripherals/cap_touch_sens.rst b/docs/en/api-reference/peripherals/cap_touch_sens.rst index 0b08103dbd8..7e4ba8c6eef 100644 --- a/docs/en/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/en/api-reference/peripherals/cap_touch_sens.rst @@ -3,7 +3,7 @@ Capacitive Touch Sensor :link_to_translation:`zh_CN:[中文]` -{IDF_TARGET_TOUCH_SENSOR_VERSION:default="NOT_UPDATED", esp32p4="v3"} +{IDF_TARGET_TOUCH_SENSOR_VERSION:default="NOT_UPDATED", esp32s2="v2", esp32s3="v2", esp32p4="v3"} Introduction --------------- @@ -35,59 +35,9 @@ Overview of Capacitive Touch Sensor Versions Overview of Touch Sensor Channels ------------------------------------ -.. only:: esp32p4 - - .. list-table:: - :header-rows: 1 - :widths: 20 20 - - * - Channel - - GPIO - - * - CH0 - - IO2 - - * - CH1 - - IO3 - - * - CH2 - - IO4 - - * - CH3 - - IO5 - - * - CH4 - - IO6 - - * - CH5 - - IO7 - - * - CH6 - - IO8 - - * - CH7 - - IO9 - - * - CH8 - - IO10 - - * - CH9 - - IO11 - - * - CH10 - - IO12 - - * - CH11 - - IO13 - - * - CH12 - - IO14 - - * - CH13 - - IO15 - - * - CH14 - - Internal +.. include:: cap_touch_sens/{IDF_TARGET_PATH_NAME}.inc + :start-after: touch-chan-mapping + :end-before: --- Terminology in the Driver ---------------------------- @@ -148,6 +98,7 @@ Categorized by functionality, the APIs of Capacitive Touch Sensor mainly include :SOC_TOUCH_SUPPORT_WATERPROOF: - `Waterproof Configuration <#touch-waterproof>`__ :SOC_TOUCH_SUPPORT_PROX_SENSING: - `Proximity Sensing Configuration <#touch-prox-sensing>`__ :SOC_TOUCH_SUPPORT_SLEEP_WAKEUP: - `Sleep Wake-up Configuration <#touch-sleep-wakeup>`__ + :SOC_TOUCH_SUPPORT_DENOISE_CHAN: - `Denoise Channel Configuration <#touch-denoise-chan>`__ .. _touch-ctrl: @@ -385,7 +336,13 @@ Call :cpp:func:`touch_channel_read_data` to read the data with different types. The {IDF_TARGET_NAME} supports proximity sensing. Proximity sensing can be registered by calling :cpp:func:`touch_sensor_config_proximity_sensing` and specify the configurations :cpp:type:`touch_proximity_config_t`. - Since the capacitance change caused by proximity sensing is far less than that caused by physical touch, large area of copper foil is often used on PCB to increase the sensing area. In addition, multiple rounds of scans are needed and the result of each scan will be accumulated in the driver to improve the measurement sensitivity. The scan times (rounds) can be determined by :cpp:member:`touch_proximity_config_t::scan_times` and the charging times of the proximity channel in one scan can be determined by :cpp:member:`touch_proximity_config_t::charge_times`. Generally, the larger the scan times and charging times is, the higher the sensitivity will be, however, the read data will be unstable if the sensitivity is too high. Proper parameters should be determined regarding the application. + .. only:: esp32p4 + + Since the capacitance change caused by proximity sensing is far less than that caused by physical touch, large area of copper foil is often used on PCB to increase the sensing area. In addition, multiple rounds of scans are needed and the result of each scan will be accumulated in the driver to improve the measurement sensitivity. The scan times (rounds) can be determined by :cpp:member:`touch_proximity_config_t::scan_times` and the charging times of the proximity channel in one scan can be determined by :cpp:member:`touch_proximity_config_t::charge_times`. Generally, the larger the scan times and charging times is, the higher the sensitivity will be, however, the read data will be unstable if the sensitivity is too high. Proper parameters should be determined regarding the application. + + .. only:: not esp32p4 + + Since the capacitance change caused by proximity sensing is far less than that caused by physical touch, large area of copper foil is often used on PCB to increase the sensing area. In addition, multiple rounds of scans are needed and the result of each scan will be accumulated in the driver to improve the measurement sensitivity. The scan times (rounds) can be determined by :cpp:member:`touch_proximity_config_t::scan_times`. Generally, the larger the scan times and charging times is, the higher the sensitivity will be, however, the read data will be unstable if the sensitivity is too high. Proper parameters should be determined regarding the application. The accumulated proximity data can be read by :cpp:func:`touch_channel_read_data` with the data type :cpp:enumerator:`TOUCH_CHAN_DATA_TYPE_PROXIMITY` @@ -421,7 +378,7 @@ Call :cpp:func:`touch_channel_read_data` to read the data with different types. If you want to read or configure the touch sensor during the sleep, you can turn to the driver ``components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h`` which based on the :doc:`Ultra Low Power (ULP) Coprocessor <../system/ulp>`. - Light sleep wake-up: you need to set :cpp:member:`slp_wakeup_lvl` to :cpp:enumerator:`TOUCH_LIGHT_SLEEP_WAKEUP` to enable the light sleep wake-up by touch sensor. Note that any registered touch channel can wake-up the chip from light sleep. - - Deep sleep wake-up: beside setting :cpp:member:`slp_wakeup_lvl` to :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP`, you need to specify :cpp:member:`deep_slp_chan` additionally. Only the specified channel can wake-up the chip from the deep sleep, in order to reduce the power consumption. And also, the driver supports to store another set of configurations for the deep sleep via :cpp:member:`deep_slp_sens_cfg`, this set of configurations only takes effect during the deep sleep, you can customize the configurations to save more power. The configurations will be reset to the previous set after waking-up from the deep sleep. Please be aware that, not only deep sleep wake-up, but also light sleep wake-up will be enabled when the :cpp:member:`slp_wakeup_lvl` is :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP`. + - Deep sleep wake-up: beside setting :cpp:member:`slp_wakeup_lvl` to :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP`, you need to specify :cpp:member:`deep_slp_chan` additionally. In order to reduce the power consumption, only the specified channel can wake-up the chip from the deep sleep when RTC_PREI power domain off. And also, the driver supports to store another set of configurations for the deep sleep via :cpp:member:`deep_slp_sens_cfg`, this set of configurations only takes effect during the deep sleep, you can customize the configurations to save more power. The configurations will be reset to the previous set after waking-up from the deep sleep. Please be aware that, not only deep sleep wake-up, but also light sleep wake-up will be enabled when the :cpp:member:`slp_wakeup_lvl` is :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP`. To deregister the sleep wake-up function, you can call :cpp:func:`touch_sensor_config_sleep_wakeup` again, and set the second parameter (i.e. :cpp:type:`touch_sleep_config_t` pointer) to ``NULL``. @@ -444,15 +401,44 @@ Call :cpp:func:`touch_channel_read_data` to read the data with different types. // Register the deep sleep wake-up ESP_ERROR_CHECK(touch_sensor_config_sleep_wakeup(sens_handle, &deep_slp_cfg)); +.. _touch-denoise-chan: + +.. only:: SOC_TOUCH_SUPPORT_DENOISE_CHAN + + Denoise Channel Configuration + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + + The {IDF_TARGET_NAME} supports the internal background noise suppression by the denoise channel. Denoise channel can be registered by calling :cpp:func:`touch_sensor_config_denoise_channel` and specify the configurations :cpp:type:`touch_denoise_chan_config_t`. + + Denoise channel is an internal channel that not fanned out. After the denoise channel is enabled, the sampled data of the other touch channels will minus the data of the denoise channel automatically, so the final measurement result of the touch channels will be attenuated compare to the original data. + + Aside of the common touch channel configuration, the reference capacitance that attached to the denoise channel can be set by :cpp:member:`touch_denoise_chan_config_t::ref_cap`. And the noise suppression resolution can be set by :cpp:member:`touch_denoise_chan_config_t::resolution`. The higher the resolution, the greater and more accuracy the denoise channel sample data will be, and the better suppression effect it takes. But at the same time, the attenuation of other touch channel sampling values also increases. + + For example, the denoise channel resolution is :cpp:enumerator:`touch_denoise_chan_resolution_t::TOUCH_DENOISE_CHAN_RESOLUTION_BIT8`, i.e., maximum sample data is ``255``. Assuming the actual sample data of a normal touch channel is ``10000``, and the denoise channel sample data is ``100``, then the final measurement result of the touch channel will be ``10000 - 100 = 9900``; If we increase the resolution to :cpp:enumerator:`touch_denoise_chan_resolution_t::TOUCH_DENOISE_CHAN_RESOLUTION_BIT12`, i.e., maximum sample data is ``4095``, the resolution is ``16`` times greater. So the denoise channel sample data will be about ``100 * 16 = 1600``, then the final measurement result of this touch channel will be ``10000 - 1600 = 8400.`` + + To deregister the denoise channel, you can call :cpp:func:`touch_sensor_config_denoise_channel` again, and set the second parameter (i.e. :cpp:type:`touch_denoise_chan_config_t` pointer) to ``NULL``. + + .. code-block:: c + + touch_denoise_chan_config_t denoise_cfg = { + // Denoise channel configurations + // ... + } + // Register the denoise channel + ESP_ERROR_CHECK(touch_sensor_config_denoise_channel(sens_handle, &denoise_cfg)); + // ... + // Deregister the denoise channel + ESP_ERROR_CHECK(touch_sensor_config_denoise_channel(sens_handle, NULL)); + Application Examples ------------------------ - - :example:`peripherals/touch_sensor/touch_sensor_v3` demonstrates how to register touch channels and read the data, including hardware requirements and project configuration instructions. + - :example:`peripherals/touch_sensor/touch_sens_basic` demonstrates how to register touch channels and read the data, including hardware requirements and project configuration instructions. API Reference ------------- -.. only:: esp32p4 +.. only:: esp32p4 or esp32s2 or esp32s3 .. include-build-file:: inc/touch_sens.inc .. include-build-file:: inc/touch_sens_types.inc diff --git a/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc b/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc new file mode 100644 index 00000000000..e02da617bbb --- /dev/null +++ b/docs/en/api-reference/peripherals/cap_touch_sens/esp32p4.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - Channel + - GPIO + + * - CH0 + - IO2 + + * - CH1 + - IO3 + + * - CH2 + - IO4 + + * - CH3 + - IO5 + + * - CH4 + - IO6 + + * - CH5 + - IO7 + + * - CH6 + - IO8 + + * - CH7 + - IO9 + + * - CH8 + - IO10 + + * - CH9 + - IO11 + + * - CH10 + - IO12 + + * - CH11 + - IO13 + + * - CH12 + - IO14 + + * - CH13 + - IO15 + + * - CH14 + - Internal + +--- diff --git a/docs/en/api-reference/peripherals/cap_touch_sens/esp32s2.inc b/docs/en/api-reference/peripherals/cap_touch_sens/esp32s2.inc new file mode 100644 index 00000000000..c4af1781b1e --- /dev/null +++ b/docs/en/api-reference/peripherals/cap_touch_sens/esp32s2.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - Channel + - GPIO + + * - CH0 + - Internal + + * - CH1 + - IO1 + + * - CH2 + - IO2 + + * - CH3 + - IO3 + + * - CH4 + - IO4 + + * - CH5 + - IO5 + + * - CH6 + - IO6 + + * - CH7 + - IO7 + + * - CH8 + - IO8 + + * - CH9 + - IO9 + + * - CH10 + - IO10 + + * - CH11 + - IO11 + + * - CH12 + - IO12 + + * - CH13 + - IO13 + + * - CH14 + - IO14 + +--- diff --git a/docs/en/api-reference/peripherals/cap_touch_sens/esp32s3.inc b/docs/en/api-reference/peripherals/cap_touch_sens/esp32s3.inc new file mode 100644 index 00000000000..c4af1781b1e --- /dev/null +++ b/docs/en/api-reference/peripherals/cap_touch_sens/esp32s3.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - Channel + - GPIO + + * - CH0 + - Internal + + * - CH1 + - IO1 + + * - CH2 + - IO2 + + * - CH3 + - IO3 + + * - CH4 + - IO4 + + * - CH5 + - IO5 + + * - CH6 + - IO6 + + * - CH7 + - IO7 + + * - CH8 + - IO8 + + * - CH9 + - IO9 + + * - CH10 + - IO10 + + * - CH11 + - IO11 + + * - CH12 + - IO12 + + * - CH13 + - IO13 + + * - CH14 + - IO14 + +--- diff --git a/docs/en/api-reference/peripherals/index.rst b/docs/en/api-reference/peripherals/index.rst index 3a959b72490..0e0fd30b16a 100644 --- a/docs/en/api-reference/peripherals/index.rst +++ b/docs/en/api-reference/peripherals/index.rst @@ -42,8 +42,8 @@ Peripherals API :SOC_GPSPI_SUPPORTED: spi_slave :SOC_SPI_SUPPORT_SLAVE_HD_VER2: spi_slave_hd :SOC_TEMP_SENSOR_SUPPORTED: temp_sensor - :SOC_TOUCH_SENSOR_SUPPORTED and not esp32p4: touch_pad - :esp32p4: cap_touch_sens + :esp32: touch_pad + :SOC_TOUCH_SENSOR_SUPPORTED and not esp32: cap_touch_sens :esp32s2: touch_element :SOC_TWAI_SUPPORTED: twai uart diff --git a/docs/en/api-reference/peripherals/touch_element.rst b/docs/en/api-reference/peripherals/touch_element.rst index 22d1761d831..5ddae43a3b9 100644 --- a/docs/en/api-reference/peripherals/touch_element.rst +++ b/docs/en/api-reference/peripherals/touch_element.rst @@ -6,7 +6,11 @@ Touch Element Overview -------- -The Touch Element Library is a highly abstracted element library designed on the basis of the touch sensor driver. The library provides a unified and user-friendly software interface to quickly build capacitive touch sensor applications. For more information about the touch sensor driver API, see :doc:`../peripherals/touch_pad`. +The Touch Element Library is a highly abstracted element library designed on the basis of the touch sensor driver. The library provides a unified and user-friendly software interface to quickly build capacitive touch sensor applications. + +.. warning:: + + The Touch Element Library currently is still based on the legacy touch driver. Please refer to the :doc:`new driver of Capacitive Touch Sensor ` if you don't need the Touch Element Library. Architecture ^^^^^^^^^^^^ diff --git a/docs/en/api-reference/peripherals/touch_pad.rst b/docs/en/api-reference/peripherals/touch_pad.rst index 1725375aa67..0cbab8545c8 100644 --- a/docs/en/api-reference/peripherals/touch_pad.rst +++ b/docs/en/api-reference/peripherals/touch_pad.rst @@ -5,6 +5,12 @@ Touch Sensor {IDF_TARGET_TOUCH_SENSOR_VERSION:default="v2", esp32="v1"} +.. only:: esp32s2 or esp32s3 + + .. warning:: + + The touch driver in this document has been deprecated, please move to the new document for the latest touch driver: :doc:`Capacitive Touch Sensor `. + Introduction ------------ @@ -146,8 +152,6 @@ Touch State Measurements It can also be used, for example, to evaluate a particular touch pad design by checking the range of sensor readings when a pad is touched or released. This information can be then used to establish a touch threshold. -For the demonstration of how to read the touch pad data, check the application example :example:`peripherals/touch_sensor/touch_sensor_{IDF_TARGET_TOUCH_SENSOR_VERSION}/touch_pad_read`. - Method of Measurements ^^^^^^^^^^^^^^^^^^^^^^ @@ -250,7 +254,7 @@ Touch detection is implemented in ESP32's hardware based on the user-configured Hardware touch detection can also be wired to interrupts. This is described in the next section. -If measurements are noisy and capacity changes are small, hardware touch detection might be unreliable. To resolve this issue, instead of using hardware detection/provided interrupts, implement measurement filtering and perform touch detection in your own application. For sample implementation of both methods of touch detection, see :example:`peripherals/touch_sensor/touch_sensor_{IDF_TARGET_TOUCH_SENSOR_VERSION}/touch_pad_interrupt`. +If measurements are noisy and capacity changes are small, hardware touch detection might be unreliable. To resolve this issue, instead of using hardware detection/provided interrupts, implement measurement filtering and perform touch detection in your own application. Touch Triggered Interrupts ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,9 +304,9 @@ Application Examples .. only:: esp32s2 or esp32s3 - - :example:`peripherals/touch_sensor/touch_sensor_v2/touch_pad_read` demonstrates how to read and display raw values from capacitive touch pad sensors on {IDF_TARGET_NAME}, including how to calibrate the sensors and detect touch actions. - - :example:`peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt` demonstrates how to set up {IDF_TARGET_NAME}'s capacitive touch pad peripheral to trigger an interrupt when a pad is touched, and how to detect the touch event by the software for sensor designs when greater touch detection sensitivity is required. + .. warning:: + The example that uses legacy driver is removed, please see :example:`peripherals/touch_sensor/touch_sens_basic` for the usage of the new driver. .. _touch_pad-api-reference: @@ -321,4 +325,4 @@ Some useful macros can be used to specified the GPIO number of a touch pad chann 2. ``TOUCH_PAD_GPIO4_CHANNEL`` is the channel number of GPIO 4 (channel 0). .. include-build-file:: inc/touch_sensor_channel.inc -.. include-build-file:: inc/touch_sensor_types.inc +.. include-build-file:: inc/touch_sensor_legacy_types.inc diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst index 794c4e67c6b..6070b6a3013 100644 --- a/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens.rst @@ -3,7 +3,7 @@ :link_to_translation:`en:[English]` -{IDF_TARGET_TOUCH_SENSOR_VERSION:default="NOT_UPDATED", esp32p4="v3"} +{IDF_TARGET_TOUCH_SENSOR_VERSION:default="NOT_UPDATED", esp32s2="v2", esp32s3="v2", esp32p4="v3"} 概述 ------ @@ -35,59 +35,9 @@ 触摸通道概览 ---------------------- -.. only:: esp32p4 - - .. list-table:: - :header-rows: 1 - :widths: 20 20 - - * - 通道 - - GPIO - - * - CH0 - - IO2 - - * - CH1 - - IO3 - - * - CH2 - - IO4 - - * - CH3 - - IO5 - - * - CH4 - - IO6 - - * - CH5 - - IO7 - - * - CH6 - - IO8 - - * - CH7 - - IO9 - - * - CH8 - - IO10 - - * - CH9 - - IO11 - - * - CH10 - - IO12 - - * - CH11 - - IO13 - - * - CH12 - - IO14 - - * - CH13 - - IO15 - - * - CH14 - - 未引出 +.. include:: cap_touch_sens/{IDF_TARGET_PATH_NAME}.inc + :start-after: touch-chan-mapping + :end-before: --- 驱动中的术语介绍 ------------------------- @@ -148,6 +98,7 @@ :SOC_TOUCH_SUPPORT_WATERPROOF: - `防水防潮配置 <#touch-waterproof>`__ :SOC_TOUCH_SUPPORT_PROX_SENSING: - `接近感应配置 <#touch-prox-sensing>`__ :SOC_TOUCH_SUPPORT_SLEEP_WAKEUP: - `睡眠唤醒配置 <#touch-sleep-wakeup>`__ + :SOC_TOUCH_SUPPORT_DENOISE_CHAN: - `去噪通道配置 <#touch-denoise-chan>`__ .. _touch-ctrl: @@ -385,7 +336,13 @@ {IDF_TARGET_NAME} 支持接近感应功能。可通过调用 :cpp:func:`touch_sensor_config_proximity_sensing` 并配置 :cpp:type:`touch_proximity_config_t` 来注册接近感应功能。 - 由于接近感应引起的电容变化远小于物理触摸,PCB 上常用较大面积的铺铜来增大触摸通道的感应面积,另外需要在硬件上对接近感应通道进行多轮扫描并在驱动中进行累加来提高测量灵敏度。接近感应的灵敏度由测量轮数 :cpp:member:`touch_proximity_config_t::scan_times` 以及单次测量的充放电次数 :cpp:member:`touch_proximity_config_t::charge_times` 决定。测量轮数以及充放电次数越高,灵敏度越高,但是过高的灵敏度容易导致误触发,请选择适当的灵敏度来保证触发的稳定性。 + .. only:: esp32p4 + + 由于接近感应引起的电容变化远小于物理触摸,PCB 上常用较大面积的铺铜来增大触摸通道的感应面积,另外需要在硬件上对接近感应通道进行多轮扫描并在驱动中进行累加来提高测量灵敏度。接近感应的灵敏度由测量轮数 :cpp:member:`touch_proximity_config_t::scan_times` 以及单次测量的充放电次数 :cpp:member:`touch_proximity_config_t::charge_times` 决定。测量轮数以及充放电次数越高,灵敏度越高,但是过高的灵敏度容易导致误触发,请选择适当的灵敏度来保证触发的稳定性。 + + .. only:: not esp32p4 + + 由于接近感应引起的电容变化远小于物理触摸,PCB 上常用较大面积的铺铜来增大触摸通道的感应面积,另外需要在硬件上对接近感应通道进行多轮扫描并在驱动中进行累加来提高测量灵敏度。接近感应的灵敏度由测量轮数 :cpp:member:`touch_proximity_config_t::scan_times` 决定。测量轮数以及充放电次数越高,灵敏度越高,但是过高的灵敏度容易导致误触发,请选择适当的灵敏度来保证触发的稳定性。 接近感应通道多次测量的累加值也可通过 :cpp:func:`touch_channel_read_data` 获取,数据类型 :cpp:type:`touch_chan_data_type_t` 为 :cpp:enumerator:`TOUCH_CHAN_DATA_TYPE_PROXIMITY`。 @@ -410,7 +367,7 @@ 睡眠唤醒配置 ^^^^^^^^^^^^^^ - {IDF_TARGET_NAME} 支持触摸传感器将芯片从浅睡眠或深睡眠状态中唤醒。可通过调用 :cpp:func:`touch_sensor_config_sleep_wakeup` 并配置 :cpp:type:`touch_sleep_config_t` 来注册接近感应功能。 + {IDF_TARGET_NAME} 支持触摸传感器将芯片从 Light-sleep 或 Deep-sleep 状态中唤醒。可通过调用 :cpp:func:`touch_sensor_config_sleep_wakeup` 并配置 :cpp:type:`touch_sleep_config_t` 来注册接近感应功能。 注册触摸传感器的睡眠唤醒功能后,处于睡眠状态下的芯片仍将继续保持对触摸传感器的采样,这将会导致芯片睡眠后的功耗增加,可通过减少充放电次数、增加采样间隔等方式来降低功耗。 @@ -420,8 +377,8 @@ 若需要在睡眠过程中进行读数、配置等操作,可通过运行在 :doc:`超低功耗协处理器 ULP <../system/ulp>` 上的触摸传感器驱动 ``components/ulp/ulp_riscv/ulp_core/include/ulp_riscv_touch_ulp_core.h`` 实现。 - - 浅睡眠状态唤醒:通过指定 :cpp:member:`slp_wakeup_lvl` 为 :cpp:enumerator:`TOUCH_LIGHT_SLEEP_WAKEUP` 即可启用触摸传感器浅睡眠唤醒功能。注意任何已注册的触摸传感器通道都会在浅睡眠状态下保持采样并支持唤醒浅睡眠。 - - 深睡眠状态唤醒:启用触摸传感器深睡眠唤醒功能除了指定 :cpp:member:`slp_wakeup_lvl` 为 :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP` 外,还需要指定深睡眠唤醒通道 :cpp:member:`deep_slp_chan`,注意只有该指定的通道才会在深睡眠状态下保持采样以及唤醒,以此降低在深睡眠状态下的功耗。此外,若需要在深度睡眠下使用另一套低功耗的配置来进一步降低功耗,可以通过 :cpp:member:`deep_slp_sens_cfg` 额外指定一套低功耗配置,在进入深睡眠前,驱动会应用这套配置,从深睡眠状态唤醒后,则会重新配置到之前的配置。请注意当 :cpp:member:`slp_wakeup_lvl` 配置为 :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP` 后,触摸传感器不仅能唤醒深睡眠状态,还能唤醒浅睡眠状态。 + - Light-sleep 状态唤醒:通过指定 :cpp:member:`slp_wakeup_lvl` 为 :cpp:enumerator:`TOUCH_LIGHT_SLEEP_WAKEUP` 即可启用触摸传感器 Light-sleep 唤醒功能。注意任何已注册的触摸传感器通道都会在 Light-sleep 状态下保持采样并支持唤醒 Light-sleep。 + - Deep-sleep 状态唤醒:启用触摸传感器 Deep-sleep 唤醒功能除了指定 :cpp:member:`slp_wakeup_lvl` 为 :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP` 外,还需要指定 Deep-sleep 唤醒通道 :cpp:member:`deep_slp_chan`,注意只有该指定的通道才会在 Deep-sleep 状态下保持采样以及唤醒,以此降低在 Deep-sleep 状态下的功耗。此外,若需要在深度睡眠下使用另一套低功耗的配置来进一步降低功耗,可以通过 :cpp:member:`deep_slp_sens_cfg` 额外指定一套低功耗配置,在进入 Deep-sleep 前,驱动会应用这套配置,从 Deep-sleep 状态唤醒后,则会重新配置到之前的配置。请注意当 :cpp:member:`slp_wakeup_lvl` 配置为 :cpp:enumerator:`TOUCH_DEEP_SLEEP_WAKEUP` 后,触摸传感器不仅能唤醒 Deep-sleep 状态,还能唤醒 Light-sleep 状态。 若需要注销睡眠唤醒功能,可再次调用 :cpp:func:`touch_sensor_config_sleep_wakeup` 并将第二个参数(即 :cpp:type:`touch_sleep_config_t` 的配置结构体指针)设为 ``NULL`` 来注销睡眠唤醒功能。 @@ -430,7 +387,7 @@ touch_sleep_config_t light_slp_cfg = { .slp_wakeup_lvl = TOUCH_LIGHT_SLEEP_WAKEUP, }; - // 注册浅睡眠唤醒功能 + // 注册 Light-sleep 唤醒功能 ESP_ERROR_CHECK(touch_sensor_config_sleep_wakeup(sens_handle, &light_slp_cfg)); // ... // 注销睡眠唤醒功能 @@ -438,21 +395,50 @@ touch_sleep_config_t deep_slp_cfg = { .slp_wakeup_lvl = TOUCH_DEEP_SLEEP_WAKEUP, .deep_slp_chan = dslp_chan_handle, - // 其他深睡眠唤醒配置 + // 其他 Deep-sleep 唤醒配置 // ... }; - // 注册深睡眠唤醒功能 + // 注册 Deep-sleep 唤醒功能 ESP_ERROR_CHECK(touch_sensor_config_sleep_wakeup(sens_handle, &deep_slp_cfg)); +.. _touch-denoise-chan: + +.. only:: SOC_TOUCH_SUPPORT_DENOISE_CHAN + + 去噪通道配置 + ^^^^^^^^^^^^ + + {IDF_TARGET_NAME} 支持通过去噪通道抑制内部背景噪声。可通过调用 :cpp:func:`touch_sensor_config_denoise_channel` 并配置 :cpp:type:`touch_denoise_chan_config_t` 来注册去噪通道。 + + 去噪通道是一个没有引出的内部触摸通道。去噪通道使能之后,其他触摸通道的采样值会自动减去去噪通道的采样值,从而实现去噪。因此最终测量结果相比去噪前会有一定衰减。 + + 除了常规的触摸通道配置,去噪通道还可以配置 :cpp:member:`touch_denoise_chan_config_t::ref_cap` 来指定连接到该通道上的参考电容大小,以及 :cpp:member:`touch_denoise_chan_config_t::resolution` 来指定噪声抑制的分辨率。分辨率越高,去噪通道采样值越大越精确,抑制效果越好,但同时其他触摸通道在自动扣除去噪通道采样值后的测量值衰减也越大。 + + 例如,去噪通道分辨率为 :cpp:enumerator:`touch_denoise_chan_resolution_t::TOUCH_DENOISE_CHAN_RESOLUTION_BIT8`,即去噪通道采样值最大为 ``255``。假设此时一个常规通道实际采样值为 ``10000``,去噪通道采样值假设为 ``100``,则该常规通道扣除去噪通道采样值后的读数为 ``10000 - 100 = 9900``;若分辨率改为 :cpp:enumerator:`touch_denoise_chan_resolution_t::TOUCH_DENOISE_CHAN_RESOLUTION_BIT12`,即去噪通道采样值最大为 ``4095``,去噪通道分辨率提升 ``16`` 倍,去噪通道采样值大概为 ``100 * 16 = 1600``。此时该常规通道扣除去噪通道采样值后的读数为 ``10000 - 1600 = 8400``。 + + 若需要注销去噪通道功能,可再次调用 :cpp:func:`touch_sensor_config_denoise_channel` 并将第二个参数(即 :cpp:type:`touch_denoise_chan_config_t` 的配置结构体指针)设为 ``NULL`` 来注销去噪通道功能。 + + .. code-block:: c + + touch_denoise_chan_config_t denoise_cfg = { + // 去噪通道配置 + // ... + } + // 注册去噪通道 + ESP_ERROR_CHECK(touch_sensor_config_denoise_channel(sens_handle, &denoise_cfg)); + // ... + // 注销去噪通道 + ESP_ERROR_CHECK(touch_sensor_config_denoise_channel(sens_handle, NULL)); + 应用示例 -------- - - :example:`peripherals/touch_sensor/touch_sensor_v3` 演示了如何注册触摸通道并读取数据,并说明了硬件要求及项目配置。 + - :example:`peripherals/touch_sensor/touch_sens_basic` 演示了如何注册触摸通道并读取数据,并说明了硬件要求及项目配置。 API 参考 ---------- -.. only:: esp32p4 +.. only:: esp32p4 or esp32s2 or esp32s3 .. include-build-file:: inc/touch_sens.inc .. include-build-file:: inc/touch_sens_types.inc diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc new file mode 100644 index 00000000000..dcaf2a6ba77 --- /dev/null +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32p4.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - 通道 + - GPIO + + * - CH0 + - IO2 + + * - CH1 + - IO3 + + * - CH2 + - IO4 + + * - CH3 + - IO5 + + * - CH4 + - IO6 + + * - CH5 + - IO7 + + * - CH6 + - IO8 + + * - CH7 + - IO9 + + * - CH8 + - IO10 + + * - CH9 + - IO11 + + * - CH10 + - IO12 + + * - CH11 + - IO13 + + * - CH12 + - IO14 + + * - CH13 + - IO15 + + * - CH14 + - 未引出 + +--- diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s2.inc b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s2.inc new file mode 100644 index 00000000000..736efa5ed8a --- /dev/null +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s2.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - 通道 + - GPIO + + * - CH0 + - 未引出 + + * - CH1 + - IO1 + + * - CH2 + - IO2 + + * - CH3 + - IO3 + + * - CH4 + - IO4 + + * - CH5 + - IO5 + + * - CH6 + - IO6 + + * - CH7 + - IO7 + + * - CH8 + - IO8 + + * - CH9 + - IO9 + + * - CH10 + - IO10 + + * - CH11 + - IO11 + + * - CH12 + - IO12 + + * - CH13 + - IO13 + + * - CH14 + - IO14 + +--- diff --git a/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s3.inc b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s3.inc new file mode 100644 index 00000000000..736efa5ed8a --- /dev/null +++ b/docs/zh_CN/api-reference/peripherals/cap_touch_sens/esp32s3.inc @@ -0,0 +1,64 @@ +.. This file gets included from other .rst files in this folder. +.. It contains target-specific snippets. +.. Comments and '---' lines act as delimiters. +.. +.. This is necessary mainly because RST doesn't support substitutions +.. (defined in RST, not in Python) inside code blocks. If that is ever implemented, +.. These code blocks can be moved back to the main .rst files, with target-specific +.. file names being replaced by substitutions. + +.. touch-chan-mapping + +.. list-table:: + :header-rows: 1 + :widths: 20 20 + + * - 通道 + - GPIO + + * - CH0 + - 未引出 + + * - CH1 + - IO1 + + * - CH2 + - IO2 + + * - CH3 + - IO3 + + * - CH4 + - IO4 + + * - CH5 + - IO5 + + * - CH6 + - IO6 + + * - CH7 + - IO7 + + * - CH8 + - IO8 + + * - CH9 + - IO9 + + * - CH10 + - IO10 + + * - CH11 + - IO11 + + * - CH12 + - IO12 + + * - CH13 + - IO13 + + * - CH14 + - IO14 + +--- diff --git a/docs/zh_CN/api-reference/peripherals/index.rst b/docs/zh_CN/api-reference/peripherals/index.rst index ea2198b57a3..bc60f6a4894 100644 --- a/docs/zh_CN/api-reference/peripherals/index.rst +++ b/docs/zh_CN/api-reference/peripherals/index.rst @@ -42,8 +42,8 @@ :SOC_SPI_SUPPORT_SLAVE_HD_VER2: spi_slave_hd :SOC_JPEG_CODEC_SUPPORTED: jpeg :SOC_TEMP_SENSOR_SUPPORTED: temp_sensor - :SOC_TOUCH_SENSOR_SUPPORTED and not esp32p4: touch_pad - :esp32p4: cap_touch_sens + :esp32: touch_pad + :SOC_TOUCH_SENSOR_SUPPORTED and not esp32: cap_touch_sens :esp32s2: touch_element :SOC_TWAI_SUPPORTED: twai uart diff --git a/docs/zh_CN/api-reference/peripherals/touch_element.rst b/docs/zh_CN/api-reference/peripherals/touch_element.rst index 22c22ad58b7..277471e08ce 100644 --- a/docs/zh_CN/api-reference/peripherals/touch_element.rst +++ b/docs/zh_CN/api-reference/peripherals/touch_element.rst @@ -6,7 +6,11 @@ 概述 -------- -触摸元件库是基于触摸传感器驱动设计的高度抽象的元件库,该库提供了统一且友好的软件接口,可以快速构建电容式触摸传感器的应用。有关触摸传感器驱动 API 的更多信息,请参阅 :doc:`../peripherals/touch_pad`。 +触摸元件库是基于触摸传感器驱动设计的高度抽象的元件库,该库提供了统一且友好的软件接口,可以快速构建电容式触摸传感器的应用。 + +.. warning:: + + 目前的触摸元件库仍然基于旧的触摸传感器驱动。如您不需要使用触摸元件库,请参考新的 :doc:`电容式触摸传感器 ` 驱动。 架构 ^^^^^^^^^^^^ diff --git a/docs/zh_CN/api-reference/peripherals/touch_pad.rst b/docs/zh_CN/api-reference/peripherals/touch_pad.rst index 4879ece09e6..b5a38a87396 100644 --- a/docs/zh_CN/api-reference/peripherals/touch_pad.rst +++ b/docs/zh_CN/api-reference/peripherals/touch_pad.rst @@ -5,6 +5,12 @@ {IDF_TARGET_TOUCH_SENSOR_VERSION:default="v2", esp32="v1"} +.. only:: esp32s2 or esp32s3 + + .. warning:: + + 该文档所演示的 Touch 驱动已弃用, 请移步新文档查看最新的 Touch 驱动: :doc:`Capacitive Touch Sensor `. + 概述 ------------ @@ -146,8 +152,6 @@ 该函数也可以用于检查触碰和释放触摸传感器时传感器读数变化范围,然后根据这些信息设定触摸传感器的触摸阈值。 -请参考应用示例 :example:`peripherals/touch_sensor/touch_sensor_{IDF_TARGET_TOUCH_SENSOR_VERSION}/touch_pad_read`,查看如何使用读取触摸传感器数据。 - 测量方式 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -250,7 +254,7 @@ 也可以将硬件触摸监测连接至中断,详细介绍见下一章节。 -如果测量中存在噪声,且电容变化幅度较小,硬件触摸监测结果可能就不太理想。如需解决这一问题,不建议使用硬件监测或中断信号,建议在自己的应用程序中进行采样滤波,并执行触摸监测。请参考 :example:`peripherals/touch_sensor/touch_sensor_{IDF_TARGET_TOUCH_SENSOR_VERSION}/touch_pad_interrupt`,查看以上两种触摸监测的实现方式。 +如果测量中存在噪声,且电容变化幅度较小,硬件触摸监测结果可能就不太理想。如需解决这一问题,不建议使用硬件监测或中断信号,建议在自己的应用程序中进行采样滤波,并执行触摸监测。 中断触发 ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,9 +304,9 @@ .. only:: esp32s2 or esp32s3 - - :example:`peripherals/touch_sensor/touch_sensor_v2/touch_pad_read` 演示了如何在 {IDF_TARGET_NAME} 上读取并显示电容触摸传感器的原始值,包括如何校准传感器以及监测触摸动作。 - - :example:`peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt` 演示了如何设置 {IDF_TARGET_NAME} 的电容触摸板外设,使其在被触摸时触发中断,以及在需要更高触摸监测灵敏度的传感器设计中,如何通过软件来监测触摸事件。 + .. warning:: + 使用老驱动的例程已移除,新驱动用法请参考 :example:`peripherals/touch_sensor/touch_sens_basic`。 .. _touch_pad-api-reference: @@ -321,4 +325,4 @@ GPIO 宏查找表 2. ``TOUCH_PAD_GPIO4_CHANNEL`` 定义了 GPIO 4 的通道(即通道 0)。 .. include-build-file:: inc/touch_sensor_channel.inc -.. include-build-file:: inc/touch_sensor_types.inc +.. include-build-file:: inc/touch_sensor_legacy_types.inc diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index 1764bbee248..98739f2580f 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -420,24 +420,19 @@ examples/peripherals/touch_sensor/touch_element: - if: IDF_TARGET in ["esp32s2", "esp32s3"] reason: only supports esp32s2 and esp32s3 -examples/peripherals/touch_sensor/touch_sensor_v1: - disable: - - if: SOC_TOUCH_SENSOR_VERSION != 1 - -examples/peripherals/touch_sensor/touch_sensor_v2: +examples/peripherals/touch_sensor/touch_sens_basic: disable: - - if: SOC_TOUCH_SENSOR_VERSION != 2 - -examples/peripherals/touch_sensor/touch_sensor_v3: - disable: - - if: SOC_TOUCH_SENSOR_VERSION != 3 - disable_test: - - if: IDF_TARGET == "esp32p4" + - if: SOC_TOUCH_SENSOR_SUPPORTED != 1 + - if: SOC_TOUCH_SENSOR_VERSION == 1 temporary: true - reason: the runners do not support the pins for touch sensor + reason: not supported yet depends_components: - esp_driver_touch_sens +examples/peripherals/touch_sensor/touch_sensor_v1: + disable: + - if: SOC_TOUCH_SENSOR_VERSION != 1 + examples/peripherals/twai/twai_alert_and_recovery: disable: - if: SOC_TWAI_SUPPORTED != 1 diff --git a/examples/peripherals/touch_sensor/touch_sensor_v3/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sens_basic/CMakeLists.txt similarity index 100% rename from examples/peripherals/touch_sensor/touch_sensor_v3/CMakeLists.txt rename to examples/peripherals/touch_sensor/touch_sens_basic/CMakeLists.txt diff --git a/examples/peripherals/touch_sensor/touch_sensor_v3/README.md b/examples/peripherals/touch_sensor/touch_sens_basic/README.md similarity index 97% rename from examples/peripherals/touch_sensor/touch_sensor_v3/README.md rename to examples/peripherals/touch_sensor/touch_sens_basic/README.md index 650d3a24a66..c7381427a82 100644 --- a/examples/peripherals/touch_sensor/touch_sensor_v3/README.md +++ b/examples/peripherals/touch_sensor/touch_sens_basic/README.md @@ -1,5 +1,5 @@ -| Supported Targets | ESP32-P4 | -| ----------------- | -------- | +| Supported Targets | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | -------- | -------- | -------- | # Capacity Touch Sensor Example (for hardware version 3) diff --git a/examples/peripherals/touch_sensor/touch_sensor_v3/main/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sens_basic/main/CMakeLists.txt similarity index 58% rename from examples/peripherals/touch_sensor/touch_sensor_v3/main/CMakeLists.txt rename to examples/peripherals/touch_sensor/touch_sens_basic/main/CMakeLists.txt index 8c6b0002d3b..b39f3c6de9c 100644 --- a/examples/peripherals/touch_sensor/touch_sensor_v3/main/CMakeLists.txt +++ b/examples/peripherals/touch_sensor/touch_sens_basic/main/CMakeLists.txt @@ -1,3 +1,3 @@ -idf_component_register(SRCS "touch_sens_v3_example_main.c" +idf_component_register(SRCS "touch_sens_basic_example_main.c" REQUIRES esp_driver_touch_sens INCLUDE_DIRS ".") diff --git a/examples/peripherals/touch_sensor/touch_sensor_v3/main/touch_sens_v3_example_main.c b/examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_basic_example_main.c similarity index 71% rename from examples/peripherals/touch_sensor/touch_sensor_v3/main/touch_sens_v3_example_main.c rename to examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_basic_example_main.c index 77d37045f08..5973a1d1019 100644 --- a/examples/peripherals/touch_sensor/touch_sensor_v3/main/touch_sens_v3_example_main.c +++ b/examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_basic_example_main.c @@ -10,11 +10,7 @@ #include "freertos/task.h" #include "driver/touch_sens.h" #include "esp_check.h" - -// Touch version 3 supports multiple sample configurations -#define EXAMPLE_TOUCH_SAMPLE_CFG_NUM 1 // Up to 'TOUCH_SAMPLE_CFG_NUM' -#define EXAMPLE_TOUCH_CHANNEL_NUM 4 -#define EXAMPLE_TOUCH_CHAN_INIT_SCAN_TIMES 3 +#include "touch_sens_example_config.h" static touch_sensor_handle_t s_sens_handle = NULL; static touch_channel_handle_t s_chan_handle[EXAMPLE_TOUCH_CHANNEL_NUM] = {}; @@ -22,6 +18,13 @@ static touch_channel_handle_t s_chan_handle[EXAMPLE_TOUCH_CHANNEL_NUM] = {}; static float s_thresh2bm_ratio[EXAMPLE_TOUCH_CHANNEL_NUM] = { [0 ... EXAMPLE_TOUCH_CHANNEL_NUM - 1] = 0.015f, // 1.5% }; +// The touch channel IDs that used in this example +static int s_channel_id[EXAMPLE_TOUCH_CHANNEL_NUM] = { + TOUCH_MIN_CHAN_ID, + TOUCH_MIN_CHAN_ID + 1, + TOUCH_MIN_CHAN_ID + 2, + TOUCH_MIN_CHAN_ID + 3, +}; bool example_touch_on_active_callback(touch_sensor_handle_t sens_handle, const touch_active_event_data_t *event, void *user_ctx) { @@ -56,7 +59,7 @@ static void example_touch_do_initial_scanning(void) ESP_ERROR_CHECK(touch_channel_read_data(s_chan_handle[i], TOUCH_CHAN_DATA_TYPE_BENCHMARK, benchmark)); /* Calculate the proper active thresholds regarding the initial benchmark */ printf("[CH %d]", i); - touch_channel_config_t chan_cfg = {}; + touch_channel_config_t chan_cfg = EXAMPLE_TOUCH_CHAN_CFG_DEFAULT(); for (int j = 0; j < EXAMPLE_TOUCH_SAMPLE_CFG_NUM; j++) { chan_cfg.active_thresh[j] = (uint32_t)(benchmark[j] * s_thresh2bm_ratio[i]); printf(" %d: %"PRIu32", %"PRIu32"\t", j, benchmark[j], chan_cfg.active_thresh[j]); @@ -70,15 +73,7 @@ static void example_touch_do_initial_scanning(void) void app_main(void) { /* Use the default sample configurations */ - touch_sensor_sample_config_t sample_cfg[EXAMPLE_TOUCH_SAMPLE_CFG_NUM] = { - TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(1, 1, 1), -#if EXAMPLE_TOUCH_SAMPLE_CFG_NUM > 1 - TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(2, 1, 1), -#endif -#if EXAMPLE_TOUCH_SAMPLE_CFG_NUM > 2 - TOUCH_SENSOR_V3_DEFAULT_SAMPLE_CONFIG(4, 1, 1), -#endif - }; + touch_sensor_sample_config_t sample_cfg[EXAMPLE_TOUCH_SAMPLE_CFG_NUM] = EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT(); /* Allocate new touch controller handle */ touch_sensor_config_t sens_cfg = TOUCH_SENSOR_DEFAULT_BASIC_CONFIG(EXAMPLE_TOUCH_SAMPLE_CFG_NUM, sample_cfg); ESP_ERROR_CHECK(touch_sensor_new_controller(&sens_cfg, &s_sens_handle)); @@ -87,37 +82,27 @@ void app_main(void) touch_sensor_filter_config_t filter_cfg = TOUCH_SENSOR_DEFAULT_FILTER_CONFIG(); ESP_ERROR_CHECK(touch_sensor_config_filter(s_sens_handle, &filter_cfg)); + /** Following is about setting the touch channel active threshold of each sample configuration. + * + * @How to Determine: + * As the actual threshold is affected by various factors in real application, + * we need to run the touch app first to get the `benchmark` and the `smooth_data` that being touched. + * + * @Formula: + * threshold = benchmark * coeff, (coeff for example, 0.1%~20%) + * Please adjust the coeff to guarantee the threshold < smooth_data - benchmark + * + * @Typical Practice: + * Normally, we can't determine a fixed threshold at the beginning, + * but we can give them estimated values first and update them after an initial scanning (like this example), + * Step1: set an estimated value for each sample configuration first. (i.e., here) + * Step2: then reconfig the threshold after the initial scanning.(see `example_touch_do_initial_scanning`) + * Step3: adjust the `s_thresh2bm_ratio` to a proper value to trigger the active callback + */ + touch_channel_config_t chan_cfg = EXAMPLE_TOUCH_CHAN_CFG_DEFAULT(); /* Allocate new touch channel on the touch controller */ - touch_channel_config_t chan_cfg = { - /** Set the touch channel active threshold of each sample configuration. - * - * @How to Determine: - * As the actual threshold is affected by various factors in real application, - * we need to run the touch app first to get the `benchmark` and the `smooth_data` that being touched. - * - * @Formula: - * threshold = benchmark * coeff, (coeff for example, 0.1%~20%) - * Please adjust the coeff to guarantee the threshold < smooth_data - benchmark - * - * @Typical Practice: - * Normally, we can't determine a fixed threshold at the beginning, - * but we can give them estimated values first and update them after an initial scanning (like this example), - * Step1: set an estimated value for each sample configuration first. (i.e., here) - * Step2: then reconfig the threshold after the initial scanning.(see `example_touch_do_initial_scanning`) - * Step3: adjust the `s_thresh2bm_ratio` to a proper value to trigger the active callback - */ - .active_thresh = { - 1000, // estimated active threshold of sample configuration 0 -#if EXAMPLE_TOUCH_SAMPLE_CFG_NUM > 1 - 2500, // estimated active threshold of sample configuration 1 -#endif -#if EXAMPLE_TOUCH_SAMPLE_CFG_NUM > 2 - 5000, // estimated active threshold of sample configuration 2 -#endif - }, - }; for (int i = 0; i < EXAMPLE_TOUCH_CHANNEL_NUM; i++) { - ESP_ERROR_CHECK(touch_sensor_new_channel(s_sens_handle, i, &chan_cfg, &s_chan_handle[i])); + ESP_ERROR_CHECK(touch_sensor_new_channel(s_sens_handle, s_channel_id[i], &chan_cfg, &s_chan_handle[i])); } /* Do the initial scanning to initialize the touch channel data @@ -149,14 +134,14 @@ void app_main(void) for (int i = 0; i < EXAMPLE_TOUCH_CHANNEL_NUM; i++) { /* Read and print the benchmark of each sample configuration */ ESP_ERROR_CHECK(touch_channel_read_data(s_chan_handle[i], TOUCH_CHAN_DATA_TYPE_BENCHMARK, benchmark)); - printf("benchmark [CH %d]:", i); + printf("benchmark [CH %d]:", s_channel_id[i]); for (int j = 0; j < EXAMPLE_TOUCH_SAMPLE_CFG_NUM; j++) { printf(" %"PRIu32, benchmark[j]); } printf("\n"); /* Read and print the channel data of each sample configuration */ ESP_ERROR_CHECK(touch_channel_read_data(s_chan_handle[i], TOUCH_CHAN_DATA_TYPE_SMOOTH, chan_data)); - printf("chan_data [CH %d]:", i); + printf("chan_data [CH %d]:", s_channel_id[i]); for (int j = 0; j < EXAMPLE_TOUCH_SAMPLE_CFG_NUM; j++) { printf(" %"PRIu32, chan_data[j]); } diff --git a/examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_example_config.h b/examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_example_config.h new file mode 100644 index 00000000000..856922df767 --- /dev/null +++ b/examples/peripherals/touch_sensor/touch_sens_basic/main/touch_sens_example_config.h @@ -0,0 +1,54 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: CC0-1.0 + */ + +#pragma once + +#include "driver/touch_sens.h" +#include "esp_assert.h" + +#ifdef __cplusplus +extern "C" { +#endif + +// Touch version 3 supports multiple sample configurations +#define EXAMPLE_TOUCH_SAMPLE_CFG_NUM TOUCH_SAMPLE_CFG_NUM // Up to 'TOUCH_SAMPLE_CFG_NUM' +#define EXAMPLE_TOUCH_CHANNEL_NUM 4 +#define EXAMPLE_TOUCH_CHAN_INIT_SCAN_TIMES 3 + +ESP_STATIC_ASSERT(EXAMPLE_TOUCH_SAMPLE_CFG_NUM <= TOUCH_SAMPLE_CFG_NUM, "sample configuration number exceed the supported number"); +ESP_STATIC_ASSERT(EXAMPLE_TOUCH_CHANNEL_NUM <= (TOUCH_MAX_CHAN_ID - TOUCH_MIN_CHAN_ID + 1), "touch channel number exceed the max supported number "); + +#if SOC_TOUCH_SENSOR_VERSION == 2 +#define EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT() {TOUCH_SENSOR_V2_DEFAULT_SAMPLE_CONFIG(500, TOUCH_VOLT_LIM_L_0V5, TOUCH_VOLT_LIM_H_2V2)} +#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \ + .active_thresh = {2000}, \ + .charge_speed = TOUCH_CHARGE_SPEED_7, \ + .init_charge_volt = TOUCH_INIT_CHARGE_VOLT_LOW, \ +} +#elif SOC_TOUCH_SENSOR_VERSION == 3 +#define EXAMPLE_TOUCH_SAMPLE_CFG(res, cap, coarse_freq_tune, fine_freq_tune) { \ + .div_num = 8, \ + .charge_times = 500, \ + .rc_filter_res = res, \ + .rc_filter_cap = cap, \ + .low_drv = fine_freq_tune, \ + .high_drv = coarse_freq_tune, \ + .bias_volt = 5, \ + .bypass_shield_output = false, \ +} +#define EXAMPLE_TOUCH_SAMPLE_CFG_DEFAULT() {EXAMPLE_TOUCH_SAMPLE_CFG(3, 29, 8, 3),\ + EXAMPLE_TOUCH_SAMPLE_CFG(2, 88, 31, 7), \ + EXAMPLE_TOUCH_SAMPLE_CFG(3, 10, 31, 7)} +#define EXAMPLE_TOUCH_CHAN_CFG_DEFAULT() { \ + .active_thresh = {1000, 2500, 5000}, \ +} +#else +#error "Target not supported" +#endif + +#ifdef __cplusplus +} +#endif diff --git a/examples/peripherals/touch_sensor/touch_sensor_v3/pytest_touch_sens_v3.py b/examples/peripherals/touch_sensor/touch_sens_basic/pytest_touch_sens_basic.py similarity index 82% rename from examples/peripherals/touch_sensor/touch_sensor_v3/pytest_touch_sens_v3.py rename to examples/peripherals/touch_sensor/touch_sens_basic/pytest_touch_sens_basic.py index f03c56c2ffd..2dbede48e3d 100644 --- a/examples/peripherals/touch_sensor/touch_sensor_v3/pytest_touch_sens_v3.py +++ b/examples/peripherals/touch_sensor/touch_sens_basic/pytest_touch_sens_basic.py @@ -4,8 +4,9 @@ from pytest_embedded import Dut +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 @pytest.mark.esp32p4 -@pytest.mark.temp_skip_ci(targets=['esp32p4'], reason='esp32p4 runners do not support touch pins') @pytest.mark.generic def test_touch_sens_v3(dut: Dut) -> None: dut.expect_exact('Initial benchmark and new threshold are:') diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/CMakeLists.txt deleted file mode 100644 index c7504c7d03f..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# The following lines of boilerplate have to be in your project's CMakeLists -# in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.16) - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(touch_pad_interrupt) diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/README.md b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/README.md deleted file mode 100644 index d871b21849c..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/README.md +++ /dev/null @@ -1,60 +0,0 @@ -| Supported Targets | ESP32-S2 | ESP32-S3 | -| ----------------- | -------- | -------- | - -# Touch Pad Interrupt Example - -(See the README.md file in the upper level 'examples' directory for more information about examples.) - -This example demonstrates how to set up ESP32-S2/S3's capacitive touch pad peripheral to trigger interrupt when a pad is touched. It also shows how to detect the touch event by the software for sensor designs when greater touch detection sensitivity is required. - -- The hardware interrupt mode occupies less CPU resources, but we can only apply fixed threshold and software algorithms are also impossibile. -- The polling mode is flexible and supports various software algorithms. However, it comsumes more CPU. - -ESP32-S2/S3 supports touch detection by configuring hardware registers. The hardware periodically detects the pulse counts. If the number of pulse counts exceeds the set threshold, a hardware interrupt will be generated to notify the application layer that a certain touch sensor channel may be triggered. - -For a simpler example how to configure and read capacitive touch pads, please refer to [touch_pad_read](../touch_pad_read). - -## How to use example - -### Hardware Required - -* A development board with ESP32-S2 or ESP32-S3 chip -* A touch extension board like [esp32-s2-touch-devkit-1](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s2/esp32-s2-touch-devkit-1/user_guide.html) - -### Build and Flash - -Build the project and flash it to the board, then run monitor tool to view serial output: - -``` -idf.py -p PORT flash monitor -``` - -(Replace PORT with the name of the serial port to use.) - -(To exit the serial monitor, type ``Ctrl-]``.) - -See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. - -## Example Output - -The application cycles between the interrupt mode and the pooling mode with a filter, to compare performance of the touch sensor system between both scenarios: - -``` -I (304) Touch pad: Initializing touch pad -I (304) Touch pad: Denoise function init -I (304) Touch pad: touch pad waterproof init -I (304) Touch pad: touch pad filter init 2 -I (414) Touch pad: test init: touch pad [7] base 7382, thresh 1476 -I (414) Touch pad: test init: touch pad [9] base 7349, thresh 1469 -I (414) Touch pad: test init: touch pad [11] base 8047, thresh 1609 -I (414) Touch pad: test init: touch pad [13] base 8104, thresh 810 -I (5954) Touch pad: TouchSensor [9] be actived, status mask 0x200 -W (6034) Touch pad: TouchSensor [13] be actived, enter guard mode -W (6034) Touch pad: In guard mode. No response -W (6174) Touch pad: TouchSensor [13] be actived, exit guard mode -I (6194) Touch pad: TouchSensor [9] be inactived, status mask 0x0 -``` - -## Troubleshooting - -For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/CMakeLists.txt deleted file mode 100644 index 94fac9872e9..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "tp_interrupt_main.c" - INCLUDE_DIRS ".") diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/tp_interrupt_main.c b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/tp_interrupt_main.c deleted file mode 100644 index e8a671ecfcb..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/main/tp_interrupt_main.c +++ /dev/null @@ -1,211 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: CC0-1.0 - */ - -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/queue.h" -#include "esp_log.h" -#include "driver/touch_pad.h" - -static const char *TAG = "Touch pad"; - -static QueueHandle_t que_touch = NULL; -typedef struct touch_msg { - touch_pad_intr_mask_t intr_mask; - uint32_t pad_num; - uint32_t pad_status; - uint32_t pad_val; -} touch_event_t; - -#define TOUCH_BUTTON_NUM 4 -#define TOUCH_BUTTON_WATERPROOF_ENABLE 1 -#define TOUCH_BUTTON_DENOISE_ENABLE 1 -#define TOUCH_CHANGE_CONFIG 0 - -static const touch_pad_t button[TOUCH_BUTTON_NUM] = { - TOUCH_PAD_NUM7, // 'SELECT' button. - TOUCH_PAD_NUM9, // 'MENU' button. - TOUCH_PAD_NUM11, // 'BACK' button. - TOUCH_PAD_NUM13, // Guard ring for waterproof design. - // If this pad be touched, other pads no response. -}; - -/* - * Touch threshold. The threshold determines the sensitivity of the touch. - * This threshold is derived by testing changes in readings from different touch channels. - * If (raw_data - benchmark) > benchmark * threshold, the pad be activated. - * If (raw_data - benchmark) < benchmark * threshold, the pad be inactivated. - */ -static const float button_threshold[TOUCH_BUTTON_NUM] = { - 0.2, // 20%. - 0.2, // 20%. - 0.2, // 20%. - 0.1, // 10%. -}; - -/* - Handle an interrupt triggered when a pad is touched. - Recognize what pad has been touched and save it in a table. - */ -static void touchsensor_interrupt_cb(void *arg) -{ - int task_awoken = pdFALSE; - touch_event_t evt; - - evt.intr_mask = touch_pad_read_intr_status_mask(); - evt.pad_status = touch_pad_get_status(); - evt.pad_num = touch_pad_get_current_meas_channel(); - - xQueueSendFromISR(que_touch, &evt, &task_awoken); - if (task_awoken == pdTRUE) { - portYIELD_FROM_ISR(); - } -} - -static void tp_example_set_thresholds(void) -{ - uint32_t touch_value; - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - //read benchmark value - touch_pad_read_benchmark(button[i], &touch_value); - //set interrupt threshold. - touch_pad_set_thresh(button[i], touch_value * button_threshold[i]); - ESP_LOGI(TAG, "touch pad [%d] base %"PRIu32", thresh %"PRIu32, \ - button[i], touch_value, (uint32_t)(touch_value * button_threshold[i])); - } -} - -static void touchsensor_filter_set(touch_filter_mode_t mode) -{ - /* Filter function */ - touch_filter_config_t filter_info = { - .mode = mode, // Test jitter and filter 1/4. - .debounce_cnt = 1, // 1 time count. - .noise_thr = 0, // 50% - .jitter_step = 4, // use for jitter mode. - .smh_lvl = TOUCH_PAD_SMOOTH_IIR_2, - }; - touch_pad_filter_set_config(&filter_info); - touch_pad_filter_enable(); - ESP_LOGI(TAG, "touch pad filter init"); -} - -static void tp_example_read_task(void *pvParameter) -{ - touch_event_t evt = {0}; - static uint8_t guard_mode_flag = 0; - /* Wait touch sensor init done */ - vTaskDelay(50 / portTICK_PERIOD_MS); - tp_example_set_thresholds(); - - while (1) { - int ret = xQueueReceive(que_touch, &evt, (TickType_t)portMAX_DELAY); - if (ret != pdTRUE) { - continue; - } - if (evt.intr_mask & TOUCH_PAD_INTR_MASK_ACTIVE) { - /* if guard pad be touched, other pads no response. */ - if (evt.pad_num == button[3]) { - guard_mode_flag = 1; - ESP_LOGW(TAG, "TouchSensor [%"PRIu32"] be activated, enter guard mode", evt.pad_num); - } else { - if (guard_mode_flag == 0) { - ESP_LOGI(TAG, "TouchSensor [%"PRIu32"] be activated, status mask 0x%"PRIu32"", evt.pad_num, evt.pad_status); - } else { - ESP_LOGW(TAG, "In guard mode. No response"); - } - } - } - if (evt.intr_mask & TOUCH_PAD_INTR_MASK_INACTIVE) { - /* if guard pad be touched, other pads no response. */ - if (evt.pad_num == button[3]) { - guard_mode_flag = 0; - ESP_LOGW(TAG, "TouchSensor [%"PRIu32"] be inactivated, exit guard mode", evt.pad_num); - } else { - if (guard_mode_flag == 0) { - ESP_LOGI(TAG, "TouchSensor [%"PRIu32"] be inactivated, status mask 0x%"PRIu32, evt.pad_num, evt.pad_status); - } - } - } - if (evt.intr_mask & TOUCH_PAD_INTR_MASK_SCAN_DONE) { - ESP_LOGI(TAG, "The touch sensor group measurement is done [%"PRIu32"].", evt.pad_num); - } - if (evt.intr_mask & TOUCH_PAD_INTR_MASK_TIMEOUT) { - /* Add your exception handling in here. */ - ESP_LOGI(TAG, "Touch sensor channel %"PRIu32" measure timeout. Skip this exception channel!!", evt.pad_num); - touch_pad_timeout_resume(); // Point on the next channel to measure. - } - } -} - -void app_main(void) -{ - if (que_touch == NULL) { - que_touch = xQueueCreate(TOUCH_BUTTON_NUM, sizeof(touch_event_t)); - } - // Initialize touch pad peripheral, it will start a timer to run a filter - ESP_LOGI(TAG, "Initializing touch pad"); - /* Initialize touch pad peripheral. */ - touch_pad_init(); - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - touch_pad_config(button[i]); - } - -#if TOUCH_CHANGE_CONFIG - /* If you want change the touch sensor default setting, please write here(after initialize). There are examples: */ - touch_pad_set_measurement_interval(TOUCH_PAD_SLEEP_CYCLE_DEFAULT); - touch_pad_set_charge_discharge_times(TOUCH_PAD_MEASURE_CYCLE_DEFAULT); - touch_pad_set_voltage(TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD); - touch_pad_set_idle_channel_connect(TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT); - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - touch_pad_set_cnt_mode(button[i], TOUCH_PAD_SLOPE_DEFAULT, TOUCH_PAD_TIE_OPT_DEFAULT); - } -#endif - -#if TOUCH_BUTTON_DENOISE_ENABLE - /* Denoise setting at TouchSensor 0. */ - touch_pad_denoise_t denoise = { - /* The bits to be cancelled are determined according to the noise level. */ - .grade = TOUCH_PAD_DENOISE_BIT4, - /* By adjusting the parameters, the reading of T0 should be approximated to the reading of the measured channel. */ - .cap_level = TOUCH_PAD_DENOISE_CAP_L4, - }; - touch_pad_denoise_set_config(&denoise); - touch_pad_denoise_enable(); - ESP_LOGI(TAG, "Denoise function init"); -#endif - -#if TOUCH_BUTTON_WATERPROOF_ENABLE - /* Waterproof function */ - touch_pad_waterproof_t waterproof = { - .guard_ring_pad = button[3], // If no ring pad, set 0; - /* It depends on the number of the parasitic capacitance of the shield pad. - Based on the touch readings of T14 and T0, estimate the size of the parasitic capacitance on T14 - and set the parameters of the appropriate hardware. */ - .shield_driver = TOUCH_PAD_SHIELD_DRV_L2, - }; - touch_pad_waterproof_set_config(&waterproof); - touch_pad_waterproof_enable(); - ESP_LOGI(TAG, "touch pad waterproof init"); -#endif - - /* Filter setting */ - touchsensor_filter_set(TOUCH_PAD_FILTER_IIR_16); - touch_pad_timeout_set(true, TOUCH_PAD_THRESHOLD_MAX); - /* Register touch interrupt ISR, enable intr type. */ - touch_pad_isr_register(touchsensor_interrupt_cb, NULL, TOUCH_PAD_INTR_MASK_ALL); - /* If you have other touch algorithm, you can get the measured value after the `TOUCH_PAD_INTR_MASK_SCAN_DONE` interrupt is generated. */ - touch_pad_intr_enable(TOUCH_PAD_INTR_MASK_ACTIVE | TOUCH_PAD_INTR_MASK_INACTIVE | TOUCH_PAD_INTR_MASK_TIMEOUT); - - /* Enable touch sensor clock. Work mode is "timer trigger". */ - touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); - touch_pad_fsm_start(); - - // Start a task to show what pads have been touched - xTaskCreate(&tp_example_read_task, "touch_pad_read_task", 4096, NULL, 5, NULL); -} diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/pytest_touch_pad_interrupt_v2.py b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/pytest_touch_pad_interrupt_v2.py deleted file mode 100644 index 890b110e91a..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_interrupt/pytest_touch_pad_interrupt_v2.py +++ /dev/null @@ -1,15 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Unlicense OR CC0-1.0 -import pytest -from pytest_embedded import Dut - - -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.generic -def test_touch_pad_interrupt_v2(dut: Dut) -> None: - dut.expect_exact('Touch pad: Initializing touch pad') - dut.expect_exact('Touch pad: Denoise function init') - dut.expect_exact('Touch pad: touch pad waterproof init') - dut.expect_exact('Touch pad: touch pad filter init') - dut.expect(r'touch pad \[\d+\] base \d+, thresh \d+') diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/CMakeLists.txt deleted file mode 100644 index 9baf66a8bb1..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -# The following lines of boilerplate have to be in your project's CMakeLists -# in this exact order for cmake to work correctly -cmake_minimum_required(VERSION 3.16) - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(touch_pad_read) diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/README.md b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/README.md deleted file mode 100644 index 459e6e6e947..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/README.md +++ /dev/null @@ -1,50 +0,0 @@ -| Supported Targets | ESP32-S2 | ESP32-S3 | -| ----------------- | -------- | -------- | - -# Touch Pad Read Example - -(See the README.md file in the upper level 'examples' directory for more information about examples.) - -Read and display raw values from capacitive touch pad sensors. - -Once configured, ESP32S2/S3 will continuously measure capacitance of touch pad sensors. Measurement is reflected as numeric value inversely related to sensor's capacitance. With a finger touched on a pad, its capacitance will get larger meanwhile the measured value gets smaller, and vice versa. - -To detect if a sensor is touched or not, each particular design should be calibrated by obtaining both measurements for each individual sensor. Then a threshold between both values can be established. With specific threshold, API is then able to distinguish whether specific sensor is touched or released. For ESP32-S2/S3, the hardware integrates the edge detection algorithm, which can achieve the purpose of detecting touch actions by configuring appropriate parameters. There is another similar example that demonstrates how to perform simple calibration and trigger an interrupt when a pad is touched - see [touch_pad_interrupt](../touch_pad_interrupt). - -## How to use example - -### Hardware Required - -* A development board with ESP32-S2 or ESP32-S3 chip -* A touch extension board like [esp32-s2-touch-devkit-1](https://docs.espressif.com/projects/espressif-esp-dev-kits/en/latest/esp32s2/esp32-s2-touch-devkit-1/user_guide.html) - -### Build and Flash - -Build the project and flash it to the board, then run monitor tool to view serial output: - -``` -idf.py -p PORT flash monitor -``` - -(Replace PORT with the name of the serial port to use.) - -(To exit the serial monitor, type ``Ctrl-]``.) - -See the Getting Started Guide for full steps to configure and use ESP-IDF to build projects. - -## Example Output - -ESP32-S2/S3 supports up to 14 capacitive touch pads, T1 - T14, which are connected to the specific GPIO pins. For the information of available pins please refer to ESP32-S2/S3 Technical Reference Manual. Note that T0 is an internal channel with no corresponding GPIO, it is mainly used for de-noise. This example will initialize all the 14 touch pads. The raw values of each pad can be monitored in the terminal: - -``` -Touch Sensor read, the output format is: -Touchpad num:[raw data] - -T1: [6473] T2: [6507] T3: [6638] T4: [8917] T5: [9053] T6: [7190] T7: [7176] T8: [7416] T9: [7145] T10: [7387] T11: [7973] T12: [7776] T13: [8151] T14: [8190] -T1: [6463] T2: [6512] T3: [6643] T4: [8920] T5: [9050] T6: [7191] T7: [7176] T8: [7416] T9: [7143] T10: [7387] T11: [7974] T12: [7778] T13: [8152] T14: [8192] -T1: [6476] T2: [6508] T3: [6641] T4: [8919] T5: [9053] T6: [7190] T7: [7177] T8: [7416] T9: [7143] T10: [7386] T11: [7974] T12: [7776] T13: [8153] T14: [8193] -``` - -## Troubleshooting - -For any technical queries, please open an [issue](https://github.com/espressif/esp-idf/issues) on GitHub. We will get back to you soon. diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/CMakeLists.txt b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/CMakeLists.txt deleted file mode 100644 index 2b9a209ec42..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "tp_read_main.c" - INCLUDE_DIRS ".") diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c deleted file mode 100644 index c082d9e6b3d..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/main/tp_read_main.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: CC0-1.0 - */ - -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "driver/touch_pad.h" -#include "esp_log.h" - -#define TOUCH_BUTTON_NUM 14 -#define TOUCH_CHANGE_CONFIG 0 - -static const char *TAG = "touch read"; -static const touch_pad_t button[TOUCH_BUTTON_NUM] = { - TOUCH_PAD_NUM1, - TOUCH_PAD_NUM2, - TOUCH_PAD_NUM3, - TOUCH_PAD_NUM4, - TOUCH_PAD_NUM5, - TOUCH_PAD_NUM6, - TOUCH_PAD_NUM7, - TOUCH_PAD_NUM8, - TOUCH_PAD_NUM9, - TOUCH_PAD_NUM10, - TOUCH_PAD_NUM11, - TOUCH_PAD_NUM12, - TOUCH_PAD_NUM13, - TOUCH_PAD_NUM14 -}; - -/* - Read values sensed at all available touch pads. - Print out values in a loop on a serial monitor. - */ -static void tp_example_read_task(void *pvParameter) -{ - uint32_t touch_value; - - /* Wait touch sensor init done */ - vTaskDelay(100 / portTICK_PERIOD_MS); - printf("Touch Sensor read, the output format is: \nTouchpad num:[raw data]\n\n"); - - while (1) { - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - touch_pad_read_raw_data(button[i], &touch_value); // read raw data. - printf("T%d: [%4"PRIu32"] ", button[i], touch_value); - } - printf("\n"); - vTaskDelay(200 / portTICK_PERIOD_MS); - } -} - -void app_main(void) -{ - /* Initialize touch pad peripheral. */ - touch_pad_init(); - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - touch_pad_config(button[i]); - } -#if TOUCH_CHANGE_CONFIG - /* If you want change the touch sensor default setting, please write here(after initialize). There are examples: */ - touch_pad_set_measurement_interval(TOUCH_PAD_SLEEP_CYCLE_DEFAULT); - touch_pad_set_charge_discharge_times(TOUCH_PAD_MEASURE_CYCLE_DEFAULT); - touch_pad_set_voltage(TOUCH_PAD_HIGH_VOLTAGE_THRESHOLD, TOUCH_PAD_LOW_VOLTAGE_THRESHOLD, TOUCH_PAD_ATTEN_VOLTAGE_THRESHOLD); - touch_pad_set_idle_channel_connect(TOUCH_PAD_IDLE_CH_CONNECT_DEFAULT); - for (int i = 0; i < TOUCH_BUTTON_NUM; i++) { - touch_pad_set_cnt_mode(button[i], TOUCH_PAD_SLOPE_DEFAULT, TOUCH_PAD_TIE_OPT_DEFAULT); - } -#endif - /* Denoise setting at TouchSensor 0. */ - touch_pad_denoise_t denoise = { - /* The bits to be cancelled are determined according to the noise level. */ - .grade = TOUCH_PAD_DENOISE_BIT4, - .cap_level = TOUCH_PAD_DENOISE_CAP_L4, - }; - touch_pad_denoise_set_config(&denoise); - touch_pad_denoise_enable(); - ESP_LOGI(TAG, "Denoise function init"); - - /* Enable touch sensor clock. Work mode is "timer trigger". */ - touch_pad_set_fsm_mode(TOUCH_FSM_MODE_TIMER); - touch_pad_fsm_start(); - - /* Start task to read values by pads. */ - xTaskCreate(&tp_example_read_task, "touch_pad_read_task", 4096, NULL, 5, NULL); -} diff --git a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/pytest_touch_pad_read_v2.py b/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/pytest_touch_pad_read_v2.py deleted file mode 100644 index 4c58c674927..00000000000 --- a/examples/peripherals/touch_sensor/touch_sensor_v2/touch_pad_read/pytest_touch_pad_read_v2.py +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: Unlicense OR CC0-1.0 -import pytest -from pytest_embedded import Dut - - -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.generic -def test_touch_pad_read_v2(dut: Dut) -> None: - dut.expect_exact('touch read: Denoise function init') - dut.expect(r'T1: \[\d+\] T2: \[\d+\] T3: \[\d+\] T4: \[\d+\] T5: \[\d+\] T6: \[\d+\] T7: \[\d+\] T8: \[\d+\] T9: \[\d+\]' - r' T10: \[\d+\] T11: \[\d+\] T12: \[\d+\] T13: \[\d+\] T14: \[\d+\]') diff --git a/examples/system/deep_sleep/main/Kconfig.projbuild b/examples/system/deep_sleep/main/Kconfig.projbuild index 7c2999c8578..5590daf455e 100644 --- a/examples/system/deep_sleep/main/Kconfig.projbuild +++ b/examples/system/deep_sleep/main/Kconfig.projbuild @@ -3,7 +3,7 @@ menu "Example Configuration" config EXAMPLE_TOUCH_WAKEUP bool "Enable touch wake up" default y - depends on SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP + depends on SOC_PM_SUPPORT_TOUCH_SENSOR_WAKEUP && !IDF_TARGET_ESP32P4 help This option enables wake up from deep sleep using touch pads. ESP32 - TOUCH8 and TOUCH9, which correspond to GPIO33 and GPIO32. diff --git a/examples/system/deep_sleep/main/touch_wakeup.c b/examples/system/deep_sleep/main/touch_wakeup.c index 13d4ff64d4d..97d54e8311b 100644 --- a/examples/system/deep_sleep/main/touch_wakeup.c +++ b/examples/system/deep_sleep/main/touch_wakeup.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Unlicense OR CC0-1.0 */ diff --git a/examples/system/deep_sleep/sdkconfig.defaults b/examples/system/deep_sleep/sdkconfig.defaults index b508ab21b76..0fc182032c8 100644 --- a/examples/system/deep_sleep/sdkconfig.defaults +++ b/examples/system/deep_sleep/sdkconfig.defaults @@ -6,3 +6,4 @@ CONFIG_NEWLIB_TIME_SYSCALL_USE_RTC_HRT=y CONFIG_RTC_CLK_SRC_INT_RC=y CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP=y CONFIG_PARTITION_TABLE_CUSTOM=y +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y diff --git a/examples/system/ulp/ulp_riscv/touch/main/ulp_riscv_touch_example_main.c b/examples/system/ulp/ulp_riscv/touch/main/ulp_riscv_touch_example_main.c index dd5d4a29985..8be53ec9b8e 100644 --- a/examples/system/ulp/ulp_riscv/touch/main/ulp_riscv_touch_example_main.c +++ b/examples/system/ulp/ulp_riscv/touch/main/ulp_riscv_touch_example_main.c @@ -10,7 +10,7 @@ #include "esp_sleep.h" #include "ulp_riscv.h" #include "ulp_main.h" -#include "driver/touch_pad.h" +#include "driver/touch_sensor.h" #include "freertos/FreeRTOS.h" #include "freertos/task.h" diff --git a/examples/system/ulp/ulp_riscv/touch/sdkconfig.defaults b/examples/system/ulp/ulp_riscv/touch/sdkconfig.defaults index e3745e50576..332fdc55f14 100644 --- a/examples/system/ulp/ulp_riscv/touch/sdkconfig.defaults +++ b/examples/system/ulp/ulp_riscv/touch/sdkconfig.defaults @@ -7,3 +7,4 @@ CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y CONFIG_BOOTLOADER_LOG_LEVEL=2 CONFIG_LOG_DEFAULT_LEVEL_WARN=y CONFIG_LOG_DEFAULT_LEVEL=2 +CONFIG_TOUCH_SUPPRESS_DEPRECATE_WARN=y From 4b767d03fe7961ee0e3091546c4cdb2c41c392fe Mon Sep 17 00:00:00 2001 From: zhiweijian Date: Mon, 26 Aug 2024 20:04:00 +0800 Subject: [PATCH 34/70] feat(bt/controller): Support controller code run in flash only --- components/bt/CMakeLists.txt | 12 +- components/bt/controller/esp32c3/Kconfig.in | 36 + components/bt/controller/esp32c3/bt.c | 8 + components/bt/controller/lib_esp32c3_family | 2 +- .../bt/host/bluedroid/hci/hci_packet_parser.c | 1 - .../bt/include/esp32c3/include/esp_bt.h | 68 +- components/esp_rom/CMakeLists.txt | 59 +- .../esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld | 75 ++ .../esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld | 32 + .../esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld | 22 + .../esp32c3/ld/esp32c3.rom.ble_master.ld | 20 + .../esp32c3/ld/esp32c3.rom.ble_scan.ld | 36 + .../esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld | 44 + .../esp32c3/ld/esp32c3.rom.ble_test.ld | 37 + .../esp32c3/ld/esp32c3.rom.bt_funcs.ld | 844 +++++++++++++++++ .../esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld | 32 - .../esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld | 45 + .../esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld | 126 --- .../esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld | 130 +++ components/esp_rom/esp32c3/ld/esp32c3.rom.ld | 826 ----------------- .../esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld | 75 ++ .../esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld | 32 + .../esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld | 22 + .../esp32s3/ld/esp32s3.rom.ble_master.ld | 20 + .../esp32s3/ld/esp32s3.rom.ble_scan.ld | 37 + .../esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld | 44 + .../esp32s3/ld/esp32s3.rom.ble_test.ld | 37 + .../esp32s3/ld/esp32s3.rom.bt_funcs.ld | 874 ++++++++++++++++++ components/esp_rom/esp32s3/ld/esp32s3.rom.ld | 851 ----------------- 29 files changed, 2606 insertions(+), 1841 deletions(-) create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld create mode 100644 components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld create mode 100644 components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld diff --git a/components/bt/CMakeLists.txt b/components/bt/CMakeLists.txt index 3c59c835a14..143c8e3efb2 100644 --- a/components/bt/CMakeLists.txt +++ b/components/bt/CMakeLists.txt @@ -865,11 +865,19 @@ if(CONFIG_BT_ENABLED) elseif(CONFIG_IDF_TARGET_ESP32C3) target_link_directories(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32c3") - target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash) + else() + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + endif() elseif(CONFIG_IDF_TARGET_ESP32S3) target_link_directories(${COMPONENT_LIB} INTERFACE "${CMAKE_CURRENT_LIST_DIR}/controller/lib_esp32c3_family/esp32s3") - target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app_flash) + else() + target_link_libraries(${COMPONENT_LIB} PUBLIC btdm_app) + endif() elseif(CONFIG_BT_CONTROLLER_ENABLED) if(CONFIG_IDF_TARGET_ESP32C6) add_prebuilt_library(libble_app diff --git a/components/bt/controller/esp32c3/Kconfig.in b/components/bt/controller/esp32c3/Kconfig.in index 5b7c1c8bee5..0121b3404a1 100644 --- a/components/bt/controller/esp32c3/Kconfig.in +++ b/components/bt/controller/esp32c3/Kconfig.in @@ -226,6 +226,7 @@ config BT_CTRL_DFT_TX_POWER_LEVEL_EFF config BT_CTRL_BLE_ADV_REPORT_FLOW_CTRL_SUPP bool "BLE adv report flow control supported" + depends on (!BT_CTRL_RUN_IN_FLASH_ONLY) || (BT_CTRL_RUN_IN_FLASH_ONLY && BT_CTRL_BLE_SCAN) default y help The function is mainly used to enable flow control for advertising reports. When it is enabled, @@ -512,3 +513,38 @@ menu "BLE disconnect when instant passed" If this option is enabled, Controller will terminate the connection when instant passed in PHY update procedure. endmenu +config BT_CTRL_RUN_IN_FLASH_ONLY + bool "Put all BLE Controller code in flash" + default n + help + If this option is enabled, all code for the Bluetooth controller will be moved from ROM and IRAM + to flash, saving over 20K bytes of memory. However, it will require more flash resources and the + performance of Bluetooth will decrease If this option is enabled, Bluetooth may not work properly + during erasing flash. It is recommended to turn on the auto suspend function of flash. After auto + suspend is turned on, Bluetooth interrupts can be executed normally during erasing flash, with less + impact on Bluetooth performance. + +config BT_CTRL_DTM_ENABLE + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable direct test mode feature" + default n + +config BT_CTRL_BLE_MASTER + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE master role feature" + default y + +config BT_CTRL_BLE_TEST + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE QA test feature" + default n + +config BT_CTRL_BLE_SCAN + depends on BT_CTRL_RUN_IN_FLASH_ONLY + bool "Enable BLE scan feature" + default y + +config BT_CTRL_BLE_SECURITY_ENABLE + depends on BT_CTRL_RUN_IN_FLASH_ONLY && BT_CONTROLLER_ONLY + bool "Enable BLE security feature" + default y diff --git a/components/bt/controller/esp32c3/bt.c b/components/bt/controller/esp32c3/bt.c index 34c6ff9816d..c943fb92fad 100644 --- a/components/bt/controller/esp32c3/bt.c +++ b/components/bt/controller/esp32c3/bt.c @@ -499,7 +499,11 @@ static int interrupt_alloc_wrapper(int cpu_id, int source, intr_handler_t handle { btdm_isr_alloc_t p; p.source = source; +#if CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY + p.flags = ESP_INTR_FLAG_LEVEL3; +#else p.flags = ESP_INTR_FLAG_LEVEL3 | ESP_INTR_FLAG_IRAM; +#endif p.fn = handler; p.arg = arg; p.handle = (intr_handle_t *)ret_handle; @@ -1426,6 +1430,10 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) ESP_LOGI(BT_LOG_TAG, "BT controller compile version [%s]", btdm_controller_get_compile_version()); +#if (CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + ESP_LOGI(BT_LOG_TAG,"Put all controller code in flash"); +#endif + if ((err = btdm_low_power_mode_init(cfg)) != ESP_OK) { ESP_LOGE(BT_LOG_TAG, "Low power module initialization failed"); goto error; diff --git a/components/bt/controller/lib_esp32c3_family b/components/bt/controller/lib_esp32c3_family index eeb2782618e..6470c01165c 160000 --- a/components/bt/controller/lib_esp32c3_family +++ b/components/bt/controller/lib_esp32c3_family @@ -1 +1 @@ -Subproject commit eeb2782618e0ab8cf0cf609c98c6a0c86d691a6c +Subproject commit 6470c01165cf4edeed5d826ce4082a90deb92efd diff --git a/components/bt/host/bluedroid/hci/hci_packet_parser.c b/components/bt/host/bluedroid/hci/hci_packet_parser.c index 1ee5033112f..d25caf3506e 100644 --- a/components/bt/host/bluedroid/hci/hci_packet_parser.c +++ b/components/bt/host/bluedroid/hci/hci_packet_parser.c @@ -219,7 +219,6 @@ static void parse_ble_read_adv_max_len_response( // Size: 2 Octets ; Value: 0x001F – 0x0672 ; Maximum supported advertising data length STREAM_TO_UINT16(*adv_max_len_ptr, stream); } - osi_free(response); } #endif // #if (BLE_50_FEATURE_SUPPORT == TRUE) diff --git a/components/bt/include/esp32c3/include/esp_bt.h b/components/bt/include/esp32c3/include/esp_bt.h index 6ce147befcf..1cd79be9021 100644 --- a/components/bt/include/esp32c3/include/esp_bt.h +++ b/components/bt/include/esp32c3/include/esp_bt.h @@ -19,7 +19,7 @@ extern "C" { #endif #define ESP_BT_CTRL_CONFIG_MAGIC_VAL 0x5A5AA5A5 -#define ESP_BT_CTRL_CONFIG_VERSION 0x02409260 +#define ESP_BT_CTRL_CONFIG_VERSION 0x02410230 #define ESP_BT_HCI_TL_MAGIC_VALUE 0xfadebead #define ESP_BT_HCI_TL_VERSION 0x00010000 @@ -236,6 +236,60 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); #endif #define BT_CTRL_BLE_LLCP_DISC_FLAG (BT_CTRL_BLE_LLCP_CONN_UPDATE | BT_CTRL_BLE_LLCP_CHAN_MAP_UPDATE | BT_CTRL_BLE_LLCP_PHY_UPDATE) +#if defined(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) +#define BT_CTRL_RUN_IN_FLASH_ONLY CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY +#else +#define BT_CTRL_RUN_IN_FLASH_ONLY (0) +#endif + +#if (BT_CTRL_RUN_IN_FLASH_ONLY == 1) + +#if defined(CONFIG_BT_CTRL_DTM_ENABLE) +#define BT_CTRL_DTM_ENABLE CONFIG_BT_CTRL_DTM_ENABLE +#else +#define BT_CTRL_DTM_ENABLE (0) +#endif + +#if defined(CONFIG_BT_CTRL_BLE_MASTER) +#define BT_CTRL_BLE_MASTER CONFIG_BT_CTRL_BLE_MASTER +#else +#define BT_CTRL_BLE_MASTER (0) +#endif + +#if defined(CONFIG_BT_CTRL_BLE_TEST) +#define BT_CTRL_BLE_TEST CONFIG_BT_CTRL_BLE_TEST +#else +#define BT_CTRL_BLE_TEST (0) +#endif + +#if defined (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || defined (CONFIG_BT_BLE_SMP_ENABLE) +#ifdef CONFIG_BT_NIMBLE_SECURITY_ENABLE +#define BLE_SECURITY_ENABLE (CONFIG_BT_NIMBLE_SECURITY_ENABLE) +#endif //CONFIG_BT_NIMBLE_SECURITY_ENABLE +#ifdef CONFIG_BT_BLE_SMP_ENABLE +#define BLE_SECURITY_ENABLE (CONFIG_BT_BLE_SMP_ENABLE) +#endif //CONFIG_BT_BLE_SMP_ENABLE +#else +#if defined (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE) +#define BLE_SECURITY_ENABLE (CONFIG_BT_CTRL_BLE_SECURITY_ENABLE) +#else +#define BLE_SECURITY_ENABLE (0) +#endif +#endif // (CONFIG_BT_NIMBLE_SECURITY_ENABLE) || (CONFIG_BT_BLE_SMP_ENABLE) + +#if defined (CONFIG_BT_CTRL_BLE_SCAN) +#define BT_CTRL_BLE_SCAN CONFIG_BT_CTRL_BLE_SCAN +#else +#define BT_CTRL_BLE_SCAN (0) +#endif + +#else +#define BT_CTRL_BLE_MASTER (1) +#define BT_CTRL_DTM_ENABLE (1) +#define BT_CTRL_BLE_TEST (1) +#define BLE_SECURITY_ENABLE (1) +#define BT_CTRL_BLE_SCAN (1) +#endif // (BT_CTRL_RUN_IN_FLASH_ONLY == 1) #define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \ .magic = ESP_BT_CTRL_CONFIG_MAGIC_VAL, \ @@ -276,6 +330,12 @@ typedef void (* esp_bt_hci_tl_callback_t) (void *arg, uint8_t status); .ble_chan_ass_en = BT_CTRL_CHAN_ASS_EN, \ .ble_ping_en = BT_CTRL_LE_PING_EN, \ .ble_llcp_disc_flag = BT_CTRL_BLE_LLCP_DISC_FLAG, \ + .run_in_flash = BT_CTRL_RUN_IN_FLASH_ONLY, \ + .dtm_en = BT_CTRL_DTM_ENABLE, \ + .enc_en = BLE_SECURITY_ENABLE, \ + .qa_test = BT_CTRL_BLE_TEST, \ + .master_en = BT_CTRL_BLE_MASTER, \ + .scan_en = BT_CTRL_BLE_SCAN, \ } #else @@ -351,6 +411,12 @@ typedef struct { uint8_t ble_chan_ass_en; /*!< BLE channel assessment enable */ uint8_t ble_ping_en; /*!< BLE ping procedure enable */ uint8_t ble_llcp_disc_flag; /*!< BLE disconnect flag when instant passed */ + bool run_in_flash; /*!< Check if controller code is in flash */ + bool dtm_en; /*!< Controller DTM feature is enabled or not */ + bool enc_en; /*!< Controller encryption feature is enabled or not */ + bool qa_test; /*!< Controller QA test feature is enabled or not */ + bool master_en; /*!< Controller master feature is enabled or not */ + bool scan_en; /*!< Controller scan feature is enabled or not */ } esp_bt_controller_config_t; /** diff --git a/components/esp_rom/CMakeLists.txt b/components/esp_rom/CMakeLists.txt index e344d4dffcf..a2a86ed786d 100644 --- a/components/esp_rom/CMakeLists.txt +++ b/components/esp_rom/CMakeLists.txt @@ -99,6 +99,11 @@ if(target STREQUAL "linux") else() target_linker_script(${COMPONENT_LIB} INTERFACE "${target_folder}/${ld_folder}/${target}.rom.ld") rom_linker_script("api") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(target STREQUAL "esp32s3" OR target STREQUAL "esp32c3") + rom_linker_script("bt_funcs") + endif() + endif() if(CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB) rom_linker_script("libgcc") @@ -176,15 +181,67 @@ else() # Regular app build endif() elseif(target STREQUAL "esp32c3") + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(NOT CONFIG_BT_CTRL_BLE_MASTER) + rom_linker_script("ble_master") + endif() + if(NOT CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT AND NOT CONFIG_BT_BLE_50_FEATURES_SUPPORTED) + rom_linker_script("ble_50") + endif() + if(CONFIG_BT_BLE_CCA_MODE_NONE) + rom_linker_script("ble_cca") + endif() + if(NOT CONFIG_BT_NIMBLE_SECURITY_ENABLE AND NOT CONFIG_BT_BLE_SMP_ENABLE) + rom_linker_script("ble_smp") + endif() + if(NOT CONFIG_BT_CTRL_DTM_ENABLE) + rom_linker_script("ble_dtm") + endif() + if(NOT CONFIG_BT_CTRL_BLE_TEST) + rom_linker_script("ble_test") + endif() + if(NOT CONFIG_BT_CTRL_BLE_SCAN) + rom_linker_script("ble_scan") + endif() + endif() if(CONFIG_ESP32C3_REV_MIN_FULL GREATER_EQUAL 3) rom_linker_script("eco3") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + rom_linker_script("eco3_bt_funcs") + endif() endif() if(CONFIG_ESP32C3_REV_MIN_FULL GREATER_EQUAL 101) rom_linker_script("eco7") + if(NOT CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + rom_linker_script("eco7_bt_funcs") + endif() + endif() + elseif(target STREQUAL "esp32s3") + if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY) + if(NOT CONFIG_BT_CTRL_BLE_MASTER) + rom_linker_script("ble_master") + endif() + if(NOT CONFIG_BT_NIMBLE_50_FEATURE_SUPPORT AND NOT CONFIG_BT_BLE_50_FEATURES_SUPPORTED) + rom_linker_script("ble_50") + endif() + if(CONFIG_BT_BLE_CCA_MODE_NONE) + rom_linker_script("ble_cca") + endif() + if(NOT CONFIG_BT_NIMBLE_SECURITY_ENABLE AND NOT CONFIG_BT_BLE_SMP_ENABLE) + rom_linker_script("ble_smp") + endif() + if(NOT CONFIG_BT_CTRL_DTM_ENABLE) + rom_linker_script("ble_dtm") + endif() + if(NOT CONFIG_BT_CTRL_BLE_TEST) + rom_linker_script("ble_test") + endif() + if(NOT CONFIG_BT_CTRL_BLE_SCAN) + rom_linker_script("ble_scan") + endif() endif() - elseif(target STREQUAL "esp32c6") # esp32c6.rom.api.ld has been split to several lds by components. # esp32c6.rom.api.ld is still reserved to map the APIs diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld new file mode 100644 index 00000000000..cf9e0c3e127 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_50.ld @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* extend adv */ +f_hci_le_set_ext_adv_param_cmd_handler = 0; +f_hci_le_set_adv_set_rand_addr_cmd_handler = 0; +f_hci_le_set_ext_adv_data_cmd_handler = 0; +f_hci_le_set_ext_scan_rsp_data_cmd_handler = 0; +f_hci_le_set_ext_adv_en_cmd_handler = 0; +f_hci_le_rd_max_adv_data_len_cmd_handler = 0; +f_hci_le_rd_nb_supp_adv_sets_cmd_handler = 0; +f_hci_le_rmv_adv_set_cmd_handler = 0; +f_hci_le_clear_adv_sets_cmd_handler = 0; +r_lld_adv_sync_info_set = 0; + +r_lld_ext_adv_dynamic_pti_process = 0; +r_lld_adv_ext_chain_construct = 0; +r_lld_adv_aux_evt_canceled_cbk = 0; +r_lld_adv_aux_evt_start_cbk = 0; +r_lld_adv_aux_ch_idx_set = 0; + +/* periodic adv */ +f_hci_le_set_per_adv_param_cmd_handler = 0; +f_hci_le_set_per_adv_data_cmd_handler = 0; +f_hci_le_set_per_adv_en_cmd_handler = 0; +r_lld_per_adv_ch_map_update = 0; +r_lld_per_adv_init = 0; + +/* PA list */ +f_hci_le_add_dev_to_per_adv_list_cmd_handler = 0; +f_hci_le_rmv_dev_from_per_adv_list_cmd_handler = 0; +f_hci_le_clear_per_adv_list_cmd_handler = 0; +f_hci_le_rd_per_adv_list_size_cmd_handler = 0; + +/* extend scan */ +f_hci_le_set_ext_scan_param_cmd_handler = 0; +f_hci_le_set_ext_scan_en_cmd_handler = 0; +r_lld_scan_process_pkt_rx_ext_adv = 0; +r_lld_scan_trunc_ind = 0; + +/* extend con */ +f_hci_le_ext_create_con_cmd_handler = 0; +r_lld_init_process_pkt_rx_adv_ext_ind = 0; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0; + +/* PA sync */ +f_hci_le_per_adv_create_sync_cmd_handler = 0; +f_hci_le_per_adv_create_sync_cancel_cmd_handler = 0; +f_hci_le_per_adv_term_sync_cmd_handler = 0; +f_lld_per_adv_rx_end_ind_handler_hack = 0; +f_lld_sync_start_req_handler = 0; +f_lld_per_adv_rep_ind_handler = 0; +r_lld_sync_init = 0; + +/* phy update*/ +r_phy_upd_proc_start = 0; +f_llc_op_phy_upd_ind_handler = 0; +f_ll_phy_req_handler = 0; +f_ll_phy_rsp_handler = 0; +f_ll_phy_update_ind_handler = 0; +f_lld_phy_upd_cfm_handler = 0; +f_hci_le_set_phy_cmd_handler = 0; +llc_llcp_phy_update_ind_ack = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld new file mode 100644 index 00000000000..3bb14764722 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_cca.ld @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SW CCA */ +r_lld_cca_con_evt_start_handle = 0; +r_lld_hw_cca_end_isr = 0; +r_lld_hw_cca_isr_eco = 0; +r_lld_cca_bb_sync_found_handle = 0; +r_lld_cca_data_reset = 0; +r_lld_cca_sw_init = 0; +r_lld_cca_con_evt_end_handle = 0; +r_lld_cca_alloc = 0; +r_lld_cca_sw_alloc = 0; +r_lld_cca_sw_free = 0; +r_lld_cca_free = 0; +r_cca_init = 0; +r_lld_hw_cca_evt_handler = 0; +r_lld_sw_cca_evt_handler = 0; +r_ble_sw_cca_check_isr = 0; +bt_bb_tx_cca_set = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld new file mode 100644 index 00000000000..aeede90250d --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_dtm.ld @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* DTM */ +f_hci_le_rx_test_cmd_handler = 0; +f_hci_le_tx_test_cmd_handler = 0; +f_hci_le_enh_rx_test_cmd_handler = 0; +f_hci_le_enh_tx_test_cmd_handler = 0; +f_hci_le_test_end_cmd_handler = 0; +r_lld_test_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld new file mode 100644 index 00000000000..e7d2db0cbff --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_master.ld @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* master */ +f_hci_le_create_con_cmd_handler = 0; +f_hci_le_create_con_cancel_cmd_handler = 0; +lld_init_end_ind_handler = 0; +r_lld_init_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld new file mode 100644 index 00000000000..eda6c721a1b --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_scan.ld @@ -0,0 +1,36 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* BLE scan */ +f_hci_le_set_scan_param_cmd_handler = 0; +f_hci_le_set_scan_en_cmd_handler = 0; +f_llm_scan_period_to_handler_hack = 0; +f_lld_adv_rep_ind_handler_hack = 0; +r_lld_scan_init = 0; +r_lld_scan_restart = 0; +f_lld_scan_end_ind_handler_hack = 0; +r_llm_env_adv_dup_filt_deinit_eco = 0; +llm_exception_list_init = 0; +llm_duplicate_list_init = 0; +f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0; +f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0; +f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0; +coex_schm_ble_scan_stop = 0; + +f_hci_le_set_ext_scan_param_cmd_handler = 0; +f_hci_le_set_ext_scan_en_cmd_handler = 0; +r_lld_scan_process_pkt_rx_ext_adv = 0; +r_lld_scan_trunc_ind = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld new file mode 100644 index 00000000000..15436088d77 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_smp.ld @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SMP */ +f_ll_pause_enc_req_handler = 0; +f_ll_pause_enc_rsp_handler = 0; +f_ll_enc_req_handler = 0; +f_ll_enc_rsp_handler = 0; +f_ll_start_enc_req_handler = 0; +f_ll_start_enc_rsp_handler = 0; +f_hci_le_start_enc_cmd_handler = 0; +f_hci_le_ltk_req_reply_cmd_handler = 0; +f_hci_le_ltk_req_neg_reply_cmd_handler = 0; +f_llc_encrypt_ind_handler = 0; +f_llc_op_encrypt_ind_handler = 0; +f_hci_le_rd_local_p256_public_key_cmd_handler = 0; +f_hci_le_generate_dhkey_cmd_handler = 0; +f_hci_le_enc_cmd_handler = 0; +r_rwip_crypt_evt_handler = 0; + +/* LE ping */ +f_ll_ping_req_handler = 0; +f_ll_ping_rsp_handler = 0; +r_llc_le_ping_set = 0; +r_llc_le_ping_restart = 0; +f_llc_op_le_ping_ind_handler = 0; +f_llc_auth_payl_nearly_op_handler = 0; +f_llc_auth_payl_real_to_handler = 0; +f_llc_auth_payl_nearly_to_handler = 0; + +/* ecc */ +r_ecc_init = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld new file mode 100644 index 00000000000..0c821cf5ba8 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ble_test.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* overwrite */ +lld_acl_rx_ind_handler = 0; +lld_con_estab_ind_handler = 0; +lld_adv_rep_ind_handler = 0; +llm_rpa_renew_to_handler = 0; +lld_scan_end_ind_handler = 0; +llm_scan_period_to_handler = 0; + +/* nvds */ +r_nvds_init = 0; +f_nvds_get = 0; +f_nvds_del = 0; +f_nvds_put = 0; + +/* controller flash */ +r_flash_init = 0; +r_flash_env_init = 0; +r_flash_env_deinit = 0; + +/* QA test */ +f_hci_vendor_ble_qa_test_cmd_handler = 0; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld new file mode 100644 index 00000000000..89ea7c532ce --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.bt_funcs.ld @@ -0,0 +1,844 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32c3.rom.ld for esp32c3 + * + * + * Generated from ./interface-esp32c3.yml md5sum 93b28a9e1fe42d212018eb4336849208 + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +bt_rf_coex_get_dft_cfg = 0x400008dc; +bt_rf_coex_hooks_p_set = 0x400008e0; +btdm_con_maxevtime_cal_impl = 0x400008e4; +btdm_controller_get_compile_version_impl = 0x400008e8; +btdm_controller_rom_data_init = 0x400008ec; +btdm_dis_privacy_err_report_impl = 0x400008f0; +btdm_disable_adv_delay_impl = 0x400008f4; +btdm_enable_scan_continue_impl = 0x400008f8; +btdm_enable_scan_forever_impl = 0x400008fc; +btdm_get_power_state_impl = 0x40000900; +btdm_get_prevent_sleep_flag_impl = 0x40000904; +btdm_power_state_active_impl = 0x40000908; +btdm_switch_phy_coded_impl = 0x4000090c; +hci_acl_data_handler = 0x40000910; +hci_disconnect_cmd_handler = 0x40000914; +hci_le_con_upd_cmd_handler = 0x40000918; +hci_le_ltk_req_neg_reply_cmd_handler = 0x4000091c; +hci_le_ltk_req_reply_cmd_handler = 0x40000920; +hci_le_rd_chnl_map_cmd_handler = 0x40000924; +hci_le_rd_phy_cmd_handler = 0x40000928; +hci_le_rd_rem_feats_cmd_handler = 0x4000092c; +hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40000930; +hci_le_rem_con_param_req_reply_cmd_handler = 0x40000934; +hci_le_set_data_len_cmd_handler = 0x40000938; +hci_le_set_phy_cmd_handler = 0x4000093c; +hci_le_start_enc_cmd_handler = 0x40000940; +hci_rd_auth_payl_to_cmd_handler = 0x40000944; +hci_rd_rem_ver_info_cmd_handler = 0x40000948; +hci_rd_rssi_cmd_handler = 0x4000094c; +hci_rd_tx_pwr_lvl_cmd_handler = 0x40000950; +hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40000954; +hci_vs_set_pref_slave_latency_cmd_handler = 0x40000958; +hci_wr_auth_payl_to_cmd_handler = 0x4000095c; +ll_channel_map_ind_handler = 0x40000960; +ll_connection_param_req_handler = 0x40000964; +ll_connection_param_rsp_handler = 0x40000968; +ll_connection_update_ind_handler = 0x4000096c; +ll_enc_req_handler = 0x40000970; +ll_enc_rsp_handler = 0x40000974; +ll_feature_req_handler = 0x40000978; +ll_feature_rsp_handler = 0x4000097c; +ll_length_req_handler = 0x40000980; +ll_length_rsp_handler = 0x40000984; +ll_min_used_channels_ind_handler = 0x40000988; +ll_pause_enc_req_handler = 0x4000098c; +ll_pause_enc_rsp_handler = 0x40000990; +ll_phy_req_handler = 0x40000994; +ll_phy_rsp_handler = 0x40000998; +ll_phy_update_ind_handler = 0x4000099c; +ll_ping_req_handler = 0x400009a0; +ll_ping_rsp_handler = 0x400009a4; +ll_slave_feature_req_handler = 0x400009a8; +ll_start_enc_req_handler = 0x400009ac; +ll_start_enc_rsp_handler = 0x400009b0; +ll_terminate_ind_handler = 0x400009b4; +ll_version_ind_handler = 0x400009b8; +llc_auth_payl_nearly_to_handler = 0x400009bc; +llc_auth_payl_real_to_handler = 0x400009c0; +llc_encrypt_ind_handler = 0x400009c4; +llc_hci_command_handler_wrapper = 0x400009c8; +llc_ll_connection_param_req_pdu_send = 0x400009cc; +llc_ll_connection_param_rsp_pdu_send = 0x400009d0; +llc_ll_connection_update_ind_pdu_send = 0x400009d4; +llc_ll_enc_req_pdu_send = 0x400009d8; +llc_ll_enc_rsp_pdu_send = 0x400009dc; +llc_ll_feature_req_pdu_send = 0x400009e0; +llc_ll_feature_rsp_pdu_send = 0x400009e4; +llc_ll_length_req_pdu_send = 0x400009e8; +llc_ll_length_rsp_pdu_send = 0x400009ec; +llc_ll_pause_enc_req_pdu_send = 0x400009f0; +llc_ll_pause_enc_rsp_pdu_send = 0x400009f4; +llc_ll_phy_req_pdu_send = 0x400009f8; +llc_ll_phy_rsp_pdu_send = 0x400009fc; +llc_ll_ping_req_pdu_send = 0x40000a00; +llc_ll_ping_rsp_pdu_send = 0x40000a04; +llc_ll_start_enc_req_pdu_send = 0x40000a08; +llc_ll_start_enc_rsp_pdu_send = 0x40000a0c; +llc_ll_terminate_ind_pdu_send = 0x40000a10; +llc_ll_unknown_rsp_pdu_send = 0x40000a14; +llc_llcp_ch_map_update_ind_pdu_send = 0x40000a18; +llc_llcp_phy_upd_ind_pdu_send = 0x40000a1c; +llc_llcp_version_ind_pdu_send = 0x40000a20; +llc_op_ch_map_upd_ind_handler = 0x40000a24; +llc_op_con_upd_ind_handler = 0x40000a28; +llc_op_disconnect_ind_handler = 0x40000a2c; +llc_op_dl_upd_ind_handler = 0x40000a30; +llc_op_encrypt_ind_handler = 0x40000a34; +llc_op_feats_exch_ind_handler = 0x40000a38; +llc_op_le_ping_ind_handler = 0x40000a3c; +llc_op_phy_upd_ind_handler = 0x40000a40; +llc_op_ver_exch_ind_handler = 0x40000a44; +llc_stopped_ind_handler = 0x40000a48; +lld_acl_rx_ind_handler = 0x40000a4c; +lld_acl_tx_cfm_handler = 0x40000a50; +lld_adv_end_ind_handler = 0x40000a54; +lld_adv_rep_ind_handler = 0x40000a58; +lld_ch_map_upd_cfm_handler = 0x40000a5c; +lld_con_estab_ind_handler = 0x40000a60; +lld_con_evt_sd_evt_time_set = 0x40000a64; +lld_con_offset_upd_ind_handler = 0x40000a68; +lld_con_param_upd_cfm_handler = 0x40000a6c; +lld_disc_ind_handler = 0x40000a70; +lld_init_end_ind_handler = 0x40000a74; +lld_llcp_rx_ind_handler_wrapper = 0x40000a78; +lld_llcp_tx_cfm_handler = 0x40000a7c; +lld_per_adv_end_ind_handler = 0x40000a80; +lld_per_adv_rep_ind_handler = 0x40000a84; +lld_per_adv_rx_end_ind_handler = 0x40000a88; +lld_phy_coded_500k_get = 0x40000a8c; +lld_phy_upd_cfm_handler = 0x40000a90; +lld_scan_end_ind_handler = 0x40000a94; +lld_scan_req_ind_handler = 0x40000a98; +lld_sync_start_req_handler = 0x40000a9c; +lld_test_end_ind_handler = 0x40000aa0; +lld_update_rxbuf_handler = 0x40000aa4; +llm_ch_map_update_ind_handler = 0x40000aa8; +llm_hci_command_handler_wrapper = 0x40000aac; +llm_scan_period_to_handler = 0x40000ab0; +r_Add2SelfBigHex256 = 0x40000ab4; +r_AddBigHex256 = 0x40000ab8; +r_AddBigHexModP256 = 0x40000abc; +r_AddP256 = 0x40000ac0; +r_AddPdiv2_256 = 0x40000ac4; +r_GF_Jacobian_Point_Addition256 = 0x40000ac8; +r_GF_Jacobian_Point_Double256 = 0x40000acc; +r_GF_Point_Jacobian_To_Affine256 = 0x40000ad0; +r_MultiplyBigHexByUint32_256 = 0x40000ad4; +r_MultiplyBigHexModP256 = 0x40000ad8; +r_MultiplyByU16ModP256 = 0x40000adc; +r_SubtractBigHex256 = 0x40000ae0; +r_SubtractBigHexMod256 = 0x40000ae4; +r_SubtractBigHexUint32_256 = 0x40000ae8; +r_SubtractFromSelfBigHex256 = 0x40000aec; +r_SubtractFromSelfBigHexSign256 = 0x40000af0; +r_aes_alloc = 0x40000af4; +r_aes_ccm_continue = 0x40000af8; +r_aes_ccm_process_e = 0x40000afc; +r_aes_ccm_xor_128_lsb = 0x40000b00; +r_aes_ccm_xor_128_msb = 0x40000b04; +r_aes_cmac_continue = 0x40000b08; +r_aes_cmac_start = 0x40000b0c; +r_aes_k1_continue = 0x40000b10; +r_aes_k2_continue = 0x40000b14; +r_aes_k3_continue = 0x40000b18; +r_aes_k4_continue = 0x40000b1c; +r_aes_shift_left_128 = 0x40000b20; +r_aes_start = 0x40000b24; +r_aes_xor_128 = 0x40000b28; +r_assert_err = 0x40000b2c; +r_assert_param = 0x40000b30; +r_assert_warn = 0x40000b34; +r_bigHexInversion256 = 0x40000b38; +r_ble_sw_cca_check_isr = 0x40000b3c; +r_ble_util_buf_acl_tx_alloc = 0x40000b40; +r_ble_util_buf_acl_tx_elt_get = 0x40000b44; +r_ble_util_buf_acl_tx_free = 0x40000b48; +r_ble_util_buf_acl_tx_free_in_isr = 0x40000b4c; +r_ble_util_buf_adv_tx_alloc = 0x40000b50; +r_ble_util_buf_adv_tx_free = 0x40000b54; +r_ble_util_buf_adv_tx_free_in_isr = 0x40000b58; +r_ble_util_buf_env_deinit = 0x40000b5c; +r_ble_util_buf_env_init = 0x40000b60; +r_ble_util_buf_get_rx_buf_nb = 0x40000b64; +r_ble_util_buf_get_rx_buf_size = 0x40000b68; +r_ble_util_buf_llcp_tx_alloc = 0x40000b6c; +r_ble_util_buf_llcp_tx_free = 0x40000b70; +r_ble_util_buf_rx_alloc = 0x40000b74; +r_ble_util_buf_rx_alloc_in_isr = 0x40000b78; +r_ble_util_buf_rx_free = 0x40000b7c; +r_ble_util_buf_rx_free_in_isr = 0x40000b80; +r_ble_util_buf_set_rx_buf_nb = 0x40000b84; +r_ble_util_buf_set_rx_buf_size = 0x40000b88; +r_ble_util_data_rx_buf_reset = 0x40000b8c; +r_bt_bb_get_intr_mask = 0x40000b90; +r_bt_bb_intr_clear = 0x40000b94; +r_bt_bb_intr_mask_set = 0x40000b98; +r_bt_rf_coex_cfg_set = 0x40000ba0; +r_bt_rf_coex_conn_dynamic_pti_en_get = 0x40000ba4; +r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x40000bac; +r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x40000bb0; +r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40000bb4; +r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x40000bb8; +r_bt_rf_coex_pti_table_get = 0x40000bbc; +r_bt_rf_coex_st_param_get = 0x40000bc0; +r_bt_rf_coex_st_param_set = 0x40000bc4; +r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x40000bc8; +r_bt_rma_apply_rule_cs_fmt = 0x40000bcc; +r_bt_rma_apply_rule_cs_idx = 0x40000bd0; +r_bt_rma_configure = 0x40000bd4; +r_bt_rma_deregister_rule_cs_fmt = 0x40000bd8; +r_bt_rma_deregister_rule_cs_idx = 0x40000bdc; +r_bt_rma_get_ant_by_act = 0x40000be0; +r_bt_rma_init = 0x40000be4; +r_bt_rma_register_rule_cs_fmt = 0x40000be8; +r_bt_rma_register_rule_cs_idx = 0x40000bec; +r_bt_rtp_apply_rule_cs_fmt = 0x40000bf0; +r_bt_rtp_apply_rule_cs_idx = 0x40000bf4; +r_bt_rtp_deregister_rule_cs_fmt = 0x40000bf8; +r_bt_rtp_deregister_rule_cs_idx = 0x40000bfc; +r_bt_rtp_init = 0x40000c04; +r_bt_rtp_register_rule_cs_fmt = 0x40000c08; +r_bt_rtp_register_rule_cs_idx = 0x40000c0c; +r_btdm_isr = 0x40000c10; +r_cali_phase_match_p = 0x40000c20; +r_cmp_abs_time = 0x40000c24; +r_cmp_dest_id = 0x40000c28; +r_cmp_timer_id = 0x40000c2c; +r_co_bdaddr_compare = 0x40000c30; +r_co_ble_pkt_dur_in_us = 0x40000c34; +r_co_list_extract = 0x40000c38; +r_co_list_extract_after = 0x40000c3c; +r_co_list_extract_sublist = 0x40000c40; +r_co_list_find = 0x40000c44; +r_co_list_init = 0x40000c48; +r_co_list_insert_after = 0x40000c4c; +r_co_list_insert_before = 0x40000c50; +r_co_list_merge = 0x40000c54; +r_co_list_pool_init = 0x40000c58; +r_co_list_pop_front = 0x40000c5c; +r_co_list_push_back = 0x40000c60; +r_co_list_push_back_sublist = 0x40000c64; +r_co_list_push_front = 0x40000c68; +r_co_list_size = 0x40000c6c; +r_co_nb_good_le_channels = 0x40000c70; +r_co_util_pack = 0x40000c74; +r_co_util_read_array_size = 0x40000c78; +r_co_util_unpack = 0x40000c7c; +r_dbg_env_deinit = 0x40000c80; +r_dbg_env_init = 0x40000c84; +r_dbg_platform_reset_complete = 0x40000c88; +r_dl_upd_proc_start = 0x40000c8c; +r_dump_data = 0x40000c90; +r_ecc_abort_key256_generation = 0x40000c94; +r_ecc_gen_new_public_key = 0x40000c98; +r_ecc_gen_new_secret_key = 0x40000c9c; +r_ecc_generate_key256 = 0x40000ca0; +r_ecc_get_debug_Keys = 0x40000ca4; +r_ecc_init = 0x40000ca8; +r_ecc_is_valid_point = 0x40000cac; +r_ecc_multiplication_event_handler = 0x40000cb0; +r_ecc_point_multiplication_win_256 = 0x40000cb4; +r_emi_alloc_em_mapping_by_offset = 0x40000cb8; +r_emi_base_reg_lut_show = 0x40000cbc; +r_emi_em_base_reg_show = 0x40000cc0; +r_emi_free_em_mapping_by_offset = 0x40000cc4; +r_emi_get_em_mapping_idx_by_offset = 0x40000cc8; +r_emi_get_mem_addr_by_offset = 0x40000ccc; +r_emi_overwrite_em_mapping_by_offset = 0x40000cd0; +r_esp_vendor_hci_command_handler = 0x40000cd4; +r_get_stack_usage = 0x40000cd8; +r_h4tl_acl_hdr_rx_evt_handler = 0x40000cdc; +r_h4tl_cmd_hdr_rx_evt_handler = 0x40000ce0; +r_h4tl_cmd_pld_rx_evt_handler = 0x40000ce4; +r_h4tl_eif_io_event_post = 0x40000ce8; +r_h4tl_eif_register = 0x40000cec; +r_h4tl_init = 0x40000cf0; +r_h4tl_out_of_sync = 0x40000cf4; +r_h4tl_out_of_sync_check = 0x40000cf8; +r_h4tl_read_hdr = 0x40000cfc; +r_h4tl_read_next_out_of_sync = 0x40000d00; +r_h4tl_read_payl = 0x40000d04; +r_h4tl_read_start = 0x40000d08; +r_h4tl_rx_acl_hdr_extract = 0x40000d0c; +r_h4tl_rx_cmd_hdr_extract = 0x40000d10; +r_h4tl_rx_done = 0x40000d14; +r_h4tl_start = 0x40000d18; +r_h4tl_stop = 0x40000d1c; +r_h4tl_tx_done = 0x40000d20; +r_h4tl_tx_evt_handler = 0x40000d24; +r_h4tl_write = 0x40000d28; +r_hci_acl_tx_data_alloc = 0x40000d2c; +r_hci_acl_tx_data_received = 0x40000d30; +r_hci_basic_cmd_send_2_controller = 0x40000d34; +r_hci_ble_adv_report_filter_check = 0x40000d38; +r_hci_ble_adv_report_tx_check = 0x40000d3c; +r_hci_ble_conhdl_register = 0x40000d40; +r_hci_ble_conhdl_unregister = 0x40000d44; +r_hci_build_acl_data = 0x40000d48; +r_hci_build_cc_evt = 0x40000d4c; +r_hci_build_cs_evt = 0x40000d50; +r_hci_build_evt = 0x40000d54; +r_hci_build_le_evt = 0x40000d58; +r_hci_cmd_get_max_param_size = 0x40000d5c; +r_hci_cmd_received = 0x40000d60; +r_hci_cmd_reject = 0x40000d64; +r_hci_evt_mask_check = 0x40000d68; +r_hci_evt_mask_set = 0x40000d6c; +r_hci_fc_acl_buf_size_set = 0x40000d70; +r_hci_fc_acl_en = 0x40000d74; +r_hci_fc_acl_packet_sent = 0x40000d78; +r_hci_fc_check_host_available_nb_acl_packets = 0x40000d7c; +r_hci_fc_host_nb_acl_pkts_complete = 0x40000d80; +r_hci_fc_init = 0x40000d84; +r_hci_look_for_cmd_desc = 0x40000d88; +r_hci_look_for_evt_desc = 0x40000d8c; +r_hci_look_for_le_evt_desc = 0x40000d90; +r_hci_look_for_le_evt_desc_esp = 0x40000d94; +r_hci_pack_bytes = 0x40000d98; +r_hci_send_2_controller = 0x40000da0; +r_hci_send_2_host = 0x40000da4; +r_hci_tl_c2h_data_flow_on = 0x40000da8; +r_hci_tl_cmd_hdr_rx_evt_handler = 0x40000dac; +r_hci_tl_cmd_pld_rx_evt_handler = 0x40000db0; +r_hci_tl_get_pkt = 0x40000db4; +r_hci_tl_hci_pkt_handler = 0x40000db8; +r_hci_tl_hci_tx_done_evt_handler = 0x40000dbc; +r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40000dc0; +r_hci_tl_save_pkt = 0x40000dc4; +r_hci_tl_send = 0x40000dc8; +r_hci_tx_done = 0x40000dcc; +r_hci_tx_start = 0x40000dd0; +r_hci_tx_trigger = 0x40000dd4; +r_isValidSecretKey_256 = 0x40000dd8; +r_ke_check_malloc = 0x40000ddc; +r_ke_event_callback_set = 0x40000de0; +r_ke_event_clear = 0x40000de4; +r_ke_event_flush = 0x40000de8; +r_ke_event_get = 0x40000dec; +r_ke_event_get_all = 0x40000df0; +r_ke_event_init = 0x40000df4; +r_ke_event_schedule = 0x40000df8; +r_ke_event_set = 0x40000dfc; +r_ke_flush = 0x40000e00; +r_ke_free = 0x40000e04; +r_ke_handler_search = 0x40000e08; +r_ke_init = 0x40000e0c; +r_ke_is_free = 0x40000e10; +r_ke_malloc = 0x40000e14; +r_ke_mem_init = 0x40000e18; +r_ke_mem_is_empty = 0x40000e1c; +r_ke_mem_is_in_heap = 0x40000e20; +r_ke_msg_alloc = 0x40000e24; +r_ke_msg_dest_id_get = 0x40000e28; +r_ke_msg_discard = 0x40000e2c; +r_ke_msg_forward = 0x40000e30; +r_ke_msg_forward_new_id = 0x40000e34; +r_ke_msg_free = 0x40000e38; +r_ke_msg_in_queue = 0x40000e3c; +r_ke_msg_save = 0x40000e40; +r_ke_msg_send = 0x40000e44; +r_ke_msg_send_basic = 0x40000e48; +r_ke_msg_src_id_get = 0x40000e4c; +r_ke_queue_extract = 0x40000e50; +r_ke_queue_insert = 0x40000e54; +r_ke_sleep_check = 0x40000e58; +r_ke_state_get = 0x40000e5c; +r_ke_state_set = 0x40000e60; +r_ke_task_check = 0x40000e64; +r_ke_task_create = 0x40000e68; +r_ke_task_delete = 0x40000e6c; +r_ke_task_handler_get = 0x40000e70; +r_ke_task_init = 0x40000e74; +r_ke_task_msg_flush = 0x40000e78; +r_ke_task_saved_update = 0x40000e7c; +r_ke_time = 0x40000e84; +r_ke_time_cmp = 0x40000e88; +r_ke_time_past = 0x40000e8c; +r_ke_timer_active = 0x40000e90; +r_ke_timer_adjust_all = 0x40000e94; +r_ke_timer_clear = 0x40000e98; +r_ke_timer_init = 0x40000e9c; +r_ke_timer_schedule = 0x40000ea0; +r_ke_timer_set = 0x40000ea4; +r_led_init = 0x40000ea8; +r_led_set_all = 0x40000eac; +r_llc_aes_res_cb = 0x40000eb0; +r_llc_ch_map_up_proc_err_cb = 0x40000eb4; +r_llc_cleanup = 0x40000eb8; +r_llc_cmd_cmp_send = 0x40000ebc; +r_llc_cmd_stat_send = 0x40000ec0; +r_llc_con_move_cbk = 0x40000ec4; +r_llc_con_plan_set_update = 0x40000ec8; +r_llc_con_upd_param_in_range = 0x40000ecc; +r_llc_disconnect = 0x40000ed0; +r_llc_disconnect_end = 0x40000ed4; +r_llc_disconnect_proc_continue = 0x40000ed8; +r_llc_disconnect_proc_err_cb = 0x40000edc; +r_llc_dl_chg_check = 0x40000ee0; +r_llc_dle_proc_err_cb = 0x40000ee4; +r_llc_feats_exch_proc_err_cb = 0x40000ee8; +r_llc_hci_cmd_handler_tab_p_get = 0x40000eec; +r_llc_hci_con_param_req_evt_send = 0x40000ef4; +r_llc_hci_con_upd_info_send = 0x40000ef8; +r_llc_hci_disconnected_dis = 0x40000efc; +r_llc_hci_dl_upd_info_send = 0x40000f00; +r_llc_hci_enc_evt_send = 0x40000f04; +r_llc_hci_feats_info_send = 0x40000f08; +r_llc_hci_le_phy_upd_cmp_evt_send = 0x40000f0c; +r_llc_hci_ltk_request_evt_send = 0x40000f10; +r_llc_hci_nb_cmp_pkts_evt_send = 0x40000f14; +r_llc_hci_version_info_send = 0x40000f18; +r_llc_init_term_proc = 0x40000f1c; +r_llc_iv_skd_rand_gen = 0x40000f20; +r_llc_le_ping_proc_continue = 0x40000f24; +r_llc_le_ping_proc_err_cb = 0x40000f28; +/* r_llc_le_ping_restart = 0x40000f2c; */ +r_llc_le_ping_set = 0x40000f30; +r_llc_ll_pause_enc_rsp_ack_handler = 0x40000f34; +r_llc_ll_reject_ind_ack_handler = 0x40000f38; +r_llc_ll_reject_ind_pdu_send = 0x40000f3c; +r_llc_ll_start_enc_rsp_ack_handler = 0x40000f40; +r_llc_ll_terminate_ind_ack = 0x40000f44; +r_llc_ll_unknown_ind_handler = 0x40000f48; +r_llc_llcp_send = 0x40000f4c; +r_llc_llcp_state_set = 0x40000f50; +r_llc_llcp_trans_timer_set = 0x40000f54; +r_llc_llcp_tx_check = 0x40000f58; +r_llc_loc_con_upd_proc_err_cb = 0x40000f64; +r_llc_loc_dl_upd_proc_continue = 0x40000f68; +r_llc_loc_encrypt_proc_continue = 0x40000f6c; +r_llc_loc_encrypt_proc_err_cb = 0x40000f70; +r_llc_loc_feats_exch_proc_continue = 0x40000f74; +r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c; +r_llc_msg_handler_tab_p_get = 0x40000f80; +r_llc_pref_param_compute = 0x40000f84; +r_llc_proc_collision_check = 0x40000f88; +r_llc_proc_err_ind = 0x40000f8c; +r_llc_proc_get = 0x40000f90; +r_llc_proc_id_get = 0x40000f94; +r_llc_proc_reg = 0x40000f98; +r_llc_proc_state_get = 0x40000f9c; +r_llc_proc_state_set = 0x40000fa0; +r_llc_proc_timer_pause_set = 0x40000fa4; +r_llc_proc_timer_set = 0x40000fa8; +r_llc_proc_unreg = 0x40000fac; +r_llc_rem_ch_map_proc_continue = 0x40000fb0; +r_llc_rem_con_upd_proc_err_cb = 0x40000fb8; +r_llc_rem_dl_upd_proc = 0x40000fbc; +r_llc_rem_encrypt_proc_continue = 0x40000fc0; +r_llc_rem_encrypt_proc_err_cb = 0x40000fc4; +r_llc_rem_phy_upd_proc_continue = 0x40000fc8; +r_llc_rem_phy_upd_proc_err_cb = 0x40000fcc; +r_llc_role_get = 0x40000fd0; +r_llc_sk_gen = 0x40000fd4; +r_llc_start = 0x40000fd8; +r_llc_stop = 0x40000fdc; +r_llc_ver_exch_loc_proc_continue = 0x40000fe0; +r_llc_ver_proc_err_cb = 0x40000fe4; +r_llcp_pdu_handler_tab_p_get = 0x40000fe8; +r_lld_aa_gen = 0x40000fec; +r_lld_adv_adv_data_set = 0x40000ff0; +r_lld_adv_adv_data_update = 0x40000ff4; +r_lld_adv_aux_ch_idx_set = 0x40000ff8; +r_lld_adv_aux_evt_canceled_cbk = 0x40000ffc; +r_lld_adv_aux_evt_start_cbk = 0x40001000; +r_lld_adv_coex_check_ext_adv_synced = 0x40001004; +r_lld_adv_coex_env_reset = 0x40001008; +r_lld_adv_duration_update = 0x4000100c; +r_lld_adv_dynamic_pti_process = 0x40001010; +r_lld_adv_end = 0x40001014; +r_lld_adv_evt_canceled_cbk = 0x40001018; +r_lld_adv_evt_start_cbk = 0x4000101c; +r_lld_adv_ext_chain_construct = 0x40001020; +r_lld_adv_ext_pkt_prepare = 0x40001024; +r_lld_adv_frm_cbk = 0x40001028; +r_lld_adv_frm_isr = 0x4000102c; +r_lld_adv_frm_skip_isr = 0x40001030; +r_lld_adv_init = 0x40001034; +r_lld_adv_pkt_rx = 0x40001038; +r_lld_adv_pkt_rx_connect_ind = 0x4000103c; +r_lld_adv_pkt_rx_send_scan_req_evt = 0x40001040; +r_lld_adv_rand_addr_update = 0x40001044; +r_lld_adv_restart = 0x40001048; +r_lld_adv_scan_rsp_data_set = 0x4000104c; +r_lld_adv_scan_rsp_data_update = 0x40001050; +r_lld_adv_set_tx_power = 0x40001054; +r_lld_adv_start = 0x40001058; +r_lld_adv_stop = 0x4000105c; +r_lld_adv_sync_info_set = 0x40001060; +r_lld_adv_sync_info_update = 0x40001064; +r_lld_calc_aux_rx = 0x40001068; +r_lld_cca_alloc = 0x4000106c; +r_lld_cca_data_reset = 0x40001070; +r_lld_cca_free = 0x40001074; +r_lld_ch_assess_data_get = 0x40001078; +r_lld_ch_idx_get = 0x4000107c; +r_lld_ch_map_set = 0x40001080; +r_lld_channel_assess = 0x40001084; +r_lld_con_activity_act_offset_compute = 0x40001088; +r_lld_con_activity_offset_compute = 0x4000108c; +r_lld_con_ch_map_update = 0x40001090; +r_lld_con_cleanup = 0x40001094; +r_lld_con_current_tx_power_get = 0x40001098; +r_lld_con_data_flow_set = 0x4000109c; +r_lld_con_data_len_update = 0x400010a0; +r_lld_con_data_tx = 0x400010a4; +r_lld_con_enc_key_load = 0x400010a8; +r_lld_con_event_counter_get = 0x400010ac; +r_lld_con_evt_canceled_cbk = 0x400010b0; +r_lld_con_evt_duration_min_get = 0x400010b4; +r_lld_con_evt_max_eff_time_cal = 0x400010b8; +r_lld_con_evt_sd_evt_time_get = 0x400010bc; +r_lld_con_evt_start_cbk = 0x400010c0; +r_lld_con_evt_time_update = 0x400010c4; +r_lld_con_free_all_tx_buf = 0x400010c8; +r_lld_con_frm_cbk = 0x400010cc; +r_lld_con_frm_isr = 0x400010d0; +r_lld_con_frm_skip_isr = 0x400010d4; +r_lld_con_init = 0x400010d8; +r_lld_con_llcp_tx = 0x400010dc; +r_lld_con_max_lat_calc = 0x400010e0; +r_lld_con_offset_get = 0x400010e4; +r_lld_con_param_update = 0x400010e8; +r_lld_con_phys_update = 0x400010ec; +r_lld_con_pref_slave_evt_dur_set = 0x400010f0; +r_lld_con_pref_slave_latency_set = 0x400010f4; +r_lld_con_rssi_get = 0x400010f8; +r_lld_con_rx = 0x400010fc; +/* r_lld_con_rx_channel_assess = 0x40001100; */ +r_lld_con_rx_enc = 0x40001104; +r_lld_con_rx_isr = 0x40001108; +r_lld_con_rx_link_info_check = 0x4000110c; +r_lld_con_rx_llcp_check = 0x40001110; +r_lld_con_rx_sync_time_update = 0x40001114; +r_lld_con_set_tx_power = 0x4000111c; +r_lld_con_start = 0x40001120; +r_lld_con_tx = 0x40001128; +r_lld_con_tx_enc = 0x4000112c; +r_lld_con_tx_isr = 0x40001130; +r_lld_con_tx_len_update = 0x40001134; +r_lld_con_tx_len_update_for_intv = 0x40001138; +r_lld_con_tx_len_update_for_rate = 0x4000113c; +r_lld_con_tx_prog = 0x40001140; +r_lld_conn_dynamic_pti_process = 0x40001144; +r_lld_continue_scan_rx_isr_end_process = 0x40001148; +r_lld_ext_scan_dynamic_pti_process = 0x4000114c; +r_lld_hw_cca_end_isr = 0x40001150; +r_lld_hw_cca_evt_handler = 0x40001154; +r_lld_hw_cca_isr = 0x40001158; +r_lld_init_cal_anchor_point = 0x4000115c; +r_lld_init_compute_winoffset = 0x40001160; +r_lld_init_connect_req_pack = 0x40001164; +r_lld_init_end = 0x40001168; +r_lld_init_evt_canceled_cbk = 0x4000116c; +r_lld_init_evt_start_cbk = 0x40001170; +r_lld_init_frm_cbk = 0x40001174; +r_lld_init_frm_eof_isr = 0x40001178; +r_lld_init_frm_skip_isr = 0x4000117c; +r_lld_init_init = 0x40001180; +r_lld_init_process_pkt_rx = 0x40001184; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x40001188; +r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x4000118c; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40001190; +r_lld_init_process_pkt_tx = 0x40001194; +r_lld_init_process_pkt_tx_cal_con_timestamp = 0x40001198; +r_lld_init_sched = 0x4000119c; +r_lld_init_set_tx_power = 0x400011a0; +r_lld_init_start = 0x400011a4; +r_lld_init_stop = 0x400011a8; +r_lld_instant_proc_end = 0x400011ac; +r_lld_per_adv_ch_map_update = 0x400011b4; +r_lld_per_adv_chain_construct = 0x400011b8; +r_lld_per_adv_cleanup = 0x400011bc; +r_lld_per_adv_coex_env_reset = 0x400011c0; +r_lld_per_adv_data_set = 0x400011c4; +r_lld_per_adv_data_update = 0x400011c8; +r_lld_per_adv_dynamic_pti_process = 0x400011cc; +r_lld_per_adv_evt_canceled_cbk = 0x400011d0; +r_lld_per_adv_evt_start_cbk = 0x400011d4; +r_lld_per_adv_ext_pkt_prepare = 0x400011d8; +r_lld_per_adv_frm_cbk = 0x400011dc; +r_lld_per_adv_frm_isr = 0x400011e0; +r_lld_per_adv_frm_skip_isr = 0x400011e4; +r_lld_per_adv_init = 0x400011e8; +r_lld_per_adv_init_info_get = 0x400011ec; +r_lld_per_adv_list_add = 0x400011f0; +r_lld_per_adv_list_rem = 0x400011f4; +r_lld_per_adv_set_tx_power = 0x400011fc; +r_lld_per_adv_start = 0x40001200; +r_lld_per_adv_stop = 0x40001204; +r_lld_per_adv_sync_info_get = 0x40001208; +r_lld_process_cca_data = 0x4000120c; +r_lld_ral_search = 0x40001210; +r_lld_read_clock = 0x40001214; +r_lld_res_list_add = 0x40001218; +r_lld_res_list_is_empty = 0x40001220; +r_lld_res_list_local_rpa_get = 0x40001224; +r_lld_res_list_peer_rpa_get = 0x40001228; +r_lld_res_list_peer_update = 0x4000122c; +/* r_lld_res_list_priv_mode_update = 0x40001230; */ +r_lld_reset_reg = 0x40001238; +r_lld_rpa_renew = 0x4000123c; +r_lld_rpa_renew_evt_canceled_cbk = 0x40001240; +r_lld_rpa_renew_evt_start_cbk = 0x40001244; +r_lld_rpa_renew_instant_cbk = 0x40001248; +r_lld_rxdesc_check = 0x4000124c; +r_lld_rxdesc_free = 0x40001250; +r_lld_scan_create_sync = 0x40001254; +r_lld_scan_create_sync_cancel = 0x40001258; +r_lld_scan_end = 0x4000125c; +r_lld_scan_evt_canceled_cbk = 0x40001260; +r_lld_scan_evt_start_cbk = 0x40001264; +r_lld_scan_frm_cbk = 0x40001268; +r_lld_scan_frm_eof_isr = 0x4000126c; +r_lld_scan_frm_rx_isr = 0x40001270; +r_lld_scan_frm_skip_isr = 0x40001274; +r_lld_scan_init = 0x40001278; +r_lld_scan_params_update = 0x4000127c; +r_lld_scan_process_pkt_rx_aux_adv_ind = 0x40001288; +r_lld_scan_process_pkt_rx_aux_chain_ind = 0x4000128c; +r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40001290; +r_lld_scan_process_pkt_rx_ext_adv = 0x40001294; +r_lld_scan_process_pkt_rx_ext_adv_ind = 0x40001298; +r_lld_scan_process_pkt_rx_legacy_adv = 0x4000129c; +r_lld_scan_restart = 0x400012a0; +r_lld_scan_sched = 0x400012a4; +r_lld_scan_set_tx_power = 0x400012a8; +r_lld_scan_start = 0x400012ac; +r_lld_scan_stop = 0x400012b0; +r_lld_scan_sync_accept = 0x400012b4; +r_lld_scan_sync_info_unpack = 0x400012b8; +r_lld_scan_trunc_ind = 0x400012bc; +r_lld_sw_cca_evt_handler = 0x400012c0; +r_lld_sw_cca_isr = 0x400012c4; +r_lld_sync_ch_map_update = 0x400012c8; +r_lld_sync_cleanup = 0x400012cc; +r_lld_sync_evt_canceled_cbk = 0x400012d0; +r_lld_sync_evt_start_cbk = 0x400012d4; +r_lld_sync_frm_cbk = 0x400012d8; +r_lld_sync_frm_eof_isr = 0x400012dc; +r_lld_sync_frm_rx_isr = 0x400012e0; +r_lld_sync_frm_skip_isr = 0x400012e4; +r_lld_sync_init = 0x400012e8; +r_lld_sync_process_pkt_rx = 0x400012ec; +r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400012f0; +r_lld_sync_process_pkt_rx_pkt_check = 0x400012f4; +r_lld_sync_scan_dynamic_pti_process = 0x400012f8; +r_lld_sync_sched = 0x400012fc; +r_lld_sync_start = 0x40001300; +r_lld_sync_stop = 0x40001304; +r_lld_sync_trunc_ind = 0x40001308; +r_lld_test_cleanup = 0x4000130c; +r_lld_test_evt_canceled_cbk = 0x40001310; +r_lld_test_evt_start_cbk = 0x40001314; +r_lld_test_freq2chnl = 0x40001318; +r_lld_test_frm_cbk = 0x4000131c; +r_lld_test_frm_isr = 0x40001320; +r_lld_test_init = 0x40001324; +r_lld_test_rx_isr = 0x40001328; +r_lld_test_set_tx_power = 0x4000132c; +r_lld_test_start = 0x40001330; +/* r_lld_test_stop = 0x40001334; */ +r_lld_update_rxbuf = 0x40001338; +r_lld_update_rxbuf_isr = 0x4000133c; +r_lld_white_list_add = 0x40001340; +r_lld_white_list_rem = 0x40001344; +r_llm_activity_free_get = 0x40001348; +r_llm_activity_free_set = 0x4000134c; +r_llm_activity_syncing_get = 0x40001350; +r_llm_adv_con_len_check = 0x40001354; +r_llm_adv_hdl_to_id = 0x40001358; +r_llm_adv_rep_flow_control_check = 0x4000135c; +r_llm_adv_rep_flow_control_update = 0x40001360; +r_llm_adv_reports_list_check = 0x40001364; +r_llm_adv_set_all_release = 0x40001368; +r_llm_adv_set_dft_params = 0x4000136c; +r_llm_adv_set_release = 0x40001370; +r_llm_aes_res_cb = 0x40001374; +r_llm_ble_update_adv_flow_control = 0x40001378; +r_llm_ch_map_update = 0x4000137c; +r_llm_cmd_cmp_send = 0x40001380; +r_llm_cmd_stat_send = 0x40001384; +r_llm_dev_list_empty_entry = 0x40001388; +r_llm_dev_list_search = 0x4000138c; +r_llm_env_adv_dup_filt_deinit = 0x40001390; +r_llm_env_adv_dup_filt_init = 0x40001394; +r_llm_init_ble_adv_report_flow_contol = 0x40001398; +r_llm_is_dev_connected = 0x4000139c; +r_llm_is_dev_synced = 0x400013a0; +r_llm_is_non_con_act_ongoing_check = 0x400013a4; +r_llm_is_wl_accessible = 0x400013a8; +r_llm_le_evt_mask_check = 0x400013ac; +r_llm_link_disc = 0x400013b4; +r_llm_master_ch_map_get = 0x400013b8; +r_llm_msg_handler_tab_p_get = 0x400013bc; +r_llm_no_activity = 0x400013c0; +r_llm_per_adv_slot_dur = 0x400013c4; +r_llm_plan_elt_get = 0x400013c8; +r_llm_rx_path_comp_get = 0x400013cc; +r_llm_scan_start = 0x400013d0; +r_llm_scan_sync_acad_attach = 0x400013d4; +r_llm_scan_sync_acad_detach = 0x400013d8; +r_llm_send_adv_lost_event_to_host = 0x400013dc; +r_llm_tx_path_comp_get = 0x400013e0; +r_misc_deinit = 0x400013e4; +r_misc_free_em_buf_in_isr = 0x400013e8; +r_misc_init = 0x400013ec; +r_misc_msg_handler_tab_p_get = 0x400013f0; +r_notEqual256 = 0x400013f4; +r_phy_upd_proc_start = 0x400013f8; +r_platform_reset = 0x400013fc; +r_rf_em_init = 0x40001404; +r_rf_force_agc_enable = 0x40001408; +r_rf_reg_rd = 0x4000140c; +r_rf_reg_wr = 0x40001410; +r_rf_reset = 0x40001414; +r_rf_rssi_convert = 0x40001418; +r_rf_rw_v9_le_disable = 0x4000141c; +r_rf_rw_v9_le_enable = 0x40001420; +r_rf_sleep = 0x40001424; +r_rf_util_cs_fmt_convert = 0x40001430; +r_rw_crypto_aes_ccm = 0x40001434; +r_rw_crypto_aes_encrypt = 0x40001438; +r_rw_crypto_aes_init = 0x4000143c; +r_rw_crypto_aes_k1 = 0x40001440; +r_rw_crypto_aes_k2 = 0x40001444; +r_rw_crypto_aes_k3 = 0x40001448; +r_rw_crypto_aes_k4 = 0x4000144c; +r_rw_crypto_aes_rand = 0x40001450; +r_rw_crypto_aes_result_handler = 0x40001454; +r_rw_crypto_aes_s1 = 0x40001458; +r_rw_cryto_aes_cmac = 0x4000145c; +r_rw_v9_init_em_radio_table = 0x40001460; +r_rwble_sleep_enter = 0x40001468; +r_rwble_sleep_wakeup_end = 0x4000146c; +/* r_rwbtdm_isr_wrapper = 0x40001470; */ +r_rwip_active_check = 0x40001474; +r_rwip_aes_encrypt = 0x40001478; +/* r_rwip_assert = 0x4000147c; */ +r_rwip_crypt_evt_handler = 0x40001480; +r_rwip_crypt_isr_handler = 0x40001484; +r_rwip_eif_get = 0x40001488; +r_rwip_half_slot_2_lpcycles = 0x4000148c; +r_rwip_hus_2_lpcycles = 0x40001490; +r_rwip_isr = 0x40001494; +r_rwip_lpcycles_2_hus = 0x40001498; +r_rwip_prevent_sleep_clear = 0x4000149c; +r_rwip_prevent_sleep_set = 0x400014a0; +r_rwip_schedule = 0x400014a4; +r_rwip_sleep = 0x400014a8; +r_rwip_sw_int_handler = 0x400014ac; +r_rwip_sw_int_req = 0x400014b0; +r_rwip_time_get = 0x400014b4; +r_rwip_timer_10ms_handler = 0x400014b8; +r_rwip_timer_10ms_set = 0x400014bc; +r_rwip_timer_hs_handler = 0x400014c0; +r_rwip_timer_hs_set = 0x400014c4; +r_rwip_timer_hus_handler = 0x400014c8; +r_rwip_timer_hus_set = 0x400014cc; +r_rwip_wakeup = 0x400014d0; +/* r_rwip_wakeup_end = 0x400014d4; */ +r_rwip_wlcoex_set = 0x400014d8; +r_sch_alarm_clear = 0x400014dc; +r_sch_alarm_init = 0x400014e0; +r_sch_alarm_prog = 0x400014e4; +r_sch_alarm_set = 0x400014e8; +r_sch_alarm_timer_isr = 0x400014ec; +r_sch_arb_conflict_check = 0x400014f0; +r_sch_arb_elt_cancel = 0x400014f4; +r_sch_arb_init = 0x400014fc; +r_sch_arb_insert = 0x40001500; +r_sch_arb_prog_timer = 0x40001504; +r_sch_arb_remove = 0x40001508; +r_sch_arb_sw_isr = 0x4000150c; +r_sch_plan_chk = 0x40001510; +r_sch_plan_clock_wrap_offset_update = 0x40001514; +r_sch_plan_init = 0x40001518; +r_sch_plan_interval_req = 0x4000151c; +r_sch_plan_offset_max_calc = 0x40001520; +r_sch_plan_offset_req = 0x40001524; +r_sch_plan_position_range_compute = 0x40001528; +r_sch_plan_rem = 0x4000152c; +r_sch_plan_req = 0x40001530; +r_sch_prog_init = 0x4000153c; +r_sch_prog_push = 0x40001540; +r_sch_prog_rx_isr = 0x40001544; +r_sch_prog_skip_isr = 0x40001548; +r_sch_prog_tx_isr = 0x4000154c; +r_sch_slice_bg_add = 0x40001550; +r_sch_slice_bg_remove = 0x40001554; +r_sch_slice_compute = 0x40001558; +r_sch_slice_fg_add = 0x4000155c; +r_sch_slice_fg_remove = 0x40001560; +r_sch_slice_init = 0x40001564; +r_sch_slice_per_add = 0x40001568; +r_sch_slice_per_remove = 0x4000156c; +r_sdk_config_get_bt_sleep_enable = 0x40001570; +r_sdk_config_get_hl_derived_opts = 0x40001574; +r_sdk_config_get_opts = 0x40001578; +r_sdk_config_get_priv_opts = 0x4000157c; +r_sdk_config_set_bt_sleep_enable = 0x40001580; +r_sdk_config_set_hl_derived_opts = 0x40001584; +r_sdk_config_set_opts = 0x40001588; +r_specialModP256 = 0x4000158c; +r_unloaded_area_init = 0x40001590; +r_vhci_flow_off = 0x40001594; +r_vhci_flow_on = 0x40001598; +r_vhci_notify_host_send_available = 0x4000159c; +r_vhci_send_to_host = 0x400015a0; +r_vnd_hci_command_handler = 0x400015a4; +r_vshci_init = 0x400015a8; +vnd_hci_command_handler_wrapper = 0x400015ac; + +/* bluetooth hook funcs */ +r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; +r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; +r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; +r_lld_scan_frm_eof_isr_hook = 0x40001c6c; +r_lld_scan_evt_start_cbk_hook = 0x40001c70; +r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; +r_lld_scan_sched_hook = 0x40001c7c; +r_lld_adv_evt_start_cbk_hook = 0x40001c84; +r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; +r_lld_adv_frm_isr_hook = 0x40001c8c; +r_lld_adv_start_init_evt_param_hook = 0x40001c90; +r_lld_con_evt_canceled_cbk_hook = 0x40001c94; +r_lld_con_frm_isr_hook = 0x40001c98; +r_lld_con_tx_hook = 0x40001c9c; +r_lld_con_rx_hook = 0x40001ca0; +r_lld_con_evt_start_cbk_hook = 0x40001ca4; +r_lld_con_tx_prog_new_packet_hook = 0x40001cac; +r_lld_init_frm_eof_isr_hook = 0x40001cb0; +r_lld_init_evt_start_cbk_hook = 0x40001cb4; +r_lld_init_sched_hook = 0x40001cbc; +r_lld_init_process_pkt_tx_hook = 0x40001cc0; +r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; +r_lld_per_adv_frm_isr_hook = 0x40001cc8; +r_lld_per_adv_start_hook = 0x40001ccc; +r_lld_sync_frm_eof_isr_hook = 0x40001cd0; +r_lld_sync_evt_start_cbk_hook = 0x40001cd4; +r_lld_sync_start_hook = 0x40001cd8; +r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; +r_sch_arb_insert_hook = 0x40001ce0; +r_sch_plan_offset_req_hook = 0x40001ce4; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld index 969dd372d8b..edad2237dc7 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3.ld @@ -44,38 +44,6 @@ ppProcTxCallback = 0x40001b30; ieee80211_gettid = 0x40001b34; -/*************************************** - Group eco3_bluetooth - ***************************************/ - -/* Functions */ -r_lld_legacy_adv_dynamic_pti_get = 0x40001b38; -r_lld_legacy_adv_dynamic_pti_process = 0x40001b3c; -r_lld_ext_adv_dynamic_pti_get = 0x40001b40; -r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44; -r_lld_ext_adv_dynamic_pti_process = 0x40001b48; -/* r_lld_adv_ext_pkt_prepare_set = 0x40001b4c; */ -r_lld_adv_ext_chain_connectable_construct = 0x40001b54; -r_lld_adv_pkt_rx_connect_post = 0x40001b5c; -r_lld_adv_start_init_evt_param = 0x40001b60; -r_lld_adv_start_set_cs = 0x40001b64; -/* r_lld_adv_start_update_filter_policy = 0x40001b68; */ -r_lld_adv_start_schedule_asap = 0x40001b6c; -r_lld_con_tx_prog_new_packet_coex = 0x40001b70; -r_lld_per_adv_dynamic_pti_get = 0x40001b78; -r_lld_per_adv_evt_start_chm_upd = 0x40001b7c; -r_lld_ext_scan_dynamic_pti_get = 0x40001b80; -r_lld_sync_insert = 0x40001b88; -r_sch_prog_ble_push = 0x40001b8c; -r_sch_prog_bt_push = 0x40001b90; -r_lld_init_evt_end_type_set = 0x40001b94; -r_lld_init_evt_end_type_get = 0x40001b98; -r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40001b9c; -r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x40001ba0; -r_lld_init_evt_end_type_check_state_set = 0x40001ba4; -r_lld_init_evt_end_type_check_state_get = 0x40001ba8; - - /*************************************** Group eco3_phy ***************************************/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld new file mode 100644 index 00000000000..6f67b8ddc33 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco3_bt_funcs.ld @@ -0,0 +1,45 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* +ESP32C3 ECO3 ROM address table +Version 3 API's imported from the ROM +*/ + + +/*************************************** + Group eco3_bluetooth + ***************************************/ + +/* Functions */ +r_lld_legacy_adv_dynamic_pti_get = 0x40001b38; +r_lld_legacy_adv_dynamic_pti_process = 0x40001b3c; +r_lld_ext_adv_dynamic_pti_get = 0x40001b40; +r_lld_ext_adv_dynamic_aux_pti_process = 0x40001b44; +r_lld_ext_adv_dynamic_pti_process = 0x40001b48; +/* +r_lld_adv_ext_pkt_prepare_set = 0x40001b4c; +*/ +r_lld_adv_ext_chain_connectable_construct = 0x40001b54; +r_lld_adv_pkt_rx_connect_post = 0x40001b5c; +r_lld_adv_start_init_evt_param = 0x40001b60; +r_lld_adv_start_set_cs = 0x40001b64; +/* r_lld_adv_start_update_filter_policy = 0x40001b68; */ +r_lld_adv_start_schedule_asap = 0x40001b6c; +r_lld_con_tx_prog_new_packet_coex = 0x40001b70; +r_lld_per_adv_dynamic_pti_get = 0x40001b78; +r_lld_per_adv_evt_start_chm_upd = 0x40001b7c; +r_lld_ext_scan_dynamic_pti_get = 0x40001b80; +r_lld_sync_insert = 0x40001b88; +/* +r_sch_prog_ble_push = 0x40001b8c; +*/ +r_sch_prog_bt_push = 0x40001b90; +r_lld_init_evt_end_type_set = 0x40001b94; +r_lld_init_evt_end_type_get = 0x40001b98; +r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40001b9c; +r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x40001ba0; +r_lld_init_evt_end_type_check_state_set = 0x40001ba4; +r_lld_init_evt_end_type_check_state_get = 0x40001ba8; diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld index fb6938026c0..41445a1b543 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7.ld @@ -93,132 +93,6 @@ rom1_phy_close_rf = 0x40001c18; uart_tx_switch = 0x40001c44; -/*************************************** - Group eco7_bluetooth - ***************************************/ - -/* Functions */ -r_lld_con_count_get = 0x40001c48; -r_lld_update_con_offset = 0x40001c4c; -r_lld_con_update_last_clock = 0x40001c50; -r_lld_con_llcp_ind_info_clear = 0x40001c54; -r_lld_con_update_terminte_info_init = 0x40001c58; -r_lld_con_terminate_max_evt_update = 0x40001c5c; -r_llc_pref_param_compute_eco = 0x40001ce8; -r_llc_hci_con_upd_info_send_eco = 0x40001cec; -r_llc_rem_encrypt_proc_continue_eco = 0x40001cf0; -r_llc_start_eco = 0x40001cf8; -r_lld_ext_adv_dynamic_aux_pti_process_eco = 0x40001cfc; -r_lld_adv_start_eco = 0x40001d04; -r_lld_con_evt_canceled_cbk_eco = 0x40001d08; -r_lld_con_evt_time_update_eco = 0x40001d0c; -r_lld_con_start_eco = 0x40001d10; -r_lld_con_frm_isr_eco = 0x40001d14; -r_lld_con_tx_eco = 0x40001d18; -r_lld_ext_scan_dynamic_pti_process_eco = 0x40001d28; -r_lld_scan_frm_eof_isr_eco = 0x40001d2c; -r_lld_sync_start_eco = 0x40001d30; -r_lld_sync_insert_eco = 0x40001d34; -r_llm_adv_rep_flow_control_update_eco = 0x40001d38; -r_llm_env_adv_dup_filt_init_eco = 0x40001d3c; -r_llm_env_adv_dup_filt_deinit_eco = 0x40001d40; -r_llm_adv_rep_flow_control_check_eco = 0x40001d44; -r_llm_scan_start_eco = 0x40001d48; -r_llm_update_duplicate_scan_count = 0x40001d4c; -r_llc_hci_command_handler_pre = 0x40001d50; -r_llc_hci_command_handler_get = 0x40001d54; -r_llc_hci_command_handler_search = 0x40001d58; -r_llc_llcp_pdu_handler_pre = 0x40001d60; -r_llc_llcp_pdu_handler_end = 0x40001d64; -r_llc_con_conflict_check = 0x40001d6c; -r_sch_prog_hw_reset_try = 0x40001d70; -r_sch_prog_et_state_reset = 0x40001d74; -r_sch_prog_end_isr_handler = 0x40001d78; -r_sch_plan_conflict_check = 0x40001d7c; -r_rwble_isr_hw_fixed = 0x40001d80; -r_bt_bb_recorrect_is_dead = 0x40001d84; -r_bt_bb_restart_hw_recorrect = 0x40001d88; -r_ke_task_handler_pre = 0x40001da0; -r_ke_task_handler_end = 0x40001da4; -r_lld_scan_frm_skip_isr_eco = 0x40001db0; -r_lld_ext_scan_dynamic_pti_reset = 0x40001db4; -r_llc_rem_phy_upd_proc_continue_eco = 0x40001db8; -r_llm_get_preferred_phys = 0x40001dbc; -r_lld_hw_cca_isr_eco = 0x40001dc0; -r_lld_sw_cca_isr_eco = 0x40001dc4; -r_lld_cca_chan_prn_e = 0x40001dc8; -r_lld_cca_chan_prn_s = 0x40001dcc; -r_lld_cca_chan_sel_remap = 0x40001dd0; -r_lld_cca_chan_sel_1 = 0x40001dd4; -r_lld_cca_chan_sel_2 = 0x40001dd8; -r_lld_cca_set_thresh = 0x40001ddc; -r_lld_cca_con_start = 0x40001de0; -r_lld_cca_con_end = 0x40001de4; -r_lld_cca_chm_restore = 0x40001de8; -r_lld_cca_chan_unused_check = 0x40001dec; -r_lld_cca_chm_update_check = 0x40001df0; -r_lld_cca_busy_mode_handle = 0x40001df4; -r_lld_cca_lbt_handle = 0x40001df8; -r_lld_cca_scst_timeout_check = 0x40001dfc; -r_lld_cca_chan_avl_timeout_check = 0x40001e00; - -r_lld_con_start_hook = 0x40001ca8; - -/* ble Functions eco */ -r_bt_bb_isr = 0x40000b9c; -r_bt_rf_coex_conn_phy_coded_data_time_limit_en_get = 0x40000ba8; -r_bt_rtp_get_txpwr_idx_by_act = 0x40000c00; -r_btdm_task_post = 0x40000c14; -r_btdm_task_post_from_isr = 0x40000c18; -r_btdm_task_recycle = 0x40000c1c; -r_ke_task_schedule = 0x40000e80; -r_llc_hci_command_handler = 0x40000ef0; -r_llc_loc_ch_map_proc_continue = 0x40000f5c; -r_llc_loc_con_upd_proc_continue = 0x40000f60; -r_llc_loc_phy_upd_proc_continue = 0x40000f78; -r_llc_rem_con_upd_proc_continue = 0x40000fb4; -r_lld_con_sched = 0x40001118; -r_lld_con_stop = 0x40001124; -r_lld_llcp_rx_ind_handler = 0x400011b0; -r_lld_per_adv_sched = 0x400011f8; -r_rf_txpwr_cs_get = 0x40001428; -r_rf_txpwr_dbm_get = 0x4000142c; -r_sch_arb_event_start_isr = 0x400014f8; -r_sch_plan_set = 0x40001534; -r_sch_prog_end_isr = 0x40001538; -r_lld_adv_ext_chain_scannable_construct = 0x40001b58; - -r_lld_scan_process_pkt_rx = 0x40001280; -r_llm_le_features_get = 0x400013b0; - -/* ble functions rename */ -r_lld_init_start_hack = 0x400011a4; - -/* ble functions disable */ -/* -r_lld_adv_frm_isr_eco = 0x40001d00; -r_lld_res_list_clear = 0x40004638; -r_lld_res_list_rem = 0x40004680; -r_lld_adv_start_hook = 0x40001c80; -r_lld_con_evt_start_cbk_eco = 0x40001d1c; -r_lld_con_tx_prog_new_packet = 0x40001b74; -r_lld_adv_ext_chain_none_construct = 0x40001b50; -r_llc_llcp_send_eco = 0x40001cf4; -r_llc_llcp_channel_map_ind_ack = 0x40001d68; -r_rwble_isr = 0x40001464; -r_lld_scan_start_eco = 0x40001d24; -r_lld_scan_try_sched_eco = 0x40001dac; -r_lld_scan_start_hook = 0x40001c74; -r_lld_init_start_hook = 0x40001cb8; -r_lld_scan_evt_start_cbk_eco = 0x40001d20; -r_ke_task_handler_get_overwrite = 0x40001da8; -r_hci_register_vendor_desc_tab = 0x40000d9c; -r_lld_scan_process_pkt_rx_adv_rep = 0x40001284; -r_register_esp_vendor_cmd_handler = 0x40001400; -r_llc_llcp_pdu_handler_get_overwrite = 0x40001d5c; -*/ - - /*************************************** Group eco7_phy ***************************************/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld new file mode 100644 index 00000000000..33b0ed595d6 --- /dev/null +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.eco7_bt_funcs.ld @@ -0,0 +1,130 @@ +/* + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/*************************************** + Group eco7_bluetooth + ***************************************/ + +/* Functions */ +r_lld_con_count_get = 0x40001c48; +r_lld_update_con_offset = 0x40001c4c; +r_lld_con_update_last_clock = 0x40001c50; +r_lld_con_llcp_ind_info_clear = 0x40001c54; +r_lld_con_update_terminte_info_init = 0x40001c58; +r_lld_con_terminate_max_evt_update = 0x40001c5c; +r_llc_pref_param_compute_eco = 0x40001ce8; +r_llc_hci_con_upd_info_send_eco = 0x40001cec; +r_llc_rem_encrypt_proc_continue_eco = 0x40001cf0; +r_llc_start_eco = 0x40001cf8; +r_lld_ext_adv_dynamic_aux_pti_process_eco = 0x40001cfc; +r_lld_adv_start_eco = 0x40001d04; +r_lld_con_evt_canceled_cbk_eco = 0x40001d08; +r_lld_con_evt_time_update_eco = 0x40001d0c; +r_lld_con_start_eco = 0x40001d10; +r_lld_con_frm_isr_eco = 0x40001d14; +r_lld_con_tx_eco = 0x40001d18; +r_lld_ext_scan_dynamic_pti_process_eco = 0x40001d28; +r_lld_scan_frm_eof_isr_eco = 0x40001d2c; +r_lld_sync_start_eco = 0x40001d30; +r_lld_sync_insert_eco = 0x40001d34; +r_llm_adv_rep_flow_control_update_eco = 0x40001d38; +r_llm_env_adv_dup_filt_init_eco = 0x40001d3c; +r_llm_env_adv_dup_filt_deinit_eco = 0x40001d40; +r_llm_adv_rep_flow_control_check_eco = 0x40001d44; +r_llm_scan_start_eco = 0x40001d48; +r_llm_update_duplicate_scan_count = 0x40001d4c; +r_llc_hci_command_handler_pre = 0x40001d50; +r_llc_hci_command_handler_get = 0x40001d54; +r_llc_hci_command_handler_search = 0x40001d58; +r_llc_llcp_pdu_handler_pre = 0x40001d60; +r_llc_llcp_pdu_handler_end = 0x40001d64; +r_llc_con_conflict_check = 0x40001d6c; +r_sch_prog_hw_reset_try = 0x40001d70; +r_sch_prog_et_state_reset = 0x40001d74; +r_sch_prog_end_isr_handler = 0x40001d78; +r_sch_plan_conflict_check = 0x40001d7c; +r_rwble_isr_hw_fixed = 0x40001d80; +r_bt_bb_recorrect_is_dead = 0x40001d84; +r_bt_bb_restart_hw_recorrect = 0x40001d88; +r_ke_task_handler_pre = 0x40001da0; +r_ke_task_handler_end = 0x40001da4; +r_lld_scan_frm_skip_isr_eco = 0x40001db0; +r_lld_ext_scan_dynamic_pti_reset = 0x40001db4; +r_llc_rem_phy_upd_proc_continue_eco = 0x40001db8; +r_llm_get_preferred_phys = 0x40001dbc; +r_lld_hw_cca_isr_eco = 0x40001dc0; +r_lld_sw_cca_isr_eco = 0x40001dc4; +r_lld_cca_chan_prn_e = 0x40001dc8; +r_lld_cca_chan_prn_s = 0x40001dcc; +r_lld_cca_chan_sel_remap = 0x40001dd0; +r_lld_cca_chan_sel_1 = 0x40001dd4; +r_lld_cca_chan_sel_2 = 0x40001dd8; +r_lld_cca_set_thresh = 0x40001ddc; +r_lld_cca_con_start = 0x40001de0; +r_lld_cca_con_end = 0x40001de4; +r_lld_cca_chm_restore = 0x40001de8; +r_lld_cca_chan_unused_check = 0x40001dec; +r_lld_cca_chm_update_check = 0x40001df0; +r_lld_cca_busy_mode_handle = 0x40001df4; +r_lld_cca_lbt_handle = 0x40001df8; +r_lld_cca_scst_timeout_check = 0x40001dfc; +r_lld_cca_chan_avl_timeout_check = 0x40001e00; + +r_lld_con_start_hook = 0x40001ca8; + +/* ble Functions eco */ +r_bt_bb_isr = 0x40000b9c; +r_bt_rf_coex_conn_phy_coded_data_time_limit_en_get = 0x40000ba8; +r_bt_rtp_get_txpwr_idx_by_act = 0x40000c00; +r_btdm_task_post = 0x40000c14; +r_btdm_task_post_from_isr = 0x40000c18; +r_btdm_task_recycle = 0x40000c1c; +r_ke_task_schedule = 0x40000e80; +r_llc_hci_command_handler = 0x40000ef0; +r_llc_loc_ch_map_proc_continue = 0x40000f5c; +r_llc_loc_con_upd_proc_continue = 0x40000f60; +r_llc_loc_phy_upd_proc_continue = 0x40000f78; +r_llc_rem_con_upd_proc_continue = 0x40000fb4; +r_lld_con_sched = 0x40001118; +r_lld_con_stop = 0x40001124; +r_lld_llcp_rx_ind_handler = 0x400011b0; +r_lld_per_adv_sched = 0x400011f8; +r_rf_txpwr_cs_get = 0x40001428; +r_rf_txpwr_dbm_get = 0x4000142c; +r_sch_arb_event_start_isr = 0x400014f8; +r_sch_plan_set = 0x40001534; +r_sch_prog_end_isr = 0x40001538; +r_lld_adv_ext_chain_scannable_construct = 0x40001b58; + +r_lld_scan_process_pkt_rx = 0x40001280; +r_llm_le_features_get = 0x400013b0; + +/* ble functions rename */ +r_lld_init_start_hack = 0x400011a4; + +/* ble functions disable */ +/* +r_lld_adv_frm_isr_eco = 0x40001d00; +r_lld_res_list_clear = 0x40004638; +r_lld_res_list_rem = 0x40004680; +r_lld_adv_start_hook = 0x40001c80; +r_lld_con_evt_start_cbk_eco = 0x40001d1c; +r_lld_con_tx_prog_new_packet = 0x40001b74; +r_lld_adv_ext_chain_none_construct = 0x40001b50; +r_llc_llcp_send_eco = 0x40001cf4; +r_llc_llcp_channel_map_ind_ack = 0x40001d68; +r_rwble_isr = 0x40001464; +r_lld_scan_start_eco = 0x40001d24; +r_lld_scan_try_sched_eco = 0x40001dac; +r_lld_scan_start_hook = 0x40001c74; +r_lld_init_start_hook = 0x40001cb8; +r_lld_scan_evt_start_cbk_eco = 0x40001d20; +r_ke_task_handler_get_overwrite = 0x40001da8; +r_hci_register_vendor_desc_tab = 0x40000d9c; +r_lld_scan_process_pkt_rx_adv_rep = 0x40001284; +r_register_esp_vendor_cmd_handler = 0x40001400; +r_llc_llcp_pdu_handler_get_overwrite = 0x40001d5c; +*/ diff --git a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld index 1299d2f21a6..33944248095 100644 --- a/components/esp_rom/esp32c3/ld/esp32c3.rom.ld +++ b/components/esp_rom/esp32c3/ld/esp32c3.rom.ld @@ -525,800 +525,6 @@ PROVIDE( g_usb_print = 0x3fcdffd0 ); /*************************************** Group bluetooth ***************************************/ - -/* Functions */ -bt_rf_coex_get_dft_cfg = 0x400008dc; -bt_rf_coex_hooks_p_set = 0x400008e0; -btdm_con_maxevtime_cal_impl = 0x400008e4; -btdm_controller_get_compile_version_impl = 0x400008e8; -btdm_controller_rom_data_init = 0x400008ec; -btdm_dis_privacy_err_report_impl = 0x400008f0; -btdm_disable_adv_delay_impl = 0x400008f4; -btdm_enable_scan_continue_impl = 0x400008f8; -btdm_enable_scan_forever_impl = 0x400008fc; -btdm_get_power_state_impl = 0x40000900; -btdm_get_prevent_sleep_flag_impl = 0x40000904; -btdm_power_state_active_impl = 0x40000908; -btdm_switch_phy_coded_impl = 0x4000090c; -hci_acl_data_handler = 0x40000910; -hci_disconnect_cmd_handler = 0x40000914; -hci_le_con_upd_cmd_handler = 0x40000918; -hci_le_ltk_req_neg_reply_cmd_handler = 0x4000091c; -hci_le_ltk_req_reply_cmd_handler = 0x40000920; -hci_le_rd_chnl_map_cmd_handler = 0x40000924; -hci_le_rd_phy_cmd_handler = 0x40000928; -hci_le_rd_rem_feats_cmd_handler = 0x4000092c; -hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40000930; -hci_le_rem_con_param_req_reply_cmd_handler = 0x40000934; -hci_le_set_data_len_cmd_handler = 0x40000938; -hci_le_set_phy_cmd_handler = 0x4000093c; -hci_le_start_enc_cmd_handler = 0x40000940; -hci_rd_auth_payl_to_cmd_handler = 0x40000944; -hci_rd_rem_ver_info_cmd_handler = 0x40000948; -hci_rd_rssi_cmd_handler = 0x4000094c; -hci_rd_tx_pwr_lvl_cmd_handler = 0x40000950; -hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40000954; -hci_vs_set_pref_slave_latency_cmd_handler = 0x40000958; -hci_wr_auth_payl_to_cmd_handler = 0x4000095c; -ll_channel_map_ind_handler = 0x40000960; -ll_connection_param_req_handler = 0x40000964; -ll_connection_param_rsp_handler = 0x40000968; -ll_connection_update_ind_handler = 0x4000096c; -ll_enc_req_handler = 0x40000970; -ll_enc_rsp_handler = 0x40000974; -ll_feature_req_handler = 0x40000978; -ll_feature_rsp_handler = 0x4000097c; -ll_length_req_handler = 0x40000980; -ll_length_rsp_handler = 0x40000984; -ll_min_used_channels_ind_handler = 0x40000988; -ll_pause_enc_req_handler = 0x4000098c; -ll_pause_enc_rsp_handler = 0x40000990; -ll_phy_req_handler = 0x40000994; -ll_phy_rsp_handler = 0x40000998; -ll_phy_update_ind_handler = 0x4000099c; -ll_ping_req_handler = 0x400009a0; -ll_ping_rsp_handler = 0x400009a4; -ll_slave_feature_req_handler = 0x400009a8; -ll_start_enc_req_handler = 0x400009ac; -ll_start_enc_rsp_handler = 0x400009b0; -ll_terminate_ind_handler = 0x400009b4; -ll_version_ind_handler = 0x400009b8; -llc_auth_payl_nearly_to_handler = 0x400009bc; -llc_auth_payl_real_to_handler = 0x400009c0; -llc_encrypt_ind_handler = 0x400009c4; -llc_hci_command_handler_wrapper = 0x400009c8; -llc_ll_connection_param_req_pdu_send = 0x400009cc; -llc_ll_connection_param_rsp_pdu_send = 0x400009d0; -llc_ll_connection_update_ind_pdu_send = 0x400009d4; -llc_ll_enc_req_pdu_send = 0x400009d8; -llc_ll_enc_rsp_pdu_send = 0x400009dc; -llc_ll_feature_req_pdu_send = 0x400009e0; -llc_ll_feature_rsp_pdu_send = 0x400009e4; -llc_ll_length_req_pdu_send = 0x400009e8; -llc_ll_length_rsp_pdu_send = 0x400009ec; -llc_ll_pause_enc_req_pdu_send = 0x400009f0; -llc_ll_pause_enc_rsp_pdu_send = 0x400009f4; -llc_ll_phy_req_pdu_send = 0x400009f8; -llc_ll_phy_rsp_pdu_send = 0x400009fc; -llc_ll_ping_req_pdu_send = 0x40000a00; -llc_ll_ping_rsp_pdu_send = 0x40000a04; -llc_ll_start_enc_req_pdu_send = 0x40000a08; -llc_ll_start_enc_rsp_pdu_send = 0x40000a0c; -llc_ll_terminate_ind_pdu_send = 0x40000a10; -llc_ll_unknown_rsp_pdu_send = 0x40000a14; -llc_llcp_ch_map_update_ind_pdu_send = 0x40000a18; -llc_llcp_phy_upd_ind_pdu_send = 0x40000a1c; -llc_llcp_version_ind_pdu_send = 0x40000a20; -llc_op_ch_map_upd_ind_handler = 0x40000a24; -llc_op_con_upd_ind_handler = 0x40000a28; -llc_op_disconnect_ind_handler = 0x40000a2c; -llc_op_dl_upd_ind_handler = 0x40000a30; -llc_op_encrypt_ind_handler = 0x40000a34; -llc_op_feats_exch_ind_handler = 0x40000a38; -llc_op_le_ping_ind_handler = 0x40000a3c; -llc_op_phy_upd_ind_handler = 0x40000a40; -llc_op_ver_exch_ind_handler = 0x40000a44; -llc_stopped_ind_handler = 0x40000a48; -lld_acl_rx_ind_handler = 0x40000a4c; -lld_acl_tx_cfm_handler = 0x40000a50; -lld_adv_end_ind_handler = 0x40000a54; -lld_adv_rep_ind_handler = 0x40000a58; -lld_ch_map_upd_cfm_handler = 0x40000a5c; -lld_con_estab_ind_handler = 0x40000a60; -lld_con_evt_sd_evt_time_set = 0x40000a64; -lld_con_offset_upd_ind_handler = 0x40000a68; -lld_con_param_upd_cfm_handler = 0x40000a6c; -lld_disc_ind_handler = 0x40000a70; -lld_init_end_ind_handler = 0x40000a74; -lld_llcp_rx_ind_handler_wrapper = 0x40000a78; -lld_llcp_tx_cfm_handler = 0x40000a7c; -lld_per_adv_end_ind_handler = 0x40000a80; -lld_per_adv_rep_ind_handler = 0x40000a84; -lld_per_adv_rx_end_ind_handler = 0x40000a88; -lld_phy_coded_500k_get = 0x40000a8c; -lld_phy_upd_cfm_handler = 0x40000a90; -lld_scan_end_ind_handler = 0x40000a94; -lld_scan_req_ind_handler = 0x40000a98; -lld_sync_start_req_handler = 0x40000a9c; -lld_test_end_ind_handler = 0x40000aa0; -lld_update_rxbuf_handler = 0x40000aa4; -llm_ch_map_update_ind_handler = 0x40000aa8; -llm_hci_command_handler_wrapper = 0x40000aac; -llm_scan_period_to_handler = 0x40000ab0; -r_Add2SelfBigHex256 = 0x40000ab4; -r_AddBigHex256 = 0x40000ab8; -r_AddBigHexModP256 = 0x40000abc; -r_AddP256 = 0x40000ac0; -r_AddPdiv2_256 = 0x40000ac4; -r_GF_Jacobian_Point_Addition256 = 0x40000ac8; -r_GF_Jacobian_Point_Double256 = 0x40000acc; -r_GF_Point_Jacobian_To_Affine256 = 0x40000ad0; -r_MultiplyBigHexByUint32_256 = 0x40000ad4; -r_MultiplyBigHexModP256 = 0x40000ad8; -r_MultiplyByU16ModP256 = 0x40000adc; -r_SubtractBigHex256 = 0x40000ae0; -r_SubtractBigHexMod256 = 0x40000ae4; -r_SubtractBigHexUint32_256 = 0x40000ae8; -r_SubtractFromSelfBigHex256 = 0x40000aec; -r_SubtractFromSelfBigHexSign256 = 0x40000af0; -r_aes_alloc = 0x40000af4; -r_aes_ccm_continue = 0x40000af8; -r_aes_ccm_process_e = 0x40000afc; -r_aes_ccm_xor_128_lsb = 0x40000b00; -r_aes_ccm_xor_128_msb = 0x40000b04; -r_aes_cmac_continue = 0x40000b08; -r_aes_cmac_start = 0x40000b0c; -r_aes_k1_continue = 0x40000b10; -r_aes_k2_continue = 0x40000b14; -r_aes_k3_continue = 0x40000b18; -r_aes_k4_continue = 0x40000b1c; -r_aes_shift_left_128 = 0x40000b20; -r_aes_start = 0x40000b24; -r_aes_xor_128 = 0x40000b28; -r_assert_err = 0x40000b2c; -r_assert_param = 0x40000b30; -r_assert_warn = 0x40000b34; -r_bigHexInversion256 = 0x40000b38; -r_ble_sw_cca_check_isr = 0x40000b3c; -r_ble_util_buf_acl_tx_alloc = 0x40000b40; -r_ble_util_buf_acl_tx_elt_get = 0x40000b44; -r_ble_util_buf_acl_tx_free = 0x40000b48; -r_ble_util_buf_acl_tx_free_in_isr = 0x40000b4c; -r_ble_util_buf_adv_tx_alloc = 0x40000b50; -r_ble_util_buf_adv_tx_free = 0x40000b54; -r_ble_util_buf_adv_tx_free_in_isr = 0x40000b58; -r_ble_util_buf_env_deinit = 0x40000b5c; -r_ble_util_buf_env_init = 0x40000b60; -r_ble_util_buf_get_rx_buf_nb = 0x40000b64; -r_ble_util_buf_get_rx_buf_size = 0x40000b68; -r_ble_util_buf_llcp_tx_alloc = 0x40000b6c; -r_ble_util_buf_llcp_tx_free = 0x40000b70; -r_ble_util_buf_rx_alloc = 0x40000b74; -r_ble_util_buf_rx_alloc_in_isr = 0x40000b78; -r_ble_util_buf_rx_free = 0x40000b7c; -r_ble_util_buf_rx_free_in_isr = 0x40000b80; -r_ble_util_buf_set_rx_buf_nb = 0x40000b84; -r_ble_util_buf_set_rx_buf_size = 0x40000b88; -r_ble_util_data_rx_buf_reset = 0x40000b8c; -r_bt_bb_get_intr_mask = 0x40000b90; -r_bt_bb_intr_clear = 0x40000b94; -r_bt_bb_intr_mask_set = 0x40000b98; -r_bt_rf_coex_cfg_set = 0x40000ba0; -r_bt_rf_coex_conn_dynamic_pti_en_get = 0x40000ba4; -r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x40000bac; -r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x40000bb0; -r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40000bb4; -r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x40000bb8; -r_bt_rf_coex_pti_table_get = 0x40000bbc; -r_bt_rf_coex_st_param_get = 0x40000bc0; -r_bt_rf_coex_st_param_set = 0x40000bc4; -r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x40000bc8; -r_bt_rma_apply_rule_cs_fmt = 0x40000bcc; -r_bt_rma_apply_rule_cs_idx = 0x40000bd0; -r_bt_rma_configure = 0x40000bd4; -r_bt_rma_deregister_rule_cs_fmt = 0x40000bd8; -r_bt_rma_deregister_rule_cs_idx = 0x40000bdc; -r_bt_rma_get_ant_by_act = 0x40000be0; -r_bt_rma_init = 0x40000be4; -r_bt_rma_register_rule_cs_fmt = 0x40000be8; -r_bt_rma_register_rule_cs_idx = 0x40000bec; -r_bt_rtp_apply_rule_cs_fmt = 0x40000bf0; -r_bt_rtp_apply_rule_cs_idx = 0x40000bf4; -r_bt_rtp_deregister_rule_cs_fmt = 0x40000bf8; -r_bt_rtp_deregister_rule_cs_idx = 0x40000bfc; -r_bt_rtp_init = 0x40000c04; -r_bt_rtp_register_rule_cs_fmt = 0x40000c08; -r_bt_rtp_register_rule_cs_idx = 0x40000c0c; -r_btdm_isr = 0x40000c10; -r_cali_phase_match_p = 0x40000c20; -r_cmp_abs_time = 0x40000c24; -r_cmp_dest_id = 0x40000c28; -r_cmp_timer_id = 0x40000c2c; -r_co_bdaddr_compare = 0x40000c30; -r_co_ble_pkt_dur_in_us = 0x40000c34; -r_co_list_extract = 0x40000c38; -r_co_list_extract_after = 0x40000c3c; -r_co_list_extract_sublist = 0x40000c40; -r_co_list_find = 0x40000c44; -r_co_list_init = 0x40000c48; -r_co_list_insert_after = 0x40000c4c; -r_co_list_insert_before = 0x40000c50; -r_co_list_merge = 0x40000c54; -r_co_list_pool_init = 0x40000c58; -r_co_list_pop_front = 0x40000c5c; -r_co_list_push_back = 0x40000c60; -r_co_list_push_back_sublist = 0x40000c64; -r_co_list_push_front = 0x40000c68; -r_co_list_size = 0x40000c6c; -r_co_nb_good_le_channels = 0x40000c70; -r_co_util_pack = 0x40000c74; -r_co_util_read_array_size = 0x40000c78; -r_co_util_unpack = 0x40000c7c; -r_dbg_env_deinit = 0x40000c80; -r_dbg_env_init = 0x40000c84; -r_dbg_platform_reset_complete = 0x40000c88; -r_dl_upd_proc_start = 0x40000c8c; -r_dump_data = 0x40000c90; -r_ecc_abort_key256_generation = 0x40000c94; -r_ecc_gen_new_public_key = 0x40000c98; -r_ecc_gen_new_secret_key = 0x40000c9c; -r_ecc_generate_key256 = 0x40000ca0; -r_ecc_get_debug_Keys = 0x40000ca4; -r_ecc_init = 0x40000ca8; -r_ecc_is_valid_point = 0x40000cac; -r_ecc_multiplication_event_handler = 0x40000cb0; -r_ecc_point_multiplication_win_256 = 0x40000cb4; -r_emi_alloc_em_mapping_by_offset = 0x40000cb8; -r_emi_base_reg_lut_show = 0x40000cbc; -r_emi_em_base_reg_show = 0x40000cc0; -r_emi_free_em_mapping_by_offset = 0x40000cc4; -r_emi_get_em_mapping_idx_by_offset = 0x40000cc8; -r_emi_get_mem_addr_by_offset = 0x40000ccc; -r_emi_overwrite_em_mapping_by_offset = 0x40000cd0; -r_esp_vendor_hci_command_handler = 0x40000cd4; -r_get_stack_usage = 0x40000cd8; -r_h4tl_acl_hdr_rx_evt_handler = 0x40000cdc; -r_h4tl_cmd_hdr_rx_evt_handler = 0x40000ce0; -r_h4tl_cmd_pld_rx_evt_handler = 0x40000ce4; -r_h4tl_eif_io_event_post = 0x40000ce8; -r_h4tl_eif_register = 0x40000cec; -r_h4tl_init = 0x40000cf0; -r_h4tl_out_of_sync = 0x40000cf4; -r_h4tl_out_of_sync_check = 0x40000cf8; -r_h4tl_read_hdr = 0x40000cfc; -r_h4tl_read_next_out_of_sync = 0x40000d00; -r_h4tl_read_payl = 0x40000d04; -r_h4tl_read_start = 0x40000d08; -r_h4tl_rx_acl_hdr_extract = 0x40000d0c; -r_h4tl_rx_cmd_hdr_extract = 0x40000d10; -r_h4tl_rx_done = 0x40000d14; -r_h4tl_start = 0x40000d18; -r_h4tl_stop = 0x40000d1c; -r_h4tl_tx_done = 0x40000d20; -r_h4tl_tx_evt_handler = 0x40000d24; -r_h4tl_write = 0x40000d28; -r_hci_acl_tx_data_alloc = 0x40000d2c; -r_hci_acl_tx_data_received = 0x40000d30; -r_hci_basic_cmd_send_2_controller = 0x40000d34; -r_hci_ble_adv_report_filter_check = 0x40000d38; -r_hci_ble_adv_report_tx_check = 0x40000d3c; -r_hci_ble_conhdl_register = 0x40000d40; -r_hci_ble_conhdl_unregister = 0x40000d44; -r_hci_build_acl_data = 0x40000d48; -r_hci_build_cc_evt = 0x40000d4c; -r_hci_build_cs_evt = 0x40000d50; -r_hci_build_evt = 0x40000d54; -r_hci_build_le_evt = 0x40000d58; -r_hci_cmd_get_max_param_size = 0x40000d5c; -r_hci_cmd_received = 0x40000d60; -r_hci_cmd_reject = 0x40000d64; -r_hci_evt_mask_check = 0x40000d68; -r_hci_evt_mask_set = 0x40000d6c; -r_hci_fc_acl_buf_size_set = 0x40000d70; -r_hci_fc_acl_en = 0x40000d74; -r_hci_fc_acl_packet_sent = 0x40000d78; -r_hci_fc_check_host_available_nb_acl_packets = 0x40000d7c; -r_hci_fc_host_nb_acl_pkts_complete = 0x40000d80; -r_hci_fc_init = 0x40000d84; -r_hci_look_for_cmd_desc = 0x40000d88; -r_hci_look_for_evt_desc = 0x40000d8c; -r_hci_look_for_le_evt_desc = 0x40000d90; -r_hci_look_for_le_evt_desc_esp = 0x40000d94; -r_hci_pack_bytes = 0x40000d98; -r_hci_send_2_controller = 0x40000da0; -r_hci_send_2_host = 0x40000da4; -r_hci_tl_c2h_data_flow_on = 0x40000da8; -r_hci_tl_cmd_hdr_rx_evt_handler = 0x40000dac; -r_hci_tl_cmd_pld_rx_evt_handler = 0x40000db0; -r_hci_tl_get_pkt = 0x40000db4; -r_hci_tl_hci_pkt_handler = 0x40000db8; -r_hci_tl_hci_tx_done_evt_handler = 0x40000dbc; -r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40000dc0; -r_hci_tl_save_pkt = 0x40000dc4; -r_hci_tl_send = 0x40000dc8; -r_hci_tx_done = 0x40000dcc; -r_hci_tx_start = 0x40000dd0; -r_hci_tx_trigger = 0x40000dd4; -r_isValidSecretKey_256 = 0x40000dd8; -r_ke_check_malloc = 0x40000ddc; -r_ke_event_callback_set = 0x40000de0; -r_ke_event_clear = 0x40000de4; -r_ke_event_flush = 0x40000de8; -r_ke_event_get = 0x40000dec; -r_ke_event_get_all = 0x40000df0; -r_ke_event_init = 0x40000df4; -r_ke_event_schedule = 0x40000df8; -r_ke_event_set = 0x40000dfc; -r_ke_flush = 0x40000e00; -r_ke_free = 0x40000e04; -r_ke_handler_search = 0x40000e08; -r_ke_init = 0x40000e0c; -r_ke_is_free = 0x40000e10; -r_ke_malloc = 0x40000e14; -r_ke_mem_init = 0x40000e18; -r_ke_mem_is_empty = 0x40000e1c; -r_ke_mem_is_in_heap = 0x40000e20; -r_ke_msg_alloc = 0x40000e24; -r_ke_msg_dest_id_get = 0x40000e28; -r_ke_msg_discard = 0x40000e2c; -r_ke_msg_forward = 0x40000e30; -r_ke_msg_forward_new_id = 0x40000e34; -r_ke_msg_free = 0x40000e38; -r_ke_msg_in_queue = 0x40000e3c; -r_ke_msg_save = 0x40000e40; -r_ke_msg_send = 0x40000e44; -r_ke_msg_send_basic = 0x40000e48; -r_ke_msg_src_id_get = 0x40000e4c; -r_ke_queue_extract = 0x40000e50; -r_ke_queue_insert = 0x40000e54; -r_ke_sleep_check = 0x40000e58; -r_ke_state_get = 0x40000e5c; -r_ke_state_set = 0x40000e60; -r_ke_task_check = 0x40000e64; -r_ke_task_create = 0x40000e68; -r_ke_task_delete = 0x40000e6c; -r_ke_task_handler_get = 0x40000e70; -r_ke_task_init = 0x40000e74; -r_ke_task_msg_flush = 0x40000e78; -r_ke_task_saved_update = 0x40000e7c; -r_ke_time = 0x40000e84; -r_ke_time_cmp = 0x40000e88; -r_ke_time_past = 0x40000e8c; -r_ke_timer_active = 0x40000e90; -r_ke_timer_adjust_all = 0x40000e94; -r_ke_timer_clear = 0x40000e98; -r_ke_timer_init = 0x40000e9c; -r_ke_timer_schedule = 0x40000ea0; -r_ke_timer_set = 0x40000ea4; -r_led_init = 0x40000ea8; -r_led_set_all = 0x40000eac; -r_llc_aes_res_cb = 0x40000eb0; -r_llc_ch_map_up_proc_err_cb = 0x40000eb4; -r_llc_cleanup = 0x40000eb8; -r_llc_cmd_cmp_send = 0x40000ebc; -r_llc_cmd_stat_send = 0x40000ec0; -r_llc_con_move_cbk = 0x40000ec4; -r_llc_con_plan_set_update = 0x40000ec8; -r_llc_con_upd_param_in_range = 0x40000ecc; -r_llc_disconnect = 0x40000ed0; -r_llc_disconnect_end = 0x40000ed4; -r_llc_disconnect_proc_continue = 0x40000ed8; -r_llc_disconnect_proc_err_cb = 0x40000edc; -r_llc_dl_chg_check = 0x40000ee0; -r_llc_dle_proc_err_cb = 0x40000ee4; -r_llc_feats_exch_proc_err_cb = 0x40000ee8; -r_llc_hci_cmd_handler_tab_p_get = 0x40000eec; -r_llc_hci_con_param_req_evt_send = 0x40000ef4; -r_llc_hci_con_upd_info_send = 0x40000ef8; -r_llc_hci_disconnected_dis = 0x40000efc; -r_llc_hci_dl_upd_info_send = 0x40000f00; -r_llc_hci_enc_evt_send = 0x40000f04; -r_llc_hci_feats_info_send = 0x40000f08; -r_llc_hci_le_phy_upd_cmp_evt_send = 0x40000f0c; -r_llc_hci_ltk_request_evt_send = 0x40000f10; -r_llc_hci_nb_cmp_pkts_evt_send = 0x40000f14; -r_llc_hci_version_info_send = 0x40000f18; -r_llc_init_term_proc = 0x40000f1c; -r_llc_iv_skd_rand_gen = 0x40000f20; -r_llc_le_ping_proc_continue = 0x40000f24; -r_llc_le_ping_proc_err_cb = 0x40000f28; -/* r_llc_le_ping_restart = 0x40000f2c; */ -r_llc_le_ping_set = 0x40000f30; -r_llc_ll_pause_enc_rsp_ack_handler = 0x40000f34; -r_llc_ll_reject_ind_ack_handler = 0x40000f38; -r_llc_ll_reject_ind_pdu_send = 0x40000f3c; -r_llc_ll_start_enc_rsp_ack_handler = 0x40000f40; -r_llc_ll_terminate_ind_ack = 0x40000f44; -r_llc_ll_unknown_ind_handler = 0x40000f48; -r_llc_llcp_send = 0x40000f4c; -r_llc_llcp_state_set = 0x40000f50; -r_llc_llcp_trans_timer_set = 0x40000f54; -r_llc_llcp_tx_check = 0x40000f58; -r_llc_loc_con_upd_proc_err_cb = 0x40000f64; -r_llc_loc_dl_upd_proc_continue = 0x40000f68; -r_llc_loc_encrypt_proc_continue = 0x40000f6c; -r_llc_loc_encrypt_proc_err_cb = 0x40000f70; -r_llc_loc_feats_exch_proc_continue = 0x40000f74; -r_llc_loc_phy_upd_proc_err_cb = 0x40000f7c; -r_llc_msg_handler_tab_p_get = 0x40000f80; -r_llc_pref_param_compute = 0x40000f84; -r_llc_proc_collision_check = 0x40000f88; -r_llc_proc_err_ind = 0x40000f8c; -r_llc_proc_get = 0x40000f90; -r_llc_proc_id_get = 0x40000f94; -r_llc_proc_reg = 0x40000f98; -r_llc_proc_state_get = 0x40000f9c; -r_llc_proc_state_set = 0x40000fa0; -r_llc_proc_timer_pause_set = 0x40000fa4; -r_llc_proc_timer_set = 0x40000fa8; -r_llc_proc_unreg = 0x40000fac; -r_llc_rem_ch_map_proc_continue = 0x40000fb0; -r_llc_rem_con_upd_proc_err_cb = 0x40000fb8; -r_llc_rem_dl_upd_proc = 0x40000fbc; -r_llc_rem_encrypt_proc_continue = 0x40000fc0; -r_llc_rem_encrypt_proc_err_cb = 0x40000fc4; -r_llc_rem_phy_upd_proc_continue = 0x40000fc8; -r_llc_rem_phy_upd_proc_err_cb = 0x40000fcc; -r_llc_role_get = 0x40000fd0; -r_llc_sk_gen = 0x40000fd4; -r_llc_start = 0x40000fd8; -r_llc_stop = 0x40000fdc; -r_llc_ver_exch_loc_proc_continue = 0x40000fe0; -r_llc_ver_proc_err_cb = 0x40000fe4; -r_llcp_pdu_handler_tab_p_get = 0x40000fe8; -r_lld_aa_gen = 0x40000fec; -r_lld_adv_adv_data_set = 0x40000ff0; -r_lld_adv_adv_data_update = 0x40000ff4; -r_lld_adv_aux_ch_idx_set = 0x40000ff8; -r_lld_adv_aux_evt_canceled_cbk = 0x40000ffc; -r_lld_adv_aux_evt_start_cbk = 0x40001000; -r_lld_adv_coex_check_ext_adv_synced = 0x40001004; -r_lld_adv_coex_env_reset = 0x40001008; -r_lld_adv_duration_update = 0x4000100c; -r_lld_adv_dynamic_pti_process = 0x40001010; -r_lld_adv_end = 0x40001014; -r_lld_adv_evt_canceled_cbk = 0x40001018; -r_lld_adv_evt_start_cbk = 0x4000101c; -r_lld_adv_ext_chain_construct = 0x40001020; -r_lld_adv_ext_pkt_prepare = 0x40001024; -r_lld_adv_frm_cbk = 0x40001028; -r_lld_adv_frm_isr = 0x4000102c; -r_lld_adv_frm_skip_isr = 0x40001030; -r_lld_adv_init = 0x40001034; -r_lld_adv_pkt_rx = 0x40001038; -r_lld_adv_pkt_rx_connect_ind = 0x4000103c; -r_lld_adv_pkt_rx_send_scan_req_evt = 0x40001040; -r_lld_adv_rand_addr_update = 0x40001044; -r_lld_adv_restart = 0x40001048; -r_lld_adv_scan_rsp_data_set = 0x4000104c; -r_lld_adv_scan_rsp_data_update = 0x40001050; -r_lld_adv_set_tx_power = 0x40001054; -r_lld_adv_start = 0x40001058; -r_lld_adv_stop = 0x4000105c; -r_lld_adv_sync_info_set = 0x40001060; -r_lld_adv_sync_info_update = 0x40001064; -r_lld_calc_aux_rx = 0x40001068; -r_lld_cca_alloc = 0x4000106c; -r_lld_cca_data_reset = 0x40001070; -r_lld_cca_free = 0x40001074; -r_lld_ch_assess_data_get = 0x40001078; -r_lld_ch_idx_get = 0x4000107c; -r_lld_ch_map_set = 0x40001080; -r_lld_channel_assess = 0x40001084; -r_lld_con_activity_act_offset_compute = 0x40001088; -r_lld_con_activity_offset_compute = 0x4000108c; -r_lld_con_ch_map_update = 0x40001090; -r_lld_con_cleanup = 0x40001094; -r_lld_con_current_tx_power_get = 0x40001098; -r_lld_con_data_flow_set = 0x4000109c; -r_lld_con_data_len_update = 0x400010a0; -r_lld_con_data_tx = 0x400010a4; -r_lld_con_enc_key_load = 0x400010a8; -r_lld_con_event_counter_get = 0x400010ac; -r_lld_con_evt_canceled_cbk = 0x400010b0; -r_lld_con_evt_duration_min_get = 0x400010b4; -r_lld_con_evt_max_eff_time_cal = 0x400010b8; -r_lld_con_evt_sd_evt_time_get = 0x400010bc; -r_lld_con_evt_start_cbk = 0x400010c0; -r_lld_con_evt_time_update = 0x400010c4; -r_lld_con_free_all_tx_buf = 0x400010c8; -r_lld_con_frm_cbk = 0x400010cc; -r_lld_con_frm_isr = 0x400010d0; -r_lld_con_frm_skip_isr = 0x400010d4; -r_lld_con_init = 0x400010d8; -r_lld_con_llcp_tx = 0x400010dc; -r_lld_con_max_lat_calc = 0x400010e0; -r_lld_con_offset_get = 0x400010e4; -r_lld_con_param_update = 0x400010e8; -r_lld_con_phys_update = 0x400010ec; -r_lld_con_pref_slave_evt_dur_set = 0x400010f0; -r_lld_con_pref_slave_latency_set = 0x400010f4; -r_lld_con_rssi_get = 0x400010f8; -r_lld_con_rx = 0x400010fc; -/* r_lld_con_rx_channel_assess = 0x40001100; */ -r_lld_con_rx_enc = 0x40001104; -r_lld_con_rx_isr = 0x40001108; -r_lld_con_rx_link_info_check = 0x4000110c; -r_lld_con_rx_llcp_check = 0x40001110; -r_lld_con_rx_sync_time_update = 0x40001114; -r_lld_con_set_tx_power = 0x4000111c; -r_lld_con_start = 0x40001120; -r_lld_con_tx = 0x40001128; -r_lld_con_tx_enc = 0x4000112c; -r_lld_con_tx_isr = 0x40001130; -r_lld_con_tx_len_update = 0x40001134; -r_lld_con_tx_len_update_for_intv = 0x40001138; -r_lld_con_tx_len_update_for_rate = 0x4000113c; -r_lld_con_tx_prog = 0x40001140; -r_lld_conn_dynamic_pti_process = 0x40001144; -r_lld_continue_scan_rx_isr_end_process = 0x40001148; -r_lld_ext_scan_dynamic_pti_process = 0x4000114c; -r_lld_hw_cca_end_isr = 0x40001150; -r_lld_hw_cca_evt_handler = 0x40001154; -r_lld_hw_cca_isr = 0x40001158; -r_lld_init_cal_anchor_point = 0x4000115c; -r_lld_init_compute_winoffset = 0x40001160; -r_lld_init_connect_req_pack = 0x40001164; -r_lld_init_end = 0x40001168; -r_lld_init_evt_canceled_cbk = 0x4000116c; -r_lld_init_evt_start_cbk = 0x40001170; -r_lld_init_frm_cbk = 0x40001174; -r_lld_init_frm_eof_isr = 0x40001178; -r_lld_init_frm_skip_isr = 0x4000117c; -r_lld_init_init = 0x40001180; -r_lld_init_process_pkt_rx = 0x40001184; -r_lld_init_process_pkt_rx_adv_ext_ind = 0x40001188; -r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x4000118c; -r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40001190; -r_lld_init_process_pkt_tx = 0x40001194; -r_lld_init_process_pkt_tx_cal_con_timestamp = 0x40001198; -r_lld_init_sched = 0x4000119c; -r_lld_init_set_tx_power = 0x400011a0; -r_lld_init_start = 0x400011a4; -r_lld_init_stop = 0x400011a8; -r_lld_instant_proc_end = 0x400011ac; -r_lld_per_adv_ch_map_update = 0x400011b4; -r_lld_per_adv_chain_construct = 0x400011b8; -r_lld_per_adv_cleanup = 0x400011bc; -r_lld_per_adv_coex_env_reset = 0x400011c0; -r_lld_per_adv_data_set = 0x400011c4; -r_lld_per_adv_data_update = 0x400011c8; -r_lld_per_adv_dynamic_pti_process = 0x400011cc; -r_lld_per_adv_evt_canceled_cbk = 0x400011d0; -r_lld_per_adv_evt_start_cbk = 0x400011d4; -r_lld_per_adv_ext_pkt_prepare = 0x400011d8; -r_lld_per_adv_frm_cbk = 0x400011dc; -r_lld_per_adv_frm_isr = 0x400011e0; -r_lld_per_adv_frm_skip_isr = 0x400011e4; -r_lld_per_adv_init = 0x400011e8; -r_lld_per_adv_init_info_get = 0x400011ec; -r_lld_per_adv_list_add = 0x400011f0; -r_lld_per_adv_list_rem = 0x400011f4; -r_lld_per_adv_set_tx_power = 0x400011fc; -r_lld_per_adv_start = 0x40001200; -r_lld_per_adv_stop = 0x40001204; -r_lld_per_adv_sync_info_get = 0x40001208; -r_lld_process_cca_data = 0x4000120c; -r_lld_ral_search = 0x40001210; -r_lld_read_clock = 0x40001214; -r_lld_res_list_add = 0x40001218; -r_lld_res_list_is_empty = 0x40001220; -r_lld_res_list_local_rpa_get = 0x40001224; -r_lld_res_list_peer_rpa_get = 0x40001228; -r_lld_res_list_peer_update = 0x4000122c; -/* r_lld_res_list_priv_mode_update = 0x40001230; */ -r_lld_reset_reg = 0x40001238; -r_lld_rpa_renew = 0x4000123c; -r_lld_rpa_renew_evt_canceled_cbk = 0x40001240; -r_lld_rpa_renew_evt_start_cbk = 0x40001244; -r_lld_rpa_renew_instant_cbk = 0x40001248; -r_lld_rxdesc_check = 0x4000124c; -r_lld_rxdesc_free = 0x40001250; -r_lld_scan_create_sync = 0x40001254; -r_lld_scan_create_sync_cancel = 0x40001258; -r_lld_scan_end = 0x4000125c; -r_lld_scan_evt_canceled_cbk = 0x40001260; -r_lld_scan_evt_start_cbk = 0x40001264; -r_lld_scan_frm_cbk = 0x40001268; -r_lld_scan_frm_eof_isr = 0x4000126c; -r_lld_scan_frm_rx_isr = 0x40001270; -r_lld_scan_frm_skip_isr = 0x40001274; -r_lld_scan_init = 0x40001278; -r_lld_scan_params_update = 0x4000127c; -r_lld_scan_process_pkt_rx_aux_adv_ind = 0x40001288; -r_lld_scan_process_pkt_rx_aux_chain_ind = 0x4000128c; -r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40001290; -r_lld_scan_process_pkt_rx_ext_adv = 0x40001294; -r_lld_scan_process_pkt_rx_ext_adv_ind = 0x40001298; -r_lld_scan_process_pkt_rx_legacy_adv = 0x4000129c; -r_lld_scan_restart = 0x400012a0; -r_lld_scan_sched = 0x400012a4; -r_lld_scan_set_tx_power = 0x400012a8; -r_lld_scan_start = 0x400012ac; -r_lld_scan_stop = 0x400012b0; -r_lld_scan_sync_accept = 0x400012b4; -r_lld_scan_sync_info_unpack = 0x400012b8; -r_lld_scan_trunc_ind = 0x400012bc; -r_lld_sw_cca_evt_handler = 0x400012c0; -r_lld_sw_cca_isr = 0x400012c4; -r_lld_sync_ch_map_update = 0x400012c8; -r_lld_sync_cleanup = 0x400012cc; -r_lld_sync_evt_canceled_cbk = 0x400012d0; -r_lld_sync_evt_start_cbk = 0x400012d4; -r_lld_sync_frm_cbk = 0x400012d8; -r_lld_sync_frm_eof_isr = 0x400012dc; -r_lld_sync_frm_rx_isr = 0x400012e0; -r_lld_sync_frm_skip_isr = 0x400012e4; -r_lld_sync_init = 0x400012e8; -r_lld_sync_process_pkt_rx = 0x400012ec; -r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400012f0; -r_lld_sync_process_pkt_rx_pkt_check = 0x400012f4; -r_lld_sync_scan_dynamic_pti_process = 0x400012f8; -r_lld_sync_sched = 0x400012fc; -r_lld_sync_start = 0x40001300; -r_lld_sync_stop = 0x40001304; -r_lld_sync_trunc_ind = 0x40001308; -r_lld_test_cleanup = 0x4000130c; -r_lld_test_evt_canceled_cbk = 0x40001310; -r_lld_test_evt_start_cbk = 0x40001314; -r_lld_test_freq2chnl = 0x40001318; -r_lld_test_frm_cbk = 0x4000131c; -r_lld_test_frm_isr = 0x40001320; -r_lld_test_init = 0x40001324; -r_lld_test_rx_isr = 0x40001328; -r_lld_test_set_tx_power = 0x4000132c; -r_lld_test_start = 0x40001330; -/* r_lld_test_stop = 0x40001334; */ -r_lld_update_rxbuf = 0x40001338; -r_lld_update_rxbuf_isr = 0x4000133c; -r_lld_white_list_add = 0x40001340; -r_lld_white_list_rem = 0x40001344; -r_llm_activity_free_get = 0x40001348; -r_llm_activity_free_set = 0x4000134c; -r_llm_activity_syncing_get = 0x40001350; -r_llm_adv_con_len_check = 0x40001354; -r_llm_adv_hdl_to_id = 0x40001358; -r_llm_adv_rep_flow_control_check = 0x4000135c; -r_llm_adv_rep_flow_control_update = 0x40001360; -r_llm_adv_reports_list_check = 0x40001364; -r_llm_adv_set_all_release = 0x40001368; -r_llm_adv_set_dft_params = 0x4000136c; -r_llm_adv_set_release = 0x40001370; -r_llm_aes_res_cb = 0x40001374; -r_llm_ble_update_adv_flow_control = 0x40001378; -r_llm_ch_map_update = 0x4000137c; -r_llm_cmd_cmp_send = 0x40001380; -r_llm_cmd_stat_send = 0x40001384; -r_llm_dev_list_empty_entry = 0x40001388; -r_llm_dev_list_search = 0x4000138c; -r_llm_env_adv_dup_filt_deinit = 0x40001390; -r_llm_env_adv_dup_filt_init = 0x40001394; -r_llm_init_ble_adv_report_flow_contol = 0x40001398; -r_llm_is_dev_connected = 0x4000139c; -r_llm_is_dev_synced = 0x400013a0; -r_llm_is_non_con_act_ongoing_check = 0x400013a4; -r_llm_is_wl_accessible = 0x400013a8; -r_llm_le_evt_mask_check = 0x400013ac; -r_llm_link_disc = 0x400013b4; -r_llm_master_ch_map_get = 0x400013b8; -r_llm_msg_handler_tab_p_get = 0x400013bc; -r_llm_no_activity = 0x400013c0; -r_llm_per_adv_slot_dur = 0x400013c4; -r_llm_plan_elt_get = 0x400013c8; -r_llm_rx_path_comp_get = 0x400013cc; -r_llm_scan_start = 0x400013d0; -r_llm_scan_sync_acad_attach = 0x400013d4; -r_llm_scan_sync_acad_detach = 0x400013d8; -r_llm_send_adv_lost_event_to_host = 0x400013dc; -r_llm_tx_path_comp_get = 0x400013e0; -r_misc_deinit = 0x400013e4; -r_misc_free_em_buf_in_isr = 0x400013e8; -r_misc_init = 0x400013ec; -r_misc_msg_handler_tab_p_get = 0x400013f0; -r_notEqual256 = 0x400013f4; -r_phy_upd_proc_start = 0x400013f8; -r_platform_reset = 0x400013fc; -r_rf_em_init = 0x40001404; -r_rf_force_agc_enable = 0x40001408; -r_rf_reg_rd = 0x4000140c; -r_rf_reg_wr = 0x40001410; -r_rf_reset = 0x40001414; -r_rf_rssi_convert = 0x40001418; -r_rf_rw_v9_le_disable = 0x4000141c; -r_rf_rw_v9_le_enable = 0x40001420; -r_rf_sleep = 0x40001424; -r_rf_util_cs_fmt_convert = 0x40001430; -r_rw_crypto_aes_ccm = 0x40001434; -r_rw_crypto_aes_encrypt = 0x40001438; -r_rw_crypto_aes_init = 0x4000143c; -r_rw_crypto_aes_k1 = 0x40001440; -r_rw_crypto_aes_k2 = 0x40001444; -r_rw_crypto_aes_k3 = 0x40001448; -r_rw_crypto_aes_k4 = 0x4000144c; -r_rw_crypto_aes_rand = 0x40001450; -r_rw_crypto_aes_result_handler = 0x40001454; -r_rw_crypto_aes_s1 = 0x40001458; -r_rw_cryto_aes_cmac = 0x4000145c; -r_rw_v9_init_em_radio_table = 0x40001460; -r_rwble_sleep_enter = 0x40001468; -r_rwble_sleep_wakeup_end = 0x4000146c; -/* r_rwbtdm_isr_wrapper = 0x40001470; */ -r_rwip_active_check = 0x40001474; -r_rwip_aes_encrypt = 0x40001478; -/* r_rwip_assert = 0x4000147c; */ -r_rwip_crypt_evt_handler = 0x40001480; -r_rwip_crypt_isr_handler = 0x40001484; -r_rwip_eif_get = 0x40001488; -r_rwip_half_slot_2_lpcycles = 0x4000148c; -r_rwip_hus_2_lpcycles = 0x40001490; -r_rwip_isr = 0x40001494; -r_rwip_lpcycles_2_hus = 0x40001498; -r_rwip_prevent_sleep_clear = 0x4000149c; -r_rwip_prevent_sleep_set = 0x400014a0; -r_rwip_schedule = 0x400014a4; -r_rwip_sleep = 0x400014a8; -r_rwip_sw_int_handler = 0x400014ac; -r_rwip_sw_int_req = 0x400014b0; -r_rwip_time_get = 0x400014b4; -r_rwip_timer_10ms_handler = 0x400014b8; -r_rwip_timer_10ms_set = 0x400014bc; -r_rwip_timer_hs_handler = 0x400014c0; -r_rwip_timer_hs_set = 0x400014c4; -r_rwip_timer_hus_handler = 0x400014c8; -r_rwip_timer_hus_set = 0x400014cc; -r_rwip_wakeup = 0x400014d0; -/* r_rwip_wakeup_end = 0x400014d4; */ -r_rwip_wlcoex_set = 0x400014d8; -r_sch_alarm_clear = 0x400014dc; -r_sch_alarm_init = 0x400014e0; -r_sch_alarm_prog = 0x400014e4; -r_sch_alarm_set = 0x400014e8; -r_sch_alarm_timer_isr = 0x400014ec; -r_sch_arb_conflict_check = 0x400014f0; -r_sch_arb_elt_cancel = 0x400014f4; -r_sch_arb_init = 0x400014fc; -r_sch_arb_insert = 0x40001500; -r_sch_arb_prog_timer = 0x40001504; -r_sch_arb_remove = 0x40001508; -r_sch_arb_sw_isr = 0x4000150c; -r_sch_plan_chk = 0x40001510; -r_sch_plan_clock_wrap_offset_update = 0x40001514; -r_sch_plan_init = 0x40001518; -r_sch_plan_interval_req = 0x4000151c; -r_sch_plan_offset_max_calc = 0x40001520; -r_sch_plan_offset_req = 0x40001524; -r_sch_plan_position_range_compute = 0x40001528; -r_sch_plan_rem = 0x4000152c; -r_sch_plan_req = 0x40001530; -r_sch_prog_init = 0x4000153c; -r_sch_prog_push = 0x40001540; -r_sch_prog_rx_isr = 0x40001544; -r_sch_prog_skip_isr = 0x40001548; -r_sch_prog_tx_isr = 0x4000154c; -r_sch_slice_bg_add = 0x40001550; -r_sch_slice_bg_remove = 0x40001554; -r_sch_slice_compute = 0x40001558; -r_sch_slice_fg_add = 0x4000155c; -r_sch_slice_fg_remove = 0x40001560; -r_sch_slice_init = 0x40001564; -r_sch_slice_per_add = 0x40001568; -r_sch_slice_per_remove = 0x4000156c; -r_sdk_config_get_bt_sleep_enable = 0x40001570; -r_sdk_config_get_hl_derived_opts = 0x40001574; -r_sdk_config_get_opts = 0x40001578; -r_sdk_config_get_priv_opts = 0x4000157c; -r_sdk_config_set_bt_sleep_enable = 0x40001580; -r_sdk_config_set_hl_derived_opts = 0x40001584; -r_sdk_config_set_opts = 0x40001588; -r_specialModP256 = 0x4000158c; -r_unloaded_area_init = 0x40001590; -r_vhci_flow_off = 0x40001594; -r_vhci_flow_on = 0x40001598; -r_vhci_notify_host_send_available = 0x4000159c; -r_vhci_send_to_host = 0x400015a0; -r_vnd_hci_command_handler = 0x400015a4; -r_vshci_init = 0x400015a8; -vnd_hci_command_handler_wrapper = 0x400015ac; /* Data (.data, .bss, .rodata) */ bt_rf_coex_cfg_p = 0x3fcdffcc; bt_rf_coex_hooks_p = 0x3fcdffc8; @@ -1462,38 +668,6 @@ rwip_coex_cfg = 0x3ff1eeac; rwip_priority = 0x3ff1ee94; veryBigHexP256 = 0x3ff1ee48; -/* bluetooth hook funcs */ -r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; -r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; -r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; -r_lld_scan_frm_eof_isr_hook = 0x40001c6c; -r_lld_scan_evt_start_cbk_hook = 0x40001c70; -r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; -r_lld_scan_sched_hook = 0x40001c7c; -r_lld_adv_evt_start_cbk_hook = 0x40001c84; -r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; -r_lld_adv_frm_isr_hook = 0x40001c8c; -r_lld_adv_start_init_evt_param_hook = 0x40001c90; -r_lld_con_evt_canceled_cbk_hook = 0x40001c94; -r_lld_con_frm_isr_hook = 0x40001c98; -r_lld_con_tx_hook = 0x40001c9c; -r_lld_con_rx_hook = 0x40001ca0; -r_lld_con_evt_start_cbk_hook = 0x40001ca4; -r_lld_con_tx_prog_new_packet_hook = 0x40001cac; -r_lld_init_frm_eof_isr_hook = 0x40001cb0; -r_lld_init_evt_start_cbk_hook = 0x40001cb4; -r_lld_init_sched_hook = 0x40001cbc; -r_lld_init_process_pkt_tx_hook = 0x40001cc0; -r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; -r_lld_per_adv_frm_isr_hook = 0x40001cc8; -r_lld_per_adv_start_hook = 0x40001ccc; -r_lld_sync_frm_eof_isr_hook = 0x40001cd0; -r_lld_sync_evt_start_cbk_hook = 0x40001cd4; -r_lld_sync_start_hook = 0x40001cd8; -r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; -r_sch_arb_insert_hook = 0x40001ce0; -r_sch_plan_offset_req_hook = 0x40001ce4; - /*************************************** Group rom_pp ***************************************/ diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld new file mode 100644 index 00000000000..10cc038cc3b --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_50.ld @@ -0,0 +1,75 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* extend adv */ +f_hci_le_set_ext_adv_param_cmd_handler = 0x40000000; +f_hci_le_set_adv_set_rand_addr_cmd_handler = 0x40000000; +f_hci_le_set_ext_adv_data_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_rsp_data_cmd_handler = 0x40000000; +f_hci_le_set_ext_adv_en_cmd_handler = 0x40000000; +f_hci_le_rd_max_adv_data_len_cmd_handler = 0x40000000; +f_hci_le_rd_nb_supp_adv_sets_cmd_handler = 0x40000000; +f_hci_le_rmv_adv_set_cmd_handler = 0x40000000; +f_hci_le_clear_adv_sets_cmd_handler = 0x40000000; +r_lld_adv_sync_info_set = 0x40000000; + +r_lld_ext_adv_dynamic_pti_process = 0x40000000; +r_lld_adv_ext_chain_construct = 0x40000000; +r_lld_adv_aux_evt_canceled_cbk = 0x40000000; +r_lld_adv_aux_evt_start_cbk = 0x40000000; +r_lld_adv_aux_ch_idx_set = 0x40000000; + +/* periodic adv */ +f_hci_le_set_per_adv_param_cmd_handler = 0x40000000; +f_hci_le_set_per_adv_data_cmd_handler = 0x40000000; +f_hci_le_set_per_adv_en_cmd_handler = 0x40000000; +r_lld_per_adv_ch_map_update = 0x40000000; +r_lld_per_adv_init = 0x40000000; + +/* PA list */ +f_hci_le_add_dev_to_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_rmv_dev_from_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_clear_per_adv_list_cmd_handler = 0x40000000; +f_hci_le_rd_per_adv_list_size_cmd_handler = 0x40000000; + +/* extend scan */ +f_hci_le_set_ext_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_en_cmd_handler = 0x40000000; +r_lld_scan_process_pkt_rx_ext_adv = 0x40000000; +r_lld_scan_trunc_ind = 0x40000000; + +/* extend con */ +f_hci_le_ext_create_con_cmd_handler = 0x40000000; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x40000000; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40000000; + +/* PA sync */ +f_hci_le_per_adv_create_sync_cmd_handler = 0x40000000; +f_hci_le_per_adv_create_sync_cancel_cmd_handler = 0x40000000; +f_hci_le_per_adv_term_sync_cmd_handler = 0x40000000; +f_lld_per_adv_rx_end_ind_handler_hack = 0x40000000; +f_lld_sync_start_req_handler = 0x40000000; +f_lld_per_adv_rep_ind_handler = 0x40000000; +r_lld_sync_init = 0x40000000; + +/* phy update*/ +r_phy_upd_proc_start = 0x40000000; +f_llc_op_phy_upd_ind_handler = 0x40000000; +f_ll_phy_req_handler = 0x40000000; +f_ll_phy_rsp_handler = 0x40000000; +f_ll_phy_update_ind_handler = 0x40000000; +f_lld_phy_upd_cfm_handler = 0x40000000; +f_hci_le_set_phy_cmd_handler = 0x40000000; +llc_llcp_phy_update_ind_ack = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld new file mode 100644 index 00000000000..74d2dca0e30 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_cca.ld @@ -0,0 +1,32 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SW CCA */ +r_lld_cca_con_evt_start_handle = 0x40000000; +r_lld_hw_cca_end_isr = 0x40000000; +r_lld_hw_cca_isr_eco = 0x40000000; +r_lld_cca_bb_sync_found_handle = 0x40000000; +r_lld_cca_data_reset = 0x40000000; +r_lld_cca_sw_init = 0x40000000; +r_lld_cca_con_evt_end_handle = 0x40000000; +r_lld_cca_alloc = 0x40000000; +r_lld_cca_sw_alloc = 0x40000000; +r_lld_cca_sw_free = 0x40000000; +r_lld_cca_free = 0x40000000; +r_cca_init = 0x40000000; +r_lld_hw_cca_evt_handler = 0x40000000; +r_lld_sw_cca_evt_handler = 0x40000000; +r_ble_sw_cca_check_isr = 0x40000000; +bt_bb_tx_cca_set = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld new file mode 100644 index 00000000000..e08545c7179 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_dtm.ld @@ -0,0 +1,22 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* DTM */ +f_hci_le_rx_test_cmd_handler = 0x40000000; +f_hci_le_tx_test_cmd_handler = 0x40000000; +f_hci_le_enh_rx_test_cmd_handler = 0x40000000; +f_hci_le_enh_tx_test_cmd_handler = 0x40000000; +f_hci_le_test_end_cmd_handler = 0x40000000; +r_lld_test_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld new file mode 100644 index 00000000000..498330a6804 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_master.ld @@ -0,0 +1,20 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* master */ +f_hci_le_create_con_cmd_handler = 0x40000000; +f_hci_le_create_con_cancel_cmd_handler = 0x40000000; +lld_init_end_ind_handler = 0x40000000; +r_lld_init_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld new file mode 100644 index 00000000000..c3c8414e516 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_scan.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* BLE scan */ + +f_hci_le_set_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_scan_en_cmd_handler = 0x40000000; +f_llm_scan_period_to_handler_hack = 0x40000000; +f_lld_adv_rep_ind_handler_hack = 0x40000000; +r_lld_scan_init = 0x40000000; +r_lld_scan_restart = 0x40000000; +f_lld_scan_end_ind_handler_hack = 0x40000000; +r_llm_env_adv_dup_filt_deinit_eco = 0x40000000; +llm_exception_list_init = 0x40000000; +llm_duplicate_list_init = 0x40000000; +f_hci_vendor_ble_update_duplicate_exceptional_list_cmd_handler = 0x40000000; +f_hci_vendor_ble_init_adv_flow_control_cmd_handler = 0x40000000; +f_hci_vendor_ble_update_adv_report_flow_control_cmd_handler = 0x40000000; +coex_schm_ble_scan_stop = 0x40000000; + +f_hci_le_set_ext_scan_param_cmd_handler = 0x40000000; +f_hci_le_set_ext_scan_en_cmd_handler = 0x40000000; +r_lld_scan_process_pkt_rx_ext_adv = 0x40000000; +r_lld_scan_trunc_ind = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld new file mode 100644 index 00000000000..78d1fb9784a --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_smp.ld @@ -0,0 +1,44 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/* SMP */ +f_ll_pause_enc_req_handler = 0x40000000; +f_ll_pause_enc_rsp_handler = 0x40000000; +f_ll_enc_req_handler = 0x40000000; +f_ll_enc_rsp_handler = 0x40000000; +f_ll_start_enc_req_handler = 0x40000000; +f_ll_start_enc_rsp_handler = 0x40000000; +f_hci_le_start_enc_cmd_handler = 0x40000000; +f_hci_le_ltk_req_reply_cmd_handler = 0x40000000; +f_hci_le_ltk_req_neg_reply_cmd_handler = 0x40000000; +f_llc_encrypt_ind_handler = 0x40000000; +f_llc_op_encrypt_ind_handler = 0x40000000; +f_hci_le_rd_local_p256_public_key_cmd_handler = 0x40000000; +f_hci_le_generate_dhkey_cmd_handler = 0x40000000; +f_hci_le_enc_cmd_handler = 0x40000000; +r_rwip_crypt_evt_handler = 0x40000000; + +/* LE ping */ +f_ll_ping_req_handler = 0x40000000; +f_ll_ping_rsp_handler = 0x40000000; +r_llc_le_ping_set = 0x40000000; +r_llc_le_ping_restart = 0x40000000; +f_llc_op_le_ping_ind_handler = 0x40000000; +f_llc_auth_payl_nearly_op_handler = 0x40000000; +f_llc_auth_payl_real_to_handler = 0x40000000; +f_llc_auth_payl_nearly_to_handler = 0x40000000; + +/* ecc */ +r_ecc_init = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld new file mode 100644 index 00000000000..1c0a6b59f0a --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ble_test.ld @@ -0,0 +1,37 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + + +/* overwrite */ +lld_acl_rx_ind_handler = 0x40000000; +lld_con_estab_ind_handler = 0x40000000; +lld_adv_rep_ind_handler = 0x40000000; +llm_rpa_renew_to_handler = 0x40000000; +lld_scan_end_ind_handler = 0x40000000; +llm_scan_period_to_handler = 0x40000000; + +/* nvds */ +r_nvds_init = 0x40000000; +f_nvds_get = 0x40000000; +f_nvds_del = 0x40000000; +f_nvds_put = 0x40000000; + +/* controller flash */ +r_flash_init = 0x40000000; +r_flash_env_init = 0x40000000; +r_flash_env_deinit = 0x40000000; + +/* QA test */ +f_hci_vendor_ble_qa_test_cmd_handler = 0x40000000; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld new file mode 100644 index 00000000000..de1ad187533 --- /dev/null +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.bt_funcs.ld @@ -0,0 +1,874 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ +/* ROM function interface esp32s3.rom.ld for esp32s3 + * + * + * Generated from ./interface-esp32s3.yml md5sum 39c4ce259b11323b9404c192b01b712b + * + * Compatible with ROM where ECO version equal or greater to 0. + * + * THIS FILE WAS AUTOMATICALLY GENERATED. DO NOT EDIT. + */ + +/*************************************** + Group bluetooth + ***************************************/ + +/* Functions */ +bt_rf_coex_get_dft_cfg = 0x40002a78; +bt_rf_coex_hooks_p_set = 0x40002a84; +btdm_con_maxevtime_cal_impl = 0x40002a90; +btdm_controller_get_compile_version_impl = 0x40002a9c; +btdm_controller_rom_data_init = 0x40002aa8; +btdm_dis_privacy_err_report_impl = 0x40002ab4; +btdm_disable_adv_delay_impl = 0x40002ac0; +btdm_enable_scan_continue_impl = 0x40002acc; +btdm_enable_scan_forever_impl = 0x40002ad8; +btdm_get_power_state_impl = 0x40002ae4; +btdm_get_prevent_sleep_flag_impl = 0x40002af0; +btdm_power_state_active_impl = 0x40002afc; +btdm_switch_phy_coded_impl = 0x40002b08; +hci_acl_data_handler = 0x40002b14; +hci_disconnect_cmd_handler = 0x40002b20; +hci_le_con_upd_cmd_handler = 0x40002b2c; +hci_le_ltk_req_neg_reply_cmd_handler = 0x40002b38; +hci_le_ltk_req_reply_cmd_handler = 0x40002b44; +hci_le_rd_chnl_map_cmd_handler = 0x40002b50; +hci_le_rd_phy_cmd_handler = 0x40002b5c; +hci_le_rd_rem_feats_cmd_handler = 0x40002b68; +hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40002b74; +hci_le_rem_con_param_req_reply_cmd_handler = 0x40002b80; +hci_le_set_data_len_cmd_handler = 0x40002b8c; +hci_le_set_phy_cmd_handler = 0x40002b98; +hci_le_start_enc_cmd_handler = 0x40002ba4; +hci_rd_auth_payl_to_cmd_handler = 0x40002bb0; +hci_rd_rem_ver_info_cmd_handler = 0x40002bbc; +hci_rd_rssi_cmd_handler = 0x40002bc8; +hci_rd_tx_pwr_lvl_cmd_handler = 0x40002bd4; +hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40002be0; +hci_vs_set_pref_slave_latency_cmd_handler = 0x40002bec; +hci_wr_auth_payl_to_cmd_handler = 0x40002bf8; +ll_channel_map_ind_handler = 0x40002c04; +ll_connection_param_req_handler = 0x40002c10; +ll_connection_param_rsp_handler = 0x40002c1c; +ll_connection_update_ind_handler = 0x40002c28; +ll_enc_req_handler = 0x40002c34; +ll_enc_rsp_handler = 0x40002c40; +ll_feature_req_handler = 0x40002c4c; +ll_feature_rsp_handler = 0x40002c58; +ll_length_req_handler = 0x40002c64; +ll_length_rsp_handler = 0x40002c70; +ll_min_used_channels_ind_handler = 0x40002c7c; +ll_pause_enc_req_handler = 0x40002c88; +ll_pause_enc_rsp_handler = 0x40002c94; +ll_phy_req_handler = 0x40002ca0; +ll_phy_rsp_handler = 0x40002cac; +ll_phy_update_ind_handler = 0x40002cb8; +ll_ping_req_handler = 0x40002cc4; +ll_ping_rsp_handler = 0x40002cd0; +ll_slave_feature_req_handler = 0x40002cdc; +ll_start_enc_req_handler = 0x40002ce8; +ll_start_enc_rsp_handler = 0x40002cf4; +ll_terminate_ind_handler = 0x40002d00; +ll_version_ind_handler = 0x40002d0c; +llc_auth_payl_nearly_to_handler = 0x40002d18; +llc_auth_payl_real_to_handler = 0x40002d24; +llc_encrypt_ind_handler = 0x40002d30; +llc_hci_command_handler_wrapper = 0x40002d3c; +llc_ll_connection_param_req_pdu_send = 0x40002d48; +llc_ll_connection_param_rsp_pdu_send = 0x40002d54; +llc_ll_connection_update_ind_pdu_send = 0x40002d60; +llc_ll_enc_req_pdu_send = 0x40002d6c; +llc_ll_enc_rsp_pdu_send = 0x40002d78; +llc_ll_feature_req_pdu_send = 0x40002d84; +llc_ll_feature_rsp_pdu_send = 0x40002d90; +llc_ll_length_req_pdu_send = 0x40002d9c; +llc_ll_length_rsp_pdu_send = 0x40002da8; +llc_ll_pause_enc_req_pdu_send = 0x40002db4; +llc_ll_pause_enc_rsp_pdu_send = 0x40002dc0; +llc_ll_phy_req_pdu_send = 0x40002dcc; +llc_ll_phy_rsp_pdu_send = 0x40002dd8; +llc_ll_ping_req_pdu_send = 0x40002de4; +llc_ll_ping_rsp_pdu_send = 0x40002df0; +llc_ll_start_enc_req_pdu_send = 0x40002dfc; +llc_ll_start_enc_rsp_pdu_send = 0x40002e08; +llc_ll_terminate_ind_pdu_send = 0x40002e14; +llc_ll_unknown_rsp_pdu_send = 0x40002e20; +llc_llcp_ch_map_update_ind_pdu_send = 0x40002e2c; +llc_llcp_phy_upd_ind_pdu_send = 0x40002e38; +llc_llcp_version_ind_pdu_send = 0x40002e44; +llc_op_ch_map_upd_ind_handler = 0x40002e50; +llc_op_con_upd_ind_handler = 0x40002e5c; +llc_op_disconnect_ind_handler = 0x40002e68; +llc_op_dl_upd_ind_handler = 0x40002e74; +llc_op_encrypt_ind_handler = 0x40002e80; +llc_op_feats_exch_ind_handler = 0x40002e8c; +llc_op_le_ping_ind_handler = 0x40002e98; +llc_op_phy_upd_ind_handler = 0x40002ea4; +llc_op_ver_exch_ind_handler = 0x40002eb0; +llc_stopped_ind_handler = 0x40002ebc; +lld_acl_rx_ind_handler = 0x40002ec8; +lld_acl_tx_cfm_handler = 0x40002ed4; +lld_adv_end_ind_handler = 0x40002ee0; +lld_adv_rep_ind_handler = 0x40002eec; +lld_ch_map_upd_cfm_handler = 0x40002ef8; +lld_con_estab_ind_handler = 0x40002f04; +lld_con_evt_sd_evt_time_set = 0x40002f10; +lld_con_offset_upd_ind_handler = 0x40002f1c; +lld_con_param_upd_cfm_handler = 0x40002f28; +lld_disc_ind_handler = 0x40002f34; +lld_init_end_ind_handler = 0x40002f40; +lld_llcp_rx_ind_handler_wrapper = 0x40002f4c; +lld_llcp_tx_cfm_handler = 0x40002f58; +lld_per_adv_end_ind_handler = 0x40002f64; +lld_per_adv_rep_ind_handler = 0x40002f70; +lld_per_adv_rx_end_ind_handler = 0x40002f7c; +lld_phy_coded_500k_get = 0x40002f88; +lld_phy_upd_cfm_handler = 0x40002f94; +lld_scan_end_ind_handler = 0x40002fa0; +lld_scan_req_ind_handler = 0x40002fac; +lld_sync_start_req_handler = 0x40002fb8; +lld_test_end_ind_handler = 0x40002fc4; +lld_update_rxbuf_handler = 0x40002fd0; +llm_ch_map_update_ind_handler = 0x40002fdc; +llm_hci_command_handler_wrapper = 0x40002fe8; +llm_scan_period_to_handler = 0x40002ff4; +r_Add2SelfBigHex256 = 0x40003000; +r_AddBigHex256 = 0x4000300c; +r_AddBigHexModP256 = 0x40003018; +r_AddP256 = 0x40003024; +r_AddPdiv2_256 = 0x40003030; +r_GF_Jacobian_Point_Addition256 = 0x4000303c; +r_GF_Jacobian_Point_Double256 = 0x40003048; +r_GF_Point_Jacobian_To_Affine256 = 0x40003054; +r_MultiplyBigHexByUint32_256 = 0x40003060; +r_MultiplyBigHexModP256 = 0x4000306c; +r_MultiplyByU16ModP256 = 0x40003078; +r_SubtractBigHex256 = 0x40003084; +r_SubtractBigHexMod256 = 0x40003090; +r_SubtractBigHexUint32_256 = 0x4000309c; +r_SubtractFromSelfBigHex256 = 0x400030a8; +r_SubtractFromSelfBigHexSign256 = 0x400030b4; +r_aes_alloc = 0x400030c0; +r_aes_ccm_continue = 0x400030cc; +r_aes_ccm_process_e = 0x400030d8; +r_aes_ccm_xor_128_lsb = 0x400030e4; +r_aes_ccm_xor_128_msb = 0x400030f0; +r_aes_cmac_continue = 0x400030fc; +r_aes_cmac_start = 0x40003108; +r_aes_k1_continue = 0x40003114; +r_aes_k2_continue = 0x40003120; +r_aes_k3_continue = 0x4000312c; +r_aes_k4_continue = 0x40003138; +r_aes_shift_left_128 = 0x40003144; +r_aes_start = 0x40003150; +r_aes_xor_128 = 0x4000315c; +r_assert_err = 0x40003168; +r_assert_param = 0x40003174; +r_assert_warn = 0x40003180; +r_bigHexInversion256 = 0x4000318c; +r_ble_sw_cca_check_isr = 0x40003198; +r_ble_util_buf_acl_tx_alloc = 0x400031a4; +r_ble_util_buf_acl_tx_elt_get = 0x400031b0; +r_ble_util_buf_acl_tx_free = 0x400031bc; +r_ble_util_buf_acl_tx_free_in_isr = 0x400031c8; +r_ble_util_buf_adv_tx_alloc = 0x400031d4; +r_ble_util_buf_adv_tx_free = 0x400031e0; +r_ble_util_buf_adv_tx_free_in_isr = 0x400031ec; +r_ble_util_buf_env_deinit = 0x400031f8; +r_ble_util_buf_env_init = 0x40003204; +r_ble_util_buf_get_rx_buf_nb = 0x40003210; +r_ble_util_buf_get_rx_buf_size = 0x4000321c; +r_ble_util_buf_llcp_tx_alloc = 0x40003228; +r_ble_util_buf_llcp_tx_free = 0x40003234; +r_ble_util_buf_rx_alloc = 0x40003240; +r_ble_util_buf_rx_alloc_in_isr = 0x4000324c; +r_ble_util_buf_rx_free = 0x40003258; +r_ble_util_buf_rx_free_in_isr = 0x40003264; +r_ble_util_buf_set_rx_buf_nb = 0x40003270; +r_ble_util_buf_set_rx_buf_size = 0x4000327c; +r_ble_util_data_rx_buf_reset = 0x40003288; +r_bt_bb_get_intr_mask = 0x40003294; +r_bt_bb_intr_clear = 0x400032a0; +r_bt_bb_intr_mask_set = 0x400032ac; +r_bt_rf_coex_cfg_set = 0x400032c4; +r_bt_rf_coex_conn_dynamic_pti_en_get = 0x400032d0; +r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x400032e8; +r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x400032f4; +r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40003300; +r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x4000330c; +r_bt_rf_coex_pti_table_get = 0x40003318; +r_bt_rf_coex_st_param_get = 0x40003324; +r_bt_rf_coex_st_param_set = 0x40003330; +r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x4000333c; +r_bt_rma_apply_rule_cs_fmt = 0x40003348; +r_bt_rma_apply_rule_cs_idx = 0x40003354; +r_bt_rma_configure = 0x40003360; +r_bt_rma_deregister_rule_cs_fmt = 0x4000336c; +r_bt_rma_deregister_rule_cs_idx = 0x40003378; +r_bt_rma_get_ant_by_act = 0x40003384; +r_bt_rma_init = 0x40003390; +r_bt_rma_register_rule_cs_fmt = 0x4000339c; +r_bt_rma_register_rule_cs_idx = 0x400033a8; +r_bt_rtp_apply_rule_cs_fmt = 0x400033b4; +r_bt_rtp_apply_rule_cs_idx = 0x400033c0; +r_bt_rtp_deregister_rule_cs_fmt = 0x400033cc; +r_bt_rtp_deregister_rule_cs_idx = 0x400033d8; +r_bt_rtp_init = 0x400033f0; +r_bt_rtp_register_rule_cs_fmt = 0x400033fc; +r_bt_rtp_register_rule_cs_idx = 0x40003408; +r_btdm_isr = 0x40003414; +r_cali_phase_match_p = 0x40003444; +r_cmp_abs_time = 0x40003450; +r_cmp_dest_id = 0x4000345c; +r_cmp_timer_id = 0x40003468; +r_co_bdaddr_compare = 0x40003474; +r_co_ble_pkt_dur_in_us = 0x40003480; +r_co_list_extract = 0x4000348c; +r_co_list_extract_after = 0x40003498; +r_co_list_extract_sublist = 0x400034a4; +r_co_list_find = 0x400034b0; +r_co_list_init = 0x400034bc; +r_co_list_insert_after = 0x400034c8; +r_co_list_insert_before = 0x400034d4; +r_co_list_merge = 0x400034e0; +r_co_list_pool_init = 0x400034ec; +r_co_list_pop_front = 0x400034f8; +r_co_list_push_back = 0x40003504; +r_co_list_push_back_sublist = 0x40003510; +r_co_list_push_front = 0x4000351c; +r_co_list_size = 0x40003528; +r_co_nb_good_le_channels = 0x40003534; +r_co_util_pack = 0x40003540; +r_co_util_read_array_size = 0x4000354c; +r_co_util_unpack = 0x40003558; +r_dbg_env_deinit = 0x40003564; +r_dbg_env_init = 0x40003570; +r_dbg_platform_reset_complete = 0x4000357c; +r_dl_upd_proc_start = 0x40003588; +r_dump_data = 0x40003594; +r_ecc_abort_key256_generation = 0x400035a0; +r_ecc_gen_new_public_key = 0x400035ac; +r_ecc_gen_new_secret_key = 0x400035b8; +r_ecc_generate_key256 = 0x400035c4; +r_ecc_get_debug_Keys = 0x400035d0; +r_ecc_init = 0x400035dc; +r_ecc_is_valid_point = 0x400035e8; +r_ecc_multiplication_event_handler = 0x400035f4; +r_ecc_point_multiplication_win_256 = 0x40003600; +r_emi_alloc_em_mapping_by_offset = 0x4000360c; +r_emi_base_reg_lut_show = 0x40003618; +r_emi_em_base_reg_show = 0x40003624; +r_emi_free_em_mapping_by_offset = 0x40003630; +r_emi_get_em_mapping_idx_by_offset = 0x4000363c; +r_emi_get_mem_addr_by_offset = 0x40003648; +r_emi_overwrite_em_mapping_by_offset = 0x40003654; +r_esp_vendor_hci_command_handler = 0x40003660; +r_get_stack_usage = 0x4000366c; +r_h4tl_acl_hdr_rx_evt_handler = 0x40003678; +r_h4tl_cmd_hdr_rx_evt_handler = 0x40003684; +r_h4tl_cmd_pld_rx_evt_handler = 0x40003690; +r_h4tl_eif_io_event_post = 0x4000369c; +r_h4tl_eif_register = 0x400036a8; +r_h4tl_init = 0x400036b4; +r_h4tl_out_of_sync = 0x400036c0; +r_h4tl_out_of_sync_check = 0x400036cc; +r_h4tl_read_hdr = 0x400036d8; +r_h4tl_read_next_out_of_sync = 0x400036e4; +r_h4tl_read_payl = 0x400036f0; +r_h4tl_read_start = 0x400036fc; +r_h4tl_rx_acl_hdr_extract = 0x40003708; +r_h4tl_rx_cmd_hdr_extract = 0x40003714; +r_h4tl_rx_done = 0x40003720; +r_h4tl_start = 0x4000372c; +r_h4tl_stop = 0x40003738; +r_h4tl_tx_done = 0x40003744; +r_h4tl_tx_evt_handler = 0x40003750; +r_h4tl_write = 0x4000375c; +r_hci_acl_tx_data_alloc = 0x40003768; +r_hci_acl_tx_data_received = 0x40003774; +r_hci_basic_cmd_send_2_controller = 0x40003780; +r_hci_ble_adv_report_filter_check = 0x4000378c; +r_hci_ble_adv_report_tx_check = 0x40003798; +r_hci_ble_conhdl_register = 0x400037a4; +r_hci_ble_conhdl_unregister = 0x400037b0; +r_hci_build_acl_data = 0x400037bc; +r_hci_build_cc_evt = 0x400037c8; +r_hci_build_cs_evt = 0x400037d4; +r_hci_build_evt = 0x400037e0; +r_hci_build_le_evt = 0x400037ec; +r_hci_cmd_get_max_param_size = 0x400037f8; +r_hci_cmd_received = 0x40003804; +r_hci_cmd_reject = 0x40003810; +r_hci_evt_mask_check = 0x4000381c; +r_hci_evt_mask_set = 0x40003828; +r_hci_fc_acl_buf_size_set = 0x40003834; +r_hci_fc_acl_en = 0x40003840; +r_hci_fc_acl_packet_sent = 0x4000384c; +r_hci_fc_check_host_available_nb_acl_packets = 0x40003858; +r_hci_fc_host_nb_acl_pkts_complete = 0x40003864; +r_hci_fc_init = 0x40003870; +r_hci_look_for_cmd_desc = 0x4000387c; +r_hci_look_for_evt_desc = 0x40003888; +r_hci_look_for_le_evt_desc = 0x40003894; +r_hci_look_for_le_evt_desc_esp = 0x400038a0; +r_hci_pack_bytes = 0x400038ac; +r_hci_send_2_controller = 0x400038c4; +r_hci_send_2_host = 0x400038d0; +r_hci_tl_c2h_data_flow_on = 0x400038dc; +r_hci_tl_cmd_hdr_rx_evt_handler = 0x400038e8; +r_hci_tl_cmd_pld_rx_evt_handler = 0x400038f4; +r_hci_tl_get_pkt = 0x40003900; +r_hci_tl_hci_pkt_handler = 0x4000390c; +r_hci_tl_hci_tx_done_evt_handler = 0x40003918; +r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40003924; +r_hci_tl_save_pkt = 0x40003930; +r_hci_tl_send = 0x4000393c; +r_hci_tx_done = 0x40003948; +r_hci_tx_start = 0x40003954; +r_hci_tx_trigger = 0x40003960; +r_isValidSecretKey_256 = 0x4000396c; +r_ke_check_malloc = 0x40003978; +r_ke_event_callback_set = 0x40003984; +r_ke_event_clear = 0x40003990; +r_ke_event_flush = 0x4000399c; +r_ke_event_get = 0x400039a8; +r_ke_event_get_all = 0x400039b4; +r_ke_event_init = 0x400039c0; +r_ke_event_schedule = 0x400039cc; +r_ke_event_set = 0x400039d8; +r_ke_flush = 0x400039e4; +r_ke_free = 0x400039f0; +r_ke_handler_search = 0x400039fc; +r_ke_init = 0x40003a08; +r_ke_is_free = 0x40003a14; +r_ke_malloc = 0x40003a20; +r_ke_mem_init = 0x40003a2c; +r_ke_mem_is_empty = 0x40003a38; +r_ke_mem_is_in_heap = 0x40003a44; +r_ke_msg_alloc = 0x40003a50; +r_ke_msg_dest_id_get = 0x40003a5c; +r_ke_msg_discard = 0x40003a68; +r_ke_msg_forward = 0x40003a74; +r_ke_msg_forward_new_id = 0x40003a80; +r_ke_msg_free = 0x40003a8c; +r_ke_msg_in_queue = 0x40003a98; +r_ke_msg_save = 0x40003aa4; +r_ke_msg_send = 0x40003ab0; +r_ke_msg_send_basic = 0x40003abc; +r_ke_msg_src_id_get = 0x40003ac8; +r_ke_queue_extract = 0x40003ad4; +r_ke_queue_insert = 0x40003ae0; +r_ke_sleep_check = 0x40003aec; +r_ke_state_get = 0x40003af8; +r_ke_state_set = 0x40003b04; +r_ke_task_check = 0x40003b10; +r_ke_task_create = 0x40003b1c; +r_ke_task_delete = 0x40003b28; +r_ke_task_handler_get = 0x40003b34; +r_ke_task_init = 0x40003b40; +r_ke_task_msg_flush = 0x40003b4c; +r_ke_task_saved_update = 0x40003b58; +r_ke_time = 0x40003b70; +r_ke_time_cmp = 0x40003b7c; +r_ke_time_past = 0x40003b88; +r_ke_timer_active = 0x40003b94; +r_ke_timer_adjust_all = 0x40003ba0; +r_ke_timer_clear = 0x40003bac; +r_ke_timer_init = 0x40003bb8; +r_ke_timer_schedule = 0x40003bc4; +r_ke_timer_set = 0x40003bd0; +r_led_init = 0x40003bdc; +r_led_set_all = 0x40003be8; +r_llc_aes_res_cb = 0x40003bf4; +r_llc_ch_map_up_proc_err_cb = 0x40003c00; +r_llc_cleanup = 0x40003c0c; +r_llc_cmd_cmp_send = 0x40003c18; +r_llc_cmd_stat_send = 0x40003c24; +r_llc_con_move_cbk = 0x40003c30; +r_llc_con_plan_set_update = 0x40003c3c; +r_llc_con_upd_param_in_range = 0x40003c48; +r_llc_disconnect = 0x40003c54; +r_llc_disconnect_end = 0x40003c60; +r_llc_disconnect_proc_continue = 0x40003c6c; +r_llc_disconnect_proc_err_cb = 0x40003c78; +r_llc_dl_chg_check = 0x40003c84; +r_llc_dle_proc_err_cb = 0x40003c90; +r_llc_feats_exch_proc_err_cb = 0x40003c9c; +r_llc_hci_cmd_handler_tab_p_get = 0x40003ca8; +r_llc_hci_con_param_req_evt_send = 0x40003cc0; +r_llc_hci_con_upd_info_send = 0x40003ccc; +r_llc_hci_disconnected_dis = 0x40003cd8; +r_llc_hci_dl_upd_info_send = 0x40003ce4; +r_llc_hci_enc_evt_send = 0x40003cf0; +r_llc_hci_feats_info_send = 0x40003cfc; +r_llc_hci_le_phy_upd_cmp_evt_send = 0x40003d08; +r_llc_hci_ltk_request_evt_send = 0x40003d14; +r_llc_hci_nb_cmp_pkts_evt_send = 0x40003d20; +r_llc_hci_version_info_send = 0x40003d2c; +r_llc_init_term_proc = 0x40003d38; +r_llc_iv_skd_rand_gen = 0x40003d44; +r_llc_le_ping_proc_continue = 0x40003d50; +r_llc_le_ping_proc_err_cb = 0x40003d5c; +/* r_llc_le_ping_restart = 0x40003d68; */ +r_llc_le_ping_set = 0x40003d74; +r_llc_ll_pause_enc_rsp_ack_handler = 0x40003d80; +r_llc_ll_reject_ind_ack_handler = 0x40003d8c; +r_llc_ll_reject_ind_pdu_send = 0x40003d98; +r_llc_ll_start_enc_rsp_ack_handler = 0x40003da4; +r_llc_ll_terminate_ind_ack = 0x40003db0; +r_llc_ll_unknown_ind_handler = 0x40003dbc; +r_llc_llcp_send = 0x40003dc8; +r_llc_llcp_state_set = 0x40003dd4; +r_llc_llcp_trans_timer_set = 0x40003de0; +r_llc_llcp_tx_check = 0x40003dec; +/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */ +r_llc_loc_con_upd_proc_err_cb = 0x40003e10; +r_llc_loc_dl_upd_proc_continue = 0x40003e1c; +r_llc_loc_encrypt_proc_continue = 0x40003e28; +r_llc_loc_encrypt_proc_err_cb = 0x40003e34; +r_llc_loc_feats_exch_proc_continue = 0x40003e40; +r_llc_loc_phy_upd_proc_err_cb = 0x40003e58; +r_llc_msg_handler_tab_p_get = 0x40003e64; +r_llc_pref_param_compute = 0x40003e70; +r_llc_proc_collision_check = 0x40003e7c; +r_llc_proc_err_ind = 0x40003e88; +r_llc_proc_get = 0x40003e94; +r_llc_proc_id_get = 0x40003ea0; +r_llc_proc_reg = 0x40003eac; +r_llc_proc_state_get = 0x40003eb8; +r_llc_proc_state_set = 0x40003ec4; +r_llc_proc_timer_pause_set = 0x40003ed0; +r_llc_proc_timer_set = 0x40003edc; +r_llc_proc_unreg = 0x40003ee8; +r_llc_rem_ch_map_proc_continue = 0x40003ef4; +r_llc_rem_con_upd_proc_err_cb = 0x40003f0c; +r_llc_rem_dl_upd_proc = 0x40003f18; +r_llc_rem_encrypt_proc_continue = 0x40003f24; +r_llc_rem_encrypt_proc_err_cb = 0x40003f30; +r_llc_rem_phy_upd_proc_continue = 0x40003f3c; +r_llc_rem_phy_upd_proc_err_cb = 0x40003f48; +r_llc_role_get = 0x40003f54; +r_llc_sk_gen = 0x40003f60; +r_llc_start = 0x40003f6c; +r_llc_stop = 0x40003f78; +r_llc_ver_exch_loc_proc_continue = 0x40003f84; +r_llc_ver_proc_err_cb = 0x40003f90; +r_llcp_pdu_handler_tab_p_get = 0x40003f9c; +r_lld_aa_gen = 0x40003fa8; +r_lld_adv_adv_data_set = 0x40003fb4; +r_lld_adv_adv_data_update = 0x40003fc0; +r_lld_adv_aux_ch_idx_set = 0x40003fcc; +r_lld_adv_aux_evt_canceled_cbk = 0x40003fd8; +r_lld_adv_aux_evt_start_cbk = 0x40003fe4; +r_lld_adv_coex_check_ext_adv_synced = 0x40003ff0; +r_lld_adv_coex_env_reset = 0x40003ffc; +r_lld_adv_duration_update = 0x40004008; +r_lld_adv_dynamic_pti_process = 0x40004014; +r_lld_adv_end = 0x40004020; +r_lld_adv_evt_canceled_cbk = 0x4000402c; +r_lld_adv_evt_start_cbk = 0x40004038; +r_lld_adv_ext_chain_construct = 0x40004044; +r_lld_adv_ext_pkt_prepare = 0x40004050; +r_lld_adv_frm_cbk = 0x4000405c; +r_lld_adv_frm_isr = 0x40004068; +r_lld_adv_frm_skip_isr = 0x40004074; +r_lld_adv_init = 0x40004080; +r_lld_adv_pkt_rx = 0x4000408c; +r_lld_adv_pkt_rx_connect_ind = 0x40004098; +r_lld_adv_pkt_rx_send_scan_req_evt = 0x400040a4; +r_lld_adv_rand_addr_update = 0x400040b0; +r_lld_adv_restart = 0x400040bc; +r_lld_adv_scan_rsp_data_set = 0x400040c8; +r_lld_adv_scan_rsp_data_update = 0x400040d4; +r_lld_adv_set_tx_power = 0x400040e0; +r_lld_adv_start = 0x400040ec; +r_lld_adv_stop = 0x400040f8; +r_lld_adv_sync_info_set = 0x40004104; +r_lld_adv_sync_info_update = 0x40004110; +r_lld_calc_aux_rx = 0x4000411c; +r_lld_cca_alloc = 0x40004128; +r_lld_cca_data_reset = 0x40004134; +r_lld_cca_free = 0x40004140; +r_lld_ch_assess_data_get = 0x4000414c; +r_lld_ch_idx_get = 0x40004158; +r_lld_ch_map_set = 0x40004164; +r_lld_channel_assess = 0x40004170; +r_lld_con_activity_act_offset_compute = 0x4000417c; +r_lld_con_activity_offset_compute = 0x40004188; +r_lld_con_ch_map_update = 0x40004194; +r_lld_con_cleanup = 0x400041a0; +r_lld_con_current_tx_power_get = 0x400041ac; +r_lld_con_data_flow_set = 0x400041b8; +r_lld_con_data_len_update = 0x400041c4; +r_lld_con_data_tx = 0x400041d0; +r_lld_con_enc_key_load = 0x400041dc; +r_lld_con_event_counter_get = 0x400041e8; +r_lld_con_evt_canceled_cbk = 0x400041f4; +r_lld_con_evt_duration_min_get = 0x40004200; +r_lld_con_evt_max_eff_time_cal = 0x4000420c; +r_lld_con_evt_sd_evt_time_get = 0x40004218; +r_lld_con_evt_start_cbk = 0x40004224; +r_lld_con_evt_time_update = 0x40004230; +r_lld_con_free_all_tx_buf = 0x4000423c; +r_lld_con_frm_cbk = 0x40004248; +r_lld_con_frm_isr = 0x40004254; +r_lld_con_frm_skip_isr = 0x40004260; +r_lld_con_init = 0x4000426c; +r_lld_con_llcp_tx = 0x40004278; +r_lld_con_max_lat_calc = 0x40004284; +r_lld_con_offset_get = 0x40004290; +r_lld_con_param_update = 0x4000429c; +r_lld_con_phys_update = 0x400042a8; +r_lld_con_pref_slave_evt_dur_set = 0x400042b4; +r_lld_con_pref_slave_latency_set = 0x400042c0; +r_lld_con_rssi_get = 0x400042cc; +r_lld_con_rx = 0x400042d8; +/* r_lld_con_rx_channel_assess = 0x400042e4; */ +r_lld_con_rx_enc = 0x400042f0; +r_lld_con_rx_isr = 0x400042fc; +r_lld_con_rx_link_info_check = 0x40004308; +r_lld_con_rx_llcp_check = 0x40004314; +r_lld_con_rx_sync_time_update = 0x40004320; +r_lld_con_set_tx_power = 0x40004338; +r_lld_con_start = 0x40004344; +r_lld_con_tx = 0x4000435c; +r_lld_con_tx_enc = 0x40004368; +r_lld_con_tx_isr = 0x40004374; +r_lld_con_tx_len_update = 0x40004380; +r_lld_con_tx_len_update_for_intv = 0x4000438c; +r_lld_con_tx_len_update_for_rate = 0x40004398; +r_lld_con_tx_prog = 0x400043a4; +r_lld_conn_dynamic_pti_process = 0x400043b0; +r_lld_continue_scan_rx_isr_end_process = 0x400043bc; +r_lld_ext_scan_dynamic_pti_process = 0x400043c8; +r_lld_hw_cca_end_isr = 0x400043d4; +r_lld_hw_cca_evt_handler = 0x400043e0; +r_lld_hw_cca_isr = 0x400043ec; +r_lld_init_cal_anchor_point = 0x400043f8; +r_lld_init_compute_winoffset = 0x40004404; +r_lld_init_connect_req_pack = 0x40004410; +r_lld_init_end = 0x4000441c; +r_lld_init_evt_canceled_cbk = 0x40004428; +r_lld_init_evt_start_cbk = 0x40004434; +r_lld_init_frm_cbk = 0x40004440; +r_lld_init_frm_eof_isr = 0x4000444c; +r_lld_init_frm_skip_isr = 0x40004458; +r_lld_init_init = 0x40004464; +r_lld_init_process_pkt_rx = 0x40004470; +r_lld_init_process_pkt_rx_adv_ext_ind = 0x4000447c; +r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x40004488; +r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40004494; +r_lld_init_process_pkt_tx = 0x400044a0; +r_lld_init_process_pkt_tx_cal_con_timestamp = 0x400044ac; +r_lld_init_sched = 0x400044b8; +r_lld_init_set_tx_power = 0x400044c4; +r_lld_init_start = 0x400044d0; +r_lld_init_stop = 0x400044dc; +r_lld_instant_proc_end = 0x400044e8; +r_lld_per_adv_ch_map_update = 0x40004500; +r_lld_per_adv_chain_construct = 0x4000450c; +r_lld_per_adv_cleanup = 0x40004518; +r_lld_per_adv_coex_env_reset = 0x40004524; +r_lld_per_adv_data_set = 0x40004530; +r_lld_per_adv_data_update = 0x4000453c; +r_lld_per_adv_dynamic_pti_process = 0x40004548; +r_lld_per_adv_evt_canceled_cbk = 0x40004554; +r_lld_per_adv_evt_start_cbk = 0x40004560; +r_lld_per_adv_ext_pkt_prepare = 0x4000456c; +r_lld_per_adv_frm_cbk = 0x40004578; +r_lld_per_adv_frm_isr = 0x40004584; +r_lld_per_adv_frm_skip_isr = 0x40004590; +r_lld_per_adv_init = 0x4000459c; +r_lld_per_adv_init_info_get = 0x400045a8; +r_lld_per_adv_list_add = 0x400045b4; +r_lld_per_adv_list_rem = 0x400045c0; +r_lld_per_adv_set_tx_power = 0x400045d8; +r_lld_per_adv_start = 0x400045e4; +r_lld_per_adv_stop = 0x400045f0; +r_lld_per_adv_sync_info_get = 0x400045fc; +r_lld_process_cca_data = 0x40004608; +r_lld_ral_search = 0x40004614; +r_lld_read_clock = 0x40004620; +r_lld_res_list_add = 0x4000462c; +r_lld_res_list_is_empty = 0x40004644; +r_lld_res_list_local_rpa_get = 0x40004650; +r_lld_res_list_peer_rpa_get = 0x4000465c; +r_lld_res_list_peer_update = 0x40004668; +/* r_lld_res_list_priv_mode_update = 0x40004674; */ +r_lld_reset_reg = 0x4000468c; +r_lld_rpa_renew = 0x40004698; +r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4; +r_lld_rpa_renew_evt_start_cbk = 0x400046b0; +r_lld_rpa_renew_instant_cbk = 0x400046bc; +r_lld_rxdesc_check = 0x400046c8; +r_lld_rxdesc_free = 0x400046d4; +r_lld_scan_create_sync = 0x400046e0; +r_lld_scan_create_sync_cancel = 0x400046ec; +r_lld_scan_end = 0x400046f8; +r_lld_scan_evt_canceled_cbk = 0x40004704; +r_lld_scan_evt_start_cbk = 0x40004710; +r_lld_scan_frm_cbk = 0x4000471c; +r_lld_scan_frm_eof_isr = 0x40004728; +r_lld_scan_frm_rx_isr = 0x40004734; +r_lld_scan_frm_skip_isr = 0x40004740; +r_lld_scan_init = 0x4000474c; +r_lld_scan_params_update = 0x40004758; +r_lld_scan_process_pkt_rx_aux_adv_ind = 0x4000477c; +r_lld_scan_process_pkt_rx_aux_chain_ind = 0x40004788; +r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40004794; +r_lld_scan_process_pkt_rx_ext_adv = 0x400047a0; +r_lld_scan_process_pkt_rx_ext_adv_ind = 0x400047ac; +r_lld_scan_process_pkt_rx_legacy_adv = 0x400047b8; +r_lld_scan_restart = 0x400047c4; +r_lld_scan_sched = 0x400047d0; +r_lld_scan_set_tx_power = 0x400047dc; +r_lld_scan_start = 0x400047e8; +r_lld_scan_stop = 0x400047f4; +r_lld_scan_sync_accept = 0x40004800; +r_lld_scan_sync_info_unpack = 0x4000480c; +r_lld_scan_trunc_ind = 0x40004818; +r_lld_sw_cca_evt_handler = 0x40004824; +r_lld_sw_cca_isr = 0x40004830; +r_lld_sync_ch_map_update = 0x4000483c; +r_lld_sync_cleanup = 0x40004848; +r_lld_sync_evt_canceled_cbk = 0x40004854; +r_lld_sync_evt_start_cbk = 0x40004860; +r_lld_sync_frm_cbk = 0x4000486c; +r_lld_sync_frm_eof_isr = 0x40004878; +r_lld_sync_frm_rx_isr = 0x40004884; +r_lld_sync_frm_skip_isr = 0x40004890; +r_lld_sync_init = 0x4000489c; +r_lld_sync_process_pkt_rx = 0x400048a8; +r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400048b4; +r_lld_sync_process_pkt_rx_pkt_check = 0x400048c0; +r_lld_sync_scan_dynamic_pti_process = 0x400048cc; +r_lld_sync_sched = 0x400048d8; +r_lld_sync_start = 0x400048e4; +r_lld_sync_stop = 0x400048f0; +r_lld_sync_trunc_ind = 0x400048fc; +r_lld_test_cleanup = 0x40004908; +r_lld_test_evt_canceled_cbk = 0x40004914; +r_lld_test_evt_start_cbk = 0x40004920; +r_lld_test_freq2chnl = 0x4000492c; +r_lld_test_frm_cbk = 0x40004938; +r_lld_test_frm_isr = 0x40004944; +r_lld_test_init = 0x40004950; +r_lld_test_rx_isr = 0x4000495c; +r_lld_test_set_tx_power = 0x40004968; +r_lld_test_start = 0x40004974; +/* r_lld_test_stop = 0x40004980;*/ +r_lld_update_rxbuf = 0x4000498c; +r_lld_update_rxbuf_isr = 0x40004998; +r_lld_white_list_add = 0x400049a4; +r_lld_white_list_rem = 0x400049b0; +r_llm_activity_free_get = 0x400049bc; +r_llm_activity_free_set = 0x400049c8; +r_llm_activity_syncing_get = 0x400049d4; +r_llm_adv_con_len_check = 0x400049e0; +r_llm_adv_hdl_to_id = 0x400049ec; +r_llm_adv_rep_flow_control_check = 0x400049f8; +r_llm_adv_rep_flow_control_update = 0x40004a04; +r_llm_adv_reports_list_check = 0x40004a10; +r_llm_adv_set_all_release = 0x40004a1c; +r_llm_adv_set_dft_params = 0x40004a28; +r_llm_adv_set_release = 0x40004a34; +r_llm_aes_res_cb = 0x40004a40; +r_llm_ble_update_adv_flow_control = 0x40004a4c; +r_llm_ch_map_update = 0x40004a58; +r_llm_cmd_cmp_send = 0x40004a64; +r_llm_cmd_stat_send = 0x40004a70; +r_llm_dev_list_empty_entry = 0x40004a7c; +r_llm_dev_list_search = 0x40004a88; +r_llm_env_adv_dup_filt_deinit = 0x40004a94; +r_llm_env_adv_dup_filt_init = 0x40004aa0; +r_llm_init_ble_adv_report_flow_contol = 0x40004aac; +r_llm_is_dev_connected = 0x40004ab8; +r_llm_is_dev_synced = 0x40004ac4; +r_llm_is_non_con_act_ongoing_check = 0x40004ad0; +r_llm_is_wl_accessible = 0x40004adc; +r_llm_le_evt_mask_check = 0x40004ae8; +r_llm_link_disc = 0x40004b00; +r_llm_master_ch_map_get = 0x40004b0c; +r_llm_msg_handler_tab_p_get = 0x40004b18; +r_llm_no_activity = 0x40004b24; +r_llm_per_adv_slot_dur = 0x40004b30; +r_llm_plan_elt_get = 0x40004b3c; +r_llm_rx_path_comp_get = 0x40004b48; +r_llm_scan_start = 0x40004b54; +r_llm_scan_sync_acad_attach = 0x40004b60; +r_llm_scan_sync_acad_detach = 0x40004b6c; +r_llm_send_adv_lost_event_to_host = 0x40004b78; +r_llm_tx_path_comp_get = 0x40004b84; +r_misc_deinit = 0x40004b90; +r_misc_free_em_buf_in_isr = 0x40004b9c; +r_misc_init = 0x40004ba8; +r_misc_msg_handler_tab_p_get = 0x40004bb4; +r_notEqual256 = 0x40004bc0; +r_phy_upd_proc_start = 0x40004bcc; +r_platform_reset = 0x40004bd8; +r_rf_em_init = 0x40004bf0; +r_rf_force_agc_enable = 0x40004bfc; +r_rf_reg_rd = 0x40004c08; +r_rf_reg_wr = 0x40004c14; +r_rf_reset = 0x40004c20; +r_rf_rssi_convert = 0x40004c2c; +r_rf_rw_v9_le_disable = 0x40004c38; +r_rf_rw_v9_le_enable = 0x40004c44; +r_rf_sleep = 0x40004c50; +r_rf_util_cs_fmt_convert = 0x40004c74; +r_rw_crypto_aes_ccm = 0x40004c80; +r_rw_crypto_aes_encrypt = 0x40004c8c; +r_rw_crypto_aes_init = 0x40004c98; +r_rw_crypto_aes_k1 = 0x40004ca4; +r_rw_crypto_aes_k2 = 0x40004cb0; +r_rw_crypto_aes_k3 = 0x40004cbc; +r_rw_crypto_aes_k4 = 0x40004cc8; +r_rw_crypto_aes_rand = 0x40004cd4; +r_rw_crypto_aes_result_handler = 0x40004ce0; +r_rw_crypto_aes_s1 = 0x40004cec; +r_rw_cryto_aes_cmac = 0x40004cf8; +r_rw_v9_init_em_radio_table = 0x40004d04; +r_rwble_sleep_enter = 0x40004d1c; +r_rwble_sleep_wakeup_end = 0x40004d28; +/* r_rwbtdm_isr_wrapper = 0x40004d34; */ +r_rwip_active_check = 0x40004d40; +r_rwip_aes_encrypt = 0x40004d4c; +/* r_rwip_assert = 0x40004d58; */ +r_rwip_crypt_evt_handler = 0x40004d64; +r_rwip_crypt_isr_handler = 0x40004d70; +r_rwip_eif_get = 0x40004d7c; +r_rwip_half_slot_2_lpcycles = 0x40004d88; +r_rwip_hus_2_lpcycles = 0x40004d94; +r_rwip_isr = 0x40004da0; +r_rwip_lpcycles_2_hus = 0x40004dac; +r_rwip_prevent_sleep_clear = 0x40004db8; +r_rwip_prevent_sleep_set = 0x40004dc4; +r_rwip_schedule = 0x40004dd0; +r_rwip_sleep = 0x40004ddc; +r_rwip_sw_int_handler = 0x40004de8; +r_rwip_sw_int_req = 0x40004df4; +r_rwip_time_get = 0x40004e00; +r_rwip_timer_10ms_handler = 0x40004e0c; +r_rwip_timer_10ms_set = 0x40004e18; +r_rwip_timer_hs_handler = 0x40004e24; +r_rwip_timer_hs_set = 0x40004e30; +r_rwip_timer_hus_handler = 0x40004e3c; +r_rwip_timer_hus_set = 0x40004e48; +r_rwip_wakeup = 0x40004e54; +/* r_rwip_wakeup_end = 0x40004e60; */ +r_rwip_wlcoex_set = 0x40004e6c; +r_sch_alarm_clear = 0x40004e78; +r_sch_alarm_init = 0x40004e84; +r_sch_alarm_prog = 0x40004e90; +r_sch_alarm_set = 0x40004e9c; +r_sch_alarm_timer_isr = 0x40004ea8; +r_sch_arb_conflict_check = 0x40004eb4; +r_sch_arb_elt_cancel = 0x40004ec0; +r_sch_arb_init = 0x40004ed8; +r_sch_arb_insert = 0x40004ee4; +r_sch_arb_prog_timer = 0x40004ef0; +r_sch_arb_remove = 0x40004efc; +r_sch_arb_sw_isr = 0x40004f08; +r_sch_plan_chk = 0x40004f14; +r_sch_plan_clock_wrap_offset_update = 0x40004f20; +r_sch_plan_init = 0x40004f2c; +r_sch_plan_interval_req = 0x40004f38; +r_sch_plan_offset_max_calc = 0x40004f44; +r_sch_plan_offset_req = 0x40004f50; +r_sch_plan_position_range_compute = 0x40004f5c; +r_sch_plan_rem = 0x40004f68; +r_sch_plan_req = 0x40004f74; +r_sch_prog_init = 0x40004f98; +r_sch_prog_push = 0x40004fa4; +r_sch_prog_rx_isr = 0x40004fb0; +r_sch_prog_skip_isr = 0x40004fbc; +r_sch_prog_tx_isr = 0x40004fc8; +r_sch_slice_bg_add = 0x40004fd4; +r_sch_slice_bg_remove = 0x40004fe0; +r_sch_slice_compute = 0x40004fec; +r_sch_slice_fg_add = 0x40004ff8; +r_sch_slice_fg_remove = 0x40005004; +r_sch_slice_init = 0x40005010; +r_sch_slice_per_add = 0x4000501c; +r_sch_slice_per_remove = 0x40005028; +r_sdk_config_get_bt_sleep_enable = 0x40005034; +r_sdk_config_get_hl_derived_opts = 0x40005040; +r_sdk_config_get_opts = 0x4000504c; +r_sdk_config_get_priv_opts = 0x40005058; +r_sdk_config_set_bt_sleep_enable = 0x40005064; +r_sdk_config_set_hl_derived_opts = 0x40005070; +r_sdk_config_set_opts = 0x4000507c; +r_specialModP256 = 0x40005088; +r_unloaded_area_init = 0x40005094; +r_vhci_flow_off = 0x400050a0; +r_vhci_flow_on = 0x400050ac; +r_vhci_notify_host_send_available = 0x400050b8; +r_vhci_send_to_host = 0x400050c4; +r_vnd_hci_command_handler = 0x400050d0; +r_vshci_init = 0x400050dc; +vnd_hci_command_handler_wrapper = 0x400050e8; +r_lld_legacy_adv_dynamic_pti_get = 0x400050f4; +r_lld_legacy_adv_dynamic_pti_process = 0x40005100; +r_lld_ext_adv_dynamic_pti_get = 0x4000510c; +r_lld_ext_adv_dynamic_aux_pti_process = 0x40005118; +r_lld_ext_adv_dynamic_pti_process = 0x40005124; +/* +r_lld_adv_ext_pkt_prepare_set = 0x40005130; +*/ +r_lld_adv_ext_chain_connectable_construct = 0x40005148; +r_lld_adv_pkt_rx_connect_post = 0x40005160; +r_lld_adv_start_init_evt_param = 0x4000516c; +r_lld_adv_start_set_cs = 0x40005178; +/* r_lld_adv_start_update_filter_policy = 0x40005184; */ +r_lld_adv_start_schedule_asap = 0x40005190; +r_lld_con_tx_prog_new_packet_coex = 0x4000519c; +r_lld_per_adv_dynamic_pti_get = 0x400051b4; +r_lld_per_adv_evt_start_chm_upd = 0x400051c0; +r_lld_ext_scan_dynamic_pti_get = 0x400051cc; +r_lld_sync_insert = 0x400051e4; +/* +r_sch_prog_ble_push = 0x400051f0; +*/ +r_sch_prog_bt_push = 0x400051fc; +r_lld_init_evt_end_type_set = 0x40005208; +r_lld_init_evt_end_type_get = 0x40005214; +r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40005220; +r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x4000522c; +r_lld_init_evt_end_type_check_state_set = 0x40005238; +r_lld_init_evt_end_type_check_state_get = 0x40005244; + +/* bluetooth hook funcs */ +r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; +r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; +r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; +r_lld_scan_frm_eof_isr_hook = 0x40001c6c; +r_lld_scan_evt_start_cbk_hook = 0x40001c70; +r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; +r_lld_scan_sched_hook = 0x40001c7c; +r_lld_adv_evt_start_cbk_hook = 0x40001c84; +r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; +r_lld_adv_frm_isr_hook = 0x40001c8c; +r_lld_adv_start_init_evt_param_hook = 0x40001c90; +r_lld_con_evt_canceled_cbk_hook = 0x40001c94; +r_lld_con_frm_isr_hook = 0x40001c98; +r_lld_con_tx_hook = 0x40001c9c; +r_lld_con_rx_hook = 0x40001ca0; +r_lld_con_evt_start_cbk_hook = 0x40001ca4; +r_lld_con_tx_prog_new_packet_hook = 0x40001cac; +r_lld_init_frm_eof_isr_hook = 0x40001cb0; +r_lld_init_evt_start_cbk_hook = 0x40001cb4; +r_lld_init_sched_hook = 0x40001cbc; +r_lld_init_process_pkt_tx_hook = 0x40001cc0; +r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; +r_lld_per_adv_frm_isr_hook = 0x40001cc8; +r_lld_per_adv_start_hook = 0x40001ccc; +r_lld_sync_frm_eof_isr_hook = 0x40001cd0; +r_lld_sync_evt_start_cbk_hook = 0x40001cd4; +r_lld_sync_start_hook = 0x40001cd8; +r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; +r_sch_arb_insert_hook = 0x40001ce0; +r_sch_plan_offset_req_hook = 0x40001ce4; diff --git a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld index 49d401d356b..a883ee04162 100644 --- a/components/esp_rom/esp32s3/ld/esp32s3.rom.ld +++ b/components/esp_rom/esp32s3/ld/esp32s3.rom.ld @@ -776,825 +776,6 @@ rom_usb_osglue = 0x3fceffac; Group bluetooth ***************************************/ -/* Functions */ -bt_rf_coex_get_dft_cfg = 0x40002a78; -bt_rf_coex_hooks_p_set = 0x40002a84; -btdm_con_maxevtime_cal_impl = 0x40002a90; -btdm_controller_get_compile_version_impl = 0x40002a9c; -btdm_controller_rom_data_init = 0x40002aa8; -btdm_dis_privacy_err_report_impl = 0x40002ab4; -btdm_disable_adv_delay_impl = 0x40002ac0; -btdm_enable_scan_continue_impl = 0x40002acc; -btdm_enable_scan_forever_impl = 0x40002ad8; -btdm_get_power_state_impl = 0x40002ae4; -btdm_get_prevent_sleep_flag_impl = 0x40002af0; -btdm_power_state_active_impl = 0x40002afc; -btdm_switch_phy_coded_impl = 0x40002b08; -hci_acl_data_handler = 0x40002b14; -hci_disconnect_cmd_handler = 0x40002b20; -hci_le_con_upd_cmd_handler = 0x40002b2c; -hci_le_ltk_req_neg_reply_cmd_handler = 0x40002b38; -hci_le_ltk_req_reply_cmd_handler = 0x40002b44; -hci_le_rd_chnl_map_cmd_handler = 0x40002b50; -hci_le_rd_phy_cmd_handler = 0x40002b5c; -hci_le_rd_rem_feats_cmd_handler = 0x40002b68; -hci_le_rem_con_param_req_neg_reply_cmd_handler = 0x40002b74; -hci_le_rem_con_param_req_reply_cmd_handler = 0x40002b80; -hci_le_set_data_len_cmd_handler = 0x40002b8c; -hci_le_set_phy_cmd_handler = 0x40002b98; -hci_le_start_enc_cmd_handler = 0x40002ba4; -hci_rd_auth_payl_to_cmd_handler = 0x40002bb0; -hci_rd_rem_ver_info_cmd_handler = 0x40002bbc; -hci_rd_rssi_cmd_handler = 0x40002bc8; -hci_rd_tx_pwr_lvl_cmd_handler = 0x40002bd4; -hci_vs_set_pref_slave_evt_dur_cmd_handler = 0x40002be0; -hci_vs_set_pref_slave_latency_cmd_handler = 0x40002bec; -hci_wr_auth_payl_to_cmd_handler = 0x40002bf8; -ll_channel_map_ind_handler = 0x40002c04; -ll_connection_param_req_handler = 0x40002c10; -ll_connection_param_rsp_handler = 0x40002c1c; -ll_connection_update_ind_handler = 0x40002c28; -ll_enc_req_handler = 0x40002c34; -ll_enc_rsp_handler = 0x40002c40; -ll_feature_req_handler = 0x40002c4c; -ll_feature_rsp_handler = 0x40002c58; -ll_length_req_handler = 0x40002c64; -ll_length_rsp_handler = 0x40002c70; -ll_min_used_channels_ind_handler = 0x40002c7c; -ll_pause_enc_req_handler = 0x40002c88; -ll_pause_enc_rsp_handler = 0x40002c94; -ll_phy_req_handler = 0x40002ca0; -ll_phy_rsp_handler = 0x40002cac; -ll_phy_update_ind_handler = 0x40002cb8; -ll_ping_req_handler = 0x40002cc4; -ll_ping_rsp_handler = 0x40002cd0; -ll_slave_feature_req_handler = 0x40002cdc; -ll_start_enc_req_handler = 0x40002ce8; -ll_start_enc_rsp_handler = 0x40002cf4; -ll_terminate_ind_handler = 0x40002d00; -ll_version_ind_handler = 0x40002d0c; -llc_auth_payl_nearly_to_handler = 0x40002d18; -llc_auth_payl_real_to_handler = 0x40002d24; -llc_encrypt_ind_handler = 0x40002d30; -llc_hci_command_handler_wrapper = 0x40002d3c; -llc_ll_connection_param_req_pdu_send = 0x40002d48; -llc_ll_connection_param_rsp_pdu_send = 0x40002d54; -llc_ll_connection_update_ind_pdu_send = 0x40002d60; -llc_ll_enc_req_pdu_send = 0x40002d6c; -llc_ll_enc_rsp_pdu_send = 0x40002d78; -llc_ll_feature_req_pdu_send = 0x40002d84; -llc_ll_feature_rsp_pdu_send = 0x40002d90; -llc_ll_length_req_pdu_send = 0x40002d9c; -llc_ll_length_rsp_pdu_send = 0x40002da8; -llc_ll_pause_enc_req_pdu_send = 0x40002db4; -llc_ll_pause_enc_rsp_pdu_send = 0x40002dc0; -llc_ll_phy_req_pdu_send = 0x40002dcc; -llc_ll_phy_rsp_pdu_send = 0x40002dd8; -llc_ll_ping_req_pdu_send = 0x40002de4; -llc_ll_ping_rsp_pdu_send = 0x40002df0; -llc_ll_start_enc_req_pdu_send = 0x40002dfc; -llc_ll_start_enc_rsp_pdu_send = 0x40002e08; -llc_ll_terminate_ind_pdu_send = 0x40002e14; -llc_ll_unknown_rsp_pdu_send = 0x40002e20; -llc_llcp_ch_map_update_ind_pdu_send = 0x40002e2c; -llc_llcp_phy_upd_ind_pdu_send = 0x40002e38; -llc_llcp_version_ind_pdu_send = 0x40002e44; -llc_op_ch_map_upd_ind_handler = 0x40002e50; -llc_op_con_upd_ind_handler = 0x40002e5c; -llc_op_disconnect_ind_handler = 0x40002e68; -llc_op_dl_upd_ind_handler = 0x40002e74; -llc_op_encrypt_ind_handler = 0x40002e80; -llc_op_feats_exch_ind_handler = 0x40002e8c; -llc_op_le_ping_ind_handler = 0x40002e98; -llc_op_phy_upd_ind_handler = 0x40002ea4; -llc_op_ver_exch_ind_handler = 0x40002eb0; -llc_stopped_ind_handler = 0x40002ebc; -lld_acl_rx_ind_handler = 0x40002ec8; -lld_acl_tx_cfm_handler = 0x40002ed4; -lld_adv_end_ind_handler = 0x40002ee0; -lld_adv_rep_ind_handler = 0x40002eec; -lld_ch_map_upd_cfm_handler = 0x40002ef8; -lld_con_estab_ind_handler = 0x40002f04; -lld_con_evt_sd_evt_time_set = 0x40002f10; -lld_con_offset_upd_ind_handler = 0x40002f1c; -lld_con_param_upd_cfm_handler = 0x40002f28; -lld_disc_ind_handler = 0x40002f34; -lld_init_end_ind_handler = 0x40002f40; -lld_llcp_rx_ind_handler_wrapper = 0x40002f4c; -lld_llcp_tx_cfm_handler = 0x40002f58; -lld_per_adv_end_ind_handler = 0x40002f64; -lld_per_adv_rep_ind_handler = 0x40002f70; -lld_per_adv_rx_end_ind_handler = 0x40002f7c; -lld_phy_coded_500k_get = 0x40002f88; -lld_phy_upd_cfm_handler = 0x40002f94; -lld_scan_end_ind_handler = 0x40002fa0; -lld_scan_req_ind_handler = 0x40002fac; -lld_sync_start_req_handler = 0x40002fb8; -lld_test_end_ind_handler = 0x40002fc4; -lld_update_rxbuf_handler = 0x40002fd0; -llm_ch_map_update_ind_handler = 0x40002fdc; -llm_hci_command_handler_wrapper = 0x40002fe8; -llm_scan_period_to_handler = 0x40002ff4; -r_Add2SelfBigHex256 = 0x40003000; -r_AddBigHex256 = 0x4000300c; -r_AddBigHexModP256 = 0x40003018; -r_AddP256 = 0x40003024; -r_AddPdiv2_256 = 0x40003030; -r_GF_Jacobian_Point_Addition256 = 0x4000303c; -r_GF_Jacobian_Point_Double256 = 0x40003048; -r_GF_Point_Jacobian_To_Affine256 = 0x40003054; -r_MultiplyBigHexByUint32_256 = 0x40003060; -r_MultiplyBigHexModP256 = 0x4000306c; -r_MultiplyByU16ModP256 = 0x40003078; -r_SubtractBigHex256 = 0x40003084; -r_SubtractBigHexMod256 = 0x40003090; -r_SubtractBigHexUint32_256 = 0x4000309c; -r_SubtractFromSelfBigHex256 = 0x400030a8; -r_SubtractFromSelfBigHexSign256 = 0x400030b4; -r_aes_alloc = 0x400030c0; -r_aes_ccm_continue = 0x400030cc; -r_aes_ccm_process_e = 0x400030d8; -r_aes_ccm_xor_128_lsb = 0x400030e4; -r_aes_ccm_xor_128_msb = 0x400030f0; -r_aes_cmac_continue = 0x400030fc; -r_aes_cmac_start = 0x40003108; -r_aes_k1_continue = 0x40003114; -r_aes_k2_continue = 0x40003120; -r_aes_k3_continue = 0x4000312c; -r_aes_k4_continue = 0x40003138; -r_aes_shift_left_128 = 0x40003144; -r_aes_start = 0x40003150; -r_aes_xor_128 = 0x4000315c; -r_assert_err = 0x40003168; -r_assert_param = 0x40003174; -r_assert_warn = 0x40003180; -r_bigHexInversion256 = 0x4000318c; -r_ble_sw_cca_check_isr = 0x40003198; -r_ble_util_buf_acl_tx_alloc = 0x400031a4; -r_ble_util_buf_acl_tx_elt_get = 0x400031b0; -r_ble_util_buf_acl_tx_free = 0x400031bc; -r_ble_util_buf_acl_tx_free_in_isr = 0x400031c8; -r_ble_util_buf_adv_tx_alloc = 0x400031d4; -r_ble_util_buf_adv_tx_free = 0x400031e0; -r_ble_util_buf_adv_tx_free_in_isr = 0x400031ec; -r_ble_util_buf_env_deinit = 0x400031f8; -r_ble_util_buf_env_init = 0x40003204; -r_ble_util_buf_get_rx_buf_nb = 0x40003210; -r_ble_util_buf_get_rx_buf_size = 0x4000321c; -r_ble_util_buf_llcp_tx_alloc = 0x40003228; -r_ble_util_buf_llcp_tx_free = 0x40003234; -r_ble_util_buf_rx_alloc = 0x40003240; -r_ble_util_buf_rx_alloc_in_isr = 0x4000324c; -r_ble_util_buf_rx_free = 0x40003258; -r_ble_util_buf_rx_free_in_isr = 0x40003264; -r_ble_util_buf_set_rx_buf_nb = 0x40003270; -r_ble_util_buf_set_rx_buf_size = 0x4000327c; -r_ble_util_data_rx_buf_reset = 0x40003288; -r_bt_bb_get_intr_mask = 0x40003294; -r_bt_bb_intr_clear = 0x400032a0; -r_bt_bb_intr_mask_set = 0x400032ac; -r_bt_rf_coex_cfg_set = 0x400032c4; -r_bt_rf_coex_conn_dynamic_pti_en_get = 0x400032d0; -r_bt_rf_coex_ext_adv_dynamic_pti_en_get = 0x400032e8; -r_bt_rf_coex_ext_scan_dynamic_pti_en_get = 0x400032f4; -r_bt_rf_coex_legacy_adv_dynamic_pti_en_get = 0x40003300; -r_bt_rf_coex_per_adv_dynamic_pti_en_get = 0x4000330c; -r_bt_rf_coex_pti_table_get = 0x40003318; -r_bt_rf_coex_st_param_get = 0x40003324; -r_bt_rf_coex_st_param_set = 0x40003330; -r_bt_rf_coex_sync_scan_dynamic_pti_en_get = 0x4000333c; -r_bt_rma_apply_rule_cs_fmt = 0x40003348; -r_bt_rma_apply_rule_cs_idx = 0x40003354; -r_bt_rma_configure = 0x40003360; -r_bt_rma_deregister_rule_cs_fmt = 0x4000336c; -r_bt_rma_deregister_rule_cs_idx = 0x40003378; -r_bt_rma_get_ant_by_act = 0x40003384; -r_bt_rma_init = 0x40003390; -r_bt_rma_register_rule_cs_fmt = 0x4000339c; -r_bt_rma_register_rule_cs_idx = 0x400033a8; -r_bt_rtp_apply_rule_cs_fmt = 0x400033b4; -r_bt_rtp_apply_rule_cs_idx = 0x400033c0; -r_bt_rtp_deregister_rule_cs_fmt = 0x400033cc; -r_bt_rtp_deregister_rule_cs_idx = 0x400033d8; -r_bt_rtp_init = 0x400033f0; -r_bt_rtp_register_rule_cs_fmt = 0x400033fc; -r_bt_rtp_register_rule_cs_idx = 0x40003408; -r_btdm_isr = 0x40003414; -r_cali_phase_match_p = 0x40003444; -r_cmp_abs_time = 0x40003450; -r_cmp_dest_id = 0x4000345c; -r_cmp_timer_id = 0x40003468; -r_co_bdaddr_compare = 0x40003474; -r_co_ble_pkt_dur_in_us = 0x40003480; -r_co_list_extract = 0x4000348c; -r_co_list_extract_after = 0x40003498; -r_co_list_extract_sublist = 0x400034a4; -r_co_list_find = 0x400034b0; -r_co_list_init = 0x400034bc; -r_co_list_insert_after = 0x400034c8; -r_co_list_insert_before = 0x400034d4; -r_co_list_merge = 0x400034e0; -r_co_list_pool_init = 0x400034ec; -r_co_list_pop_front = 0x400034f8; -r_co_list_push_back = 0x40003504; -r_co_list_push_back_sublist = 0x40003510; -r_co_list_push_front = 0x4000351c; -r_co_list_size = 0x40003528; -r_co_nb_good_le_channels = 0x40003534; -r_co_util_pack = 0x40003540; -r_co_util_read_array_size = 0x4000354c; -r_co_util_unpack = 0x40003558; -r_dbg_env_deinit = 0x40003564; -r_dbg_env_init = 0x40003570; -r_dbg_platform_reset_complete = 0x4000357c; -r_dl_upd_proc_start = 0x40003588; -r_dump_data = 0x40003594; -r_ecc_abort_key256_generation = 0x400035a0; -r_ecc_gen_new_public_key = 0x400035ac; -r_ecc_gen_new_secret_key = 0x400035b8; -r_ecc_generate_key256 = 0x400035c4; -r_ecc_get_debug_Keys = 0x400035d0; -r_ecc_init = 0x400035dc; -r_ecc_is_valid_point = 0x400035e8; -r_ecc_multiplication_event_handler = 0x400035f4; -r_ecc_point_multiplication_win_256 = 0x40003600; -r_emi_alloc_em_mapping_by_offset = 0x4000360c; -r_emi_base_reg_lut_show = 0x40003618; -r_emi_em_base_reg_show = 0x40003624; -r_emi_free_em_mapping_by_offset = 0x40003630; -r_emi_get_em_mapping_idx_by_offset = 0x4000363c; -r_emi_get_mem_addr_by_offset = 0x40003648; -r_emi_overwrite_em_mapping_by_offset = 0x40003654; -r_esp_vendor_hci_command_handler = 0x40003660; -r_get_stack_usage = 0x4000366c; -r_h4tl_acl_hdr_rx_evt_handler = 0x40003678; -r_h4tl_cmd_hdr_rx_evt_handler = 0x40003684; -r_h4tl_cmd_pld_rx_evt_handler = 0x40003690; -r_h4tl_eif_io_event_post = 0x4000369c; -r_h4tl_eif_register = 0x400036a8; -r_h4tl_init = 0x400036b4; -r_h4tl_out_of_sync = 0x400036c0; -r_h4tl_out_of_sync_check = 0x400036cc; -r_h4tl_read_hdr = 0x400036d8; -r_h4tl_read_next_out_of_sync = 0x400036e4; -r_h4tl_read_payl = 0x400036f0; -r_h4tl_read_start = 0x400036fc; -r_h4tl_rx_acl_hdr_extract = 0x40003708; -r_h4tl_rx_cmd_hdr_extract = 0x40003714; -r_h4tl_rx_done = 0x40003720; -r_h4tl_start = 0x4000372c; -r_h4tl_stop = 0x40003738; -r_h4tl_tx_done = 0x40003744; -r_h4tl_tx_evt_handler = 0x40003750; -r_h4tl_write = 0x4000375c; -r_hci_acl_tx_data_alloc = 0x40003768; -r_hci_acl_tx_data_received = 0x40003774; -r_hci_basic_cmd_send_2_controller = 0x40003780; -r_hci_ble_adv_report_filter_check = 0x4000378c; -r_hci_ble_adv_report_tx_check = 0x40003798; -r_hci_ble_conhdl_register = 0x400037a4; -r_hci_ble_conhdl_unregister = 0x400037b0; -r_hci_build_acl_data = 0x400037bc; -r_hci_build_cc_evt = 0x400037c8; -r_hci_build_cs_evt = 0x400037d4; -r_hci_build_evt = 0x400037e0; -r_hci_build_le_evt = 0x400037ec; -r_hci_cmd_get_max_param_size = 0x400037f8; -r_hci_cmd_received = 0x40003804; -r_hci_cmd_reject = 0x40003810; -r_hci_evt_mask_check = 0x4000381c; -r_hci_evt_mask_set = 0x40003828; -r_hci_fc_acl_buf_size_set = 0x40003834; -r_hci_fc_acl_en = 0x40003840; -r_hci_fc_acl_packet_sent = 0x4000384c; -r_hci_fc_check_host_available_nb_acl_packets = 0x40003858; -r_hci_fc_host_nb_acl_pkts_complete = 0x40003864; -r_hci_fc_init = 0x40003870; -r_hci_look_for_cmd_desc = 0x4000387c; -r_hci_look_for_evt_desc = 0x40003888; -r_hci_look_for_le_evt_desc = 0x40003894; -r_hci_look_for_le_evt_desc_esp = 0x400038a0; -r_hci_pack_bytes = 0x400038ac; -r_hci_send_2_controller = 0x400038c4; -r_hci_send_2_host = 0x400038d0; -r_hci_tl_c2h_data_flow_on = 0x400038dc; -r_hci_tl_cmd_hdr_rx_evt_handler = 0x400038e8; -r_hci_tl_cmd_pld_rx_evt_handler = 0x400038f4; -r_hci_tl_get_pkt = 0x40003900; -r_hci_tl_hci_pkt_handler = 0x4000390c; -r_hci_tl_hci_tx_done_evt_handler = 0x40003918; -r_hci_tl_inc_nb_h2c_cmd_pkts = 0x40003924; -r_hci_tl_save_pkt = 0x40003930; -r_hci_tl_send = 0x4000393c; -r_hci_tx_done = 0x40003948; -r_hci_tx_start = 0x40003954; -r_hci_tx_trigger = 0x40003960; -r_isValidSecretKey_256 = 0x4000396c; -r_ke_check_malloc = 0x40003978; -r_ke_event_callback_set = 0x40003984; -r_ke_event_clear = 0x40003990; -r_ke_event_flush = 0x4000399c; -r_ke_event_get = 0x400039a8; -r_ke_event_get_all = 0x400039b4; -r_ke_event_init = 0x400039c0; -r_ke_event_schedule = 0x400039cc; -r_ke_event_set = 0x400039d8; -r_ke_flush = 0x400039e4; -r_ke_free = 0x400039f0; -r_ke_handler_search = 0x400039fc; -r_ke_init = 0x40003a08; -r_ke_is_free = 0x40003a14; -r_ke_malloc = 0x40003a20; -r_ke_mem_init = 0x40003a2c; -r_ke_mem_is_empty = 0x40003a38; -r_ke_mem_is_in_heap = 0x40003a44; -r_ke_msg_alloc = 0x40003a50; -r_ke_msg_dest_id_get = 0x40003a5c; -r_ke_msg_discard = 0x40003a68; -r_ke_msg_forward = 0x40003a74; -r_ke_msg_forward_new_id = 0x40003a80; -r_ke_msg_free = 0x40003a8c; -r_ke_msg_in_queue = 0x40003a98; -r_ke_msg_save = 0x40003aa4; -r_ke_msg_send = 0x40003ab0; -r_ke_msg_send_basic = 0x40003abc; -r_ke_msg_src_id_get = 0x40003ac8; -r_ke_queue_extract = 0x40003ad4; -r_ke_queue_insert = 0x40003ae0; -r_ke_sleep_check = 0x40003aec; -r_ke_state_get = 0x40003af8; -r_ke_state_set = 0x40003b04; -r_ke_task_check = 0x40003b10; -r_ke_task_create = 0x40003b1c; -r_ke_task_delete = 0x40003b28; -r_ke_task_handler_get = 0x40003b34; -r_ke_task_init = 0x40003b40; -r_ke_task_msg_flush = 0x40003b4c; -r_ke_task_saved_update = 0x40003b58; -r_ke_time = 0x40003b70; -r_ke_time_cmp = 0x40003b7c; -r_ke_time_past = 0x40003b88; -r_ke_timer_active = 0x40003b94; -r_ke_timer_adjust_all = 0x40003ba0; -r_ke_timer_clear = 0x40003bac; -r_ke_timer_init = 0x40003bb8; -r_ke_timer_schedule = 0x40003bc4; -r_ke_timer_set = 0x40003bd0; -r_led_init = 0x40003bdc; -r_led_set_all = 0x40003be8; -r_llc_aes_res_cb = 0x40003bf4; -r_llc_ch_map_up_proc_err_cb = 0x40003c00; -r_llc_cleanup = 0x40003c0c; -r_llc_cmd_cmp_send = 0x40003c18; -r_llc_cmd_stat_send = 0x40003c24; -r_llc_con_move_cbk = 0x40003c30; -r_llc_con_plan_set_update = 0x40003c3c; -r_llc_con_upd_param_in_range = 0x40003c48; -r_llc_disconnect = 0x40003c54; -r_llc_disconnect_end = 0x40003c60; -r_llc_disconnect_proc_continue = 0x40003c6c; -r_llc_disconnect_proc_err_cb = 0x40003c78; -r_llc_dl_chg_check = 0x40003c84; -r_llc_dle_proc_err_cb = 0x40003c90; -r_llc_feats_exch_proc_err_cb = 0x40003c9c; -r_llc_hci_cmd_handler_tab_p_get = 0x40003ca8; -r_llc_hci_con_param_req_evt_send = 0x40003cc0; -r_llc_hci_con_upd_info_send = 0x40003ccc; -r_llc_hci_disconnected_dis = 0x40003cd8; -r_llc_hci_dl_upd_info_send = 0x40003ce4; -r_llc_hci_enc_evt_send = 0x40003cf0; -r_llc_hci_feats_info_send = 0x40003cfc; -r_llc_hci_le_phy_upd_cmp_evt_send = 0x40003d08; -r_llc_hci_ltk_request_evt_send = 0x40003d14; -r_llc_hci_nb_cmp_pkts_evt_send = 0x40003d20; -r_llc_hci_version_info_send = 0x40003d2c; -r_llc_init_term_proc = 0x40003d38; -r_llc_iv_skd_rand_gen = 0x40003d44; -r_llc_le_ping_proc_continue = 0x40003d50; -r_llc_le_ping_proc_err_cb = 0x40003d5c; -/* r_llc_le_ping_restart = 0x40003d68; */ -r_llc_le_ping_set = 0x40003d74; -r_llc_ll_pause_enc_rsp_ack_handler = 0x40003d80; -r_llc_ll_reject_ind_ack_handler = 0x40003d8c; -r_llc_ll_reject_ind_pdu_send = 0x40003d98; -r_llc_ll_start_enc_rsp_ack_handler = 0x40003da4; -r_llc_ll_terminate_ind_ack = 0x40003db0; -r_llc_ll_unknown_ind_handler = 0x40003dbc; -r_llc_llcp_send = 0x40003dc8; -r_llc_llcp_state_set = 0x40003dd4; -r_llc_llcp_trans_timer_set = 0x40003de0; -r_llc_llcp_tx_check = 0x40003dec; -/* r_llc_loc_ch_map_proc_continue = 0x40003df8; */ -r_llc_loc_con_upd_proc_err_cb = 0x40003e10; -r_llc_loc_dl_upd_proc_continue = 0x40003e1c; -r_llc_loc_encrypt_proc_continue = 0x40003e28; -r_llc_loc_encrypt_proc_err_cb = 0x40003e34; -r_llc_loc_feats_exch_proc_continue = 0x40003e40; -r_llc_loc_phy_upd_proc_err_cb = 0x40003e58; -r_llc_msg_handler_tab_p_get = 0x40003e64; -r_llc_pref_param_compute = 0x40003e70; -r_llc_proc_collision_check = 0x40003e7c; -r_llc_proc_err_ind = 0x40003e88; -r_llc_proc_get = 0x40003e94; -r_llc_proc_id_get = 0x40003ea0; -r_llc_proc_reg = 0x40003eac; -r_llc_proc_state_get = 0x40003eb8; -r_llc_proc_state_set = 0x40003ec4; -r_llc_proc_timer_pause_set = 0x40003ed0; -r_llc_proc_timer_set = 0x40003edc; -r_llc_proc_unreg = 0x40003ee8; -r_llc_rem_ch_map_proc_continue = 0x40003ef4; -r_llc_rem_con_upd_proc_err_cb = 0x40003f0c; -r_llc_rem_dl_upd_proc = 0x40003f18; -r_llc_rem_encrypt_proc_continue = 0x40003f24; -r_llc_rem_encrypt_proc_err_cb = 0x40003f30; -r_llc_rem_phy_upd_proc_continue = 0x40003f3c; -r_llc_rem_phy_upd_proc_err_cb = 0x40003f48; -r_llc_role_get = 0x40003f54; -r_llc_sk_gen = 0x40003f60; -r_llc_start = 0x40003f6c; -r_llc_stop = 0x40003f78; -r_llc_ver_exch_loc_proc_continue = 0x40003f84; -r_llc_ver_proc_err_cb = 0x40003f90; -r_llcp_pdu_handler_tab_p_get = 0x40003f9c; -r_lld_aa_gen = 0x40003fa8; -r_lld_adv_adv_data_set = 0x40003fb4; -r_lld_adv_adv_data_update = 0x40003fc0; -r_lld_adv_aux_ch_idx_set = 0x40003fcc; -r_lld_adv_aux_evt_canceled_cbk = 0x40003fd8; -r_lld_adv_aux_evt_start_cbk = 0x40003fe4; -r_lld_adv_coex_check_ext_adv_synced = 0x40003ff0; -r_lld_adv_coex_env_reset = 0x40003ffc; -r_lld_adv_duration_update = 0x40004008; -r_lld_adv_dynamic_pti_process = 0x40004014; -r_lld_adv_end = 0x40004020; -r_lld_adv_evt_canceled_cbk = 0x4000402c; -r_lld_adv_evt_start_cbk = 0x40004038; -r_lld_adv_ext_chain_construct = 0x40004044; -r_lld_adv_ext_pkt_prepare = 0x40004050; -r_lld_adv_frm_cbk = 0x4000405c; -r_lld_adv_frm_isr = 0x40004068; -r_lld_adv_frm_skip_isr = 0x40004074; -r_lld_adv_init = 0x40004080; -r_lld_adv_pkt_rx = 0x4000408c; -r_lld_adv_pkt_rx_connect_ind = 0x40004098; -r_lld_adv_pkt_rx_send_scan_req_evt = 0x400040a4; -r_lld_adv_rand_addr_update = 0x400040b0; -r_lld_adv_restart = 0x400040bc; -r_lld_adv_scan_rsp_data_set = 0x400040c8; -r_lld_adv_scan_rsp_data_update = 0x400040d4; -r_lld_adv_set_tx_power = 0x400040e0; -r_lld_adv_start = 0x400040ec; -r_lld_adv_stop = 0x400040f8; -r_lld_adv_sync_info_set = 0x40004104; -r_lld_adv_sync_info_update = 0x40004110; -r_lld_calc_aux_rx = 0x4000411c; -r_lld_cca_alloc = 0x40004128; -r_lld_cca_data_reset = 0x40004134; -r_lld_cca_free = 0x40004140; -r_lld_ch_assess_data_get = 0x4000414c; -r_lld_ch_idx_get = 0x40004158; -r_lld_ch_map_set = 0x40004164; -r_lld_channel_assess = 0x40004170; -r_lld_con_activity_act_offset_compute = 0x4000417c; -r_lld_con_activity_offset_compute = 0x40004188; -r_lld_con_ch_map_update = 0x40004194; -r_lld_con_cleanup = 0x400041a0; -r_lld_con_current_tx_power_get = 0x400041ac; -r_lld_con_data_flow_set = 0x400041b8; -r_lld_con_data_len_update = 0x400041c4; -r_lld_con_data_tx = 0x400041d0; -r_lld_con_enc_key_load = 0x400041dc; -r_lld_con_event_counter_get = 0x400041e8; -r_lld_con_evt_canceled_cbk = 0x400041f4; -r_lld_con_evt_duration_min_get = 0x40004200; -r_lld_con_evt_max_eff_time_cal = 0x4000420c; -r_lld_con_evt_sd_evt_time_get = 0x40004218; -r_lld_con_evt_start_cbk = 0x40004224; -r_lld_con_evt_time_update = 0x40004230; -r_lld_con_free_all_tx_buf = 0x4000423c; -r_lld_con_frm_cbk = 0x40004248; -r_lld_con_frm_isr = 0x40004254; -r_lld_con_frm_skip_isr = 0x40004260; -r_lld_con_init = 0x4000426c; -r_lld_con_llcp_tx = 0x40004278; -r_lld_con_max_lat_calc = 0x40004284; -r_lld_con_offset_get = 0x40004290; -r_lld_con_param_update = 0x4000429c; -r_lld_con_phys_update = 0x400042a8; -r_lld_con_pref_slave_evt_dur_set = 0x400042b4; -r_lld_con_pref_slave_latency_set = 0x400042c0; -r_lld_con_rssi_get = 0x400042cc; -r_lld_con_rx = 0x400042d8; -/* r_lld_con_rx_channel_assess = 0x400042e4; */ -r_lld_con_rx_enc = 0x400042f0; -r_lld_con_rx_isr = 0x400042fc; -r_lld_con_rx_link_info_check = 0x40004308; -r_lld_con_rx_llcp_check = 0x40004314; -r_lld_con_rx_sync_time_update = 0x40004320; -r_lld_con_set_tx_power = 0x40004338; -r_lld_con_start = 0x40004344; -r_lld_con_tx = 0x4000435c; -r_lld_con_tx_enc = 0x40004368; -r_lld_con_tx_isr = 0x40004374; -r_lld_con_tx_len_update = 0x40004380; -r_lld_con_tx_len_update_for_intv = 0x4000438c; -r_lld_con_tx_len_update_for_rate = 0x40004398; -r_lld_con_tx_prog = 0x400043a4; -r_lld_conn_dynamic_pti_process = 0x400043b0; -r_lld_continue_scan_rx_isr_end_process = 0x400043bc; -r_lld_ext_scan_dynamic_pti_process = 0x400043c8; -r_lld_hw_cca_end_isr = 0x400043d4; -r_lld_hw_cca_evt_handler = 0x400043e0; -r_lld_hw_cca_isr = 0x400043ec; -r_lld_init_cal_anchor_point = 0x400043f8; -r_lld_init_compute_winoffset = 0x40004404; -r_lld_init_connect_req_pack = 0x40004410; -r_lld_init_end = 0x4000441c; -r_lld_init_evt_canceled_cbk = 0x40004428; -r_lld_init_evt_start_cbk = 0x40004434; -r_lld_init_frm_cbk = 0x40004440; -r_lld_init_frm_eof_isr = 0x4000444c; -r_lld_init_frm_skip_isr = 0x40004458; -r_lld_init_init = 0x40004464; -r_lld_init_process_pkt_rx = 0x40004470; -r_lld_init_process_pkt_rx_adv_ext_ind = 0x4000447c; -r_lld_init_process_pkt_rx_adv_ind_or_direct_ind = 0x40004488; -r_lld_init_process_pkt_rx_aux_connect_rsp = 0x40004494; -r_lld_init_process_pkt_tx = 0x400044a0; -r_lld_init_process_pkt_tx_cal_con_timestamp = 0x400044ac; -r_lld_init_sched = 0x400044b8; -r_lld_init_set_tx_power = 0x400044c4; -r_lld_init_start = 0x400044d0; -r_lld_init_stop = 0x400044dc; -r_lld_instant_proc_end = 0x400044e8; -r_lld_per_adv_ch_map_update = 0x40004500; -r_lld_per_adv_chain_construct = 0x4000450c; -r_lld_per_adv_cleanup = 0x40004518; -r_lld_per_adv_coex_env_reset = 0x40004524; -r_lld_per_adv_data_set = 0x40004530; -r_lld_per_adv_data_update = 0x4000453c; -r_lld_per_adv_dynamic_pti_process = 0x40004548; -r_lld_per_adv_evt_canceled_cbk = 0x40004554; -r_lld_per_adv_evt_start_cbk = 0x40004560; -r_lld_per_adv_ext_pkt_prepare = 0x4000456c; -r_lld_per_adv_frm_cbk = 0x40004578; -r_lld_per_adv_frm_isr = 0x40004584; -r_lld_per_adv_frm_skip_isr = 0x40004590; -r_lld_per_adv_init = 0x4000459c; -r_lld_per_adv_init_info_get = 0x400045a8; -r_lld_per_adv_list_add = 0x400045b4; -r_lld_per_adv_list_rem = 0x400045c0; -r_lld_per_adv_set_tx_power = 0x400045d8; -r_lld_per_adv_start = 0x400045e4; -r_lld_per_adv_stop = 0x400045f0; -r_lld_per_adv_sync_info_get = 0x400045fc; -r_lld_process_cca_data = 0x40004608; -r_lld_ral_search = 0x40004614; -r_lld_read_clock = 0x40004620; -r_lld_res_list_add = 0x4000462c; -r_lld_res_list_is_empty = 0x40004644; -r_lld_res_list_local_rpa_get = 0x40004650; -r_lld_res_list_peer_rpa_get = 0x4000465c; -r_lld_res_list_peer_update = 0x40004668; -/* r_lld_res_list_priv_mode_update = 0x40004674; */ -r_lld_reset_reg = 0x4000468c; -r_lld_rpa_renew = 0x40004698; -r_lld_rpa_renew_evt_canceled_cbk = 0x400046a4; -r_lld_rpa_renew_evt_start_cbk = 0x400046b0; -r_lld_rpa_renew_instant_cbk = 0x400046bc; -r_lld_rxdesc_check = 0x400046c8; -r_lld_rxdesc_free = 0x400046d4; -r_lld_scan_create_sync = 0x400046e0; -r_lld_scan_create_sync_cancel = 0x400046ec; -r_lld_scan_end = 0x400046f8; -r_lld_scan_evt_canceled_cbk = 0x40004704; -r_lld_scan_evt_start_cbk = 0x40004710; -r_lld_scan_frm_cbk = 0x4000471c; -r_lld_scan_frm_eof_isr = 0x40004728; -r_lld_scan_frm_rx_isr = 0x40004734; -r_lld_scan_frm_skip_isr = 0x40004740; -r_lld_scan_init = 0x4000474c; -r_lld_scan_params_update = 0x40004758; -r_lld_scan_process_pkt_rx_aux_adv_ind = 0x4000477c; -r_lld_scan_process_pkt_rx_aux_chain_ind = 0x40004788; -r_lld_scan_process_pkt_rx_aux_scan_rsp = 0x40004794; -r_lld_scan_process_pkt_rx_ext_adv = 0x400047a0; -r_lld_scan_process_pkt_rx_ext_adv_ind = 0x400047ac; -r_lld_scan_process_pkt_rx_legacy_adv = 0x400047b8; -r_lld_scan_restart = 0x400047c4; -r_lld_scan_sched = 0x400047d0; -r_lld_scan_set_tx_power = 0x400047dc; -r_lld_scan_start = 0x400047e8; -r_lld_scan_stop = 0x400047f4; -r_lld_scan_sync_accept = 0x40004800; -r_lld_scan_sync_info_unpack = 0x4000480c; -r_lld_scan_trunc_ind = 0x40004818; -r_lld_sw_cca_evt_handler = 0x40004824; -r_lld_sw_cca_isr = 0x40004830; -r_lld_sync_ch_map_update = 0x4000483c; -r_lld_sync_cleanup = 0x40004848; -r_lld_sync_evt_canceled_cbk = 0x40004854; -r_lld_sync_evt_start_cbk = 0x40004860; -r_lld_sync_frm_cbk = 0x4000486c; -r_lld_sync_frm_eof_isr = 0x40004878; -r_lld_sync_frm_rx_isr = 0x40004884; -r_lld_sync_frm_skip_isr = 0x40004890; -r_lld_sync_init = 0x4000489c; -r_lld_sync_process_pkt_rx = 0x400048a8; -r_lld_sync_process_pkt_rx_aux_sync_ind = 0x400048b4; -r_lld_sync_process_pkt_rx_pkt_check = 0x400048c0; -r_lld_sync_scan_dynamic_pti_process = 0x400048cc; -r_lld_sync_sched = 0x400048d8; -r_lld_sync_start = 0x400048e4; -r_lld_sync_stop = 0x400048f0; -r_lld_sync_trunc_ind = 0x400048fc; -r_lld_test_cleanup = 0x40004908; -r_lld_test_evt_canceled_cbk = 0x40004914; -r_lld_test_evt_start_cbk = 0x40004920; -r_lld_test_freq2chnl = 0x4000492c; -r_lld_test_frm_cbk = 0x40004938; -r_lld_test_frm_isr = 0x40004944; -r_lld_test_init = 0x40004950; -r_lld_test_rx_isr = 0x4000495c; -r_lld_test_set_tx_power = 0x40004968; -r_lld_test_start = 0x40004974; -/* r_lld_test_stop = 0x40004980;*/ -r_lld_update_rxbuf = 0x4000498c; -r_lld_update_rxbuf_isr = 0x40004998; -r_lld_white_list_add = 0x400049a4; -r_lld_white_list_rem = 0x400049b0; -r_llm_activity_free_get = 0x400049bc; -r_llm_activity_free_set = 0x400049c8; -r_llm_activity_syncing_get = 0x400049d4; -r_llm_adv_con_len_check = 0x400049e0; -r_llm_adv_hdl_to_id = 0x400049ec; -r_llm_adv_rep_flow_control_check = 0x400049f8; -r_llm_adv_rep_flow_control_update = 0x40004a04; -r_llm_adv_reports_list_check = 0x40004a10; -r_llm_adv_set_all_release = 0x40004a1c; -r_llm_adv_set_dft_params = 0x40004a28; -r_llm_adv_set_release = 0x40004a34; -r_llm_aes_res_cb = 0x40004a40; -r_llm_ble_update_adv_flow_control = 0x40004a4c; -r_llm_ch_map_update = 0x40004a58; -r_llm_cmd_cmp_send = 0x40004a64; -r_llm_cmd_stat_send = 0x40004a70; -r_llm_dev_list_empty_entry = 0x40004a7c; -r_llm_dev_list_search = 0x40004a88; -r_llm_env_adv_dup_filt_deinit = 0x40004a94; -r_llm_env_adv_dup_filt_init = 0x40004aa0; -r_llm_init_ble_adv_report_flow_contol = 0x40004aac; -r_llm_is_dev_connected = 0x40004ab8; -r_llm_is_dev_synced = 0x40004ac4; -r_llm_is_non_con_act_ongoing_check = 0x40004ad0; -r_llm_is_wl_accessible = 0x40004adc; -r_llm_le_evt_mask_check = 0x40004ae8; -r_llm_link_disc = 0x40004b00; -r_llm_master_ch_map_get = 0x40004b0c; -r_llm_msg_handler_tab_p_get = 0x40004b18; -r_llm_no_activity = 0x40004b24; -r_llm_per_adv_slot_dur = 0x40004b30; -r_llm_plan_elt_get = 0x40004b3c; -r_llm_rx_path_comp_get = 0x40004b48; -r_llm_scan_start = 0x40004b54; -r_llm_scan_sync_acad_attach = 0x40004b60; -r_llm_scan_sync_acad_detach = 0x40004b6c; -r_llm_send_adv_lost_event_to_host = 0x40004b78; -r_llm_tx_path_comp_get = 0x40004b84; -r_misc_deinit = 0x40004b90; -r_misc_free_em_buf_in_isr = 0x40004b9c; -r_misc_init = 0x40004ba8; -r_misc_msg_handler_tab_p_get = 0x40004bb4; -r_notEqual256 = 0x40004bc0; -r_phy_upd_proc_start = 0x40004bcc; -r_platform_reset = 0x40004bd8; -r_rf_em_init = 0x40004bf0; -r_rf_force_agc_enable = 0x40004bfc; -r_rf_reg_rd = 0x40004c08; -r_rf_reg_wr = 0x40004c14; -r_rf_reset = 0x40004c20; -r_rf_rssi_convert = 0x40004c2c; -r_rf_rw_v9_le_disable = 0x40004c38; -r_rf_rw_v9_le_enable = 0x40004c44; -r_rf_sleep = 0x40004c50; -r_rf_util_cs_fmt_convert = 0x40004c74; -r_rw_crypto_aes_ccm = 0x40004c80; -r_rw_crypto_aes_encrypt = 0x40004c8c; -r_rw_crypto_aes_init = 0x40004c98; -r_rw_crypto_aes_k1 = 0x40004ca4; -r_rw_crypto_aes_k2 = 0x40004cb0; -r_rw_crypto_aes_k3 = 0x40004cbc; -r_rw_crypto_aes_k4 = 0x40004cc8; -r_rw_crypto_aes_rand = 0x40004cd4; -r_rw_crypto_aes_result_handler = 0x40004ce0; -r_rw_crypto_aes_s1 = 0x40004cec; -r_rw_cryto_aes_cmac = 0x40004cf8; -r_rw_v9_init_em_radio_table = 0x40004d04; -r_rwble_sleep_enter = 0x40004d1c; -r_rwble_sleep_wakeup_end = 0x40004d28; -/* r_rwbtdm_isr_wrapper = 0x40004d34; */ -r_rwip_active_check = 0x40004d40; -r_rwip_aes_encrypt = 0x40004d4c; -/* r_rwip_assert = 0x40004d58; */ -r_rwip_crypt_evt_handler = 0x40004d64; -r_rwip_crypt_isr_handler = 0x40004d70; -r_rwip_eif_get = 0x40004d7c; -r_rwip_half_slot_2_lpcycles = 0x40004d88; -r_rwip_hus_2_lpcycles = 0x40004d94; -r_rwip_isr = 0x40004da0; -r_rwip_lpcycles_2_hus = 0x40004dac; -r_rwip_prevent_sleep_clear = 0x40004db8; -r_rwip_prevent_sleep_set = 0x40004dc4; -r_rwip_schedule = 0x40004dd0; -r_rwip_sleep = 0x40004ddc; -r_rwip_sw_int_handler = 0x40004de8; -r_rwip_sw_int_req = 0x40004df4; -r_rwip_time_get = 0x40004e00; -r_rwip_timer_10ms_handler = 0x40004e0c; -r_rwip_timer_10ms_set = 0x40004e18; -r_rwip_timer_hs_handler = 0x40004e24; -r_rwip_timer_hs_set = 0x40004e30; -r_rwip_timer_hus_handler = 0x40004e3c; -r_rwip_timer_hus_set = 0x40004e48; -r_rwip_wakeup = 0x40004e54; -/* r_rwip_wakeup_end = 0x40004e60; */ -r_rwip_wlcoex_set = 0x40004e6c; -r_sch_alarm_clear = 0x40004e78; -r_sch_alarm_init = 0x40004e84; -r_sch_alarm_prog = 0x40004e90; -r_sch_alarm_set = 0x40004e9c; -r_sch_alarm_timer_isr = 0x40004ea8; -r_sch_arb_conflict_check = 0x40004eb4; -r_sch_arb_elt_cancel = 0x40004ec0; -r_sch_arb_init = 0x40004ed8; -r_sch_arb_insert = 0x40004ee4; -r_sch_arb_prog_timer = 0x40004ef0; -r_sch_arb_remove = 0x40004efc; -r_sch_arb_sw_isr = 0x40004f08; -r_sch_plan_chk = 0x40004f14; -r_sch_plan_clock_wrap_offset_update = 0x40004f20; -r_sch_plan_init = 0x40004f2c; -r_sch_plan_interval_req = 0x40004f38; -r_sch_plan_offset_max_calc = 0x40004f44; -r_sch_plan_offset_req = 0x40004f50; -r_sch_plan_position_range_compute = 0x40004f5c; -r_sch_plan_rem = 0x40004f68; -r_sch_plan_req = 0x40004f74; -r_sch_prog_init = 0x40004f98; -r_sch_prog_push = 0x40004fa4; -r_sch_prog_rx_isr = 0x40004fb0; -r_sch_prog_skip_isr = 0x40004fbc; -r_sch_prog_tx_isr = 0x40004fc8; -r_sch_slice_bg_add = 0x40004fd4; -r_sch_slice_bg_remove = 0x40004fe0; -r_sch_slice_compute = 0x40004fec; -r_sch_slice_fg_add = 0x40004ff8; -r_sch_slice_fg_remove = 0x40005004; -r_sch_slice_init = 0x40005010; -r_sch_slice_per_add = 0x4000501c; -r_sch_slice_per_remove = 0x40005028; -r_sdk_config_get_bt_sleep_enable = 0x40005034; -r_sdk_config_get_hl_derived_opts = 0x40005040; -r_sdk_config_get_opts = 0x4000504c; -r_sdk_config_get_priv_opts = 0x40005058; -r_sdk_config_set_bt_sleep_enable = 0x40005064; -r_sdk_config_set_hl_derived_opts = 0x40005070; -r_sdk_config_set_opts = 0x4000507c; -r_specialModP256 = 0x40005088; -r_unloaded_area_init = 0x40005094; -r_vhci_flow_off = 0x400050a0; -r_vhci_flow_on = 0x400050ac; -r_vhci_notify_host_send_available = 0x400050b8; -r_vhci_send_to_host = 0x400050c4; -r_vnd_hci_command_handler = 0x400050d0; -r_vshci_init = 0x400050dc; -vnd_hci_command_handler_wrapper = 0x400050e8; -r_lld_legacy_adv_dynamic_pti_get = 0x400050f4; -r_lld_legacy_adv_dynamic_pti_process = 0x40005100; -r_lld_ext_adv_dynamic_pti_get = 0x4000510c; -r_lld_ext_adv_dynamic_aux_pti_process = 0x40005118; -r_lld_ext_adv_dynamic_pti_process = 0x40005124; -/* r_lld_adv_ext_pkt_prepare_set = 0x40005130; */ -r_lld_adv_ext_chain_connectable_construct = 0x40005148; -r_lld_adv_pkt_rx_connect_post = 0x40005160; -r_lld_adv_start_init_evt_param = 0x4000516c; -r_lld_adv_start_set_cs = 0x40005178; -/* r_lld_adv_start_update_filter_policy = 0x40005184; */ -r_lld_adv_start_schedule_asap = 0x40005190; -r_lld_con_tx_prog_new_packet_coex = 0x4000519c; -r_lld_per_adv_dynamic_pti_get = 0x400051b4; -r_lld_per_adv_evt_start_chm_upd = 0x400051c0; -r_lld_ext_scan_dynamic_pti_get = 0x400051cc; -r_lld_sync_insert = 0x400051e4; -r_sch_prog_ble_push = 0x400051f0; -r_sch_prog_bt_push = 0x400051fc; -r_lld_init_evt_end_type_set = 0x40005208; -r_lld_init_evt_end_type_get = 0x40005214; -r_lld_adv_direct_adv_use_rpa_addr_state_set = 0x40005220; -r_lld_adv_direct_adv_use_rpa_addr_state_get = 0x4000522c; -r_lld_init_evt_end_type_check_state_set = 0x40005238; -r_lld_init_evt_end_type_check_state_get = 0x40005244; /* Data (.data, .bss, .rodata) */ bt_rf_coex_cfg_p = 0x3fceffa8; bt_rf_coex_hooks_p = 0x3fceffa4; @@ -1738,38 +919,6 @@ rwip_coex_cfg = 0x3ff1eebe; rwip_priority = 0x3ff1eea8; veryBigHexP256 = 0x3ff1ee5c; -/* bluetooth hook funcs */ -r_llc_loc_encrypt_proc_continue_hook = 0x40001c60; -r_llc_loc_phy_upd_proc_continue_hook = 0x40001c64; -r_llc_rem_phy_upd_proc_continue_hook = 0x40001c68; -r_lld_scan_frm_eof_isr_hook = 0x40001c6c; -r_lld_scan_evt_start_cbk_hook = 0x40001c70; -r_lld_scan_process_pkt_rx_ext_adv_hook = 0x40001c78; -r_lld_scan_sched_hook = 0x40001c7c; -r_lld_adv_evt_start_cbk_hook = 0x40001c84; -r_lld_adv_aux_evt_start_cbk_hook = 0x40001c88; -r_lld_adv_frm_isr_hook = 0x40001c8c; -r_lld_adv_start_init_evt_param_hook = 0x40001c90; -r_lld_con_evt_canceled_cbk_hook = 0x40001c94; -r_lld_con_frm_isr_hook = 0x40001c98; -r_lld_con_tx_hook = 0x40001c9c; -r_lld_con_rx_hook = 0x40001ca0; -r_lld_con_evt_start_cbk_hook = 0x40001ca4; -r_lld_con_tx_prog_new_packet_hook = 0x40001cac; -r_lld_init_frm_eof_isr_hook = 0x40001cb0; -r_lld_init_evt_start_cbk_hook = 0x40001cb4; -r_lld_init_sched_hook = 0x40001cbc; -r_lld_init_process_pkt_tx_hook = 0x40001cc0; -r_lld_per_adv_evt_start_cbk_hook = 0x40001cc4; -r_lld_per_adv_frm_isr_hook = 0x40001cc8; -r_lld_per_adv_start_hook = 0x40001ccc; -r_lld_sync_frm_eof_isr_hook = 0x40001cd0; -r_lld_sync_evt_start_cbk_hook = 0x40001cd4; -r_lld_sync_start_hook = 0x40001cd8; -r_lld_sync_process_pkt_rx_pkt_check_hook = 0x40001cdc; -r_sch_arb_insert_hook = 0x40001ce0; -r_sch_plan_offset_req_hook = 0x40001ce4; - /*************************************** Group rom_pp ***************************************/ From a98ff3aea68556656aed330509e279ac00cb3981 Mon Sep 17 00:00:00 2001 From: shenmengjing Date: Thu, 10 Oct 2024 18:57:38 +0800 Subject: [PATCH 35/70] docs: Update CN translation for libs-framework.rst and partition-table.rst --- docs/en/api-guides/partition-tables.rst | 266 ++++++++------- .../libs-frameworks.rst | 1 - docs/zh_CN/api-guides/partition-tables.rst | 314 ++++++++++-------- .../libs-frameworks.rst | 24 +- 4 files changed, 326 insertions(+), 279 deletions(-) diff --git a/docs/en/api-guides/partition-tables.rst b/docs/en/api-guides/partition-tables.rst index 4f95b0fd403..622a9185e0f 100644 --- a/docs/en/api-guides/partition-tables.rst +++ b/docs/en/api-guides/partition-tables.rst @@ -17,55 +17,61 @@ The simplest way to use the partition table is to open the project configuration * "Single factory app, no OTA" * "Factory app, two OTA definitions" -In both cases the factory app is flashed at offset 0x10000. If you execute `idf.py partition-table` then it will print a summary of the partition table. +In both cases the factory app is flashed at offset 0x10000. If you execute ``idf.py partition-table`` then it will print a summary of the partition table. Built-in Partition Tables ------------------------- -Here is the summary printed for the "Single factory app, no OTA" configuration:: +Here is the summary printed for the "Single factory app, no OTA" configuration: - # ESP-IDF Partition Table - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x6000, - phy_init, data, phy, 0xf000, 0x1000, - factory, app, factory, 0x10000, 1M, +.. code-block:: none + + # ESP-IDF Partition Table + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x6000, + phy_init, data, phy, 0xf000, 0x1000, + factory, app, factory, 0x10000, 1M, * At a 0x10000 (64 KB) offset in the flash is the app labelled "factory". The bootloader runs this app by default. * There are also two data regions defined in the partition table for storing NVS library partition and PHY init data. -Here is the summary printed for the "Factory app, two OTA definitions" configuration:: +Here is the summary printed for the "Factory app, two OTA definitions" configuration: + +.. code-block:: none - # ESP-IDF Partition Table - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x4000, - otadata, data, ota, 0xd000, 0x2000, - phy_init, data, phy, 0xf000, 0x1000, - factory, app, factory, 0x10000, 1M, - ota_0, app, ota_0, 0x110000, 1M, - ota_1, app, ota_1, 0x210000, 1M, + # ESP-IDF Partition Table + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x4000, + otadata, data, ota, 0xd000, 0x2000, + phy_init, data, phy, 0xf000, 0x1000, + factory, app, factory, 0x10000, 1M, + ota_0, app, ota_0, 0x110000, 1M, + ota_1, app, ota_1, 0x210000, 1M, * There are now three app partition definitions. The type of the factory app (at 0x10000) and the next two "OTA" apps are all set to "app", but their subtypes are different. * There is also a new "otadata" slot, which holds the data for OTA updates. The bootloader consults this data in order to know which app to execute. If "ota data" is empty, it will execute the factory app. Creating Custom Tables -------------------------- +---------------------- If you choose "Custom partition table CSV" in menuconfig then you can also enter the name of a CSV file (in the project directory) to use for your partition table. The CSV file can describe any number of definitions for the table you need. -The CSV format is the same format as printed in the summaries shown above. However, not all fields are required in the CSV. For example, here is the "input" CSV for the OTA partition table:: +The CSV format is the same format as printed in the summaries shown above. However, not all fields are required in the CSV. For example, here is the "input" CSV for the OTA partition table: + +.. code-block:: none - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x4000 - otadata, data, ota, 0xd000, 0x2000 - phy_init, data, phy, 0xf000, 0x1000 - factory, app, factory, 0x10000, 1M - ota_0, app, ota_0, , 1M - ota_1, app, ota_1, , 1M - nvs_key, data, nvs_keys, , 0x1000 + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x4000 + otadata, data, ota, 0xd000, 0x2000 + phy_init, data, phy, 0xf000, 0x1000 + factory, app, factory, 0x10000, 1M + ota_0, app, ota_0, , 1M + ota_1, app, ota_1, , 1M + nvs_key, data, nvs_keys, , 0x1000 * Whitespace between fields is ignored, and so is any line starting with # (comments). * Each non-comment line in the CSV file is a partition definition. -* The "Offset" field for each partition is empty. The gen_esp32part.py tool fills in each blank offset, starting after the partition table and making sure each partition is aligned correctly. +* The ``Offset`` field for each partition is empty. The ``gen_esp32part.py`` tool fills in each blank offset, starting after the partition table and making sure each partition is aligned correctly. Name Field ~~~~~~~~~~ @@ -77,15 +83,17 @@ Type Field Partition type field can be specified as a name or a number 0-254 (or as hex 0x00-0xFE). Types 0x00-0x3F are reserved for ESP-IDF core functions. -- ``app`` (0x00), -- ``data`` (0x01), -- ``bootloader`` (0x02). By default, this partition is not included in any CSV partition table files because it is not required and does not impact the system's functionality. It is only useful for the bootloader OTA update. Even if this partition is not present in the CSV file, it is still possible to perform the OTA. Please note that if you specify this partition in the CSV file, its address and size must match Kconfigs, -- ``partition_table`` (0x03), +- ``app`` (0x00). +- ``data`` (0x01). +- ``bootloader`` (0x02). By default, this partition is not included in any CSV partition table files because it is not required and does not impact the system's functionality. It is only useful for the bootloader OTA update. Even if this partition is not present in the CSV file, it is still possible to perform the OTA. Please note that if you specify this partition in the CSV file, its address and size must match Kconfigs. +- ``partition_table`` (0x03). - 0x40-0xFE are reserved for **custom partition types**. If your app needs to store data in a format not already supported by ESP-IDF, then use a value from this range. See :cpp:type:`esp_partition_type_t` for the enum definitions for ``app`` and ``data`` partitions. -If writing in C++ then specifying a application-defined partition type requires casting an integer to :cpp:type:`esp_partition_type_t` in order to use it with the :ref:`partition API`. For example:: +If writing in C++ then specifying a application-defined partition type requires casting an integer to :cpp:type:`esp_partition_type_t` in order to use it with the :ref:`partition API`. For example: + +.. code-block:: none static const esp_partition_type_t APP_PARTITION_TYPE_A = (esp_partition_type_t)0x40; @@ -93,6 +101,7 @@ The bootloader ignores any partition types other than ``app`` (0x00) and ``data` SubType ~~~~~~~ + {IDF_TARGET_ESP_PHY_REF:default = ":ref:`CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION`", esp32p4, esp32c5, esp32c61="NOT UPDATED YET"} The 8-bit SubType field is specific to a given partition type. ESP-IDF currently only specifies the meaning of the subtype field for ``app`` and ``data`` partition types. @@ -101,63 +110,63 @@ See enum :cpp:type:`esp_partition_subtype_t` for the full list of subtypes defin * When type is ``app``, the SubType field can be specified as ``factory`` (0x00), ``ota_0`` (0x10) ... ``ota_15`` (0x1F) or ``test`` (0x20). - - ``factory`` (0x00) is the default app partition. The bootloader will execute the factory app unless there it sees a partition of type data/ota, in which case it reads this partition to determine which OTA image to boot. + - ``factory`` (0x00) is the default app partition. The bootloader will execute the factory app unless there it sees a partition of type data/ota, in which case it reads this partition to determine which OTA image to boot. - - OTA never updates the factory partition. - - If you want to conserve flash usage in an OTA project, you can remove the factory partition and use ``ota_0`` instead. + - OTA never updates the factory partition. + - If you want to conserve flash usage in an OTA project, you can remove the factory partition and use ``ota_0`` instead. - - ``ota_0`` (0x10) ... ``ota_15`` (0x1F) are the OTA app slots. When :doc:`OTA <../api-reference/system/ota>` is in use, the OTA data partition configures which app slot the bootloader should boot. When using OTA, an application should have at least two OTA application slots (``ota_0`` & ``ota_1``). Refer to the :doc:`OTA documentation <../api-reference/system/ota>` for more details. - - ``test`` (0x20) is a reserved subtype for factory test procedures. It will be used as the fallback boot partition if no other valid app partition is found. It is also possible to configure the bootloader to read a GPIO input during each boot, and boot this partition if the GPIO is held low, see :ref:`bootloader_boot_from_test_firmware`. + - ``ota_0`` (0x10) ... ``ota_15`` (0x1F) are the OTA app slots. When :doc:`OTA <../api-reference/system/ota>` is in use, the OTA data partition configures which app slot the bootloader should boot. When using OTA, an application should have at least two OTA application slots (``ota_0`` & ``ota_1``). Refer to the :doc:`OTA documentation <../api-reference/system/ota>` for more details. + - ``test`` (0x20) is a reserved subtype for factory test procedures. It will be used as the fallback boot partition if no other valid app partition is found. It is also possible to configure the bootloader to read a GPIO input during each boot, and boot this partition if the GPIO is held low, see :ref:`bootloader_boot_from_test_firmware`. * When type is ``bootloader``, the SubType field can be specified as: - - ``primary`` (0x00). It is the so-called 2nd stage bootloader, which is placed at the {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. - - ``ota`` (0x01). It is a temporary bootloader partition used by the bootloader OTA update functionality for downloading a new image. + - ``primary`` (0x00). It is the so-called second stage bootloader, which is placed at the {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. + - ``ota`` (0x01). It is a temporary bootloader partition used by the bootloader OTA update functionality for downloading a new image. * When type is ``partition_table``, the SubType field can be specified as: - - ``primary`` (0x00). It is the primary partition table, which is placed at the :ref:`CONFIG_PARTITION_TABLE_OFFSET` address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. - - ``ota`` (0x01). It is a temporary partition table partition used by the partition table OTA update functionality for downloading a new image. + - ``primary`` (0x00). It is the primary partition table, which is placed at the :ref:`CONFIG_PARTITION_TABLE_OFFSET` address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. + - ``ota`` (0x01). It is a temporary partition table partition used by the partition table OTA update functionality for downloading a new image. * When type is ``data``, the subtype field can be specified as ``ota`` (0x00), ``phy`` (0x01), ``nvs`` (0x02), nvs_keys (0x04), or a range of other component-specific subtypes (see :cpp:type:`subtype enum `). - - ``ota`` (0) is the :ref:`OTA data partition ` which stores information about the currently selected OTA app slot. This partition should be 0x2000 bytes in size. Refer to the :ref:`OTA documentation ` for more details. - - ``phy`` (1) is for storing PHY initialisation data. This allows PHY to be configured per-device, instead of in firmware. + - ``ota`` (0) is the :ref:`OTA data partition ` which stores information about the currently selected OTA app slot. This partition should be 0x2000 bytes in size. Refer to the :ref:`OTA documentation ` for more details. + - ``phy`` (1) is for storing PHY initialisation data. This allows PHY to be configured per-device, instead of in firmware. - - In the default configuration, the phy partition is not used and PHY initialisation data is compiled into the app itself. As such, this partition can be removed from the partition table to save space. - - To load PHY data from this partition, open the project configuration menu (``idf.py menuconfig``) and enable {IDF_TARGET_ESP_PHY_REF} option. You will also need to flash your devices with phy init data as the esp-idf build system does not do this automatically. - - ``nvs`` (2) is for the :doc:`Non-Volatile Storage (NVS) API <../api-reference/storage/nvs_flash>`. + - In the default configuration, the phy partition is not used and PHY initialisation data is compiled into the app itself. As such, this partition can be removed from the partition table to save space. + - To load PHY data from this partition, open the project configuration menu (``idf.py menuconfig``) and enable {IDF_TARGET_ESP_PHY_REF} option. You will also need to flash your devices with phy init data as the esp-idf build system does not do this automatically. + - ``nvs`` (2) is for the :doc:`Non-Volatile Storage (NVS) API <../api-reference/storage/nvs_flash>`. - - NVS is used to store per-device PHY calibration data (different to initialisation data). + - NVS is used to store per-device PHY calibration data (different to initialisation data). - .. only:: SOC_WIFI_SUPPORTED + .. only:: SOC_WIFI_SUPPORTED - - NVS is used to store Wi-Fi data if the :doc:`esp_wifi_set_storage(WIFI_STORAGE_FLASH) <../api-reference/network/esp_wifi>` initialization function is used. + - NVS is used to store Wi-Fi data if the :doc:`esp_wifi_set_storage(WIFI_STORAGE_FLASH) <../api-reference/network/esp_wifi>` initialization function is used. - - The NVS API can also be used for other application data. - - It is strongly recommended that you include an NVS partition of at least 0x3000 bytes in your project. - - If using NVS API to store a lot of data, increase the NVS partition size from the default 0x6000 bytes. - - ``nvs_keys`` (4) is for the NVS key partition. See :doc:`Non-Volatile Storage (NVS) API <../api-reference/storage/nvs_flash>` for more details. + - The NVS API can also be used for other application data. + - It is strongly recommended that you include an NVS partition of at least 0x3000 bytes in your project. + - If using NVS API to store a lot of data, increase the NVS partition size from the default 0x6000 bytes. + - ``nvs_keys`` (4) is for the NVS key partition. See :doc:`Non-Volatile Storage (NVS) API <../api-reference/storage/nvs_flash>` for more details. - - It is used to store NVS encryption keys when `NVS Encryption` feature is enabled. - - The size of this partition should be 4096 bytes (minimum partition size). + - It is used to store NVS encryption keys when `NVS Encryption` feature is enabled. + - The size of this partition should be 4096 bytes (minimum partition size). - - There are other predefined data subtypes for data storage supported by ESP-IDF. These include: + - There are other predefined data subtypes for data storage supported by ESP-IDF. These include: - - ``coredump`` (0x03) is for storing core dumps while using a custom partition table CSV file. See :doc:`/api-guides/core_dump` for more details. - - ``efuse`` (0x05) is for emulating eFuse bits using :ref:`virtual-efuses`. - - ``undefined`` (0x06) is implicitly used for data partitions with unspecified (empty) subtype, but it is possible to explicitly mark them as undefined as well. - - ``fat`` (0x81) is for :doc:`/api-reference/storage/fatfs`. - - ``spiffs`` (0x82) is for :doc:`/api-reference/storage/spiffs`. - - ``littlefs`` (0x83) is for `LittleFS filesystem `_. See :example:`storage/littlefs` example for more details. + - ``coredump`` (0x03) is for storing core dumps while using a custom partition table CSV file. See :doc:`/api-guides/core_dump` for more details. + - ``efuse`` (0x05) is for emulating eFuse bits using :ref:`virtual-efuses`. + - ``undefined`` (0x06) is implicitly used for data partitions with unspecified (empty) subtype, but it is possible to explicitly mark them as undefined as well. + - ``fat`` (0x81) is for :doc:`/api-reference/storage/fatfs`. + - ``spiffs`` (0x82) is for :doc:`/api-reference/storage/spiffs`. + - ``littlefs`` (0x83) is for `LittleFS filesystem `_. See :example:`storage/littlefs` example for more details. .. Comment: ``esphttpd`` (0x80) was not added to the list because there is no docs section for it and it is not clear whether user should use it explicitly. - Other subtypes of ``data`` type are reserved for future ESP-IDF uses. + Other subtypes of ``data`` type are reserved for future ESP-IDF uses. * If the partition type is any application-defined value (range 0x40-0xFE), then ``subtype`` field can be any value chosen by the application (range 0x00-0xFE). - Note that when writing in C++, an application-defined subtype value requires casting to type :cpp:type:`esp_partition_subtype_t` in order to use it with the :ref:`partition API `. + Note that when writing in C++, an application-defined subtype value requires casting to type :cpp:type:`esp_partition_subtype_t` in order to use it with the :ref:`partition API `. Extra Partition SubTypes ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -185,17 +194,17 @@ Flags Two flags are currently supported, ``encrypted`` and ``readonly``: - - If ``encrypted`` flag is set, the partition will be encrypted if :doc:`/security/flash-encryption` is enabled. + - If ``encrypted`` flag is set, the partition will be encrypted if :doc:`/security/flash-encryption` is enabled. - .. note:: + .. note:: - ``app`` type partitions will always be encrypted, regardless of whether this flag is set or not. + ``app`` type partitions will always be encrypted, regardless of whether this flag is set or not. - - If ``readonly`` flag is set, the partition will be read-only. This flag is only supported for ``data`` type partitions except ``ota``` and ``coredump``` subtypes. This flag can help to protect against accidental writes to a partition that contains critical device-specific configuration data, e.g., factory data partition. + - If ``readonly`` flag is set, the partition will be read-only. This flag is only supported for ``data`` type partitions except ``ota``` and ``coredump``` subtypes. This flag can help to protect against accidental writes to a partition that contains critical device-specific configuration data, e.g., factory data partition. - .. note:: + .. note:: - Using C file I/O API to open a file (``fopen```) in any write mode (``w``, ``w+``, ``a``, ``a+``, ``r+``) will fail and return ``NULL``. Using ``open`` with any other flag than ``O_RDONLY`` will fail and return ``-1`` while ``errno`` global variable will be set to ``EROFS``. This is also true for any other POSIX syscall function performing write or erase operations. Opening a handle in read-write mode for NVS on a read-only partition will fail and return :c:macro:`ESP_ERR_NOT_ALLOWED` error code. Using a lower level API like ``esp_partition``, ``spi_flash``, etc. to write to a read-only partition will result in :c:macro:`ESP_ERR_NOT_ALLOWED` error code. + Using C file I/O API to open a file (``fopen```) in any write mode (``w``, ``w+``, ``a``, ``a+``, ``r+``) will fail and return ``NULL``. Using ``open`` with any other flag than ``O_RDONLY`` will fail and return ``-1`` while ``errno`` global variable will be set to ``EROFS``. This is also true for any other POSIX syscall function performing write or erase operations. Opening a handle in read-write mode for NVS on a read-only partition will fail and return :c:macro:`ESP_ERR_NOT_ALLOWED` error code. Using a lower level API like ``esp_partition``, ``spi_flash``, etc. to write to a read-only partition will result in :c:macro:`ESP_ERR_NOT_ALLOWED` error code. You can specify multiple flags by separating them with a colon. For example, ``encrypted:readonly``. @@ -206,17 +215,23 @@ The partition table which is flashed to the {IDF_TARGET_NAME} is in a binary for If you configure the partition table CSV name in the project configuration (``idf.py menuconfig``) and then build the project or run ``idf.py partition-table``, this conversion is done as part of the build process. -To convert CSV to Binary manually:: +To convert CSV to Binary manually: + +.. code-block:: none + + python gen_esp32part.py input_partitions.csv binary_partitions.bin - python gen_esp32part.py input_partitions.csv binary_partitions.bin +To convert binary format back to CSV manually: -To convert binary format back to CSV manually:: +.. code-block:: none - python gen_esp32part.py binary_partitions.bin input_partitions.csv + python gen_esp32part.py binary_partitions.bin input_partitions.csv -To display the contents of a binary partition table on stdout (this is how the summaries displayed when running ``idf.py partition-table`` are generated:: +To display the contents of a binary partition table on stdout (this is how the summaries displayed when running ``idf.py partition-table`` are generated: - python gen_esp32part.py binary_partitions.bin +.. code-block:: none + + python gen_esp32part.py binary_partitions.bin Partition Size Checks --------------------- @@ -230,7 +245,7 @@ Currently these checks are performed for the following binaries: .. note:: - Although the build process will fail if the size check returns an error, the binary files are still generated and can be flashed (although they may not work if they are too large for the available space.) + Although the build process will fail if the size check returns an error, the binary files are still generated and can be flashed (although they may not work if they are too large for the available space.) MD5 Checksum ~~~~~~~~~~~~ @@ -256,7 +271,7 @@ A manual flashing command is also printed as part of ``idf.py partition-table`` .. note:: - Note that updating the partition table does not erase data that may have been stored according to the old partition table. You can use ``idf.py erase-flash`` (or ``esptool.py erase_flash``) to erase the entire flash contents. + Note that updating the partition table does not erase data that may have been stored according to the old partition table. You can use ``idf.py erase-flash`` (or ``esptool.py erase_flash``) to erase the entire flash contents. Partition Tool (``parttool.py``) @@ -264,10 +279,10 @@ Partition Tool (``parttool.py``) The component `partition_table` provides a tool :component_file:`parttool.py ` for performing partition-related operations on a target device. The following operations can be performed using the tool: - - reading a partition and saving the contents to a file (read_partition) - - writing the contents of a file to a partition (write_partition) - - erasing a partition (erase_partition) - - retrieving info such as name, offset, size and flag ("encrypted") of a given partition (get_partition_info) + - reading a partition and saving the contents to a file (read_partition) + - writing the contents of a file to a partition (write_partition) + - erasing a partition (erase_partition) + - retrieving info such as name, offset, size and flag ("encrypted") of a given partition (get_partition_info) The tool can either be imported and used from another Python script or invoked from shell script for users wanting to perform operation programmatically. This is facilitated by the tool's Python API and command-line interface, respectively. @@ -278,38 +293,38 @@ Before anything else, make sure that the `parttool` module is imported. .. code-block:: python - import sys - import os + import sys + import os - idf_path = os.environ["IDF_PATH"] # get value of IDF_PATH from environment - parttool_dir = os.path.join(idf_path, "components", "partition_table") # parttool.py lives in $IDF_PATH/components/partition_table + idf_path = os.environ["IDF_PATH"] # get value of IDF_PATH from environment + parttool_dir = os.path.join(idf_path, "components", "partition_table") # parttool.py lives in $IDF_PATH/components/partition_table - sys.path.append(parttool_dir) # this enables Python to find parttool module - from parttool import * # import all names inside parttool module + sys.path.append(parttool_dir) # this enables Python to find parttool module + from parttool import * # import all names inside parttool module The starting point for using the tool's Python API to do is create a `ParttoolTarget` object: .. code-block:: python - # Create a parttool.py target device connected on serial port /dev/ttyUSB1 - target = ParttoolTarget("/dev/ttyUSB1") + # Create a parttool.py target device connected on serial port /dev/ttyUSB1 + target = ParttoolTarget("/dev/ttyUSB1") The created object can now be used to perform operations on the target device: .. code-block:: python - # Erase partition with name 'storage' + # Erase partition with name 'storage' target.erase_partition(PartitionName("storage")) - # Read partition with type 'data' and subtype 'spiffs' and save to file 'spiffs.bin' - target.read_partition(PartitionType("data", "spiffs"), "spiffs.bin") + # Read partition with type 'data' and subtype 'spiffs' and save to file 'spiffs.bin' + target.read_partition(PartitionType("data", "spiffs"), "spiffs.bin") - # Write to partition 'factory' the contents of a file named 'factory.bin' - target.write_partition(PartitionName("factory"), "factory.bin") + # Write to partition 'factory' the contents of a file named 'factory.bin' + target.write_partition(PartitionName("factory"), "factory.bin") - # Print the size of default boot partition - storage = target.get_partition_info(PARTITION_BOOT_DEFAULT) - print(storage.size) + # Print the size of default boot partition + storage = target.get_partition_info(PARTITION_BOOT_DEFAULT) + print(storage.size) The partition to operate on is specified using `PartitionName` or `PartitionType` or PARTITION_BOOT_DEFAULT. As the name implies, these can be used to refer to partitions of a particular name, type-subtype combination, or the default boot partition. @@ -322,53 +337,54 @@ The command-line interface of `parttool.py` has the following structure: .. code-block:: bash - parttool.py [command-args] [subcommand] [subcommand-args] + parttool.py [command-args] [subcommand] [subcommand-args] - - command-args - These are arguments that are needed for executing the main command (parttool.py), mostly pertaining to the target device - - subcommand - This is the operation to be performed - - subcommand-args - These are arguments that are specific to the chosen operation + - command-args - These are arguments that are needed for executing the main command (parttool.py), mostly pertaining to the target device + - subcommand - This is the operation to be performed + - subcommand-args - These are arguments that are specific to the chosen operation .. code-block:: bash - # Erase partition with name 'storage' - parttool.py --port "/dev/ttyUSB1" erase_partition --partition-name=storage + # Erase partition with name 'storage' + parttool.py --port "/dev/ttyUSB1" erase_partition --partition-name=storage - # Read partition with type 'data' and subtype 'spiffs' and save to file 'spiffs.bin' - parttool.py --port "/dev/ttyUSB1" read_partition --partition-type=data --partition-subtype=spiffs --output "spiffs.bin" + # Read partition with type 'data' and subtype 'spiffs' and save to file 'spiffs.bin' + parttool.py --port "/dev/ttyUSB1" read_partition --partition-type=data --partition-subtype=spiffs --output "spiffs.bin" - # Write to partition 'factory' the contents of a file named 'factory.bin' - parttool.py --port "/dev/ttyUSB1" write_partition --partition-name=factory --input "factory.bin" + # Write to partition 'factory' the contents of a file named 'factory.bin' + parttool.py --port "/dev/ttyUSB1" write_partition --partition-name=factory --input "factory.bin" - # Print the size of default boot partition - parttool.py --port "/dev/ttyUSB1" get_partition_info --partition-boot-default --info size + # Print the size of default boot partition + parttool.py --port "/dev/ttyUSB1" get_partition_info --partition-boot-default --info size .. note:: - If the device has already enabled ``Flash Encryption`` or ``Secure Boot``, attempting to use commands that modify the flash content, such as ``erase_partition`` or ``write_partition``, will result in an error. This error is generated by the erase command of ``esptool.py``, which is called first before writing. This error is done as a safety measure to prevent bricking your device. - :: + If the device has already enabled ``Flash Encryption`` or ``Secure Boot``, attempting to use commands that modify the flash content, such as ``erase_partition`` or ``write_partition``, will result in an error. This error is generated by the erase command of ``esptool.py``, which is called first before writing. This error is done as a safety measure to prevent bricking your device. - A fatal error occurred: Active security features detected, erasing flash is disabled as a safety measure. Use --force to override, please use with caution, otherwise it may brick your device! + .. code-block:: none - To work around this, you need use the ``--force`` flag with ``esptool.py``. Specifically, the ``parttool.py`` provides the ``--esptool-erase-args`` argument that help to pass this flag to ``esptool.py``. + A fatal error occurred: Active security features detected, erasing flash is disabled as a safety measure. Use --force to override, please use with caution, otherwise it may brick your device! - .. code-block:: bash + To work around this, you need use the ``--force`` flag with ``esptool.py``. Specifically, the ``parttool.py`` provides the ``--esptool-erase-args`` argument that help to pass this flag to ``esptool.py``. - # Erase partition with name 'storage' - # If Flash Encryption or Secure Boot are enabled then add "--esptool-erase-args=force" - parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force erase_partition --partition-name=storage + .. code-block:: bash - # Write to partition 'factory' the contents of a file named 'factory.bin' - # If Flash Encryption or Secure Boot are enabled then add "--esptool-erase-args=force" - parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force write_partition --partition-name=factory --input "factory.bin" + # Erase partition with name 'storage' + # If Flash Encryption or Secure Boot are enabled then add "--esptool-erase-args=force" + parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force erase_partition --partition-name=storage + + # Write to partition 'factory' the contents of a file named 'factory.bin' + # If Flash Encryption or Secure Boot are enabled then add "--esptool-erase-args=force" + parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force write_partition --partition-name=factory --input "factory.bin" More information can be obtained by specifying `--help` as argument: .. code-block:: bash - # Display possible subcommands and show main command argument descriptions - parttool.py --help + # Display possible subcommands and show main command argument descriptions + parttool.py --help - # Show descriptions for specific subcommand arguments - parttool.py [subcommand] --help + # Show descriptions for specific subcommand arguments + parttool.py [subcommand] --help .. _secure boot: security/secure-boot-v1.rst diff --git a/docs/en/libraries-and-frameworks/libs-frameworks.rst b/docs/en/libraries-and-frameworks/libs-frameworks.rst index 0793fd7726f..5c18c5b1364 100644 --- a/docs/en/libraries-and-frameworks/libs-frameworks.rst +++ b/docs/en/libraries-and-frameworks/libs-frameworks.rst @@ -107,4 +107,3 @@ ESP-IDF-CXX ----------- `ESP-IDF-CXX `_ contains C++ wrappers for part of ESP-IDF. The focuses are on ease of use, safety, automatic resource management. They also move error checking from runtime to compile time to prevent running failure. There are C++ classes for ESP-Timer, I2C, SPI, GPIO and other peripherals or features of ESP-IDF. ESP-IDF-CXX is available as a component from `ESP Component Registry `__. Please check the project's `README.md `_ for more information. - diff --git a/docs/zh_CN/api-guides/partition-tables.rst b/docs/zh_CN/api-guides/partition-tables.rst index 2b47491940a..735cfbe1acd 100644 --- a/docs/zh_CN/api-guides/partition-tables.rst +++ b/docs/zh_CN/api-guides/partition-tables.rst @@ -8,64 +8,70 @@ 每片 {IDF_TARGET_NAME} 的 flash 可以包含多个应用程序,以及多种不同类型的数据(例如校准数据、文件系统数据、参数存储数据等)。因此,我们在 flash 的 :ref:`默认偏移地址 ` 0x8000 处烧写一张分区表。 -分区表的长度为 0xC00 字节,最多可以保存 95 条分区表条目。MD5 校验和附加在分区表之后,用于在运行时验证分区表的完整性。分区表占据了整个 flash 扇区,大小为 0x1000 (4 KB)。因此,它后面的任何分区至少需要位于 (:ref:`默认偏移地址 `) + 0x1000 处。 +分区表的长度为 0xC00 字节,最多可以保存 95 条分区表条目。MD5 校验和附加在分区表之后,用于在运行时验证分区表的完整性。分区表占据了整个 flash 扇区,大小为 0x1000 (4 KB)。因此,它后面的任何分区至少需要位于(:ref:`默认偏移地址 `) + 0x1000 处。 分区表中的每个条目都包括以下几个部分:Name(标签)、Type(app、data 等)、SubType 以及在 flash 中的偏移量(分区的加载地址)。 -在使用分区表时,最简单的方法就是打开项目配置菜单(``idf.py menuconfig``),并在 :ref:`CONFIG_PARTITION_TABLE_TYPE` 下选择一个预定义的分区表: +在使用分区表时,最简单的方法就是打开项目配置菜单 (``idf.py menuconfig``),并在 :ref:`CONFIG_PARTITION_TABLE_TYPE` 下选择一个预定义的分区表: -- "Single factory app, no OTA" -- "Factory app, two OTA definitions" +* "Single factory app, no OTA" +* "Factory app, two OTA definitions" 在以上两种选项中,出厂应用程序均将被烧录至 flash 的 0x10000 偏移地址处。这时,运行 ``idf.py partition-table``,即可以打印当前使用分区表的信息摘要。 内置分区表 ------------- +---------- + +以下是 "Single factory app, no OTA" 选项的分区表信息摘要: -以下是 "Single factory app, no OTA" 选项的分区表信息摘要:: +.. code-block:: none - # ESP-IDF Partition Table - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x6000, - phy_init, data, phy, 0xf000, 0x1000, - factory, app, factory, 0x10000, 1M, + # ESP-IDF Partition Table + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x6000, + phy_init, data, phy, 0xf000, 0x1000, + factory, app, factory, 0x10000, 1M, -- flash 的 0x10000 (64 KB) 偏移地址处存放一个标记为 "factory" 的二进制应用程序。引导加载程序默认加载这个应用程序。 +- flash 的 0x10000 (64 KB) 偏移地址处存放一个标记为 "factory" 的二进制应用程序,引导加载程序默认加载这个应用程序。 - 分区表中还定义了两个数据区域,分别用于存储 NVS 库专用分区和 PHY 初始化数据。 -以下是 "Factory app, two OTA definitions" 选项的分区表信息摘要:: +以下是 "Factory app, two OTA definitions" 选项的分区表信息摘要: - # ESP-IDF Partition Table - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x4000, - otadata, data, ota, 0xd000, 0x2000, - phy_init, data, phy, 0xf000, 0x1000, - factory, app, factory, 0x10000, 1M, - ota_0, app, ota_0, 0x110000, 1M, - ota_1, app, ota_1, 0x210000, 1M, +.. code-block:: none -- 分区表中定义了三个应用程序分区,这三个分区的类型都被设置为 “app”,但具体 app 类型不同。其中,位于 0x10000 偏移地址处的为出厂应用程序 (factory),其余两个为 OTA 应用程序(ota_0,ota_1)。 -- 新增了一个名为 “otadata” 的数据分区,用于保存 OTA 升级时需要的数据。引导加载程序会查询该分区的数据,以判断该从哪个 OTA 应用程序分区加载程序。如果 “otadata” 分区为空,则会执行出厂程序。 + # ESP-IDF Partition Table + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x4000, + otadata, data, ota, 0xd000, 0x2000, + phy_init, data, phy, 0xf000, 0x1000, + factory, app, factory, 0x10000, 1M, + ota_0, app, ota_0, 0x110000, 1M, + ota_1, app, ota_1, 0x210000, 1M, + +* 分区表中定义了三个应用程序分区,这三个分区的类型都被设置为 “app”,但具体 app 类型不同。其中,位于 0x10000 偏移地址处的为出厂应用程序 (factory),其余两个为 OTA 应用程序 (ota_0, ota_1)。 +* 新增了一个名为 "otadata" 的数据分区,用于保存 OTA 升级时需要的数据。引导加载程序会查询该分区的数据,以判断该从哪个 OTA 应用程序分区加载程序。如果 "otadata" 分区为空,则会执行出厂程序。 创建自定义分区表 ---------------- -如果在 ``menuconfig`` 中选择了 “Custom partition table CSV”,则还需要输入该分区表的 CSV 文件在项目中的路径。CSV 文件可以根据需要,描述任意数量的分区信息。 +如果在 ``menuconfig`` 中选择了 "Custom partition table CSV",则还需要输入该分区表的 CSV 文件在项目中的路径。CSV 文件可以根据需要,描述任意数量的分区信息。 + +CSV 文件的格式与上面摘要中打印的格式相同,但是在 CSV 文件中并非所有字段都是必需的。例如下面是一个自定义的 OTA 分区表的 CSV 文件: -CSV 文件的格式与上面摘要中打印的格式相同,但是在 CSV 文件中并非所有字段都是必需的。例如下面是一个自定义的 OTA 分区表的 CSV 文件:: +.. code-block:: none - # Name, Type, SubType, Offset, Size, Flags - nvs, data, nvs, 0x9000, 0x4000 - otadata, data, ota, 0xd000, 0x2000 - phy_init, data, phy, 0xf000, 0x1000 - factory, app, factory, 0x10000, 1M - ota_0, app, ota_0, , 1M - ota_1, app, ota_1, , 1M - nvs_key, data, nvs_keys, , 0x1000 + # Name, Type, SubType, Offset, Size, Flags + nvs, data, nvs, 0x9000, 0x4000 + otadata, data, ota, 0xd000, 0x2000 + phy_init, data, phy, 0xf000, 0x1000 + factory, app, factory, 0x10000, 1M + ota_0, app, ota_0, , 1M + ota_1, app, ota_1, , 1M + nvs_key, data, nvs_keys, , 0x1000 -- 字段之间的空格会被忽略,任何以 ``#`` 开头的行(注释)也会被忽略。 -- CSV 文件中的每个非注释行均为一个分区定义。 -- 每个分区的 ``Offset`` 字段可以为空,``gen_esp32part.py`` 工具会从分区表位置的后面开始自动计算并填充该分区的偏移地址,同时确保每个分区的偏移地址正确对齐。 +* 字段之间的空格会被忽略,任何以 ``#`` 开头的行(注释)也会被忽略。 +* CSV 文件中的每个非注释行均为一个分区定义。 +* 每个分区的 ``Offset`` 字段可以为空,``gen_esp32part.py`` 工具会从分区表位置的后面开始自动计算并填充该分区的偏移地址,同时确保每个分区的偏移地址正确对齐。 Name 字段 ~~~~~~~~~ @@ -75,13 +81,19 @@ Name 字段可以是任何有意义的名称,但不能超过 16 个字节, Type 字段 ~~~~~~~~~ -Type 字段可以指定为 app (0x00) 或者 data (0x01),也可以直接使用数字 0-254(或者十六进制 0x00-0xFE)。注意,0x00-0x3F 不得使用(预留给 esp-idf 的核心功能)。 +Type 字段可以指定为名称或数字 0~254(或者十六进制 0x00-0xFE)。注意,不得使用预留给 ESP-IDF 核心功能的 0x00-0x3F。 -如果你的应用程序需要以 ESP-IDF 尚未支持的格式存储数据,请在 0x40-0xFE 内添加一个自定义分区类型。 +- ``app`` (0x00)。 +- ``data`` (0x01)。 +- ``bootloader`` (0x02)。该分区为可选项且不会影响系统功能,因此默认情况下,该分区不会出现在任何 CSV 分区表文件中,仅在引导加载程序 OTA 更新时有用。即使 CSV 文件中没有该分区,仍然可以执行 OTA。请注意,如果在 CSV 文件中指定了该分区,其地址和大小必须与 Kconfig 设置相匹配。 +- ``partition_table`` (0x03)。 +- 0x40-0xFE 预留给 **自定义分区类型**。如果你的应用程序需要以 ESP-IDF 尚未支持的格式存储数据,请在 0x40-0xFE 内添加一个自定义分区类型。 -参考 :cpp:type:`esp_partition_type_t` 关于 ``app`` 和 ``data`` 分区的枚举定义。 +关于 ``app`` 和 ``data`` 分区的枚举定义,请参考 :cpp:type:`esp_partition_type_t`。 -如果用 C++ 编写,那么指定一个应用程序定义的分区类型,需要在 :cpp:type:`esp_partition_type_t` 中使用整数,从而与 :ref:`分区 API` 一起使用。例如:: +如果用 C++ 编写,那么指定一个应用程序定义的分区类型,需要在 :cpp:type:`esp_partition_type_t` 中使用整数,从而与 :ref:`分区 API` 一起使用。例如: + +.. code-block:: none static const esp_partition_type_t APP_PARTITION_TYPE_A = (esp_partition_type_t)0x40; @@ -89,61 +101,72 @@ Type 字段可以指定为 app (0x00) 或者 data (0x01),也可以直接使用 SubType 字段 ~~~~~~~~~~~~ -{IDF_TARGET_ESP_PHY_REF:default = ":ref:`CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION`", esp32p4, esp32c5, esp32c61 = "NOT UPDATED YET"} -SubType 字段长度为 8 bit,内容与具体分区 Type 有关。目前,esp-idf 仅仅规定了 “app” 和 “data” 两种分区类型的子类型含义。 +{IDF_TARGET_ESP_PHY_REF:default = ":ref:`CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION`", esp32p4, esp32c5, esp32c61 = "尚未更新"} + +SubType 字段长度为 8 bit,内容与具体分区 Type 有关。目前,ESP-IDF 仅仅规定了 ``app`` 和 ``data`` 两种分区类型的子类型含义。 参考 :cpp:type:`esp_partition_subtype_t`,以了解 ESP-IDF 定义的全部子类型列表,包括: * 当 Type 定义为 ``app`` 时,SubType 字段可以指定为 ``factory`` (0x00)、 ``ota_0`` (0x10) … ``ota_15`` (0x1F) 或者 ``test`` (0x20)。 - - ``factory`` (0x00) 是默认的 app 分区。引导加载程序默认加载该应用程序。但如果存在类型为 data/ota 的分区,则引导加载程序将加载 data/ota 分区中的数据,进而判断启动哪个 OTA 镜像文件。 + - ``factory`` (0x00) 是默认的 app 分区。引导加载程序将默认加载该应用程序。但如果存在类型为 data/ota 的分区,则引导加载程序将加载 data/ota 分区中的数据,进而判断启动哪个 OTA 镜像文件。 + + - OTA 升级永远都不会更新 factory 分区中的内容。 + - 如果你希望在 OTA 项目中预留更多 flash,可以删除 factory 分区,转而使用 ota_0 分区。 + + - ``ota_0`` (0x10) … ``ota_15`` (0x1F) 为 OTA 应用程序分区,引导加载程序将根据 OTA 数据分区中的数据来决定加载哪个 OTA 应用程序分区中的程序。在使用 OTA 功能时,应用程序应至少拥有 2 个 OTA 应用程序分区(``ota_0`` 和 ``ota_1``)。更多详细信息,请参考 :doc:`OTA 文档 `。 + - ``test`` (0x20) 为预留的子类型,用于工厂测试流程。如果没有其他有效 app 分区,test 将作为备选启动分区使用。也可以配置引导加载程序在每次启动时读取 GPIO,如果 GPIO 被拉低则启动该分区。详细信息请查阅 :ref:`bootloader_boot_from_test_firmware`。 + +* 当 Type 定义为 ``bootloader`` 时,可以将 SubType 字段指定为: - - OTA 升级永远都不会更新 factory 分区中的内容。 - - 如果你希望在 OTA 项目中预留更多 flash,可以删除 factory 分区,转而使用 ota_0 分区。 + - ``primary`` (0x00),即二级引导加载程序,放置在 flash 的 {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} 地址处。目前 ``gen_esp32part.py`` 不支持在 CSV 文件中包含该分区。 + - ``ota`` (0x01),是一个临时的引导加载程序分区,在 OTA 更新期间可用于下载新的引导加载程序镜像。 - - ota_0 (0x10) … ota_15 (0x1F) 为 OTA 应用程序分区,引导加载程序将根据 OTA 数据分区中的数据来决定加载哪个 OTA 应用程序分区中的程序。在使用 OTA 功能时,应用程序应至少拥有 2 个 OTA 应用程序分区(``ota_0`` 和 ``ota_1``)。更多详细信息,请参考 :doc:`OTA 文档 ` 。 - - ``test`` (0x20) 为预留的子类型,用于工厂测试流程。如果没有其他有效 app 分区,test 将作为备选启动分区使用。也可以配置引导加载程序在每次启动时读取 GPIO,如果 GPIO 被拉低则启动该分区。详细信息请查阅 :ref:`bootloader_boot_from_test_firmware`。 +* 当 Type 定义为 ``partition_table`` 时,可以将 SubType 字段指定为: + + - ``primary`` (0x00)。这是主分区表,放置在 flash 的 :ref:`CONFIG_PARTITION_TABLE_OFFSET` 地址处。目前 ``gen_esp32part.py`` 不支持在 CSV 文件中包含该分区。 + - ``ota`` (0x01)。这是一个临时的分区表分区,在 OTA 更新期间可用于下载新的分区表镜像。 * 当 Type 定义为 ``data`` 时,SubType 字段可以指定为 ``ota`` (0x00)、``phy`` (0x01)、``nvs`` (0x02)、``nvs_keys`` (0x04) 或者其他组件特定的子类型(请参考 :cpp:type:`子类型枚举 `). - - ``ota`` (0) 即 :ref:`OTA 数据分区 ` ,用于存储当前所选的 OTA 应用程序的信息。这个分区的大小需要设定为 0x2000。更多详细信息,请参考 :doc:`OTA 文档 <../api-reference/system/ota>` 。 - - ``phy`` (1) 分区用于存放 PHY 初始化数据,从而保证可以为每个设备单独配置 PHY,而非必须采用固件中的统一 PHY 初始化数据。 + - ``ota`` (0) 即 :ref:`OTA 数据分区 ` ,用于存储当前所选的 OTA 应用程序的信息。这个分区的大小需要设定为 0x2000。更多详细信息,请参考 :doc:`OTA 文档 <../api-reference/system/ota>` 。 + - ``phy`` (1) 分区用于存放 PHY 初始化数据,从而保证可以为每个设备单独配置 PHY,而非必须采用固件中的统一 PHY 初始化数据。 - - 默认配置下,phy 分区并不启用,而是直接将 phy 初始化数据编译至应用程序中,从而节省分区表空间(直接将此分区删掉)。 - - 如果需要从此分区加载 phy 初始化数据,请打开项目配置菜单(``idf.py menuconfig``),并且使能 {IDF_TARGET_ESP_PHY_REF} 选项。此时,还需要手动将 phy 初始化数据烧至设备 flash(esp-idf 编译系统并不会自动完成该操作)。 - - ``nvs`` (2) 是专门给 :doc:`非易失性存储 (NVS) API <../api-reference/storage/nvs_flash>` 使用的分区。 + - 默认配置下,phy 分区并不启用,而是直接将 phy 初始化数据编译至应用程序中,从而节省分区表空间(直接将此分区删掉)。 + - 如果需要从此分区加载 phy 初始化数据,请打开项目配置菜单(``idf.py menuconfig``),并且使能 {IDF_TARGET_ESP_PHY_REF} 选项。此时,还需要手动将 phy 初始化数据烧至设备 flash(esp-idf 编译系统并不会自动完成该操作)。 + - ``nvs`` (2) 是专门给 :doc:`非易失性存储 (NVS) API <../api-reference/storage/nvs_flash>` 使用的分区。 - - 用于存储每台设备的 PHY 校准数据(注意,并不是 PHY 初始化数据)。 + - 用于存储每台设备的 PHY 校准数据(注意,并不是 PHY 初始化数据)。 - .. only:: SOC_WIFI_SUPPORTED + .. only:: SOC_WIFI_SUPPORTED - - 用于存储 Wi-Fi 数据(如果使用了 :doc:`esp_wifi_set_storage(WIFI_STORAGE_FLASH) <../api-reference/network/esp_wifi>` 初始化函数)。 + - 用于存储 Wi-Fi 数据(如果使用了 :doc:`esp_wifi_set_storage(WIFI_STORAGE_FLASH) <../api-reference/network/esp_wifi>` 初始化函数)。 - - NVS API 还可以用于其他应用程序数据。 - - 强烈建议为 NVS 分区分配至少 0x3000 字节空间。 - - 如果使用 NVS API 存储大量数据,请增加 NVS 分区的大小(默认是 0x6000 字节)。 - - ``nvs_keys`` (4) 是 NVS 秘钥分区。详细信息,请参考 :doc:`非易失性存储 (NVS) API <../api-reference/storage/nvs_flash>` 文档。 + - NVS API 还可以用于其他应用程序数据。 + - 强烈建议为 NVS 分区分配至少 0x3000 字节空间。 + - 如果使用 NVS API 存储大量数据,请增加 NVS 分区的大小(默认是 0x6000 字节)。 + - ``nvs_keys`` (4) 是 NVS 秘钥分区。详细信息,请参考 :doc:`非易失性存储 (NVS) API <../api-reference/storage/nvs_flash>` 文档。 - - 用于存储加密密钥(如果启用了 `NVS 加密` 功能)。 - - 此分区应至少设定为 4096 字节。 + - 用于存储加密密钥(如果启用了 `NVS 加密` 功能)。 + - 此分区应至少设定为 4096 字节。 - - ESP-IDF 还支持其他用于数据存储的预定义子类型,包括: + - ESP-IDF 还支持其他用于数据存储的预定义子类型,包括: - - ``coredump`` (0x03) 用于在使用自定义分区表 CSV 文件时存储核心转储,详情请参阅 :doc:`/api-guides/core_dump`。 - - ``efuse`` (0x05) 使用 :ref:`虚拟 eFuse ` 模拟 eFuse 位。 - - ``undefined`` (0x06) 隐式用于未指定子类型(即子类型为空)的数据分区,但也可显式将其标记为未定义。 - - ``fat`` (0x81) 用于 :doc:`/api-reference/storage/fatfs`。 - - ``spiffs`` (0x82) 用于 :doc:`/api-reference/storage/spiffs`。 - - ``littlefs`` (0x83) 用于 `LittleFS 文件系统 `_,详情可参阅 :example:`storage/littlefs` 示例。 + - ``coredump`` (0x03) 用于在使用自定义分区表 CSV 文件时存储核心转储,详情请参阅 :doc:`/api-guides/core_dump`。 + - ``efuse`` (0x05) 使用 :ref:`虚拟 eFuse ` 模拟 eFuse 位。 + - ``undefined`` (0x06) 隐式用于未指定子类型(即子类型为空)的数据分区,但也可显式将其标记为未定义。 + - ``fat`` (0x81) 用于 :doc:`/api-reference/storage/fatfs`。 + - ``spiffs`` (0x82) 用于 :doc:`/api-reference/storage/spiffs`。 + - ``littlefs`` (0x83) 用于 `LittleFS 文件系统 `_,详情可参阅 :example:`storage/littlefs` 示例。 .. Comment: ``esphttpd`` (0x80) was not added to the list because there is no docs section for it and it is not clear whether user should use it explicitly. - 其它数据子类型已预留给 ESP-IDF 未来使用。 + 其它数据子类型已预留给 ESP-IDF 未来使用。 * 如果分区类型是由应用程序定义的任意值 (0x40-0xFE),那么 ``subtype`` 字段可以是由应用程序选择的任何值 (0x00-0xFE)。 - 请注意,如果用 C++ 编写,应用程序定义的子类型值需要转换为 :cpp:type:`esp_partition_type_t`,从而与 :ref:`分区 API ` 一起使用。 + 请注意,如果用 C++ 编写,应用程序定义的子类型值需要转换为 :cpp:type:`esp_partition_type_t`,从而与 :ref:`分区 API ` 一起使用。 额外分区 SubType 字段 ~~~~~~~~~~~~~~~~~~~~~~~~ @@ -152,17 +175,17 @@ SubType 字段长度为 8 bit,内容与具体分区 Type 有关。目前,esp .. _partition-offset-and-size: -偏移地址 (Offset) 和 大小 (Size) 字段 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +偏移地址 (Offset) 和大小 (Size) 字段 +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. list:: - - 偏移地址表示 SPI flash 中的分区地址,扇区大小为 0x1000 (4 KB)。因此,偏移地址必须是 4 KB 的倍数。 - - 若 CSV 文件中的分区偏移地址为空,则该分区会接在前一个分区之后;若为首个分区,则将接在分区表之后。 - - ``app`` 分区的偏移地址必须与 0x10000 (64 KB) 对齐。如果偏移字段留空,则 ``gen_esp32part.py`` 工具会自动计算得到一个满足对齐要求的偏移地址。如果 ``app`` 分区的偏移地址没有与 0x10000 (64 KB) 对齐,则该工具会报错。 - - ``app`` 分区的大小必须与 flash 扇区大小对齐。为 ``app`` 分区指定未对齐的大小将返回错误。 - :SOC_SECURE_BOOT_V1: - 若启用了安全启动 V1,则 ``app`` 分区的大小需与 0x10000 (64 KB) 对齐。 - - ``app`` 分区的大小和偏移地址可以采用十进制数或是以 0x 为前缀的十六进制数,且支持 K 或 M 的倍数单位(K 和 M 分别代表 1024 和 1024*1024 字节)。 + - 偏移地址表示 SPI flash 中的分区地址,扇区大小为 0x1000 (4 KB)。因此,偏移地址必须是 4 KB 的倍数。 + - 若 CSV 文件中的分区偏移地址为空,则该分区会接在前一个分区之后;若为首个分区,则将接在分区表之后。 + - ``app`` 分区的偏移地址必须与 0x10000 (64 KB) 对齐。如果偏移字段留空,则 ``gen_esp32part.py`` 工具会自动计算得到一个满足对齐要求的偏移地址。如果 ``app`` 分区的偏移地址没有与 0x10000 (64 KB) 对齐,则该工具会报错。 + - ``app`` 分区的大小必须与 flash 扇区大小对齐。为 ``app`` 分区指定未对齐的大小将返回错误。 + :SOC_SECURE_BOOT_V1: - 若启用了安全启动 V1,则 ``app`` 分区的大小需与 0x10000 (64 KB) 对齐。 + - ``app`` 分区的大小和偏移地址可以采用十进制数或是以 0x 为前缀的十六进制数,且支持 K 或 M 的倍数单位(K 和 M 分别代表 1024 和 1024*1024 字节)。 如果你希望允许分区表中的分区采用任意起始偏移量 (:ref:`CONFIG_PARTITION_TABLE_OFFSET`),请将分区表(CSV 文件)中所有分区的偏移字段都留空。注意,此时,如果你更改了分区表中任意分区的偏移地址,则其他分区的偏移地址也会跟着改变。这种情况下,如果你之前还曾设定某个分区采用固定偏移地址,则可能造成分区表冲突,从而导致报错。 @@ -171,17 +194,17 @@ Flags 字段 目前支持 ``encrypted`` 和 ``readonly`` 标记: - - 如果 Flags 字段设置为 ``encrypted``,且已启用 :doc:`/security/flash-encryption` 功能,则该分区将会被加密。 + - 如果 Flags 字段设置为 ``encrypted``,且已启用 :doc:`/security/flash-encryption` 功能,则该分区将会被加密。 - .. note:: + .. note:: - 无论是否设置 Flags 字段,``app`` 分区都将保持加密。 + 无论是否设置 Flags 字段,``app`` 分区都将保持加密。 - - 如果 Flags 字段设置为 ``readonly``,则该分区为只读分区。``readonly`` 标记仅支持除 ``ota`` 和 ``coredump`` 子类型外的 ``data`` 分区。使用该标记,防止意外写入如出厂数据分区等包含关键设备特定配置数据的分区。 + - 如果 Flags 字段设置为 ``readonly``,则该分区为只读分区。``readonly`` 标记仅支持除 ``ota`` 和 ``coredump`` 子类型外的 ``data`` 分区。使用该标记,防止意外写入如出厂数据分区等包含关键设备特定配置数据的分区。 - .. note:: + .. note:: - 在任何写入模式下 (``w``、``w+``、``a``、``a+``、``r+``),尝试通过 C 文件 I/O API 打开文件 (``fopen```) 的操作都将失败并返回 ``NULL``。除 ``O_RDONLY`` 外,``open`` 与任何标志一同使用都将失败并返回 ``-1``,全局变量 ``errno`` 也将设置为 ``EROFS``。上述情况同样适用于通过其他 POSIX 系统调用函数执行写入或擦除的操作。在只读分区上,以读写模式打开 NVS 的句柄将失败并返回 :c:macro:`ESP_ERR_NOT_ALLOWED` 错误代码,使用 ``esp_partition`` 或 ``spi_flash`` 等较低级别的 API 进行写入操作也将返回 :c:macro:`ESP_ERR_NOT_ALLOWED` 错误代码。 + 在任何写入模式下 (``w``、``w+``、``a``、``a+``、``r+``),尝试通过 C 文件 I/O API 打开文件 (``fopen```) 的操作都将失败并返回 ``NULL``。除 ``O_RDONLY`` 外,``open`` 与任何标志一同使用都将失败并返回 ``-1``,全局变量 ``errno`` 也将设置为 ``EROFS``。上述情况同样适用于通过其他 POSIX 系统调用函数执行写入或擦除的操作。在只读分区上,以读写模式打开 NVS 的句柄将失败并返回 :c:macro:`ESP_ERR_NOT_ALLOWED` 错误代码,使用 ``esp_partition`` 或 ``spi_flash`` 等较低级别的 API 进行写入操作也将返回 :c:macro:`ESP_ERR_NOT_ALLOWED` 错误代码。 可以使用冒号连接不同的标记,来同时指定多个标记,如 ``encrypted:readonly``。 @@ -192,20 +215,26 @@ Flags 字段 如果你在项目配置菜单(``idf.py menuconfig``)中设置了分区表 CSV 文件的名称,然后构建项目或执行 ``idf.py partition-table``。这时,转换将在编译过程中自动完成。 -手动将 CSV 文件转换为二进制文件:: +手动将 CSV 文件转换为二进制文件: + +.. code-block:: none + + python gen_esp32part.py input_partitions.csv binary_partitions.bin - python gen_esp32part.py input_partitions.csv binary_partitions.bin +手动将二进制文件转换为 CSV 文件: -手动将二进制文件转换为 CSV 文件:: +.. code-block:: none - python gen_esp32part.py binary_partitions.bin input_partitions.csv + python gen_esp32part.py binary_partitions.bin input_partitions.csv -在标准输出 (stdout) 上,打印二进制分区表的内容(运行 ``idf.py partition-table`` 时展示的信息摘要也是这样生成的):: +在标准输出 (stdout) 上,打印二进制分区表的内容(运行 ``idf.py partition-table`` 时展示的信息摘要也是这样生成的): - python gen_esp32part.py binary_partitions.bin +.. code-block:: none + + python gen_esp32part.py binary_partitions.bin 分区大小检查 ---------------------- +------------ ESP-IDF 构建系统将自动检查生成的二进制文件大小与可用的分区大小是否匹配,如果二进制文件太大,则会构建失败并报错。 @@ -216,7 +245,7 @@ ESP-IDF 构建系统将自动检查生成的二进制文件大小与可用的分 .. note:: - 即使分区大小检查返回错误并导致构建失败,仍然会生成可以烧录的二进制文件(它们对于可用空间来说过大,因此无法正常工作)。 + 即使分区大小检查返回错误并导致构建失败,仍然会生成可以烧录的二进制文件(它们对于可用空间来说过大,因此无法正常工作)。 MD5 校验和 ~~~~~~~~~~ @@ -225,7 +254,7 @@ MD5 校验和 .. only:: esp32 - 用户可通过 ``gen_esp32part.py`` 的 ``--disable-md5sum`` 选项或者 :ref:`CONFIG_PARTITION_TABLE_MD5` 选项关闭 MD5 校验。对于 :ref:`ESP-IDF v3.1 版本前的引导加载程序 `,因为它不支持 MD5 校验,所以无法正常启动并报错 ``invalid magic number 0xebeb``,此时用户可以使用此选项关闭 MD5 校验。 + 用户可通过 ``gen_esp32part.py`` 的 ``--disable-md5sum`` 选项或者 :ref:`CONFIG_PARTITION_TABLE_MD5` 选项关闭 MD5 校验。对于 :ref:`ESP-IDF v3.1 版本前的引导加载程序 `,因为它不支持 MD5 校验,所以无法正常启动并报错 ``invalid magic number 0xebeb``,此时用户可以使用此选项关闭 MD5 校验。 .. only:: not esp32 @@ -235,67 +264,67 @@ MD5 校验和 烧写分区表 ---------- -- ``idf.py partition-table-flash`` :使用 esptool.py 工具烧写分区表。 -- ``idf.py flash`` :会烧写所有内容,包括分区表。 +* ``idf.py partition-table-flash`` :使用 esptool.py 工具烧写分区表。 +* ``idf.py flash`` :会烧写所有内容,包括分区表。 在执行 ``idf.py partition-table`` 命令时,手动烧写分区表的命令也将打印在终端上。 .. note:: - 分区表的更新并不会擦除根据旧分区表存储的数据。此时,可以使用 ``idf.py erase-flash`` 命令或者 ``esptool.py erase_flash`` 命令来擦除 flash 中的所有内容。 + 分区表的更新并不会擦除根据旧分区表存储的数据。此时,可以使用 ``idf.py erase-flash`` 命令或者 ``esptool.py erase_flash`` 命令来擦除 flash 中的所有内容。 分区工具 (``parttool.py``) ---------------------------- +-------------------------- `partition_table` 组件中有分区工具 :component_file:`parttool.py`,可以在目标设备上完成分区相关操作。该工具有如下用途: - - 读取分区,将内容存储到文件中 (read_partition) - - 将文件中的内容写至分区 (write_partition) - - 擦除分区 (erase_partition) - - 检索特定分区的名称、偏移、大小和 flag(“加密”)标志等信息 (get_partition_info) + - 读取分区,将内容存储到文件中 (read_partition) + - 将文件中的内容写至分区 (write_partition) + - 擦除分区 (erase_partition) + - 检索特定分区的名称、偏移、大小和 flag(“加密”)标志等信息 (get_partition_info) 用户若想通过编程方式完成相关操作,可从另一个 Python 脚本导入并使用分区工具,或者从 Shell 脚本调用分区工具。前者可使用工具的 Python API,后者可使用命令行界面。 Python API -~~~~~~~~~~~ +~~~~~~~~~~ 首先请确保已导入 `parttool` 模块。 .. code-block:: python - import sys - import os + import sys + import os - idf_path = os.environ["IDF_PATH"] # 从环境中获取 IDF_PATH 的值 - parttool_dir = os.path.join(idf_path, "components", "partition_table") # parttool.py 位于 $IDF_PATH/components/partition_table 下 + idf_path = os.environ["IDF_PATH"] # 从环境中获取 IDF_PATH 的值 + parttool_dir = os.path.join(idf_path, "components", "partition_table") # parttool.py 位于 $IDF_PATH/components/partition_table 下 - sys.path.append(parttool_dir) # 使能 Python 寻找 parttool 模块 - from parttool import * # 导入 parttool 模块内的所有名称 + sys.path.append(parttool_dir) # 使能 Python 寻找 parttool 模块 + from parttool import * # 导入 parttool 模块内的所有名称 要使用分区工具的 Python API,第一步是创建 `ParttoolTarget`: .. code-block:: python - # 创建 parttool.py 的目标设备,并将目标设备连接到串行端口 /dev/ttyUSB1 - target = ParttoolTarget("/dev/ttyUSB1") + # 创建 parttool.py 的目标设备,并将目标设备连接到串行端口 /dev/ttyUSB1 + target = ParttoolTarget("/dev/ttyUSB1") 现在,可使用创建的 `ParttoolTarget` 在目标设备上完成操作: .. code-block:: python - # 擦除名为 'storage' 的分区 - target.erase_partition(PartitionName("storage")) + # 擦除名为 'storage' 的分区 + target.erase_partition(PartitionName("storage")) - # 读取类型为 'data'、子类型为 'spiffs' 的分区,保存至文件 'spiffs.bin' - target.read_partition(PartitionType("data", "spiffs"), "spiffs.bin") + # 读取类型为 'data'、子类型为 'spiffs' 的分区,保存至文件 'spiffs.bin' + target.read_partition(PartitionType("data", "spiffs"), "spiffs.bin") - # 将 'factory.bin' 文件的内容写至 'factory' 分区 - target.write_partition(PartitionName("factory"), "factory.bin") + # 将 'factory.bin' 文件的内容写至 'factory' 分区 + target.write_partition(PartitionName("factory"), "factory.bin") - # 打印默认启动分区的大小 - storage = target.get_partition_info(PARTITION_BOOT_DEFAULT) - print(storage.size) + # 打印默认启动分区的大小 + storage = target.get_partition_info(PARTITION_BOOT_DEFAULT) + print(storage.size) 使用 `PartitionName`、`PartitionType` 或 PARTITION_BOOT_DEFAULT 指定要操作的分区。顾名思义,这三个参数可以指向拥有特定名称的分区、特定类型和子类型的分区或默认启动分区。 @@ -308,44 +337,45 @@ Python API .. code-block:: bash - parttool.py [command-args] [subcommand] [subcommand-args] + parttool.py [command-args] [subcommand] [subcommand-args] - - command-args - 执行主命令 (parttool.py) 所需的实际参数,多与目标设备有关 - - subcommand - 要执行的操作 - - subcommand-args - 所选操作的实际参数 + - command-args - 执行主命令 (parttool.py) 所需的实际参数,多与目标设备有关 + - subcommand - 要执行的操作 + - subcommand-args - 所选操作的实际参数 .. code-block:: bash - # 擦除名为 'storage' 的分区 - parttool.py --port "/dev/ttyUSB1" erase_partition --partition-name=storage + # 擦除名为 'storage' 的分区 + parttool.py --port "/dev/ttyUSB1" erase_partition --partition-name=storage - # 读取类型为 'data'、子类型为 'spiffs' 的分区,保存到 'spiffs.bin' 文件 - parttool.py --port "/dev/ttyUSB1" read_partition --partition-type=data --partition-subtype=spiffs --output "spiffs.bin" + # 读取类型为 'data'、子类型为 'spiffs' 的分区,保存到 'spiffs.bin' 文件 + parttool.py --port "/dev/ttyUSB1" read_partition --partition-type=data --partition-subtype=spiffs --output "spiffs.bin" - # 将 'factory.bin' 文件中的内容写入到 'factory' 分区 - parttool.py --port "/dev/ttyUSB1" write_partition --partition-name=factory --input "factory.bin" + # 将 'factory.bin' 文件中的内容写入到 'factory' 分区 + parttool.py --port "/dev/ttyUSB1" write_partition --partition-name=factory --input "factory.bin" - # 打印默认启动分区的大小 - parttool.py --port "/dev/ttyUSB1" get_partition_info --partition-boot-default --info size + # 打印默认启动分区的大小 + parttool.py --port "/dev/ttyUSB1" get_partition_info --partition-boot-default --info size .. note:: - 如果设备启用了 ``Flash Encryption`` 或 ``Secure Boot``,尝试使用修改 flash 内容的命令(如 ``erase_partition`` 或 ``write_partition``)会导致错误。这是因为 ``esptool.py`` 的擦除命令会在写入之前先被调用。这个“错误”实际上是一个用来防止设备变砖的安全措施。 - :: + 如果设备启用了 ``Flash Encryption`` 或 ``Secure Boot``,尝试使用修改 flash 内容的命令(如 ``erase_partition`` 或 ``write_partition``)会导致错误。这是因为 ``esptool.py`` 的擦除命令会在写入之前先被调用。这个“错误”实际上是一个用来防止设备变砖的安全措施。 - A fatal error occurred: Active security features detected, erasing flash is disabled as a safety measure. Use --force to override, please use with caution, otherwise it may brick your device! + .. code-block:: none - 要解决此问题,需在运行 ``esptool.py`` 时使用 ``--force`` 参数。具体而言,``parttool.py`` 提供了 ``--esptool-erase-args`` 参数,用来将 ``--force`` 参数传递给 ``esptool.py``。 + A fatal error occurred: Active security features detected, erasing flash is disabled as a safety measure. Use --force to override, please use with caution, otherwise it may brick your device! - .. code-block:: bash + 要解决此问题,需在运行 ``esptool.py`` 时使用 ``--force`` 参数。具体而言,``parttool.py`` 提供了 ``--esptool-erase-args`` 参数,用来将 ``--force`` 参数传递给 ``esptool.py``。 - # 擦除名为 'storage' 的分区 - # 如果启用了 Flash Encryption 或 Secure Boot,则添加 "--esptool-erase-args=force" - parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force erase_partition --partition-name=storage + .. code-block:: bash + + # 擦除名为 'storage' 的分区 + # 如果启用了 Flash Encryption 或 Secure Boot,则添加 "--esptool-erase-args=force" + parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force erase_partition --partition-name=storage - # 将名为 'factory.bin' 的文件内容写入 'factory' 分区 - # 如果启用了 Flash Encryption 或 Secure Boot,则添加 "--esptool-erase-args=force" - parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force write_partition --partition-name=factory --input "factory.bin" + # 将名为 'factory.bin' 的文件内容写入 'factory' 分区 + # 如果启用了 Flash Encryption 或 Secure Boot,则添加 "--esptool-erase-args=force" + parttool.py --port "/dev/ttyUSB1" --esptool-erase-args=force write_partition --partition-name=factory --input "factory.bin" 更多信息可用 `--help` 指令查看: diff --git a/docs/zh_CN/libraries-and-frameworks/libs-frameworks.rst b/docs/zh_CN/libraries-and-frameworks/libs-frameworks.rst index b2a818aa1c8..9dc2d0492c4 100644 --- a/docs/zh_CN/libraries-and-frameworks/libs-frameworks.rst +++ b/docs/zh_CN/libraries-and-frameworks/libs-frameworks.rst @@ -1,11 +1,11 @@ 其他库和开发框架 -============================= +================ :link_to_translation:`en:[English]` 本文展示了一系列乐鑫官方发布的库和框架。 ESP-ADF -------------------------------------- +------- ESP-ADF 是一个全方位的音频应用程序框架,该框架支持: @@ -20,14 +20,14 @@ ESP-ADF 是一个全方位的音频应用程序框架,该框架支持: 该框架对应的 GitHub 仓库为 `ESP-ADF `_。 ESP-CSI ------------------------------------- +------- ESP-CSI 是一个具有实验性的框架,它利用 Wi-Fi 信道状态信息来检测人体存在。 该框架对应的 GitHub 仓库为 `ESP-CSI `_。 ESP-DSP ------------------------------------- +------- ESP-DSP 提供了针对数字信号处理应用优化的算法,该库支持: @@ -41,7 +41,7 @@ ESP-DSP 提供了针对数字信号处理应用优化的算法,该库支持: 该库对应的 GitHub 仓库为 `ESP-DSP 库 `_。 ESP-WIFI-MESH ------------------------------------------------------- +------------- ESP-WIFI-MESH 基于 ESP-WIFI-MESH 协议搭建,该框架支持: @@ -54,21 +54,21 @@ ESP-WIFI-MESH 基于 ESP-WIFI-MESH 协议搭建,该框架支持: 该框架对应的 GitHub 仓库为 `ESP-MDF `_。 ESP-WHO ------------------------------- +------- ESP-WHO 框架利用 ESP32 及摄像头实现人脸检测及识别。 该框架对应的 GitHub 仓库为 `ESP-WHO `_。 ESP RainMaker ---------------------------------------------- +------------- `ESP RainMaker `_ 提供了一个快速 AIoT 开发的完整解决方案。使用 ESP RainMaker,用户可以创建多种 AIoT 设备,包括固件 AIoT 以及集成了语音助手、手机应用程序和云后端的 AIoT 等。 该解决方案对应的 GitHub 仓库为 `GitHub 上的 ESP RainMaker `_。 ESP-IoT-Solution --------------------------------------------------- +---------------- `ESP-IoT-Solution `_ 涵盖了开发 IoT 系统时常用的设备驱动程序及代码框架。在 ESP-IoT-Solution 中,设备驱动程序和代码框架以独立组件存在,可以轻松地集成到 ESP-IDF 项目中。 @@ -82,7 +82,7 @@ ESP-IoT-Solution 支持: ESP-Protocols ------------------------------------------ +------------- `ESP-Protocols `_ 库包含 ESP-IDF 的协议组件集。ESP-Protocols 中的代码以独立组件存在,可以轻松地集成到 ESP-IDF 项目中。此外,每个组件都可以在 `乐鑫组件注册表 `__ 中找到。 @@ -96,12 +96,14 @@ ESP-Protocols 组件: * `asio `_ 是一个跨平台的 C++ 库,请参阅 ``_。该库基于现代 C++ 提供一致的异步模型,请参阅 `asio 文档 `_。 +* `esp_wifi_remote `_ 是一个 Wi-Fi 通信库,提供标准的 Wi-Fi API,并且能够借助指定的传输接口,帮助目标设备通过外部 ESP32 芯片实现 Wi-Fi 通信。详情请参阅 :doc:`../api-guides/wifi-expansion`。 + ESP-BSP ----------------------------------------- +------- `ESP-BSP `_ 库包含了各种乐鑫和第三方开发板的板级支持包 (BSP),可以帮助快速上手特定的开发板。它们通常包含管脚定义和辅助函数,这些函数可用于初始化特定开发板的外设。此外,BSP 还提供了一些驱动程序,可用于开发版上的外部芯片,如传感器、显示屏、音频编解码器等。 ESP-IDF-CXX ----------------------------------------------------------- +----------- `ESP-IDF-CXX `_ 包含了 ESP-IDF 的部分 C++ 封装,重点在实现易用性、安全性、自动资源管理,以及将错误检查转移到编译过程中,以避免运行时失败。它还提供了 ESP 定时器、I2C、SPI、GPIO 等外设或 ESP-IDF 其他功能的 C++ 类。ESP-IDF-CXX 作为组件可以从 `乐鑫组件注册表 `__ 中获取。详情请参阅 `README.md `_。 From d74b5844277e07b22e5a6d9d482ad3afd97ea055 Mon Sep 17 00:00:00 2001 From: "wangtao@espressif.com" Date: Tue, 29 Oct 2024 14:54:00 +0800 Subject: [PATCH 36/70] fix(wifi): fix spiram ignore issue --- components/esp_wifi/include/esp_wifi.h | 8 ++++---- components/esp_wifi/lib | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/components/esp_wifi/include/esp_wifi.h b/components/esp_wifi/include/esp_wifi.h index eb112e06070..fc321d20367 100644 --- a/components/esp_wifi/include/esp_wifi.h +++ b/components/esp_wifi/include/esp_wifi.h @@ -224,10 +224,10 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; #define WIFI_ENABLE_WPA3_SAE 0 #endif -#if CONFIG_SPIRAM -#define WIFI_ENABLE_SPIRAM (1<<1) +#if WIFI_CACHE_TX_BUFFER_NUM > 0 +#define WIFI_ENABLE_CACHE_TX_BUFFER (1<<1) #else -#define WIFI_ENABLE_SPIRAM 0 +#define WIFI_ENABLE_CACHE_TX_BUFFER 0 #endif #if CONFIG_ESP_WIFI_FTM_INITIATOR_SUPPORT @@ -289,7 +289,7 @@ extern wifi_osi_funcs_t g_wifi_osi_funcs; /* Set additional WiFi features and capabilities */ #define WIFI_FEATURE_CAPS (WIFI_ENABLE_WPA3_SAE | \ - WIFI_ENABLE_SPIRAM | \ + WIFI_ENABLE_CACHE_TX_BUFFER | \ WIFI_FTM_INITIATOR | \ WIFI_FTM_RESPONDER | \ WIFI_ENABLE_GCMP | \ diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 9532814f141..4488e06749c 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 9532814f14186bd643b2d8a65c957ed985a5ddee +Subproject commit 4488e06749ce73a8a58e53fcb0d415ab54b62122 From 29513cfe0915063dc7f2951d98ade5ab0d3f9c2b Mon Sep 17 00:00:00 2001 From: Linda Date: Mon, 28 Oct 2024 14:14:24 +0800 Subject: [PATCH 37/70] docs: Add description and code example for ADC zero-crossing detection --- .../peripherals/adc_continuous.rst | 39 ++++++++++++++++++- .../peripherals/adc_continuous.rst | 39 ++++++++++++++++++- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/docs/en/api-reference/peripherals/adc_continuous.rst b/docs/en/api-reference/peripherals/adc_continuous.rst index 853f82314d3..923f50e2cc8 100644 --- a/docs/en/api-reference/peripherals/adc_continuous.rst +++ b/docs/en/api-reference/peripherals/adc_continuous.rst @@ -117,7 +117,7 @@ If the ADC continuous mode driver is no longer used, you should deinitialize the - :cpp:func:`adc_continuous_monitor_enable`: Enable a monitor. - :cpp:func:`adc_continuous_monitor_disable`: Disable a monitor. - - :cpp:func:`adc_monitor_register_callbacks`: register user callbacks to take action when the ADC value exceeds of the threshold. + - :cpp:func:`adc_continuous_monitor_register_event_callbacks`: register user callbacks to take action when the ADC value exceeds of the thresholds. - :cpp:func:`adc_del_continuous_monitor`: Delete a created monitor and free resources. .. only:: esp32s2 @@ -129,6 +129,41 @@ If the ADC continuous mode driver is no longer used, you should deinitialize the 2. Only one monitor is supported for one ADC unit. 3. All enabled channel(s) of a certain ADC unit in ADC continuous mode driver will be monitored. The :cpp:member:`adc_monitor_config_t::channel` parameter will not be used. + Specifically, the monitor function can be used to implement zero-crossing detection. As ADC cannot directly process negative input signals, an extra **DC bias** should be applied to the original signal before measurement. + + First, add a DC bias to the input signal through a circuit to "shift" the negative signal into the ADC's measurement range. For the measurement range, please refer to the On-Chip Sensor and Analog Signal Processing chapter in `TRM <{IDF_TARGET_TRM_EN_URL}>`__. For example, adding a 1 V bias would transform a signal from -1 V to +1 V into 0 V to 2 V range. Then by setting the appropriate high and low thresholds, the ADC can detect if the input signal approaches zero, allowing for the identification of phase changes in the signal. Refer to the example code below for details. + + .. code:: c + + // Initialize the ADC monitor handle + adc_monitor_handle_t adc_monitor_handle = NULL; + + // Configure the ADC monitor + adc_monitor_config_t zero_crossing_config = { + .adc_unit = EXAMPLE_ADC_UNIT_1, // Specify the ADC unit to monitor + .channel = EXAMPLE_ADC_CHANNEL_0, // Specify the ADC channel to monitor + .h_threshold = 1100, // Set the high threshold close to the DC bias and adjust it as needed + .l_threshold = 900, // Set the low threshold close to the DC bias and adjust it as needed + }; + + // Create the ADC monitor + ESP_ERROR_CHECK(adc_new_continuous_monitor(&zero_crossing_config, &adc_monitor_handle)); + + // Register the callback function + adc_monitor_evt_cbs_t zero_crossing_cbs = { + .on_over_high_thresh = example_on_exceed_high_thresh, + .on_below_low_thresh = example_on_below_low_thresh, + }; + + ESP_ERROR_CHECK(adc_continuous_monitor_register_event_callbacks(adc_monitor_handle, &zero_crossing_cbs, NULL)); + + // Enable the ADC monitor + ESP_ERROR_CHECK(adc_continuous_monitor_enable(adc_monitor_handle)); + + // Disable and delete the ADC monitor + ESP_ERROR_CHECK(adc_continuous_monitor_disable(adc_monitor_handle)); + ESP_ERROR_CHECK(adc_del_continuous_monitor(adc_monitor_handle)); + Initialize the ADC Continuous Mode Driver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -277,7 +312,7 @@ where: * - Dout - ADC raw digital reading result. * - Vmax - - Maximum measurable input analog voltage, this is related to the ADC attenuation, please refer to the On-Chip Sensor and Analog Signal Processing chapter in `Datasheet <{IDF_TARGET_DATASHEET_EN_URL}>`__. + - Maximum measurable input analog voltage, this is related to the ADC attenuation, please refer to the On-Chip Sensor and Analog Signal Processing chapter in `TRM <{IDF_TARGET_TRM_EN_URL}#sensor>`__. * - Dmax - Maximum of the output ADC raw digital reading result, which is 2^bitwidth, where the bitwidth is the :cpp:member:`adc_digi_pattern_config_t::bit_width` configured before. diff --git a/docs/zh_CN/api-reference/peripherals/adc_continuous.rst b/docs/zh_CN/api-reference/peripherals/adc_continuous.rst index 5ebd83dabad..de07d357056 100644 --- a/docs/zh_CN/api-reference/peripherals/adc_continuous.rst +++ b/docs/zh_CN/api-reference/peripherals/adc_continuous.rst @@ -117,7 +117,7 @@ ADC 连续转换模式驱动基于 {IDF_TARGET_NAME} SAR ADC 模块实现,不 - :cpp:func:`adc_continuous_monitor_enable`:启用监视器。 - :cpp:func:`adc_continuous_monitor_disable`:禁用监视器. - - :cpp:func:`adc_monitor_register_callbacks`:注册用户回调函数,在 ADC 转换结果超出阈值时,执行相应操作。 + - :cpp:func:`adc_continuous_monitor_register_event_callbacks`:注册用户回调函数,在 ADC 转换结果超出阈值时,执行相应操作。 - :cpp:func:`adc_del_continuous_monitor`:删除监视器,释放资源。 .. only:: esp32s2 @@ -129,6 +129,41 @@ ADC 连续转换模式驱动基于 {IDF_TARGET_NAME} SAR ADC 模块实现,不 2. 每个 ADC 单元仅支持一个监视器。 3. ADC 连续转换模式驱动中,如果启用了监视器,无需使用参数 :cpp:member:`adc_monitor_config_t::channel` 指定,某个 ADC 单元中所有已启用的通道都会受监视。 + 特别地,监视器功能可用于实现过零检测。由于 ADC 无法直接处理负输入信号,可以通过 **直流偏置(DC bias)** 来实现过零检测。 + + 首先,通过电路将直流偏置添加到输入信号中,以将负信号“移位”到 ADC 的测量范围内。关于 ADC 的测量范围,请参考 `技术参考手册 <{IDF_TARGET_TRM_CN_URL}#sensor>`__ 中的片上传感器与模拟信号处理章节。例如,添加一个 1 V 的偏置可以将 -1 V 至 +1 V 的信号变换到 0 V 至 2 V 的范围。然后,通过设置合适的高阈值与低阈值,ADC 可以检测输入信号是否接近零,从而识别信号的相位变化。详情请参考下面的示例代码。 + + .. code:: c + + // 初始化 ADC 监视器句柄 + adc_monitor_handle_t adc_monitor_handle = NULL; + + // 配置 ADC 监视器 + adc_monitor_config_t zero_crossing_config = { + .adc_unit = EXAMPLE_ADC_UNIT_1, // 指定要监视的 ADC 单元 + .channel = EXAMPLE_ADC_CHANNEL_0, // 指定要监视的 ADC 通道 + .h_threshold = 1100, // 设置监视的高阈值为接近偏置值,请根据实际情况进行调整 + .l_threshold = 900, // 设置监视的低阈值为接近偏置值,请根据实际情况进行调整 + }; + + // 创建 ADC 监视器 + ESP_ERROR_CHECK(adc_new_continuous_monitor(&zero_crossing_config, &adc_monitor_handle)); + + // 注册回调函数 + adc_monitor_evt_cbs_t zero_crossing_cbs = { + .on_over_high_thresh = example_on_exceed_high_thresh, + .on_below_low_thresh = example_on_below_low_thresh, + }; + + ESP_ERROR_CHECK(adc_continuous_monitor_register_event_callbacks(adc_monitor_handle, &zero_crossing_cbs, NULL)); + + // 启用 ADC 监视器 + ESP_ERROR_CHECK(adc_continuous_monitor_enable(adc_monitor_handle)); + + // 禁用并删除 ADC 监视器 + ESP_ERROR_CHECK(adc_continuous_monitor_disable(adc_monitor_handle)); + ESP_ERROR_CHECK(adc_del_continuous_monitor(adc_monitor_handle)); + 初始化 ADC 连续转换模式驱动 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -165,7 +200,7 @@ ADC 连续转换模式驱动基于 {IDF_TARGET_NAME} SAR ADC 模块实现,不 按照以下步骤设置 :cpp:type:`adc_digi_pattern_config_t`: -- :cpp:member:`adc_digi_pattern_config_t::atten`:ADC 衰减。请参阅 `技术规格书 <{IDF_TARGET_DATASHEET_CN_URL}#sensor>`__ 中的 ``ADC 特性`` 章节。 +- :cpp:member:`adc_digi_pattern_config_t::atten`:ADC 衰减。请参阅 `技术参考手册 <{IDF_TARGET_TRM_CN_URL}#sensor>`__ 中的 ``ADC 特性`` 章节。 - :cpp:member:`adc_digi_pattern_config_t::channel`:IO 对应的 ADC 通道号,请参阅下文注意事项。 - :cpp:member:`adc_digi_pattern_config_t::unit`:IO 所属的 ADC 单元。 - :cpp:member:`adc_digi_pattern_config_t::bit_width`:原始转换结果的位宽。 From 4464673ab97c7cc8eec9e5dab8cc1db2751c8825 Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Tue, 29 Oct 2024 12:38:53 +0800 Subject: [PATCH 38/70] ci(i2s): fix i2s_multi_dev failed case --- .../i2s_multi_dev/main/test_i2s_multi_dev.c | 19 +++++-------------- components/soc/esp32c5/include/soc/soc_caps.h | 1 - 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/test_i2s_multi_dev.c b/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/test_i2s_multi_dev.c index 5a6d0251173..35b1b237602 100644 --- a/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/test_i2s_multi_dev.c +++ b/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/test_i2s_multi_dev.c @@ -240,8 +240,9 @@ TEST_CASE_MULTIPLE_DEVICES("I2S_TDM_full_duplex_test_in_48k_8bits_4slots", "[I2S test_i2s_tdm_master_48k_8bits_4slots, test_i2s_tdm_slave_48k_8bits_4slots); /* The I2S source clock can only reach 96Mhz on ESP32H2, + and the max clock source APLL on P4 is 125M, which can't satisfy the following configurations in slave mode */ -#if !CONFIG_IDF_TARGET_ESP32H2 +#if !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32P4 static void test_i2s_tdm_master_48k_16bits_8slots(void) { test_i2s_tdm_master(48000, I2S_DATA_BIT_WIDTH_16BIT, I2S_TDM_SLOT0 | I2S_TDM_SLOT1 | I2S_TDM_SLOT2 | I2S_TDM_SLOT3 | @@ -257,8 +258,6 @@ static void test_i2s_tdm_slave_48k_16bits_8slots(void) TEST_CASE_MULTIPLE_DEVICES("I2S_TDM_full_duplex_test_in_48k_16bits_8slots", "[I2S_TDM]", test_i2s_tdm_master_48k_16bits_8slots, test_i2s_tdm_slave_48k_16bits_8slots); -// The max clock source APLL on P4 is 125M which can't satisfy the following config in slave mode -#if !CONFIG_IDF_TARGET_ESP32P4 static void test_i2s_tdm_master_96k_16bits_4slots(void) { test_i2s_tdm_master(96000, I2S_DATA_BIT_WIDTH_16BIT, I2S_TDM_SLOT0 | I2S_TDM_SLOT1 | I2S_TDM_SLOT2 | I2S_TDM_SLOT3); @@ -271,8 +270,7 @@ static void test_i2s_tdm_slave_96k_16bits_4slots(void) TEST_CASE_MULTIPLE_DEVICES("I2S_TDM_full_duplex_test_in_96k_16bits_4slots", "[I2S_TDM]", test_i2s_tdm_master_96k_16bits_4slots, test_i2s_tdm_slave_96k_16bits_4slots); -#endif // !CONFIG_IDF_TARGET_ESP32P4 -#endif // !CONFIG_IDF_TARGET_ESP32H2 +#endif // !CONFIG_IDF_TARGET_ESP32H2 && !CONFIG_IDF_TARGET_ESP32P4 static void test_i2s_external_clk_src(bool is_master, bool is_external) { @@ -285,22 +283,15 @@ static void test_i2s_external_clk_src(bool is_master, bool is_external) .slot_cfg = I2S_STD_MSB_SLOT_DEFAULT_CONFIG(16, I2S_SLOT_MODE_STEREO), .gpio_cfg = TEST_I2S_DEFAULT_GPIO(TEST_I2S_MCK_IO, is_master), }; + std_cfg.clk_cfg.mclk_multiple = I2S_MCLK_MULTIPLE_512; if (is_external) { std_cfg.clk_cfg.clk_src = I2S_CLK_SRC_EXTERNAL; - std_cfg.clk_cfg.ext_clk_freq_hz = 11289600; + std_cfg.clk_cfg.ext_clk_freq_hz = 22579200; } TEST_ESP_OK(i2s_channel_init_std_mode(tx_handle, &std_cfg)); - if (is_master && !is_external) { - i2s_std_slot_config_t slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(16, I2S_SLOT_MODE_STEREO); - memcpy(&std_cfg.slot_cfg, &slot_cfg, sizeof(i2s_std_slot_config_t)); - } TEST_ESP_OK(i2s_channel_init_std_mode(rx_handle, &std_cfg)); if (is_master) { - if (!is_external) { - // Delay bclk to get compensate the data delay - I2S0.rx_timing.rx_bck_out_dm = 1; - } uint8_t mst_tx_data[4] = {0x12, 0x34, 0x56, 0x78}; size_t w_bytes = 4; while (w_bytes == 4) { diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index edafca62797..7eb49628ea3 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -279,7 +279,6 @@ #define SOC_I2S_HW_VERSION_2 (1) #define SOC_I2S_SUPPORTS_ETM (1) #define SOC_I2S_SUPPORTS_TX_SYNC_CNT (1) -// #define SOC_I2S_SUPPORTS_RX_RECOMB (1) //TODO[C5] IDF-9966 #define SOC_I2S_SUPPORTS_XTAL (1) #define SOC_I2S_SUPPORTS_PLL_F160M (1) #define SOC_I2S_SUPPORTS_PLL_F240M (1) From ecefb3c7e544add396800c5c548cf3d0e6a089aa Mon Sep 17 00:00:00 2001 From: linruihao Date: Wed, 30 Oct 2024 15:05:17 +0800 Subject: [PATCH 39/70] fix(bt/bluedroid): Fix memory leak in sco when bluedroid disable --- .codespellrc | 2 +- .../bt/host/bluedroid/stack/btm/btm_main.c | 3 +++ .../bt/host/bluedroid/stack/btm/btm_sco.c | 20 +++++++++++++++++-- .../bluedroid/stack/btm/include/btm_int.h | 1 + 4 files changed, 23 insertions(+), 3 deletions(-) diff --git a/.codespellrc b/.codespellrc index a886554427d..e9be43f2160 100644 --- a/.codespellrc +++ b/.codespellrc @@ -1,4 +1,4 @@ [codespell] skip = build,*.yuv,components/fatfs/src/*,alice.txt,*.rgb,components/wpa_supplicant/*,components/esp_wifi/*,*.pem -ignore-words-list = ser,dout,rsource,fram,inout,shs,ans,aci,unstall,unstalling,hart,wheight,wel,ot,fane,assertIn,registr,oen +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 diff --git a/components/bt/host/bluedroid/stack/btm/btm_main.c b/components/bt/host/bluedroid/stack/btm/btm_main.c index e9e443380c8..1519ecb990a 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_main.c +++ b/components/bt/host/bluedroid/stack/btm/btm_main.c @@ -110,6 +110,9 @@ void btm_free(void) fixed_queue_free(btm_cb.sec_pending_q, osi_free_func); btm_acl_free(); btm_sec_dev_free(); +#if BTM_SCO_INCLUDED == TRUE + btm_sco_free(); +#endif #if BTM_DYNAMIC_MEMORY FREE_AND_RESET(btm_cb_ptr); #endif diff --git a/components/bt/host/bluedroid/stack/btm/btm_sco.c b/components/bt/host/bluedroid/stack/btm/btm_sco.c index 53a9768a1ae..7dede5d4d3f 100644 --- a/components/bt/host/bluedroid/stack/btm/btm_sco.c +++ b/components/bt/host/bluedroid/stack/btm/btm_sco.c @@ -123,6 +123,22 @@ void btm_sco_init (void) btm_cb.sco_cb.desired_sco_mode = BTM_DEFAULT_SCO_MODE; } +/******************************************************************************* +** +** Function btm_sco_free +** +** Description Free sco specific fixed_queue from btm control block +** +*******************************************************************************/ +void btm_sco_free(void) +{ +#if (BTM_SCO_HCI_INCLUDED == TRUE) + for (int i = 0; i < BTM_MAX_SCO_LINKS; i++) { + fixed_queue_free(btm_cb.sco_cb.sco_db[i].xmit_data_q, osi_free_func); + } +#endif +} + /******************************************************************************* ** ** Function btm_esco_conn_rsp @@ -233,7 +249,7 @@ void btm_sco_process_num_bufs (UINT16 num_lm_sco_bufs) ** pointer is used, PCM parameter maintained in ** the control block will be used; otherwise update ** control block value. -** err_data_rpt: Lisbon feature to enable the erronous data report +** err_data_rpt: Lisbon feature to enable the erroneous data report ** or not. ** ** Returns BTM_SUCCESS if the successful. @@ -947,7 +963,7 @@ void btm_sco_conn_req (BD_ADDR bda, DEV_CLASS dev_class, UINT8 link_type) for (xx = 0; xx < BTM_MAX_SCO_LINKS; xx++, p++) { /* * If the sco state is in the SCO_ST_CONNECTING state, we still need - * to return accept sco to avoid race conditon for sco creation + * to return accept sco to avoid race condition for sco creation */ int rem_bd_matches = p->rem_bd_known && !memcmp (p->esco.data.bd_addr, bda, BD_ADDR_LEN); diff --git a/components/bt/host/bluedroid/stack/btm/include/btm_int.h b/components/bt/host/bluedroid/stack/btm/include/btm_int.h index 64bcc300cd2..df7e435db1a 100644 --- a/components/bt/host/bluedroid/stack/btm/include/btm_int.h +++ b/components/bt/host/bluedroid/stack/btm/include/btm_int.h @@ -1119,6 +1119,7 @@ void btm_ble_periodic_adv_sync_trans_complete(UINT16 op_code, UINT8 hci_status, ******************************************** */ void btm_sco_init (void); +void btm_sco_free(void); void btm_sco_connected (UINT8 hci_status, BD_ADDR bda, UINT16 hci_handle, tBTM_ESCO_DATA *p_esco_data); void btm_esco_proc_conn_chg (UINT8 status, UINT16 handle, UINT8 tx_interval, From 059de88f23db352b18a64a5b48e5346497fc0e4b Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Wed, 30 Oct 2024 15:45:15 +0800 Subject: [PATCH 40/70] feat(i2s): support i2s retention on C61 --- components/soc/esp32c61/i2s_periph.c | 39 +++++++++++++++++++ .../esp32c61/include/soc/Kconfig.soc_caps.in | 4 ++ .../include/soc/retention_periph_defs.h | 3 ++ .../soc/esp32c61/include/soc/soc_caps.h | 1 + 4 files changed, 47 insertions(+) diff --git a/components/soc/esp32c61/i2s_periph.c b/components/soc/esp32c61/i2s_periph.c index f7f815d157d..667c4d3e9f0 100644 --- a/components/soc/esp32c61/i2s_periph.c +++ b/components/soc/esp32c61/i2s_periph.c @@ -5,6 +5,7 @@ */ #include "soc/i2s_periph.h" +#include "soc/i2s_reg.h" #include "soc/gpio_sig_map.h" /* @@ -32,3 +33,41 @@ const i2s_signal_conn_t i2s_periph_signal[SOC_I2S_NUM] = { .irq = ETS_I2S0_INTR_SOURCE, } }; + +/** + * I2S Registers to be saved during sleep retention + * - I2S_RX_CONF_REG + * - I2S_TX_CONF_REG + * - I2S_RX_CONF1_REG + * - I2S_TX_CONF1_REG + * - I2S_TX_PCM2PDM_CONF_REG + * - I2S_TX_PCM2PDM_CONF1_REG + * - I2S_RX_TDM_CTRL_REG + * - I2S_TX_TDM_CTRL_REG + * - I2S_RXEOF_NUM_REG + * - I2S_ETM_CONF_REG +*/ +#define I2S_RETENTION_REGS_CNT 10 +#define I2S_RETENTION_REGS_BASE(i) I2S_RX_CONF_REG +static const uint32_t i2s_regs_map[4] = {0x12360f, 0x0, 0x0, 0x0}; +#define I2S_SLEEP_RETENTION_ENTRIES(i2s_port) { \ + /* Save/restore the register values */ \ + [0] = { .config = REGDMA_LINK_ADDR_MAP_INIT( \ + REGDMA_I2S_LINK(0x00), \ + I2S_RETENTION_REGS_BASE(i2s_port), \ + I2S_RETENTION_REGS_BASE(i2s_port), \ + I2S_RETENTION_REGS_CNT, 0, 0, \ + i2s_regs_map[0], i2s_regs_map[1], \ + i2s_regs_map[2], i2s_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2)}, \ +}; + +static const regdma_entries_config_t i2s0_regs_retention[] = I2S_SLEEP_RETENTION_ENTRIES(0); + +const i2s_reg_retention_info_t i2s_reg_retention_info[SOC_I2S_NUM] = { + [0] = { + .retention_module = SLEEP_RETENTION_MODULE_I2S0, + .entry_array = i2s0_regs_retention, + .array_size = ARRAY_SIZE(i2s0_regs_retention) + }, +}; diff --git a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in index 184218444db..f31e21b6103 100644 --- a/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c61/include/soc/Kconfig.soc_caps.in @@ -495,6 +495,10 @@ config SOC_I2S_SUPPORTS_TDM bool default y +config SOC_I2S_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_LEDC_SUPPORT_PLL_DIV_CLOCK bool default y diff --git a/components/soc/esp32c61/include/soc/retention_periph_defs.h b/components/soc/esp32c61/include/soc/retention_periph_defs.h index f0a8f61f6ae..6ec8597817d 100644 --- a/components/soc/esp32c61/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c61/include/soc/retention_periph_defs.h @@ -36,6 +36,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_ETM0 = 16, SLEEP_RETENTION_MODULE_GPSPI2 = 17, SLEEP_RETENTION_MODULE_LEDC = 18, + SLEEP_RETENTION_MODULE_I2S0 = 19, /* Modem module, which includes WiFi, BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_WIFI_MAC = 26, @@ -68,6 +69,7 @@ typedef enum periph_retention_module_bitmap { SLEEP_RETENTION_MODULE_BM_ETM0 = BIT(SLEEP_RETENTION_MODULE_ETM0), SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2), SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC), + SLEEP_RETENTION_MODULE_BM_I2S0 = BIT(SLEEP_RETENTION_MODULE_I2S0), /* modem module, which includes WiFi, BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC), SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB), @@ -90,6 +92,7 @@ typedef enum periph_retention_module_bitmap { | SLEEP_RETENTION_MODULE_BM_ETM0 \ | SLEEP_RETENTION_MODULE_BM_GPSPI2 \ | SLEEP_RETENTION_MODULE_BM_LEDC \ + | SLEEP_RETENTION_MODULE_BM_I2S0 \ ) #ifdef __cplusplus diff --git a/components/soc/esp32c61/include/soc/soc_caps.h b/components/soc/esp32c61/include/soc/soc_caps.h index 4b4c36f3e7b..bf10bbd7e1a 100644 --- a/components/soc/esp32c61/include/soc/soc_caps.h +++ b/components/soc/esp32c61/include/soc/soc_caps.h @@ -244,6 +244,7 @@ #define SOC_I2S_SUPPORTS_PDM_TX (1) #define SOC_I2S_PDM_MAX_TX_LINES (2) #define SOC_I2S_SUPPORTS_TDM (1) +#define SOC_I2S_SUPPORT_SLEEP_RETENTION (1) /*-------------------------- LEDC CAPS ---------------------------------------*/ #define SOC_LEDC_SUPPORT_PLL_DIV_CLOCK (1) From 5ee42e02394352a3e6229191ae5403c889e2588e Mon Sep 17 00:00:00 2001 From: laokaiyao Date: Wed, 30 Oct 2024 16:05:35 +0800 Subject: [PATCH 41/70] fix(i2s): suplimemt of c61 i2s ll --- components/hal/esp32c5/include/hal/i2s_ll.h | 3 +- components/hal/esp32c61/include/hal/etm_ll.h | 2 + components/hal/esp32c61/include/hal/i2s_ll.h | 146 +++++++++++++++---- 3 files changed, 117 insertions(+), 34 deletions(-) diff --git a/components/hal/esp32c5/include/hal/i2s_ll.h b/components/hal/esp32c5/include/hal/i2s_ll.h index 02288bd1cd6..59c2f96ed6e 100644 --- a/components/hal/esp32c5/include/hal/i2s_ll.h +++ b/components/hal/esp32c5/include/hal/i2s_ll.h @@ -13,7 +13,6 @@ #pragma once #include -#include "sdkconfig.h" #include "hal/misc.h" #include "hal/assert.h" #include "soc/i2s_periph.h" @@ -154,7 +153,7 @@ static inline void i2s_ll_rx_disable_clock(i2s_dev_t *hw) static inline void i2s_ll_mclk_bind_to_tx_clk(i2s_dev_t *hw) { (void)hw; - PCR.i2s_rx_clkm_conf.i2s_mclk_sel = 0; // TODO: need check + PCR.i2s_rx_clkm_conf.i2s_mclk_sel = 0; } /** diff --git a/components/hal/esp32c61/include/hal/etm_ll.h b/components/hal/esp32c61/include/hal/etm_ll.h index 6708cd7f17e..ebed4861b56 100644 --- a/components/hal/esp32c61/include/hal/etm_ll.h +++ b/components/hal/esp32c61/include/hal/etm_ll.h @@ -18,6 +18,8 @@ extern "C" { #endif +#define ETM_LL_SUPPORT_STATUS 1 // Support to get and clear the status of the ETM event and task + /** * @brief Enable the clock for ETM register * diff --git a/components/hal/esp32c61/include/hal/i2s_ll.h b/components/hal/esp32c61/include/hal/i2s_ll.h index 5bbad89e5a1..209bf67219f 100644 --- a/components/hal/esp32c61/include/hal/i2s_ll.h +++ b/components/hal/esp32c61/include/hal/i2s_ll.h @@ -18,6 +18,7 @@ #include "soc/i2s_periph.h" #include "soc/i2s_struct.h" #include "soc/pcr_struct.h" +#include "soc/soc_etm_struct.h" #include "soc/soc_etm_source.h" #include "hal/i2s_types.h" #include "hal/hal_utils.h" @@ -28,16 +29,16 @@ extern "C" { #endif #define I2S_LL_GET_HW(num) (((num) == 0)? (&I2S0) : NULL) +#define I2S_LL_GET_ID(hw) (((hw) == &I2S0)? 0 : -1) #define I2S_LL_TDM_CH_MASK (0xffff) #define I2S_LL_PDM_BCK_FACTOR (64) -#define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width -#define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width +#define I2S_LL_CLK_FRAC_DIV_N_MAX 256 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the N register is 8 bit-width +#define I2S_LL_CLK_FRAC_DIV_AB_MAX 512 // I2S_MCLK = I2S_SRC_CLK / (N + b/a), the a/b register is 9 bit-width -#define I2S_LL_PLL_F120M_CLK_FREQ (120 * 1000000) // PLL_F160M_CLK: 120MHz #define I2S_LL_PLL_F160M_CLK_FREQ (160 * 1000000) // PLL_F160M_CLK: 160MHz -#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT +#define I2S_LL_DEFAULT_CLK_FREQ I2S_LL_PLL_F160M_CLK_FREQ // The default PLL clock frequency while using I2S_CLK_SRC_DEFAULT #define I2S_LL_ETM_EVENT_TABLE(i2s_port, chan_dir, event) \ (uint32_t[SOC_I2S_NUM][2][I2S_ETM_EVENT_MAX]){{ \ @@ -64,6 +65,7 @@ extern "C" { #define I2S_LL_ETM_MAX_THRESH_NUM (0x3FFUL) /** + * @brief Enable the bus clock for I2S module * * @param i2s_id The port id of I2S * @param enable Set true to enable the buf clock @@ -313,13 +315,21 @@ static inline void i2s_ll_tx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, 2); + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = 1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = 0; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_yn1 = yn1; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_z = z; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_y = y; + PCR.i2s_tx_clkm_div_conf.i2s_tx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_tx_clkm_conf, i2s_tx_clkm_div_num, div_int); - typeof(PCR.i2s_tx_clkm_div_conf) div = {}; - div.i2s_tx_clkm_div_x = x; - div.i2s_tx_clkm_div_y = y; - div.i2s_tx_clkm_div_z = z; - div.i2s_tx_clkm_div_yn1 = yn1; - PCR.i2s_tx_clkm_div_conf.val = div.val; } /** @@ -335,13 +345,21 @@ static inline void i2s_ll_tx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, uint32_t x, uint32_t y, uint32_t z, uint32_t yn1) { (void)hw; + /* Workaround for the double division issue. + * The division coefficients must be set in particular sequence. + * And it has to switch to a small division first before setting the target division. */ + HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, 2); + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = 1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = 0; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = 0; + + /* Set the target mclk division coefficients */ + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_yn1 = yn1; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_z = z; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_y = y; + PCR.i2s_rx_clkm_div_conf.i2s_rx_clkm_div_x = x; HAL_FORCE_MODIFY_U32_REG_FIELD(PCR.i2s_rx_clkm_conf, i2s_rx_clkm_div_num, div_int); - typeof(PCR.i2s_rx_clkm_div_conf) div = {}; - div.i2s_rx_clkm_div_x = x; - div.i2s_rx_clkm_div_y = y; - div.i2s_rx_clkm_div_z = z; - div.i2s_rx_clkm_div_yn1 = yn1; - PCR.i2s_rx_clkm_div_conf.val = div.val; } /** @@ -352,12 +370,6 @@ static inline void i2s_ll_rx_set_raw_clk_div(i2s_dev_t *hw, uint32_t div_int, ui */ static inline void i2s_ll_tx_set_mclk(i2s_dev_t *hw, const hal_utils_clk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_tx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -392,12 +404,6 @@ static inline void i2s_ll_rx_set_bck_div_num(i2s_dev_t *hw, uint32_t val) */ static inline void i2s_ll_rx_set_mclk(i2s_dev_t *hw, const hal_utils_clk_div_t *mclk_div) { - /* Workaround for inaccurate clock while switching from a relatively low sample rate to a high sample rate - * Set to particular coefficients first then update to the target coefficients, - * otherwise the clock division might be inaccurate. - * the general idea is to set a value that impossible to calculate from the regular decimal */ - i2s_ll_rx_set_raw_clk_div(hw, 7, 317, 7, 3, 0); - uint32_t div_x = 0; uint32_t div_y = 0; uint32_t div_z = 0; @@ -525,7 +531,7 @@ static inline void i2s_ll_rx_set_sample_bit(i2s_dev_t *hw, uint8_t chan_bit, int */ static inline void i2s_ll_tx_set_half_sample_bit(i2s_dev_t *hw, int half_sample_bits) { - hw->tx_conf1.tx_half_sample_bits = half_sample_bits - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->tx_conf1, tx_half_sample_bits, half_sample_bits - 1); } /** @@ -536,7 +542,7 @@ static inline void i2s_ll_tx_set_half_sample_bit(i2s_dev_t *hw, int half_sample_ */ static inline void i2s_ll_rx_set_half_sample_bit(i2s_dev_t *hw, int half_sample_bits) { - hw->rx_conf1.rx_half_sample_bits = half_sample_bits - 1; + HAL_FORCE_MODIFY_U32_REG_FIELD(hw->rx_conf1, rx_half_sample_bits, half_sample_bits - 1); } /** @@ -1218,7 +1224,7 @@ static inline uint32_t i2s_ll_tx_get_bclk_sync_count(i2s_dev_t *hw) * @brief Set the TX ETM threshold of REACH_THRESH event * * @param hw Peripheral I2S hardware instance address. - * @param thresh The threshold that send + * @param thresh The threshold that send, in words (4 bytes) */ static inline void i2s_ll_tx_set_etm_threshold(i2s_dev_t *hw, uint32_t thresh) { @@ -1229,13 +1235,89 @@ static inline void i2s_ll_tx_set_etm_threshold(i2s_dev_t *hw, uint32_t thresh) * @brief Set the RX ETM threshold of REACH_THRESH event * * @param hw Peripheral I2S hardware instance address. - * @param thresh The threshold that received + * @param thresh The threshold that received, in words (4 bytes) */ static inline void i2s_ll_rx_set_etm_threshold(i2s_dev_t *hw, uint32_t thresh) { hw->etm_conf.etm_rx_receive_word_num = thresh; } +/** + * @brief Get I2S ETM TX done event status + * + * @param hw Peripheral I2S hardware instance address. + * @return + * - true TX done event triggered + * - false TX done event not triggered + */ +static inline bool i2s_ll_get_etm_tx_done_event_status(i2s_dev_t *hw) +{ + uint32_t i2s_id = I2S_LL_GET_ID(hw); + switch (i2s_id) { + case 0: + return SOC_ETM.evt_st2.i2s0_evt_tx_done_st; + default: + HAL_ASSERT(false); + } +} + +/** + * @brief Get I2S ETM TX done event status + * + * @param hw Peripheral I2S hardware instance address. + * @return + * - true TX done event triggered + * - false TX done event not triggered + */ +static inline bool i2s_ll_get_etm_rx_done_event_status(i2s_dev_t *hw) +{ + uint32_t i2s_id = I2S_LL_GET_ID(hw); + switch (i2s_id) { + case 0: + return SOC_ETM.evt_st2.i2s0_evt_rx_done_st; + default: + HAL_ASSERT(false); + } +} + +/** + * @brief Get I2S ETM TX done event status + * + * @param hw Peripheral I2S hardware instance address. + * @return + * - true TX done event triggered + * - false TX done event not triggered + */ +static inline bool i2s_ll_get_etm_tx_threshold_event_status(i2s_dev_t *hw) +{ + uint32_t i2s_id = I2S_LL_GET_ID(hw); + switch (i2s_id) { + case 0: + return SOC_ETM.evt_st2.i2s0_evt_x_words_sent_st; + default: + HAL_ASSERT(false); + } +} + +/** + * @brief Get I2S ETM TX done event status + * + * @param hw Peripheral I2S hardware instance address. + * @return + * - true TX done event triggered + * - false TX done event not triggered + */ +static inline bool i2s_ll_get_etm_rx_threshold_event_status(i2s_dev_t *hw) +{ + uint32_t i2s_id = I2S_LL_GET_ID(hw); + switch (i2s_id) { + case 0: + return SOC_ETM.evt_st2.i2s0_evt_x_words_received_st; + default: + HAL_ASSERT(false); + } +} + #ifdef __cplusplus } #endif From ddf6fea6a2789df65a8f6be0c3868648b00ac774 Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 24 Oct 2024 18:00:16 +0800 Subject: [PATCH 42/70] feat(pcnt): add sleep retention init Currently, due to the lack of sleep callback feature. We only init sleep module but don't allocate it. Thus the power domain will be kept during the light sleep. And temporarily disable pcnt sleep retention support on P4 due to the lack of retention module ID. --- components/esp_driver_pcnt/src/pulse_cnt.c | 45 ++++++ .../test_apps/pulse_cnt/main/CMakeLists.txt | 5 + .../pulse_cnt/main/test_pulse_cnt_sleep.c | 141 ++++++++++++++++++ .../test_apps/pulse_cnt/sdkconfig.ci.release | 1 + .../test_apps/pulse_cnt/sdkconfig.defaults | 3 + .../esp32c5/include/soc/Kconfig.soc_caps.in | 4 + .../include/soc/retention_periph_defs.h | 3 + components/soc/esp32c5/include/soc/soc_caps.h | 1 + components/soc/esp32c5/pcnt_periph.c | 29 ++++ .../esp32c6/include/soc/Kconfig.soc_caps.in | 4 + .../include/soc/retention_periph_defs.h | 3 + components/soc/esp32c6/include/soc/soc_caps.h | 1 + components/soc/esp32c6/pcnt_periph.c | 30 +++- .../esp32h2/include/soc/Kconfig.soc_caps.in | 4 + .../include/soc/retention_periph_defs.h | 3 + components/soc/esp32h2/include/soc/soc_caps.h | 1 + components/soc/esp32h2/pcnt_periph.c | 30 +++- components/soc/esp32p4/include/soc/soc_caps.h | 1 + components/soc/esp32p4/pcnt_periph.c | 33 +++- components/soc/include/soc/pcnt_periph.h | 16 +- components/soc/include/soc/regdma.h | 2 + 21 files changed, 356 insertions(+), 4 deletions(-) create mode 100644 components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c diff --git a/components/esp_driver_pcnt/src/pulse_cnt.c b/components/esp_driver_pcnt/src/pulse_cnt.c index 0f1148e9fdd..6be76876c19 100644 --- a/components/esp_driver_pcnt/src/pulse_cnt.c +++ b/components/esp_driver_pcnt/src/pulse_cnt.c @@ -28,6 +28,7 @@ #include "hal/gpio_hal.h" #include "esp_private/esp_clk.h" #include "esp_private/periph_ctrl.h" +#include "esp_private/sleep_retention.h" #include "driver/gpio.h" #include "esp_private/gpio.h" #include "hal/gpio_ll.h" // for io_loop_back flag only @@ -65,6 +66,13 @@ typedef struct pcnt_group_t pcnt_group_t; typedef struct pcnt_unit_t pcnt_unit_t; typedef struct pcnt_chan_t pcnt_chan_t; +// Use retention link only when the target supports sleep retention +#define PCNT_USE_RETENTION_LINK (SOC_PCNT_SUPPORT_SLEEP_RETENTION && CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP) + +#if PCNT_USE_RETENTION_LINK +static esp_err_t pcnt_create_sleep_retention_link_cb(void *arg); +#endif + struct pcnt_platform_t { _lock_t mutex; // platform level mutex lock pcnt_group_t *groups[SOC_PCNT_GROUPS]; // pcnt group pool @@ -864,6 +872,23 @@ static pcnt_group_t *pcnt_acquire_group_handle(int group_id) pcnt_ll_enable_bus_clock(group_id, true); pcnt_ll_reset_register(group_id); } +#if PCNT_USE_RETENTION_LINK + sleep_retention_module_t module_id = pcnt_reg_retention_info[group_id].retention_module; + sleep_retention_module_init_param_t init_param = { + .cbs = { + .create = { + .handle = pcnt_create_sleep_retention_link_cb, + .arg = group, + }, + }, + .depends = SLEEP_RETENTION_MODULE_BM_CLOCK_SYSTEM + }; + // we only do retention init here. Allocate retention module in the unit initialization + if (sleep_retention_module_init(module_id, &init_param) != ESP_OK) { + // even though the sleep retention module init failed, PCNT driver should still work, so just warning here + ESP_LOGW(TAG, "init sleep retention failed %d, power domain may be turned off during sleep", group_id); + } +#endif // PCNT_USE_RETENTION_LINK // initialize HAL context pcnt_hal_init(&group->hal, group_id); } @@ -901,6 +926,12 @@ static void pcnt_release_group_handle(pcnt_group_t *group) _lock_release(&s_platform.mutex); if (do_deinitialize) { +#if PCNT_USE_RETENTION_LINK + const periph_retention_module_t module_id = pcnt_reg_retention_info[group_id].retention_module; + if (sleep_retention_get_inited_modules() & BIT(module_id)) { + sleep_retention_module_deinit(module_id); + } +#endif // PCNT_USE_RETENTION_LINK free(group); ESP_LOGD(TAG, "del group (%d)", group_id); } @@ -998,3 +1029,17 @@ IRAM_ATTR static void pcnt_default_isr(void *args) portYIELD_FROM_ISR(); } } + +#if PCNT_USE_RETENTION_LINK +static esp_err_t pcnt_create_sleep_retention_link_cb(void *arg) +{ + pcnt_group_t *group = (pcnt_group_t *)arg; + int group_id = group->group_id; + sleep_retention_module_t module_id = pcnt_reg_retention_info[group_id].retention_module; + esp_err_t err = sleep_retention_entries_create(pcnt_reg_retention_info[group_id].regdma_entry_array, + pcnt_reg_retention_info[group_id].array_size, + REGDMA_LINK_PRI_PCNT, module_id); + ESP_RETURN_ON_ERROR(err, TAG, "create retention link failed"); + return ESP_OK; +} +#endif // PCNT_USE_RETENTION_LINK diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt index 67bb690c46b..78a5ea7d4e1 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/CMakeLists.txt @@ -6,6 +6,11 @@ if(CONFIG_PCNT_ISR_IRAM_SAFE) list(APPEND srcs "test_pulse_cnt_iram.c") endif() +# TODO: IDF-9907 support ESP32P4 +if(CONFIG_SOC_LIGHT_SLEEP_SUPPORTED AND CONFIG_PM_ENABLE AND !CONFIG_IDF_TARGET_ESP32P4) + list(APPEND srcs "test_pulse_cnt_sleep.c") +endif() + # 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} diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c new file mode 100644 index 00000000000..2df0e0b9c07 --- /dev/null +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/main/test_pulse_cnt_sleep.c @@ -0,0 +1,141 @@ +/* + * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/semphr.h" +#include "unity.h" +#include "unity_test_utils.h" +#include "driver/pulse_cnt.h" +#include "driver/gpio.h" +#include "spi_flash_mmap.h" +#include "esp_attr.h" +#include "esp_sleep.h" +#include "soc/soc_caps.h" +#include "soc/pcnt_struct.h" +#include "hal/pcnt_ll.h" +#include "test_pulse_cnt_board.h" +#include "esp_private/sleep_cpu.h" +#include "esp_private/esp_sleep_internal.h" +#include "esp_private/esp_pmu.h" + +/** + * @brief Test the PCNT driver can still work after light sleep + */ +static void test_pcnt_sleep_retention() +{ + test_gpio_init_for_simulation(TEST_PCNT_GPIO_A); + test_gpio_init_for_simulation(TEST_PCNT_GPIO_B); + + printf("install pcnt units\r\n"); + pcnt_unit_config_t unit_config = { + .low_limit = -100, + .high_limit = 100, + }; + pcnt_unit_handle_t units[2]; + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_new_unit(&unit_config, &units[i])); + } + + printf("install pcnt channels\r\n"); + const int channel_gpios[] = {TEST_PCNT_GPIO_A, TEST_PCNT_GPIO_B}; + pcnt_chan_config_t chan_config = { + .level_gpio_num = -1, + }; + pcnt_channel_handle_t chans[2]; + for (int i = 0; i < 2; i++) { + chan_config.edge_gpio_num = channel_gpios[i]; + TEST_ESP_OK(pcnt_new_channel(units[i], &chan_config, &chans[i])); + TEST_ESP_OK(pcnt_channel_set_edge_action(chans[i], PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD)); + TEST_ESP_OK(pcnt_channel_set_level_action(chans[i], PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_KEEP)); + } + + printf("enable and start unit\r\n"); + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_unit_enable(units[i])); + TEST_ESP_OK(pcnt_unit_start(units[i])); + } + + // trigger 10 rising edge on GPIO + test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_A, 10); + test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_B, 10); + + int count_value = 0; + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); + TEST_ASSERT_EQUAL(10, count_value); + } + + // hold GPIO to avoid trigger PCNT counter during GPIO power down + gpio_hold_en(TEST_PCNT_GPIO_A); + gpio_hold_en(TEST_PCNT_GPIO_B); + + printf("stop and disable unit before sleep\r\n"); + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_unit_stop(units[i])); + TEST_ESP_OK(pcnt_unit_disable(units[i])); + } + + // go to sleep + esp_sleep_context_t sleep_ctx; + esp_sleep_set_sleep_context(&sleep_ctx); + printf("go to light sleep for 1 seconds\r\n"); +#if ESP_SLEEP_POWER_DOWN_CPU + TEST_ESP_OK(sleep_cpu_configure(true)); +#endif + TEST_ESP_OK(esp_sleep_enable_timer_wakeup(1 * 1000 * 1000)); + TEST_ESP_OK(esp_light_sleep_start()); + + printf("Waked up! Let's see if PCNT driver can still work...\r\n"); +#if ESP_SLEEP_POWER_DOWN_CPU + TEST_ESP_OK(sleep_cpu_configure(false)); +#endif + + printf("check if the sleep happened as expected\r\n"); + TEST_ASSERT_EQUAL(0, sleep_ctx.sleep_request_result); +#if SOC_PCNT_SUPPORT_SLEEP_RETENTION + // check if the power domain also is powered down + TEST_ASSERT_EQUAL(0, (sleep_ctx.sleep_flags) & PMU_SLEEP_PD_TOP); +#endif + esp_sleep_set_sleep_context(NULL); + + gpio_hold_dis(TEST_PCNT_GPIO_A); + gpio_hold_dis(TEST_PCNT_GPIO_B); + + printf("enable and start unit after sleep\r\n"); + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_unit_enable(units[i])); + TEST_ESP_OK(pcnt_unit_start(units[i])); + } + + // Verify the counter still holds the value + test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_A, 10); + test_gpio_simulate_rising_edge(TEST_PCNT_GPIO_B, 10); + + int reg_value = 0; + for (int i = 0; i < 2; i++) { + // check the counter value (include accum value and register value) + TEST_ESP_OK(pcnt_unit_get_count(units[i], &count_value)); + TEST_ASSERT_EQUAL(20, count_value); + // check the register value + reg_value = pcnt_ll_get_count(&PCNT, i); + TEST_ASSERT_EQUAL(20, reg_value); + } + + for (int i = 0; i < 2; i++) { + TEST_ESP_OK(pcnt_unit_stop(units[i])); + TEST_ESP_OK(pcnt_unit_disable(units[i])); + TEST_ESP_OK(pcnt_del_channel(chans[i])); + TEST_ESP_OK(pcnt_del_unit(units[i])); + } +} + +TEST_CASE("pcnt light sleep", "[pcnt]") +{ + test_pcnt_sleep_retention(); +} diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.ci.release b/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.ci.release index 91d93f163e6..17aaee1e8ec 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.ci.release +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.ci.release @@ -1,5 +1,6 @@ CONFIG_PM_ENABLE=y CONFIG_FREERTOS_USE_TICKLESS_IDLE=y +CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y CONFIG_COMPILER_OPTIMIZATION_SIZE=y CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.defaults b/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.defaults index fa8ac618b94..488ad46859a 100644 --- a/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.defaults +++ b/components/esp_driver_pcnt/test_apps/pulse_cnt/sdkconfig.defaults @@ -1,2 +1,5 @@ CONFIG_FREERTOS_HZ=1000 CONFIG_ESP_TASK_WDT_EN=n + +# primitives for checking sleep internal state +CONFIG_ESP_SLEEP_DEBUG=y diff --git a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in index 70fab9c6755..e1ceec5368d 100644 --- a/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c5/include/soc/Kconfig.soc_caps.in @@ -767,6 +767,10 @@ config SOC_PCNT_SUPPORT_STEP_NOTIFY bool default y +config SOC_PCNT_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32c5/include/soc/retention_periph_defs.h b/components/soc/esp32c5/include/soc/retention_periph_defs.h index f65bfde5218..28f99fdbc46 100644 --- a/components/soc/esp32c5/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c5/include/soc/retention_periph_defs.h @@ -42,6 +42,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_PARLIO0 = 19, SLEEP_RETENTION_MODULE_GPSPI2 = 20, SLEEP_RETENTION_MODULE_LEDC = 21, + SLEEP_RETENTION_MODULE_PCNT0 = 22, /* modem module, which includes WiFi, BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_WIFI_MAC = 26, @@ -86,6 +87,7 @@ typedef enum periph_retention_module_bitmap { SLEEP_RETENTION_MODULE_BM_PARLIO0 = BIT(SLEEP_RETENTION_MODULE_PARLIO0), SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2), SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC), + SLEEP_RETENTION_MODULE_BM_PCNT0 = BIT(SLEEP_RETENTION_MODULE_PCNT0), SLEEP_RETENTION_MODULE_BM_GDMA_CH0 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH0), SLEEP_RETENTION_MODULE_BM_GDMA_CH1 = BIT(SLEEP_RETENTION_MODULE_GDMA_CH1), @@ -112,6 +114,7 @@ typedef enum periph_retention_module_bitmap { | SLEEP_RETENTION_MODULE_BM_PARLIO0 \ | SLEEP_RETENTION_MODULE_BM_GPSPI2 \ | SLEEP_RETENTION_MODULE_BM_LEDC \ + | SLEEP_RETENTION_MODULE_BM_PCNT0 \ ) #ifdef __cplusplus } diff --git a/components/soc/esp32c5/include/soc/soc_caps.h b/components/soc/esp32c5/include/soc/soc_caps.h index 7eb49628ea3..584cac7d542 100644 --- a/components/soc/esp32c5/include/soc/soc_caps.h +++ b/components/soc/esp32c5/include/soc/soc_caps.h @@ -322,6 +322,7 @@ #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 #define SOC_PCNT_SUPPORT_STEP_NOTIFY 1 +#define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up PCNT registers before sleep */ /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ diff --git a/components/soc/esp32c5/pcnt_periph.c b/components/soc/esp32c5/pcnt_periph.c index 162db5aa27b..c96644dae1d 100644 --- a/components/soc/esp32c5/pcnt_periph.c +++ b/components/soc/esp32c5/pcnt_periph.c @@ -6,6 +6,7 @@ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" +#include "soc/pcnt_reg.h" const pcnt_signal_conn_t pcnt_periph_signals = { .groups = { @@ -68,3 +69,31 @@ const pcnt_signal_conn_t pcnt_periph_signals = { } } }; + +/** + * PCNT Registers to be saved during sleep retention + * - Configuration registers, e.g.: PCNT_CTRL_REG, PCNT_U0_CONF0_REG, PCNT_U0_CONF1_REG, PCNT_U0_CONF2_REG, PCNT_U1_CONF0_REG... + * - Step Configuration registers, e.g.: PCNT_U0_CHANGE_CONF_REG, PCNT_U1_CHANGE_CONF_REG, PCNT_U2_CHANGE_CONF_REG, PCNT_U3_CHANGE_CONF_REG + * - Interrupt enable registers, e.g.: PCNT_INT_ENA_REG +*/ +#define PCNT_RETENTION_REGS_CNT 18 +#define PCNT_RETENTION_REGS_BASE (DR_REG_PCNT_BASE + 0x0) +static const uint32_t pcnt_regs_map[4] = {0x1f040fff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t pcnt_regs_retention[] = { + // backup stage: save configuration registers + // restore stage: restore the configuration registers + [0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_PCNT_LINK(0x00), \ + PCNT_RETENTION_REGS_BASE, PCNT_RETENTION_REGS_BASE, \ + PCNT_RETENTION_REGS_CNT, 0, 0, \ + pcnt_regs_map[0], pcnt_regs_map[1], \ + pcnt_regs_map[2], pcnt_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) }, \ +}; + +const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS] = { + [0] = { + .regdma_entry_array = pcnt_regs_retention, + .array_size = ARRAY_SIZE(pcnt_regs_retention), + .retention_module = SLEEP_RETENTION_MODULE_PCNT0 + }, +}; diff --git a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in index 84c3cd72b30..a7626d57a7d 100644 --- a/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c6/include/soc/Kconfig.soc_caps.in @@ -779,6 +779,10 @@ config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y +config SOC_PCNT_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32c6/include/soc/retention_periph_defs.h b/components/soc/esp32c6/include/soc/retention_periph_defs.h index 2b1854ecedb..6b828753537 100644 --- a/components/soc/esp32c6/include/soc/retention_periph_defs.h +++ b/components/soc/esp32c6/include/soc/retention_periph_defs.h @@ -44,6 +44,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_PARLIO0 = 21, SLEEP_RETENTION_MODULE_GPSPI2 = 22, SLEEP_RETENTION_MODULE_LEDC = 23, + SLEEP_RETENTION_MODULE_PCNT0 = 24, /* Modem module, which includes WiFi, BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_WIFI_MAC = 26, @@ -84,6 +85,7 @@ typedef enum periph_retention_module_bitmap { SLEEP_RETENTION_MODULE_BM_PARLIO0 = BIT(SLEEP_RETENTION_MODULE_PARLIO0), SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2), SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC), + SLEEP_RETENTION_MODULE_BM_PCNT0 = BIT(SLEEP_RETENTION_MODULE_PCNT0), /* modem module, which includes WiFi, BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_BM_WIFI_MAC = BIT(SLEEP_RETENTION_MODULE_WIFI_MAC), SLEEP_RETENTION_MODULE_BM_WIFI_BB = BIT(SLEEP_RETENTION_MODULE_WIFI_BB), @@ -114,6 +116,7 @@ typedef enum periph_retention_module_bitmap { | SLEEP_RETENTION_MODULE_BM_PARLIO0 \ | SLEEP_RETENTION_MODULE_BM_GPSPI2 \ | SLEEP_RETENTION_MODULE_BM_LEDC \ + | SLEEP_RETENTION_MODULE_BM_PCNT0 \ ) #ifdef __cplusplus diff --git a/components/soc/esp32c6/include/soc/soc_caps.h b/components/soc/esp32c6/include/soc/soc_caps.h index 948c1cd0f68..0750f12c3fb 100644 --- a/components/soc/esp32c6/include/soc/soc_caps.h +++ b/components/soc/esp32c6/include/soc/soc_caps.h @@ -308,6 +308,7 @@ #define SOC_PCNT_CHANNELS_PER_UNIT 2 #define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 +#define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up PCNT registers before sleep */ /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ diff --git a/components/soc/esp32c6/pcnt_periph.c b/components/soc/esp32c6/pcnt_periph.c index b2b440245b7..14c52fc0d62 100644 --- a/components/soc/esp32c6/pcnt_periph.c +++ b/components/soc/esp32c6/pcnt_periph.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" +#include "soc/pcnt_reg.h" const pcnt_signal_conn_t pcnt_periph_signals = { .groups = { @@ -64,3 +65,30 @@ const pcnt_signal_conn_t pcnt_periph_signals = { } } }; + +/** + * PCNT Registers to be saved during sleep retention + * - Configuration registers, e.g.: PCNT_CTRL_REG, PCNT_U0_CONF0_REG, PCNT_U0_CONF1_REG, PCNT_U0_CONF2_REG, PCNT_U1_CONF0_REG... + * - Interrupt enable registers, e.g.: PCNT_INT_ENA_REG +*/ +#define PCNT_RETENTION_REGS_CNT 14 +#define PCNT_RETENTION_REGS_BASE (DR_REG_PCNT_BASE + 0x0) +static const uint32_t pcnt_regs_map[4] = {0x1040fff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t pcnt_regs_retention[] = { + // backup stage: save configuration registers + // restore stage: restore the configuration registers + [0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_PCNT_LINK(0x00), \ + PCNT_RETENTION_REGS_BASE, PCNT_RETENTION_REGS_BASE, \ + PCNT_RETENTION_REGS_CNT, 0, 0, \ + pcnt_regs_map[0], pcnt_regs_map[1], \ + pcnt_regs_map[2], pcnt_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) }, \ +}; + +const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS] = { + [0] = { + .regdma_entry_array = pcnt_regs_retention, + .array_size = ARRAY_SIZE(pcnt_regs_retention), + .retention_module = SLEEP_RETENTION_MODULE_PCNT0 + }, +}; diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 72bfb1fa09c..f655023a994 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -763,6 +763,10 @@ config SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE bool default y +config SOC_PCNT_SUPPORT_SLEEP_RETENTION + bool + default y + config SOC_RMT_GROUPS int default 1 diff --git a/components/soc/esp32h2/include/soc/retention_periph_defs.h b/components/soc/esp32h2/include/soc/retention_periph_defs.h index 766db48639b..c22b47fb59d 100644 --- a/components/soc/esp32h2/include/soc/retention_periph_defs.h +++ b/components/soc/esp32h2/include/soc/retention_periph_defs.h @@ -44,6 +44,7 @@ typedef enum periph_retention_module { SLEEP_RETENTION_MODULE_PARLIO0 = 21, SLEEP_RETENTION_MODULE_GPSPI2 = 22, SLEEP_RETENTION_MODULE_LEDC = 23, + SLEEP_RETENTION_MODULE_PCNT0 = 24, /* Modem module, which includes BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_BLE_MAC = 28, @@ -82,6 +83,7 @@ typedef enum periph_retention_module_bitmap { SLEEP_RETENTION_MODULE_BM_PARLIO0 = BIT(SLEEP_RETENTION_MODULE_PARLIO0), SLEEP_RETENTION_MODULE_BM_GPSPI2 = BIT(SLEEP_RETENTION_MODULE_GPSPI2), SLEEP_RETENTION_MODULE_BM_LEDC = BIT(SLEEP_RETENTION_MODULE_LEDC), + SLEEP_RETENTION_MODULE_BM_PCNT0 = BIT(SLEEP_RETENTION_MODULE_PCNT0), /* modem module, which includes BLE and 802.15.4 */ SLEEP_RETENTION_MODULE_BM_BLE_MAC = BIT(SLEEP_RETENTION_MODULE_BLE_MAC), SLEEP_RETENTION_MODULE_BM_BT_BB = BIT(SLEEP_RETENTION_MODULE_BT_BB), @@ -110,6 +112,7 @@ typedef enum periph_retention_module_bitmap { | SLEEP_RETENTION_MODULE_BM_PARLIO0 \ | SLEEP_RETENTION_MODULE_BM_GPSPI2 \ | SLEEP_RETENTION_MODULE_BM_LEDC \ + | SLEEP_RETENTION_MODULE_BM_PCNT0 \ ) #ifdef __cplusplus diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 416f1106827..26252ef134d 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -302,6 +302,7 @@ #define SOC_PCNT_CHANNELS_PER_UNIT 2 #define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 +#define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 /*!< The sleep retention feature can help back up PCNT registers before sleep */ /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ diff --git a/components/soc/esp32h2/pcnt_periph.c b/components/soc/esp32h2/pcnt_periph.c index b2b440245b7..14c52fc0d62 100644 --- a/components/soc/esp32h2/pcnt_periph.c +++ b/components/soc/esp32h2/pcnt_periph.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" +#include "soc/pcnt_reg.h" const pcnt_signal_conn_t pcnt_periph_signals = { .groups = { @@ -64,3 +65,30 @@ const pcnt_signal_conn_t pcnt_periph_signals = { } } }; + +/** + * PCNT Registers to be saved during sleep retention + * - Configuration registers, e.g.: PCNT_CTRL_REG, PCNT_U0_CONF0_REG, PCNT_U0_CONF1_REG, PCNT_U0_CONF2_REG, PCNT_U1_CONF0_REG... + * - Interrupt enable registers, e.g.: PCNT_INT_ENA_REG +*/ +#define PCNT_RETENTION_REGS_CNT 14 +#define PCNT_RETENTION_REGS_BASE (DR_REG_PCNT_BASE + 0x0) +static const uint32_t pcnt_regs_map[4] = {0x1040fff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t pcnt_regs_retention[] = { + // backup stage: save configuration registers + // restore stage: restore the configuration registers + [0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_PCNT_LINK(0x00), \ + PCNT_RETENTION_REGS_BASE, PCNT_RETENTION_REGS_BASE, \ + PCNT_RETENTION_REGS_CNT, 0, 0, \ + pcnt_regs_map[0], pcnt_regs_map[1], \ + pcnt_regs_map[2], pcnt_regs_map[3]), \ + .owner = ENTRY(0) | ENTRY(2) }, \ +}; + +const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS] = { + [0] = { + .regdma_entry_array = pcnt_regs_retention, + .array_size = ARRAY_SIZE(pcnt_regs_retention), + .retention_module = SLEEP_RETENTION_MODULE_PCNT0 + }, +}; diff --git a/components/soc/esp32p4/include/soc/soc_caps.h b/components/soc/esp32p4/include/soc/soc_caps.h index 754ba908465..ee00d3083d7 100644 --- a/components/soc/esp32p4/include/soc/soc_caps.h +++ b/components/soc/esp32p4/include/soc/soc_caps.h @@ -408,6 +408,7 @@ #define SOC_PCNT_THRES_POINT_PER_UNIT 2 #define SOC_PCNT_SUPPORT_RUNTIME_THRES_UPDATE 1 #define SOC_PCNT_SUPPORT_CLEAR_SIGNAL 1 /*!< Support clear signal input */ +// #define SOC_PCNT_SUPPORT_SLEEP_RETENTION 1 // TODO: IDF-9907 Waiting for expansion of module ID /*!< The sleep retention feature can help back up PCNT registers before sleep */ /*--------------------------- RMT CAPS ---------------------------------------*/ #define SOC_RMT_GROUPS 1U /*!< One RMT group */ diff --git a/components/soc/esp32p4/pcnt_periph.c b/components/soc/esp32p4/pcnt_periph.c index ae7d32b2fe8..4b1cbcac5c6 100644 --- a/components/soc/esp32p4/pcnt_periph.c +++ b/components/soc/esp32p4/pcnt_periph.c @@ -1,11 +1,12 @@ /* - * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ #include "soc/pcnt_periph.h" #include "soc/gpio_sig_map.h" +#include "soc/pcnt_reg.h" const pcnt_signal_conn_t pcnt_periph_signals = { .groups = { @@ -68,3 +69,33 @@ const pcnt_signal_conn_t pcnt_periph_signals = { } } }; + +#if SOC_PCNT_SUPPORT_SLEEP_RETENTION +/** + * PCNT Registers to be saved during sleep retention + * - Configuration registers, e.g.: PCNT_CTRL_REG, PCNT_U0_CONF0_REG, PCNT_U0_CONF1_REG, PCNT_U0_CONF2_REG, PCNT_U1_CONF0_REG... + * - Step Configuration registers, e.g.: PCNT_U0_CHANGE_CONF_REG, PCNT_U1_CHANGE_CONF_REG, PCNT_U2_CHANGE_CONF_REG, PCNT_U3_CHANGE_CONF_REG + * - Interrupt enable registers, e.g.: PCNT_INT_ENA_REG +*/ +#define PCNT_RETENTION_REGS_CNT 18 +#define PCNT_RETENTION_REGS_BASE (DR_REG_PCNT_BASE + 0x0) +static const uint32_t pcnt_regs_map[4] = {0x1f040fff, 0x0, 0x0, 0x0}; +static const regdma_entries_config_t pcnt_regs_retention[] = { + // backup stage: save configuration registers + // restore stage: restore the configuration registers + [0] = { .config = REGDMA_LINK_ADDR_MAP_INIT(REGDMA_PCNT_LINK(0x00), \ + PCNT_RETENTION_REGS_BASE, PCNT_RETENTION_REGS_BASE, \ + PCNT_RETENTION_REGS_CNT, 0, 0, \ + pcnt_regs_map[0], pcnt_regs_map[1], \ + pcnt_regs_map[2], pcnt_regs_map[3]), \ + .owner = ENTRY(0)}, \ +}; + +const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS] = { + [0] = { + .regdma_entry_array = pcnt_regs_retention, + .array_size = ARRAY_SIZE(pcnt_regs_retention), + .retention_module = SLEEP_RETENTION_MODULE_PCNT0 + }, +}; +#endif // SOC_PCNT_SUPPORT_SLEEP_RETENTION diff --git a/components/soc/include/soc/pcnt_periph.h b/components/soc/include/soc/pcnt_periph.h index e7d8818b090..a060af597fe 100644 --- a/components/soc/include/soc/pcnt_periph.h +++ b/components/soc/include/soc/pcnt_periph.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2019-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -9,6 +9,10 @@ #include #include "soc/soc_caps.h" #include "soc/periph_defs.h" +#include "soc/regdma.h" +#if SOC_PCNT_SUPPORT_SLEEP_RETENTION +#include "soc/retention_periph_defs.h" +#endif #ifdef __cplusplus extern "C" { @@ -31,6 +35,16 @@ typedef struct { extern const pcnt_signal_conn_t pcnt_periph_signals; +#if SOC_PCNT_SUPPORT_SLEEP_RETENTION +typedef struct { + const periph_retention_module_t retention_module; + const regdma_entries_config_t *regdma_entry_array; + uint32_t array_size; +} pcnt_reg_retention_info_t; + +extern const pcnt_reg_retention_info_t pcnt_reg_retention_info[SOC_PCNT_GROUPS]; +#endif // SOC_PCNT_SUPPORT_SLEEP_RETENTION + #endif // SOC_PCNT_SUPPORTED #ifdef __cplusplus diff --git a/components/soc/include/soc/regdma.h b/components/soc/include/soc/regdma.h index 44a116119f9..7ee06f0095b 100644 --- a/components/soc/include/soc/regdma.h +++ b/components/soc/include/soc/regdma.h @@ -60,6 +60,7 @@ extern "C" { #define REGDMA_PARLIO_LINK(_pri) ((0x22 << 8) | _pri) #define REGDMA_GPSPI_LINK(_pri) ((0x23 << 8) | _pri) #define REGDMA_LEDC_LINK(_pri) ((0x24 << 8) | _pri) +#define REGDMA_PCNT_LINK(_pri) ((0x25 << 8) | _pri) #define REGDMA_MODEM_FE_LINK(_pri) ((0xFF << 8) | _pri) #define REGDMA_LINK_PRI_SYS_CLK REGDMA_LINK_PRI_0 @@ -79,6 +80,7 @@ extern "C" { #define REGDMA_LINK_PRI_I2C REGDMA_LINK_PRI_GENERAL_PERIPH #define REGDMA_LINK_PRI_I2S REGDMA_LINK_PRI_GENERAL_PERIPH #define REGDMA_LINK_PRI_PARLIO REGDMA_LINK_PRI_GENERAL_PERIPH +#define REGDMA_LINK_PRI_PCNT REGDMA_LINK_PRI_GENERAL_PERIPH #define REGDMA_LINK_PRI_UART REGDMA_LINK_PRI_GENERAL_PERIPH #define REGDMA_LINK_PRI_TEMPERATURE_SENSOR REGDMA_LINK_PRI_GENERAL_PERIPH #define REGDMA_LINK_PRI_TWAI REGDMA_LINK_PRI_GENERAL_PERIPH From dd8c5454230e5deb643da1950dd84d8c133418b2 Mon Sep 17 00:00:00 2001 From: Chen Jichang Date: Thu, 24 Oct 2024 21:56:21 +0800 Subject: [PATCH 43/70] fix(mcpwm): add warning about generator deadtime Closes https://github.com/espressif/esp-idf/issues/14773 --- components/esp_driver_mcpwm/src/mcpwm_gen.c | 4 ++++ docs/en/api-reference/peripherals/mcpwm.rst | 2 +- docs/zh_CN/api-reference/peripherals/mcpwm.rst | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/components/esp_driver_mcpwm/src/mcpwm_gen.c b/components/esp_driver_mcpwm/src/mcpwm_gen.c index 2c145e8bea4..85ca5cb8f2b 100644 --- a/components/esp_driver_mcpwm/src/mcpwm_gen.c +++ b/components/esp_driver_mcpwm/src/mcpwm_gen.c @@ -405,6 +405,10 @@ esp_err_t mcpwm_generator_set_dead_time(mcpwm_gen_handle_t in_generator, mcpwm_g mcpwm_ll_deadtime_set_falling_delay(hal->dev, oper_id, config->negedge_delay_ticks); } + if (delay_on_both_edge && in_generator->gen_id == 0 && oper->generators[1]) { + ESP_LOGW(TAG, "generator B will not function correctly. To set deadtime on both edges for one generator while bypassing the deadtime for the other, please set the deadtime for generator B only."); + } + ESP_LOGD(TAG, "operator (%d,%d) dead time (R:%"PRIu32",F:%"PRIu32"), topology code:%"PRIx32, group->group_id, oper_id, config->posedge_delay_ticks, config->negedge_delay_ticks, mcpwm_ll_deadtime_get_switch_topology(hal->dev, oper_id)); return ESP_OK; diff --git a/docs/en/api-reference/peripherals/mcpwm.rst b/docs/en/api-reference/peripherals/mcpwm.rst index a7d1ae5ba42..7e80c519c56 100644 --- a/docs/en/api-reference/peripherals/mcpwm.rst +++ b/docs/en/api-reference/peripherals/mcpwm.rst @@ -523,7 +523,7 @@ Dead time specific configuration is listed in the :cpp:type:`mcpwm_dead_time_con // NOTE: This is invalid, you can not apply the posedge delay to another generator mcpwm_generator_set_dead_time(mcpwm_gen_b, mcpwm_gen_b, &dt_config); - However, you can apply ``posedge delay`` to generator A and ``negedge delay`` to generator B. You can also set both ``posedge delay`` and ``negedge delay`` for generator A, while letting generator B bypass the dead time module. + However, you can apply ``posedge delay`` to generator A and ``negedge delay`` to generator B. You can also set both ``posedge delay`` and ``negedge delay`` for generator B, while letting generator A bypass the dead time module. Note that if ``negedge delay`` and ``posedge delay`` are both set for generator A, generator B will not be available. Where generator A is the first generator requested through the operator handle and generator B is the second generator requested through an operator handle. .. note:: diff --git a/docs/zh_CN/api-reference/peripherals/mcpwm.rst b/docs/zh_CN/api-reference/peripherals/mcpwm.rst index 9aaaa22bb46..78f29d6983c 100644 --- a/docs/zh_CN/api-reference/peripherals/mcpwm.rst +++ b/docs/zh_CN/api-reference/peripherals/mcpwm.rst @@ -523,7 +523,7 @@ MCPWM 比较器可以在定时器计数器等于比较值时发送通知。若 // NOTE: 下面的操作是无效的,不能将同一种 delay 应用于不同的 generator 上 mcpwm_generator_set_dead_time(mcpwm_gen_b, mcpwm_gen_b, &dt_config); - 然而,你可以为生成器 A 设置 ``posedge delay``,为生成器 B 设置 ``negedge delay``。另外,也可以为生成器 A 同时设置 ``posedge delay`` 和 ``negedge delay``,而让生成器 B 绕过死区模块。 + 然而,你可以为生成器 A 设置 ``posedge delay``,为生成器 B 设置 ``negedge delay``。另外,也可以为生成器 B 同时设置 ``posedge delay`` 和 ``negedge delay``,而让生成器 A 绕过死区模块。注意,如果对生成器 A 同时设置 ``negedge delay`` 和 ``posedge delay``,生成器 B 将无法正常工作。其中,生成器 A 为通过操作器句柄申请的第一个生成器,生成器 B 为通过操作器句柄申请的第二个生成器。 .. note:: From a2be2ffe5a5f8fb32895f528cd98c35d490f3428 Mon Sep 17 00:00:00 2001 From: wanckl Date: Wed, 23 Oct 2024 18:59:53 +0800 Subject: [PATCH 44/70] fix(driver_spi): fixed p4 no dma polling trans cache sync fail --- components/esp_driver_spi/src/gpspi/spi_master.c | 2 +- .../esp_driver_spi/test_apps/master/main/test_spi_master.c | 2 -- .../esp_driver_spi/test_apps/param/main/test_spi_param.c | 2 +- .../esp_driver_spi/test_apps/slave/main/test_spi_slave.c | 4 ++-- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/components/esp_driver_spi/src/gpspi/spi_master.c b/components/esp_driver_spi/src/gpspi/spi_master.c index 7237a0edebc..b447b40a5f0 100644 --- a/components/esp_driver_spi/src/gpspi/spi_master.c +++ b/components/esp_driver_spi/src/gpspi/spi_master.c @@ -1415,7 +1415,7 @@ esp_err_t SPI_MASTER_ISR_ATTR spi_device_polling_end(spi_device_handle_t handle, #if SOC_CACHE_INTERNAL_MEM_VIA_L1CACHE //invalidate here to let user access rx data in post_cb if possible const spi_bus_attr_t *bus_attr = host->bus_attr; - if (host->cur_trans_buf.buffer_to_rcv) { + if (bus_attr->dma_enabled && host->cur_trans_buf.buffer_to_rcv) { uint16_t alignment = bus_attr->internal_mem_align_size; uint32_t buffer_byte_len = (host->cur_trans_buf.trans->rxlength + 7) / 8; buffer_byte_len = (buffer_byte_len + alignment - 1) & (~(alignment - 1)); diff --git a/components/esp_driver_spi/test_apps/master/main/test_spi_master.c b/components/esp_driver_spi/test_apps/master/main/test_spi_master.c index d08e8996bd7..f3d284d69e7 100644 --- a/components/esp_driver_spi/test_apps/master/main/test_spi_master.c +++ b/components/esp_driver_spi/test_apps/master/main/test_spi_master.c @@ -1856,7 +1856,6 @@ TEST_CASE("test_spi_master_sleep_retention", "[spi]") #endif } -#if 0 /* Temp disable, TODO: IDFCI-2455*/ #if CONFIG_PM_ENABLE TEST_CASE("test_spi_master_auto_sleep_retention", "[spi]") { @@ -1922,4 +1921,3 @@ TEST_CASE("test_spi_master_auto_sleep_retention", "[spi]") TEST_ESP_OK(esp_pm_configure(&pm_config)); } #endif //CONFIG_PM_ENABLE -#endif // 0 diff --git a/components/esp_driver_spi/test_apps/param/main/test_spi_param.c b/components/esp_driver_spi/test_apps/param/main/test_spi_param.c index 71506acb752..7f507a549b9 100644 --- a/components/esp_driver_spi/test_apps/param/main/test_spi_param.c +++ b/components/esp_driver_spi/test_apps/param/main/test_spi_param.c @@ -1438,7 +1438,7 @@ static void test_master_fd_no_dma(void) .length = test_trans_len * 8, }; unity_wait_for_signal("Slave ready"); - TEST_ESP_OK(spi_device_transmit(dev0, &trans_cfg)); + TEST_ESP_OK(spi_device_polling_transmit(dev0, &trans_cfg)); ESP_LOG_BUFFER_HEX("master tx", master_send, test_trans_len); ESP_LOG_BUFFER_HEX_LEVEL("master rx", master_receive, test_trans_len, ESP_LOG_DEBUG); diff --git a/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c b/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c index 46537168210..f5634dbba91 100644 --- a/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c +++ b/components/esp_driver_spi/test_apps/slave/main/test_spi_slave.c @@ -162,7 +162,7 @@ TEST_CASE("Test slave rx no_dma overwrite when length below/over config", "[spi] .length = 8 * 7, .tx_buffer = master_tx, }; - spi_device_transmit(spidev0, &master_tans); + spi_device_polling_transmit(spidev0, &master_tans); TEST_ESP_OK(spi_slave_get_trans_result(TEST_SLAVE_HOST, &slave_out, portMAX_DELAY)); @@ -181,7 +181,7 @@ TEST_CASE("Test slave rx no_dma overwrite when length below/over config", "[spi] TEST_ESP_OK(spi_slave_queue_trans(TEST_SLAVE_HOST, &slave_tans, portMAX_DELAY)); master_tans.length = 8 * 11, - spi_device_transmit(spidev0, &master_tans); + spi_device_polling_transmit(spidev0, &master_tans); TEST_ESP_OK(spi_slave_get_trans_result(TEST_SLAVE_HOST, &slave_out, portMAX_DELAY)); From 908e1e670a4475008b257076098dedb4e0b5c398 Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Mon, 23 Sep 2024 17:38:05 +0800 Subject: [PATCH 45/70] test(bootloader_support): enable analog super wdt reset for the ESP32-C61 --- components/bootloader_support/src/esp32c61/bootloader_soc.c | 2 +- components/bootloader_support/test_apps/.build-test-rules.yml | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/components/bootloader_support/src/esp32c61/bootloader_soc.c b/components/bootloader_support/src/esp32c61/bootloader_soc.c index 055fe372bdd..ef415ace135 100644 --- a/components/bootloader_support/src/esp32c61/bootloader_soc.c +++ b/components/bootloader_support/src/esp32c61/bootloader_soc.c @@ -11,9 +11,9 @@ #include "hal/regi2c_ctrl.h" #include "soc/regi2c_saradc.h" -//Not supported but common bootloader calls the function. Do nothing void bootloader_ana_clock_glitch_reset_config(bool enable) { + // TODO: IDF-9274 (void)enable; } diff --git a/components/bootloader_support/test_apps/.build-test-rules.yml b/components/bootloader_support/test_apps/.build-test-rules.yml index 859b46f7aa5..1dbe91f9132 100644 --- a/components/bootloader_support/test_apps/.build-test-rules.yml +++ b/components/bootloader_support/test_apps/.build-test-rules.yml @@ -4,7 +4,3 @@ components/bootloader_support/test_apps/rtc_custom_section: enable: - if: SOC_RTC_MEM_SUPPORTED == 1 reason: this feature is supported on chips that have RTC memory - disable: - - if: IDF_TARGET == "esp32c61" - temporary: true - reason: IDF-9260 From 61a7ecd145ce8a0582cc81223a569414ed7fc370 Mon Sep 17 00:00:00 2001 From: zwx Date: Tue, 29 Oct 2024 20:36:39 +0800 Subject: [PATCH 46/70] fix(openthread): set channel for energy scan --- components/ieee802154/include/esp_ieee802154_types.h | 2 ++ components/openthread/src/port/esp_openthread_radio.c | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/components/ieee802154/include/esp_ieee802154_types.h b/components/ieee802154/include/esp_ieee802154_types.h index 0b83cf2eed5..8c551f75526 100644 --- a/components/ieee802154/include/esp_ieee802154_types.h +++ b/components/ieee802154/include/esp_ieee802154_types.h @@ -9,6 +9,8 @@ #include #include +#define US_PER_SYMBLE 16 + #ifdef __cplusplus extern "C" { #endif diff --git a/components/openthread/src/port/esp_openthread_radio.c b/components/openthread/src/port/esp_openthread_radio.c index 3e0f4286fe1..f87cb682914 100644 --- a/components/openthread/src/port/esp_openthread_radio.c +++ b/components/openthread/src/port/esp_openthread_radio.c @@ -412,7 +412,8 @@ void otPlatRadioClearSrcMatchExtEntries(otInstance *aInstance) otError otPlatRadioEnergyScan(otInstance *aInstance, uint8_t aScanChannel, uint16_t aScanDuration) { - esp_ieee802154_energy_detect(aScanDuration); + esp_ieee802154_set_channel(aScanChannel); + esp_ieee802154_energy_detect(aScanDuration * US_PER_MS / US_PER_SYMBLE); return OT_ERROR_NONE; } From 034a35a66f09cb009abf691b19916ca2c75562ac Mon Sep 17 00:00:00 2001 From: gongyantao Date: Fri, 25 Oct 2024 11:16:11 +0800 Subject: [PATCH 47/70] fix(bt): fix some issues in bt controller 1: Store local device name into NVDS when handling hci_wr_local_name_cmd. 2: Set default device name during link manager initialization. 3: Set the QoS value to the minimum value if the calculated QoS is less than the minumum. --- components/bt/controller/lib_esp32 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/lib_esp32 b/components/bt/controller/lib_esp32 index 171c4a7653d..5c4a62c1d45 160000 --- a/components/bt/controller/lib_esp32 +++ b/components/bt/controller/lib_esp32 @@ -1 +1 @@ -Subproject commit 171c4a7653d2ef56edecaa832bdd4faedd403d77 +Subproject commit 5c4a62c1d4577d1352d28708c790ba2b4f741842 From 460233ee3bde5e2b808e1da064a5e90ef75836ad Mon Sep 17 00:00:00 2001 From: wanckl Date: Mon, 30 Sep 2024 16:57:34 +0800 Subject: [PATCH 48/70] fix(driver_twai): fixed bus-off when twai_init due to wrong gpio config Closes https://github.com/espressif/esp-idf/issues/14548 --- components/driver/twai/twai.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/components/driver/twai/twai.c b/components/driver/twai/twai.c index 0878239115a..345f2ae3ae7 100644 --- a/components/driver/twai/twai.c +++ b/components/driver/twai/twai.c @@ -18,14 +18,14 @@ #include "esp_heap_caps.h" #include "esp_clk_tree.h" #include "clk_ctrl_os.h" -#include "driver/gpio.h" #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" +#include "esp_private/gpio.h" #include "driver/twai.h" #include "soc/soc_caps.h" #include "soc/soc.h" +#include "soc/io_mux_reg.h" #include "soc/twai_periph.h" -#include "soc/gpio_sig_map.h" #include "hal/twai_hal.h" #include "esp_rom_gpio.h" #if SOC_TWAI_SUPPORT_SLEEP_RETENTION @@ -289,37 +289,30 @@ static void twai_configure_gpio(int controller_id, gpio_num_t tx, gpio_num_t rx, { // assert the GPIO number is not a negative number (shift operation on a negative number is undefined) assert(tx >= 0 && rx >= 0); - // if TX and RX set to the same GPIO, which means we want to create a loop-back in the GPIO matrix - bool io_loop_back = (tx == rx); - gpio_config_t gpio_conf = { - .intr_type = GPIO_INTR_DISABLE, - .pull_down_en = false, - .pull_up_en = false, - }; + //Set RX pin - gpio_conf.mode = GPIO_MODE_INPUT | (io_loop_back ? GPIO_MODE_OUTPUT : 0); - gpio_conf.pin_bit_mask = 1ULL << rx; - gpio_config(&gpio_conf); + gpio_func_sel(rx, PIN_FUNC_GPIO); + gpio_set_pull_mode(rx, GPIO_FLOATING); + gpio_input_enable(rx); esp_rom_gpio_connect_in_signal(rx, twai_controller_periph_signals.controllers[controller_id].rx_sig, false); //Set TX pin - gpio_conf.mode = GPIO_MODE_OUTPUT | (io_loop_back ? GPIO_MODE_INPUT : 0); - gpio_conf.pin_bit_mask = 1ULL << tx; - gpio_config(&gpio_conf); + gpio_func_sel(tx, PIN_FUNC_GPIO); + gpio_set_pull_mode(tx, GPIO_FLOATING); esp_rom_gpio_connect_out_signal(tx, twai_controller_periph_signals.controllers[controller_id].tx_sig, false, false); //Configure output clock pin (Optional) if (clkout >= 0 && clkout < GPIO_NUM_MAX) { gpio_set_pull_mode(clkout, GPIO_FLOATING); + gpio_func_sel(clkout, PIN_FUNC_GPIO); esp_rom_gpio_connect_out_signal(clkout, twai_controller_periph_signals.controllers[controller_id].clk_out_sig, false, false); - esp_rom_gpio_pad_select_gpio(clkout); } //Configure bus status pin (Optional) if (bus_status >= 0 && bus_status < GPIO_NUM_MAX) { gpio_set_pull_mode(bus_status, GPIO_FLOATING); + gpio_func_sel(bus_status, PIN_FUNC_GPIO); esp_rom_gpio_connect_out_signal(bus_status, twai_controller_periph_signals.controllers[controller_id].bus_off_sig, false, false); - esp_rom_gpio_pad_select_gpio(bus_status); } } From b64e2ebfc9c19fc42233793eacabd1722a148189 Mon Sep 17 00:00:00 2001 From: wanckl Date: Thu, 17 Oct 2024 15:25:57 +0800 Subject: [PATCH 49/70] feat(twai): support gpio reserve check --- components/driver/twai/twai.c | 80 +++++++++++++++++++++++++---------- 1 file changed, 58 insertions(+), 22 deletions(-) diff --git a/components/driver/twai/twai.c b/components/driver/twai/twai.c index 345f2ae3ae7..274a785133c 100644 --- a/components/driver/twai/twai.c +++ b/components/driver/twai/twai.c @@ -21,6 +21,7 @@ #include "esp_private/periph_ctrl.h" #include "esp_private/esp_clk.h" #include "esp_private/gpio.h" +#include "esp_private/esp_gpio_reserve.h" #include "driver/twai.h" #include "soc/soc_caps.h" #include "soc/soc.h" @@ -34,6 +35,7 @@ /* ---------------------------- Definitions --------------------------------- */ //Internal Macros +#define TWAI_TAG "TWAI" #define TWAI_CHECK(cond, ret_val) ({ \ if (!(cond)) { \ return (ret_val); \ @@ -46,7 +48,6 @@ #ifdef CONFIG_TWAI_ISR_IN_IRAM #define TWAI_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) #else -#define TWAI_TAG "TWAI" #define TWAI_MALLOC_CAPS MALLOC_CAP_DEFAULT #endif //CONFIG_TWAI_ISR_IN_IRAM @@ -74,6 +75,10 @@ //Control structure for TWAI driver typedef struct twai_obj_t { int controller_id; + gpio_num_t tx_io; + gpio_num_t rx_io; + gpio_num_t clkout_io; + gpio_num_t bus_off_io; twai_hal_context_t hal; // hal context //Control and status members twai_state_t state; @@ -285,37 +290,61 @@ static void twai_intr_handler_main(void *arg) /* -------------------------- Helper functions ----------------------------- */ -static void twai_configure_gpio(int controller_id, gpio_num_t tx, gpio_num_t rx, gpio_num_t clkout, gpio_num_t bus_status) +static void twai_configure_gpio(twai_obj_t *p_obj) { - // assert the GPIO number is not a negative number (shift operation on a negative number is undefined) - assert(tx >= 0 && rx >= 0); + uint8_t controller_id = p_obj->controller_id; + uint64_t gpio_mask = BIT64(p_obj->tx_io); //Set RX pin - gpio_func_sel(rx, PIN_FUNC_GPIO); - gpio_set_pull_mode(rx, GPIO_FLOATING); - gpio_input_enable(rx); - esp_rom_gpio_connect_in_signal(rx, twai_controller_periph_signals.controllers[controller_id].rx_sig, false); + gpio_func_sel(p_obj->rx_io, PIN_FUNC_GPIO); + gpio_input_enable(p_obj->rx_io); + esp_rom_gpio_connect_in_signal(p_obj->rx_io, twai_controller_periph_signals.controllers[controller_id].rx_sig, false); //Set TX pin - gpio_func_sel(tx, PIN_FUNC_GPIO); - gpio_set_pull_mode(tx, GPIO_FLOATING); - esp_rom_gpio_connect_out_signal(tx, twai_controller_periph_signals.controllers[controller_id].tx_sig, false, false); + gpio_func_sel(p_obj->tx_io, PIN_FUNC_GPIO); + esp_rom_gpio_connect_out_signal(p_obj->tx_io, twai_controller_periph_signals.controllers[controller_id].tx_sig, false, false); //Configure output clock pin (Optional) - if (clkout >= 0 && clkout < GPIO_NUM_MAX) { - gpio_set_pull_mode(clkout, GPIO_FLOATING); - gpio_func_sel(clkout, PIN_FUNC_GPIO); - esp_rom_gpio_connect_out_signal(clkout, twai_controller_periph_signals.controllers[controller_id].clk_out_sig, false, false); + if (GPIO_IS_VALID_OUTPUT_GPIO(p_obj->clkout_io)) { + gpio_mask |= BIT64(p_obj->clkout_io); + gpio_func_sel(p_obj->clkout_io, PIN_FUNC_GPIO); + esp_rom_gpio_connect_out_signal(p_obj->clkout_io, twai_controller_periph_signals.controllers[controller_id].clk_out_sig, false, false); } //Configure bus status pin (Optional) - if (bus_status >= 0 && bus_status < GPIO_NUM_MAX) { - gpio_set_pull_mode(bus_status, GPIO_FLOATING); - gpio_func_sel(bus_status, PIN_FUNC_GPIO); - esp_rom_gpio_connect_out_signal(bus_status, twai_controller_periph_signals.controllers[controller_id].bus_off_sig, false, false); + if (GPIO_IS_VALID_OUTPUT_GPIO(p_obj->bus_off_io)) { + gpio_mask |= BIT64(p_obj->bus_off_io); + gpio_func_sel(p_obj->bus_off_io, PIN_FUNC_GPIO); + esp_rom_gpio_connect_out_signal(p_obj->bus_off_io, twai_controller_periph_signals.controllers[controller_id].bus_off_sig, false, false); + } + + uint64_t busy_mask = esp_gpio_reserve(gpio_mask); + uint64_t conflict_mask = busy_mask & gpio_mask; + for (; conflict_mask > 0;) { + uint8_t pos = __builtin_ctz(conflict_mask); + conflict_mask &= ~(1 << pos); + ESP_LOGW(TWAI_TAG, "GPIO %d is not usable, maybe used by others", pos); } } +static void twai_release_gpio(twai_obj_t *p_obj) +{ + assert(p_obj); + uint64_t gpio_mask = BIT64(p_obj->tx_io); + + esp_rom_gpio_connect_in_signal(GPIO_MATRIX_CONST_ONE_INPUT, twai_controller_periph_signals.controllers[p_obj->controller_id].rx_sig, false); + gpio_output_disable(p_obj->tx_io); + if (GPIO_IS_VALID_OUTPUT_GPIO(p_obj->clkout_io)) { + gpio_mask |= BIT64(p_obj->clkout_io); + gpio_output_disable(p_obj->clkout_io); + } + if (GPIO_IS_VALID_OUTPUT_GPIO(p_obj->bus_off_io)) { + gpio_mask |= BIT64(p_obj->bus_off_io); + gpio_output_disable(p_obj->bus_off_io); + } + esp_gpio_revoke(gpio_mask); +} + static void twai_free_driver_obj(twai_obj_t *p_obj) { //Free driver object and any dependent SW resources it uses (queues, semaphores, interrupts, PM locks etc) @@ -442,6 +471,7 @@ esp_err_t twai_driver_install_v2(const twai_general_config_t *g_config, const tw TWAI_CHECK(f_config != NULL, ESP_ERR_INVALID_ARG); TWAI_CHECK(g_config->controller_id < SOC_TWAI_CONTROLLER_NUM, ESP_ERR_INVALID_ARG); TWAI_CHECK(g_config->rx_queue_len > 0, ESP_ERR_INVALID_ARG); + // assert the GPIO number is not a negative number (shift operation on a negative number is undefined) TWAI_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(g_config->tx_io), ESP_ERR_INVALID_ARG); TWAI_CHECK(GPIO_IS_VALID_GPIO(g_config->rx_io), ESP_ERR_INVALID_ARG); #ifndef CONFIG_TWAI_ISR_IN_IRAM @@ -484,6 +514,10 @@ esp_err_t twai_driver_install_v2(const twai_general_config_t *g_config, const tw p_twai_obj->state = TWAI_STATE_STOPPED; p_twai_obj->mode = g_config->mode; p_twai_obj->alerts_enabled = g_config->alerts_enabled; + p_twai_obj->tx_io = g_config->tx_io; + p_twai_obj->rx_io = g_config->rx_io; + p_twai_obj->clkout_io = g_config->clkout_io; + p_twai_obj->bus_off_io = g_config->bus_off_io; //Assign the TWAI object portENTER_CRITICAL(&g_spinlock); @@ -518,7 +552,7 @@ esp_err_t twai_driver_install_v2(const twai_general_config_t *g_config, const tw twai_hal_configure(&p_twai_obj->hal, t_config, f_config, DRIVER_DEFAULT_INTERRUPTS, g_config->clkout_divider); //Assign GPIO and Interrupts - twai_configure_gpio(controller_id, g_config->tx_io, g_config->rx_io, g_config->clkout_io, g_config->bus_off_io); + twai_configure_gpio(p_twai_obj); #if CONFIG_PM_ENABLE //Acquire PM lock @@ -566,6 +600,9 @@ esp_err_t twai_driver_uninstall_v2(twai_handle_t handle) g_twai_objs[controller_id] = NULL; portEXIT_CRITICAL(&g_spinlock); + //Disable interrupt + ESP_ERROR_CHECK(esp_intr_disable(p_twai_obj->isr_handle)); + //Clear registers by reading twai_hal_deinit(&p_twai_obj->hal); TWAI_PERI_ATOMIC() { @@ -582,8 +619,7 @@ esp_err_t twai_driver_uninstall_v2(twai_handle_t handle) } #endif //CONFIG_PM_ENABLE - //Disable interrupt - ESP_ERROR_CHECK(esp_intr_disable(p_twai_obj->isr_handle)); + twai_release_gpio(p_twai_obj); //Free twai driver object twai_free_driver_obj(p_twai_obj); return ESP_OK; From f7da0175b09754e086a688c638d4f2eadabd5e16 Mon Sep 17 00:00:00 2001 From: Tomas Rezucha Date: Tue, 29 Oct 2024 12:01:11 +0100 Subject: [PATCH 50/70] docs(usb_host): Update usb_host example READMEs for P4 Closes https://github.com/espressif/esp-idf/issues/14578 Closes https://github.com/espressif/esp-idf/issues/12142 --- examples/peripherals/usb/README.md | 7 +++++-- .../usb/host/cdc/cdc_acm_host/README.md | 5 ++--- .../usb/host/cdc/cdc_acm_vcp/README.md | 12 +++++------- examples/peripherals/usb/host/hid/README.md | 15 ++------------- examples/peripherals/usb/host/msc/README.md | 16 +++------------- .../peripherals/usb/host/usb_host_lib/README.md | 7 ++----- examples/peripherals/usb/host/uvc/README.md | 4 +++- 7 files changed, 22 insertions(+), 44 deletions(-) diff --git a/examples/peripherals/usb/README.md b/examples/peripherals/usb/README.md index 2d23a497d73..c25ec63e52a 100644 --- a/examples/peripherals/usb/README.md +++ b/examples/peripherals/usb/README.md @@ -1,10 +1,10 @@ # USB-OTG Examples -See the [README.md](../README.md) file in the upper level [examples](../) directory for more information about examples. +See the [README.md](../../README.md) file in the upper level [examples](../../) directory for more information about examples. ## Common Pin Assignments -Pin assignment is only needed for ESP chips that have an USB-OTG peripheral. +Pin assignment is only needed for ESP chips that have a USB-OTG peripheral. If your board doesn't have a USB connector connected to the USB-OTG dedicated GPIOs, you may have to DIY a cable and connect **D+** and **D-** to the pins listed below. ``` @@ -21,3 +21,6 @@ Refer to `soc/usb_pins.h` to find the real GPIO number of **USBPHY_DP_NUM** and | | USB_DP | USB_DM | | ----------- | ------ | ------ | | ESP32-S2/S3 | GPIO20 | GPIO19 | +| ESP32-P4 | pin 51 | pin 50 | + +> Note: On the ESP32-P4, the USB 2.0 PHY pins are dedicated to USB-OTG functionality and cannot be used as general-purpose GPIOs. diff --git a/examples/peripherals/usb/host/cdc/cdc_acm_host/README.md b/examples/peripherals/usb/host/cdc/cdc_acm_host/README.md index 8f1d6652ff2..504c16e5494 100644 --- a/examples/peripherals/usb/host/cdc/cdc_acm_host/README.md +++ b/examples/peripherals/usb/host/cdc/cdc_acm_host/README.md @@ -11,12 +11,11 @@ This example shows how to use the CDC-ACM Host Driver to allow an ESP chip to co ### Hardware Required -Two ESP boards that have USB-OTG supported. One will act as USB host and the other as USB device. -Connect USB_D+, USB_D-, GND and +5V signals of USB host to USB device. +Two development boards with USB-OTG support. One will act as USB host and the other as USB device. #### Pin Assignment -See common pin assignments for USB Device examples from [upper level](../../../README.md#common-pin-assignments). +Follow instruction in [examples/usb/README.md](../../../README.md) for specific hardware setup. ### Build and Flash diff --git a/examples/peripherals/usb/host/cdc/cdc_acm_vcp/README.md b/examples/peripherals/usb/host/cdc/cdc_acm_vcp/README.md index 7f3dcd02f1b..2883ef06198 100644 --- a/examples/peripherals/usb/host/cdc/cdc_acm_vcp/README.md +++ b/examples/peripherals/usb/host/cdc/cdc_acm_vcp/README.md @@ -5,28 +5,26 @@ (See the README.md file in the upper level 'examples' directory for more information about examples.) -This example shows how to extend CDC-ACM driver for Virtual Communication Port (VCP) devices, -such as CP210x, FTDI FT23x or CH34x devices. +This example shows how to extend CDC-ACM driver for Virtual Communication Port (VCP) devices, such as CP210x, FTDI FT23x or CH34x devices. The drivers are fetched from [ESP Component Registry](https://components.espressif.com/) together with VCP service that automatically loads correct driver for plugged-in device. ## How to use example -1. Connect your USB<->UART converter to ESP32-S2/S3, the device will be automatically enumerated and correct driver will be loaded +1. Connect your USB<->UART converter to ESP board, the device will be automatically enumerated and correct driver will be loaded 2. Change baudrate and other line coding parameters in [cdc_acm_vcp_example_main.cpp](main/cdc_acm_vcp_example_main.cpp) to match your needs 3. Now you can use the usual CDC-ACM API to control the device and send data. Data are received in `handle_rx` callback 4. Try disconnecting and then reconnecting of the USB device to experiment with USB hotplugging ### Hardware Required -* ESP board with USB-OTG supported +* Development board with USB-OTG support +* A USB cable for Power supply and programming * Silicon Labs CP210x, FTDI FT23x or CP34x USB to UART converter -Connect USB_D+, USB_D-, GND and +5V signals of your ESP chip to matching signals on USB to UART converter. - #### Pin Assignment -See common pin assignments for USB Device examples from [upper level](../../../README.md#common-pin-assignments). +Follow instruction in [examples/usb/README.md](../../../README.md) for specific hardware setup. ### Build and Flash diff --git a/examples/peripherals/usb/host/hid/README.md b/examples/peripherals/usb/host/hid/README.md index 281c1805f08..9c52850ee83 100644 --- a/examples/peripherals/usb/host/hid/README.md +++ b/examples/peripherals/usb/host/hid/README.md @@ -6,24 +6,13 @@ This example implements a basic USB Host HID Class Driver, and demonstrates how ### Hardware Required -* Development board with USB capable ESP SoC (ESP32-S2/ESP32-S3) +* Development board with USB-OTG support * A USB cable for Power supply and programming * USB OTG Cable ### Common Pin Assignments -If your board doesn't have a USB A connector connected to the dedicated GPIOs, -you may have to DIY a cable and connect **D+** and **D-** to the pins listed below. - -``` -ESP BOARD USB CONNECTOR (type A) - -- - | || VCC -[GPIO19] ------> | || D- -[GPIO20] ------> | || D+ - | || GND - -- -``` +Follow instructions in [examples/usb/README.md](../../README.md) for specific hardware setup. ### Build and Flash diff --git a/examples/peripherals/usb/host/msc/README.md b/examples/peripherals/usb/host/msc/README.md index 94fe45587ac..67504d559ba 100644 --- a/examples/peripherals/usb/host/msc/README.md +++ b/examples/peripherals/usb/host/msc/README.md @@ -12,6 +12,7 @@ This example demonstrates usage of the MSC (Mass Storage Class) to access storag 3. Create `ESP` subdirectory (if not present already), as well as a `text.txt` file 4. Run read/write benchmarks by transferring 1 MB of data to a `dummy` file +> Note: This example currently supports only FAT-formatted drives. Other file systems, such as exFAT or NTFS, are not compatible with this example. Please ensure that your USB drive is formatted as FAT to avoid compatibility issues. ### USB Reconnections @@ -20,24 +21,13 @@ The example is run in a loop so that it can demonstrate USB connection and recon ### Hardware Required -* Development board with USB capable ESP SoC (ESP32-S2/ESP32-S3) +* Development board with USB-OTG support * A USB cable for Power supply and programming * A USB flash drive ### Common Pin Assignments -If your board doesn't have a USB A connector connected to the dedicated GPIOs, -you may have to DIY a cable and connect **D+** and **D-** to the pins listed below. - -``` -ESP BOARD USB CONNECTOR (type A) - -- - | || VCC -[GPIO19] ------> | || D- -[GPIO20] ------> | || D+ - | || GND - -- -``` +Follow instructions in [examples/usb/README.md](../../README.md) for specific hardware setup. Additionally, GPIO0 can be shorted to ground in order to deinitialize USB stack. diff --git a/examples/peripherals/usb/host/usb_host_lib/README.md b/examples/peripherals/usb/host/usb_host_lib/README.md index a391aedd9bf..e7a2028e181 100644 --- a/examples/peripherals/usb/host/usb_host_lib/README.md +++ b/examples/peripherals/usb/host/usb_host_lib/README.md @@ -32,11 +32,8 @@ The example demonstrates the following aspects of the USB Host Library API: ### Hardware Required -An ESP board that has a push button and supports USB-OTG. The example uses the ESP's internal USB PHY, however the internal USB PHY's pins will need to be connected to a USB port (i.e., a USB breakout board) as follows: - -- GND and 5V signals of the ESP board to the GND and 5V lines of the USB port -- GPIO 19 to D- -- GPIO 20 to D+ +* Development board with USB-OTG support. +* Follow instruction in [examples/usb/README.md](../../README.md) for specific hardware setup. ### Configure the project diff --git a/examples/peripherals/usb/host/uvc/README.md b/examples/peripherals/usb/host/uvc/README.md index 3fab9cf6107..eb2e4fee454 100644 --- a/examples/peripherals/usb/host/uvc/README.md +++ b/examples/peripherals/usb/host/uvc/README.md @@ -22,12 +22,14 @@ Optionally, the captured video can be visualized on a PC with help of the `playe ### Hardware Required -* ESP with USB peripheral and external PSRAM +* Development board with USB-OTG support and external PSRAM * Exposed USB host connector * USB camera Running this example on an **ESP module without external PSRAM will fail on initialization**. Please select your PSRAM configuration in menuconfig `Component config->ESP PSRAM`. If you manually disable PSRAM, the required framebuffers might not fit into DRAM (especially on ESP32-S2). +Follow instructions in [examples/usb/README.md](../../README.md) for specific hardware setup. + ### Configure the project Following configuration is needed for streaming video: From 35ef6f5140ea656d401c9c3c3acf3a8dcadfc729 Mon Sep 17 00:00:00 2001 From: xiongweichao Date: Tue, 29 Oct 2024 17:40:04 +0800 Subject: [PATCH 51/70] fix(bt/bluedroid): Replace free/malloc with osi_free/malloc --- .../host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c | 10 +++++----- .../bt/host/bluedroid/btc/profile/std/spp/btc_spp.c | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c b/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c index 7c5157736a9..12e55c62184 100644 --- a/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c +++ b/components/bt/host/bluedroid/btc/profile/std/l2cap/btc_l2cap.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -281,7 +281,7 @@ static void close_timeout_handler(void *arg) status = btc_transfer_context(&msg, slot->alarm_arg, sizeof(tBTA_JV), NULL, NULL); if (slot->alarm_arg) { - free(slot->alarm_arg); + osi_free(slot->alarm_arg); slot->alarm_arg = NULL; } @@ -832,7 +832,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) // if rx still has data, delay free slot if (slot->close_alarm == NULL && slot->rx.queue && fixed_queue_length(slot->rx.queue) > 0) { tBTA_JV *p_arg = NULL; - if ((p_arg = malloc(sizeof(tBTA_JV))) == NULL) { + if ((p_arg = osi_malloc(sizeof(tBTA_JV))) == NULL) { param.close.status = ESP_BT_L2CAP_NO_RESOURCE; osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex); BTC_TRACE_ERROR("%s unable to malloc slot close_alarm arg!", __func__); @@ -842,7 +842,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) slot->alarm_arg = (void *)p_arg; if ((slot->close_alarm = osi_alarm_new("slot", close_timeout_handler, (void *)slot, VFS_CLOSE_TIMEOUT)) == NULL) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; param.close.status = ESP_BT_L2CAP_NO_RESOURCE; osi_mutex_unlock(&l2cap_local_param.l2cap_slot_mutex); @@ -850,7 +850,7 @@ void btc_l2cap_cb_handler(btc_msg_t *msg) break; } if (osi_alarm_set(slot->close_alarm, VFS_CLOSE_TIMEOUT) != OSI_ALARM_ERR_PASS) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; osi_alarm_free(slot->close_alarm); param.close.status = ESP_BT_L2CAP_BUSY; diff --git a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c index cf334494487..181f2014164 100644 --- a/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c +++ b/components/bt/host/bluedroid/btc/profile/std/spp/btc_spp.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -1199,7 +1199,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) slot->alarm_arg = (void *)p_arg; if ((slot->close_alarm = osi_alarm_new("slot", close_timeout_handler, (void *)slot, VFS_CLOSE_TIMEOUT)) == NULL) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; param.close.status = ESP_SPP_NO_RESOURCE; osi_mutex_unlock(&spp_local_param.spp_slot_mutex); @@ -1207,7 +1207,7 @@ void btc_spp_cb_handler(btc_msg_t *msg) break; } if (osi_alarm_set(slot->close_alarm, VFS_CLOSE_TIMEOUT) != OSI_ALARM_ERR_PASS) { - free(p_arg); + osi_free(p_arg); slot->alarm_arg = NULL; osi_alarm_free(slot->close_alarm); param.close.status = ESP_SPP_BUSY; @@ -1488,7 +1488,7 @@ static ssize_t spp_vfs_write(int fd, const void * data, size_t size) BTC_TRACE_DEBUG("%s items_waiting:%d, fd:%d\n", __func__, items_waiting, fd); osi_mutex_unlock(&spp_local_param.spp_slot_mutex); - // block untill under water level, be closed or time out + // block until under water level, be closed or time out tx_event_group_val = xEventGroupWaitBits(spp_local_param.tx_event_group, SLOT_WRITE_BIT(serial) | SLOT_CLOSE_BIT(serial), pdTRUE, pdFALSE, VFS_WRITE_TIMEOUT / portTICK_PERIOD_MS); From 7a044c0f81e2a146b27961ff8341413800c7e491 Mon Sep 17 00:00:00 2001 From: zwx Date: Mon, 9 Sep 2024 20:38:29 +0800 Subject: [PATCH 52/70] feat(openthread): support alloc nat64 session from psram --- components/openthread/Kconfig | 18 +++++++++++----- .../private_include/esp_openthread_common.hpp | 21 +++++++++++++++++++ .../private_include/esp_openthread_platform.h | 13 ++++++++++-- .../src/esp_openthread_platform.cpp | 10 +++++++++ 4 files changed, 55 insertions(+), 7 deletions(-) create mode 100644 components/openthread/private_include/esp_openthread_common.hpp diff --git a/components/openthread/Kconfig b/components/openthread/Kconfig index d344f596152..a739f701635 100644 --- a/components/openthread/Kconfig +++ b/components/openthread/Kconfig @@ -278,12 +278,20 @@ menu "OpenThread" help Select this option to enable border router features in OpenThread. - config OPENTHREAD_PLATFORM_MSGPOOL_MANAGEMENT - bool 'Allocate message pool buffer from PSRAM' + menu "Thread Memory Allocation Config" depends on OPENTHREAD_ENABLED && (SPIRAM_USE_CAPS_ALLOC || SPIRAM_USE_MALLOC) - default n - help - If enabled, the message pool is managed by platform defined logic. + config OPENTHREAD_MEM_ALLOC_EXTERNAL + bool 'Allocate memory from PSRAM' + default y + help + Select this option to allocate buffer from PSRAM for Thread + + config OPENTHREAD_PLATFORM_MSGPOOL_MANAGEMENT + bool 'Allocate message pool buffer from PSRAM' + default n + help + If enabled, the message pool is managed by platform defined logic. + endmenu config OPENTHREAD_NUM_MESSAGE_BUFFERS int "The number of openthread message buffers" diff --git a/components/openthread/private_include/esp_openthread_common.hpp b/components/openthread/private_include/esp_openthread_common.hpp new file mode 100644 index 00000000000..c4dbf749ee8 --- /dev/null +++ b/components/openthread/private_include/esp_openthread_common.hpp @@ -0,0 +1,21 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#pragma once + +#include "esp_heap_caps.h" +#include +#include "common/new.hpp" + +template +inline T *New(uint32_t alloc_caps, Args &&...args) +{ + void *p = heap_caps_calloc(1, sizeof(T), alloc_caps); + if (p != nullptr) { + return new (p) T(std::forward(args)...); + } + return nullptr; +} diff --git a/components/openthread/private_include/esp_openthread_platform.h b/components/openthread/private_include/esp_openthread_platform.h index 6919e914be2..3999322a8d1 100644 --- a/components/openthread/private_include/esp_openthread_platform.h +++ b/components/openthread/private_include/esp_openthread_platform.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -84,7 +84,7 @@ void esp_openthread_platform_workflow_unregister(const char *name); * @brief Initializes the platform-specific support for the OpenThread stack. * * @note This function is not called by and will not call the OpenThread library. - * The user needs to call otInstanceInitSingle to intialize the OpenThread + * The user needs to call otInstanceInitSingle to initialize the OpenThread * stack after calling this function. * * @param[in] init_config The initialization configuration. @@ -146,6 +146,15 @@ esp_err_t esp_openthread_platform_process(otInstance *instance, const esp_openth * */ void esp_openthread_set_storage_name(const char *name); + +/** + * @brief Gets the caps of memory allocation. + * + * @return + * - The caps of the memory. + */ +uint32_t esp_openthread_get_alloc_caps(void); + #ifdef __cplusplus } // end of extern "C" #endif diff --git a/components/openthread/src/esp_openthread_platform.cpp b/components/openthread/src/esp_openthread_platform.cpp index 8beb8143dc4..51bfd779042 100644 --- a/components/openthread/src/esp_openthread_platform.cpp +++ b/components/openthread/src/esp_openthread_platform.cpp @@ -204,3 +204,13 @@ esp_err_t esp_openthread_platform_process(otInstance *instance, const esp_openth } return ESP_OK; } + +uint32_t esp_openthread_get_alloc_caps(void) +{ + return +#if CONFIG_OPENTHREAD_PLATFORM_MALLOC_CAP_SPIRAM + (MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT); +#else + (MALLOC_CAP_DEFAULT | MALLOC_CAP_8BIT); +#endif +} From 92b4c62d06cf10fc731b260ffee659a904bf0860 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Tue, 10 Sep 2024 17:37:58 +0800 Subject: [PATCH 53/70] fix(uart_vfs): read() now aligned to POSIX defined behavior - For blocking mode, block until data available - Return with the bytes available in the file at the time, it should not block until reaching the requested size And read() should not realy return on the newline character Closes https://github.com/espressif/esp-idf/issues/14155 --- components/esp_driver_uart/src/uart_vfs.c | 109 ++++++++++++----- .../test_apps/uart_vfs/main/test_vfs_uart.c | 113 ++++++++++++++++-- 2 files changed, 182 insertions(+), 40 deletions(-) diff --git a/components/esp_driver_uart/src/uart_vfs.c b/components/esp_driver_uart/src/uart_vfs.c index 6e5a0dbfaf7..8d00ab43382 100644 --- a/components/esp_driver_uart/src/uart_vfs.c +++ b/components/esp_driver_uart/src/uart_vfs.c @@ -53,14 +53,18 @@ typedef void (*tx_func_t)(int, int); // UART read bytes function type typedef int (*rx_func_t)(int); +// UART get available received bytes function type +typedef size_t (*get_available_data_len_func_t)(int); -// Basic functions for sending and receiving bytes over UART +// Basic functions for sending, receiving bytes, and get available data length over UART static void uart_tx_char(int fd, int c); static int uart_rx_char(int fd); +static size_t uart_get_avail_data_len(int fd); -// Functions for sending and receiving bytes which use UART driver +// Functions for sending, receiving bytes, and get available data length which use UART driver static void uart_tx_char_via_driver(int fd, int c); static int uart_rx_char_via_driver(int fd); +static size_t uart_get_avail_data_len_via_driver(int fd); typedef struct { // Pointers to UART peripherals @@ -82,6 +86,8 @@ typedef struct { tx_func_t tx_func; // Functions used to read bytes from UART. Default to "basic" functions. rx_func_t rx_func; + // Function used to get available data bytes from UART. Default to "basic" functions. + get_available_data_len_func_t get_avail_data_len_func; } uart_vfs_context_t; #define VFS_CTX_DEFAULT_VAL(uart_dev) (uart_vfs_context_t) {\ @@ -91,6 +97,7 @@ typedef struct { .rx_mode = DEFAULT_RX_MODE,\ .tx_func = uart_tx_char,\ .rx_func = uart_rx_char,\ + .get_avail_data_len_func = uart_get_avail_data_len,\ } //If the context should be dynamically initialized, remove this structure @@ -162,6 +169,19 @@ static int uart_open(const char *path, int flags, int mode) return fd; } +size_t uart_get_avail_data_len(int fd) +{ + uart_dev_t* uart = s_ctx[fd]->uart; + return uart_ll_get_rxfifo_len(uart); +} + +size_t uart_get_avail_data_len_via_driver(int fd) +{ + size_t buffered_size = 0; + uart_get_buffered_data_len(fd, &buffered_size); + return buffered_size; +} + static void uart_tx_char(int fd, int c) { uart_dev_t* uart = s_ctx[fd]->uart; @@ -253,38 +273,65 @@ static ssize_t uart_read(int fd, void* data, size_t size) assert(fd >= 0 && fd < 3); char *data_c = (char *) data; size_t received = 0; + size_t available_size = 0; + int c = NONE; // store the read char _lock_acquire_recursive(&s_ctx[fd]->read_lock); - while (received < size) { - int c = uart_read_char(fd); - if (c == '\r') { - if (s_ctx[fd]->rx_mode == ESP_LINE_ENDINGS_CR) { - c = '\n'; - } else if (s_ctx[fd]->rx_mode == ESP_LINE_ENDINGS_CRLF) { - /* look ahead */ - int c2 = uart_read_char(fd); - if (c2 == NONE) { - /* could not look ahead, put the current character back */ - uart_return_char(fd, c); - break; - } - if (c2 == '\n') { - /* this was \r\n sequence. discard \r, return \n */ + + if (!s_ctx[fd]->non_blocking) { + c = uart_read_char(fd); // blocking until data available for non-O_NONBLOCK mode + } + + // find the actual fetch size + available_size += s_ctx[fd]->get_avail_data_len_func(fd); + if (c != NONE) { + available_size++; + } + if (s_ctx[fd]->peek_char != NONE) { + available_size++; + } + size_t fetch_size = MIN(available_size, size); + + if (fetch_size > 0) { + do { + if (c == NONE) { // for non-O_NONBLOCK mode, there is already a pre-fetched char + c = uart_read_char(fd); + } + assert(c != NONE); + + if (c == '\r') { + if (s_ctx[fd]->rx_mode == ESP_LINE_ENDINGS_CR) { c = '\n'; - } else { - /* \r followed by something else. put the second char back, - * it will be processed on next iteration. return \r now. - */ - uart_return_char(fd, c2); + } else if (s_ctx[fd]->rx_mode == ESP_LINE_ENDINGS_CRLF) { + /* look ahead */ + int c2 = uart_read_char(fd); + fetch_size--; + if (c2 == NONE) { + /* could not look ahead, put the current character back */ + uart_return_char(fd, c); + c = NONE; + break; + } + if (c2 == '\n') { + /* this was \r\n sequence. discard \r, return \n */ + c = '\n'; + } else { + /* \r followed by something else. put the second char back, + * it will be processed on next iteration. return \r now. + */ + uart_return_char(fd, c2); + fetch_size++; + } } } - } else if (c == NONE) { - break; - } - data_c[received] = (char) c; - ++received; - if (c == '\n') { - break; - } + + data_c[received] = (char) c; + ++received; + c = NONE; + } while (received < fetch_size); + } + + if (c != NONE) { // fetched, but not used + uart_return_char(fd, c); } _lock_release_recursive(&s_ctx[fd]->read_lock); if (received > 0) { @@ -1061,6 +1108,7 @@ void uart_vfs_dev_use_nonblocking(int uart_num) _lock_acquire_recursive(&s_ctx[uart_num]->write_lock); s_ctx[uart_num]->tx_func = uart_tx_char; s_ctx[uart_num]->rx_func = uart_rx_char; + s_ctx[uart_num]->get_avail_data_len_func = uart_get_avail_data_len; _lock_release_recursive(&s_ctx[uart_num]->write_lock); _lock_release_recursive(&s_ctx[uart_num]->read_lock); } @@ -1071,6 +1119,7 @@ void uart_vfs_dev_use_driver(int uart_num) _lock_acquire_recursive(&s_ctx[uart_num]->write_lock); s_ctx[uart_num]->tx_func = uart_tx_char_via_driver; s_ctx[uart_num]->rx_func = uart_rx_char_via_driver; + s_ctx[uart_num]->get_avail_data_len_func = uart_get_avail_data_len_via_driver; _lock_release_recursive(&s_ctx[uart_num]->write_lock); _lock_release_recursive(&s_ctx[uart_num]->read_lock); } diff --git a/components/esp_driver_uart/test_apps/uart_vfs/main/test_vfs_uart.c b/components/esp_driver_uart/test_apps/uart_vfs/main/test_vfs_uart.c index 5cf95429d32..b3266a625d9 100644 --- a/components/esp_driver_uart/test_apps/uart_vfs/main/test_vfs_uart.c +++ b/components/esp_driver_uart/test_apps/uart_vfs/main/test_vfs_uart.c @@ -74,6 +74,12 @@ TEST_CASE("CRs are removed from the stdin correctly", "[vfs_uart]") uart_vfs_dev_port_set_tx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); flush_stdin_stdout(); + + // A test case with no use of uart driver + // For non-uart-driver-involved uart vfs, all reads are non-blocking + // If no data at the moment, read() returns directly; + // If there is data available at the moment, read() also returns directly with the currently available size + const char* send_str = "1234567890\n\r123\r\n4\n"; /* with CONFIG_NEWLIB_STDOUT_ADDCR, the following will be sent on the wire. * (last character of each part is marked with a hat) @@ -133,30 +139,46 @@ struct read_task_arg_t { struct write_task_arg_t { const char* str; + size_t str_len; SemaphoreHandle_t done; }; -static void read_task_fn(void* varg) +static void read_blocking_task_fn(void* varg) { struct read_task_arg_t* parg = (struct read_task_arg_t*) varg; - parg->out_buffer[0] = 0; + memset(parg->out_buffer, 0, parg->out_buffer_len); fgets(parg->out_buffer, parg->out_buffer_len, stdin); xSemaphoreGive(parg->done); vTaskDelete(NULL); } +static void read_non_blocking_task_fn(void* varg) +{ + struct read_task_arg_t* parg = (struct read_task_arg_t*) varg; + memset(parg->out_buffer, 0, parg->out_buffer_len); + char *ptr = parg->out_buffer; + + while (fgets(ptr, parg->out_buffer_len, stdin) != NULL) { + while (*ptr != 0) { + ptr++; + } + } + xSemaphoreGive(parg->done); + vTaskDelete(NULL); +} + static void write_task_fn(void* varg) { struct write_task_arg_t* parg = (struct write_task_arg_t*) varg; - fwrite_str_loopback(parg->str, strlen(parg->str)); + fwrite_str_loopback(parg->str, parg->str_len); xSemaphoreGive(parg->done); vTaskDelete(NULL); } -TEST_CASE("can write to UART while another task is reading", "[vfs_uart]") +TEST_CASE("read with uart driver (blocking)", "[vfs_uart]") { - char out_buffer[32]; + char out_buffer[32] = {}; size_t out_buffer_len = sizeof(out_buffer); struct read_task_arg_t read_arg = { @@ -165,8 +187,12 @@ TEST_CASE("can write to UART while another task is reading", "[vfs_uart]") .done = xSemaphoreCreateBinary() }; + // Send a string with length less than the read requested length + const char in_buffer[] = "!(@*#&(!*@&#((SDasdkjhadsl\n"; + size_t in_buffer_len = sizeof(in_buffer); struct write_task_arg_t write_arg = { - .str = "!(@*#&(!*@&#((SDasdkjhadsl\n", + .str = in_buffer, + .str_len = in_buffer_len, .done = xSemaphoreCreateBinary() }; @@ -176,14 +202,18 @@ TEST_CASE("can write to UART while another task is reading", "[vfs_uart]") 256, 0, 0, NULL, 0)); uart_vfs_dev_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); - xTaskCreate(&read_task_fn, "vfs_read", 4096, &read_arg, 5, NULL); - vTaskDelay(10); + // Start the read task first, it will block until data incoming + xTaskCreate(&read_blocking_task_fn, "vfs_read", 4096, &read_arg, 5, NULL); + + int res = xSemaphoreTake(read_arg.done, 100 / portTICK_PERIOD_MS); + TEST_ASSERT_FALSE(res); + xTaskCreate(&write_task_fn, "vfs_write", 4096, &write_arg, 6, NULL); - int res = xSemaphoreTake(write_arg.done, 100 / portTICK_PERIOD_MS); + res = xSemaphoreTake(write_arg.done, 100 / portTICK_PERIOD_MS); TEST_ASSERT(res); - res = xSemaphoreTake(read_arg.done, 100 / portTICK_PERIOD_MS); + res = xSemaphoreTake(read_arg.done, 100 / portTICK_PERIOD_MS); // read() returns with currently available size TEST_ASSERT(res); TEST_ASSERT_EQUAL(0, strcmp(write_arg.str, read_arg.out_buffer)); @@ -195,6 +225,69 @@ TEST_CASE("can write to UART while another task is reading", "[vfs_uart]") vTaskDelay(2); // wait for tasks to exit } +TEST_CASE("read with uart driver (non-blocking)", "[vfs_uart]") +{ + char out_buffer[32] = {}; + size_t out_buffer_len = sizeof(out_buffer); + + struct read_task_arg_t read_arg = { + .out_buffer = out_buffer, + .out_buffer_len = out_buffer_len, + .done = xSemaphoreCreateBinary() + }; + + // Send a string with length less than the read requested length + const char in_buffer[] = "!(@*#&(!*@&#((SDasdkjhad\nce"; // read should not early return on \n + size_t in_buffer_len = sizeof(in_buffer); + struct write_task_arg_t write_arg = { + .str = in_buffer, + .str_len = in_buffer_len, + .done = xSemaphoreCreateBinary() + }; + + flush_stdin_stdout(); + + ESP_ERROR_CHECK(uart_driver_install(CONFIG_ESP_CONSOLE_UART_NUM, + 256, 0, 0, NULL, 0)); + uart_vfs_dev_use_driver(CONFIG_ESP_CONSOLE_UART_NUM); + + uart_vfs_dev_port_set_rx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_LF); + uart_vfs_dev_port_set_tx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_LF); + + int flags = fcntl(STDIN_FILENO, F_GETFL, 0); + fcntl(STDIN_FILENO, F_SETFL, flags | O_NONBLOCK); + + // If start the read task first, it will return immediately + xTaskCreate(&read_non_blocking_task_fn, "vfs_read", 4096, &read_arg, 5, NULL); + + int res = xSemaphoreTake(read_arg.done, 100 / portTICK_PERIOD_MS); + TEST_ASSERT(res); + + xTaskCreate(&write_task_fn, "vfs_write", 4096, &write_arg, 6, NULL); + vTaskDelay(10); + xTaskCreate(&read_non_blocking_task_fn, "vfs_read", 4096, &read_arg, 5, NULL); + + res = xSemaphoreTake(write_arg.done, 100 / portTICK_PERIOD_MS); + TEST_ASSERT(res); + + res = xSemaphoreTake(read_arg.done, 1000 / portTICK_PERIOD_MS); // read() returns with currently available size + TEST_ASSERT(res); + + // string compare + for (int i = 0; i < in_buffer_len; i++) { + TEST_ASSERT_EQUAL(in_buffer[i], out_buffer[i]); + } + + uart_vfs_dev_use_nonblocking(CONFIG_ESP_CONSOLE_UART_NUM); + fcntl(STDIN_FILENO, F_SETFL, flags); + uart_vfs_dev_port_set_rx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); + uart_vfs_dev_port_set_tx_line_endings(CONFIG_ESP_CONSOLE_UART_NUM, ESP_LINE_ENDINGS_CRLF); + uart_driver_delete(CONFIG_ESP_CONSOLE_UART_NUM); + vSemaphoreDelete(read_arg.done); + vSemaphoreDelete(write_arg.done); + vTaskDelay(2); // wait for tasks to exit +} + TEST_CASE("fcntl supported in UART VFS", "[vfs_uart]") { int flags = fcntl(STDIN_FILENO, F_GETFL, 0); From 8cd4091114a43ef8cf0e3b76729e02f58d108b50 Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 31 Oct 2024 18:32:37 +0800 Subject: [PATCH 54/70] fix(gdma): run test cases after reset --- components/esp_hw_support/test_apps/dma/pytest_dma.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/esp_hw_support/test_apps/dma/pytest_dma.py b/components/esp_hw_support/test_apps/dma/pytest_dma.py index 3d78de4a849..1d741f14fb1 100644 --- a/components/esp_hw_support/test_apps/dma/pytest_dma.py +++ b/components/esp_hw_support/test_apps/dma/pytest_dma.py @@ -21,7 +21,7 @@ indirect=True, ) def test_dma(dut: Dut) -> None: - dut.run_all_single_board_cases() + dut.run_all_single_board_cases(reset=True) @pytest.mark.esp32s3 @@ -34,4 +34,4 @@ def test_dma(dut: Dut) -> None: indirect=True, ) def test_dma_psram(dut: Dut) -> None: - dut.run_all_single_board_cases() + dut.run_all_single_board_cases(reset=True) From 77656e20466fdd138050783f68bbea3ecdca1a8c Mon Sep 17 00:00:00 2001 From: WanqQixiang Date: Thu, 31 Oct 2024 14:53:33 +0800 Subject: [PATCH 55/70] feat(openthread): Add dataset changed event and post it in state change callback --- .../openthread/include/esp_openthread_types.h | 21 +++++++++++++++- .../src/port/esp_openthread_state.c | 25 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/components/openthread/include/esp_openthread_types.h b/components/openthread/include/esp_openthread_types.h index e046c4606f3..debc464066d 100644 --- a/components/openthread/include/esp_openthread_types.h +++ b/components/openthread/include/esp_openthread_types.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -46,6 +46,7 @@ typedef enum { OPENTHREAD_EVENT_SET_DNS_SERVER, /*!< OpenThread stack set DNS server >*/ OPENTHREAD_EVENT_PUBLISH_MESHCOP_E, /*!< OpenThread stack start to publish meshcop-e service >*/ OPENTHREAD_EVENT_REMOVE_MESHCOP_E, /*!< OpenThread stack start to remove meshcop-e service >*/ + OPENTHREAD_EVENT_DATASET_CHANGED, /*!< OpenThread dataset changed >*/ } esp_openthread_event_t; /** @@ -63,6 +64,24 @@ typedef struct { otDeviceRole current_role; /*!< Current Thread role */ } esp_openthread_role_changed_event_t; +/** + * @brief OpenThread dataset type + * + */ +typedef enum { + OPENTHREAD_ACTIVE_DATASET, /*!< Active dataset */ + OPENTHREAD_PENDING_DATASET, /*!< Pending dataset */ +} esp_openthread_dataset_type_t; + +/** + * @brief OpenThread dataset changed event data + * + */ +typedef struct { + esp_openthread_dataset_type_t type; /*!< Dataset type */ + otOperationalDataset new_dataset; /*!< New dataset */ +} esp_openthread_dataset_changed_event_t; + /** * This structure represents a context for a select() based mainloop. * diff --git a/components/openthread/src/port/esp_openthread_state.c b/components/openthread/src/port/esp_openthread_state.c index 6dbe1016705..7d04cba9f52 100644 --- a/components/openthread/src/port/esp_openthread_state.c +++ b/components/openthread/src/port/esp_openthread_state.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -80,6 +80,21 @@ static void handle_ot_role_change(otInstance* instance) s_previous_role = role; } +static void handle_ot_dataset_change(esp_openthread_dataset_type_t type, otInstance *instance) +{ + esp_openthread_dataset_changed_event_t event_data; + event_data.type = type; + memset(&event_data.new_dataset, 0, sizeof(event_data.new_dataset)); + if (type == OPENTHREAD_ACTIVE_DATASET) { + (void)otDatasetGetActive(instance, &event_data.new_dataset); + } else if (type == OPENTHREAD_PENDING_DATASET) { + (void)otDatasetGetPending(instance, &event_data.new_dataset); + } + if (esp_event_post(OPENTHREAD_EVENT, OPENTHREAD_EVENT_DATASET_CHANGED, &event_data, sizeof(event_data), 0) != ESP_OK) { + ESP_LOGE(TAG, "Failed to post dataset changed event"); + } +} + static void ot_state_change_callback(otChangedFlags changed_flags, void* ctx) { OT_UNUSED_VARIABLE(ctx); @@ -99,6 +114,14 @@ static void ot_state_change_callback(otChangedFlags changed_flags, void* ctx) if (changed_flags & OT_CHANGED_THREAD_NETIF_STATE) { handle_ot_netif_state_change(instance); } + + if (changed_flags & OT_CHANGED_ACTIVE_DATASET) { + handle_ot_dataset_change(OPENTHREAD_ACTIVE_DATASET, instance); + } + + if (changed_flags & OT_CHANGED_PENDING_DATASET) { + handle_ot_dataset_change(OPENTHREAD_PENDING_DATASET, instance); + } } esp_err_t esp_openthread_state_event_init(otInstance* instance) From 7e5741953d3a2f2a7ee472fbd84d68fa9ae46136 Mon Sep 17 00:00:00 2001 From: sibeibei Date: Mon, 14 Oct 2024 16:55:41 +0800 Subject: [PATCH 56/70] fix(wifi): fix some wifi issues 241031 1. fix cant sleep if reconnect to connected ap 2. clear pmk in internal reconnection 3. update connect status for init-->auth 4. add protection for probe request when wifi band is 5g --- components/esp_wifi/lib | 2 +- components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h | 1 + components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index 4488e06749c..cde7c641e30 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit 4488e06749ce73a8a58e53fcb0d415ab54b62122 +Subproject commit cde7c641e30d4ae701c4949f1792e0dea6d2d703 diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h index d5ca7fd7163..a07650603d8 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wifi_driver.h @@ -144,6 +144,7 @@ struct wpa_funcs { void (*wpa_config_done)(void); uint8_t *(*owe_build_dhie)(uint16_t group); int (*owe_process_assoc_resp)(const u8 *rsn_ie, size_t rsn_len, const uint8_t *dh_ie, size_t dh_len); + void (*wpa_sta_clear_curr_pmksa)(void); }; struct wpa2_funcs { diff --git a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c index 0d4bf2a3f9c..09532deb126 100644 --- a/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c +++ b/components/wpa_supplicant/esp_supplicant/src/esp_wpa_main.c @@ -476,6 +476,7 @@ int esp_supplicant_init(void) wpa_cb->wpa_config_bss = NULL;//wpa_config_bss; wpa_cb->wpa_michael_mic_failure = wpa_michael_mic_failure; wpa_cb->wpa_config_done = wpa_config_done; + wpa_cb->wpa_sta_clear_curr_pmksa = wpa_sta_clear_curr_pmksa; esp_wifi_register_wpa3_ap_cb(wpa_cb); esp_wifi_register_wpa3_cb(wpa_cb); From 8c4f576f99f6a7ed45ba1a795b8b8c8647bc5d8e Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Mon, 14 Oct 2024 20:45:24 +0300 Subject: [PATCH 57/70] feat(partition_table): Support primary subtypes partitions --- .../include/esp_image_format.h | 33 ++++++-- .../src/bootloader_common.c | 4 +- .../bootloader_support/src/esp_image_format.c | 35 +++++++-- .../src/flash_encryption/flash_encrypt.c | 77 ++++++++++++------- .../bootloader_support/src/flash_partitions.c | 7 +- components/partition_table/CMakeLists.txt | 16 +++- components/partition_table/gen_esp32part.py | 47 +++++++++-- components/partition_table/parttool.py | 7 +- .../partition_table/project_include.cmake | 8 ++ .../gen_esp32part_tests.py | 45 ++++++++++- docs/en/api-guides/partition-tables.rst | 46 ++++++++--- .../efuse/test/partitions_efuse_emul.csv | 16 ++-- 12 files changed, 263 insertions(+), 78 deletions(-) diff --git a/components/bootloader_support/include/esp_image_format.h b/components/bootloader_support/include/esp_image_format.h index f677b08fe50..c385babeebd 100644 --- a/components/bootloader_support/include/esp_image_format.h +++ b/components/bootloader_support/include/esp_image_format.h @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -86,12 +86,12 @@ ESP_STATIC_ASSERT(sizeof(rtc_retain_mem_t) <= ESP_BOOTLOADER_RESERVE_RTC, "Reser #endif // CONFIG_BOOTLOADER_RESERVE_RTC_MEM /** - * @brief Verify an app image. + * @brief Verify an app/bootloader image. * * If encryption is enabled, data will be transparently decrypted. * * @param mode Mode of operation (verify, silent verify, or load). - * @param part Partition to load the app from. + * @param part Partition to load the app/bootloader from. * @param[inout] data Pointer to the image metadata structure which is be filled in by this function. * 'start_addr' member should be set (to the start address of the image.) * Other fields will all be initialised by this function. @@ -113,11 +113,11 @@ ESP_STATIC_ASSERT(sizeof(rtc_retain_mem_t) <= ESP_BOOTLOADER_RESERVE_RTC, "Reser esp_err_t esp_image_verify(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data); /** - * @brief Get metadata of app + * @brief Get metadata of app/bootloader * * If encryption is enabled, data will be transparently decrypted. * - * @param part Partition to load the app from. + * @param part Partition to load the app/bootloader from. * @param[out] metadata Pointer to the image metadata structure which is be filled in by this function. * Fields will all be initialised by this function. * @@ -171,7 +171,7 @@ esp_err_t bootloader_load_image(const esp_partition_pos_t *part, esp_image_metad esp_err_t bootloader_load_image_no_verify(const esp_partition_pos_t *part, esp_image_metadata_t *data); /** - * @brief Verify the bootloader image. + * @brief Verify the PRIMARY bootloader image. * * @param[out] If result is ESP_OK and this pointer is non-NULL, it * will be set to the length of the bootloader image. @@ -181,7 +181,7 @@ esp_err_t bootloader_load_image_no_verify(const esp_partition_pos_t *part, esp_i esp_err_t esp_image_verify_bootloader(uint32_t *length); /** - * @brief Verify the bootloader image. + * @brief Verify the PRIMARY bootloader image. * * @param[out] Metadata for the image. Only valid if result is ESP_OK. * @@ -197,6 +197,25 @@ esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data); */ int esp_image_get_flash_size(esp_image_flash_size_t app_flash_size); +/** + * @brief Get the ota bootloader offset + * + * The esp_image_verify functions use the offset to distinguish between application and bootloader verifications. + * The application must set the OTA bootloader offset before running any verification functions for the OTA bootloader partition. + * + * @return ota Bootloader offset. UINT32_MAX - not set. + */ +uint32_t esp_image_bootloader_offset_get(void); + +/** + * @brief Set the ota bootloader offset + * + * The esp_image_verify functions use the offset to distinguish between application and bootloader verifications. + * The application must set the OTA bootloader offset before running any verification functions for the OTA bootloader partition. + * + * @param offset ota Bootloader offset + */ +void esp_image_bootloader_offset_set(const uint32_t offset); typedef struct { uint32_t drom_addr; diff --git a/components/bootloader_support/src/bootloader_common.c b/components/bootloader_support/src/bootloader_common.c index e37a5b41c38..759263e1222 100644 --- a/components/bootloader_support/src/bootloader_common.c +++ b/components/bootloader_support/src/bootloader_common.c @@ -140,13 +140,13 @@ bool bootloader_common_erase_part_type_data(const char *list_erase, bool ota_dat return ret; } -esp_err_t bootloader_common_get_sha256_of_partition (uint32_t address, uint32_t size, int type, uint8_t *out_sha_256) +esp_err_t bootloader_common_get_sha256_of_partition(uint32_t address, uint32_t size, int type, uint8_t *out_sha_256) { if (out_sha_256 == NULL || size == 0) { return ESP_ERR_INVALID_ARG; } - if (type == PART_TYPE_APP) { + if (type == PART_TYPE_APP || type == PART_TYPE_BOOTLOADER) { const esp_partition_pos_t partition_pos = { .offset = address, .size = size, diff --git a/components/bootloader_support/src/esp_image_format.c b/components/bootloader_support/src/esp_image_format.c index 6b2f88a7ba5..4342780ef44 100644 --- a/components/bootloader_support/src/esp_image_format.c +++ b/components/bootloader_support/src/esp_image_format.c @@ -102,6 +102,24 @@ static esp_err_t process_checksum(bootloader_sha256_handle_t sha_handle, uint32_ static esp_err_t __attribute__((unused)) verify_secure_boot_signature(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data, uint8_t *image_digest, uint8_t *verified_digest); static esp_err_t __attribute__((unused)) verify_simple_hash(bootloader_sha256_handle_t sha_handle, esp_image_metadata_t *data); +static uint32_t s_bootloader_partition_offset = ESP_PRIMARY_BOOTLOADER_OFFSET; + +uint32_t esp_image_bootloader_offset_get(void) +{ + return s_bootloader_partition_offset; +} + +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); +} + +static bool is_bootloader(uint32_t offset) +{ + return ((offset == ESP_PRIMARY_BOOTLOADER_OFFSET) || (offset == s_bootloader_partition_offset)); +} + static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_t *part, esp_image_metadata_t *data) { #ifdef BOOTLOADER_BUILD @@ -135,7 +153,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_ // For secure boot V1 on ESP32, we don't calculate SHA or verify signature on bootloaders. // (For non-secure boot, we don't verify any SHA-256 hash appended to the bootloader because // esptool.py may have rewritten the header - rely on esptool.py having verified the bootloader at flashing time, instead.) - verify_sha = (part->offset != ESP_BOOTLOADER_OFFSET) && do_verify; + verify_sha = !is_bootloader(part->offset) && do_verify; #endif if (part->size > SIXTEEN_MB) { @@ -199,7 +217,7 @@ static esp_err_t image_load(esp_image_load_mode_t mode, const esp_partition_pos_ #if CONFIG_SECURE_BOOT_V2_ENABLED ESP_FAULT_ASSERT(!esp_secure_boot_enabled() || memcmp(image_digest, verified_digest, HASH_LEN) == 0); #else // Secure Boot V1 on ESP32, only verify signatures for apps not bootloaders - ESP_FAULT_ASSERT(data->start_addr == ESP_BOOTLOADER_OFFSET || memcmp(image_digest, verified_digest, HASH_LEN) == 0); + ESP_FAULT_ASSERT(is_bootloader(data->start_addr) || memcmp(image_digest, verified_digest, HASH_LEN) == 0); #endif #endif // SECURE_BOOT_CHECK_SIGNATURE @@ -332,7 +350,8 @@ static esp_err_t verify_image_header(uint32_t src_addr, const esp_image_header_t // Checking the chip revision header *will* print a bunch of other info // regardless of silent setting as this may be important, but don't bother checking it // if it looks like the app partition is erased or otherwise garbage - CHECK_ERR(bootloader_common_check_chip_validity(image, ESP_IMAGE_APPLICATION)); + esp_image_type image_type = is_bootloader(src_addr) ? ESP_IMAGE_BOOTLOADER : ESP_IMAGE_APPLICATION; + CHECK_ERR(bootloader_common_check_chip_validity(image, image_type)); if (image->segment_count > ESP_IMAGE_MAX_SEGMENTS) { FAIL_LOAD("image at 0x%"PRIx32" segment count %d exceeds max %d", src_addr, image->segment_count, ESP_IMAGE_MAX_SEGMENTS); @@ -695,7 +714,7 @@ static esp_err_t process_segment_data(int segment, intptr_t load_addr, uint32_t // Case II: Bootloader verifying bootloader // The esp_app_desc_t structure is located in DROM and is always in segment #0. // Anti-rollback check and efuse block version check should handle only Case I from above. - if (segment == 0 && metadata->start_addr != ESP_BOOTLOADER_OFFSET) { + if (segment == 0 && !is_bootloader(metadata->start_addr)) { /* ESP32 doesn't have more memory and more efuse bits for block major version. */ #if !CONFIG_IDF_TARGET_ESP32 const esp_app_desc_t *app_desc = (const esp_app_desc_t *)src; @@ -847,8 +866,8 @@ esp_err_t esp_image_verify_bootloader_data(esp_image_metadata_t *data) return ESP_ERR_INVALID_ARG; } const esp_partition_pos_t bootloader_part = { - .offset = ESP_BOOTLOADER_OFFSET, - .size = ESP_PARTITION_TABLE_OFFSET - ESP_BOOTLOADER_OFFSET, + .offset = ESP_PRIMARY_BOOTLOADER_OFFSET, + .size = ESP_BOOTLOADER_SIZE, }; return esp_image_verify(ESP_IMAGE_VERIFY, &bootloader_part, @@ -871,7 +890,7 @@ static esp_err_t process_appended_hash_and_sig(esp_image_metadata_t *data, uint3 #if CONFIG_SECURE_BOOT || CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT // Case I: Bootloader part - if (part_offset == ESP_BOOTLOADER_OFFSET) { + if (is_bootloader(part_offset)) { // For bootloader with secure boot v1, signature stays in an independent flash // sector (offset 0x0) and does not get appended to the image. #if CONFIG_SECURE_BOOT_V2_ENABLED @@ -1005,7 +1024,7 @@ static esp_err_t verify_secure_boot_signature(bootloader_sha256_handle_t sha_han #if CONFIG_SECURE_SIGNED_APPS_RSA_SCHEME || CONFIG_SECURE_SIGNED_APPS_ECDSA_V2_SCHEME data->image_len = end - data->start_addr + sizeof(ets_secure_boot_signature_t); #elif defined(CONFIG_SECURE_SIGNED_APPS_ECDSA_SCHEME) - if (data->start_addr != ESP_BOOTLOADER_OFFSET) { + if (!is_bootloader(data->start_addr)) { data->image_len = end - data->start_addr + sizeof(esp_secure_boot_sig_block_t); } #endif diff --git a/components/bootloader_support/src/flash_encryption/flash_encrypt.c b/components/bootloader_support/src/flash_encryption/flash_encrypt.c index 810cd36c2d1..8a75cd2f111 100644 --- a/components/bootloader_support/src/flash_encryption/flash_encrypt.c +++ b/components/bootloader_support/src/flash_encryption/flash_encrypt.c @@ -43,7 +43,7 @@ static const char *TAG = "flash_encrypt"; /* Static functions for stages of flash encryption */ static esp_err_t encrypt_bootloader(void); -static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions); +static esp_err_t encrypt_and_load_partition_table(uint32_t offset, esp_partition_info_t *partition_table, int *num_partitions); static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition); static size_t get_flash_encrypt_cnt_value(void); @@ -262,12 +262,12 @@ esp_err_t esp_flash_encrypt_contents(void) esp_flash_encryption_enable_key_mgr(); #endif - err = encrypt_bootloader(); + err = encrypt_bootloader(); // PART_SUBTYPE_BOOTLOADER_PRIMARY if (err != ESP_OK) { return err; } - err = encrypt_and_load_partition_table(partition_table, &num_partitions); + err = encrypt_and_load_partition_table(ESP_PRIMARY_PARTITION_TABLE_OFFSET, partition_table, &num_partitions); // PART_SUBTYPE_PARTITION_TABLE_PRIMARY if (err != ESP_OK) { return err; } @@ -277,6 +277,14 @@ esp_err_t esp_flash_encrypt_contents(void) /* Go through each partition and encrypt if necessary */ for (int i = 0; i < num_partitions; i++) { + if ((partition_table[i].type == PART_TYPE_BOOTLOADER && partition_table[i].subtype == PART_SUBTYPE_BOOTLOADER_PRIMARY) + || (partition_table[i].type == PART_TYPE_PARTITION_TABLE && partition_table[i].subtype == PART_SUBTYPE_PARTITION_TABLE_PRIMARY)) { + /* Skip encryption of PRIMARY partitions for bootloader and partition table. + * PRIMARY partitions have already been encrypted above. + * We allow to encrypt partitions that are not PRIMARY. + */ + continue; + } err = encrypt_partition(i, &partition_table[i]); if (err != ESP_OK) { return err; @@ -337,13 +345,13 @@ static esp_err_t encrypt_bootloader(void) #if CONFIG_SECURE_BOOT_V2_ENABLED /* The image length obtained from esp_image_verify_bootloader includes the sector boundary padding and the signature block lengths */ - if (ESP_BOOTLOADER_OFFSET + image_length > ESP_PARTITION_TABLE_OFFSET) { - ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PARTITION_TABLE_OFFSET); + if (image_length > ESP_BOOTLOADER_SIZE) { + ESP_LOGE(TAG, "Bootloader is too large to fit Secure Boot V2 signature sector and partition table (configured offset 0x%x)", ESP_PRIMARY_PARTITION_TABLE_OFFSET); return ESP_ERR_INVALID_SIZE; } #endif // CONFIG_SECURE_BOOT_V2_ENABLED - err = esp_flash_encrypt_region(ESP_BOOTLOADER_OFFSET, image_length); + err = esp_flash_encrypt_region(ESP_PRIMARY_BOOTLOADER_OFFSET, image_length); if (err != ESP_OK) { ESP_LOGE(TAG, "Failed to encrypt bootloader in place: 0x%x", err); return err; @@ -368,53 +376,64 @@ static esp_err_t encrypt_bootloader(void) return ESP_OK; } -static esp_err_t encrypt_and_load_partition_table(esp_partition_info_t *partition_table, int *num_partitions) +static esp_err_t read_and_verify_partition_table(uint32_t offset, esp_partition_info_t *partition_table, int *num_partitions) { esp_err_t err; /* Check for plaintext partition table */ - err = bootloader_flash_read(ESP_PARTITION_TABLE_OFFSET, partition_table, ESP_PARTITION_TABLE_MAX_LEN, false); + err = bootloader_flash_read(offset, partition_table, ESP_PARTITION_TABLE_MAX_LEN, false); if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to read partition table data"); + ESP_LOGE(TAG, "Failed to read partition table data at 0x%" PRIx32, offset); return err; } - if (esp_partition_table_verify(partition_table, false, num_partitions) == ESP_OK) { - ESP_LOGD(TAG, "partition table is plaintext. Encrypting..."); - esp_err_t err = esp_flash_encrypt_region(ESP_PARTITION_TABLE_OFFSET, - FLASH_SECTOR_SIZE); - if (err != ESP_OK) { - ESP_LOGE(TAG, "Failed to encrypt partition table in place. %x", err); - return err; - } - } else { - ESP_LOGE(TAG, "Failed to read partition table data - not plaintext?"); - return ESP_ERR_INVALID_STATE; + err = esp_partition_table_verify(partition_table, false, num_partitions); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to read partition table data - not plaintext or empty?"); } + return err; +} - /* Valid partition table loaded */ +static esp_err_t encrypt_and_load_partition_table(uint32_t offset, esp_partition_info_t *partition_table, int *num_partitions) +{ + esp_err_t err = read_and_verify_partition_table(offset, partition_table, num_partitions); + if (err != ESP_OK) { + return err; + } + ESP_LOGD(TAG, "partition table is plaintext. Encrypting..."); + err = esp_flash_encrypt_region(offset, FLASH_SECTOR_SIZE); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Failed to encrypt partition table in place. %x", err); + return err; + } ESP_LOGI(TAG, "partition table encrypted and loaded successfully"); - return ESP_OK; + return err; } - static esp_err_t encrypt_partition(int index, const esp_partition_info_t *partition) { esp_err_t err; bool should_encrypt = (partition->flags & PART_FLAG_ENCRYPTED); uint32_t size = partition->pos.size; - if (partition->type == PART_TYPE_APP) { - /* check if the partition holds a valid unencrypted app */ + if (partition->type == PART_TYPE_APP || partition->type == PART_TYPE_BOOTLOADER) { + /* check if the partition holds a valid unencrypted app/bootloader */ esp_image_metadata_t image_data = {}; - err = esp_image_verify(ESP_IMAGE_VERIFY, - &partition->pos, - &image_data); + if (partition->type == PART_TYPE_BOOTLOADER) { + esp_image_bootloader_offset_set(partition->pos.offset); + } + err = esp_image_verify(ESP_IMAGE_VERIFY, &partition->pos, &image_data); should_encrypt = (err == ESP_OK); #ifdef CONFIG_SECURE_FLASH_ENCRYPT_ONLY_IMAGE_LEN_IN_APP_PART - if (should_encrypt) { + if (partition->type == PART_TYPE_APP && should_encrypt) { // Encrypt only the app image instead of encrypting the whole partition size = image_data.image_len; } #endif + } else if (partition->type == PART_TYPE_PARTITION_TABLE) { + /* check if the partition holds a valid unencrypted partition table */ + esp_partition_info_t partition_table[ESP_PARTITION_TABLE_MAX_ENTRIES]; + int num_partitions; + err = read_and_verify_partition_table(partition->pos.offset, partition_table, &num_partitions); + should_encrypt = (err == ESP_OK && num_partitions != 0); } else if ((partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_OTA) || (partition->type == PART_TYPE_DATA && partition->subtype == PART_SUBTYPE_DATA_NVS_KEYS)) { /* check if we have ota data partition and the partition should be encrypted unconditionally */ diff --git a/components/bootloader_support/src/flash_partitions.c b/components/bootloader_support/src/flash_partitions.c index 69cf92cbc08..8d0abd039d8 100644 --- a/components/bootloader_support/src/flash_partitions.c +++ b/components/bootloader_support/src/flash_partitions.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -52,10 +52,11 @@ esp_err_t esp_partition_table_verify(const esp_partition_info_t *partition_table } return ESP_ERR_INVALID_STATE; } - //MD5 checksum matches and we continue with the next interation in + //MD5 checksum matches and we continue with the next iteration in //order to detect the end of the partition table md5_found = 1; - } else if (part->magic == 0xFFFF + } else if (num_parts != 0 // the first record cannot be empty, otherwise the whole table is empty + && part->magic == 0xFFFF && part->type == PART_TYPE_END && part->subtype == PART_SUBTYPE_END) { ESP_LOGD(TAG, "partition table verified, %d entries", num_parts); diff --git a/components/partition_table/CMakeLists.txt b/components/partition_table/CMakeLists.txt index 26b8229bc75..89633d19e48 100644 --- a/components/partition_table/CMakeLists.txt +++ b/components/partition_table/CMakeLists.txt @@ -6,6 +6,14 @@ if(NOT ${target} STREQUAL "linux") list(APPEND priv_req esptool_py) endif() +if(NOT DEFINED BOOTLOADER_OFFSET) # For Linux target + if(DEFINED CONFIG_BOOTLOADER_OFFSET_IN_FLASH) + set(BOOTLOADER_OFFSET ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}) + else() + set(BOOTLOADER_OFFSET 0) + endif() +endif() + idf_component_register(PRIV_REQUIRES ${priv_req}) if(non_os_build) @@ -55,8 +63,12 @@ idf_build_get_property(build_dir BUILD_DIR) idf_build_get_property(python PYTHON) idf_build_get_property(extra_subtypes EXTRA_PARTITION_SUBTYPES) -set(gen_partition_table "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" "-q" - "--offset" "${PARTITION_TABLE_OFFSET}" "${md5_opt}" "${flashsize_opt}" +set(gen_partition_table "${python}" "${CMAKE_CURRENT_SOURCE_DIR}/gen_esp32part.py" + "-q" + "--offset" "${PARTITION_TABLE_OFFSET}" + "--primary-bootloader-offset" "${BOOTLOADER_OFFSET}" + "${md5_opt}" + "${flashsize_opt}" "${partition_secure_opt}" ${extra_partition_subtypes} "--") set(partition_table_display diff --git a/components/partition_table/gen_esp32part.py b/components/partition_table/gen_esp32part.py index 6c6592b326c..dea0d8d725b 100755 --- a/components/partition_table/gen_esp32part.py +++ b/components/partition_table/gen_esp32part.py @@ -58,11 +58,11 @@ def get_ptype_as_int(ptype): # Keep this map in sync with esp_partition_subtype_t enum in esp_partition.h SUBTYPES = { BOOTLOADER_TYPE: { - # 'primary': 0x00, # The tool does not allow to define this partition yet. + 'primary': 0x00, 'ota': 0x01, }, PARTITION_TABLE_TYPE: { - # 'primary': 0x00, # The tool does not allow to define this partition yet. + 'primary': 0x00, 'ota': 0x01, }, APP_TYPE: { @@ -153,6 +153,7 @@ def add_extra_subtypes(csv): md5sum = True secure = SECURE_NONE offset_part_table = 0 +primary_bootloader_offset = None def status(msg): @@ -210,6 +211,11 @@ def expand_vars(f): # fix up missing offsets & negative sizes last_end = offset_part_table + PARTITION_TABLE_SIZE # first offset after partition table for e in res: + is_primary_bootloader = (e.type == BOOTLOADER_TYPE and e.subtype == SUBTYPES[e.type]['primary']) + is_primary_partition_table = (e.type == PARTITION_TABLE_TYPE and e.subtype == SUBTYPES[e.type]['primary']) + if is_primary_bootloader or is_primary_partition_table: + # They do not participate in the restoration of missing offsets + continue if e.offset is not None and e.offset < last_end: if e == res[0]: raise InputError('CSV Error at line %d: Partitions overlap. Partition sets offset 0x%x. ' @@ -280,7 +286,10 @@ def verify(self): last = None for p in sorted(self, key=lambda x:x.offset): if p.offset < offset_part_table + PARTITION_TABLE_SIZE: - raise InputError('Partition offset 0x%x is below 0x%x' % (p.offset, offset_part_table + PARTITION_TABLE_SIZE)) + is_primary_bootloader = (p.type == BOOTLOADER_TYPE and p.subtype == SUBTYPES[p.type]['primary']) + is_primary_partition_table = (p.type == PARTITION_TABLE_TYPE and p.subtype == SUBTYPES[p.type]['primary']) + if not (is_primary_bootloader or is_primary_partition_table): + raise InputError('Partition offset 0x%x is below 0x%x' % (p.offset, offset_part_table + PARTITION_TABLE_SIZE)) if last is not None and p.offset < last.offset + last.size: raise InputError('Partition at 0x%x overlaps 0x%x-0x%x' % (p.offset, last.offset, last.offset + last.size - 1)) last = p @@ -388,8 +397,8 @@ def from_csv(cls, line, line_no): res.name = fields[0] res.type = res.parse_type(fields[1]) res.subtype = res.parse_subtype(fields[2]) - res.offset = res.parse_address(fields[3]) - res.size = res.parse_address(fields[4]) + res.offset = res.parse_address(fields[3], res.type, res.subtype) + res.size = res.parse_size(fields[4], res.type) if res.size is None: raise InputError("Size field can't be empty") @@ -443,7 +452,24 @@ def parse_subtype(self, strval): return SUBTYPES[DATA_TYPE]['undefined'] return parse_int(strval, SUBTYPES.get(self.type, {})) - def parse_address(self, strval): + def parse_size(self, strval, ptype): + if ptype == BOOTLOADER_TYPE: + if primary_bootloader_offset is None: + raise InputError(f'Primary bootloader offset is not defined. Please use --primary-bootloader-offset') + return offset_part_table - primary_bootloader_offset + if ptype == PARTITION_TABLE_TYPE: + return PARTITION_TABLE_SIZE + if strval == '': + return None # PartitionTable will fill in default + return parse_int(strval) + + def parse_address(self, strval, ptype, psubtype): + if ptype == BOOTLOADER_TYPE and psubtype == SUBTYPES[ptype]['primary']: + if primary_bootloader_offset is None: + raise InputError(f'Primary bootloader offset is not defined. Please use --primary-bootloader-offset') + return primary_bootloader_offset + if ptype == PARTITION_TABLE_TYPE and psubtype == SUBTYPES[ptype]['primary']: + return offset_part_table if strval == '': return None # PartitionTable will fill in default return parse_int(strval) @@ -563,6 +589,7 @@ def main(): global md5sum global offset_part_table global secure + global primary_bootloader_offset parser = argparse.ArgumentParser(description='ESP32 partition table utility') parser.add_argument('--flash-size', help='Optional flash size limit, checks partition table fits in flash', @@ -573,6 +600,7 @@ def main(): 'enabled by default and this flag does nothing.', action='store_true') parser.add_argument('--quiet', '-q', help="Don't print non-critical status messages to stderr", action='store_true') parser.add_argument('--offset', '-o', help='Set offset partition table', default='0x8000') + parser.add_argument('--primary-bootloader-offset', help='Set primary bootloader offset', default=None) parser.add_argument('--secure', help='Require app partitions to be suitable for secure boot', nargs='?', const=SECURE_V1, choices=[SECURE_V1, SECURE_V2]) parser.add_argument('--extra-partition-subtypes', help='Extra partition subtype entries', nargs='*') parser.add_argument('input', help='Path to CSV or binary file to parse.', type=argparse.FileType('rb')) @@ -585,6 +613,13 @@ def main(): md5sum = not args.disable_md5sum secure = args.secure offset_part_table = int(args.offset, 0) + if args.primary_bootloader_offset is not None: + primary_bootloader_offset = int(args.primary_bootloader_offset, 0) + if primary_bootloader_offset >= offset_part_table: + raise InputError( + f'Unsupported configuration. Primary bootloader must be below partition table. ' + f'Check --primary-bootloader-offset={primary_bootloader_offset:#x} and --offset={offset_part_table:#x}' + ) if args.extra_partition_subtypes: add_extra_subtypes(args.extra_partition_subtypes) diff --git a/components/partition_table/parttool.py b/components/partition_table/parttool.py index 85167f3af14..a979de98b92 100755 --- a/components/partition_table/parttool.py +++ b/components/partition_table/parttool.py @@ -56,12 +56,13 @@ def __init__(self, p_type, subtype, part_list=None): class ParttoolTarget(): - def __init__(self, port=None, baud=None, partition_table_offset=PARTITION_TABLE_OFFSET, partition_table_file=None, + def __init__(self, port=None, baud=None, partition_table_offset=PARTITION_TABLE_OFFSET, primary_bootloader_offset=None, partition_table_file=None, esptool_args=[], esptool_write_args=[], esptool_read_args=[], esptool_erase_args=[]): self.port = port self.baud = baud gen.offset_part_table = partition_table_offset + gen.primary_bootloader_offset = primary_bootloader_offset def parse_esptool_args(esptool_args): results = list() @@ -239,6 +240,7 @@ def main(): parser.add_argument('--baud', '-b', help='baudrate to use', type=int) parser.add_argument('--partition-table-offset', '-o', help='offset to read the partition table from', type=str) + parser.add_argument('--primary-bootloader-offset', help='offset for primary bootloader', type=str) parser.add_argument('--partition-table-file', '-f', help='file (CSV/binary) to read the partition table from; \ overrides device attached to specified port as the partition table source when defined') @@ -313,6 +315,9 @@ def main(): if args.partition_table_offset: target_args['partition_table_offset'] = int(args.partition_table_offset, 0) + if args.primary_bootloader_offset: + target_args['primary_bootloader_offset'] = int(args.primary_bootloader_offset, 0) + if args.esptool_args: target_args['esptool_args'] = args.esptool_args diff --git a/components/partition_table/project_include.cmake b/components/partition_table/project_include.cmake index ddd6230db37..bcbd571c350 100644 --- a/components/partition_table/project_include.cmake +++ b/components/partition_table/project_include.cmake @@ -1,4 +1,11 @@ set(PARTITION_TABLE_OFFSET ${CONFIG_PARTITION_TABLE_OFFSET}) +if(NOT DEFINED BOOTLOADER_OFFSET) # For Linux target + if(DEFINED CONFIG_BOOTLOADER_OFFSET_IN_FLASH) + set(BOOTLOADER_OFFSET ${CONFIG_BOOTLOADER_OFFSET_IN_FLASH}) + else() + set(BOOTLOADER_OFFSET 0) + endif() +endif() set(PARTITION_TABLE_CHECK_SIZES_TOOL_PATH "${CMAKE_CURRENT_LIST_DIR}/check_sizes.py") @@ -58,6 +65,7 @@ function(partition_table_get_partition_info result get_part_info_args part_info) execute_process(COMMAND ${python} ${idf_path}/components/partition_table/parttool.py -q --partition-table-offset ${PARTITION_TABLE_OFFSET} + --primary-bootloader-offset ${BOOTLOADER_OFFSET} --partition-table-file ${PARTITION_CSV_PATH} get_partition_info ${get_part_info_args} --info ${part_info} ${extra_partition_subtypes} diff --git a/components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py b/components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py index 1fcd855e183..13ea53149e7 100755 --- a/components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py +++ b/components/partition_table/test_gen_esp32part_host/gen_esp32part_tests.py @@ -1,8 +1,6 @@ #!/usr/bin/env python -# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD +# SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD # SPDX-License-Identifier: Apache-2.0 -from __future__ import division, print_function - import csv import io import os @@ -64,6 +62,9 @@ def _strip_trailing_ffs(binary_table): class CSVParserTests(Py23TestCase): + def tearDown(self): + gen_esp32part.primary_bootloader_offset = None + gen_esp32part.offset_part_table = 0 def test_simple_partition(self): table = gen_esp32part.PartitionTable.from_csv(SIMPLE_CSV) @@ -182,6 +183,42 @@ def test_unique_name_fail(self): t = gen_esp32part.PartitionTable.from_csv(csv) t.verify() + def test_bootloader_and_part_table_partitions_no_sdkconfig(self): + csv = """ +bootloader, bootloader, primary, N/A, N/A +""" + with self.assertRaisesRegex(gen_esp32part.InputError, 'Primary bootloader offset is not defined. Please use --primary-bootloader-offset'): + gen_esp32part.PartitionTable.from_csv(csv) + + def test_bootloader_and_part_table_partitions(self): + csv = """ +bootloader, bootloader, primary, N/A, N/A +partition_table, partition_table, primary, N/A, N/A +FactoryApp, app, factory, , 1M +OtaBTLDR, bootloader, ota, , N/A +OtaPrtTable, partition_table, ota, , N/A +""" + gen_esp32part.primary_bootloader_offset = 0x1000 + gen_esp32part.offset_part_table = 0x9000 + part_table_size = 0x1000 + bootloader_size = gen_esp32part.offset_part_table - gen_esp32part.primary_bootloader_offset + t = gen_esp32part.PartitionTable.from_csv(csv) + t.verify() + # bootloader + self.assertEqual(t[0].offset, gen_esp32part.primary_bootloader_offset) + self.assertEqual(t[0].size, bootloader_size) + # partition_table + self.assertEqual(t[1].offset, gen_esp32part.offset_part_table) + self.assertEqual(t[1].size, part_table_size) + # FactoryApp + self.assertEqual(t[2].offset, 0x10000) + # OtaBTLDR + self.assertEqual(t[3].offset, 0x110000) + self.assertEqual(t[3].size, bootloader_size) + # OtaPrtTable + self.assertEqual(t[4].offset, 0x118000) + self.assertEqual(t[4].size, part_table_size) + class BinaryOutputTests(Py23TestCase): def test_binary_entry(self): @@ -369,7 +406,7 @@ def test_basic_cmdline(self): from_csv = gen_esp32part.PartitionTable.from_csv(f.read()) self.assertEqual(_strip_trailing_ffs(from_csv.to_binary()), LONGER_BINARY_TABLE) - # run gen_esp32part.py to conver the CSV to binary again + # run gen_esp32part.py to convert the CSV to binary again output = subprocess.check_output([sys.executable, '../gen_esp32part.py', csvpath, binpath], stderr=subprocess.STDOUT) self.assertNotIn(b'WARNING', output) diff --git a/docs/en/api-guides/partition-tables.rst b/docs/en/api-guides/partition-tables.rst index 622a9185e0f..e2c5ec148b3 100644 --- a/docs/en/api-guides/partition-tables.rst +++ b/docs/en/api-guides/partition-tables.rst @@ -73,6 +73,20 @@ The CSV format is the same format as printed in the summaries shown above. Howev * Each non-comment line in the CSV file is a partition definition. * The ``Offset`` field for each partition is empty. The ``gen_esp32part.py`` tool fills in each blank offset, starting after the partition table and making sure each partition is aligned correctly. +Here is an example of a CSV partition table that includes bootloader and partition table partitions: + +.. code-block:: none + + # ESP-IDF Partition Table + # Name, Type, SubType, Offset, Size, Flags + bootloader, bootloader, primary, N/A, N/A, + partition_table, partition_table, primary, N/A, N/A, + nvs, data, nvs, , 0x6000, + phy_init, data, phy, , 0x1000, + factory, app, factory, , 1M, + +The ``gen_esp32part.py`` tool will replace each ``N/A`` with appropriate values based on the selected Kconfig options: {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} for the bootloader offset and :ref:`CONFIG_PARTITION_TABLE_OFFSET` for the partition table offset. + Name Field ~~~~~~~~~~ @@ -83,10 +97,10 @@ Type Field Partition type field can be specified as a name or a number 0-254 (or as hex 0x00-0xFE). Types 0x00-0x3F are reserved for ESP-IDF core functions. -- ``app`` (0x00). -- ``data`` (0x01). -- ``bootloader`` (0x02). By default, this partition is not included in any CSV partition table files because it is not required and does not impact the system's functionality. It is only useful for the bootloader OTA update. Even if this partition is not present in the CSV file, it is still possible to perform the OTA. Please note that if you specify this partition in the CSV file, its address and size must match Kconfigs. -- ``partition_table`` (0x03). +- ``app`` (0x00), +- ``data`` (0x01), +- ``bootloader`` (0x02). By default, this partition is not included in any CSV partition table files in ESP-IDF because it is not required and does not impact the system's functionality. It is only useful for the bootloader OTA updates and flash partitioning. Even if this partition is not present in the CSV file, it is still possible to perform the OTA. +- ``partition_table`` (0x03). By default, this partition also is not included in any CSV partition table files in ESP-IDF. - 0x40-0xFE are reserved for **custom partition types**. If your app needs to store data in a format not already supported by ESP-IDF, then use a value from this range. See :cpp:type:`esp_partition_type_t` for the enum definitions for ``app`` and ``data`` partitions. @@ -120,13 +134,17 @@ See enum :cpp:type:`esp_partition_subtype_t` for the full list of subtypes defin * When type is ``bootloader``, the SubType field can be specified as: - - ``primary`` (0x00). It is the so-called second stage bootloader, which is placed at the {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. - - ``ota`` (0x01). It is a temporary bootloader partition used by the bootloader OTA update functionality for downloading a new image. + - ``primary`` (0x00). This is the 2nd stage bootloader, located at the {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH} address in flash memory. The tool automatically determines the appropriate size and offset for this subtype, so any size or offset specified for this subtype will be ignored. You can either leave these fields blank or use ``N/A`` as a placeholder. + - ``ota`` (0x01). This is a temporary bootloader partition used by the bootloader OTA update functionality to download a new image. The tool ignores the size for this subtype, allowing you to leave it blank or use ``N/A``. You can only specify an offset, or leave it blank to have the tool calculate it based on the offsets of previously used partitions. + + The size of the bootloader type is calculated by the ``gen_esp32part.py`` tool based on the specified ``--offset`` (the partition table offset) and ``--primary-partition-offset`` arguments. Specifically, the bootloader size is defined as (:ref:`CONFIG_PARTITION_TABLE_OFFSET` - {IDF_TARGET_CONFIG_BOOTLOADER_OFFSET_IN_FLASH}). This calculated size applies to all subtypes of the bootloader. * When type is ``partition_table``, the SubType field can be specified as: - - ``primary`` (0x00). It is the primary partition table, which is placed at the :ref:`CONFIG_PARTITION_TABLE_OFFSET` address in the flash. The ``gen_esp32part.py`` does not allow to have this partition in the CSV file for now. - - ``ota`` (0x01). It is a temporary partition table partition used by the partition table OTA update functionality for downloading a new image. + - ``primary`` (0x00). This is the primary partition table, located at the :ref:`CONFIG_PARTITION_TABLE_OFFSET` address in flash memory. The tool automatically determines the appropriate size and offset for this subtype, so any size or offset specified for this subtype will be ignored. You can either leave these fields blank or use ``N/A`` as a placeholder. + - ``ota`` (0x01). It is a temporary partition table partition used by the partition table OTA update functionality for downloading a new image. The tool ignores the size for this subtype, allowing you to leave it blank or use ``N/A``. You can specify an offset, or leave it blank, in which case the tool will calculate it based on the offsets of previously allocated partitions. + + The size for the ``partition_table`` type is fixed at ``0x1000`` and applies uniformly across all subtypes of ``partition_table``. * When type is ``data``, the subtype field can be specified as ``ota`` (0x00), ``phy`` (0x01), ``nvs`` (0x02), nvs_keys (0x04), or a range of other component-specific subtypes (see :cpp:type:`subtype enum `). @@ -185,7 +203,9 @@ Offset & Size - Partitions of type ``app`` have to be placed at offsets aligned to 0x10000 (64 KB). If you leave the offset field blank, ``gen_esp32part.py`` will automatically align the partition. If you specify an unaligned offset for an ``app`` partition, the tool will return an error. - Partitions of type ``app`` should have the size aligned to the flash sector size (4 KB). If you specify an unaligned size for an ``app`` partition, the tool will return an error. :SOC_SECURE_BOOT_V1: - If Secure Boot V1 is enabled, then the partition of type ``app`` needs to have size aligned to 0x10000 (64 KB) boundary. + :SOC_SECURE_BOOT_V1: - The ``bootloader`` offset and size are not affected by the Secure Boot V1 option. Whether Secure Boot V1 is enabled or not, the bootloader remains the same size and does not include the secure digest, which is flashed at offset 0x0 in the flash and occupies one sector (4096 bytes). - Sizes and offsets can be specified as decimal numbers, hex numbers with the prefix 0x, or size multipliers K or M (1024 and 1024*1024 bytes). + - For ``bootloader`` and ``partition_table`` types, specifying ``N/A`` for size and offset in the CSV file means that these values are automatically determined by the tool and cannot be manually defined. This requires setting the ``--offset`` and ``--primary-partition-offset`` arguments of ``gen_esp32part.py``. If you want the partitions in the partition table to work relative to any placement (:ref:`CONFIG_PARTITION_TABLE_OFFSET`) of the table itself, leave the offset field (in CSV file) for all partitions blank. Similarly, if changing the partition table offset then be aware that all blank partition offsets may change to match, and that any fixed offsets may now collide with the partition table (causing an error). @@ -198,7 +218,15 @@ Two flags are currently supported, ``encrypted`` and ``readonly``: .. note:: - ``app`` type partitions will always be encrypted, regardless of whether this flag is set or not. + The following type partitions will always be encrypted, regardless of whether this flag is set or not: + + .. list:: + + - ``app``, + - ``bootloader``, + - ``partition_table``, + - type ``data`` and subtype ``ota``, + - type ``data`` and subtype ``nvs_keys``. - If ``readonly`` flag is set, the partition will be read-only. This flag is only supported for ``data`` type partitions except ``ota``` and ``coredump``` subtypes. This flag can help to protect against accidental writes to a partition that contains critical device-specific configuration data, e.g., factory data partition. diff --git a/examples/system/efuse/test/partitions_efuse_emul.csv b/examples/system/efuse/test/partitions_efuse_emul.csv index 4401ccfe748..32c46f969e0 100644 --- a/examples/system/efuse/test/partitions_efuse_emul.csv +++ b/examples/system/efuse/test/partitions_efuse_emul.csv @@ -1,7 +1,9 @@ -# Name, Type, SubType, Offset, Size, Flags -nvs, data, nvs, , 0x4000, -phy_init, data, phy, , 0x1000, -storage, data, 0xff, , 0x1000, encrypted -nvs_key, data, nvs_keys, , 0x1000, encrypted, -emul_efuse, data, efuse, , 0x2000, -factory, app, factory, , 1M, +# Name, Type, SubType, Offset, Size, Flags +bootloader, bootloader, primary, N/A, N/A, +partition_table, partition_table, primary, N/A, N/A, +nvs, data, nvs, , 0x4000, +phy_init, data, phy, , 0x1000, +storage, data, 0xff, , 0x1000, encrypted +nvs_key, data, nvs_keys, , 0x1000, encrypted, +emul_efuse, data, efuse, , 0x2000, +factory, app, factory, , 1M, From a4ef854a2d1ad1aee472e274c6f7caf8a373d01b Mon Sep 17 00:00:00 2001 From: Fu Hanxi Date: Thu, 31 Oct 2024 11:30:50 +0100 Subject: [PATCH 58/70] ci: use different base commit for merge result pipelines --- .gitlab/ci/pre_check.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.gitlab/ci/pre_check.yml b/.gitlab/ci/pre_check.yml index 2acc5ef0bf5..5b1adf24297 100644 --- a/.gitlab/ci/pre_check.yml +++ b/.gitlab/ci/pre_check.yml @@ -183,12 +183,24 @@ baseline_manifest_sha: tags: [fast_run, shiny] script: - | - if [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then + # merged results pipelines, by default + # diff between target-branch-head and merged-result-head + if [ -n "$CI_MERGE_REQUEST_TARGET_BRANCH_SHA" ]; then + git fetch origin $CI_MERGE_REQUEST_TARGET_BRANCH_SHA --depth=1 + git checkout FETCH_HEAD + idf-build-apps dump-manifest-sha \ + --manifest-files $(find . -name ".build-test-rules.yml" | xargs) \ + --output .manifest_sha + # merge request pipelines, when the mr got conflicts + # diff between diff-base-sha and merge-request-head + elif [ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]; then git fetch origin $CI_MERGE_REQUEST_DIFF_BASE_SHA --depth=1 git checkout FETCH_HEAD idf-build-apps dump-manifest-sha \ --manifest-files $(find . -name ".build-test-rules.yml" | xargs) \ --output .manifest_sha + # other pipelines, like the protected branches pipelines + # not triggered in this job fi artifacts: paths: From 8318adb448b56d79713e77e57fcfc4080f8c6927 Mon Sep 17 00:00:00 2001 From: Peter Dragun Date: Tue, 29 Oct 2024 13:51:31 +0100 Subject: [PATCH 59/70] fix: recommend using Windows Terminal in case of issues with escape sequences Closes https://github.com/espressif/esp-idf-monitor/issues/17 --- components/console/esp_console_common.c | 2 +- examples/system/console/advanced/README.md | 6 +++++- .../system/console/advanced/main/console_example_main.c | 2 +- examples/system/console/basic/README.md | 6 +++++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/components/console/esp_console_common.c b/components/console/esp_console_common.c index 416976dccbb..395aa272f7f 100644 --- a/components/console/esp_console_common.c +++ b/components/console/esp_console_common.c @@ -154,7 +154,7 @@ void esp_console_repl_task(void *args) printf("\r\n" "Your terminal application does not support escape sequences.\n\n" "Line editing and history features are disabled.\n\n" - "On Windows, try using Putty instead.\r\n"); + "On Windows, try using Windows Terminal or Putty instead.\r\n"); } linenoiseSetMaxLineLen(repl_com->max_cmdline_length); diff --git a/examples/system/console/advanced/README.md b/examples/system/console/advanced/README.md index 6a520e850d9..412ba5c0bf9 100644 --- a/examples/system/console/advanced/README.md +++ b/examples/system/console/advanced/README.md @@ -160,10 +160,14 @@ Use UP/DOWN arrows to navigate through command history. Press TAB when typing command name to auto-complete. Your terminal application does not support escape sequences. Line editing and history features are disabled. -On Windows, try using Putty instead. +On Windows, try using Windows Terminal or Putty instead. esp32> ``` +### Escape Sequences on Windows 10 + +When using the default command line or PowerShell on Windows 10, you may see a message indicating that the console does not support escape sequences, as shown in the above output. To avoid such issues, it is recommended to run the serial monitor under [Windows Terminal](https://en.wikipedia.org/wiki/Windows_Terminal), which supports all required escape sequences for the app, unlike the default terminal. The main escape sequence of concern is the Device Status Report (`0x1b[5n`), which is used to check terminal capabilities. Any response to this sequence indicates support. This should not be an issue on Windows 11, where Windows Terminal is the default. + ### No USB port appears On Windows 10, macOS, Linux, USB CDC devices do not require additional drivers to be installed. diff --git a/examples/system/console/advanced/main/console_example_main.c b/examples/system/console/advanced/main/console_example_main.c index 1ca7aee2e8f..b02fc8fb7b1 100644 --- a/examples/system/console/advanced/main/console_example_main.c +++ b/examples/system/console/advanced/main/console_example_main.c @@ -118,7 +118,7 @@ void app_main(void) printf("\n" "Your terminal application does not support escape sequences.\n" "Line editing and history features are disabled.\n" - "On Windows, try using Putty instead.\n"); + "On Windows, try using Windows Terminal or Putty instead.\n"); } /* Main loop */ diff --git a/examples/system/console/basic/README.md b/examples/system/console/basic/README.md index 42387e5c625..cd17e6af15c 100644 --- a/examples/system/console/basic/README.md +++ b/examples/system/console/basic/README.md @@ -147,6 +147,10 @@ Use UP/DOWN arrows to navigate through command history. Press TAB when typing command name to auto-complete. Your terminal application does not support escape sequences. Line editing and history features are disabled. -On Windows, try using Putty instead. +On Windows, try using Windows Terminal or Putty instead. esp32> ``` + +### Escape Sequences on Windows 10 + +When using the default command line or PowerShell on Windows 10, you may see a message indicating that the console does not support escape sequences, as shown in the above output. To avoid such issues, it is recommended to run the serial monitor under [Windows Terminal](https://en.wikipedia.org/wiki/Windows_Terminal), which supports all required escape sequences for the app, unlike the default terminal. The main escape sequence of concern is the Device Status Report (`0x1b[5n`), which is used to check terminal capabilities. Any response to this sequence indicates support. This should not be an issue on Windows 11, where Windows Terminal is the default. From 0e8a933488a4f37a5d14a72cd4f9c68ff4edacad Mon Sep 17 00:00:00 2001 From: Marius Vikhammer Date: Fri, 1 Nov 2024 09:23:47 +0800 Subject: [PATCH 60/70] ci(system): fixed build-test-rules which used ARCH config These variables are not availble when evaluating the rules, resulting in that the tests were never run. --- examples/system/.build-test-rules.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/system/.build-test-rules.yml b/examples/system/.build-test-rules.yml index c5311cbf9f6..7591b17ad1d 100644 --- a/examples/system/.build-test-rules.yml +++ b/examples/system/.build-test-rules.yml @@ -110,14 +110,14 @@ examples/system/himem: examples/system/ipc/ipc_isr/riscv: enable: - - if: IDF_TARGET_ARCH_RISCV == 1 and ESP_IPC_ISR_ENABLE == 1 + - if: IDF_TARGET in ["esp32p4"] reason: The test is intended only for multi-core chips depends_components: - esp_system examples/system/ipc/ipc_isr/xtensa: enable: - - if: IDF_TARGET_ARCH_XTENSA == 1 and ESP_IPC_ISR_ENABLE == 1 + - if: IDF_TARGET in ["esp32", "esp32s3"] reason: The test is intended only for multi-core chips depends_components: - esp_system @@ -128,7 +128,7 @@ examples/system/light_sleep: examples/system/nmi_isr: enable: - - if: IDF_TARGET_ARCH_XTENSA == 1 + - if: IDF_TARGET in ["esp32", "esp32s2", "esp32s3"] reason: test NMI for Xtensa targets only examples/system/ota/advanced_https_ota: From 775c65a6b7284d21b3a97e6e8060ec76f295c2cd Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Tue, 10 Sep 2024 15:10:34 +0800 Subject: [PATCH 61/70] feat(bootloader): add the possibility to specify extra components directories --- components/bootloader/project_include.cmake | 8 ++- .../bootloader/subproject/CMakeLists.txt | 4 +- docs/en/api-guides/build-system.rst | 17 +++++- .../bootloader_extra_dir/CMakeLists.txt | 11 ++++ .../bootloader_extra_dir/README.md | 56 +++++++++++++++++++ .../my_boot_hooks/CMakeLists.txt | 9 +++ .../my_boot_hooks/hooks.c | 17 ++++++ .../extra_component/CMakeLists.txt | 1 + .../extra_component/extra_component.c | 11 ++++ .../bootloader_extra_dir/main/CMakeLists.txt | 2 + .../main/bootloader_hooks_example_main.c | 11 ++++ .../pytest_bootloader_extra_dir.py | 10 ++++ .../ci/check_examples_extra_component_dirs.sh | 3 +- 13 files changed, 152 insertions(+), 8 deletions(-) create mode 100644 examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt create mode 100644 examples/custom_bootloader/bootloader_extra_dir/README.md create mode 100644 examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/CMakeLists.txt create mode 100644 examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/hooks.c create mode 100644 examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/CMakeLists.txt create mode 100644 examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/extra_component.c create mode 100644 examples/custom_bootloader/bootloader_extra_dir/main/CMakeLists.txt create mode 100644 examples/custom_bootloader/bootloader_extra_dir/main/bootloader_hooks_example_main.c create mode 100644 examples/custom_bootloader/bootloader_extra_dir/pytest_bootloader_extra_dir.py diff --git a/components/bootloader/project_include.cmake b/components/bootloader/project_include.cmake index 2afe2116d3b..485a786f9b8 100644 --- a/components/bootloader/project_include.cmake +++ b/components/bootloader/project_include.cmake @@ -116,8 +116,12 @@ idf_build_get_property(sdkconfig SDKCONFIG) idf_build_get_property(python PYTHON) idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS) -# We cannot pass lists are a parameter to the external project without modifying the ';' separator +# BOOTLOADER_EXTRA_COMPONENT_DIRS may have been set by the `main` component, do not overwrite it +list(APPEND BOOTLOADER_EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}") + +# We cannot pass lists as a parameter to the external project without modifying the ';' separator string(REPLACE ";" "|" BOOTLOADER_IGNORE_EXTRA_COMPONENT "${BOOTLOADER_IGNORE_EXTRA_COMPONENT}") +string(REPLACE ";" "|" BOOTLOADER_EXTRA_COMPONENT_DIRS "${BOOTLOADER_EXTRA_COMPONENT_DIRS}") externalproject_add(bootloader SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject" @@ -127,7 +131,7 @@ externalproject_add(bootloader LIST_SEPARATOR | CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON_DEPS_CHECKED=1 -DPYTHON=${python} - -DEXTRA_COMPONENT_DIRS=${CMAKE_CURRENT_LIST_DIR} + -DEXTRA_COMPONENT_DIRS=${BOOTLOADER_EXTRA_COMPONENT_DIRS} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DIGNORE_EXTRA_COMPONENT=${BOOTLOADER_IGNORE_EXTRA_COMPONENT} ${sign_key_arg} ${ver_key_arg} diff --git a/components/bootloader/subproject/CMakeLists.txt b/components/bootloader/subproject/CMakeLists.txt index f630bcc46c7..34c7cded18a 100644 --- a/components/bootloader/subproject/CMakeLists.txt +++ b/components/bootloader/subproject/CMakeLists.txt @@ -34,8 +34,8 @@ set(COMPONENTS esp_system newlib) -# Make EXTRA_COMPONENT_DIRS variable to point to the bootloader_components directory -# of the project being compiled +# EXTRA_COMPONENT_DIRS can be populated with directories containing one or several components. +# Make sure this variable contains `bootloader_components` directory of the project being compiled. set(PROJECT_EXTRA_COMPONENTS "${PROJECT_SOURCE_DIR}/bootloader_components") if(EXISTS ${PROJECT_EXTRA_COMPONENTS}) list(APPEND EXTRA_COMPONENT_DIRS "${PROJECT_EXTRA_COMPONENTS}") diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 37356c0ea8b..ed9862198d6 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -245,7 +245,9 @@ These variables all have default values that can be overridden for custom behavi - ``COMPONENTS``: A list of component names to build into the project. Defaults to all components found in the ``COMPONENT_DIRS`` directories. Use this variable to "trim down" the project for faster build times. Note that any component which "requires" another component via the REQUIRES or PRIV_REQUIRES arguments on component registration will automatically have it added to this list, so the ``COMPONENTS`` list can be very short. -- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``: A list of components, placed in ``bootloader_components/``, that should be ignored by the bootloader compilation. Use this variable if a bootloader component needs to be included conditionally inside the project. +- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``: Optional list of components, placed in ``bootloader_components/``, that should be ignored by the bootloader compilation. Use this variable if a bootloader component needs to be included conditionally inside the project. + +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``: Optional list of additional directories to search for components to be compiled as part of the bootloader. Paths can be relative to the project directory, or absolute. Any paths in these variables can be absolute paths, or set relative to the project directory. @@ -751,7 +753,7 @@ This mechanism is shown in the example :example:`build_system/wrappers`. Check : Override the Default Bootloader ------------------------------- -Thanks to the optional ``bootloader_components`` directory present in your ESP-IDf project, it is possible to override the default ESP-IDF bootloader. To do so, a new ``bootloader_components/main`` component should be defined, which will make the project directory tree look like the following: +Thanks to the optional ``bootloader_components`` directory present in your ESP-IDF project, it is possible to override the default ESP-IDF bootloader. To do so, a new ``bootloader_components/main`` component should be defined, which will make the project directory tree look like the following: - myProject/ - CMakeLists.txt @@ -765,7 +767,7 @@ Thanks to the optional ``bootloader_components`` directory present in your ESP-I - build/ -Here the ``my_bootloader.c`` file becomes source code for the new bootloader, which means that it will need to perform all the required operations to set up and load the ``main`` application from flash. +Here, the ``my_bootloader.c`` file becomes source code for the new bootloader, which means that it will need to perform all the required operations to set up and load the ``main`` application from flash. It is also possible to conditionally replace the bootloader depending on a certain condition, such as the target for example. This can be achieved thanks to the ``BOOTLOADER_IGNORE_EXTRA_COMPONENT`` CMake variable. This list can be used to tell the ESP-IDF bootloader project to ignore and not compile the given components present in ``bootloader_components``. For example, if one wants to use the default bootloader for ESP32 target, then ``myProject/CMakeLists.txt`` should look like the following:: @@ -781,6 +783,15 @@ It is important to note that this can also be used for any other bootloader comp See :example:`custom_bootloader/bootloader_override` for an example of overriding the default bootloader. +Similarly to regular applications, it is possible to include external components, not placed in `bootloader_component`, as part of the bootloader build thanks to the CMake variable ``BOOTLOADER_EXTRA_COMPONENT_DIRS``. It can either refer to a directory that contains several components, either refer to a single component. For example: + + include($ENV{IDF_PATH}/tools/cmake/project.cmake) + + set(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/") + + project(main) + +See :example:`custom_bootloader/bootloader_extra_dir` for an example of adding extra components the bootloader build. .. _config_only_component: diff --git a/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt b/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt new file mode 100644 index 00000000000..64ae357407b --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt @@ -0,0 +1,11 @@ +# For more information about build system see +# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html +# The following five lines of boilerplate have to be in your project's +# CMakeLists in this exact order for cmake to work correctly +cmake_minimum_required(VERSION 3.16) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) + +set(BOOTLOADER_EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/extra_bootloader_components/") + +project(main) diff --git a/examples/custom_bootloader/bootloader_extra_dir/README.md b/examples/custom_bootloader/bootloader_extra_dir/README.md new file mode 100644 index 00000000000..03d842b76e1 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/README.md @@ -0,0 +1,56 @@ +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | -------- | -------- | + +# Bootloader extra component + +(See the README.md file in the upper level for more information about bootloader examples.) + +The purpose of this example is to show how to add a custom directory that contains a component to the bootloader build. + +Registering extra components for the bootloader can be done thanks to the CMake variable `BOOTLOADER_EXTRA_COMPONENT_DIRS`. It works the same way as the application's `EXTRA_COMPONENT_DIRS`, it can either refer to a directory that contains several components, either refer to a single component. + +## Usage of this example: + +Simply compile it: +``` +idf.py build +``` + +Then flash it and open the monitor with the following command: +``` +idf.py flash monitor +``` + +If everything went well, the bootloader should output the following message: +``` +I (60) EXTRA: This function is called from an extra component +``` + +And finally the application will start and show the message: +``` +User application is loaded and running. +``` + +## Organization of this example + +This project contains an application, in the `main` directory that represents an application. It also contains a `bootloader_components` that contains a component compiled and linked with the bootloader. This `bootloader_components` can contain several components, each of them would be in a different directory. + +The directory `extra_bootloader_components/extra_component/` contains a component that is meant to be included in the bootloader build. To do so, the variable `BOOTLOADER_EXTRA_COMPONENT_DIRS` is set from the `CMakeLists.txt` file. + +Below is a short explanation of files in the project folder. + +``` +├── CMakeLists.txt Defines the `BOOTLOADER_EXTRA_COMPONENT_DIRS` variable +├── main +│   ├── CMakeLists.txt +│   └── main.c User application +├── bootloader_components +│   └── my_boot_hooks +│   ├── CMakeLists.txt +│   └── hooks.c Implementation of the hooks to execute on boot +├── extra_bootloader_components +│   └── extra_component +│   ├── CMakeLists.txt +│   └── extra_component.c Implementation of the extra component +└── README.md This is the file you are currently reading +``` diff --git a/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/CMakeLists.txt b/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/CMakeLists.txt new file mode 100644 index 00000000000..6b620571a47 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/CMakeLists.txt @@ -0,0 +1,9 @@ +idf_component_register(SRCS "hooks.c" + REQUIRES extra_component) + +# We need to force GCC to integrate this static library into the +# bootloader link. Indeed, by default, as the hooks in the bootloader are weak, +# the linker would just ignore the symbols in the extra. (i.e. not strictly +# required) +# To do so, we need to define the symbol (function) `bootloader_hooks_include` +# within hooks.c source file. diff --git a/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/hooks.c b/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/hooks.c new file mode 100644 index 00000000000..e72e4570a9d --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/bootloader_components/my_boot_hooks/hooks.c @@ -0,0 +1,17 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ + +extern void bootloader_extra_dir_function(void); + +/* Function used to tell the linker to include this file + * with all its symbols. + */ +void bootloader_hooks_include(void){ +} + +void bootloader_after_init(void) { + bootloader_extra_dir_function(); +} diff --git a/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/CMakeLists.txt b/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/CMakeLists.txt new file mode 100644 index 00000000000..ac58fa9c07e --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/CMakeLists.txt @@ -0,0 +1 @@ +idf_component_register(SRCS "extra_component.c") diff --git a/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/extra_component.c b/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/extra_component.c new file mode 100644 index 00000000000..78b558c5e34 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/extra_bootloader_components/extra_component/extra_component.c @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include "esp_log.h" + +void bootloader_extra_dir_function(void) +{ + ESP_LOGI("EXTRA", "This function is called from an extra component"); +} diff --git a/examples/custom_bootloader/bootloader_extra_dir/main/CMakeLists.txt b/examples/custom_bootloader/bootloader_extra_dir/main/CMakeLists.txt new file mode 100644 index 00000000000..db0df989711 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/main/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "bootloader_hooks_example_main.c" + INCLUDE_DIRS ".") diff --git a/examples/custom_bootloader/bootloader_extra_dir/main/bootloader_hooks_example_main.c b/examples/custom_bootloader/bootloader_extra_dir/main/bootloader_hooks_example_main.c new file mode 100644 index 00000000000..293528a6111 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/main/bootloader_hooks_example_main.c @@ -0,0 +1,11 @@ +/* + * SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Unlicense OR CC0-1.0 + */ +#include + +void app_main(void) +{ + printf("User application is loaded and running.\n"); +} diff --git a/examples/custom_bootloader/bootloader_extra_dir/pytest_bootloader_extra_dir.py b/examples/custom_bootloader/bootloader_extra_dir/pytest_bootloader_extra_dir.py new file mode 100644 index 00000000000..217ce76f8e8 --- /dev/null +++ b/examples/custom_bootloader/bootloader_extra_dir/pytest_bootloader_extra_dir.py @@ -0,0 +1,10 @@ +# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 +import pytest +from pytest_embedded import Dut + + +@pytest.mark.supported_targets +@pytest.mark.generic +def test_custom_bootloader_extra_component(dut: Dut) -> None: + dut.expect_exact('This function is called from an extra component') diff --git a/tools/ci/check_examples_extra_component_dirs.sh b/tools/ci/check_examples_extra_component_dirs.sh index ac71e5975a5..dd2e311342e 100755 --- a/tools/ci/check_examples_extra_component_dirs.sh +++ b/tools/ci/check_examples_extra_component_dirs.sh @@ -5,7 +5,8 @@ set -uo pipefail # Examples shouldn't use EXTRA_COMPONENT_DIRS, instead the dependencies should be specified in idf_component.yml files output=$(find ${IDF_PATH}/examples -name "CMakeLists.txt" -not -path "**/managed_components/**" -not -path "**/build/**") -files=$(egrep "EXTRA_COMPONENT_DIRS" ${output} | cut -d ":" -f 1) +# Make sure the regex doesn't match the text `BOOTLOADER_EXTRA_COMPONENT_DIRS` +files=$(egrep "[^A-Za-Z0-9_]EXTRA_COMPONENT_DIRS" ${output} | cut -d ":" -f 1) found_issues=0 for file in ${files} do From a1df6b818541aaa6b892f50f4b3c58ec76edacd1 Mon Sep 17 00:00:00 2001 From: renpeiying Date: Wed, 18 Sep 2024 16:57:39 +0800 Subject: [PATCH 62/70] docs: Update CN translation for api-guides/build-system.rst --- docs/en/api-guides/build-system.rst | 4 ++-- docs/zh_CN/api-guides/build-system.rst | 13 ++++++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index ed9862198d6..66c821acddb 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -247,7 +247,7 @@ These variables all have default values that can be overridden for custom behavi - ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``: Optional list of components, placed in ``bootloader_components/``, that should be ignored by the bootloader compilation. Use this variable if a bootloader component needs to be included conditionally inside the project. -- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``: Optional list of additional directories to search for components to be compiled as part of the bootloader. Paths can be relative to the project directory, or absolute. +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``: Optional list of additional directories to search for components to be compiled as part of the bootloader. Any paths in these variables can be absolute paths, or set relative to the project directory. @@ -791,7 +791,7 @@ Similarly to regular applications, it is possible to include external components project(main) -See :example:`custom_bootloader/bootloader_extra_dir` for an example of adding extra components the bootloader build. +See :example:`custom_bootloader/bootloader_extra_dir` for an example of adding extra components to the bootloader build. .. _config_only_component: diff --git a/docs/zh_CN/api-guides/build-system.rst b/docs/zh_CN/api-guides/build-system.rst index 05620dded90..9f90e9c122d 100644 --- a/docs/zh_CN/api-guides/build-system.rst +++ b/docs/zh_CN/api-guides/build-system.rst @@ -245,7 +245,9 @@ ESP-IDF 适用于 Python 3.8 以上版本。 - ``COMPONENTS``:要构建进项目中的组件名称列表,默认为 ``COMPONENT_DIRS`` 目录下检索到的所有组件。使用此变量可以“精简”项目以缩短构建时间。请注意,如果一个组件通过 ``COMPONENT_REQUIRES`` 指定了它依赖的另一个组件,则会自动将其添加到 ``COMPONENTS`` 中,所以 ``COMPONENTS`` 列表可能会非常短。 -- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:引导加载程序编译时应忽略的组件列表,位于 ``bootloader_components/`` 目录中。使用这一变量可以将一个组件有条件地包含在项目中。 +- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:可选组件列表,位于 ``bootloader_components/`` 目录中,引导加载程序编译时会被忽略。使用这一变量可以将一个组件有条件地包含在项目中。 + +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``:可选目录列表,用于搜索要作为引导程序的一部分进行编译的组件。 以上变量中的路径可以是绝对路径,或者是相对于项目目录的相对路径。 @@ -781,6 +783,15 @@ KConfig.projbuild 请参考 :example:`custom_bootloader/bootloader_override` 查看覆盖默认引导加载程序的示例。 +与常规应用程序类似,通过 CMake 变量 ``BOOTLOADER_EXTRA_COMPONENT_DIRS`` 可以将不在 `bootloader_component` 中的外部组件作为引导加载程序的一部分进行构建。可以只引用一个组件,也可以引用包含多个组件的路径。例如: + + include($ENV{IDF_PATH}/tools/cmake/project.cmake) + + set(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/") + + project(main) + +请参考 :example:`custom_bootloader/bootloader_extra_dir` 查看向引导加载程序构建过程添加额外组件的示例。 .. _config_only_component: From e33bcaa6d36374d44c0860f74bff62919f21e27a Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Thu, 26 Sep 2024 12:45:50 +0800 Subject: [PATCH 63/70] feat(bootloader): use idf property to specify extra components directories --- components/bootloader/project_include.cmake | 7 ++++--- .../custom_bootloader/bootloader_extra_dir/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/components/bootloader/project_include.cmake b/components/bootloader/project_include.cmake index 485a786f9b8..12cf17dc70a 100644 --- a/components/bootloader/project_include.cmake +++ b/components/bootloader/project_include.cmake @@ -117,11 +117,12 @@ idf_build_get_property(python PYTHON) idf_build_get_property(extra_cmake_args EXTRA_CMAKE_ARGS) # BOOTLOADER_EXTRA_COMPONENT_DIRS may have been set by the `main` component, do not overwrite it -list(APPEND BOOTLOADER_EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}") +idf_build_get_property(bootloader_extra_component_dirs BOOTLOADER_EXTRA_COMPONENT_DIRS) +list(APPEND bootloader_extra_component_dirs "${CMAKE_CURRENT_LIST_DIR}") # We cannot pass lists as a parameter to the external project without modifying the ';' separator string(REPLACE ";" "|" BOOTLOADER_IGNORE_EXTRA_COMPONENT "${BOOTLOADER_IGNORE_EXTRA_COMPONENT}") -string(REPLACE ";" "|" BOOTLOADER_EXTRA_COMPONENT_DIRS "${BOOTLOADER_EXTRA_COMPONENT_DIRS}") +string(REPLACE ";" "|" bootloader_extra_component_dirs "${bootloader_extra_component_dirs}") externalproject_add(bootloader SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/subproject" @@ -131,7 +132,7 @@ externalproject_add(bootloader LIST_SEPARATOR | CMAKE_ARGS -DSDKCONFIG=${sdkconfig} -DIDF_PATH=${idf_path} -DIDF_TARGET=${idf_target} -DPYTHON_DEPS_CHECKED=1 -DPYTHON=${python} - -DEXTRA_COMPONENT_DIRS=${BOOTLOADER_EXTRA_COMPONENT_DIRS} + -DEXTRA_COMPONENT_DIRS=${bootloader_extra_component_dirs} -DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR} -DIGNORE_EXTRA_COMPONENT=${BOOTLOADER_IGNORE_EXTRA_COMPONENT} ${sign_key_arg} ${ver_key_arg} diff --git a/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt b/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt index 64ae357407b..77e21c4ce6e 100644 --- a/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt +++ b/examples/custom_bootloader/bootloader_extra_dir/CMakeLists.txt @@ -6,6 +6,6 @@ cmake_minimum_required(VERSION 3.16) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -set(BOOTLOADER_EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/extra_bootloader_components/") +idf_build_set_property(BOOTLOADER_EXTRA_COMPONENT_DIRS "${CMAKE_CURRENT_LIST_DIR}/extra_bootloader_components/" APPEND) project(main) From a49454e3524c04b72d2379c90de4970457be139b Mon Sep 17 00:00:00 2001 From: renpeiying Date: Wed, 9 Oct 2024 15:46:34 +0800 Subject: [PATCH 64/70] docs: Update CN translation according to review --- docs/zh_CN/api-guides/build-system.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/zh_CN/api-guides/build-system.rst b/docs/zh_CN/api-guides/build-system.rst index 9f90e9c122d..76dd670404d 100644 --- a/docs/zh_CN/api-guides/build-system.rst +++ b/docs/zh_CN/api-guides/build-system.rst @@ -245,9 +245,9 @@ ESP-IDF 适用于 Python 3.8 以上版本。 - ``COMPONENTS``:要构建进项目中的组件名称列表,默认为 ``COMPONENT_DIRS`` 目录下检索到的所有组件。使用此变量可以“精简”项目以缩短构建时间。请注意,如果一个组件通过 ``COMPONENT_REQUIRES`` 指定了它依赖的另一个组件,则会自动将其添加到 ``COMPONENTS`` 中,所以 ``COMPONENTS`` 列表可能会非常短。 -- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:可选组件列表,位于 ``bootloader_components/`` 目录中,引导加载程序编译时会被忽略。使用这一变量可以将一个组件有条件地包含在项目中。 +- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:可选组件列表,位于 ``bootloader_components/`` 目录中,引导加载程序编译时会忽略该列表。使用这一变量可以将一个组件有条件地包含在项目中。 -- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``:可选目录列表,用于搜索要作为引导程序的一部分进行编译的组件。 +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``:可选的附加路径列表,引导加载程序编译时将从这些路径中搜索要编译的组件。 以上变量中的路径可以是绝对路径,或者是相对于项目目录的相对路径。 From 729c55b7906a1b74f3615e8be037b55abf7406ee Mon Sep 17 00:00:00 2001 From: Omar Chebib Date: Wed, 30 Oct 2024 16:16:48 +0800 Subject: [PATCH 65/70] docs: changed bootloader extra component to a property in build-system.rst --- docs/en/api-guides/build-system.rst | 6 +++--- docs/zh_CN/api-guides/build-system.rst | 10 +++++----- .../custom_bootloader/bootloader_extra_dir/README.md | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/en/api-guides/build-system.rst b/docs/en/api-guides/build-system.rst index 66c821acddb..d38e905a134 100644 --- a/docs/en/api-guides/build-system.rst +++ b/docs/en/api-guides/build-system.rst @@ -247,7 +247,7 @@ These variables all have default values that can be overridden for custom behavi - ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``: Optional list of components, placed in ``bootloader_components/``, that should be ignored by the bootloader compilation. Use this variable if a bootloader component needs to be included conditionally inside the project. -- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``: Optional list of additional directories to search for components to be compiled as part of the bootloader. +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``: Optional list of additional directories to search for components to be compiled as part of the bootloader. Please note that this is a build property. Any paths in these variables can be absolute paths, or set relative to the project directory. @@ -783,11 +783,11 @@ It is important to note that this can also be used for any other bootloader comp See :example:`custom_bootloader/bootloader_override` for an example of overriding the default bootloader. -Similarly to regular applications, it is possible to include external components, not placed in `bootloader_component`, as part of the bootloader build thanks to the CMake variable ``BOOTLOADER_EXTRA_COMPONENT_DIRS``. It can either refer to a directory that contains several components, either refer to a single component. For example: +Similarly to regular applications, it is possible to include external components, not placed in `bootloader_component`, as part of the bootloader build thanks to the build property ``BOOTLOADER_EXTRA_COMPONENT_DIRS``. It can either refer to a directory that contains several components, or refer to a single component. For example: include($ENV{IDF_PATH}/tools/cmake/project.cmake) - set(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/") + idf_build_set_property(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/" APPEND) project(main) diff --git a/docs/zh_CN/api-guides/build-system.rst b/docs/zh_CN/api-guides/build-system.rst index 76dd670404d..a4520ec8cf6 100644 --- a/docs/zh_CN/api-guides/build-system.rst +++ b/docs/zh_CN/api-guides/build-system.rst @@ -245,9 +245,9 @@ ESP-IDF 适用于 Python 3.8 以上版本。 - ``COMPONENTS``:要构建进项目中的组件名称列表,默认为 ``COMPONENT_DIRS`` 目录下检索到的所有组件。使用此变量可以“精简”项目以缩短构建时间。请注意,如果一个组件通过 ``COMPONENT_REQUIRES`` 指定了它依赖的另一个组件,则会自动将其添加到 ``COMPONENTS`` 中,所以 ``COMPONENTS`` 列表可能会非常短。 -- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:可选组件列表,位于 ``bootloader_components/`` 目录中,引导加载程序编译时会忽略该列表。使用这一变量可以将一个组件有条件地包含在项目中。 +- ``BOOTLOADER_IGNORE_EXTRA_COMPONENT``:可选组件列表,位于 ``bootloader_components/`` 目录中,引导加载程序编译时会忽略该列表中的组件。使用这一变量可以将一个组件有条件地包含在项目中。 -- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``:可选的附加路径列表,引导加载程序编译时将从这些路径中搜索要编译的组件。 +- ``BOOTLOADER_EXTRA_COMPONENT_DIRS``:可选的附加路径列表,引导加载程序编译时将从这些路径中搜索要编译的组件。注意,这是一个构建属性。 以上变量中的路径可以是绝对路径,或者是相对于项目目录的相对路径。 @@ -783,15 +783,15 @@ KConfig.projbuild 请参考 :example:`custom_bootloader/bootloader_override` 查看覆盖默认引导加载程序的示例。 -与常规应用程序类似,通过 CMake 变量 ``BOOTLOADER_EXTRA_COMPONENT_DIRS`` 可以将不在 `bootloader_component` 中的外部组件作为引导加载程序的一部分进行构建。可以只引用一个组件,也可以引用包含多个组件的路径。例如: +与常规应用程序类似,通过构建属性 ``BOOTLOADER_EXTRA_COMPONENT_DIRS`` 可以将不在 `bootloader_component` 中的外部组件作为引导加载程序的一部分进行构建。可以只引用一个组件,也可以引用包含多个组件的路径。例如: include($ENV{IDF_PATH}/tools/cmake/project.cmake) - set(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/") + idf_build_set_property(BOOTLOADER_EXTRA_COMPONENT_DIRS "/path/to/extra/component/" APPEND) project(main) -请参考 :example:`custom_bootloader/bootloader_extra_dir` 查看向引导加载程序构建过程添加额外组件的示例。 +请参考示例 :example:`custom_bootloader/bootloader_extra_dir`,查看如何向引导加载程序构建过程添加额外的组件。 .. _config_only_component: diff --git a/examples/custom_bootloader/bootloader_extra_dir/README.md b/examples/custom_bootloader/bootloader_extra_dir/README.md index 03d842b76e1..9d0b0021ace 100644 --- a/examples/custom_bootloader/bootloader_extra_dir/README.md +++ b/examples/custom_bootloader/bootloader_extra_dir/README.md @@ -7,7 +7,7 @@ The purpose of this example is to show how to add a custom directory that contains a component to the bootloader build. -Registering extra components for the bootloader can be done thanks to the CMake variable `BOOTLOADER_EXTRA_COMPONENT_DIRS`. It works the same way as the application's `EXTRA_COMPONENT_DIRS`, it can either refer to a directory that contains several components, either refer to a single component. +Registering extra components for the bootloader can be done thanks to the IDF property `BOOTLOADER_EXTRA_COMPONENT_DIRS`. It can either refer to a directory that contains several components, either refer to a single component. ## Usage of this example: @@ -33,14 +33,14 @@ User application is loaded and running. ## Organization of this example -This project contains an application, in the `main` directory that represents an application. It also contains a `bootloader_components` that contains a component compiled and linked with the bootloader. This `bootloader_components` can contain several components, each of them would be in a different directory. +This project contains a `main` directory that represents an application. It also has a `bootloader_components` directory that contains a component that will be compiled and linked with the bootloader. This `bootloader_components` can contain several components, each of them would be in a different directory. -The directory `extra_bootloader_components/extra_component/` contains a component that is meant to be included in the bootloader build. To do so, the variable `BOOTLOADER_EXTRA_COMPONENT_DIRS` is set from the `CMakeLists.txt` file. +The directory `extra_bootloader_components/extra_component/` contains a component that is meant to be included in the bootloader build. To do so, the CMake property `BOOTLOADER_EXTRA_COMPONENT_DIRS` is set from the `CMakeLists.txt` file. Below is a short explanation of files in the project folder. ``` -├── CMakeLists.txt Defines the `BOOTLOADER_EXTRA_COMPONENT_DIRS` variable +├── CMakeLists.txt Defines the `BOOTLOADER_EXTRA_COMPONENT_DIRS` property ├── main │   ├── CMakeLists.txt │   └── main.c User application From 8fb28dcedcc49916a5206456a3a61022d4302cd8 Mon Sep 17 00:00:00 2001 From: zhangyanjiao Date: Mon, 21 Oct 2024 16:40:00 +0800 Subject: [PATCH 66/70] fix(wifi): Support AES IV with random value in esptouch v2 --- components/esp_wifi/lib | 2 +- docs/en/api-reference/network/esp_smartconfig.rst | 7 +++++++ docs/zh_CN/api-reference/network/esp_smartconfig.rst | 7 +++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/components/esp_wifi/lib b/components/esp_wifi/lib index cde7c641e30..5d2a37fe25f 160000 --- a/components/esp_wifi/lib +++ b/components/esp_wifi/lib @@ -1 +1 @@ -Subproject commit cde7c641e30d4ae701c4949f1792e0dea6d2d703 +Subproject commit 5d2a37fe25fd64fd0fcdeb3b7cd82e252fa043ac diff --git a/docs/en/api-reference/network/esp_smartconfig.rst b/docs/en/api-reference/network/esp_smartconfig.rst index d94091e8190..f7159fc6410 100644 --- a/docs/en/api-reference/network/esp_smartconfig.rst +++ b/docs/en/api-reference/network/esp_smartconfig.rst @@ -3,10 +3,17 @@ SmartConfig :link_to_translation:`zh_CN:[中文]` +Introduction +------------ + The SmartConfig\ :sup:`TM` is a provisioning technology developed by TI to connect a new Wi-Fi device to a Wi-Fi network. It uses a mobile application to broadcast the network credentials from a smartphone, or a tablet, to an un-provisioned Wi-Fi device. The advantage of this technology is that the device does not need to directly know SSID or password of an Access Point (AP). This information is provided using the smartphone. This is particularly important to headless device and systems, due to their lack of a user interface. +Currently, {IDF_TARGET_NAME} support three types of SmartConfig: Airkiss, ESPTouch, and ESPTouch v2. ESPTouch v2 has been supported since SmartConfig v3.0 (the version of SmartConfig can be get from :cpp:func:`esp_smartconfig_get_version()`), and it employs a completely different algorithm compared to ESPTouch, resulting in faster setup times. Additionally, ESPTouch v2 introduces AES encryption and custom data fields. + +Starting from SmartConfig v3.0.2, ESPTouch v2 introduces support for random IV in AES encryption. On the application side, when the option for random IV is disabled, the default IV is set to 0, maintaining consistency with previous versions. When the random IV option is enabled, the IV will be a random value. It is important to note that when AES encryption is enabled with a random IV, the provision time will be extended due to the need of transmitting the IV to the provisioning device. On the provisioning device side, the device will identify whether the random IV for AES is enabled based on the flag in the provisioning packet. + If you are looking for other options to provision your {IDF_TARGET_NAME} devices, check :doc:`../provisioning/index`. diff --git a/docs/zh_CN/api-reference/network/esp_smartconfig.rst b/docs/zh_CN/api-reference/network/esp_smartconfig.rst index 70f77b0d698..56185702cba 100644 --- a/docs/zh_CN/api-reference/network/esp_smartconfig.rst +++ b/docs/zh_CN/api-reference/network/esp_smartconfig.rst @@ -3,10 +3,17 @@ SmartConfig :link_to_translation:`en:[English]` +概述 +----- + SmartConfig\ :sup:`TM` 是由 TI 开发的配网技术,用于将新的 Wi-Fi 设备连接到 Wi-Fi 网络。它使用移动应用程序将无线网凭据从智能手机或平板电脑端广播给未配网的 Wi-Fi 设备。 这项技术的优势在于,设备无需直接获知 AP 的 SSID 或密码,而是通过智能手机获取。这对于没有用户界面的无头设备和系统而言十分重要。 +目前, {IDF_TARGET_NAME} 支持三种类型的 SmartConfig 配网: Airkiss、ESPTouch 和 ESPTouch v2。ESPTouch v2 自 SmartConfig v3.0 (SmartConfig 的版本可以从 :cpp:func:`esp_smartconfig_get_version()` 获取)起开始支持,ESPTouch v2 和 vESPTouch 采用完全不同的配网算法,因此配网速度更快。此外,ESPTouch v2 还增加了 AES 加密功能和自定义数据字段。 + +从 SmartConfig v3.0.2 开始,ESPTouch v2 的 AES 加密支持随机 IV。在应用程序端,当随机 IV 的选项关闭的时候,默认的 IV 为 0,与旧版本保持一致,当随机 IV 的选项打开的时候,IV 为随机值。需要注意的是,当启用 AES 加密且 IV 为随机值时,配网时间会延长,因为需要将 IV 传输到配网设备。在配网设备端,设备会根据配网包中的 flag 来识别 AES 的随机 IV 是否开启。 + 如需通过其他方式为 {IDF_TARGET_NAME} 设备配网,请参阅 :doc:`../provisioning/index`。 From d1e5fd08ffb36c7cf584d7a44e210f97daddf4e6 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Fri, 1 Nov 2024 10:16:06 +0100 Subject: [PATCH 67/70] fix(sysview): reduce isr stack usage to avoid stack guard exception --- .../Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/app_trace/sys_view/Sample/FreeRTOSV10.4/Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c b/components/app_trace/sys_view/Sample/FreeRTOSV10.4/Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c index fcf33d365af..c01cbed67ea 100644 --- a/components/app_trace/sys_view/Sample/FreeRTOSV10.4/Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c +++ b/components/app_trace/sys_view/Sample/FreeRTOSV10.4/Config/esp/SEGGER_SYSVIEW_Config_FreeRTOS.c @@ -3,7 +3,7 @@ * * SPDX-License-Identifier: BSD-1-Clause * - * SPDX-FileContributor: 2017-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileContributor: 2017-2024 Espressif Systems (Shanghai) CO LTD */ /********************************************************************* * SEGGER Microcontroller GmbH * @@ -58,6 +58,7 @@ File : SEGGER_SYSVIEW_Config_FreeRTOS.c Purpose : Sample setup configuration of SystemView with FreeRTOS. Revision: $Rev: 7745 $ */ +#include #include "sdkconfig.h" #include "freertos/FreeRTOS.h" #include "SEGGER_SYSVIEW.h" @@ -156,15 +157,16 @@ static esp_apptrace_lock_t s_sys_view_lock = {.mux = portMUX_INITIALIZER_UNLOCKE * Sends SystemView description strings. */ static void _cbSendSystemDesc(void) { - char irq_str[32]; + char irq_str[32] = "I#"; SEGGER_SYSVIEW_SendSysDesc("N="SYSVIEW_APP_NAME",D="SYSVIEW_DEVICE_NAME",C="SYSVIEW_CORE_NAME",O=FreeRTOS"); - snprintf(irq_str, sizeof(irq_str), "I#%d=SysTick", SYSTICK_INTR_ID); + strcat(itoa(SYSTICK_INTR_ID, irq_str + 2, 10), "=SysTick"); SEGGER_SYSVIEW_SendSysDesc(irq_str); size_t isr_count = sizeof(esp_isr_names)/sizeof(esp_isr_names[0]); for (size_t i = 0; i < isr_count; ++i) { if (esp_isr_names[i] == NULL || (ETS_INTERNAL_INTR_SOURCE_OFF + i) == SYSTICK_INTR_ID) continue; - snprintf(irq_str, sizeof(irq_str), "I#%d=%s", ETS_INTERNAL_INTR_SOURCE_OFF + i, esp_isr_names[i]); + strcat(itoa(ETS_INTERNAL_INTR_SOURCE_OFF + i, irq_str + 2, 10), "="); + strncat(irq_str, esp_isr_names[i], sizeof(irq_str) - strlen(irq_str) - 1); SEGGER_SYSVIEW_SendSysDesc(irq_str); } } From 5b1891c2fad9407dd341349453d12bcbfd146d74 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Mon, 30 Sep 2024 14:22:31 +0300 Subject: [PATCH 68/70] feat(efuse): Adds efuse ADC calib data for ESP32-P4 --- components/efuse/esp32p4/esp_efuse_table.c | 1082 ++++++++++++++++- components/efuse/esp32p4/esp_efuse_table.csv | 116 +- .../efuse/esp32p4/include/esp_efuse_table.h | 117 +- .../soc/esp32p4/register/soc/efuse_reg.h | 482 ++++++-- .../soc/esp32p4/register/soc/efuse_struct.h | 252 +++- 5 files changed, 1882 insertions(+), 167 deletions(-) diff --git a/components/efuse/esp32p4/esp_efuse_table.c b/components/efuse/esp32p4/esp_efuse_table.c index 990c984365d..049cd56f113 100644 --- a/components/efuse/esp32p4/esp_efuse_table.c +++ b/components/efuse/esp32p4/esp_efuse_table.c @@ -9,7 +9,7 @@ #include #include "esp_efuse_table.h" -// md5_digest_table 0d4e1f49db99de4dd9d3eac8d8e6078b +// md5_digest_table c56ed98dde7a08c8f70d57a01faba96a // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -287,10 +287,122 @@ static const esp_efuse_desc_t WR_DIS_SYS_DATA_PART1[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of BLOCK2, }; +static const esp_efuse_desc_t WR_DIS_LDO_VO1_DREF[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO1_DREF, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO2_DREF[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO2_DREF, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO1_MUL[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO1_MUL, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO2_MUL[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO2_MUL, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO3_K[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO3_K, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO3_VOS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO3_VOS, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO3_C[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO3_C, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO4_K[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO4_K, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO4_VOS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO4_VOS, +}; + +static const esp_efuse_desc_t WR_DIS_LDO_VO4_C[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LDO_VO4_C, +}; + +static const esp_efuse_desc_t WR_DIS_ACTIVE_HP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of ACTIVE_HP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_ACTIVE_LP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of ACTIVE_LP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_LSLP_HP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LSLP_HP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_DSLP_DBG[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of DSLP_DBG, +}; + +static const esp_efuse_desc_t WR_DIS_DSLP_LP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of DSLP_LP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_LP_DCDC_DBIAS_VOL_GAP[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LP_DCDC_DBIAS_VOL_GAP, +}; + static const esp_efuse_desc_t WR_DIS_OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of OPTIONAL_UNIQUE_ID, }; +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC2_AVE_INITCODE_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC2_AVE_INITCODE_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC2_AVE_INITCODE_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC2_AVE_INITCODE_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN3, +}; + static const esp_efuse_desc_t WR_DIS_BLOCK_USR_DATA[] = { {EFUSE_BLK0, 22, 1}, // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA, }; @@ -327,6 +439,82 @@ static const esp_efuse_desc_t WR_DIS_BLOCK_SYS_DATA2[] = { {EFUSE_BLK0, 29, 1}, // [WR_DIS.SYS_DATA_PART2] wr_dis of BLOCK_SYS_DATA2, }; +static const esp_efuse_desc_t WR_DIS_ADC2_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_HI_DOUT_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_HI_DOUT_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_HI_DOUT_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_HI_DOUT_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_TEMPERATURE_SENSOR[] = { + {EFUSE_BLK0, 29, 1}, // [] wr_dis of TEMPERATURE_SENSOR, +}; + static const esp_efuse_desc_t WR_DIS_USB_DEVICE_EXCHG_PINS[] = { {EFUSE_BLK0, 30, 1}, // [] wr_dis of USB_DEVICE_EXCHG_PINS, }; @@ -375,6 +563,82 @@ static const esp_efuse_desc_t RD_DIS_BLOCK_SYS_DATA2[] = { {EFUSE_BLK0, 38, 1}, // [RD_DIS.SYS_DATA_PART2] rd_dis of BLOCK_SYS_DATA2, }; +static const esp_efuse_desc_t RD_DIS_ADC2_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_HI_DOUT_ATTEN0, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_HI_DOUT_ATTEN1, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_HI_DOUT_ATTEN2, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_HI_DOUT_ATTEN3, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t RD_DIS_TEMPERATURE_SENSOR[] = { + {EFUSE_BLK0, 38, 1}, // [] rd_dis of TEMPERATURE_SENSOR, +}; + static const esp_efuse_desc_t USB_DEVICE_EXCHG_PINS[] = { {EFUSE_BLK0, 39, 1}, // [] Enable usb device exchange pins of D+ and D-, }; @@ -664,10 +928,122 @@ static const esp_efuse_desc_t PKG_VERSION[] = { {EFUSE_BLK1, 84, 3}, // [] Package version, }; +static const esp_efuse_desc_t LDO_VO1_DREF[] = { + {EFUSE_BLK1, 88, 4}, // [] Output VO1 parameter, +}; + +static const esp_efuse_desc_t LDO_VO2_DREF[] = { + {EFUSE_BLK1, 92, 4}, // [] Output VO2 parameter, +}; + +static const esp_efuse_desc_t LDO_VO1_MUL[] = { + {EFUSE_BLK1, 96, 3}, // [] Output VO1 parameter, +}; + +static const esp_efuse_desc_t LDO_VO2_MUL[] = { + {EFUSE_BLK1, 99, 3}, // [] Output VO2 parameter, +}; + +static const esp_efuse_desc_t LDO_VO3_K[] = { + {EFUSE_BLK1, 102, 8}, // [] Output VO3 calibration parameter, +}; + +static const esp_efuse_desc_t LDO_VO3_VOS[] = { + {EFUSE_BLK1, 110, 6}, // [] Output VO3 calibration parameter, +}; + +static const esp_efuse_desc_t LDO_VO3_C[] = { + {EFUSE_BLK1, 116, 6}, // [] Output VO3 calibration parameter, +}; + +static const esp_efuse_desc_t LDO_VO4_K[] = { + {EFUSE_BLK1, 122, 8}, // [] Output VO4 calibration parameter, +}; + +static const esp_efuse_desc_t LDO_VO4_VOS[] = { + {EFUSE_BLK1, 130, 6}, // [] Output VO4 calibration parameter, +}; + +static const esp_efuse_desc_t LDO_VO4_C[] = { + {EFUSE_BLK1, 136, 6}, // [] Output VO4 calibration parameter, +}; + +static const esp_efuse_desc_t ACTIVE_HP_DBIAS[] = { + {EFUSE_BLK1, 144, 4}, // [] Active HP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t ACTIVE_LP_DBIAS[] = { + {EFUSE_BLK1, 148, 4}, // [] Active LP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t LSLP_HP_DBIAS[] = { + {EFUSE_BLK1, 152, 4}, // [] LSLP HP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t DSLP_DBG[] = { + {EFUSE_BLK1, 156, 4}, // [] DSLP BDG of fixed voltage, +}; + +static const esp_efuse_desc_t DSLP_LP_DBIAS[] = { + {EFUSE_BLK1, 160, 5}, // [] DSLP LP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t LP_DCDC_DBIAS_VOL_GAP[] = { + {EFUSE_BLK1, 165, 5}, // [] DBIAS gap between LP and DCDC, +}; + static const esp_efuse_desc_t OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK2, 0, 128}, // [] Optional unique 128-bit ID, }; +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK2, 128, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK2, 138, 10}, // [] Average initcode of ADC1 atten1, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK2, 148, 10}, // [] Average initcode of ADC1 atten2, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK2, 158, 10}, // [] Average initcode of ADC1 atten3, +}; + +static const esp_efuse_desc_t ADC2_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK2, 168, 10}, // [] Average initcode of ADC2 atten0, +}; + +static const esp_efuse_desc_t ADC2_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK2, 178, 10}, // [] Average initcode of ADC2 atten1, +}; + +static const esp_efuse_desc_t ADC2_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK2, 188, 10}, // [] Average initcode of ADC2 atten2, +}; + +static const esp_efuse_desc_t ADC2_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK2, 198, 10}, // [] Average initcode of ADC2 atten3, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK2, 208, 10}, // [] HI_DOUT of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK2, 218, 10}, // [] HI_DOUT of ADC1 atten1, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK2, 228, 10}, // [] HI_DOUT of ADC1 atten2, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK2, 238, 10}, // [] HI_DOUT of ADC1 atten3, +}; + static const esp_efuse_desc_t USER_DATA[] = { {EFUSE_BLK3, 0, 256}, // [BLOCK_USR_DATA] User data, }; @@ -700,8 +1076,80 @@ static const esp_efuse_desc_t KEY5[] = { {EFUSE_BLK9, 0, 256}, // [BLOCK_KEY5] Key5 or user data, }; -static const esp_efuse_desc_t SYS_DATA_PART2[] = { - {EFUSE_BLK10, 0, 256}, // [BLOCK_SYS_DATA2] System data part 2 (reserved), +static const esp_efuse_desc_t ADC2_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK10, 0, 10}, // [] HI_DOUT of ADC2 atten0, +}; + +static const esp_efuse_desc_t ADC2_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK10, 10, 10}, // [] HI_DOUT of ADC2 atten1, +}; + +static const esp_efuse_desc_t ADC2_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK10, 20, 10}, // [] HI_DOUT of ADC2 atten2, +}; + +static const esp_efuse_desc_t ADC2_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK10, 30, 10}, // [] HI_DOUT of ADC2 atten3, +}; + +static const esp_efuse_desc_t ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 40, 4}, // [] Gap between ADC1_ch0 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 44, 4}, // [] Gap between ADC1_ch1 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 48, 4}, // [] Gap between ADC1_ch2 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 52, 4}, // [] Gap between ADC1_ch3 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 56, 4}, // [] Gap between ADC1_ch4 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 60, 4}, // [] Gap between ADC1_ch5 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 64, 4}, // [] Gap between ADC1_ch6 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 68, 4}, // [] Gap between ADC1_ch7 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 72, 4}, // [] Gap between ADC2_ch0 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 76, 4}, // [] Gap between ADC2_ch1 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 80, 4}, // [] Gap between ADC2_ch2 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 84, 4}, // [] Gap between ADC2_ch3 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 88, 4}, // [] Gap between ADC2_ch4 and average initcode, +}; + +static const esp_efuse_desc_t ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK10, 92, 4}, // [] Gap between ADC2_ch5 and average initcode, +}; + +static const esp_efuse_desc_t TEMPERATURE_SENSOR[] = { + {EFUSE_BLK10, 96, 9}, // [] Temperature calibration data, }; @@ -1048,83 +1496,318 @@ const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[] = { NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[] = { - &WR_DIS_OPTIONAL_UNIQUE_ID[0], // [] wr_dis of OPTIONAL_UNIQUE_ID +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO1_DREF[] = { + &WR_DIS_LDO_VO1_DREF[0], // [] wr_dis of LDO_VO1_DREF NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[] = { - &WR_DIS_BLOCK_USR_DATA[0], // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO2_DREF[] = { + &WR_DIS_LDO_VO2_DREF[0], // [] wr_dis of LDO_VO2_DREF NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_CUSTOM_MAC[] = { - &WR_DIS_CUSTOM_MAC[0], // [WR_DIS.MAC_CUSTOM WR_DIS.USER_DATA_MAC_CUSTOM] wr_dis of CUSTOM_MAC +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO1_MUL[] = { + &WR_DIS_LDO_VO1_MUL[0], // [] wr_dis of LDO_VO1_MUL NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY0[] = { - &WR_DIS_BLOCK_KEY0[0], // [WR_DIS.KEY0] wr_dis of BLOCK_KEY0 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO2_MUL[] = { + &WR_DIS_LDO_VO2_MUL[0], // [] wr_dis of LDO_VO2_MUL NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY1[] = { - &WR_DIS_BLOCK_KEY1[0], // [WR_DIS.KEY1] wr_dis of BLOCK_KEY1 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_K[] = { + &WR_DIS_LDO_VO3_K[0], // [] wr_dis of LDO_VO3_K NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY2[] = { - &WR_DIS_BLOCK_KEY2[0], // [WR_DIS.KEY2] wr_dis of BLOCK_KEY2 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_VOS[] = { + &WR_DIS_LDO_VO3_VOS[0], // [] wr_dis of LDO_VO3_VOS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY3[] = { - &WR_DIS_BLOCK_KEY3[0], // [WR_DIS.KEY3] wr_dis of BLOCK_KEY3 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_C[] = { + &WR_DIS_LDO_VO3_C[0], // [] wr_dis of LDO_VO3_C NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY4[] = { - &WR_DIS_BLOCK_KEY4[0], // [WR_DIS.KEY4] wr_dis of BLOCK_KEY4 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_K[] = { + &WR_DIS_LDO_VO4_K[0], // [] wr_dis of LDO_VO4_K NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY5[] = { - &WR_DIS_BLOCK_KEY5[0], // [WR_DIS.KEY5] wr_dis of BLOCK_KEY5 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_VOS[] = { + &WR_DIS_LDO_VO4_VOS[0], // [] wr_dis of LDO_VO4_VOS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_SYS_DATA2[] = { - &WR_DIS_BLOCK_SYS_DATA2[0], // [WR_DIS.SYS_DATA_PART2] wr_dis of BLOCK_SYS_DATA2 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_C[] = { + &WR_DIS_LDO_VO4_C[0], // [] wr_dis of LDO_VO4_C NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_DEVICE_EXCHG_PINS[] = { - &WR_DIS_USB_DEVICE_EXCHG_PINS[0], // [] wr_dis of USB_DEVICE_EXCHG_PINS +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_HP_DBIAS[] = { + &WR_DIS_ACTIVE_HP_DBIAS[0], // [] wr_dis of ACTIVE_HP_DBIAS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_OTG11_EXCHG_PINS[] = { - &WR_DIS_USB_OTG11_EXCHG_PINS[0], // [] wr_dis of USB_OTG11_EXCHG_PINS +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_LP_DBIAS[] = { + &WR_DIS_ACTIVE_LP_DBIAS[0], // [] wr_dis of ACTIVE_LP_DBIAS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_PHY_SEL[] = { - &WR_DIS_USB_PHY_SEL[0], // [] wr_dis of USB_PHY_SEL +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBIAS[] = { + &WR_DIS_LSLP_HP_DBIAS[0], // [] wr_dis of LSLP_HP_DBIAS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SOFT_DIS_JTAG[] = { - &WR_DIS_SOFT_DIS_JTAG[0], // [] wr_dis of SOFT_DIS_JTAG +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_DBG[] = { + &WR_DIS_DSLP_DBG[0], // [] wr_dis of DSLP_DBG NULL }; -const esp_efuse_desc_t* ESP_EFUSE_RD_DIS[] = { - &RD_DIS[0], // [] Disable reading from BlOCK4-10 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBIAS[] = { + &WR_DIS_DSLP_LP_DBIAS[0], // [] wr_dis of DSLP_LP_DBIAS NULL }; -const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLOCK_KEY0[] = { - &RD_DIS_BLOCK_KEY0[0], // [RD_DIS.KEY0] rd_dis of BLOCK_KEY0 +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LP_DCDC_DBIAS_VOL_GAP[] = { + &WR_DIS_LP_DCDC_DBIAS_VOL_GAP[0], // [] wr_dis of LP_DCDC_DBIAS_VOL_GAP + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[] = { + &WR_DIS_OPTIONAL_UNIQUE_ID[0], // [] wr_dis of OPTIONAL_UNIQUE_ID + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN0[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN0[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN1[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN1[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN2[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN2[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN3[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN3[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN0[] = { + &WR_DIS_ADC2_AVE_INITCODE_ATTEN0[0], // [] wr_dis of ADC2_AVE_INITCODE_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN1[] = { + &WR_DIS_ADC2_AVE_INITCODE_ATTEN1[0], // [] wr_dis of ADC2_AVE_INITCODE_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN2[] = { + &WR_DIS_ADC2_AVE_INITCODE_ATTEN2[0], // [] wr_dis of ADC2_AVE_INITCODE_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN3[] = { + &WR_DIS_ADC2_AVE_INITCODE_ATTEN3[0], // [] wr_dis of ADC2_AVE_INITCODE_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN0[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN1[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN2[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN3[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[] = { + &WR_DIS_BLOCK_USR_DATA[0], // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_CUSTOM_MAC[] = { + &WR_DIS_CUSTOM_MAC[0], // [WR_DIS.MAC_CUSTOM WR_DIS.USER_DATA_MAC_CUSTOM] wr_dis of CUSTOM_MAC + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY0[] = { + &WR_DIS_BLOCK_KEY0[0], // [WR_DIS.KEY0] wr_dis of BLOCK_KEY0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY1[] = { + &WR_DIS_BLOCK_KEY1[0], // [WR_DIS.KEY1] wr_dis of BLOCK_KEY1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY2[] = { + &WR_DIS_BLOCK_KEY2[0], // [WR_DIS.KEY2] wr_dis of BLOCK_KEY2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY3[] = { + &WR_DIS_BLOCK_KEY3[0], // [WR_DIS.KEY3] wr_dis of BLOCK_KEY3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY4[] = { + &WR_DIS_BLOCK_KEY4[0], // [WR_DIS.KEY4] wr_dis of BLOCK_KEY4 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY5[] = { + &WR_DIS_BLOCK_KEY5[0], // [WR_DIS.KEY5] wr_dis of BLOCK_KEY5 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_SYS_DATA2[] = { + &WR_DIS_BLOCK_SYS_DATA2[0], // [WR_DIS.SYS_DATA_PART2] wr_dis of BLOCK_SYS_DATA2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN0[] = { + &WR_DIS_ADC2_HI_DOUT_ATTEN0[0], // [] wr_dis of ADC2_HI_DOUT_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN1[] = { + &WR_DIS_ADC2_HI_DOUT_ATTEN1[0], // [] wr_dis of ADC2_HI_DOUT_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN2[] = { + &WR_DIS_ADC2_HI_DOUT_ATTEN2[0], // [] wr_dis of ADC2_HI_DOUT_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN3[] = { + &WR_DIS_ADC2_HI_DOUT_ATTEN3[0], // [] wr_dis of ADC2_HI_DOUT_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[] = { + &WR_DIS_TEMPERATURE_SENSOR[0], // [] wr_dis of TEMPERATURE_SENSOR + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_DEVICE_EXCHG_PINS[] = { + &WR_DIS_USB_DEVICE_EXCHG_PINS[0], // [] wr_dis of USB_DEVICE_EXCHG_PINS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_OTG11_EXCHG_PINS[] = { + &WR_DIS_USB_OTG11_EXCHG_PINS[0], // [] wr_dis of USB_OTG11_EXCHG_PINS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_PHY_SEL[] = { + &WR_DIS_USB_PHY_SEL[0], // [] wr_dis of USB_PHY_SEL + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SOFT_DIS_JTAG[] = { + &WR_DIS_SOFT_DIS_JTAG[0], // [] wr_dis of SOFT_DIS_JTAG + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS[] = { + &RD_DIS[0], // [] Disable reading from BlOCK4-10 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLOCK_KEY0[] = { + &RD_DIS_BLOCK_KEY0[0], // [RD_DIS.KEY0] rd_dis of BLOCK_KEY0 NULL }; @@ -1158,6 +1841,101 @@ const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLOCK_SYS_DATA2[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN0[] = { + &RD_DIS_ADC2_HI_DOUT_ATTEN0[0], // [] rd_dis of ADC2_HI_DOUT_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN1[] = { + &RD_DIS_ADC2_HI_DOUT_ATTEN1[0], // [] rd_dis of ADC2_HI_DOUT_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN2[] = { + &RD_DIS_ADC2_HI_DOUT_ATTEN2[0], // [] rd_dis of ADC2_HI_DOUT_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN3[] = { + &RD_DIS_ADC2_HI_DOUT_ATTEN3[0], // [] rd_dis of ADC2_HI_DOUT_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + &RD_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[0], // [] rd_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_TEMPERATURE_SENSOR[] = { + &RD_DIS_TEMPERATURE_SENSOR[0], // [] rd_dis of TEMPERATURE_SENSOR + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_USB_DEVICE_EXCHG_PINS[] = { &USB_DEVICE_EXCHG_PINS[0], // [] Enable usb device exchange pins of D+ and D- NULL @@ -1518,11 +2296,151 @@ const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO1_DREF[] = { + &LDO_VO1_DREF[0], // [] Output VO1 parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO2_DREF[] = { + &LDO_VO2_DREF[0], // [] Output VO2 parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO1_MUL[] = { + &LDO_VO1_MUL[0], // [] Output VO1 parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO2_MUL[] = { + &LDO_VO2_MUL[0], // [] Output VO2 parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_K[] = { + &LDO_VO3_K[0], // [] Output VO3 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_VOS[] = { + &LDO_VO3_VOS[0], // [] Output VO3 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_C[] = { + &LDO_VO3_C[0], // [] Output VO3 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_K[] = { + &LDO_VO4_K[0], // [] Output VO4 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_VOS[] = { + &LDO_VO4_VOS[0], // [] Output VO4 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_C[] = { + &LDO_VO4_C[0], // [] Output VO4 calibration parameter + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_HP_DBIAS[] = { + &ACTIVE_HP_DBIAS[0], // [] Active HP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_LP_DBIAS[] = { + &ACTIVE_LP_DBIAS[0], // [] Active LP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBIAS[] = { + &LSLP_HP_DBIAS[0], // [] LSLP HP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_DSLP_DBG[] = { + &DSLP_DBG[0], // [] DSLP BDG of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBIAS[] = { + &DSLP_LP_DBIAS[0], // [] DSLP LP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LP_DCDC_DBIAS_VOL_GAP[] = { + &LP_DCDC_DBIAS_VOL_GAP[0], // [] DBIAS gap between LP and DCDC + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[] = { &OPTIONAL_UNIQUE_ID[0], // [] Optional unique 128-bit ID NULL }; +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN0[] = { + &ADC1_AVE_INITCODE_ATTEN0[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN1[] = { + &ADC1_AVE_INITCODE_ATTEN1[0], // [] Average initcode of ADC1 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN2[] = { + &ADC1_AVE_INITCODE_ATTEN2[0], // [] Average initcode of ADC1 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN3[] = { + &ADC1_AVE_INITCODE_ATTEN3[0], // [] Average initcode of ADC1 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN0[] = { + &ADC2_AVE_INITCODE_ATTEN0[0], // [] Average initcode of ADC2 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN1[] = { + &ADC2_AVE_INITCODE_ATTEN1[0], // [] Average initcode of ADC2 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN2[] = { + &ADC2_AVE_INITCODE_ATTEN2[0], // [] Average initcode of ADC2 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN3[] = { + &ADC2_AVE_INITCODE_ATTEN3[0], // [] Average initcode of ADC2 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[] = { + &ADC1_HI_DOUT_ATTEN0[0], // [] HI_DOUT of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[] = { + &ADC1_HI_DOUT_ATTEN1[0], // [] HI_DOUT of ADC1 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[] = { + &ADC1_HI_DOUT_ATTEN2[0], // [] HI_DOUT of ADC1 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[] = { + &ADC1_HI_DOUT_ATTEN3[0], // [] HI_DOUT of ADC1 atten3 + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[] = { &USER_DATA[0], // [BLOCK_USR_DATA] User data NULL @@ -1563,7 +2481,97 @@ const esp_efuse_desc_t* ESP_EFUSE_KEY5[] = { NULL }; -const esp_efuse_desc_t* ESP_EFUSE_SYS_DATA_PART2[] = { - &SYS_DATA_PART2[0], // [BLOCK_SYS_DATA2] System data part 2 (reserved) +const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN0[] = { + &ADC2_HI_DOUT_ATTEN0[0], // [] HI_DOUT of ADC2 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN1[] = { + &ADC2_HI_DOUT_ATTEN1[0], // [] HI_DOUT of ADC2 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN2[] = { + &ADC2_HI_DOUT_ATTEN2[0], // [] HI_DOUT of ADC2 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN3[] = { + &ADC2_HI_DOUT_ATTEN3[0], // [] HI_DOUT of ADC2 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch0 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch1 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch2 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch3 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH4_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch4 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH5_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch5 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH6_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch6 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH7_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1_ch7 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH0_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch0 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH1_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch1 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH2_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch2 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH3_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch3 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH4_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch4 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF[] = { + &ADC2_CH5_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC2_ch5 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[] = { + &TEMPERATURE_SENSOR[0], // [] Temperature calibration data NULL }; diff --git a/components/efuse/esp32p4/esp_efuse_table.csv b/components/efuse/esp32p4/esp_efuse_table.csv index 7cd373599cb..e07ef0bd628 100644 --- a/components/efuse/esp32p4/esp_efuse_table.csv +++ b/components/efuse/esp32p4/esp_efuse_table.csv @@ -9,7 +9,7 @@ # this will generate new source files, next rebuild all the sources. # !!!!!!!!!!! # -# This file was generated by regtools.py based on the efuses.yaml file with the version: d4a48929387e281bd05db8cfb3a85f60 +# This file was generated by regtools.py based on the efuses.yaml file with the version: 73787d3f5ae45b80abca925a7562120b WR_DIS, EFUSE_BLK0, 0, 32, [] Disable programming of individual eFuses WR_DIS.RD_DIS, EFUSE_BLK0, 0, 1, [] wr_dis of RD_DIS @@ -79,7 +79,35 @@ WR_DIS.TEMP, EFUSE_BLK0, 20, 1, [] wr_dis WR_DIS.PSRAM_VENDOR, EFUSE_BLK0, 20, 1, [] wr_dis of PSRAM_VENDOR WR_DIS.PKG_VERSION, EFUSE_BLK0, 20, 1, [] wr_dis of PKG_VERSION WR_DIS.SYS_DATA_PART1, EFUSE_BLK0, 21, 1, [] wr_dis of BLOCK2 +WR_DIS.LDO_VO1_DREF, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO1_DREF +WR_DIS.LDO_VO2_DREF, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO2_DREF +WR_DIS.LDO_VO1_MUL, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO1_MUL +WR_DIS.LDO_VO2_MUL, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO2_MUL +WR_DIS.LDO_VO3_K, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO3_K +WR_DIS.LDO_VO3_VOS, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO3_VOS +WR_DIS.LDO_VO3_C, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO3_C +WR_DIS.LDO_VO4_K, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO4_K +WR_DIS.LDO_VO4_VOS, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO4_VOS +WR_DIS.LDO_VO4_C, EFUSE_BLK0, 20, 1, [] wr_dis of LDO_VO4_C +WR_DIS.ACTIVE_HP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of ACTIVE_HP_DBIAS +WR_DIS.ACTIVE_LP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of ACTIVE_LP_DBIAS +WR_DIS.LSLP_HP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of LSLP_HP_DBIAS +WR_DIS.DSLP_DBG, EFUSE_BLK0, 20, 1, [] wr_dis of DSLP_DBG +WR_DIS.DSLP_LP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of DSLP_LP_DBIAS +WR_DIS.LP_DCDC_DBIAS_VOL_GAP, EFUSE_BLK0, 20, 1, [] wr_dis of LP_DCDC_DBIAS_VOL_GAP WR_DIS.OPTIONAL_UNIQUE_ID, EFUSE_BLK0, 21, 1, [] wr_dis of OPTIONAL_UNIQUE_ID +WR_DIS.ADC1_AVE_INITCODE_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN0 +WR_DIS.ADC1_AVE_INITCODE_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN1 +WR_DIS.ADC1_AVE_INITCODE_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN2 +WR_DIS.ADC1_AVE_INITCODE_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN3 +WR_DIS.ADC2_AVE_INITCODE_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC2_AVE_INITCODE_ATTEN0 +WR_DIS.ADC2_AVE_INITCODE_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC2_AVE_INITCODE_ATTEN1 +WR_DIS.ADC2_AVE_INITCODE_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC2_AVE_INITCODE_ATTEN2 +WR_DIS.ADC2_AVE_INITCODE_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC2_AVE_INITCODE_ATTEN3 +WR_DIS.ADC1_HI_DOUT_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN0 +WR_DIS.ADC1_HI_DOUT_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN1 +WR_DIS.ADC1_HI_DOUT_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN2 +WR_DIS.ADC1_HI_DOUT_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN3 WR_DIS.BLOCK_USR_DATA, EFUSE_BLK0, 22, 1, [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA WR_DIS.CUSTOM_MAC, EFUSE_BLK0, 22, 1, [WR_DIS.MAC_CUSTOM WR_DIS.USER_DATA_MAC_CUSTOM] wr_dis of CUSTOM_MAC WR_DIS.BLOCK_KEY0, EFUSE_BLK0, 23, 1, [WR_DIS.KEY0] wr_dis of BLOCK_KEY0 @@ -89,6 +117,25 @@ WR_DIS.BLOCK_KEY3, EFUSE_BLK0, 26, 1, [WR_DIS.K WR_DIS.BLOCK_KEY4, EFUSE_BLK0, 27, 1, [WR_DIS.KEY4] wr_dis of BLOCK_KEY4 WR_DIS.BLOCK_KEY5, EFUSE_BLK0, 28, 1, [WR_DIS.KEY5] wr_dis of BLOCK_KEY5 WR_DIS.BLOCK_SYS_DATA2, EFUSE_BLK0, 29, 1, [WR_DIS.SYS_DATA_PART2] wr_dis of BLOCK_SYS_DATA2 +WR_DIS.ADC2_HI_DOUT_ATTEN0, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_HI_DOUT_ATTEN0 +WR_DIS.ADC2_HI_DOUT_ATTEN1, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_HI_DOUT_ATTEN1 +WR_DIS.ADC2_HI_DOUT_ATTEN2, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_HI_DOUT_ATTEN2 +WR_DIS.ADC2_HI_DOUT_ATTEN3, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_HI_DOUT_ATTEN3 +WR_DIS.ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH6_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH7_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF +WR_DIS.ADC2_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 29, 1, [] wr_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF +WR_DIS.TEMPERATURE_SENSOR, EFUSE_BLK0, 29, 1, [] wr_dis of TEMPERATURE_SENSOR WR_DIS.USB_DEVICE_EXCHG_PINS, EFUSE_BLK0, 30, 1, [] wr_dis of USB_DEVICE_EXCHG_PINS WR_DIS.USB_OTG11_EXCHG_PINS, EFUSE_BLK0, 30, 1, [] wr_dis of USB_OTG11_EXCHG_PINS WR_DIS.USB_PHY_SEL, EFUSE_BLK0, 30, 1, [] wr_dis of USB_PHY_SEL @@ -101,6 +148,25 @@ RD_DIS.BLOCK_KEY3, EFUSE_BLK0, 35, 1, [RD_DIS.K RD_DIS.BLOCK_KEY4, EFUSE_BLK0, 36, 1, [RD_DIS.KEY4] rd_dis of BLOCK_KEY4 RD_DIS.BLOCK_KEY5, EFUSE_BLK0, 37, 1, [RD_DIS.KEY5] rd_dis of BLOCK_KEY5 RD_DIS.BLOCK_SYS_DATA2, EFUSE_BLK0, 38, 1, [RD_DIS.SYS_DATA_PART2] rd_dis of BLOCK_SYS_DATA2 +RD_DIS.ADC2_HI_DOUT_ATTEN0, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_HI_DOUT_ATTEN0 +RD_DIS.ADC2_HI_DOUT_ATTEN1, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_HI_DOUT_ATTEN1 +RD_DIS.ADC2_HI_DOUT_ATTEN2, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_HI_DOUT_ATTEN2 +RD_DIS.ADC2_HI_DOUT_ATTEN3, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_HI_DOUT_ATTEN3 +RD_DIS.ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH6_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH6_ATTEN0_INITCODE_DIFF +RD_DIS.ADC1_CH7_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC1_CH7_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH0_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH1_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH2_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH3_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH4_ATTEN0_INITCODE_DIFF +RD_DIS.ADC2_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 38, 1, [] rd_dis of ADC2_CH5_ATTEN0_INITCODE_DIFF +RD_DIS.TEMPERATURE_SENSOR, EFUSE_BLK0, 38, 1, [] rd_dis of TEMPERATURE_SENSOR USB_DEVICE_EXCHG_PINS, EFUSE_BLK0, 39, 1, [] Enable usb device exchange pins of D+ and D- USB_OTG11_EXCHG_PINS, EFUSE_BLK0, 40, 1, [] Enable usb otg11 exchange pins of D+ and D- DIS_USB_JTAG, EFUSE_BLK0, 41, 1, [] Represents whether the function of usb switch to jtag is disabled or enabled. 1: disabled. 0: enabled @@ -177,7 +243,35 @@ PSRAM_CAP, EFUSE_BLK1, 77, 3, [] PSRAM TEMP, EFUSE_BLK1, 80, 2, [] Operating temperature of the ESP chip PSRAM_VENDOR, EFUSE_BLK1, 82, 2, [] PSRAM vendor PKG_VERSION, EFUSE_BLK1, 84, 3, [] Package version +LDO_VO1_DREF, EFUSE_BLK1, 88, 4, [] Output VO1 parameter +LDO_VO2_DREF, EFUSE_BLK1, 92, 4, [] Output VO2 parameter +LDO_VO1_MUL, EFUSE_BLK1, 96, 3, [] Output VO1 parameter +LDO_VO2_MUL, EFUSE_BLK1, 99, 3, [] Output VO2 parameter +LDO_VO3_K, EFUSE_BLK1, 102, 8, [] Output VO3 calibration parameter +LDO_VO3_VOS, EFUSE_BLK1, 110, 6, [] Output VO3 calibration parameter +LDO_VO3_C, EFUSE_BLK1, 116, 6, [] Output VO3 calibration parameter +LDO_VO4_K, EFUSE_BLK1, 122, 8, [] Output VO4 calibration parameter +LDO_VO4_VOS, EFUSE_BLK1, 130, 6, [] Output VO4 calibration parameter +LDO_VO4_C, EFUSE_BLK1, 136, 6, [] Output VO4 calibration parameter +ACTIVE_HP_DBIAS, EFUSE_BLK1, 144, 4, [] Active HP DBIAS of fixed voltage +ACTIVE_LP_DBIAS, EFUSE_BLK1, 148, 4, [] Active LP DBIAS of fixed voltage +LSLP_HP_DBIAS, EFUSE_BLK1, 152, 4, [] LSLP HP DBIAS of fixed voltage +DSLP_DBG, EFUSE_BLK1, 156, 4, [] DSLP BDG of fixed voltage +DSLP_LP_DBIAS, EFUSE_BLK1, 160, 5, [] DSLP LP DBIAS of fixed voltage +LP_DCDC_DBIAS_VOL_GAP, EFUSE_BLK1, 165, 5, [] DBIAS gap between LP and DCDC OPTIONAL_UNIQUE_ID, EFUSE_BLK2, 0, 128, [] Optional unique 128-bit ID +ADC1_AVE_INITCODE_ATTEN0, EFUSE_BLK2, 128, 10, [] Average initcode of ADC1 atten0 +ADC1_AVE_INITCODE_ATTEN1, EFUSE_BLK2, 138, 10, [] Average initcode of ADC1 atten1 +ADC1_AVE_INITCODE_ATTEN2, EFUSE_BLK2, 148, 10, [] Average initcode of ADC1 atten2 +ADC1_AVE_INITCODE_ATTEN3, EFUSE_BLK2, 158, 10, [] Average initcode of ADC1 atten3 +ADC2_AVE_INITCODE_ATTEN0, EFUSE_BLK2, 168, 10, [] Average initcode of ADC2 atten0 +ADC2_AVE_INITCODE_ATTEN1, EFUSE_BLK2, 178, 10, [] Average initcode of ADC2 atten1 +ADC2_AVE_INITCODE_ATTEN2, EFUSE_BLK2, 188, 10, [] Average initcode of ADC2 atten2 +ADC2_AVE_INITCODE_ATTEN3, EFUSE_BLK2, 198, 10, [] Average initcode of ADC2 atten3 +ADC1_HI_DOUT_ATTEN0, EFUSE_BLK2, 208, 10, [] HI_DOUT of ADC1 atten0 +ADC1_HI_DOUT_ATTEN1, EFUSE_BLK2, 218, 10, [] HI_DOUT of ADC1 atten1 +ADC1_HI_DOUT_ATTEN2, EFUSE_BLK2, 228, 10, [] HI_DOUT of ADC1 atten2 +ADC1_HI_DOUT_ATTEN3, EFUSE_BLK2, 238, 10, [] HI_DOUT of ADC1 atten3 USER_DATA, EFUSE_BLK3, 0, 256, [BLOCK_USR_DATA] User data USER_DATA.MAC_CUSTOM, EFUSE_BLK3, 200, 48, [MAC_CUSTOM CUSTOM_MAC] Custom MAC KEY0, EFUSE_BLK4, 0, 256, [BLOCK_KEY0] Key0 or user data @@ -186,4 +280,22 @@ KEY2, EFUSE_BLK6, 0, 256, [BLOCK_KE KEY3, EFUSE_BLK7, 0, 256, [BLOCK_KEY3] Key3 or user data KEY4, EFUSE_BLK8, 0, 256, [BLOCK_KEY4] Key4 or user data KEY5, EFUSE_BLK9, 0, 256, [BLOCK_KEY5] Key5 or user data -SYS_DATA_PART2, EFUSE_BLK10, 0, 256, [BLOCK_SYS_DATA2] System data part 2 (reserved) +ADC2_HI_DOUT_ATTEN0, EFUSE_BLK10, 0, 10, [] HI_DOUT of ADC2 atten0 +ADC2_HI_DOUT_ATTEN1, EFUSE_BLK10, 10, 10, [] HI_DOUT of ADC2 atten1 +ADC2_HI_DOUT_ATTEN2, EFUSE_BLK10, 20, 10, [] HI_DOUT of ADC2 atten2 +ADC2_HI_DOUT_ATTEN3, EFUSE_BLK10, 30, 10, [] HI_DOUT of ADC2 atten3 +ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 40, 4, [] Gap between ADC1_ch0 and average initcode +ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 44, 4, [] Gap between ADC1_ch1 and average initcode +ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 48, 4, [] Gap between ADC1_ch2 and average initcode +ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 52, 4, [] Gap between ADC1_ch3 and average initcode +ADC1_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 56, 4, [] Gap between ADC1_ch4 and average initcode +ADC1_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 60, 4, [] Gap between ADC1_ch5 and average initcode +ADC1_CH6_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 64, 4, [] Gap between ADC1_ch6 and average initcode +ADC1_CH7_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 68, 4, [] Gap between ADC1_ch7 and average initcode +ADC2_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 72, 4, [] Gap between ADC2_ch0 and average initcode +ADC2_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 76, 4, [] Gap between ADC2_ch1 and average initcode +ADC2_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 80, 4, [] Gap between ADC2_ch2 and average initcode +ADC2_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 84, 4, [] Gap between ADC2_ch3 and average initcode +ADC2_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 88, 4, [] Gap between ADC2_ch4 and average initcode +ADC2_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK10, 92, 4, [] Gap between ADC2_ch5 and average initcode +TEMPERATURE_SENSOR, EFUSE_BLK10, 96, 9, [] Temperature calibration data diff --git a/components/efuse/esp32p4/include/esp_efuse_table.h b/components/efuse/esp32p4/include/esp_efuse_table.h index 9e82ad86301..8ccdd797109 100644 --- a/components/efuse/esp32p4/include/esp_efuse_table.h +++ b/components/efuse/esp32p4/include/esp_efuse_table.h @@ -10,7 +10,7 @@ extern "C" { #include "esp_efuse.h" -// md5_digest_table 0d4e1f49db99de4dd9d3eac8d8e6078b +// md5_digest_table c56ed98dde7a08c8f70d57a01faba96a // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -92,7 +92,35 @@ extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMP[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_PSRAM_VENDOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_PKG_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO1_DREF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO2_DREF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO1_MUL[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO2_MUL[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_K[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_VOS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO3_C[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_K[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_VOS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LDO_VO4_C[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LP_DCDC_DBIAS_VOL_GAP[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[]; #define ESP_EFUSE_WR_DIS_USER_DATA ESP_EFUSE_WR_DIS_BLOCK_USR_DATA extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_CUSTOM_MAC[]; @@ -112,6 +140,25 @@ extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_KEY5[]; #define ESP_EFUSE_WR_DIS_KEY5 ESP_EFUSE_WR_DIS_BLOCK_KEY5 extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_SYS_DATA2[]; #define ESP_EFUSE_WR_DIS_SYS_DATA_PART2 ESP_EFUSE_WR_DIS_BLOCK_SYS_DATA2 +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_DEVICE_EXCHG_PINS[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_OTG11_EXCHG_PINS[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_USB_PHY_SEL[]; @@ -131,6 +178,25 @@ extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLOCK_KEY5[]; #define ESP_EFUSE_RD_DIS_KEY5 ESP_EFUSE_RD_DIS_BLOCK_KEY5 extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_BLOCK_SYS_DATA2[]; #define ESP_EFUSE_RD_DIS_SYS_DATA_PART2 ESP_EFUSE_RD_DIS_BLOCK_SYS_DATA2 +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH6_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC1_CH7_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_ADC2_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_RD_DIS_TEMPERATURE_SENSOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_USB_DEVICE_EXCHG_PINS[]; extern const esp_efuse_desc_t* ESP_EFUSE_USB_OTG11_EXCHG_PINS[]; extern const esp_efuse_desc_t* ESP_EFUSE_DIS_USB_JTAG[]; @@ -209,7 +275,35 @@ extern const esp_efuse_desc_t* ESP_EFUSE_PSRAM_CAP[]; extern const esp_efuse_desc_t* ESP_EFUSE_TEMP[]; extern const esp_efuse_desc_t* ESP_EFUSE_PSRAM_VENDOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO1_DREF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO2_DREF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO1_MUL[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO2_MUL[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_K[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_VOS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO3_C[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_K[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_VOS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LDO_VO4_C[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DSLP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LP_DCDC_DBIAS_VOL_GAP[]; extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[]; extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[]; #define ESP_EFUSE_BLOCK_USR_DATA ESP_EFUSE_USER_DATA extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[]; @@ -227,8 +321,25 @@ extern const esp_efuse_desc_t* ESP_EFUSE_KEY4[]; #define ESP_EFUSE_BLOCK_KEY4 ESP_EFUSE_KEY4 extern const esp_efuse_desc_t* ESP_EFUSE_KEY5[]; #define ESP_EFUSE_BLOCK_KEY5 ESP_EFUSE_KEY5 -extern const esp_efuse_desc_t* ESP_EFUSE_SYS_DATA_PART2[]; -#define ESP_EFUSE_BLOCK_SYS_DATA2 ESP_EFUSE_SYS_DATA_PART2 +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[]; #ifdef __cplusplus } diff --git a/components/soc/esp32p4/register/soc/efuse_reg.h b/components/soc/esp32p4/register/soc/efuse_reg.h index f26a3c342e8..37d92689c6a 100644 --- a/components/soc/esp32p4/register/soc/efuse_reg.h +++ b/components/soc/esp32p4/register/soc/efuse_reg.h @@ -654,16 +654,16 @@ extern "C" { #define EFUSE_KM_DISABLE_DEPLOY_MODE_V 0x0000000FU #define EFUSE_KM_DISABLE_DEPLOY_MODE_S 8 /** EFUSE_USB_DEVICE_DREFL : RO; bitpos: [13:12]; default: 0; - * Represents the usb device single-end input low threshold, 0.8 V to 1.04 V with step - * of 80 mV. + * Represents the usb device single-end input low threshold; 0.8 V to 1.04 V with step + * of 80 mV */ #define EFUSE_USB_DEVICE_DREFL 0x00000003U #define EFUSE_USB_DEVICE_DREFL_M (EFUSE_USB_DEVICE_DREFL_V << EFUSE_USB_DEVICE_DREFL_S) #define EFUSE_USB_DEVICE_DREFL_V 0x00000003U #define EFUSE_USB_DEVICE_DREFL_S 12 /** EFUSE_USB_OTG11_DREFL : RO; bitpos: [15:14]; default: 0; - * Represents the usb otg11 single-end input low threshold, 0.8 V to 1.04 V with step - * of 80 mV. + * Represents the usb otg11 single-end input low threshold; 0.8 V to 1.04 V with step + * of 80 mV */ #define EFUSE_USB_OTG11_DREFL 0x00000003U #define EFUSE_USB_OTG11_DREFL_M (EFUSE_USB_OTG11_DREFL_V << EFUSE_USB_OTG11_DREFL_S) @@ -817,56 +817,161 @@ extern "C" { #define EFUSE_PKG_VERSION_M (EFUSE_PKG_VERSION_V << EFUSE_PKG_VERSION_S) #define EFUSE_PKG_VERSION_V 0x00000007U #define EFUSE_PKG_VERSION_S 20 -/** EFUSE_RESERVED_1_87 : R; bitpos: [31:23]; default: 0; +/** EFUSE_RESERVED_1_87 : R; bitpos: [23]; default: 0; * reserved */ -#define EFUSE_RESERVED_1_87 0x000001FFU +#define EFUSE_RESERVED_1_87 (BIT(23)) #define EFUSE_RESERVED_1_87_M (EFUSE_RESERVED_1_87_V << EFUSE_RESERVED_1_87_S) -#define EFUSE_RESERVED_1_87_V 0x000001FFU +#define EFUSE_RESERVED_1_87_V 0x00000001U #define EFUSE_RESERVED_1_87_S 23 +/** EFUSE_LDO_VO1_DREF : R; bitpos: [27:24]; default: 0; + * Output VO1 parameter + */ +#define EFUSE_LDO_VO1_DREF 0x0000000FU +#define EFUSE_LDO_VO1_DREF_M (EFUSE_LDO_VO1_DREF_V << EFUSE_LDO_VO1_DREF_S) +#define EFUSE_LDO_VO1_DREF_V 0x0000000FU +#define EFUSE_LDO_VO1_DREF_S 24 +/** EFUSE_LDO_VO2_DREF : R; bitpos: [31:28]; default: 0; + * Output VO2 parameter + */ +#define EFUSE_LDO_VO2_DREF 0x0000000FU +#define EFUSE_LDO_VO2_DREF_M (EFUSE_LDO_VO2_DREF_V << EFUSE_LDO_VO2_DREF_S) +#define EFUSE_LDO_VO2_DREF_V 0x0000000FU +#define EFUSE_LDO_VO2_DREF_S 28 /** EFUSE_RD_MAC_SYS_3_REG register * BLOCK1 data register $n. */ #define EFUSE_RD_MAC_SYS_3_REG (DR_REG_EFUSE_BASE + 0x50) -/** EFUSE_MAC_RESERVED_2 : RO; bitpos: [17:0]; default: 0; - * Reserved. - */ -#define EFUSE_MAC_RESERVED_2 0x0003FFFFU -#define EFUSE_MAC_RESERVED_2_M (EFUSE_MAC_RESERVED_2_V << EFUSE_MAC_RESERVED_2_S) -#define EFUSE_MAC_RESERVED_2_V 0x0003FFFFU -#define EFUSE_MAC_RESERVED_2_S 0 -/** EFUSE_SYS_DATA_PART0_0 : RO; bitpos: [31:18]; default: 0; - * Stores the first 14 bits of the zeroth part of system data. - */ -#define EFUSE_SYS_DATA_PART0_0 0x00003FFFU -#define EFUSE_SYS_DATA_PART0_0_M (EFUSE_SYS_DATA_PART0_0_V << EFUSE_SYS_DATA_PART0_0_S) -#define EFUSE_SYS_DATA_PART0_0_V 0x00003FFFU -#define EFUSE_SYS_DATA_PART0_0_S 18 +/** EFUSE_LDO_VO1_MUL : R; bitpos: [2:0]; default: 0; + * Output VO1 parameter + */ +#define EFUSE_LDO_VO1_MUL 0x00000007U +#define EFUSE_LDO_VO1_MUL_M (EFUSE_LDO_VO1_MUL_V << EFUSE_LDO_VO1_MUL_S) +#define EFUSE_LDO_VO1_MUL_V 0x00000007U +#define EFUSE_LDO_VO1_MUL_S 0 +/** EFUSE_LDO_VO2_MUL : R; bitpos: [5:3]; default: 0; + * Output VO2 parameter + */ +#define EFUSE_LDO_VO2_MUL 0x00000007U +#define EFUSE_LDO_VO2_MUL_M (EFUSE_LDO_VO2_MUL_V << EFUSE_LDO_VO2_MUL_S) +#define EFUSE_LDO_VO2_MUL_V 0x00000007U +#define EFUSE_LDO_VO2_MUL_S 3 +/** EFUSE_LDO_VO3_K : R; bitpos: [13:6]; default: 0; + * Output VO3 calibration parameter + */ +#define EFUSE_LDO_VO3_K 0x000000FFU +#define EFUSE_LDO_VO3_K_M (EFUSE_LDO_VO3_K_V << EFUSE_LDO_VO3_K_S) +#define EFUSE_LDO_VO3_K_V 0x000000FFU +#define EFUSE_LDO_VO3_K_S 6 +/** EFUSE_LDO_VO3_VOS : R; bitpos: [19:14]; default: 0; + * Output VO3 calibration parameter + */ +#define EFUSE_LDO_VO3_VOS 0x0000003FU +#define EFUSE_LDO_VO3_VOS_M (EFUSE_LDO_VO3_VOS_V << EFUSE_LDO_VO3_VOS_S) +#define EFUSE_LDO_VO3_VOS_V 0x0000003FU +#define EFUSE_LDO_VO3_VOS_S 14 +/** EFUSE_LDO_VO3_C : R; bitpos: [25:20]; default: 0; + * Output VO3 calibration parameter + */ +#define EFUSE_LDO_VO3_C 0x0000003FU +#define EFUSE_LDO_VO3_C_M (EFUSE_LDO_VO3_C_V << EFUSE_LDO_VO3_C_S) +#define EFUSE_LDO_VO3_C_V 0x0000003FU +#define EFUSE_LDO_VO3_C_S 20 +/** EFUSE_LDO_VO4_K : R; bitpos: [31:26]; default: 0; + * Output VO4 calibration parameter + */ +#define EFUSE_LDO_VO4_K 0x0000003FU +#define EFUSE_LDO_VO4_K_M (EFUSE_LDO_VO4_K_V << EFUSE_LDO_VO4_K_S) +#define EFUSE_LDO_VO4_K_V 0x0000003FU +#define EFUSE_LDO_VO4_K_S 26 /** EFUSE_RD_MAC_SYS_4_REG register * BLOCK1 data register $n. */ #define EFUSE_RD_MAC_SYS_4_REG (DR_REG_EFUSE_BASE + 0x54) -/** EFUSE_SYS_DATA_PART0_1 : RO; bitpos: [31:0]; default: 0; - * Stores the first 32 bits of the zeroth part of system data. +/** EFUSE_LDO_VO4_K_1 : R; bitpos: [1:0]; default: 0; + * Output VO4 calibration parameter + */ +#define EFUSE_LDO_VO4_K_1 0x00000003U +#define EFUSE_LDO_VO4_K_1_M (EFUSE_LDO_VO4_K_1_V << EFUSE_LDO_VO4_K_1_S) +#define EFUSE_LDO_VO4_K_1_V 0x00000003U +#define EFUSE_LDO_VO4_K_1_S 0 +/** EFUSE_LDO_VO4_VOS : R; bitpos: [7:2]; default: 0; + * Output VO4 calibration parameter + */ +#define EFUSE_LDO_VO4_VOS 0x0000003FU +#define EFUSE_LDO_VO4_VOS_M (EFUSE_LDO_VO4_VOS_V << EFUSE_LDO_VO4_VOS_S) +#define EFUSE_LDO_VO4_VOS_V 0x0000003FU +#define EFUSE_LDO_VO4_VOS_S 2 +/** EFUSE_LDO_VO4_C : R; bitpos: [13:8]; default: 0; + * Output VO4 calibration parameter + */ +#define EFUSE_LDO_VO4_C 0x0000003FU +#define EFUSE_LDO_VO4_C_M (EFUSE_LDO_VO4_C_V << EFUSE_LDO_VO4_C_S) +#define EFUSE_LDO_VO4_C_V 0x0000003FU +#define EFUSE_LDO_VO4_C_S 8 +/** EFUSE_RESERVED_1_142 : R; bitpos: [15:14]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART0_1 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_1_M (EFUSE_SYS_DATA_PART0_1_V << EFUSE_SYS_DATA_PART0_1_S) -#define EFUSE_SYS_DATA_PART0_1_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_1_S 0 +#define EFUSE_RESERVED_1_142 0x00000003U +#define EFUSE_RESERVED_1_142_M (EFUSE_RESERVED_1_142_V << EFUSE_RESERVED_1_142_S) +#define EFUSE_RESERVED_1_142_V 0x00000003U +#define EFUSE_RESERVED_1_142_S 14 +/** EFUSE_ACTIVE_HP_DBIAS : R; bitpos: [19:16]; default: 0; + * Active HP DBIAS of fixed voltage + */ +#define EFUSE_ACTIVE_HP_DBIAS 0x0000000FU +#define EFUSE_ACTIVE_HP_DBIAS_M (EFUSE_ACTIVE_HP_DBIAS_V << EFUSE_ACTIVE_HP_DBIAS_S) +#define EFUSE_ACTIVE_HP_DBIAS_V 0x0000000FU +#define EFUSE_ACTIVE_HP_DBIAS_S 16 +/** EFUSE_ACTIVE_LP_DBIAS : R; bitpos: [23:20]; default: 0; + * Active LP DBIAS of fixed voltage + */ +#define EFUSE_ACTIVE_LP_DBIAS 0x0000000FU +#define EFUSE_ACTIVE_LP_DBIAS_M (EFUSE_ACTIVE_LP_DBIAS_V << EFUSE_ACTIVE_LP_DBIAS_S) +#define EFUSE_ACTIVE_LP_DBIAS_V 0x0000000FU +#define EFUSE_ACTIVE_LP_DBIAS_S 20 +/** EFUSE_LSLP_HP_DBIAS : R; bitpos: [27:24]; default: 0; + * LSLP HP DBIAS of fixed voltage + */ +#define EFUSE_LSLP_HP_DBIAS 0x0000000FU +#define EFUSE_LSLP_HP_DBIAS_M (EFUSE_LSLP_HP_DBIAS_V << EFUSE_LSLP_HP_DBIAS_S) +#define EFUSE_LSLP_HP_DBIAS_V 0x0000000FU +#define EFUSE_LSLP_HP_DBIAS_S 24 +/** EFUSE_DSLP_DBG : R; bitpos: [31:28]; default: 0; + * DSLP BDG of fixed voltage + */ +#define EFUSE_DSLP_DBG 0x0000000FU +#define EFUSE_DSLP_DBG_M (EFUSE_DSLP_DBG_V << EFUSE_DSLP_DBG_S) +#define EFUSE_DSLP_DBG_V 0x0000000FU +#define EFUSE_DSLP_DBG_S 28 /** EFUSE_RD_MAC_SYS_5_REG register * BLOCK1 data register $n. */ #define EFUSE_RD_MAC_SYS_5_REG (DR_REG_EFUSE_BASE + 0x58) -/** EFUSE_SYS_DATA_PART0_2 : RO; bitpos: [31:0]; default: 0; - * Stores the second 32 bits of the zeroth part of system data. +/** EFUSE_DSLP_LP_DBIAS : R; bitpos: [4:0]; default: 0; + * DSLP LP DBIAS of fixed voltage + */ +#define EFUSE_DSLP_LP_DBIAS 0x0000001FU +#define EFUSE_DSLP_LP_DBIAS_M (EFUSE_DSLP_LP_DBIAS_V << EFUSE_DSLP_LP_DBIAS_S) +#define EFUSE_DSLP_LP_DBIAS_V 0x0000001FU +#define EFUSE_DSLP_LP_DBIAS_S 0 +/** EFUSE_LP_DCDC_DBIAS_VOL_GAP : R; bitpos: [9:5]; default: 0; + * DBIAS gap between LP and DCDC + */ +#define EFUSE_LP_DCDC_DBIAS_VOL_GAP 0x0000001FU +#define EFUSE_LP_DCDC_DBIAS_VOL_GAP_M (EFUSE_LP_DCDC_DBIAS_VOL_GAP_V << EFUSE_LP_DCDC_DBIAS_VOL_GAP_S) +#define EFUSE_LP_DCDC_DBIAS_VOL_GAP_V 0x0000001FU +#define EFUSE_LP_DCDC_DBIAS_VOL_GAP_S 5 +/** EFUSE_RESERVED_1_170 : R; bitpos: [31:10]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART0_2 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_2_M (EFUSE_SYS_DATA_PART0_2_V << EFUSE_SYS_DATA_PART0_2_S) -#define EFUSE_SYS_DATA_PART0_2_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_2_S 0 +#define EFUSE_RESERVED_1_170 0x003FFFFFU +#define EFUSE_RESERVED_1_170_M (EFUSE_RESERVED_1_170_V << EFUSE_RESERVED_1_170_S) +#define EFUSE_RESERVED_1_170_V 0x003FFFFFU +#define EFUSE_RESERVED_1_170_S 10 /** EFUSE_RD_SYS_PART1_DATA0_REG register * Register $n of BLOCK2 (system). @@ -920,49 +1025,133 @@ extern "C" { * Register $n of BLOCK2 (system). */ #define EFUSE_RD_SYS_PART1_DATA4_REG (DR_REG_EFUSE_BASE + 0x6c) -/** EFUSE_SYS_DATA_PART1_4 : RO; bitpos: [31:0]; default: 0; - * Stores the fourth 32 bits of the first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_4 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_4_M (EFUSE_SYS_DATA_PART1_4_V << EFUSE_SYS_DATA_PART1_4_S) -#define EFUSE_SYS_DATA_PART1_4_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_4_S 0 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN0 : R; bitpos: [9:0]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_M (EFUSE_ADC1_AVE_INITCODE_ATTEN0_V << EFUSE_ADC1_AVE_INITCODE_ATTEN0_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_S 0 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN1 : R; bitpos: [19:10]; default: 0; + * Average initcode of ADC1 atten1 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_M (EFUSE_ADC1_AVE_INITCODE_ATTEN1_V << EFUSE_ADC1_AVE_INITCODE_ATTEN1_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_S 10 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN2 : R; bitpos: [29:20]; default: 0; + * Average initcode of ADC1 atten2 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_M (EFUSE_ADC1_AVE_INITCODE_ATTEN2_V << EFUSE_ADC1_AVE_INITCODE_ATTEN2_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_S 20 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN3 : R; bitpos: [31:30]; default: 0; + * Average initcode of ADC1 atten3 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3 0x00000003U +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_M (EFUSE_ADC1_AVE_INITCODE_ATTEN3_V << EFUSE_ADC1_AVE_INITCODE_ATTEN3_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_V 0x00000003U +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_S 30 /** EFUSE_RD_SYS_PART1_DATA5_REG register * Register $n of BLOCK2 (system). */ #define EFUSE_RD_SYS_PART1_DATA5_REG (DR_REG_EFUSE_BASE + 0x70) -/** EFUSE_SYS_DATA_PART1_5 : RO; bitpos: [31:0]; default: 0; - * Stores the fifth 32 bits of the first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_5 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_M (EFUSE_SYS_DATA_PART1_5_V << EFUSE_SYS_DATA_PART1_5_S) -#define EFUSE_SYS_DATA_PART1_5_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_S 0 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN3_1 : R; bitpos: [7:0]; default: 0; + * Average initcode of ADC1 atten3 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_1 0x000000FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_1_M (EFUSE_ADC1_AVE_INITCODE_ATTEN3_1_V << EFUSE_ADC1_AVE_INITCODE_ATTEN3_1_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_1_V 0x000000FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_1_S 0 +/** EFUSE_ADC2_AVE_INITCODE_ATTEN0 : R; bitpos: [17:8]; default: 0; + * Average initcode of ADC2 atten0 + */ +#define EFUSE_ADC2_AVE_INITCODE_ATTEN0 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN0_M (EFUSE_ADC2_AVE_INITCODE_ATTEN0_V << EFUSE_ADC2_AVE_INITCODE_ATTEN0_S) +#define EFUSE_ADC2_AVE_INITCODE_ATTEN0_V 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN0_S 8 +/** EFUSE_ADC2_AVE_INITCODE_ATTEN1 : R; bitpos: [27:18]; default: 0; + * Average initcode of ADC2 atten1 + */ +#define EFUSE_ADC2_AVE_INITCODE_ATTEN1 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN1_M (EFUSE_ADC2_AVE_INITCODE_ATTEN1_V << EFUSE_ADC2_AVE_INITCODE_ATTEN1_S) +#define EFUSE_ADC2_AVE_INITCODE_ATTEN1_V 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN1_S 18 +/** EFUSE_ADC2_AVE_INITCODE_ATTEN2 : R; bitpos: [31:28]; default: 0; + * Average initcode of ADC2 atten2 + */ +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2 0x0000000FU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_M (EFUSE_ADC2_AVE_INITCODE_ATTEN2_V << EFUSE_ADC2_AVE_INITCODE_ATTEN2_S) +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_V 0x0000000FU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_S 28 /** EFUSE_RD_SYS_PART1_DATA6_REG register * Register $n of BLOCK2 (system). */ #define EFUSE_RD_SYS_PART1_DATA6_REG (DR_REG_EFUSE_BASE + 0x74) -/** EFUSE_SYS_DATA_PART1_6 : RO; bitpos: [31:0]; default: 0; - * Stores the sixth 32 bits of the first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_6 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_M (EFUSE_SYS_DATA_PART1_6_V << EFUSE_SYS_DATA_PART1_6_S) -#define EFUSE_SYS_DATA_PART1_6_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_S 0 +/** EFUSE_ADC2_AVE_INITCODE_ATTEN2_1 : R; bitpos: [5:0]; default: 0; + * Average initcode of ADC2 atten2 + */ +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_1 0x0000003FU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_1_M (EFUSE_ADC2_AVE_INITCODE_ATTEN2_1_V << EFUSE_ADC2_AVE_INITCODE_ATTEN2_1_S) +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_1_V 0x0000003FU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN2_1_S 0 +/** EFUSE_ADC2_AVE_INITCODE_ATTEN3 : R; bitpos: [15:6]; default: 0; + * Average initcode of ADC2 atten3 + */ +#define EFUSE_ADC2_AVE_INITCODE_ATTEN3 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN3_M (EFUSE_ADC2_AVE_INITCODE_ATTEN3_V << EFUSE_ADC2_AVE_INITCODE_ATTEN3_S) +#define EFUSE_ADC2_AVE_INITCODE_ATTEN3_V 0x000003FFU +#define EFUSE_ADC2_AVE_INITCODE_ATTEN3_S 6 +/** EFUSE_ADC1_HI_DOUT_ATTEN0 : R; bitpos: [25:16]; default: 0; + * HI_DOUT of ADC1 atten0 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN0 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_M (EFUSE_ADC1_HI_DOUT_ATTEN0_V << EFUSE_ADC1_HI_DOUT_ATTEN0_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN0_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_S 16 +/** EFUSE_ADC1_HI_DOUT_ATTEN1 : R; bitpos: [31:26]; default: 0; + * HI_DOUT of ADC1 atten1 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN1 0x0000003FU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_M (EFUSE_ADC1_HI_DOUT_ATTEN1_V << EFUSE_ADC1_HI_DOUT_ATTEN1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN1_V 0x0000003FU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_S 26 /** EFUSE_RD_SYS_PART1_DATA7_REG register * Register $n of BLOCK2 (system). */ #define EFUSE_RD_SYS_PART1_DATA7_REG (DR_REG_EFUSE_BASE + 0x78) -/** EFUSE_SYS_DATA_PART1_7 : RO; bitpos: [31:0]; default: 0; - * Stores the seventh 32 bits of the first part of system data. +/** EFUSE_ADC1_HI_DOUT_ATTEN1_1 : R; bitpos: [3:0]; default: 0; + * HI_DOUT of ADC1 atten1 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN1_1 0x0000000FU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_1_M (EFUSE_ADC1_HI_DOUT_ATTEN1_1_V << EFUSE_ADC1_HI_DOUT_ATTEN1_1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN1_1_V 0x0000000FU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_1_S 0 +/** EFUSE_ADC1_HI_DOUT_ATTEN2 : R; bitpos: [13:4]; default: 0; + * HI_DOUT of ADC1 atten2 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN2 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_M (EFUSE_ADC1_HI_DOUT_ATTEN2_V << EFUSE_ADC1_HI_DOUT_ATTEN2_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_S 4 +/** EFUSE_ADC1_HI_DOUT_ATTEN3 : R; bitpos: [23:14]; default: 0; + * HI_DOUT of ADC1 atten3 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN3 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_M (EFUSE_ADC1_HI_DOUT_ATTEN3_V << EFUSE_ADC1_HI_DOUT_ATTEN3_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_S 14 +/** EFUSE_RESERVED_2_248 : R; bitpos: [31:24]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART1_7 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_M (EFUSE_SYS_DATA_PART1_7_V << EFUSE_SYS_DATA_PART1_7_S) -#define EFUSE_SYS_DATA_PART1_7_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_S 0 +#define EFUSE_RESERVED_2_248 0x000000FFU +#define EFUSE_RESERVED_2_248_M (EFUSE_RESERVED_2_248_V << EFUSE_RESERVED_2_248_S) +#define EFUSE_RESERVED_2_248_V 0x000000FFU +#define EFUSE_RESERVED_2_248_S 24 /** EFUSE_RD_USR_DATA0_REG register * Register $n of BLOCK3 (user). @@ -1654,49 +1843,168 @@ extern "C" { * Register $n of BLOCK10 (system). */ #define EFUSE_RD_SYS_PART2_DATA0_REG (DR_REG_EFUSE_BASE + 0x15c) -/** EFUSE_SYS_DATA_PART2_0 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. - */ -#define EFUSE_SYS_DATA_PART2_0 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_0_M (EFUSE_SYS_DATA_PART2_0_V << EFUSE_SYS_DATA_PART2_0_S) -#define EFUSE_SYS_DATA_PART2_0_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_0_S 0 +/** EFUSE_ADC2_HI_DOUT_ATTEN0 : R; bitpos: [9:0]; default: 0; + * HI_DOUT of ADC2 atten0 + */ +#define EFUSE_ADC2_HI_DOUT_ATTEN0 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN0_M (EFUSE_ADC2_HI_DOUT_ATTEN0_V << EFUSE_ADC2_HI_DOUT_ATTEN0_S) +#define EFUSE_ADC2_HI_DOUT_ATTEN0_V 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN0_S 0 +/** EFUSE_ADC2_HI_DOUT_ATTEN1 : R; bitpos: [19:10]; default: 0; + * HI_DOUT of ADC2 atten1 + */ +#define EFUSE_ADC2_HI_DOUT_ATTEN1 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN1_M (EFUSE_ADC2_HI_DOUT_ATTEN1_V << EFUSE_ADC2_HI_DOUT_ATTEN1_S) +#define EFUSE_ADC2_HI_DOUT_ATTEN1_V 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN1_S 10 +/** EFUSE_ADC2_HI_DOUT_ATTEN2 : R; bitpos: [29:20]; default: 0; + * HI_DOUT of ADC2 atten2 + */ +#define EFUSE_ADC2_HI_DOUT_ATTEN2 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN2_M (EFUSE_ADC2_HI_DOUT_ATTEN2_V << EFUSE_ADC2_HI_DOUT_ATTEN2_S) +#define EFUSE_ADC2_HI_DOUT_ATTEN2_V 0x000003FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN2_S 20 +/** EFUSE_ADC2_HI_DOUT_ATTEN3 : R; bitpos: [31:30]; default: 0; + * HI_DOUT of ADC2 atten3 + */ +#define EFUSE_ADC2_HI_DOUT_ATTEN3 0x00000003U +#define EFUSE_ADC2_HI_DOUT_ATTEN3_M (EFUSE_ADC2_HI_DOUT_ATTEN3_V << EFUSE_ADC2_HI_DOUT_ATTEN3_S) +#define EFUSE_ADC2_HI_DOUT_ATTEN3_V 0x00000003U +#define EFUSE_ADC2_HI_DOUT_ATTEN3_S 30 /** EFUSE_RD_SYS_PART2_DATA1_REG register * Register $n of BLOCK9 (KEY5). */ #define EFUSE_RD_SYS_PART2_DATA1_REG (DR_REG_EFUSE_BASE + 0x160) -/** EFUSE_SYS_DATA_PART2_1 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. - */ -#define EFUSE_SYS_DATA_PART2_1 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_1_M (EFUSE_SYS_DATA_PART2_1_V << EFUSE_SYS_DATA_PART2_1_S) -#define EFUSE_SYS_DATA_PART2_1_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_1_S 0 +/** EFUSE_ADC2_HI_DOUT_ATTEN3_1 : R; bitpos: [7:0]; default: 0; + * HI_DOUT of ADC2 atten3 + */ +#define EFUSE_ADC2_HI_DOUT_ATTEN3_1 0x000000FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN3_1_M (EFUSE_ADC2_HI_DOUT_ATTEN3_1_V << EFUSE_ADC2_HI_DOUT_ATTEN3_1_S) +#define EFUSE_ADC2_HI_DOUT_ATTEN3_1_V 0x000000FFU +#define EFUSE_ADC2_HI_DOUT_ATTEN3_1_S 0 +/** EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF : R; bitpos: [11:8]; default: 0; + * Gap between ADC1_ch0 and average initcode + */ +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S 8 +/** EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF : R; bitpos: [15:12]; default: 0; + * Gap between ADC1_ch1 and average initcode + */ +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S 12 +/** EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF : R; bitpos: [19:16]; default: 0; + * Gap between ADC1_ch2 and average initcode + */ +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S 16 +/** EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF : R; bitpos: [23:20]; default: 0; + * Gap between ADC1_ch3 and average initcode + */ +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S 20 +/** EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF : R; bitpos: [27:24]; default: 0; + * Gap between ADC1_ch4 and average initcode + */ +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_S 24 +/** EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF : R; bitpos: [31:28]; default: 0; + * Gap between ADC1_ch5 and average initcode + */ +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_S 28 /** EFUSE_RD_SYS_PART2_DATA2_REG register * Register $n of BLOCK10 (system). */ #define EFUSE_RD_SYS_PART2_DATA2_REG (DR_REG_EFUSE_BASE + 0x164) -/** EFUSE_SYS_DATA_PART2_2 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. - */ -#define EFUSE_SYS_DATA_PART2_2 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_2_M (EFUSE_SYS_DATA_PART2_2_V << EFUSE_SYS_DATA_PART2_2_S) -#define EFUSE_SYS_DATA_PART2_2_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_2_S 0 +/** EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF : R; bitpos: [3:0]; default: 0; + * Gap between ADC1_ch6 and average initcode + */ +#define EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH6_ATTEN0_INITCODE_DIFF_S 0 +/** EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF : R; bitpos: [7:4]; default: 0; + * Gap between ADC1_ch7 and average initcode + */ +#define EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH7_ATTEN0_INITCODE_DIFF_S 4 +/** EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF : R; bitpos: [11:8]; default: 0; + * Gap between ADC2_ch0 and average initcode + */ +#define EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH0_ATTEN0_INITCODE_DIFF_S 8 +/** EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF : R; bitpos: [15:12]; default: 0; + * Gap between ADC2_ch1 and average initcode + */ +#define EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH1_ATTEN0_INITCODE_DIFF_S 12 +/** EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF : R; bitpos: [19:16]; default: 0; + * Gap between ADC2_ch2 and average initcode + */ +#define EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH2_ATTEN0_INITCODE_DIFF_S 16 +/** EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF : R; bitpos: [23:20]; default: 0; + * Gap between ADC2_ch3 and average initcode + */ +#define EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH3_ATTEN0_INITCODE_DIFF_S 20 +/** EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF : R; bitpos: [27:24]; default: 0; + * Gap between ADC2_ch4 and average initcode + */ +#define EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH4_ATTEN0_INITCODE_DIFF_S 24 +/** EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF : R; bitpos: [31:28]; default: 0; + * Gap between ADC2_ch5 and average initcode + */ +#define EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC2_CH5_ATTEN0_INITCODE_DIFF_S 28 /** EFUSE_RD_SYS_PART2_DATA3_REG register * Register $n of BLOCK10 (system). */ #define EFUSE_RD_SYS_PART2_DATA3_REG (DR_REG_EFUSE_BASE + 0x168) -/** EFUSE_SYS_DATA_PART2_3 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. +/** EFUSE_TEMPERATURE_SENSOR : R; bitpos: [8:0]; default: 0; + * Temperature calibration data + */ +#define EFUSE_TEMPERATURE_SENSOR 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_M (EFUSE_TEMPERATURE_SENSOR_V << EFUSE_TEMPERATURE_SENSOR_S) +#define EFUSE_TEMPERATURE_SENSOR_V 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_S 0 +/** EFUSE_RESERVED_10_105 : R; bitpos: [31:9]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART2_3 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_3_M (EFUSE_SYS_DATA_PART2_3_V << EFUSE_SYS_DATA_PART2_3_S) -#define EFUSE_SYS_DATA_PART2_3_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART2_3_S 0 +#define EFUSE_RESERVED_10_105 0x007FFFFFU +#define EFUSE_RESERVED_10_105_M (EFUSE_RESERVED_10_105_V << EFUSE_RESERVED_10_105_S) +#define EFUSE_RESERVED_10_105_V 0x007FFFFFU +#define EFUSE_RESERVED_10_105_S 9 /** EFUSE_RD_SYS_PART2_DATA4_REG register * Register $n of BLOCK10 (system). diff --git a/components/soc/esp32p4/register/soc/efuse_struct.h b/components/soc/esp32p4/register/soc/efuse_struct.h index ac74f0f7ecb..f96653c4685 100644 --- a/components/soc/esp32p4/register/soc/efuse_struct.h +++ b/components/soc/esp32p4/register/soc/efuse_struct.h @@ -607,10 +607,18 @@ typedef union { * Package version */ uint32_t pkg_version:3; - /** reserved_1_87 : R; bitpos: [31:23]; default: 0; + /** reserved_1_87 : R; bitpos: [23]; default: 0; * reserved */ - uint32_t reserved_1_87:9; + uint32_t reserved_1_87:1; + /** ldo_vo1_dref : R; bitpos: [27:24]; default: 0; + * Output VO1 parameter + */ + uint32_t ldo_vo1_dref:4; + /** ldo_vo2_dref : R; bitpos: [31:28]; default: 0; + * Output VO2 parameter + */ + uint32_t ldo_vo2_dref:4; }; uint32_t val; } efuse_rd_mac_sys_2_reg_t; @@ -620,14 +628,30 @@ typedef union { */ typedef union { struct { - /** mac_reserved_2 : RO; bitpos: [17:0]; default: 0; - * Reserved. + /** ldo_vo1_mul : R; bitpos: [2:0]; default: 0; + * Output VO1 parameter + */ + uint32_t ldo_vo1_mul:3; + /** ldo_vo2_mul : R; bitpos: [5:3]; default: 0; + * Output VO2 parameter + */ + uint32_t ldo_vo2_mul:3; + /** ldo_vo3_k : R; bitpos: [13:6]; default: 0; + * Output VO3 calibration parameter */ - uint32_t mac_reserved_2:18; - /** sys_data_part0_0 : RO; bitpos: [31:18]; default: 0; - * Stores the first 14 bits of the zeroth part of system data. + uint32_t ldo_vo3_k:8; + /** ldo_vo3_vos : R; bitpos: [19:14]; default: 0; + * Output VO3 calibration parameter */ - uint32_t sys_data_part0_0:14; + uint32_t ldo_vo3_vos:6; + /** ldo_vo3_c : R; bitpos: [25:20]; default: 0; + * Output VO3 calibration parameter + */ + uint32_t ldo_vo3_c:6; + /** ldo_vo4_k : R; bitpos: [31:26]; default: 0; + * Output VO4 calibration parameter + */ + uint32_t ldo_vo4_k:6; }; uint32_t val; } efuse_rd_mac_sys_3_reg_t; @@ -637,10 +661,38 @@ typedef union { */ typedef union { struct { - /** sys_data_part0_1 : RO; bitpos: [31:0]; default: 0; - * Stores the first 32 bits of the zeroth part of system data. + /** ldo_vo4_k_1 : R; bitpos: [1:0]; default: 0; + * Output VO4 calibration parameter + */ + uint32_t ldo_vo4_k_1:2; + /** ldo_vo4_vos : R; bitpos: [7:2]; default: 0; + * Output VO4 calibration parameter + */ + uint32_t ldo_vo4_vos:6; + /** ldo_vo4_c : R; bitpos: [13:8]; default: 0; + * Output VO4 calibration parameter + */ + uint32_t ldo_vo4_c:6; + /** reserved_1_142 : R; bitpos: [15:14]; default: 0; + * reserved + */ + uint32_t reserved_1_142:2; + /** active_hp_dbias : R; bitpos: [19:16]; default: 0; + * Active HP DBIAS of fixed voltage + */ + uint32_t active_hp_dbias:4; + /** active_lp_dbias : R; bitpos: [23:20]; default: 0; + * Active LP DBIAS of fixed voltage + */ + uint32_t active_lp_dbias:4; + /** lslp_hp_dbias : R; bitpos: [27:24]; default: 0; + * LSLP HP DBIAS of fixed voltage */ - uint32_t sys_data_part0_1:32; + uint32_t lslp_hp_dbias:4; + /** dslp_dbg : R; bitpos: [31:28]; default: 0; + * DSLP BDG of fixed voltage + */ + uint32_t dslp_dbg:4; }; uint32_t val; } efuse_rd_mac_sys_4_reg_t; @@ -650,10 +702,18 @@ typedef union { */ typedef union { struct { - /** sys_data_part0_2 : RO; bitpos: [31:0]; default: 0; - * Stores the second 32 bits of the zeroth part of system data. + /** dslp_lp_dbias : R; bitpos: [4:0]; default: 0; + * DSLP LP DBIAS of fixed voltage + */ + uint32_t dslp_lp_dbias:5; + /** lp_dcdc_dbias_vol_gap : R; bitpos: [9:5]; default: 0; + * DBIAS gap between LP and DCDC + */ + uint32_t lp_dcdc_dbias_vol_gap:5; + /** reserved_1_170 : R; bitpos: [31:10]; default: 0; + * reserved */ - uint32_t sys_data_part0_2:32; + uint32_t reserved_1_170:22; }; uint32_t val; } efuse_rd_mac_sys_5_reg_t; @@ -715,10 +775,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_4 : RO; bitpos: [31:0]; default: 0; - * Stores the fourth 32 bits of the first part of system data. + /** adc1_ave_initcode_atten0 : R; bitpos: [9:0]; default: 0; + * Average initcode of ADC1 atten0 + */ + uint32_t adc1_ave_initcode_atten0:10; + /** adc1_ave_initcode_atten1 : R; bitpos: [19:10]; default: 0; + * Average initcode of ADC1 atten1 + */ + uint32_t adc1_ave_initcode_atten1:10; + /** adc1_ave_initcode_atten2 : R; bitpos: [29:20]; default: 0; + * Average initcode of ADC1 atten2 + */ + uint32_t adc1_ave_initcode_atten2:10; + /** adc1_ave_initcode_atten3 : R; bitpos: [31:30]; default: 0; + * Average initcode of ADC1 atten3 */ - uint32_t sys_data_part1_4:32; + uint32_t adc1_ave_initcode_atten3:2; }; uint32_t val; } efuse_rd_sys_part1_data4_reg_t; @@ -728,10 +800,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_5 : RO; bitpos: [31:0]; default: 0; - * Stores the fifth 32 bits of the first part of system data. + /** adc1_ave_initcode_atten3_1 : R; bitpos: [7:0]; default: 0; + * Average initcode of ADC1 atten3 */ - uint32_t sys_data_part1_5:32; + uint32_t adc1_ave_initcode_atten3_1:8; + /** adc2_ave_initcode_atten0 : R; bitpos: [17:8]; default: 0; + * Average initcode of ADC2 atten0 + */ + uint32_t adc2_ave_initcode_atten0:10; + /** adc2_ave_initcode_atten1 : R; bitpos: [27:18]; default: 0; + * Average initcode of ADC2 atten1 + */ + uint32_t adc2_ave_initcode_atten1:10; + /** adc2_ave_initcode_atten2 : R; bitpos: [31:28]; default: 0; + * Average initcode of ADC2 atten2 + */ + uint32_t adc2_ave_initcode_atten2:4; }; uint32_t val; } efuse_rd_sys_part1_data5_reg_t; @@ -741,10 +825,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_6 : RO; bitpos: [31:0]; default: 0; - * Stores the sixth 32 bits of the first part of system data. + /** adc2_ave_initcode_atten2_1 : R; bitpos: [5:0]; default: 0; + * Average initcode of ADC2 atten2 + */ + uint32_t adc2_ave_initcode_atten2_1:6; + /** adc2_ave_initcode_atten3 : R; bitpos: [15:6]; default: 0; + * Average initcode of ADC2 atten3 + */ + uint32_t adc2_ave_initcode_atten3:10; + /** adc1_hi_dout_atten0 : R; bitpos: [25:16]; default: 0; + * HI_DOUT of ADC1 atten0 + */ + uint32_t adc1_hi_dout_atten0:10; + /** adc1_hi_dout_atten1 : R; bitpos: [31:26]; default: 0; + * HI_DOUT of ADC1 atten1 */ - uint32_t sys_data_part1_6:32; + uint32_t adc1_hi_dout_atten1:6; }; uint32_t val; } efuse_rd_sys_part1_data6_reg_t; @@ -754,10 +850,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_7 : RO; bitpos: [31:0]; default: 0; - * Stores the seventh 32 bits of the first part of system data. + /** adc1_hi_dout_atten1_1 : R; bitpos: [3:0]; default: 0; + * HI_DOUT of ADC1 atten1 */ - uint32_t sys_data_part1_7:32; + uint32_t adc1_hi_dout_atten1_1:4; + /** adc1_hi_dout_atten2 : R; bitpos: [13:4]; default: 0; + * HI_DOUT of ADC1 atten2 + */ + uint32_t adc1_hi_dout_atten2:10; + /** adc1_hi_dout_atten3 : R; bitpos: [23:14]; default: 0; + * HI_DOUT of ADC1 atten3 + */ + uint32_t adc1_hi_dout_atten3:10; + /** reserved_2_248 : R; bitpos: [31:24]; default: 0; + * reserved + */ + uint32_t reserved_2_248:8; }; uint32_t val; } efuse_rd_sys_part1_data7_reg_t; @@ -1503,10 +1611,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part2_0 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. + /** adc2_hi_dout_atten0 : R; bitpos: [9:0]; default: 0; + * HI_DOUT of ADC2 atten0 + */ + uint32_t adc2_hi_dout_atten0:10; + /** adc2_hi_dout_atten1 : R; bitpos: [19:10]; default: 0; + * HI_DOUT of ADC2 atten1 + */ + uint32_t adc2_hi_dout_atten1:10; + /** adc2_hi_dout_atten2 : R; bitpos: [29:20]; default: 0; + * HI_DOUT of ADC2 atten2 */ - uint32_t sys_data_part2_0:32; + uint32_t adc2_hi_dout_atten2:10; + /** adc2_hi_dout_atten3 : R; bitpos: [31:30]; default: 0; + * HI_DOUT of ADC2 atten3 + */ + uint32_t adc2_hi_dout_atten3:2; }; uint32_t val; } efuse_rd_sys_part2_data0_reg_t; @@ -1516,10 +1636,34 @@ typedef union { */ typedef union { struct { - /** sys_data_part2_1 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. + /** adc2_hi_dout_atten3_1 : R; bitpos: [7:0]; default: 0; + * HI_DOUT of ADC2 atten3 + */ + uint32_t adc2_hi_dout_atten3_1:8; + /** adc1_ch0_atten0_initcode_diff : R; bitpos: [11:8]; default: 0; + * Gap between ADC1_ch0 and average initcode + */ + uint32_t adc1_ch0_atten0_initcode_diff:4; + /** adc1_ch1_atten0_initcode_diff : R; bitpos: [15:12]; default: 0; + * Gap between ADC1_ch1 and average initcode + */ + uint32_t adc1_ch1_atten0_initcode_diff:4; + /** adc1_ch2_atten0_initcode_diff : R; bitpos: [19:16]; default: 0; + * Gap between ADC1_ch2 and average initcode + */ + uint32_t adc1_ch2_atten0_initcode_diff:4; + /** adc1_ch3_atten0_initcode_diff : R; bitpos: [23:20]; default: 0; + * Gap between ADC1_ch3 and average initcode */ - uint32_t sys_data_part2_1:32; + uint32_t adc1_ch3_atten0_initcode_diff:4; + /** adc1_ch4_atten0_initcode_diff : R; bitpos: [27:24]; default: 0; + * Gap between ADC1_ch4 and average initcode + */ + uint32_t adc1_ch4_atten0_initcode_diff:4; + /** adc1_ch5_atten0_initcode_diff : R; bitpos: [31:28]; default: 0; + * Gap between ADC1_ch5 and average initcode + */ + uint32_t adc1_ch5_atten0_initcode_diff:4; }; uint32_t val; } efuse_rd_sys_part2_data1_reg_t; @@ -1529,10 +1673,38 @@ typedef union { */ typedef union { struct { - /** sys_data_part2_2 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. + /** adc1_ch6_atten0_initcode_diff : R; bitpos: [3:0]; default: 0; + * Gap between ADC1_ch6 and average initcode + */ + uint32_t adc1_ch6_atten0_initcode_diff:4; + /** adc1_ch7_atten0_initcode_diff : R; bitpos: [7:4]; default: 0; + * Gap between ADC1_ch7 and average initcode + */ + uint32_t adc1_ch7_atten0_initcode_diff:4; + /** adc2_ch0_atten0_initcode_diff : R; bitpos: [11:8]; default: 0; + * Gap between ADC2_ch0 and average initcode + */ + uint32_t adc2_ch0_atten0_initcode_diff:4; + /** adc2_ch1_atten0_initcode_diff : R; bitpos: [15:12]; default: 0; + * Gap between ADC2_ch1 and average initcode + */ + uint32_t adc2_ch1_atten0_initcode_diff:4; + /** adc2_ch2_atten0_initcode_diff : R; bitpos: [19:16]; default: 0; + * Gap between ADC2_ch2 and average initcode */ - uint32_t sys_data_part2_2:32; + uint32_t adc2_ch2_atten0_initcode_diff:4; + /** adc2_ch3_atten0_initcode_diff : R; bitpos: [23:20]; default: 0; + * Gap between ADC2_ch3 and average initcode + */ + uint32_t adc2_ch3_atten0_initcode_diff:4; + /** adc2_ch4_atten0_initcode_diff : R; bitpos: [27:24]; default: 0; + * Gap between ADC2_ch4 and average initcode + */ + uint32_t adc2_ch4_atten0_initcode_diff:4; + /** adc2_ch5_atten0_initcode_diff : R; bitpos: [31:28]; default: 0; + * Gap between ADC2_ch5 and average initcode + */ + uint32_t adc2_ch5_atten0_initcode_diff:4; }; uint32_t val; } efuse_rd_sys_part2_data2_reg_t; @@ -1542,10 +1714,14 @@ typedef union { */ typedef union { struct { - /** sys_data_part2_3 : RO; bitpos: [31:0]; default: 0; - * Stores the $nth 32 bits of the 2nd part of system data. + /** temperature_sensor : R; bitpos: [8:0]; default: 0; + * Temperature calibration data + */ + uint32_t temperature_sensor:9; + /** reserved_10_105 : R; bitpos: [31:9]; default: 0; + * reserved */ - uint32_t sys_data_part2_3:32; + uint32_t reserved_10_105:23; }; uint32_t val; } efuse_rd_sys_part2_data3_reg_t; From 7397c159cba8cc43659b8bfb2bb704d7e1253565 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Mon, 30 Sep 2024 18:52:53 +0300 Subject: [PATCH 69/70] feat(efuse): Adds efuse ADC calib data for ESP32-C5 --- components/efuse/esp32c5/esp_efuse_table.c | 398 +++++++++++++++++- components/efuse/esp32c5/esp_efuse_table.csv | 46 +- .../efuse/esp32c5/include/esp_efuse_table.h | 46 +- .../soc/esp32c5/register/soc/efuse_reg.h | 244 ++++++++--- .../soc/esp32c5/register/soc/efuse_struct.h | 363 +++++++++------- 5 files changed, 901 insertions(+), 196 deletions(-) diff --git a/components/efuse/esp32c5/esp_efuse_table.c b/components/efuse/esp32c5/esp_efuse_table.c index 7c0837a52d0..54279b76a40 100644 --- a/components/efuse/esp32c5/esp_efuse_table.c +++ b/components/efuse/esp32c5/esp_efuse_table.c @@ -9,7 +9,7 @@ #include #include "esp_efuse_table.h" -// md5_digest_table 13b0a8106fd483a0fcfa8b2f7388a95f +// md5_digest_table b26e7466c400977081a142076ef1a5bb // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -287,14 +287,102 @@ static const esp_efuse_desc_t WR_DIS_SYS_DATA_PART1[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of BLOCK2, }; +static const esp_efuse_desc_t WR_DIS_ACTIVE_HP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of ACTIVE_HP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_ACTIVE_LP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of ACTIVE_LP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_LSLP_HP_DBG[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LSLP_HP_DBG, +}; + +static const esp_efuse_desc_t WR_DIS_LSLP_HP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LSLP_HP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_DSLP_LP_DBG[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of DSLP_LP_DBG, +}; + +static const esp_efuse_desc_t WR_DIS_DSLP_LP_DBIAS[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of DSLP_LP_DBIAS, +}; + +static const esp_efuse_desc_t WR_DIS_LP_HP_DBIAS_VOL_GAP[] = { + {EFUSE_BLK0, 20, 1}, // [] wr_dis of LP_HP_DBIAS_VOL_GAP, +}; + static const esp_efuse_desc_t WR_DIS_OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of OPTIONAL_UNIQUE_ID, }; +static const esp_efuse_desc_t WR_DIS_TEMPERATURE_SENSOR[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of TEMPERATURE_SENSOR, +}; + static const esp_efuse_desc_t WR_DIS_OCODE[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of OCODE, }; +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INITCODE_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF, +}; + static const esp_efuse_desc_t WR_DIS_BLOCK_USR_DATA[] = { {EFUSE_BLK0, 22, 1}, // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA, }; @@ -648,14 +736,102 @@ static const esp_efuse_desc_t TRIM_P_BIAS[] = { {EFUSE_BLK1, 101, 5}, // [] PADC CAL P bias, }; +static const esp_efuse_desc_t ACTIVE_HP_DBIAS[] = { + {EFUSE_BLK1, 106, 4}, // [] Active HP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t ACTIVE_LP_DBIAS[] = { + {EFUSE_BLK1, 110, 4}, // [] Active LP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t LSLP_HP_DBG[] = { + {EFUSE_BLK1, 114, 2}, // [] LSLP HP DBG of fixed voltage, +}; + +static const esp_efuse_desc_t LSLP_HP_DBIAS[] = { + {EFUSE_BLK1, 116, 4}, // [] LSLP HP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t DSLP_LP_DBG[] = { + {EFUSE_BLK1, 120, 4}, // [] DSLP LP DBG of fixed voltage, +}; + +static const esp_efuse_desc_t DSLP_LP_DBIAS[] = { + {EFUSE_BLK1, 124, 5}, // [] DSLP LP DBIAS of fixed voltage, +}; + +static const esp_efuse_desc_t LP_HP_DBIAS_VOL_GAP[] = { + {EFUSE_BLK1, 129, 5}, // [] DBIAS gap between LP and HP, +}; + static const esp_efuse_desc_t OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK2, 0, 128}, // [] Optional unique 128-bit ID, }; +static const esp_efuse_desc_t TEMPERATURE_SENSOR[] = { + {EFUSE_BLK2, 128, 9}, // [] Temperature calibration data, +}; + static const esp_efuse_desc_t OCODE[] = { {EFUSE_BLK2, 137, 8}, // [] ADC OCode, }; +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN0[] = { + {EFUSE_BLK2, 145, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN1[] = { + {EFUSE_BLK2, 155, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN2[] = { + {EFUSE_BLK2, 165, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_AVE_INITCODE_ATTEN3[] = { + {EFUSE_BLK2, 175, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK2, 185, 10}, // [] HI DOUT of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK2, 195, 10}, // [] HI DOUT of ADC1 atten1, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK2, 205, 10}, // [] HI DOUT of ADC1 atten2, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK2, 215, 10}, // [] HI DOUT of ADC1 atten3, +}; + +static const esp_efuse_desc_t ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 225, 4}, // [] Gap between ADC1 CH0 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 229, 4}, // [] Gap between ADC1 CH1 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 233, 4}, // [] Gap between ADC1 CH2 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 237, 4}, // [] Gap between ADC1 CH3 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 241, 4}, // [] Gap between ADC1 CH4 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 245, 4}, // [] Gap between ADC1 CH5 and average initcode, +}; + static const esp_efuse_desc_t USER_DATA[] = { {EFUSE_BLK3, 0, 256}, // [BLOCK_USR_DATA] User data, }; @@ -1036,16 +1212,126 @@ const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_HP_DBIAS[] = { + &WR_DIS_ACTIVE_HP_DBIAS[0], // [] wr_dis of ACTIVE_HP_DBIAS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_LP_DBIAS[] = { + &WR_DIS_ACTIVE_LP_DBIAS[0], // [] wr_dis of ACTIVE_LP_DBIAS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBG[] = { + &WR_DIS_LSLP_HP_DBG[0], // [] wr_dis of LSLP_HP_DBG + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBIAS[] = { + &WR_DIS_LSLP_HP_DBIAS[0], // [] wr_dis of LSLP_HP_DBIAS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBG[] = { + &WR_DIS_DSLP_LP_DBG[0], // [] wr_dis of DSLP_LP_DBG + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBIAS[] = { + &WR_DIS_DSLP_LP_DBIAS[0], // [] wr_dis of DSLP_LP_DBIAS + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LP_HP_DBIAS_VOL_GAP[] = { + &WR_DIS_LP_HP_DBIAS_VOL_GAP[0], // [] wr_dis of LP_HP_DBIAS_VOL_GAP + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[] = { &WR_DIS_OPTIONAL_UNIQUE_ID[0], // [] wr_dis of OPTIONAL_UNIQUE_ID NULL }; +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[] = { + &WR_DIS_TEMPERATURE_SENSOR[0], // [] wr_dis of TEMPERATURE_SENSOR + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OCODE[] = { &WR_DIS_OCODE[0], // [] wr_dis of OCODE NULL }; +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN0[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN0[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN1[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN1[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN2[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN2[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN3[] = { + &WR_DIS_ADC1_AVE_INITCODE_ATTEN3[0], // [] wr_dis of ADC1_AVE_INITCODE_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN0[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN1[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN2[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN3[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[] = { &WR_DIS_BLOCK_USR_DATA[0], // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA NULL @@ -1486,16 +1772,126 @@ const esp_efuse_desc_t* ESP_EFUSE_TRIM_P_BIAS[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_HP_DBIAS[] = { + &ACTIVE_HP_DBIAS[0], // [] Active HP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_LP_DBIAS[] = { + &ACTIVE_LP_DBIAS[0], // [] Active LP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBG[] = { + &LSLP_HP_DBG[0], // [] LSLP HP DBG of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBIAS[] = { + &LSLP_HP_DBIAS[0], // [] LSLP HP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBG[] = { + &DSLP_LP_DBG[0], // [] DSLP LP DBG of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBIAS[] = { + &DSLP_LP_DBIAS[0], // [] DSLP LP DBIAS of fixed voltage + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_LP_HP_DBIAS_VOL_GAP[] = { + &LP_HP_DBIAS_VOL_GAP[0], // [] DBIAS gap between LP and HP + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[] = { &OPTIONAL_UNIQUE_ID[0], // [] Optional unique 128-bit ID NULL }; +const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[] = { + &TEMPERATURE_SENSOR[0], // [] Temperature calibration data + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_OCODE[] = { &OCODE[0], // [] ADC OCode NULL }; +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN0[] = { + &ADC1_AVE_INITCODE_ATTEN0[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN1[] = { + &ADC1_AVE_INITCODE_ATTEN1[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN2[] = { + &ADC1_AVE_INITCODE_ATTEN2[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN3[] = { + &ADC1_AVE_INITCODE_ATTEN3[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[] = { + &ADC1_HI_DOUT_ATTEN0[0], // [] HI DOUT of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[] = { + &ADC1_HI_DOUT_ATTEN1[0], // [] HI DOUT of ADC1 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[] = { + &ADC1_HI_DOUT_ATTEN2[0], // [] HI DOUT of ADC1 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[] = { + &ADC1_HI_DOUT_ATTEN3[0], // [] HI DOUT of ADC1 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH0 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH1 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH2 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH3 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH4_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH4 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH5_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH5 and average initcode + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[] = { &USER_DATA[0], // [BLOCK_USR_DATA] User data NULL diff --git a/components/efuse/esp32c5/esp_efuse_table.csv b/components/efuse/esp32c5/esp_efuse_table.csv index 29fc4e1f5c2..3ba2839da4e 100644 --- a/components/efuse/esp32c5/esp_efuse_table.csv +++ b/components/efuse/esp32c5/esp_efuse_table.csv @@ -9,7 +9,7 @@ # this will generate new source files, next rebuild all the sources. # !!!!!!!!!!! # -# This file was generated by regtools.py based on the efuses.yaml file with the version: b09fa417de505238a601eddce188b696 +# This file was generated by regtools.py based on the efuses.yaml file with the version: 287a0ed4951aba84b9571a5f31000275 WR_DIS, EFUSE_BLK0, 0, 32, [] Disable programming of individual eFuses WR_DIS.RD_DIS, EFUSE_BLK0, 0, 1, [] wr_dis of RD_DIS @@ -79,8 +79,30 @@ WR_DIS.PA_TRIM_VERSION, EFUSE_BLK0, 20, 1, [] wr_dis WR_DIS.TRIM_N_BIAS, EFUSE_BLK0, 20, 1, [] wr_dis of TRIM_N_BIAS WR_DIS.TRIM_P_BIAS, EFUSE_BLK0, 20, 1, [] wr_dis of TRIM_P_BIAS WR_DIS.SYS_DATA_PART1, EFUSE_BLK0, 21, 1, [] wr_dis of BLOCK2 +WR_DIS.ACTIVE_HP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of ACTIVE_HP_DBIAS +WR_DIS.ACTIVE_LP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of ACTIVE_LP_DBIAS +WR_DIS.LSLP_HP_DBG, EFUSE_BLK0, 20, 1, [] wr_dis of LSLP_HP_DBG +WR_DIS.LSLP_HP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of LSLP_HP_DBIAS +WR_DIS.DSLP_LP_DBG, EFUSE_BLK0, 20, 1, [] wr_dis of DSLP_LP_DBG +WR_DIS.DSLP_LP_DBIAS, EFUSE_BLK0, 20, 1, [] wr_dis of DSLP_LP_DBIAS +WR_DIS.LP_HP_DBIAS_VOL_GAP, EFUSE_BLK0, 20, 1, [] wr_dis of LP_HP_DBIAS_VOL_GAP WR_DIS.OPTIONAL_UNIQUE_ID, EFUSE_BLK0, 21, 1, [] wr_dis of OPTIONAL_UNIQUE_ID +WR_DIS.TEMPERATURE_SENSOR, EFUSE_BLK0, 21, 1, [] wr_dis of TEMPERATURE_SENSOR WR_DIS.OCODE, EFUSE_BLK0, 21, 1, [] wr_dis of OCODE +WR_DIS.ADC1_AVE_INITCODE_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN0 +WR_DIS.ADC1_AVE_INITCODE_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN1 +WR_DIS.ADC1_AVE_INITCODE_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN2 +WR_DIS.ADC1_AVE_INITCODE_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INITCODE_ATTEN3 +WR_DIS.ADC1_HI_DOUT_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN0 +WR_DIS.ADC1_HI_DOUT_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN1 +WR_DIS.ADC1_HI_DOUT_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN2 +WR_DIS.ADC1_HI_DOUT_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN3 +WR_DIS.ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH4_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH5_ATTEN0_INITCODE_DIFF WR_DIS.BLOCK_USR_DATA, EFUSE_BLK0, 22, 1, [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA WR_DIS.CUSTOM_MAC, EFUSE_BLK0, 22, 1, [WR_DIS.MAC_CUSTOM WR_DIS.USER_DATA_MAC_CUSTOM] wr_dis of CUSTOM_MAC WR_DIS.BLOCK_KEY0, EFUSE_BLK0, 23, 1, [WR_DIS.KEY0] wr_dis of BLOCK_KEY0 @@ -173,8 +195,30 @@ PKG_VERSION, EFUSE_BLK1, 90, 3, [] Packag PA_TRIM_VERSION, EFUSE_BLK1, 93, 3, [] PADC CAL PA trim version TRIM_N_BIAS, EFUSE_BLK1, 96, 5, [] PADC CAL N bias TRIM_P_BIAS, EFUSE_BLK1, 101, 5, [] PADC CAL P bias +ACTIVE_HP_DBIAS, EFUSE_BLK1, 106, 4, [] Active HP DBIAS of fixed voltage +ACTIVE_LP_DBIAS, EFUSE_BLK1, 110, 4, [] Active LP DBIAS of fixed voltage +LSLP_HP_DBG, EFUSE_BLK1, 114, 2, [] LSLP HP DBG of fixed voltage +LSLP_HP_DBIAS, EFUSE_BLK1, 116, 4, [] LSLP HP DBIAS of fixed voltage +DSLP_LP_DBG, EFUSE_BLK1, 120, 4, [] DSLP LP DBG of fixed voltage +DSLP_LP_DBIAS, EFUSE_BLK1, 124, 5, [] DSLP LP DBIAS of fixed voltage +LP_HP_DBIAS_VOL_GAP, EFUSE_BLK1, 129, 5, [] DBIAS gap between LP and HP OPTIONAL_UNIQUE_ID, EFUSE_BLK2, 0, 128, [] Optional unique 128-bit ID +TEMPERATURE_SENSOR, EFUSE_BLK2, 128, 9, [] Temperature calibration data OCODE, EFUSE_BLK2, 137, 8, [] ADC OCode +ADC1_AVE_INITCODE_ATTEN0, EFUSE_BLK2, 145, 10, [] Average initcode of ADC1 atten0 +ADC1_AVE_INITCODE_ATTEN1, EFUSE_BLK2, 155, 10, [] Average initcode of ADC1 atten0 +ADC1_AVE_INITCODE_ATTEN2, EFUSE_BLK2, 165, 10, [] Average initcode of ADC1 atten0 +ADC1_AVE_INITCODE_ATTEN3, EFUSE_BLK2, 175, 10, [] Average initcode of ADC1 atten0 +ADC1_HI_DOUT_ATTEN0, EFUSE_BLK2, 185, 10, [] HI DOUT of ADC1 atten0 +ADC1_HI_DOUT_ATTEN1, EFUSE_BLK2, 195, 10, [] HI DOUT of ADC1 atten1 +ADC1_HI_DOUT_ATTEN2, EFUSE_BLK2, 205, 10, [] HI DOUT of ADC1 atten2 +ADC1_HI_DOUT_ATTEN3, EFUSE_BLK2, 215, 10, [] HI DOUT of ADC1 atten3 +ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 225, 4, [] Gap between ADC1 CH0 and average initcode +ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 229, 4, [] Gap between ADC1 CH1 and average initcode +ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 233, 4, [] Gap between ADC1 CH2 and average initcode +ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 237, 4, [] Gap between ADC1 CH3 and average initcode +ADC1_CH4_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 241, 4, [] Gap between ADC1 CH4 and average initcode +ADC1_CH5_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 245, 4, [] Gap between ADC1 CH5 and average initcode USER_DATA, EFUSE_BLK3, 0, 256, [BLOCK_USR_DATA] User data USER_DATA.MAC_CUSTOM, EFUSE_BLK3, 200, 48, [MAC_CUSTOM CUSTOM_MAC] Custom MAC KEY0, EFUSE_BLK4, 0, 256, [BLOCK_KEY0] Key0 or user data diff --git a/components/efuse/esp32c5/include/esp_efuse_table.h b/components/efuse/esp32c5/include/esp_efuse_table.h index 5cc46273545..7bcd93b66aa 100644 --- a/components/efuse/esp32c5/include/esp_efuse_table.h +++ b/components/efuse/esp32c5/include/esp_efuse_table.h @@ -10,7 +10,7 @@ extern "C" { #include "esp_efuse.h" -// md5_digest_table 13b0a8106fd483a0fcfa8b2f7388a95f +// md5_digest_table b26e7466c400977081a142076ef1a5bb // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -92,8 +92,30 @@ extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_PA_TRIM_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TRIM_N_BIAS[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TRIM_P_BIAS[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ACTIVE_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LSLP_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_DSLP_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_LP_HP_DBIAS_VOL_GAP[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OCODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH5_ATTEN0_INITCODE_DIFF[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[]; #define ESP_EFUSE_WR_DIS_USER_DATA ESP_EFUSE_WR_DIS_BLOCK_USR_DATA extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_CUSTOM_MAC[]; @@ -205,8 +227,30 @@ extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_PA_TRIM_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_TRIM_N_BIAS[]; extern const esp_efuse_desc_t* ESP_EFUSE_TRIM_P_BIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ACTIVE_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LSLP_HP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBG[]; +extern const esp_efuse_desc_t* ESP_EFUSE_DSLP_LP_DBIAS[]; +extern const esp_efuse_desc_t* ESP_EFUSE_LP_HP_DBIAS_VOL_GAP[]; extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INITCODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF[]; extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[]; #define ESP_EFUSE_BLOCK_USR_DATA ESP_EFUSE_USER_DATA extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[]; diff --git a/components/soc/esp32c5/register/soc/efuse_reg.h b/components/soc/esp32c5/register/soc/efuse_reg.h index 1da0dd667ed..51a6a3122df 100644 --- a/components/soc/esp32c5/register/soc/efuse_reg.h +++ b/components/soc/esp32c5/register/soc/efuse_reg.h @@ -804,32 +804,74 @@ extern "C" { #define EFUSE_TRIM_P_BIAS_M (EFUSE_TRIM_P_BIAS_V << EFUSE_TRIM_P_BIAS_S) #define EFUSE_TRIM_P_BIAS_V 0x0000001FU #define EFUSE_TRIM_P_BIAS_S 5 -/** EFUSE_RESERVED_1_106 : R; bitpos: [17:10]; default: 0; - * reserved - */ -#define EFUSE_RESERVED_1_106 0x000000FFU -#define EFUSE_RESERVED_1_106_M (EFUSE_RESERVED_1_106_V << EFUSE_RESERVED_1_106_S) -#define EFUSE_RESERVED_1_106_V 0x000000FFU -#define EFUSE_RESERVED_1_106_S 10 -/** EFUSE_SYS_DATA_PART0_0 : RO; bitpos: [31:18]; default: 0; - * Represents the first 14-bit of zeroth part of system data. - */ -#define EFUSE_SYS_DATA_PART0_0 0x00003FFFU -#define EFUSE_SYS_DATA_PART0_0_M (EFUSE_SYS_DATA_PART0_0_V << EFUSE_SYS_DATA_PART0_0_S) -#define EFUSE_SYS_DATA_PART0_0_V 0x00003FFFU -#define EFUSE_SYS_DATA_PART0_0_S 18 +/** EFUSE_ACTIVE_HP_DBIAS : R; bitpos: [13:10]; default: 0; + * Active HP DBIAS of fixed voltage + */ +#define EFUSE_ACTIVE_HP_DBIAS 0x0000000FU +#define EFUSE_ACTIVE_HP_DBIAS_M (EFUSE_ACTIVE_HP_DBIAS_V << EFUSE_ACTIVE_HP_DBIAS_S) +#define EFUSE_ACTIVE_HP_DBIAS_V 0x0000000FU +#define EFUSE_ACTIVE_HP_DBIAS_S 10 +/** EFUSE_ACTIVE_LP_DBIAS : R; bitpos: [17:14]; default: 0; + * Active LP DBIAS of fixed voltage + */ +#define EFUSE_ACTIVE_LP_DBIAS 0x0000000FU +#define EFUSE_ACTIVE_LP_DBIAS_M (EFUSE_ACTIVE_LP_DBIAS_V << EFUSE_ACTIVE_LP_DBIAS_S) +#define EFUSE_ACTIVE_LP_DBIAS_V 0x0000000FU +#define EFUSE_ACTIVE_LP_DBIAS_S 14 +/** EFUSE_LSLP_HP_DBG : R; bitpos: [19:18]; default: 0; + * LSLP HP DBG of fixed voltage + */ +#define EFUSE_LSLP_HP_DBG 0x00000003U +#define EFUSE_LSLP_HP_DBG_M (EFUSE_LSLP_HP_DBG_V << EFUSE_LSLP_HP_DBG_S) +#define EFUSE_LSLP_HP_DBG_V 0x00000003U +#define EFUSE_LSLP_HP_DBG_S 18 +/** EFUSE_LSLP_HP_DBIAS : R; bitpos: [23:20]; default: 0; + * LSLP HP DBIAS of fixed voltage + */ +#define EFUSE_LSLP_HP_DBIAS 0x0000000FU +#define EFUSE_LSLP_HP_DBIAS_M (EFUSE_LSLP_HP_DBIAS_V << EFUSE_LSLP_HP_DBIAS_S) +#define EFUSE_LSLP_HP_DBIAS_V 0x0000000FU +#define EFUSE_LSLP_HP_DBIAS_S 20 +/** EFUSE_DSLP_LP_DBG : R; bitpos: [27:24]; default: 0; + * DSLP LP DBG of fixed voltage + */ +#define EFUSE_DSLP_LP_DBG 0x0000000FU +#define EFUSE_DSLP_LP_DBG_M (EFUSE_DSLP_LP_DBG_V << EFUSE_DSLP_LP_DBG_S) +#define EFUSE_DSLP_LP_DBG_V 0x0000000FU +#define EFUSE_DSLP_LP_DBG_S 24 +/** EFUSE_DSLP_LP_DBIAS : R; bitpos: [31:28]; default: 0; + * DSLP LP DBIAS of fixed voltage + */ +#define EFUSE_DSLP_LP_DBIAS 0x0000000FU +#define EFUSE_DSLP_LP_DBIAS_M (EFUSE_DSLP_LP_DBIAS_V << EFUSE_DSLP_LP_DBIAS_S) +#define EFUSE_DSLP_LP_DBIAS_V 0x0000000FU +#define EFUSE_DSLP_LP_DBIAS_S 28 /** EFUSE_RD_MAC_SYS4_REG register * Represents rd_mac_sys */ #define EFUSE_RD_MAC_SYS4_REG (DR_REG_EFUSE_BASE + 0x54) -/** EFUSE_SYS_DATA_PART0_1 : RO; bitpos: [31:0]; default: 0; - * Represents the first 14-bit of zeroth part of system data. +/** EFUSE_DSLP_LP_DBIAS_1 : R; bitpos: [0]; default: 0; + * DSLP LP DBIAS of fixed voltage + */ +#define EFUSE_DSLP_LP_DBIAS_1 (BIT(0)) +#define EFUSE_DSLP_LP_DBIAS_1_M (EFUSE_DSLP_LP_DBIAS_1_V << EFUSE_DSLP_LP_DBIAS_1_S) +#define EFUSE_DSLP_LP_DBIAS_1_V 0x00000001U +#define EFUSE_DSLP_LP_DBIAS_1_S 0 +/** EFUSE_LP_HP_DBIAS_VOL_GAP : R; bitpos: [5:1]; default: 0; + * DBIAS gap between LP and HP + */ +#define EFUSE_LP_HP_DBIAS_VOL_GAP 0x0000001FU +#define EFUSE_LP_HP_DBIAS_VOL_GAP_M (EFUSE_LP_HP_DBIAS_VOL_GAP_V << EFUSE_LP_HP_DBIAS_VOL_GAP_S) +#define EFUSE_LP_HP_DBIAS_VOL_GAP_V 0x0000001FU +#define EFUSE_LP_HP_DBIAS_VOL_GAP_S 1 +/** EFUSE_RESERVED_1_134 : R; bitpos: [31:6]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART0_1 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_1_M (EFUSE_SYS_DATA_PART0_1_V << EFUSE_SYS_DATA_PART0_1_S) -#define EFUSE_SYS_DATA_PART0_1_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART0_1_S 0 +#define EFUSE_RESERVED_1_134 0x03FFFFFFU +#define EFUSE_RESERVED_1_134_M (EFUSE_RESERVED_1_134_V << EFUSE_RESERVED_1_134_S) +#define EFUSE_RESERVED_1_134_V 0x03FFFFFFU +#define EFUSE_RESERVED_1_134_S 6 /** EFUSE_RD_MAC_SYS5_REG register * Represents rd_mac_sys @@ -895,13 +937,13 @@ extern "C" { * Represents rd_sys_part1_data4 */ #define EFUSE_RD_SYS_PART1_DATA4_REG (DR_REG_EFUSE_BASE + 0x6c) -/** EFUSE_RESERVED_2_128 : R; bitpos: [8:0]; default: 0; - * reserved +/** EFUSE_TEMPERATURE_SENSOR : R; bitpos: [8:0]; default: 0; + * Temperature calibration data */ -#define EFUSE_RESERVED_2_128 0x000001FFU -#define EFUSE_RESERVED_2_128_M (EFUSE_RESERVED_2_128_V << EFUSE_RESERVED_2_128_S) -#define EFUSE_RESERVED_2_128_V 0x000001FFU -#define EFUSE_RESERVED_2_128_S 0 +#define EFUSE_TEMPERATURE_SENSOR 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_M (EFUSE_TEMPERATURE_SENSOR_V << EFUSE_TEMPERATURE_SENSOR_S) +#define EFUSE_TEMPERATURE_SENSOR_V 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_S 0 /** EFUSE_OCODE : R; bitpos: [16:9]; default: 0; * ADC OCode */ @@ -909,49 +951,147 @@ extern "C" { #define EFUSE_OCODE_M (EFUSE_OCODE_V << EFUSE_OCODE_S) #define EFUSE_OCODE_V 0x000000FFU #define EFUSE_OCODE_S 9 -/** EFUSE_RESERVED_2_145 : R; bitpos: [31:17]; default: 0; - * reserved +/** EFUSE_ADC1_AVE_INITCODE_ATTEN0 : R; bitpos: [26:17]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_M (EFUSE_ADC1_AVE_INITCODE_ATTEN0_V << EFUSE_ADC1_AVE_INITCODE_ATTEN0_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN0_S 17 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN1 : R; bitpos: [31:27]; default: 0; + * Average initcode of ADC1 atten0 */ -#define EFUSE_RESERVED_2_145 0x00007FFFU -#define EFUSE_RESERVED_2_145_M (EFUSE_RESERVED_2_145_V << EFUSE_RESERVED_2_145_S) -#define EFUSE_RESERVED_2_145_V 0x00007FFFU -#define EFUSE_RESERVED_2_145_S 17 +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1 0x0000001FU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_M (EFUSE_ADC1_AVE_INITCODE_ATTEN1_V << EFUSE_ADC1_AVE_INITCODE_ATTEN1_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_V 0x0000001FU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_S 27 /** EFUSE_RD_SYS_PART1_DATA5_REG register * Represents rd_sys_part1_data5 */ #define EFUSE_RD_SYS_PART1_DATA5_REG (DR_REG_EFUSE_BASE + 0x70) -/** EFUSE_SYS_DATA_PART1_5 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_5 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_M (EFUSE_SYS_DATA_PART1_5_V << EFUSE_SYS_DATA_PART1_5_S) -#define EFUSE_SYS_DATA_PART1_5_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_S 0 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN1_1 : R; bitpos: [4:0]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_1 0x0000001FU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_1_M (EFUSE_ADC1_AVE_INITCODE_ATTEN1_1_V << EFUSE_ADC1_AVE_INITCODE_ATTEN1_1_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_1_V 0x0000001FU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN1_1_S 0 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN2 : R; bitpos: [14:5]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_M (EFUSE_ADC1_AVE_INITCODE_ATTEN2_V << EFUSE_ADC1_AVE_INITCODE_ATTEN2_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN2_S 5 +/** EFUSE_ADC1_AVE_INITCODE_ATTEN3 : R; bitpos: [24:15]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_M (EFUSE_ADC1_AVE_INITCODE_ATTEN3_V << EFUSE_ADC1_AVE_INITCODE_ATTEN3_S) +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_V 0x000003FFU +#define EFUSE_ADC1_AVE_INITCODE_ATTEN3_S 15 +/** EFUSE_ADC1_HI_DOUT_ATTEN0 : R; bitpos: [31:25]; default: 0; + * HI DOUT of ADC1 atten0 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN0 0x0000007FU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_M (EFUSE_ADC1_HI_DOUT_ATTEN0_V << EFUSE_ADC1_HI_DOUT_ATTEN0_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN0_V 0x0000007FU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_S 25 /** EFUSE_RD_SYS_PART1_DATA6_REG register * Represents rd_sys_part1_data6 */ #define EFUSE_RD_SYS_PART1_DATA6_REG (DR_REG_EFUSE_BASE + 0x74) -/** EFUSE_SYS_DATA_PART1_6 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_6 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_M (EFUSE_SYS_DATA_PART1_6_V << EFUSE_SYS_DATA_PART1_6_S) -#define EFUSE_SYS_DATA_PART1_6_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_S 0 +/** EFUSE_ADC1_HI_DOUT_ATTEN0_1 : R; bitpos: [2:0]; default: 0; + * HI DOUT of ADC1 atten0 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1 0x00000007U +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_M (EFUSE_ADC1_HI_DOUT_ATTEN0_1_V << EFUSE_ADC1_HI_DOUT_ATTEN0_1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_V 0x00000007U +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_S 0 +/** EFUSE_ADC1_HI_DOUT_ATTEN1 : R; bitpos: [12:3]; default: 0; + * HI DOUT of ADC1 atten1 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN1 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_M (EFUSE_ADC1_HI_DOUT_ATTEN1_V << EFUSE_ADC1_HI_DOUT_ATTEN1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN1_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_S 3 +/** EFUSE_ADC1_HI_DOUT_ATTEN2 : R; bitpos: [22:13]; default: 0; + * HI DOUT of ADC1 atten2 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN2 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_M (EFUSE_ADC1_HI_DOUT_ATTEN2_V << EFUSE_ADC1_HI_DOUT_ATTEN2_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_S 13 +/** EFUSE_ADC1_HI_DOUT_ATTEN3 : R; bitpos: [31:23]; default: 0; + * HI DOUT of ADC1 atten3 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN3 0x000001FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_M (EFUSE_ADC1_HI_DOUT_ATTEN3_V << EFUSE_ADC1_HI_DOUT_ATTEN3_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_V 0x000001FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_S 23 /** EFUSE_RD_SYS_PART1_DATA7_REG register * Represents rd_sys_part1_data7 */ #define EFUSE_RD_SYS_PART1_DATA7_REG (DR_REG_EFUSE_BASE + 0x78) -/** EFUSE_SYS_DATA_PART1_7 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. +/** EFUSE_ADC1_HI_DOUT_ATTEN3_1 : R; bitpos: [0]; default: 0; + * HI DOUT of ADC1 atten3 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1 (BIT(0)) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_M (EFUSE_ADC1_HI_DOUT_ATTEN3_1_V << EFUSE_ADC1_HI_DOUT_ATTEN3_1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_V 0x00000001U +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_S 0 +/** EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF : R; bitpos: [4:1]; default: 0; + * Gap between ADC1 CH0 and average initcode + */ +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S 1 +/** EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF : R; bitpos: [8:5]; default: 0; + * Gap between ADC1 CH1 and average initcode + */ +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S 5 +/** EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF : R; bitpos: [12:9]; default: 0; + * Gap between ADC1 CH2 and average initcode + */ +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S 9 +/** EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF : R; bitpos: [16:13]; default: 0; + * Gap between ADC1 CH3 and average initcode + */ +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S 13 +/** EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF : R; bitpos: [20:17]; default: 0; + * Gap between ADC1 CH4 and average initcode + */ +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH4_ATTEN0_INITCODE_DIFF_S 17 +/** EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF : R; bitpos: [24:21]; default: 0; + * Gap between ADC1 CH5 and average initcode + */ +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH5_ATTEN0_INITCODE_DIFF_S 21 +/** EFUSE_RESERVED_2_249 : R; bitpos: [31:25]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART1_7 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_M (EFUSE_SYS_DATA_PART1_7_V << EFUSE_SYS_DATA_PART1_7_S) -#define EFUSE_SYS_DATA_PART1_7_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_S 0 +#define EFUSE_RESERVED_2_249 0x0000007FU +#define EFUSE_RESERVED_2_249_M (EFUSE_RESERVED_2_249_V << EFUSE_RESERVED_2_249_S) +#define EFUSE_RESERVED_2_249_V 0x0000007FU +#define EFUSE_RESERVED_2_249_S 25 /** EFUSE_RD_USR_DATA0_REG register * Represents rd_usr_data0 diff --git a/components/soc/esp32c5/register/soc/efuse_struct.h b/components/soc/esp32c5/register/soc/efuse_struct.h index d4825477e61..8e614477830 100644 --- a/components/soc/esp32c5/register/soc/efuse_struct.h +++ b/components/soc/esp32c5/register/soc/efuse_struct.h @@ -615,14 +615,30 @@ typedef union { * PADC CAL P bias */ uint32_t trim_p_bias:5; - /** reserved_1_106 : R; bitpos: [17:10]; default: 0; - * reserved + /** active_hp_dbias : R; bitpos: [13:10]; default: 0; + * Active HP DBIAS of fixed voltage + */ + uint32_t active_hp_dbias:4; + /** active_lp_dbias : R; bitpos: [17:14]; default: 0; + * Active LP DBIAS of fixed voltage + */ + uint32_t active_lp_dbias:4; + /** lslp_hp_dbg : R; bitpos: [19:18]; default: 0; + * LSLP HP DBG of fixed voltage + */ + uint32_t lslp_hp_dbg:2; + /** lslp_hp_dbias : R; bitpos: [23:20]; default: 0; + * LSLP HP DBIAS of fixed voltage + */ + uint32_t lslp_hp_dbias:4; + /** dslp_lp_dbg : R; bitpos: [27:24]; default: 0; + * DSLP LP DBG of fixed voltage */ - uint32_t reserved_1_106:8; - /** sys_data_part0_0 : RO; bitpos: [31:18]; default: 0; - * Represents the first 14-bit of zeroth part of system data. + uint32_t dslp_lp_dbg:4; + /** dslp_lp_dbias : R; bitpos: [31:28]; default: 0; + * DSLP LP DBIAS of fixed voltage */ - uint32_t sys_data_part0_0:14; + uint32_t dslp_lp_dbias:4; }; uint32_t val; } efuse_rd_mac_sys3_reg_t; @@ -632,10 +648,18 @@ typedef union { */ typedef union { struct { - /** sys_data_part0_1 : RO; bitpos: [31:0]; default: 0; - * Represents the first 14-bit of zeroth part of system data. + /** dslp_lp_dbias_1 : R; bitpos: [0]; default: 0; + * DSLP LP DBIAS of fixed voltage */ - uint32_t sys_data_part0_1:32; + uint32_t dslp_lp_dbias_1:1; + /** lp_hp_dbias_vol_gap : R; bitpos: [5:1]; default: 0; + * DBIAS gap between LP and HP + */ + uint32_t lp_hp_dbias_vol_gap:5; + /** reserved_1_134 : R; bitpos: [31:6]; default: 0; + * reserved + */ + uint32_t reserved_1_134:26; }; uint32_t val; } efuse_rd_mac_sys4_reg_t; @@ -712,18 +736,22 @@ typedef union { */ typedef union { struct { - /** reserved_2_128 : R; bitpos: [8:0]; default: 0; - * reserved + /** temperature_sensor : R; bitpos: [8:0]; default: 0; + * Temperature calibration data */ - uint32_t reserved_2_128:9; + uint32_t temperature_sensor:9; /** ocode : R; bitpos: [16:9]; default: 0; * ADC OCode */ uint32_t ocode:8; - /** reserved_2_145 : R; bitpos: [31:17]; default: 0; - * reserved + /** adc1_ave_initcode_atten0 : R; bitpos: [26:17]; default: 0; + * Average initcode of ADC1 atten0 + */ + uint32_t adc1_ave_initcode_atten0:10; + /** adc1_ave_initcode_atten1 : R; bitpos: [31:27]; default: 0; + * Average initcode of ADC1 atten0 */ - uint32_t reserved_2_145:15; + uint32_t adc1_ave_initcode_atten1:5; }; uint32_t val; } efuse_rd_sys_part1_data4_reg_t; @@ -733,10 +761,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_5 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_ave_initcode_atten1_1 : R; bitpos: [4:0]; default: 0; + * Average initcode of ADC1 atten0 + */ + uint32_t adc1_ave_initcode_atten1_1:5; + /** adc1_ave_initcode_atten2 : R; bitpos: [14:5]; default: 0; + * Average initcode of ADC1 atten0 + */ + uint32_t adc1_ave_initcode_atten2:10; + /** adc1_ave_initcode_atten3 : R; bitpos: [24:15]; default: 0; + * Average initcode of ADC1 atten0 */ - uint32_t sys_data_part1_5:32; + uint32_t adc1_ave_initcode_atten3:10; + /** adc1_hi_dout_atten0 : R; bitpos: [31:25]; default: 0; + * HI DOUT of ADC1 atten0 + */ + uint32_t adc1_hi_dout_atten0:7; }; uint32_t val; } efuse_rd_sys_part1_data5_reg_t; @@ -746,10 +786,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_6 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_hi_dout_atten0_1 : R; bitpos: [2:0]; default: 0; + * HI DOUT of ADC1 atten0 + */ + uint32_t adc1_hi_dout_atten0_1:3; + /** adc1_hi_dout_atten1 : R; bitpos: [12:3]; default: 0; + * HI DOUT of ADC1 atten1 + */ + uint32_t adc1_hi_dout_atten1:10; + /** adc1_hi_dout_atten2 : R; bitpos: [22:13]; default: 0; + * HI DOUT of ADC1 atten2 + */ + uint32_t adc1_hi_dout_atten2:10; + /** adc1_hi_dout_atten3 : R; bitpos: [31:23]; default: 0; + * HI DOUT of ADC1 atten3 */ - uint32_t sys_data_part1_6:32; + uint32_t adc1_hi_dout_atten3:9; }; uint32_t val; } efuse_rd_sys_part1_data6_reg_t; @@ -759,10 +811,38 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_7 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_hi_dout_atten3_1 : R; bitpos: [0]; default: 0; + * HI DOUT of ADC1 atten3 */ - uint32_t sys_data_part1_7:32; + uint32_t adc1_hi_dout_atten3_1:1; + /** adc1_ch0_atten0_initcode_diff : R; bitpos: [4:1]; default: 0; + * Gap between ADC1 CH0 and average initcode + */ + uint32_t adc1_ch0_atten0_initcode_diff:4; + /** adc1_ch1_atten0_initcode_diff : R; bitpos: [8:5]; default: 0; + * Gap between ADC1 CH1 and average initcode + */ + uint32_t adc1_ch1_atten0_initcode_diff:4; + /** adc1_ch2_atten0_initcode_diff : R; bitpos: [12:9]; default: 0; + * Gap between ADC1 CH2 and average initcode + */ + uint32_t adc1_ch2_atten0_initcode_diff:4; + /** adc1_ch3_atten0_initcode_diff : R; bitpos: [16:13]; default: 0; + * Gap between ADC1 CH3 and average initcode + */ + uint32_t adc1_ch3_atten0_initcode_diff:4; + /** adc1_ch4_atten0_initcode_diff : R; bitpos: [20:17]; default: 0; + * Gap between ADC1 CH4 and average initcode + */ + uint32_t adc1_ch4_atten0_initcode_diff:4; + /** adc1_ch5_atten0_initcode_diff : R; bitpos: [24:21]; default: 0; + * Gap between ADC1 CH5 and average initcode + */ + uint32_t adc1_ch5_atten0_initcode_diff:4; + /** reserved_2_249 : R; bitpos: [31:25]; default: 0; + * reserved + */ + uint32_t reserved_2_249:7; }; uint32_t val; } efuse_rd_sys_part1_data7_reg_t; @@ -2090,123 +2170,6 @@ typedef union { uint32_t val; } efuse_conf_reg_t; -/** Group: EFUSE Configure Registers */ -/** Type of dac_conf register - * Controls the eFuse programming voltage. - */ -typedef union { - struct { - /** dac_clk_div : R/W; bitpos: [7:0]; default: 23; - * Controls the division factor of the rising clock of the programming voltage. - */ - uint32_t dac_clk_div:8; - /** dac_clk_pad_sel : R/W; bitpos: [8]; default: 0; - * Don't care. - */ - uint32_t dac_clk_pad_sel:1; - /** dac_num : R/W; bitpos: [16:9]; default: 255; - * Controls the rising period of the programming voltage. - */ - uint32_t dac_num:8; - /** oe_clr : R/W; bitpos: [17]; default: 0; - * Reduces the power supply of the programming voltage. - */ - uint32_t oe_clr:1; - uint32_t reserved_18:14; - }; - uint32_t val; -} efuse_dac_conf_reg_t; - -/** Type of rd_tim_conf register - * Configures read timing parameters. - */ -typedef union { - struct { - /** thr_a : R/W; bitpos: [7:0]; default: 1; - * Configures the read hold time. - */ - uint32_t thr_a:8; - /** trd : R/W; bitpos: [15:8]; default: 2; - * Configures the read time. - */ - uint32_t trd:8; - /** tsur_a : R/W; bitpos: [23:16]; default: 1; - * Configures the read setup time. - */ - uint32_t tsur_a:8; - /** read_init_num : R/W; bitpos: [31:24]; default: 22; - * Configures the waiting time of reading eFuse memory. - */ - uint32_t read_init_num:8; - }; - uint32_t val; -} efuse_rd_tim_conf_reg_t; - -/** Type of wr_tim_conf1 register - * Configurarion register 1 of eFuse programming timing parameters. - */ -typedef union { - struct { - /** tsup_a : R/W; bitpos: [7:0]; default: 1; - * Configures the programming setup time. - */ - uint32_t tsup_a:8; - /** pwr_on_num : R/W; bitpos: [23:8]; default: 12288; - * Configures the power up time for VDDQ. - */ - uint32_t pwr_on_num:16; - /** thp_a : R/W; bitpos: [31:24]; default: 1; - * Configures the programming hold time. - */ - uint32_t thp_a:8; - }; - uint32_t val; -} efuse_wr_tim_conf1_reg_t; - -/** Type of wr_tim_conf2 register - * Configurarion register 2 of eFuse programming timing parameters. - */ -typedef union { - struct { - /** pwr_off_num : R/W; bitpos: [15:0]; default: 400; - * Configures the power outage time for VDDQ. - */ - uint32_t pwr_off_num:16; - /** tpgm : R/W; bitpos: [31:16]; default: 200; - * Configures the active programming time. - */ - uint32_t tpgm:16; - }; - uint32_t val; -} efuse_wr_tim_conf2_reg_t; - -/** Type of wr_tim_conf0_rs_bypass register - * Configurarion register0 of eFuse programming time parameters and rs bypass - * operation. - */ -typedef union { - struct { - /** bypass_rs_correction : R/W; bitpos: [0]; default: 0; - * Set this bit to bypass reed solomon correction step. - */ - uint32_t bypass_rs_correction:1; - /** bypass_rs_blk_num : R/W; bitpos: [11:1]; default: 0; - * Configures block number of programming twice operation. - */ - uint32_t bypass_rs_blk_num:11; - /** update : WT; bitpos: [12]; default: 0; - * Set this bit to update multi-bit register signals. - */ - uint32_t update:1; - /** tpgm_inactive : R/W; bitpos: [20:13]; default: 1; - * Configures the inactive programming time. - */ - uint32_t tpgm_inactive:8; - uint32_t reserved_21:11; - }; - uint32_t val; -} efuse_wr_tim_conf0_rs_bypass_reg_t; - /** Group: EFUSE Status Registers */ /** Type of status register @@ -2355,6 +2318,124 @@ typedef union { } efuse_int_clr_reg_t; +/** Group: EFUSE Configure Registers */ +/** Type of dac_conf register + * Controls the eFuse programming voltage. + */ +typedef union { + struct { + /** dac_clk_div : R/W; bitpos: [7:0]; default: 23; + * Controls the division factor of the rising clock of the programming voltage. + */ + uint32_t dac_clk_div:8; + /** dac_clk_pad_sel : R/W; bitpos: [8]; default: 0; + * Don't care. + */ + uint32_t dac_clk_pad_sel:1; + /** dac_num : R/W; bitpos: [16:9]; default: 255; + * Controls the rising period of the programming voltage. + */ + uint32_t dac_num:8; + /** oe_clr : R/W; bitpos: [17]; default: 0; + * Reduces the power supply of the programming voltage. + */ + uint32_t oe_clr:1; + uint32_t reserved_18:14; + }; + uint32_t val; +} efuse_dac_conf_reg_t; + +/** Type of rd_tim_conf register + * Configures read timing parameters. + */ +typedef union { + struct { + /** thr_a : R/W; bitpos: [7:0]; default: 1; + * Configures the read hold time. + */ + uint32_t thr_a:8; + /** trd : R/W; bitpos: [15:8]; default: 2; + * Configures the read time. + */ + uint32_t trd:8; + /** tsur_a : R/W; bitpos: [23:16]; default: 1; + * Configures the read setup time. + */ + uint32_t tsur_a:8; + /** read_init_num : R/W; bitpos: [31:24]; default: 22; + * Configures the waiting time of reading eFuse memory. + */ + uint32_t read_init_num:8; + }; + uint32_t val; +} efuse_rd_tim_conf_reg_t; + +/** Type of wr_tim_conf1 register + * Configurarion register 1 of eFuse programming timing parameters. + */ +typedef union { + struct { + /** tsup_a : R/W; bitpos: [7:0]; default: 1; + * Configures the programming setup time. + */ + uint32_t tsup_a:8; + /** pwr_on_num : R/W; bitpos: [23:8]; default: 12288; + * Configures the power up time for VDDQ. + */ + uint32_t pwr_on_num:16; + /** thp_a : R/W; bitpos: [31:24]; default: 1; + * Configures the programming hold time. + */ + uint32_t thp_a:8; + }; + uint32_t val; +} efuse_wr_tim_conf1_reg_t; + +/** Type of wr_tim_conf2 register + * Configurarion register 2 of eFuse programming timing parameters. + */ +typedef union { + struct { + /** pwr_off_num : R/W; bitpos: [15:0]; default: 400; + * Configures the power outage time for VDDQ. + */ + uint32_t pwr_off_num:16; + /** tpgm : R/W; bitpos: [31:16]; default: 200; + * Configures the active programming time. + */ + uint32_t tpgm:16; + }; + uint32_t val; +} efuse_wr_tim_conf2_reg_t; + +/** Type of wr_tim_conf0_rs_bypass register + * Configurarion register0 of eFuse programming time parameters and rs bypass + * operation. + */ +typedef union { + struct { + /** bypass_rs_correction : R/W; bitpos: [0]; default: 0; + * Set this bit to bypass reed solomon correction step. + */ + uint32_t bypass_rs_correction:1; + /** bypass_rs_blk_num : R/W; bitpos: [11:1]; default: 0; + * Configures block number of programming twice operation. + */ + uint32_t bypass_rs_blk_num:11; + /** update : WT; bitpos: [12]; default: 0; + * Set this bit to update multi-bit register signals. + */ + uint32_t update:1; + /** tpgm_inactive : R/W; bitpos: [20:13]; default: 1; + * Configures the inactive programming time. + */ + uint32_t tpgm_inactive:8; + uint32_t reserved_21:11; + }; + uint32_t val; +} efuse_wr_tim_conf0_rs_bypass_reg_t; + + /** Group: EFUSE_APB2OTP Block0 Write Disable Data */ /** Type of apb2otp_wr_dis register * eFuse apb2otp block0 data register1. From 37b600124f427e7eec16d4678d1efeb139e5012e Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Mon, 30 Sep 2024 18:56:37 +0300 Subject: [PATCH 70/70] feat(efuse): Adds efuse ADC calib data for ESP32-C61 --- components/efuse/esp32c61/esp_efuse_table.c | 254 +++++++++++++++++- components/efuse/esp32c61/esp_efuse_table.csv | 30 ++- .../efuse/esp32c61/include/esp_efuse_table.h | 30 ++- .../soc/esp32c61/register/soc/efuse_reg.h | 164 ++++++++--- .../soc/esp32c61/register/soc/efuse_struct.h | 86 ++++-- 5 files changed, 513 insertions(+), 51 deletions(-) diff --git a/components/efuse/esp32c61/esp_efuse_table.c b/components/efuse/esp32c61/esp_efuse_table.c index 07784d930ee..4ff8c7c62fc 100644 --- a/components/efuse/esp32c61/esp_efuse_table.c +++ b/components/efuse/esp32c61/esp_efuse_table.c @@ -9,7 +9,7 @@ #include #include "esp_efuse_table.h" -// md5_digest_table 52aee23d9256003919a3d01945678355 +// md5_digest_table af9aaa79feb0970d90f35360a5113f03 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -235,6 +235,62 @@ static const esp_efuse_desc_t WR_DIS_OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK0, 21, 1}, // [] wr_dis of OPTIONAL_UNIQUE_ID, }; +static const esp_efuse_desc_t WR_DIS_TEMPERATURE_SENSOR[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of TEMPERATURE_SENSOR, +}; + +static const esp_efuse_desc_t WR_DIS_OCODE[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of OCODE, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INIT_CODE_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INIT_CODE_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INIT_CODE_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_AVE_INIT_CODE_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN0, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN1, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN2, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_HI_DOUT_ATTEN3, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF, +}; + +static const esp_efuse_desc_t WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK0, 21, 1}, // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF, +}; + static const esp_efuse_desc_t WR_DIS_BLOCK_USR_DATA[] = { {EFUSE_BLK0, 22, 1}, // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA, }; @@ -528,6 +584,62 @@ static const esp_efuse_desc_t OPTIONAL_UNIQUE_ID[] = { {EFUSE_BLK2, 0, 128}, // [] Optional unique 128-bit ID, }; +static const esp_efuse_desc_t TEMPERATURE_SENSOR[] = { + {EFUSE_BLK2, 128, 9}, // [] Temperature calibration data, +}; + +static const esp_efuse_desc_t OCODE[] = { + {EFUSE_BLK2, 137, 8}, // [] ADC OCode calibration, +}; + +static const esp_efuse_desc_t ADC1_AVE_INIT_CODE_ATTEN0[] = { + {EFUSE_BLK2, 145, 10}, // [] Average initcode of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_AVE_INIT_CODE_ATTEN1[] = { + {EFUSE_BLK2, 155, 10}, // [] Average initcode of ADC1 atten1, +}; + +static const esp_efuse_desc_t ADC1_AVE_INIT_CODE_ATTEN2[] = { + {EFUSE_BLK2, 165, 10}, // [] Average initcode of ADC1 atten2, +}; + +static const esp_efuse_desc_t ADC1_AVE_INIT_CODE_ATTEN3[] = { + {EFUSE_BLK2, 175, 10}, // [] Average initcode of ADC1 atten3, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN0[] = { + {EFUSE_BLK2, 185, 10}, // [] HI_DOUT of ADC1 atten0, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN1[] = { + {EFUSE_BLK2, 195, 10}, // [] HI_DOUT of ADC1 atten1, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN2[] = { + {EFUSE_BLK2, 205, 10}, // [] HI_DOUT of ADC1 atten2, +}; + +static const esp_efuse_desc_t ADC1_HI_DOUT_ATTEN3[] = { + {EFUSE_BLK2, 215, 10}, // [] HI_DOUT of ADC1 atten3, +}; + +static const esp_efuse_desc_t ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 225, 4}, // [] Gap between ADC1 CH0 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 229, 4}, // [] Gap between ADC1 CH1 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 233, 4}, // [] Gap between ADC1 CH2 and average initcode, +}; + +static const esp_efuse_desc_t ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + {EFUSE_BLK2, 237, 4}, // [] Gap between ADC1 CH3 and average initcode, +}; + static const esp_efuse_desc_t USER_DATA[] = { {EFUSE_BLK3, 0, 256}, // [BLOCK_USR_DATA] User data, }; @@ -843,6 +955,76 @@ const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[] = { + &WR_DIS_TEMPERATURE_SENSOR[0], // [] wr_dis of TEMPERATURE_SENSOR + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OCODE[] = { + &WR_DIS_OCODE[0], // [] wr_dis of OCODE + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN0[] = { + &WR_DIS_ADC1_AVE_INIT_CODE_ATTEN0[0], // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN1[] = { + &WR_DIS_ADC1_AVE_INIT_CODE_ATTEN1[0], // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN2[] = { + &WR_DIS_ADC1_AVE_INIT_CODE_ATTEN2[0], // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN3[] = { + &WR_DIS_ADC1_AVE_INIT_CODE_ATTEN3[0], // [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN0[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN1[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN2[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[] = { + &WR_DIS_ADC1_HI_DOUT_ATTEN3[0], // [] wr_dis of ADC1_HI_DOUT_ATTEN3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[] = { &WR_DIS_BLOCK_USR_DATA[0], // [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA NULL @@ -1208,6 +1390,76 @@ const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[] = { NULL }; +const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[] = { + &TEMPERATURE_SENSOR[0], // [] Temperature calibration data + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_OCODE[] = { + &OCODE[0], // [] ADC OCode calibration + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN0[] = { + &ADC1_AVE_INIT_CODE_ATTEN0[0], // [] Average initcode of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN1[] = { + &ADC1_AVE_INIT_CODE_ATTEN1[0], // [] Average initcode of ADC1 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN2[] = { + &ADC1_AVE_INIT_CODE_ATTEN2[0], // [] Average initcode of ADC1 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN3[] = { + &ADC1_AVE_INIT_CODE_ATTEN3[0], // [] Average initcode of ADC1 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[] = { + &ADC1_HI_DOUT_ATTEN0[0], // [] HI_DOUT of ADC1 atten0 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[] = { + &ADC1_HI_DOUT_ATTEN1[0], // [] HI_DOUT of ADC1 atten1 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[] = { + &ADC1_HI_DOUT_ATTEN2[0], // [] HI_DOUT of ADC1 atten2 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[] = { + &ADC1_HI_DOUT_ATTEN3[0], // [] HI_DOUT of ADC1 atten3 + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH0_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH0 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH1_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH1 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH2_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH2 and average initcode + NULL +}; + +const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[] = { + &ADC1_CH3_ATTEN0_INITCODE_DIFF[0], // [] Gap between ADC1 CH3 and average initcode + NULL +}; + const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[] = { &USER_DATA[0], // [BLOCK_USR_DATA] User data NULL diff --git a/components/efuse/esp32c61/esp_efuse_table.csv b/components/efuse/esp32c61/esp_efuse_table.csv index 271c86df89c..2a82ff95b51 100644 --- a/components/efuse/esp32c61/esp_efuse_table.csv +++ b/components/efuse/esp32c61/esp_efuse_table.csv @@ -9,7 +9,7 @@ # this will generate new source files, next rebuild all the sources. # !!!!!!!!!!! # -# This file was generated by regtools.py based on the efuses.yaml file with the version: e564f8042b56a475a7714bb28ecdadfa +# This file was generated by regtools.py based on the efuses.yaml file with the version: 8f05ff9d292b10d2360200fae1d15e8d WR_DIS, EFUSE_BLK0, 0, 32, [] Disable programming of individual eFuses WR_DIS.RD_DIS, EFUSE_BLK0, 0, 1, [] wr_dis of RD_DIS @@ -66,6 +66,20 @@ WR_DIS.TEMP, EFUSE_BLK0, 20, 1, [] wr_dis WR_DIS.PKG_VERSION, EFUSE_BLK0, 20, 1, [] wr_dis of PKG_VERSION WR_DIS.SYS_DATA_PART1, EFUSE_BLK0, 21, 1, [] wr_dis of BLOCK2 WR_DIS.OPTIONAL_UNIQUE_ID, EFUSE_BLK0, 21, 1, [] wr_dis of OPTIONAL_UNIQUE_ID +WR_DIS.TEMPERATURE_SENSOR, EFUSE_BLK0, 21, 1, [] wr_dis of TEMPERATURE_SENSOR +WR_DIS.OCODE, EFUSE_BLK0, 21, 1, [] wr_dis of OCODE +WR_DIS.ADC1_AVE_INIT_CODE_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN0 +WR_DIS.ADC1_AVE_INIT_CODE_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN1 +WR_DIS.ADC1_AVE_INIT_CODE_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN2 +WR_DIS.ADC1_AVE_INIT_CODE_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_AVE_INIT_CODE_ATTEN3 +WR_DIS.ADC1_HI_DOUT_ATTEN0, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN0 +WR_DIS.ADC1_HI_DOUT_ATTEN1, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN1 +WR_DIS.ADC1_HI_DOUT_ATTEN2, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN2 +WR_DIS.ADC1_HI_DOUT_ATTEN3, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_HI_DOUT_ATTEN3 +WR_DIS.ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH0_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH1_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH2_ATTEN0_INITCODE_DIFF +WR_DIS.ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK0, 21, 1, [] wr_dis of ADC1_CH3_ATTEN0_INITCODE_DIFF WR_DIS.BLOCK_USR_DATA, EFUSE_BLK0, 22, 1, [WR_DIS.USER_DATA] wr_dis of BLOCK_USR_DATA WR_DIS.CUSTOM_MAC, EFUSE_BLK0, 22, 1, [WR_DIS.MAC_CUSTOM WR_DIS.USER_DATA_MAC_CUSTOM] wr_dis of CUSTOM_MAC WR_DIS.BLOCK_KEY0, EFUSE_BLK0, 23, 1, [WR_DIS.KEY0] wr_dis of BLOCK_KEY0 @@ -143,6 +157,20 @@ PSRAM_VENDOR, EFUSE_BLK1, 86, 2, [] PSRAM TEMP, EFUSE_BLK1, 88, 2, [] Temperature PKG_VERSION, EFUSE_BLK1, 90, 3, [] Package version OPTIONAL_UNIQUE_ID, EFUSE_BLK2, 0, 128, [] Optional unique 128-bit ID +TEMPERATURE_SENSOR, EFUSE_BLK2, 128, 9, [] Temperature calibration data +OCODE, EFUSE_BLK2, 137, 8, [] ADC OCode calibration +ADC1_AVE_INIT_CODE_ATTEN0, EFUSE_BLK2, 145, 10, [] Average initcode of ADC1 atten0 +ADC1_AVE_INIT_CODE_ATTEN1, EFUSE_BLK2, 155, 10, [] Average initcode of ADC1 atten1 +ADC1_AVE_INIT_CODE_ATTEN2, EFUSE_BLK2, 165, 10, [] Average initcode of ADC1 atten2 +ADC1_AVE_INIT_CODE_ATTEN3, EFUSE_BLK2, 175, 10, [] Average initcode of ADC1 atten3 +ADC1_HI_DOUT_ATTEN0, EFUSE_BLK2, 185, 10, [] HI_DOUT of ADC1 atten0 +ADC1_HI_DOUT_ATTEN1, EFUSE_BLK2, 195, 10, [] HI_DOUT of ADC1 atten1 +ADC1_HI_DOUT_ATTEN2, EFUSE_BLK2, 205, 10, [] HI_DOUT of ADC1 atten2 +ADC1_HI_DOUT_ATTEN3, EFUSE_BLK2, 215, 10, [] HI_DOUT of ADC1 atten3 +ADC1_CH0_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 225, 4, [] Gap between ADC1 CH0 and average initcode +ADC1_CH1_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 229, 4, [] Gap between ADC1 CH1 and average initcode +ADC1_CH2_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 233, 4, [] Gap between ADC1 CH2 and average initcode +ADC1_CH3_ATTEN0_INITCODE_DIFF, EFUSE_BLK2, 237, 4, [] Gap between ADC1 CH3 and average initcode USER_DATA, EFUSE_BLK3, 0, 256, [BLOCK_USR_DATA] User data USER_DATA.MAC_CUSTOM, EFUSE_BLK3, 200, 48, [MAC_CUSTOM CUSTOM_MAC] Custom MAC KEY0, EFUSE_BLK4, 0, 256, [BLOCK_KEY0] Key0 or user data diff --git a/components/efuse/esp32c61/include/esp_efuse_table.h b/components/efuse/esp32c61/include/esp_efuse_table.h index 085c9223e28..40844a05810 100644 --- a/components/efuse/esp32c61/include/esp_efuse_table.h +++ b/components/efuse/esp32c61/include/esp_efuse_table.h @@ -10,7 +10,7 @@ extern "C" { #include "esp_efuse.h" -// md5_digest_table 52aee23d9256003919a3d01945678355 +// md5_digest_table af9aaa79feb0970d90f35360a5113f03 // This file was generated from the file esp_efuse_table.csv. DO NOT CHANGE THIS FILE MANUALLY. // If you want to change some fields, you need to change esp_efuse_table.csv file // then run `efuse_common_table` or `efuse_custom_table` command it will generate this file. @@ -79,6 +79,20 @@ extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMP[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_PKG_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_SYS_DATA_PART1[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_TEMPERATURE_SENSOR[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_OCODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_AVE_INIT_CODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_BLOCK_USR_DATA[]; #define ESP_EFUSE_WR_DIS_USER_DATA ESP_EFUSE_WR_DIS_BLOCK_USR_DATA extern const esp_efuse_desc_t* ESP_EFUSE_WR_DIS_CUSTOM_MAC[]; @@ -175,6 +189,20 @@ extern const esp_efuse_desc_t* ESP_EFUSE_PSRAM_VENDOR[]; extern const esp_efuse_desc_t* ESP_EFUSE_TEMP[]; extern const esp_efuse_desc_t* ESP_EFUSE_PKG_VERSION[]; extern const esp_efuse_desc_t* ESP_EFUSE_OPTIONAL_UNIQUE_ID[]; +extern const esp_efuse_desc_t* ESP_EFUSE_TEMPERATURE_SENSOR[]; +extern const esp_efuse_desc_t* ESP_EFUSE_OCODE[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_AVE_INIT_CODE_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN0[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN1[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN2[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_HI_DOUT_ATTEN3[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF[]; +extern const esp_efuse_desc_t* ESP_EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF[]; extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA[]; #define ESP_EFUSE_BLOCK_USR_DATA ESP_EFUSE_USER_DATA extern const esp_efuse_desc_t* ESP_EFUSE_USER_DATA_MAC_CUSTOM[]; diff --git a/components/soc/esp32c61/register/soc/efuse_reg.h b/components/soc/esp32c61/register/soc/efuse_reg.h index c1eac845a8e..fa1866d0239 100644 --- a/components/soc/esp32c61/register/soc/efuse_reg.h +++ b/components/soc/esp32c61/register/soc/efuse_reg.h @@ -557,13 +557,13 @@ extern "C" { #define EFUSE_MAC_1_M (EFUSE_MAC_1_V << EFUSE_MAC_1_S) #define EFUSE_MAC_1_V 0x0000FFFFU #define EFUSE_MAC_1_S 0 -/** EFUSE_C61_NO_EXTENTION : R; bitpos: [31:16]; default: 0; - * Reserved +/** EFUSE_RD_RESERVE_1_48 : RW; bitpos: [31:16]; default: 0; + * Reserved, it was created by set_missed_fields_in_regs func */ -#define EFUSE_C61_NO_EXTENTION 0x0000FFFFU -#define EFUSE_C61_NO_EXTENTION_M (EFUSE_C61_NO_EXTENTION_V << EFUSE_C61_NO_EXTENTION_S) -#define EFUSE_C61_NO_EXTENTION_V 0x0000FFFFU -#define EFUSE_C61_NO_EXTENTION_S 16 +#define EFUSE_RD_RESERVE_1_48 0x0000FFFFU +#define EFUSE_RD_RESERVE_1_48_M (EFUSE_RD_RESERVE_1_48_V << EFUSE_RD_RESERVE_1_48_S) +#define EFUSE_RD_RESERVE_1_48_V 0x0000FFFFU +#define EFUSE_RD_RESERVE_1_48_S 16 /** EFUSE_RD_MAC_SYS2_REG register * Represents rd_mac_sys @@ -756,49 +756,147 @@ extern "C" { * Represents rd_sys_part1_data4 */ #define EFUSE_RD_SYS_PART1_DATA4_REG (DR_REG_EFUSE0_BASE + 0x6c) -/** EFUSE_SYS_DATA_PART1_4 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_4 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_4_M (EFUSE_SYS_DATA_PART1_4_V << EFUSE_SYS_DATA_PART1_4_S) -#define EFUSE_SYS_DATA_PART1_4_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_4_S 0 +/** EFUSE_TEMPERATURE_SENSOR : R; bitpos: [8:0]; default: 0; + * Temperature calibration data + */ +#define EFUSE_TEMPERATURE_SENSOR 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_M (EFUSE_TEMPERATURE_SENSOR_V << EFUSE_TEMPERATURE_SENSOR_S) +#define EFUSE_TEMPERATURE_SENSOR_V 0x000001FFU +#define EFUSE_TEMPERATURE_SENSOR_S 0 +/** EFUSE_OCODE : R; bitpos: [16:9]; default: 0; + * ADC OCode calibration + */ +#define EFUSE_OCODE 0x000000FFU +#define EFUSE_OCODE_M (EFUSE_OCODE_V << EFUSE_OCODE_S) +#define EFUSE_OCODE_V 0x000000FFU +#define EFUSE_OCODE_S 9 +/** EFUSE_ADC1_AVE_INIT_CODE_ATTEN0 : R; bitpos: [26:17]; default: 0; + * Average initcode of ADC1 atten0 + */ +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN0 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN0_M (EFUSE_ADC1_AVE_INIT_CODE_ATTEN0_V << EFUSE_ADC1_AVE_INIT_CODE_ATTEN0_S) +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN0_V 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN0_S 17 +/** EFUSE_ADC1_AVE_INIT_CODE_ATTEN1 : R; bitpos: [31:27]; default: 0; + * Average initcode of ADC1 atten1 + */ +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1 0x0000001FU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_M (EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_V << EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_S) +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_V 0x0000001FU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_S 27 /** EFUSE_RD_SYS_PART1_DATA5_REG register * Represents rd_sys_part1_data5 */ #define EFUSE_RD_SYS_PART1_DATA5_REG (DR_REG_EFUSE0_BASE + 0x70) -/** EFUSE_SYS_DATA_PART1_5 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_5 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_M (EFUSE_SYS_DATA_PART1_5_V << EFUSE_SYS_DATA_PART1_5_S) -#define EFUSE_SYS_DATA_PART1_5_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_5_S 0 +/** EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1 : R; bitpos: [4:0]; default: 0; + * Average initcode of ADC1 atten1 + */ +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1 0x0000001FU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1_M (EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1_V << EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1_S) +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1_V 0x0000001FU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN1_1_S 0 +/** EFUSE_ADC1_AVE_INIT_CODE_ATTEN2 : R; bitpos: [14:5]; default: 0; + * Average initcode of ADC1 atten2 + */ +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN2 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN2_M (EFUSE_ADC1_AVE_INIT_CODE_ATTEN2_V << EFUSE_ADC1_AVE_INIT_CODE_ATTEN2_S) +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN2_S 5 +/** EFUSE_ADC1_AVE_INIT_CODE_ATTEN3 : R; bitpos: [24:15]; default: 0; + * Average initcode of ADC1 atten3 + */ +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN3 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN3_M (EFUSE_ADC1_AVE_INIT_CODE_ATTEN3_V << EFUSE_ADC1_AVE_INIT_CODE_ATTEN3_S) +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN3_V 0x000003FFU +#define EFUSE_ADC1_AVE_INIT_CODE_ATTEN3_S 15 +/** EFUSE_ADC1_HI_DOUT_ATTEN0 : R; bitpos: [31:25]; default: 0; + * HI_DOUT of ADC1 atten0 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN0 0x0000007FU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_M (EFUSE_ADC1_HI_DOUT_ATTEN0_V << EFUSE_ADC1_HI_DOUT_ATTEN0_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN0_V 0x0000007FU +#define EFUSE_ADC1_HI_DOUT_ATTEN0_S 25 /** EFUSE_RD_SYS_PART1_DATA6_REG register * Represents rd_sys_part1_data6 */ #define EFUSE_RD_SYS_PART1_DATA6_REG (DR_REG_EFUSE0_BASE + 0x74) -/** EFUSE_SYS_DATA_PART1_6 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. - */ -#define EFUSE_SYS_DATA_PART1_6 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_M (EFUSE_SYS_DATA_PART1_6_V << EFUSE_SYS_DATA_PART1_6_S) -#define EFUSE_SYS_DATA_PART1_6_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_6_S 0 +/** EFUSE_ADC1_HI_DOUT_ATTEN0_1 : R; bitpos: [2:0]; default: 0; + * HI_DOUT of ADC1 atten0 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1 0x00000007U +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_M (EFUSE_ADC1_HI_DOUT_ATTEN0_1_V << EFUSE_ADC1_HI_DOUT_ATTEN0_1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_V 0x00000007U +#define EFUSE_ADC1_HI_DOUT_ATTEN0_1_S 0 +/** EFUSE_ADC1_HI_DOUT_ATTEN1 : R; bitpos: [12:3]; default: 0; + * HI_DOUT of ADC1 atten1 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN1 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_M (EFUSE_ADC1_HI_DOUT_ATTEN1_V << EFUSE_ADC1_HI_DOUT_ATTEN1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN1_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN1_S 3 +/** EFUSE_ADC1_HI_DOUT_ATTEN2 : R; bitpos: [22:13]; default: 0; + * HI_DOUT of ADC1 atten2 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN2 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_M (EFUSE_ADC1_HI_DOUT_ATTEN2_V << EFUSE_ADC1_HI_DOUT_ATTEN2_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN2_V 0x000003FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN2_S 13 +/** EFUSE_ADC1_HI_DOUT_ATTEN3 : R; bitpos: [31:23]; default: 0; + * HI_DOUT of ADC1 atten3 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN3 0x000001FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_M (EFUSE_ADC1_HI_DOUT_ATTEN3_V << EFUSE_ADC1_HI_DOUT_ATTEN3_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_V 0x000001FFU +#define EFUSE_ADC1_HI_DOUT_ATTEN3_S 23 /** EFUSE_RD_SYS_PART1_DATA7_REG register * Represents rd_sys_part1_data7 */ #define EFUSE_RD_SYS_PART1_DATA7_REG (DR_REG_EFUSE0_BASE + 0x78) -/** EFUSE_SYS_DATA_PART1_7 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. +/** EFUSE_ADC1_HI_DOUT_ATTEN3_1 : R; bitpos: [0]; default: 0; + * HI_DOUT of ADC1 atten3 + */ +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1 (BIT(0)) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_M (EFUSE_ADC1_HI_DOUT_ATTEN3_1_V << EFUSE_ADC1_HI_DOUT_ATTEN3_1_S) +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_V 0x00000001U +#define EFUSE_ADC1_HI_DOUT_ATTEN3_1_S 0 +/** EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF : R; bitpos: [4:1]; default: 0; + * Gap between ADC1 CH0 and average initcode + */ +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH0_ATTEN0_INITCODE_DIFF_S 1 +/** EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF : R; bitpos: [8:5]; default: 0; + * Gap between ADC1 CH1 and average initcode + */ +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH1_ATTEN0_INITCODE_DIFF_S 5 +/** EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF : R; bitpos: [12:9]; default: 0; + * Gap between ADC1 CH2 and average initcode + */ +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH2_ATTEN0_INITCODE_DIFF_S 9 +/** EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF : R; bitpos: [16:13]; default: 0; + * Gap between ADC1 CH3 and average initcode + */ +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_M (EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V << EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S) +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_V 0x0000000FU +#define EFUSE_ADC1_CH3_ATTEN0_INITCODE_DIFF_S 13 +/** EFUSE_RESERVED_2_241 : R; bitpos: [31:17]; default: 0; + * reserved */ -#define EFUSE_SYS_DATA_PART1_7 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_M (EFUSE_SYS_DATA_PART1_7_V << EFUSE_SYS_DATA_PART1_7_S) -#define EFUSE_SYS_DATA_PART1_7_V 0xFFFFFFFFU -#define EFUSE_SYS_DATA_PART1_7_S 0 +#define EFUSE_RESERVED_2_241 0x00007FFFU +#define EFUSE_RESERVED_2_241_M (EFUSE_RESERVED_2_241_V << EFUSE_RESERVED_2_241_S) +#define EFUSE_RESERVED_2_241_V 0x00007FFFU +#define EFUSE_RESERVED_2_241_S 17 /** EFUSE_RD_USR_DATA0_REG register * Represents rd_usr_data0 diff --git a/components/soc/esp32c61/register/soc/efuse_struct.h b/components/soc/esp32c61/register/soc/efuse_struct.h index 1ae0eb37c39..291d8b45651 100644 --- a/components/soc/esp32c61/register/soc/efuse_struct.h +++ b/components/soc/esp32c61/register/soc/efuse_struct.h @@ -456,10 +456,10 @@ typedef union { * Represents MAC address. High 16-bit. */ uint32_t mac_1:16; - /** c61_no_extention : R; bitpos: [31:16]; default: 0; - * Reserved + /** rd_reserve_1_48 : RW; bitpos: [31:16]; default: 0; + * Reserved, it was created by set_missed_fields_in_regs func */ - uint32_t c61_no_extention:16; + uint32_t rd_reserve_1_48:16; }; uint32_t val; } efuse_rd_mac_sys1_reg_t; @@ -627,10 +627,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_4 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** temperature_sensor : R; bitpos: [8:0]; default: 0; + * Temperature calibration data + */ + uint32_t temperature_sensor:9; + /** ocode : R; bitpos: [16:9]; default: 0; + * ADC OCode calibration + */ + uint32_t ocode:8; + /** adc1_ave_init_code_atten0 : R; bitpos: [26:17]; default: 0; + * Average initcode of ADC1 atten0 + */ + uint32_t adc1_ave_init_code_atten0:10; + /** adc1_ave_init_code_atten1 : R; bitpos: [31:27]; default: 0; + * Average initcode of ADC1 atten1 */ - uint32_t sys_data_part1_4:32; + uint32_t adc1_ave_init_code_atten1:5; }; uint32_t val; } efuse_rd_sys_part1_data4_reg_t; @@ -640,10 +652,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_5 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_ave_init_code_atten1_1 : R; bitpos: [4:0]; default: 0; + * Average initcode of ADC1 atten1 */ - uint32_t sys_data_part1_5:32; + uint32_t adc1_ave_init_code_atten1_1:5; + /** adc1_ave_init_code_atten2 : R; bitpos: [14:5]; default: 0; + * Average initcode of ADC1 atten2 + */ + uint32_t adc1_ave_init_code_atten2:10; + /** adc1_ave_init_code_atten3 : R; bitpos: [24:15]; default: 0; + * Average initcode of ADC1 atten3 + */ + uint32_t adc1_ave_init_code_atten3:10; + /** adc1_hi_dout_atten0 : R; bitpos: [31:25]; default: 0; + * HI_DOUT of ADC1 atten0 + */ + uint32_t adc1_hi_dout_atten0:7; }; uint32_t val; } efuse_rd_sys_part1_data5_reg_t; @@ -653,10 +677,22 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_6 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_hi_dout_atten0_1 : R; bitpos: [2:0]; default: 0; + * HI_DOUT of ADC1 atten0 + */ + uint32_t adc1_hi_dout_atten0_1:3; + /** adc1_hi_dout_atten1 : R; bitpos: [12:3]; default: 0; + * HI_DOUT of ADC1 atten1 */ - uint32_t sys_data_part1_6:32; + uint32_t adc1_hi_dout_atten1:10; + /** adc1_hi_dout_atten2 : R; bitpos: [22:13]; default: 0; + * HI_DOUT of ADC1 atten2 + */ + uint32_t adc1_hi_dout_atten2:10; + /** adc1_hi_dout_atten3 : R; bitpos: [31:23]; default: 0; + * HI_DOUT of ADC1 atten3 + */ + uint32_t adc1_hi_dout_atten3:9; }; uint32_t val; } efuse_rd_sys_part1_data6_reg_t; @@ -666,10 +702,30 @@ typedef union { */ typedef union { struct { - /** sys_data_part1_7 : RO; bitpos: [31:0]; default: 0; - * Represents the zeroth 32-bit of first part of system data. + /** adc1_hi_dout_atten3_1 : R; bitpos: [0]; default: 0; + * HI_DOUT of ADC1 atten3 + */ + uint32_t adc1_hi_dout_atten3_1:1; + /** adc1_ch0_atten0_initcode_diff : R; bitpos: [4:1]; default: 0; + * Gap between ADC1 CH0 and average initcode + */ + uint32_t adc1_ch0_atten0_initcode_diff:4; + /** adc1_ch1_atten0_initcode_diff : R; bitpos: [8:5]; default: 0; + * Gap between ADC1 CH1 and average initcode + */ + uint32_t adc1_ch1_atten0_initcode_diff:4; + /** adc1_ch2_atten0_initcode_diff : R; bitpos: [12:9]; default: 0; + * Gap between ADC1 CH2 and average initcode + */ + uint32_t adc1_ch2_atten0_initcode_diff:4; + /** adc1_ch3_atten0_initcode_diff : R; bitpos: [16:13]; default: 0; + * Gap between ADC1 CH3 and average initcode + */ + uint32_t adc1_ch3_atten0_initcode_diff:4; + /** reserved_2_241 : R; bitpos: [31:17]; default: 0; + * reserved */ - uint32_t sys_data_part1_7:32; + uint32_t reserved_2_241:15; }; uint32_t val; } efuse_rd_sys_part1_data7_reg_t;