From a4710cc2061ef390b5cf0bde499a4f4b5780d484 Mon Sep 17 00:00:00 2001 From: Chen Chen Date: Fri, 12 Sep 2025 11:23:33 +0800 Subject: [PATCH] refactor(driver): remove redundant driver dependencies now the driver component only contains legacy code for i2c, twai and touch sensor --- .gitlab/CODEOWNERS | 1 - .../test_app_update/main/CMakeLists.txt | 2 +- .../test_apps/exception/main/CMakeLists.txt | 2 +- .../exception_no_except/main/CMakeLists.txt | 2 +- .../cxx/test_apps/general/main/CMakeLists.txt | 2 +- .../cxx/test_apps/rtti/main/CMakeLists.txt | 2 +- components/driver/CMakeLists.txt | 14 +- components/driver/deprecated/rmt_legacy.c | 1417 ----------------- .../test_driver_utils/CMakeLists.txt | 3 +- .../legacy_i2c_driver/main/CMakeLists.txt | 2 +- .../test_apps/legacy_twai/main/CMakeLists.txt | 8 +- .../{test_app_main.c => test_app_main.cpp} | 2 +- ...nteractive.c => test_twai_interactive.cpp} | 24 +- ...ai_loop_back.c => test_twai_loop_back.cpp} | 70 +- .../legacy_twai/sdkconfig.ci.iram_safe | 2 +- .../touch_sensor_v1/main/CMakeLists.txt | 2 +- .../touch_sensor_v2/main/CMakeLists.txt | 2 +- components/driver/twai/Kconfig.twai | 6 + components/driver/twai/include/driver/twai.h | 2 +- components/driver/twai/linker.lf | 7 +- components/driver/twai/twai.c | 10 +- .../test_apps/dvp/main/CMakeLists.txt | 1 + components/esp_driver_gptimer/src/gptimer.c | 2 +- .../i2s_multi_dev/main/CMakeLists.txt | 2 +- .../host_sdmmc/main/CMakeLists.txt | 2 +- .../host_sdmmc/main/idf_component.yml | 2 + .../sdio/main/CMakeLists.txt | 2 +- .../test_apps/master/main/CMakeLists.txt | 2 +- .../test_apps/slave/main/CMakeLists.txt | 2 +- .../usb_serial_jtag/main/CMakeLists.txt | 2 +- .../esp_event/test_apps/main/CMakeLists.txt | 2 +- .../rtc_power_modes/main/CMakeLists.txt | 2 +- .../test_apps/i80_lcd/main/CMakeLists.txt | 2 +- .../test_apps/parlio_lcd/main/CMakeLists.txt | 2 +- .../test_apps/rgb_lcd/main/CMakeLists.txt | 2 +- .../test_apps/newlib/main/CMakeLists.txt | 2 +- .../esp_mm/test_apps/mm/main/CMakeLists.txt | 2 +- .../test_app_vfs_l2tap/main/CMakeLists.txt | 2 +- .../test_apps/esp_pm/main/CMakeLists.txt | 2 +- .../test_apps/psram/main/CMakeLists.txt | 2 +- .../test_apps/sdcard/main/CMakeLists.txt | 2 +- .../test_apps/freertos/kernel/CMakeLists.txt | 2 +- .../pms_and_cpu_intr/CMakeLists.txt | 1 + components/openthread/CMakeLists.txt | 2 +- .../test_apps/esp_flash/main/CMakeLists.txt | 3 +- .../flash_suspend/main/CMakeLists.txt | 2 +- .../test_apps/mspi_test/main/CMakeLists.txt | 2 +- components/ulp/CMakeLists.txt | 2 +- .../lp_core_basic_tests/main/CMakeLists.txt | 1 + .../test_apps/ulp_riscv/main/CMakeLists.txt | 2 +- .../release-6.x/6.0/peripherals.rst | 31 + .../release-5.x/5.0/build-system.rst | 2 +- .../release-6.x/6.0/build-system.rst | 2 +- .../release-6.x/6.0/peripherals.rst | 31 + .../cte_config/CMakeLists.txt | 5 +- .../camera/dvp_spi_lcd/main/CMakeLists.txt | 3 +- .../i2s_es7210_tdm/main/idf_component.yml | 2 +- .../main/idf_component.yml | 2 +- .../lp_core/gpio_wakeup/main/CMakeLists.txt | 2 +- .../ulp/ulp_riscv/touch/main/CMakeLists.txt | 1 + .../HA_on_off_light/main/idf_component.yml | 2 +- tools/ci/check_copyright_ignore.txt | 1 - .../peripherals/.build-test-rules.yml | 8 - .../peripherals/i2c_wifi/CMakeLists.txt | 6 - .../test_apps/peripherals/i2c_wifi/README.md | 161 -- .../peripherals/i2c_wifi/main/CMakeLists.txt | 2 - .../i2c_wifi/main/Kconfig.projbuild | 89 -- .../peripherals/i2c_wifi/main/i2c_wifi_main.c | 247 --- .../peripherals/i2c_wifi/pytest_i2c_wifi.py | 13 - .../system/cxx_build_test/main/CMakeLists.txt | 6 +- .../system/cxx_build_test/main/test_twai.cpp | 15 - 71 files changed, 189 insertions(+), 2080 deletions(-) delete mode 100644 components/driver/deprecated/rmt_legacy.c rename components/driver/test_apps/legacy_twai/main/{test_app_main.c => test_app_main.cpp} (97%) rename components/driver/test_apps/legacy_twai/main/{test_twai_interactive.c => test_twai_interactive.cpp} (84%) rename components/driver/test_apps/legacy_twai/main/{test_twai_loop_back.c => test_twai_loop_back.cpp} (82%) delete mode 100644 tools/test_apps/peripherals/.build-test-rules.yml delete mode 100644 tools/test_apps/peripherals/i2c_wifi/CMakeLists.txt delete mode 100644 tools/test_apps/peripherals/i2c_wifi/README.md delete mode 100644 tools/test_apps/peripherals/i2c_wifi/main/CMakeLists.txt delete mode 100644 tools/test_apps/peripherals/i2c_wifi/main/Kconfig.projbuild delete mode 100644 tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c delete mode 100644 tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py delete mode 100644 tools/test_apps/system/cxx_build_test/main/test_twai.cpp diff --git a/.gitlab/CODEOWNERS b/.gitlab/CODEOWNERS index fe66ae792c..410f75ae86 100644 --- a/.gitlab/CODEOWNERS +++ b/.gitlab/CODEOWNERS @@ -231,7 +231,6 @@ /tools/test_apps/components/test_utils/ @esp-idf-codeowners/peripherals @esp-idf-codeowners/system /tools/test_apps/configs/ @esp-idf-codeowners/system /tools/test_apps/linux_compatible/ @esp-idf-codeowners/system -/tools/test_apps/peripherals/ @esp-idf-codeowners/peripherals /tools/test_apps/phy/ @esp-idf-codeowners/bluetooth @esp-idf-codeowners/wifi @esp-idf-codeowners/ieee802154 /tools/test_apps/protocols/ @esp-idf-codeowners/network @esp-idf-codeowners/app-utilities /tools/test_apps/security/ @esp-idf-codeowners/security diff --git a/components/app_update/test_apps/test_app_update/main/CMakeLists.txt b/components/app_update/test_apps/test_app_update/main/CMakeLists.txt index b029b0e3a1..9098a7f947 100644 --- a/components/app_update/test_apps/test_app_update/main/CMakeLists.txt +++ b/components/app_update/test_apps/test_app_update/main/CMakeLists.txt @@ -7,7 +7,7 @@ idf_component_register( app_update bootloader_support nvs_flash - driver + esp_driver_gpio spi_flash esp_psram efuse diff --git a/components/cxx/test_apps/exception/main/CMakeLists.txt b/components/cxx/test_apps/exception/main/CMakeLists.txt index 526e9b5439..d142e9824e 100644 --- a/components/cxx/test_apps/exception/main/CMakeLists.txt +++ b/components/cxx/test_apps/exception/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "test_exception.cpp" - PRIV_REQUIRES unity driver) + PRIV_REQUIRES unity) diff --git a/components/cxx/test_apps/exception_no_except/main/CMakeLists.txt b/components/cxx/test_apps/exception_no_except/main/CMakeLists.txt index fd5da60266..d7eba39513 100644 --- a/components/cxx/test_apps/exception_no_except/main/CMakeLists.txt +++ b/components/cxx/test_apps/exception_no_except/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "test_exception_no_except.cpp" - PRIV_REQUIRES unity driver) + PRIV_REQUIRES unity) diff --git a/components/cxx/test_apps/general/main/CMakeLists.txt b/components/cxx/test_apps/general/main/CMakeLists.txt index 20c201549d..1542f7315b 100644 --- a/components/cxx/test_apps/general/main/CMakeLists.txt +++ b/components/cxx/test_apps/general/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "test_cxx_general.cpp" - PRIV_REQUIRES unity driver esp_timer) + PRIV_REQUIRES unity esp_timer) diff --git a/components/cxx/test_apps/rtti/main/CMakeLists.txt b/components/cxx/test_apps/rtti/main/CMakeLists.txt index fef050f7a7..b8b0e8a14e 100644 --- a/components/cxx/test_apps/rtti/main/CMakeLists.txt +++ b/components/cxx/test_apps/rtti/main/CMakeLists.txt @@ -1,2 +1,2 @@ idf_component_register(SRCS "test_rtti.cpp" - PRIV_REQUIRES unity driver) + PRIV_REQUIRES unity) diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 988279625a..8f222aeecf 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -8,8 +8,7 @@ endif() set(srcs) # Always included headers -set(includes "deprecated" - "i2c/include" +set(includes "i2c/include" "touch_sensor/include" "twai/include") @@ -45,15 +44,8 @@ else() # (REQUIRES cannot hide soc headers, since many arguments in the driver headers are chip-dependent) idf_component_register(SRCS "${srcs}" INCLUDE_DIRS ${includes} - PRIV_REQUIRES efuse esp_timer esp_mm - REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support - # for backward compatibility, the driver component needs to - # have a public dependency on other "esp_driver_foo" components - esp_driver_gpio esp_driver_pcnt esp_driver_gptimer esp_driver_spi esp_driver_mcpwm - esp_driver_ana_cmpr esp_driver_i2s esp_driver_sdmmc esp_driver_sdspi esp_driver_sdio - esp_driver_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm esp_driver_i2c - esp_driver_uart esp_driver_ledc esp_driver_parlio esp_driver_usb_serial_jtag - esp_driver_twai + PRIV_REQUIRES esp_timer esp_mm esp_driver_gpio esp_ringbuf esp_pm + REQUIRES freertos soc hal esp_hw_support esp_hal_i2c LDFRAGMENTS ${ldfragments} ) endif() diff --git a/components/driver/deprecated/rmt_legacy.c b/components/driver/deprecated/rmt_legacy.c deleted file mode 100644 index a88898e685..0000000000 --- a/components/driver/deprecated/rmt_legacy.c +++ /dev/null @@ -1,1417 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Apache-2.0 - */ -#include -#include -#include -#include -#include "esp_compiler.h" -#include "esp_intr_alloc.h" -#include "esp_log.h" -#include "esp_check.h" -#include "driver/gpio.h" -#include "esp_private/esp_clk_tree_common.h" -#include "esp_private/periph_ctrl.h" -#include "esp_private/gpio.h" -#include "driver/rmt_types_legacy.h" -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "freertos/semphr.h" -#include "freertos/ringbuf.h" -#include "soc/soc_caps.h" -#include "soc/soc_memory_layout.h" -#include "soc/rmt_periph.h" -#include "soc/rmt_struct.h" -#include "esp_clk_tree.h" -#include "hal/rmt_hal.h" -#include "hal/rmt_ll.h" -#include "hal/gpio_hal.h" -#include "esp_rom_gpio.h" -#include "esp_compiler.h" - -#define RMT_CHANNEL_ERROR_STR "RMT CHANNEL ERR" -#define RMT_ADDR_ERROR_STR "RMT ADDRESS ERR" -#define RMT_MEM_CNT_ERROR_STR "RMT MEM BLOCK NUM ERR" -#define RMT_CARRIER_ERROR_STR "RMT CARRIER LEVEL ERR" -#define RMT_MEM_OWNER_ERROR_STR "RMT MEM OWNER_ERR" -#define RMT_BASECLK_ERROR_STR "RMT BASECLK ERR" -#define RMT_WR_MEM_OVF_ERROR_STR "RMT WR MEM OVERFLOW" -#define RMT_GPIO_ERROR_STR "RMT GPIO ERROR" -#define RMT_MODE_ERROR_STR "RMT MODE ERROR" -#define RMT_CLK_DIV_ERROR_STR "RMT CLK DIV ERR" -#define RMT_DRIVER_ERROR_STR "RMT DRIVER ERR" -#define RMT_DRIVER_LENGTH_ERROR_STR "RMT PARAM LEN ERROR" -#define RMT_PSRAM_BUFFER_WARN_STR "Using buffer allocated from psram" -#define RMT_TRANSLATOR_NULL_STR "RMT translator is null" -#define RMT_TRANSLATOR_UNINIT_STR "RMT translator not init" -#define RMT_PARAM_ERR_STR "RMT param error" - -static const char *TAG = "rmt(legacy)"; - -// Spinlock for protecting concurrent register-level access only -#define RMT_ENTER_CRITICAL() portENTER_CRITICAL_SAFE(&(rmt_contex.rmt_spinlock)) -#define RMT_EXIT_CRITICAL() portEXIT_CRITICAL_SAFE(&(rmt_contex.rmt_spinlock)) - -#define RMT_RX_CHANNEL_ENCODING_START (SOC_RMT_CHANNELS_PER_GROUP-SOC_RMT_TX_CANDIDATES_PER_GROUP) -#define RMT_TX_CHANNEL_ENCODING_END (SOC_RMT_TX_CANDIDATES_PER_GROUP-1) - -#define RMT_IS_RX_CHANNEL(channel) ((channel) >= RMT_RX_CHANNEL_ENCODING_START) -#define RMT_IS_TX_CHANNEL(channel) ((channel) <= RMT_TX_CHANNEL_ENCODING_END) -#define RMT_DECODE_RX_CHANNEL(encode_chan) ((encode_chan - RMT_RX_CHANNEL_ENCODING_START)) -#define RMT_ENCODE_RX_CHANNEL(decode_chan) ((decode_chan + RMT_RX_CHANNEL_ENCODING_START)) - -#if SOC_PERIPH_CLK_CTRL_SHARED -#define RMT_CLOCK_SRC_ATOMIC() PERIPH_RCC_ATOMIC() -#else -#define RMT_CLOCK_SRC_ATOMIC() -#endif - -#if !SOC_RCC_IS_INDEPENDENT -#define RMT_RCC_ATOMIC() PERIPH_RCC_ATOMIC() -#else -#define RMT_RCC_ATOMIC() -#endif - -typedef struct { - rmt_hal_context_t hal; - _lock_t rmt_driver_isr_lock; - portMUX_TYPE rmt_spinlock; // Mutex lock for protecting concurrent register/unregister of RMT channels' ISR - rmt_isr_handle_t rmt_driver_intr_handle; - rmt_tx_end_callback_t rmt_tx_end_callback;// Event called when transmission is ended - uint8_t rmt_driver_channels; // Bitmask of installed drivers' channels, used to protect concurrent register/unregister of RMT channels' ISR - bool rmt_module_enabled; - uint32_t synchro_channel_mask; // Bitmap of channels already added in the synchronous group -} rmt_contex_t; - -typedef struct { - size_t tx_offset; - size_t tx_len_rem; - size_t tx_sub_len; - bool translator; - bool wait_done; //Mark whether wait tx done. - bool loop_autostop; // mark whether loop auto-stop is enabled - rmt_channel_t channel; - const rmt_item32_t *tx_data; - SemaphoreHandle_t tx_sem; -#if CONFIG_SPIRAM_USE_MALLOC - int intr_alloc_flags; - StaticSemaphore_t tx_sem_buffer; -#endif - rmt_item32_t *tx_buf; - RingbufHandle_t rx_buf; -#if SOC_RMT_SUPPORT_RX_PINGPONG - rmt_item32_t *rx_item_buf; - uint32_t rx_item_buf_size; - uint32_t rx_item_len; - int rx_item_start_idx; -#endif - sample_to_rmt_t sample_to_rmt; - void *tx_context; - size_t sample_size_remain; - const uint8_t *sample_cur; -} rmt_obj_t; - -static rmt_contex_t rmt_contex = { - .hal.regs = &RMT, - .rmt_spinlock = portMUX_INITIALIZER_UNLOCKED, - .rmt_driver_intr_handle = NULL, - .rmt_tx_end_callback = { - .function = NULL, - }, - .rmt_driver_channels = 0, - .rmt_module_enabled = false, - .synchro_channel_mask = 0 -}; - -static rmt_obj_t *p_rmt_obj[RMT_CHANNEL_MAX] = {0}; - -#if SOC_RMT_CHANNEL_CLK_INDEPENDENT -static uint32_t s_rmt_source_clock_hz[RMT_CHANNEL_MAX]; -#else -static uint32_t s_rmt_source_clock_hz; -#endif - -// RMTMEM address is declared in .peripherals.ld -extern rmt_mem_t RMTMEM; - -//Enable RMT module -static void rmt_module_enable(void) -{ - RMT_ENTER_CRITICAL(); - if (rmt_contex.rmt_module_enabled == false) { - RMT_RCC_ATOMIC() { - rmt_ll_enable_bus_clock(0, true); - rmt_ll_reset_register(0); - } - rmt_ll_mem_power_by_pmu(rmt_contex.hal.regs); - rmt_contex.rmt_module_enabled = true; - } - RMT_EXIT_CRITICAL(); -} - -//Disable RMT module -static void rmt_module_disable(void) -{ - RMT_ENTER_CRITICAL(); - if (rmt_contex.rmt_module_enabled == true) { - rmt_ll_mem_force_low_power(rmt_contex.hal.regs); - RMT_RCC_ATOMIC() { - rmt_ll_enable_bus_clock(0, false); - } - rmt_contex.rmt_module_enabled = false; - } - RMT_EXIT_CRITICAL(); -} - -esp_err_t rmt_set_clk_div(rmt_channel_t channel, uint8_t div_cnt) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - rmt_ll_rx_set_channel_clock_div(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), div_cnt); - } else { - rmt_ll_tx_set_channel_clock_div(rmt_contex.hal.regs, channel, div_cnt); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_clk_div(rmt_channel_t channel, uint8_t *div_cnt) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(div_cnt, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - *div_cnt = (uint8_t)rmt_ll_rx_get_channel_clock_div(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - } else { - *div_cnt = (uint8_t)rmt_ll_tx_get_channel_clock_div(rmt_contex.hal.regs, channel); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_rx_idle_thresh(rmt_channel_t channel, uint16_t thresh) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_set_idle_thres(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), thresh); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_rx_idle_thresh(rmt_channel_t channel, uint16_t *thresh) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(thresh, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - RMT_ENTER_CRITICAL(); - *thresh = (uint16_t)rmt_ll_rx_get_idle_thres(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_mem_block_num(rmt_channel_t channel, uint8_t rmt_mem_num) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(rmt_mem_num <= RMT_CHANNEL_MAX - channel, ESP_ERR_INVALID_ARG, TAG, RMT_MEM_CNT_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - rmt_ll_rx_set_mem_blocks(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), rmt_mem_num); - } else { - rmt_ll_tx_set_mem_blocks(rmt_contex.hal.regs, channel, rmt_mem_num); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_mem_block_num(rmt_channel_t channel, uint8_t *rmt_mem_num) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(rmt_mem_num, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - *rmt_mem_num = (uint8_t)rmt_ll_rx_get_mem_blocks(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - } else { - *rmt_mem_num = (uint8_t)rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_tx_carrier(rmt_channel_t channel, bool carrier_en, uint16_t high_level, uint16_t low_level, - rmt_carrier_level_t carrier_level) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(carrier_level < RMT_CARRIER_LEVEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CARRIER_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_set_carrier_high_low_ticks(rmt_contex.hal.regs, channel, high_level, low_level); - rmt_ll_tx_set_carrier_level(rmt_contex.hal.regs, channel, carrier_level); - rmt_ll_tx_enable_carrier_modulation(rmt_contex.hal.regs, channel, carrier_en); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_mem_pd(rmt_channel_t channel, bool pd_en) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (pd_en) { - rmt_ll_mem_force_low_power(rmt_contex.hal.regs); - } else { - rmt_ll_mem_power_by_pmu(rmt_contex.hal.regs); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_mem_pd(rmt_channel_t channel, bool *pd_en) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - *pd_en = rmt_ll_is_mem_force_powered_down(rmt_contex.hal.regs); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_tx_start(rmt_channel_t channel, bool tx_idx_rst) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (tx_idx_rst) { - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); - } - rmt_ll_clear_interrupt_status(rmt_contex.hal.regs, RMT_LL_EVENT_TX_DONE(channel)); - // enable tx end interrupt in non-loop mode - if (!rmt_ll_tx_is_loop_enabled(rmt_contex.hal.regs, channel)) { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_DONE(channel), true); - } else { -#if SOC_RMT_SUPPORT_TX_LOOP_COUNT - rmt_ll_tx_reset_loop_count(rmt_contex.hal.regs, channel); - rmt_ll_tx_enable_loop_count(rmt_contex.hal.regs, channel, true); - rmt_ll_clear_interrupt_status(rmt_contex.hal.regs, RMT_LL_EVENT_TX_LOOP_END(channel)); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_LOOP_END(channel), true); -#endif - } - rmt_ll_tx_start(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_tx_stop(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); -#if SOC_RMT_SUPPORT_ASYNC_STOP - rmt_ll_tx_stop(rmt_contex.hal.regs, channel); -#else - // write ending marker to stop the TX channel - RMTMEM.chan[channel].data32[0].val = 0; -#endif - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -#if SOC_RMT_SUPPORT_RX_PINGPONG -esp_err_t rmt_set_rx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - if (en) { - uint32_t item_block_len = rmt_ll_rx_get_mem_blocks(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)) * RMT_MEM_ITEM_NUM; - ESP_RETURN_ON_FALSE(evt_thresh <= item_block_len, ESP_ERR_INVALID_ARG, TAG, "RMT EVT THRESH ERR"); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_set_limit(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), evt_thresh); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_THRES(RMT_DECODE_RX_CHANNEL(channel)), true); - RMT_EXIT_CRITICAL(); - } else { - RMT_ENTER_CRITICAL(); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_THRES(RMT_DECODE_RX_CHANNEL(channel)), false); - RMT_EXIT_CRITICAL(); - } - return ESP_OK; -} -#endif - -esp_err_t rmt_rx_start(rmt_channel_t channel, bool rx_idx_rst) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_enable(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), false); - if (rx_idx_rst) { - rmt_ll_rx_reset_pointer(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - } - rmt_ll_clear_interrupt_status(rmt_contex.hal.regs, RMT_LL_EVENT_RX_DONE(RMT_DECODE_RX_CHANNEL(channel))); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_DONE(RMT_DECODE_RX_CHANNEL(channel)), true); - -#if SOC_RMT_SUPPORT_RX_PINGPONG - const uint32_t item_block_len = rmt_ll_rx_get_mem_blocks(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)) * RMT_MEM_ITEM_NUM; - p_rmt_obj[channel]->rx_item_start_idx = 0; - p_rmt_obj[channel]->rx_item_len = 0; - rmt_set_rx_thr_intr_en(channel, true, item_block_len / 2); -#endif - - rmt_ll_rx_enable(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), true); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_rx_stop(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_DONE(RMT_DECODE_RX_CHANNEL(channel)), false); - rmt_ll_rx_enable(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), false); - rmt_ll_rx_reset_pointer(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); -#if SOC_RMT_SUPPORT_RX_PINGPONG - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_THRES(RMT_DECODE_RX_CHANNEL(channel)), false); -#endif - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_tx_memory_reset(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_rx_memory_reset(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_reset_pointer(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_memory_owner(rmt_channel_t channel, rmt_mem_owner_t owner) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(owner < RMT_MEM_OWNER_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_MEM_OWNER_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_set_mem_owner(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), owner); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_memory_owner(rmt_channel_t channel, rmt_mem_owner_t *owner) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(owner, ESP_ERR_INVALID_ARG, TAG, RMT_MEM_OWNER_ERROR_STR); - RMT_ENTER_CRITICAL(); - *owner = (rmt_mem_owner_t)rmt_ll_rx_get_mem_owner(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_tx_loop_mode(rmt_channel_t channel, bool loop_en) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_enable_loop(rmt_contex.hal.regs, channel, loop_en); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_tx_loop_mode(rmt_channel_t channel, bool *loop_en) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - *loop_en = rmt_ll_tx_is_loop_enabled(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_rx_filter(rmt_channel_t channel, bool rx_filter_en, uint8_t thresh) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_rx_enable_filter(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), rx_filter_en); - rmt_ll_rx_set_filter_thres(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel), thresh); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_source_clk(rmt_channel_t channel, rmt_source_clk_t base_clk) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)base_clk, true)); - // `rmt_clock_source_t` and `rmt_source_clk_t` are binary compatible, as the underlying enum entries come from the same `soc_module_clk_t` - RMT_CLOCK_SRC_ATOMIC() { - rmt_ll_set_group_clock_src(rmt_contex.hal.regs, channel, (rmt_clock_source_t)base_clk, 1, 0, 0); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_source_clk(rmt_channel_t channel, rmt_source_clk_t *src_clk) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - // `rmt_clock_source_t` and `rmt_source_clk_t` are binary compatible, as the underlying enum entries come from the same `soc_module_clk_t` - *src_clk = (rmt_source_clk_t)rmt_ll_get_group_clock_src(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_idle_level(rmt_channel_t channel, bool idle_out_en, rmt_idle_level_t level) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(level < RMT_IDLE_LEVEL_MAX, ESP_ERR_INVALID_ARG, TAG, "RMT IDLE LEVEL ERR"); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_fix_idle_level(rmt_contex.hal.regs, channel, level, idle_out_en); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_idle_level(rmt_channel_t channel, bool *idle_out_en, rmt_idle_level_t *level) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - *idle_out_en = rmt_ll_tx_is_idle_enabled(rmt_contex.hal.regs, channel); - *level = rmt_ll_tx_get_idle_level(rmt_contex.hal.regs, channel); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_get_status(rmt_channel_t channel, uint32_t *status) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - *status = rmt_ll_rx_get_status_word(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - } else { - *status = rmt_ll_tx_get_status_word(rmt_contex.hal.regs, channel); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_rx_intr_en(rmt_channel_t channel, bool en) -{ - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel) && channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_DONE(RMT_DECODE_RX_CHANNEL(channel)), en); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_err_intr_en(rmt_channel_t channel, bool en) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - if (RMT_IS_RX_CHANNEL(channel)) { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_ERROR(RMT_DECODE_RX_CHANNEL(channel)), en); - } else { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_ERROR(channel), en); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_tx_intr_en(rmt_channel_t channel, bool en) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_DONE(channel), en); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_set_tx_thr_intr_en(rmt_channel_t channel, bool en, uint16_t evt_thresh) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - if (en) { - uint32_t item_block_len = rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel) * RMT_MEM_ITEM_NUM; - ESP_RETURN_ON_FALSE(evt_thresh <= item_block_len, ESP_ERR_INVALID_ARG, TAG, "RMT EVT THRESH ERR"); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_set_limit(rmt_contex.hal.regs, channel, evt_thresh); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_THRES(channel), true); - RMT_EXIT_CRITICAL(); - } else { - RMT_ENTER_CRITICAL(); - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_THRES(channel), false); - RMT_EXIT_CRITICAL(); - } - return ESP_OK; -} - -esp_err_t rmt_set_gpio(rmt_channel_t channel, rmt_mode_t mode, gpio_num_t gpio_num, bool invert_signal) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(mode < RMT_MODE_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_MODE_ERROR_STR); - ESP_RETURN_ON_FALSE(((GPIO_IS_VALID_GPIO(gpio_num) && (mode == RMT_MODE_RX)) || - (GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) && (mode == RMT_MODE_TX))), ESP_ERR_INVALID_ARG, TAG, RMT_GPIO_ERROR_STR); - - gpio_func_sel(gpio_num, PIN_FUNC_GPIO); - if (mode == RMT_MODE_TX) { - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - gpio_set_direction(gpio_num, GPIO_MODE_OUTPUT); - esp_rom_gpio_connect_out_signal(gpio_num, rmt_periph_signals.groups[0].channels[channel].tx_sig, invert_signal, 0); - } else { - ESP_RETURN_ON_FALSE(RMT_IS_RX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - gpio_set_direction(gpio_num, GPIO_MODE_INPUT); - esp_rom_gpio_connect_in_signal(gpio_num, rmt_periph_signals.groups[0].channels[channel].rx_sig, invert_signal); - } - return ESP_OK; -} - -static bool rmt_is_channel_number_valid(rmt_channel_t channel, uint8_t mode) -{ - // RX mode - if (mode == RMT_MODE_RX) { - return RMT_IS_RX_CHANNEL(channel) && (channel < RMT_CHANNEL_MAX); - } - // TX mode - return (channel >= 0) && RMT_IS_TX_CHANNEL(channel); -} - -static esp_err_t rmt_internal_config(rmt_dev_t *dev, const rmt_config_t *rmt_param) -{ - uint8_t mode = rmt_param->rmt_mode; - uint8_t channel = rmt_param->channel; - uint8_t gpio_num = rmt_param->gpio_num; - uint8_t mem_cnt = rmt_param->mem_block_num; - uint8_t clk_div = rmt_param->clk_div; - uint32_t carrier_freq_hz = rmt_param->tx_config.carrier_freq_hz; - bool carrier_en = rmt_param->tx_config.carrier_en; - uint32_t rmt_source_clk_hz; - rmt_clock_source_t clk_src = RMT_BASECLK_DEFAULT; - - ESP_RETURN_ON_FALSE(rmt_is_channel_number_valid(channel, mode), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(mem_cnt + channel <= SOC_RMT_CHANNELS_PER_GROUP && mem_cnt > 0, ESP_ERR_INVALID_ARG, TAG, RMT_MEM_CNT_ERROR_STR); - ESP_RETURN_ON_FALSE(clk_div > 0, ESP_ERR_INVALID_ARG, TAG, RMT_CLK_DIV_ERROR_STR); - - if (mode == RMT_MODE_TX) { - ESP_RETURN_ON_FALSE(!carrier_en || carrier_freq_hz > 0, ESP_ERR_INVALID_ARG, TAG, "RMT carrier frequency can't be zero"); - } - - RMT_ENTER_CRITICAL(); - rmt_ll_enable_mem_access_nonfifo(dev, true); - - if (rmt_param->flags & RMT_CHANNEL_FLAGS_AWARE_DFS) { -#if SOC_RMT_SUPPORT_XTAL - // clock src: XTAL_CLK - clk_src = RMT_BASECLK_XTAL; -#elif SOC_RMT_SUPPORT_REF_TICK - // clock src: REF_CLK - clk_src = RMT_BASECLK_REF; -#else -#error "No clock source is aware of DFS" -#endif - } - esp_clk_tree_src_get_freq_hz((soc_module_clk_t)clk_src, ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &rmt_source_clk_hz); - ESP_ERROR_CHECK(esp_clk_tree_enable_src((soc_module_clk_t)clk_src, true)); - RMT_CLOCK_SRC_ATOMIC() { - rmt_ll_set_group_clock_src(dev, channel, clk_src, 1, 0, 0); - rmt_ll_enable_group_clock(dev, true); - } - RMT_EXIT_CRITICAL(); - -#if SOC_RMT_CHANNEL_CLK_INDEPENDENT - s_rmt_source_clock_hz[channel] = rmt_source_clk_hz; -#else - if (s_rmt_source_clock_hz && rmt_source_clk_hz != s_rmt_source_clock_hz) { - ESP_LOGW(TAG, "RMT clock source has been configured to %"PRIu32" by other channel, now reconfigure it to %"PRIu32, s_rmt_source_clock_hz, rmt_source_clk_hz); - } - s_rmt_source_clock_hz = rmt_source_clk_hz; -#endif - ESP_LOGD(TAG, "rmt_source_clk_hz: %"PRIu32, rmt_source_clk_hz); - - if (mode == RMT_MODE_TX) { - uint16_t carrier_duty_percent = rmt_param->tx_config.carrier_duty_percent; - uint8_t carrier_level = rmt_param->tx_config.carrier_level; - uint8_t idle_level = rmt_param->tx_config.idle_level; - - RMT_ENTER_CRITICAL(); - rmt_ll_tx_set_channel_clock_div(dev, channel, clk_div); - rmt_ll_tx_set_mem_blocks(dev, channel, mem_cnt); - rmt_ll_tx_reset_pointer(dev, channel); - rmt_ll_tx_enable_loop(dev, channel, rmt_param->tx_config.loop_en); -#if SOC_RMT_SUPPORT_TX_LOOP_COUNT - if (rmt_param->tx_config.loop_en) { - rmt_ll_tx_set_loop_count(dev, channel, rmt_param->tx_config.loop_count); - } -#endif - /* always enable tx ping-pong */ - rmt_ll_tx_enable_wrap(dev, channel, true); - /*Set idle level */ - rmt_ll_tx_fix_idle_level(dev, channel, idle_level, rmt_param->tx_config.idle_output_en); - /*Set carrier*/ - rmt_ll_tx_enable_carrier_modulation(dev, channel, carrier_en); - if (carrier_en) { - uint32_t duty_div, duty_h, duty_l; - duty_div = rmt_source_clk_hz / carrier_freq_hz; - duty_h = duty_div * carrier_duty_percent / 100; - duty_l = duty_div - duty_h; - rmt_ll_tx_set_carrier_level(dev, channel, carrier_level); - rmt_ll_tx_set_carrier_high_low_ticks(dev, channel, duty_h, duty_l); - } else { - rmt_ll_tx_set_carrier_level(dev, channel, 0); - } - RMT_EXIT_CRITICAL(); - - ESP_LOGD(TAG, "Rmt Tx Channel %u|Gpio %u|Sclk_Hz %"PRIu32"|Div %u|Carrier_Hz %"PRIu32"|Duty %u", - channel, gpio_num, rmt_source_clk_hz, clk_div, carrier_freq_hz, carrier_duty_percent); - } else if (RMT_MODE_RX == mode) { - uint8_t filter_cnt = rmt_param->rx_config.filter_ticks_thresh; - uint16_t threshold = rmt_param->rx_config.idle_threshold; - - RMT_ENTER_CRITICAL(); - rmt_ll_rx_set_channel_clock_div(dev, RMT_DECODE_RX_CHANNEL(channel), clk_div); - rmt_ll_rx_set_mem_blocks(dev, RMT_DECODE_RX_CHANNEL(channel), mem_cnt); - rmt_ll_rx_reset_pointer(dev, RMT_DECODE_RX_CHANNEL(channel)); - rmt_ll_rx_set_mem_owner(dev, RMT_DECODE_RX_CHANNEL(channel), RMT_LL_MEM_OWNER_HW); - /*Set idle threshold*/ - rmt_ll_rx_set_idle_thres(dev, RMT_DECODE_RX_CHANNEL(channel), threshold); - /* Set RX filter */ - rmt_ll_rx_set_filter_thres(dev, RMT_DECODE_RX_CHANNEL(channel), filter_cnt); - rmt_ll_rx_enable_filter(dev, RMT_DECODE_RX_CHANNEL(channel), rmt_param->rx_config.filter_en); - -#if SOC_RMT_SUPPORT_RX_PINGPONG - /* always enable rx ping-pong */ - rmt_ll_rx_enable_wrap(dev, RMT_DECODE_RX_CHANNEL(channel), true); -#endif - -#if SOC_RMT_SUPPORT_RX_DEMODULATION - rmt_ll_rx_enable_carrier_demodulation(dev, RMT_DECODE_RX_CHANNEL(channel), rmt_param->rx_config.rm_carrier); - if (rmt_param->rx_config.rm_carrier) { - uint32_t duty_total = rmt_source_clk_hz / rmt_ll_rx_get_channel_clock_div(dev, RMT_DECODE_RX_CHANNEL(channel)) / rmt_param->rx_config.carrier_freq_hz; - uint32_t duty_high = duty_total * rmt_param->rx_config.carrier_duty_percent / 100; - // there could be residual in timing the carrier pulse, so double enlarge the theoretical value - rmt_ll_rx_set_carrier_high_low_ticks(dev, RMT_DECODE_RX_CHANNEL(channel), duty_high * 2, (duty_total - duty_high) * 2); - rmt_ll_rx_set_carrier_level(dev, RMT_DECODE_RX_CHANNEL(channel), rmt_param->rx_config.carrier_level); - } -#endif - RMT_EXIT_CRITICAL(); - - ESP_LOGD(TAG, "Rmt Rx Channel %u|Gpio %u|Sclk_Hz %"PRIu32"|Div %u|Threshold %u|Filter %u", - channel, gpio_num, rmt_source_clk_hz, clk_div, threshold, filter_cnt); - } - - return ESP_OK; -} - -esp_err_t rmt_config(const rmt_config_t *rmt_param) -{ - rmt_module_enable(); - - ESP_RETURN_ON_ERROR(rmt_set_gpio(rmt_param->channel, rmt_param->rmt_mode, rmt_param->gpio_num, rmt_param->flags & RMT_CHANNEL_FLAGS_INVERT_SIG), TAG, "set gpio for RMT driver failed"); - ESP_RETURN_ON_ERROR(rmt_internal_config(&RMT, rmt_param), TAG, "initialize RMT driver failed"); - - return ESP_OK; -} - -static void IRAM_ATTR rmt_fill_memory(rmt_channel_t channel, const rmt_item32_t *item, - uint16_t item_num, uint16_t mem_offset) -{ - uint32_t *from = (uint32_t *)item; - volatile uint32_t *to = (volatile uint32_t *)&RMTMEM.chan[channel].data32[0].val; - to += mem_offset; - while (item_num--) { - *to++ = *from++; - } -} - -esp_err_t rmt_fill_tx_items(rmt_channel_t channel, const rmt_item32_t *item, uint16_t item_num, uint16_t mem_offset) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), (0), TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(item, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - ESP_RETURN_ON_FALSE(item_num > 0, ESP_ERR_INVALID_ARG, TAG, RMT_DRIVER_LENGTH_ERROR_STR); - - uint8_t mem_cnt = rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel); - ESP_RETURN_ON_FALSE(mem_cnt * RMT_MEM_ITEM_NUM >= item_num, ESP_ERR_INVALID_ARG, TAG, RMT_WR_MEM_OVF_ERROR_STR); - rmt_fill_memory(channel, item, item_num, mem_offset); - return ESP_OK; -} - -esp_err_t rmt_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, rmt_isr_handle_t *handle) -{ - ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - ESP_RETURN_ON_FALSE(rmt_contex.rmt_driver_channels == 0, ESP_FAIL, TAG, "RMT driver installed, can not install generic ISR handler"); - - return esp_intr_alloc(rmt_periph_signals.groups[0].irq, intr_alloc_flags, fn, arg, handle); -} - -esp_err_t rmt_isr_deregister(rmt_isr_handle_t handle) -{ - return esp_intr_free(handle); -} - -static void IRAM_ATTR rmt_driver_isr_default(void *arg) -{ - uint32_t status = 0; - rmt_item32_t *addr = NULL; - uint8_t channel = 0; - rmt_hal_context_t *hal = (rmt_hal_context_t *)arg; - BaseType_t HPTaskAwoken = pdFALSE; - - // Tx end interrupt - status = rmt_ll_get_tx_end_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - if (p_rmt) { - xSemaphoreGiveFromISR(p_rmt->tx_sem, &HPTaskAwoken); - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); - p_rmt->tx_data = NULL; - p_rmt->tx_len_rem = 0; - p_rmt->tx_offset = 0; - p_rmt->tx_sub_len = 0; - p_rmt->sample_cur = NULL; - p_rmt->translator = false; - if (rmt_contex.rmt_tx_end_callback.function) { - rmt_contex.rmt_tx_end_callback.function(channel, rmt_contex.rmt_tx_end_callback.arg); - } - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_TX_DONE(channel)); - } - - // Tx thres interrupt - status = rmt_ll_get_tx_thres_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - if (p_rmt) { - if (p_rmt->translator) { - if (p_rmt->sample_size_remain > 0) { - size_t translated_size = 0; - p_rmt->sample_to_rmt((void *)p_rmt->sample_cur, - p_rmt->tx_buf, - p_rmt->sample_size_remain, - p_rmt->tx_sub_len, - &translated_size, - &p_rmt->tx_len_rem); - p_rmt->sample_size_remain -= translated_size; - p_rmt->sample_cur += translated_size; - p_rmt->tx_data = p_rmt->tx_buf; - } else { - p_rmt->sample_cur = NULL; - p_rmt->translator = false; - } - } - const rmt_item32_t *pdata = p_rmt->tx_data; - size_t len_rem = p_rmt->tx_len_rem; - rmt_idle_level_t idle_level = rmt_ll_tx_get_idle_level(hal->regs, channel); - rmt_item32_t stop_data = (rmt_item32_t) { - .level0 = idle_level, - .duration0 = 0, - }; - if (len_rem >= p_rmt->tx_sub_len) { - rmt_fill_memory(channel, pdata, p_rmt->tx_sub_len, p_rmt->tx_offset); - p_rmt->tx_data += p_rmt->tx_sub_len; - p_rmt->tx_len_rem -= p_rmt->tx_sub_len; - } else if (len_rem == 0) { - rmt_fill_memory(channel, &stop_data, 1, p_rmt->tx_offset); - } else { - rmt_fill_memory(channel, pdata, len_rem, p_rmt->tx_offset); - rmt_fill_memory(channel, &stop_data, 1, p_rmt->tx_offset + len_rem); - p_rmt->tx_data += len_rem; - p_rmt->tx_len_rem -= len_rem; - } - if (p_rmt->tx_offset == 0) { - p_rmt->tx_offset = p_rmt->tx_sub_len; - } else { - p_rmt->tx_offset = 0; - } - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_TX_THRES(channel)); - } - - // Rx end interrupt - status = rmt_ll_get_rx_end_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[RMT_ENCODE_RX_CHANNEL(channel)]; - if (p_rmt) { - rmt_ll_rx_enable(rmt_contex.hal.regs, channel, false); - int item_len = rmt_ll_rx_get_memory_writer_offset(rmt_contex.hal.regs, channel); - rmt_ll_rx_set_mem_owner(rmt_contex.hal.regs, channel, RMT_LL_MEM_OWNER_SW); - if (p_rmt->rx_buf) { - addr = (rmt_item32_t *)RMTMEM.chan[RMT_ENCODE_RX_CHANNEL(channel)].data32; -#if SOC_RMT_SUPPORT_RX_PINGPONG - if (item_len > p_rmt->rx_item_start_idx) { - item_len = item_len - p_rmt->rx_item_start_idx; - } - memcpy((void *)(p_rmt->rx_item_buf + p_rmt->rx_item_len), (void *)(addr + p_rmt->rx_item_start_idx), item_len * 4); - p_rmt->rx_item_len += item_len; - BaseType_t res = xRingbufferSendFromISR(p_rmt->rx_buf, (void *)(p_rmt->rx_item_buf), p_rmt->rx_item_len * 4, &HPTaskAwoken); -#else - BaseType_t res = xRingbufferSendFromISR(p_rmt->rx_buf, (void *)addr, item_len * 4, &HPTaskAwoken); -#endif - if (res == pdFALSE) { - ESP_DRAM_LOGE(TAG, "RMT RX BUFFER FULL"); - } - } else { - ESP_DRAM_LOGE(TAG, "RMT RX BUFFER ERROR"); - } - -#if SOC_RMT_SUPPORT_RX_PINGPONG - p_rmt->rx_item_start_idx = 0; - p_rmt->rx_item_len = 0; - memset((void *)p_rmt->rx_item_buf, 0, p_rmt->rx_item_buf_size); -#endif - rmt_ll_rx_reset_pointer(rmt_contex.hal.regs, channel); - rmt_ll_rx_set_mem_owner(rmt_contex.hal.regs, channel, RMT_LL_MEM_OWNER_HW); - rmt_ll_rx_enable(rmt_contex.hal.regs, channel, true); - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_RX_DONE(channel)); - } - -#if SOC_RMT_SUPPORT_RX_PINGPONG - // Rx thres interrupt - status = rmt_ll_get_rx_thres_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[RMT_ENCODE_RX_CHANNEL(channel)]; - int mem_item_size = rmt_ll_rx_get_mem_blocks(rmt_contex.hal.regs, channel) * RMT_MEM_ITEM_NUM; - int rx_thres_lim = rmt_ll_rx_get_limit(rmt_contex.hal.regs, channel); - int item_len = (p_rmt->rx_item_start_idx == 0) ? rx_thres_lim : (mem_item_size - rx_thres_lim); - if ((p_rmt->rx_item_len + item_len) < (p_rmt->rx_item_buf_size / 4)) { - rmt_ll_rx_set_mem_owner(rmt_contex.hal.regs, channel, RMT_LL_MEM_OWNER_SW); - memcpy((void *)(p_rmt->rx_item_buf + p_rmt->rx_item_len), (void *)(RMTMEM.chan[RMT_ENCODE_RX_CHANNEL(channel)].data32 + p_rmt->rx_item_start_idx), item_len * 4); - rmt_ll_rx_set_mem_owner(rmt_contex.hal.regs, channel, RMT_LL_MEM_OWNER_HW); - p_rmt->rx_item_len += item_len; - p_rmt->rx_item_start_idx += item_len; - if (p_rmt->rx_item_start_idx >= mem_item_size) { - p_rmt->rx_item_start_idx = 0; - } - } else { - ESP_DRAM_LOGE(TAG, "---RX buffer too small: %d", sizeof(p_rmt->rx_item_buf)); - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_RX_THRES(channel)); - } -#endif - -#if SOC_RMT_SUPPORT_TX_LOOP_COUNT - // loop count interrupt - status = rmt_ll_get_tx_loop_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - if (p_rmt) { - if (p_rmt->loop_autostop) { -#ifndef SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP - // hardware doesn't support automatically stop output so driver should stop output here (possibility already overshotted several us) - rmt_ll_tx_stop(rmt_contex.hal.regs, channel); - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); -#endif - } - xSemaphoreGiveFromISR(p_rmt->tx_sem, &HPTaskAwoken); - if (rmt_contex.rmt_tx_end_callback.function) { - rmt_contex.rmt_tx_end_callback.function(channel, rmt_contex.rmt_tx_end_callback.arg); - } - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_TX_LOOP_END(channel)); - } -#endif - - // RX Err interrupt - status = rmt_ll_get_rx_err_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[RMT_ENCODE_RX_CHANNEL(channel)]; - if (p_rmt) { - // Reset the receiver's write/read addresses to prevent endless err interrupts. - rmt_ll_rx_reset_pointer(rmt_contex.hal.regs, channel); - ESP_DRAM_LOGD(TAG, "RMT RX channel %d error", channel); - ESP_DRAM_LOGD(TAG, "status: 0x%08x", rmt_ll_rx_get_status_word(rmt_contex.hal.regs, channel)); - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_RX_ERROR(channel)); - } - - // TX Err interrupt - status = rmt_ll_get_tx_err_interrupt_status(hal->regs); - while (status) { - channel = __builtin_ffs(status) - 1; - status &= ~(1 << channel); - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - if (p_rmt) { - // Reset the transmitter's write/read addresses to prevent endless err interrupts. - rmt_ll_tx_reset_pointer(rmt_contex.hal.regs, channel); - ESP_DRAM_LOGD(TAG, "RMT TX channel %d error", channel); - ESP_DRAM_LOGD(TAG, "status: 0x%08x", rmt_ll_tx_get_status_word(rmt_contex.hal.regs, channel)); - } - rmt_ll_clear_interrupt_status(hal->regs, RMT_LL_EVENT_TX_ERROR(channel)); - } - - if (HPTaskAwoken == pdTRUE) { - portYIELD_FROM_ISR(); - } -} - -esp_err_t rmt_driver_uninstall(rmt_channel_t channel) -{ - esp_err_t err = ESP_OK; - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - // we allow to call this uninstall function on the same channel for multiple times - if (p_rmt_obj[channel] == NULL) { - return ESP_OK; - } - //Avoid blocking here(when the interrupt is disabled and do not wait tx done). - if (p_rmt_obj[channel]->wait_done) { - xSemaphoreTake(p_rmt_obj[channel]->tx_sem, portMAX_DELAY); - } - - RMT_ENTER_CRITICAL(); - // check channel's working mode - if (p_rmt_obj[channel]->rx_buf) { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_RX_MASK(RMT_DECODE_RX_CHANNEL(channel)) | RMT_LL_EVENT_RX_ERROR(RMT_DECODE_RX_CHANNEL(channel)), false); - } else { - rmt_ll_enable_interrupt(rmt_contex.hal.regs, RMT_LL_EVENT_TX_MASK(channel) | RMT_LL_EVENT_TX_ERROR(channel), false); - } - RMT_EXIT_CRITICAL(); - - _lock_acquire_recursive(&(rmt_contex.rmt_driver_isr_lock)); - rmt_contex.rmt_driver_channels &= ~BIT(channel); - if (rmt_contex.rmt_driver_channels == 0 && rmt_contex.rmt_driver_intr_handle) { - rmt_module_disable(); - // all channels have driver disabled - err = rmt_isr_deregister(rmt_contex.rmt_driver_intr_handle); - rmt_contex.rmt_driver_intr_handle = NULL; - } - _lock_release_recursive(&(rmt_contex.rmt_driver_isr_lock)); - - if (p_rmt_obj[channel]->tx_sem) { - vSemaphoreDelete(p_rmt_obj[channel]->tx_sem); - p_rmt_obj[channel]->tx_sem = NULL; - } - if (p_rmt_obj[channel]->rx_buf) { - vRingbufferDelete(p_rmt_obj[channel]->rx_buf); - p_rmt_obj[channel]->rx_buf = NULL; - } - if (p_rmt_obj[channel]->tx_buf) { - free(p_rmt_obj[channel]->tx_buf); - p_rmt_obj[channel]->tx_buf = NULL; - } - if (p_rmt_obj[channel]->sample_to_rmt) { - p_rmt_obj[channel]->sample_to_rmt = NULL; - } -#if SOC_RMT_SUPPORT_RX_PINGPONG - if (p_rmt_obj[channel]->rx_item_buf) { - free(p_rmt_obj[channel]->rx_item_buf); - p_rmt_obj[channel]->rx_item_buf = NULL; - p_rmt_obj[channel]->rx_item_buf_size = 0; - } -#endif - - free(p_rmt_obj[channel]); - p_rmt_obj[channel] = NULL; - return err; -} - -esp_err_t rmt_driver_install(rmt_channel_t channel, size_t rx_buf_size, int intr_alloc_flags) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - - esp_err_t err = ESP_OK; - - if (p_rmt_obj[channel]) { - ESP_LOGD(TAG, "RMT driver already installed"); - return ESP_ERR_INVALID_STATE; - } - -#if CONFIG_RINGBUF_PLACE_ISR_FUNCTIONS_INTO_FLASH - if (intr_alloc_flags & ESP_INTR_FLAG_IRAM) { - ESP_LOGE(TAG, "ringbuf ISR functions in flash, but used in IRAM interrupt"); - return ESP_ERR_INVALID_ARG; - } -#endif - -#if !CONFIG_SPIRAM_USE_MALLOC - p_rmt_obj[channel] = calloc(1, sizeof(rmt_obj_t)); -#else - if (!(intr_alloc_flags & ESP_INTR_FLAG_IRAM)) { - p_rmt_obj[channel] = calloc(1, sizeof(rmt_obj_t)); - } else { - p_rmt_obj[channel] = heap_caps_calloc(1, sizeof(rmt_obj_t), MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); - } -#endif - - if (p_rmt_obj[channel] == NULL) { - ESP_LOGE(TAG, "RMT driver malloc error"); - return ESP_ERR_NO_MEM; - } - - p_rmt_obj[channel]->tx_len_rem = 0; - p_rmt_obj[channel]->tx_data = NULL; - p_rmt_obj[channel]->channel = channel; - p_rmt_obj[channel]->tx_offset = 0; - p_rmt_obj[channel]->tx_sub_len = 0; - p_rmt_obj[channel]->wait_done = false; - p_rmt_obj[channel]->loop_autostop = false; - p_rmt_obj[channel]->translator = false; - p_rmt_obj[channel]->sample_to_rmt = NULL; - if (p_rmt_obj[channel]->tx_sem == NULL) { -#if !CONFIG_SPIRAM_USE_MALLOC - p_rmt_obj[channel]->tx_sem = xSemaphoreCreateBinary(); -#else - p_rmt_obj[channel]->intr_alloc_flags = intr_alloc_flags; - if (!(intr_alloc_flags & ESP_INTR_FLAG_IRAM)) { - p_rmt_obj[channel]->tx_sem = xSemaphoreCreateBinary(); - } else { - p_rmt_obj[channel]->tx_sem = xSemaphoreCreateBinaryStatic(&p_rmt_obj[channel]->tx_sem_buffer); - } -#endif - xSemaphoreGive(p_rmt_obj[channel]->tx_sem); - } - if (p_rmt_obj[channel]->rx_buf == NULL && rx_buf_size > 0) { - p_rmt_obj[channel]->rx_buf = xRingbufferCreate(rx_buf_size, RINGBUF_TYPE_NOSPLIT); - } - -#if SOC_RMT_SUPPORT_RX_PINGPONG - if (p_rmt_obj[channel]->rx_item_buf == NULL && rx_buf_size > 0) { - ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE("-Wanalyzer-malloc-leak") // False-positive detection. TODO GCC-366 -#if !CONFIG_SPIRAM_USE_MALLOC - p_rmt_obj[channel]->rx_item_buf = calloc(1, rx_buf_size); -#else - if (!(p_rmt_obj[channel]->intr_alloc_flags & ESP_INTR_FLAG_IRAM)) { - p_rmt_obj[channel]->rx_item_buf = calloc(1, rx_buf_size); - } else { - p_rmt_obj[channel]->rx_item_buf = heap_caps_calloc(1, rx_buf_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); - } -#endif - if (p_rmt_obj[channel]->rx_item_buf == NULL) { - ESP_LOGE(TAG, "RMT malloc fail"); - return ESP_FAIL; - } - ESP_COMPILER_DIAGNOSTIC_POP("-Wanalyzer-malloc-leak") - p_rmt_obj[channel]->rx_item_buf_size = rx_buf_size; - } -#endif - - _lock_acquire_recursive(&(rmt_contex.rmt_driver_isr_lock)); - - if (rmt_contex.rmt_driver_channels == 0) { - // first RMT channel using driver - err = rmt_isr_register(rmt_driver_isr_default, &rmt_contex.hal, intr_alloc_flags, &(rmt_contex.rmt_driver_intr_handle)); - } - if (err == ESP_OK) { - rmt_contex.rmt_driver_channels |= BIT(channel); - } - _lock_release_recursive(&(rmt_contex.rmt_driver_isr_lock)); - - rmt_module_enable(); - - if (RMT_IS_RX_CHANNEL(channel)) { - rmt_hal_rx_channel_reset(&rmt_contex.hal, RMT_DECODE_RX_CHANNEL(channel)); - } else { - rmt_hal_tx_channel_reset(&rmt_contex.hal, channel); - } - - return err; -} - -esp_err_t rmt_write_items(rmt_channel_t channel, const rmt_item32_t *rmt_item, int item_num, bool wait_tx_done) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - ESP_RETURN_ON_FALSE(rmt_item, ESP_FAIL, TAG, RMT_ADDR_ERROR_STR); - ESP_RETURN_ON_FALSE(item_num > 0, ESP_ERR_INVALID_ARG, TAG, RMT_DRIVER_LENGTH_ERROR_STR); - uint32_t mem_blocks = rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel); - ESP_RETURN_ON_FALSE(mem_blocks + channel <= SOC_RMT_CHANNELS_PER_GROUP, ESP_ERR_INVALID_STATE, TAG, RMT_MEM_CNT_ERROR_STR); -#if CONFIG_SPIRAM_USE_MALLOC - if (p_rmt_obj[channel]->intr_alloc_flags & ESP_INTR_FLAG_IRAM) { - if (!esp_ptr_internal(rmt_item)) { - ESP_LOGE(TAG, RMT_PSRAM_BUFFER_WARN_STR); - return ESP_ERR_INVALID_ARG; - } - } -#endif - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - int item_block_len = mem_blocks * RMT_MEM_ITEM_NUM; - int item_sub_len = mem_blocks * RMT_MEM_ITEM_NUM / 2; - int len_rem = item_num; - xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY); - // fill the memory block first - if (item_num >= item_block_len) { - rmt_fill_memory(channel, rmt_item, item_block_len, 0); - len_rem -= item_block_len; - rmt_set_tx_loop_mode(channel, false); - rmt_set_tx_thr_intr_en(channel, 1, item_sub_len); - p_rmt->tx_data = rmt_item + item_block_len; - p_rmt->tx_len_rem = len_rem; - p_rmt->tx_offset = 0; - p_rmt->tx_sub_len = item_sub_len; - } else { - rmt_fill_memory(channel, rmt_item, len_rem, 0); - rmt_idle_level_t idle_level = rmt_ll_tx_get_idle_level(rmt_contex.hal.regs, channel); - rmt_item32_t stop_data = (rmt_item32_t) { - .level0 = idle_level, - .duration0 = 0, - }; - rmt_fill_memory(channel, &stop_data, 1, len_rem); - p_rmt->tx_len_rem = 0; - } - rmt_tx_start(channel, true); - p_rmt->wait_done = wait_tx_done; - if (wait_tx_done) { - // wait loop done - if (rmt_ll_tx_is_loop_enabled(rmt_contex.hal.regs, channel)) { -#if SOC_RMT_SUPPORT_TX_LOOP_COUNT - xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY); - xSemaphoreGive(p_rmt->tx_sem); -#endif - } else { - // wait tx end - xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY); - xSemaphoreGive(p_rmt->tx_sem); - } - } - return ESP_OK; -} - -esp_err_t rmt_wait_tx_done(rmt_channel_t channel, TickType_t wait_time) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - if (xSemaphoreTake(p_rmt_obj[channel]->tx_sem, wait_time) == pdTRUE) { - p_rmt_obj[channel]->wait_done = false; - xSemaphoreGive(p_rmt_obj[channel]->tx_sem); - return ESP_OK; - } else { - if (wait_time != 0) { - // Don't emit error message if just polling. - ESP_LOGE(TAG, "Timeout on wait_tx_done"); - } - return ESP_ERR_TIMEOUT; - } -} - -esp_err_t rmt_get_ringbuf_handle(rmt_channel_t channel, RingbufHandle_t *buf_handle) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - ESP_RETURN_ON_FALSE(buf_handle, ESP_ERR_INVALID_ARG, TAG, RMT_ADDR_ERROR_STR); - *buf_handle = p_rmt_obj[channel]->rx_buf; - return ESP_OK; -} - -rmt_tx_end_callback_t rmt_register_tx_end_callback(rmt_tx_end_fn_t function, void *arg) -{ - rmt_tx_end_callback_t previous = rmt_contex.rmt_tx_end_callback; - rmt_contex.rmt_tx_end_callback.function = function; - rmt_contex.rmt_tx_end_callback.arg = arg; - return previous; -} - -esp_err_t rmt_translator_init(rmt_channel_t channel, sample_to_rmt_t fn) -{ - ESP_RETURN_ON_FALSE(fn, ESP_ERR_INVALID_ARG, TAG, RMT_TRANSLATOR_NULL_STR); - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - uint32_t mem_blocks = rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel); - ESP_RETURN_ON_FALSE(mem_blocks + channel <= SOC_RMT_CHANNELS_PER_GROUP, ESP_ERR_INVALID_STATE, TAG, RMT_MEM_CNT_ERROR_STR); - const uint32_t block_size = mem_blocks * RMT_MEM_ITEM_NUM * sizeof(rmt_item32_t); - if (p_rmt_obj[channel]->tx_buf == NULL) { -#if !CONFIG_SPIRAM_USE_MALLOC - p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)calloc(1, block_size); -#else - if (p_rmt_obj[channel]->intr_alloc_flags & ESP_INTR_FLAG_IRAM) { - p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)heap_caps_calloc(1, block_size, MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT); - } else { - p_rmt_obj[channel]->tx_buf = (rmt_item32_t *)calloc(1, block_size); - } -#endif - if (p_rmt_obj[channel]->tx_buf == NULL) { - ESP_LOGE(TAG, "RMT translator buffer create fail"); - return ESP_FAIL; - } - } - p_rmt_obj[channel]->sample_to_rmt = fn; - p_rmt_obj[channel]->tx_context = NULL; - p_rmt_obj[channel]->sample_size_remain = 0; - p_rmt_obj[channel]->sample_cur = NULL; - ESP_LOGD(TAG, "RMT translator init done"); - return ESP_OK; -} - -esp_err_t rmt_translator_set_context(rmt_channel_t channel, void *context) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - - p_rmt_obj[channel]->tx_context = context; - return ESP_OK; -} - -esp_err_t rmt_translator_get_context(const size_t *item_num, void **context) -{ - ESP_RETURN_ON_FALSE(item_num && context, ESP_ERR_INVALID_ARG, TAG, "invalid arguments"); - - // the address of tx_len_rem is directly passed to the callback, - // so it's possible to get the object address from that - rmt_obj_t *obj = __containerof(item_num, rmt_obj_t, tx_len_rem); - *context = obj->tx_context; - - return ESP_OK; -} - -esp_err_t rmt_write_sample(rmt_channel_t channel, const uint8_t *src, size_t src_size, bool wait_tx_done) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel], ESP_FAIL, TAG, RMT_DRIVER_ERROR_STR); - ESP_RETURN_ON_FALSE(p_rmt_obj[channel]->sample_to_rmt, ESP_FAIL, TAG, RMT_TRANSLATOR_UNINIT_STR); - uint32_t mem_blocks = rmt_ll_tx_get_mem_blocks(rmt_contex.hal.regs, channel); - ESP_RETURN_ON_FALSE(mem_blocks + channel <= SOC_RMT_CHANNELS_PER_GROUP, ESP_ERR_INVALID_STATE, TAG, RMT_MEM_CNT_ERROR_STR); -#if CONFIG_SPIRAM_USE_MALLOC - if (p_rmt_obj[channel]->intr_alloc_flags & ESP_INTR_FLAG_IRAM) { - if (!esp_ptr_internal(src)) { - ESP_LOGE(TAG, RMT_PSRAM_BUFFER_WARN_STR); - return ESP_ERR_INVALID_ARG; - } - } -#endif - size_t translated_size = 0; - rmt_obj_t *p_rmt = p_rmt_obj[channel]; - const uint32_t item_block_len = mem_blocks * RMT_MEM_ITEM_NUM; - const uint32_t item_sub_len = item_block_len / 2; - xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY); - p_rmt->sample_to_rmt((void *)src, p_rmt->tx_buf, src_size, item_block_len, &translated_size, &p_rmt->tx_len_rem); - p_rmt->sample_size_remain = src_size - translated_size; - p_rmt->sample_cur = src + translated_size; - rmt_fill_memory(channel, p_rmt->tx_buf, p_rmt->tx_len_rem, 0); - if (p_rmt->tx_len_rem == item_block_len) { - rmt_set_tx_thr_intr_en(channel, 1, item_sub_len); - p_rmt->tx_data = p_rmt->tx_buf; - p_rmt->tx_offset = 0; - p_rmt->tx_sub_len = item_sub_len; - p_rmt->translator = true; - } else { - rmt_idle_level_t idle_level = rmt_ll_tx_get_idle_level(rmt_contex.hal.regs, channel); - rmt_item32_t stop_data = (rmt_item32_t) { - .level0 = idle_level, - .duration0 = 0, - }; - rmt_fill_memory(channel, &stop_data, 1, p_rmt->tx_len_rem); - p_rmt->tx_len_rem = 0; - p_rmt->sample_cur = NULL; - p_rmt->translator = false; - } - rmt_tx_start(channel, true); - p_rmt->wait_done = wait_tx_done; - if (wait_tx_done) { - xSemaphoreTake(p_rmt->tx_sem, portMAX_DELAY); - xSemaphoreGive(p_rmt->tx_sem); - } - return ESP_OK; -} - -esp_err_t rmt_get_channel_status(rmt_channel_status_result_t *channel_status) -{ - ESP_RETURN_ON_FALSE(channel_status, ESP_ERR_INVALID_ARG, TAG, RMT_PARAM_ERR_STR); - for (int i = 0; i < RMT_CHANNEL_MAX; i++) { - channel_status->status[i] = RMT_CHANNEL_UNINIT; - if (p_rmt_obj[i]) { - if (p_rmt_obj[i]->tx_sem) { - if (xSemaphoreTake(p_rmt_obj[i]->tx_sem, (TickType_t)0) == pdTRUE) { - channel_status->status[i] = RMT_CHANNEL_IDLE; - xSemaphoreGive(p_rmt_obj[i]->tx_sem); - } else { - channel_status->status[i] = RMT_CHANNEL_BUSY; - } - } - } - } - return ESP_OK; -} - -esp_err_t rmt_get_counter_clock(rmt_channel_t channel, uint32_t *clock_hz) -{ - ESP_RETURN_ON_FALSE(channel < RMT_CHANNEL_MAX, ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(clock_hz, ESP_ERR_INVALID_ARG, TAG, "parameter clock_hz can't be null"); - RMT_ENTER_CRITICAL(); - uint32_t rmt_source_clk_hz = 0; -#if SOC_RMT_CHANNEL_CLK_INDEPENDENT - rmt_source_clk_hz = s_rmt_source_clock_hz[channel]; -#else - rmt_source_clk_hz = s_rmt_source_clock_hz; -#endif - if (RMT_IS_RX_CHANNEL(channel)) { - *clock_hz = rmt_source_clk_hz / rmt_ll_rx_get_channel_clock_div(rmt_contex.hal.regs, RMT_DECODE_RX_CHANNEL(channel)); - } else { - *clock_hz = rmt_source_clk_hz / rmt_ll_tx_get_channel_clock_div(rmt_contex.hal.regs, channel); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -#if SOC_RMT_SUPPORT_TX_SYNCHRO -esp_err_t rmt_add_channel_to_group(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_enable_sync(rmt_contex.hal.regs, true); - rmt_contex.synchro_channel_mask |= (1 << channel); - rmt_ll_tx_sync_group_add_channels(rmt_contex.hal.regs, 1 << channel); - rmt_ll_tx_reset_channels_clock_div(rmt_contex.hal.regs, rmt_contex.synchro_channel_mask); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_remove_channel_from_group(rmt_channel_t channel) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - RMT_ENTER_CRITICAL(); - rmt_contex.synchro_channel_mask &= ~(1 << channel); - rmt_ll_tx_sync_group_remove_channels(rmt_contex.hal.regs, 1 << channel); - if (rmt_contex.synchro_channel_mask == 0) { - rmt_ll_tx_enable_sync(rmt_contex.hal.regs, false); - } - RMT_EXIT_CRITICAL(); - return ESP_OK; -} -#endif - -#if SOC_RMT_SUPPORT_TX_LOOP_COUNT -esp_err_t rmt_set_tx_loop_count(rmt_channel_t channel, uint32_t count) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - ESP_RETURN_ON_FALSE(count <= RMT_LL_MAX_LOOP_COUNT_PER_BATCH, ESP_ERR_INVALID_ARG, TAG, "Invalid count value"); - RMT_ENTER_CRITICAL(); - rmt_ll_tx_set_loop_count(rmt_contex.hal.regs, channel, count); - RMT_EXIT_CRITICAL(); - return ESP_OK; -} - -esp_err_t rmt_enable_tx_loop_autostop(rmt_channel_t channel, bool en) -{ - ESP_RETURN_ON_FALSE(RMT_IS_TX_CHANNEL(channel), ESP_ERR_INVALID_ARG, TAG, RMT_CHANNEL_ERROR_STR); - p_rmt_obj[channel]->loop_autostop = en; -#if SOC_RMT_SUPPORT_TX_LOOP_AUTO_STOP - RMT_ENTER_CRITICAL(); - rmt_ll_tx_enable_loop_autostop(rmt_contex.hal.regs, channel, en); - RMT_EXIT_CRITICAL(); -#endif - return ESP_OK; -} -#endif - -#if !CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK -/** - * @brief This function will be called during start up, to check that this legacy RMT driver is not running along with the new driver - */ -__attribute__((constructor)) -static void check_rmt_legacy_driver_conflict(void) -{ - // This function was declared as weak here. The new RMT driver has one implementation. - // So if the new RMT driver is not linked in, then `rmt_acquire_group_handle()` should be NULL at runtime. - extern __attribute__((weak)) void *rmt_acquire_group_handle(int group_id); - if ((void *)rmt_acquire_group_handle != NULL) { - ESP_EARLY_LOGE(TAG, "CONFLICT! driver_ng is not allowed to be used with the legacy driver"); - abort(); - } - ESP_EARLY_LOGW(TAG, "legacy driver is deprecated, please migrate to `driver/rmt_tx.h` and/or `driver/rmt_rx.h`"); -} -#endif //CONFIG_RMT_SKIP_LEGACY_CONFLICT_CHECK diff --git a/components/driver/test_apps/components/test_driver_utils/CMakeLists.txt b/components/driver/test_apps/components/test_driver_utils/CMakeLists.txt index 9e70b9939b..8643decdaf 100644 --- a/components/driver/test_apps/components/test_driver_utils/CMakeLists.txt +++ b/components/driver/test_apps/components/test_driver_utils/CMakeLists.txt @@ -1,5 +1,6 @@ idf_component_register( SRCS test_spi_utils.c param_test.c test_dualboard_utils.c INCLUDE_DIRS include - REQUIRES driver unity + REQUIRES driver unity esp_ringbuf esp_driver_spi + PRIV_REQUIRES esp_driver_gpio ) diff --git a/components/driver/test_apps/legacy_i2c_driver/main/CMakeLists.txt b/components/driver/test_apps/legacy_i2c_driver/main/CMakeLists.txt index 008413a567..444ee03ec1 100644 --- a/components/driver/test_apps/legacy_i2c_driver/main/CMakeLists.txt +++ b/components/driver/test_apps/legacy_i2c_driver/main/CMakeLists.txt @@ -3,5 +3,5 @@ set(srcs "test_app_main.c" ) idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity test_utils driver + PRIV_REQUIRES unity test_utils driver esp_driver_gpio WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/legacy_twai/main/CMakeLists.txt b/components/driver/test_apps/legacy_twai/main/CMakeLists.txt index 525e6e2d87..d7bba661d0 100644 --- a/components/driver/test_apps/legacy_twai/main/CMakeLists.txt +++ b/components/driver/test_apps/legacy_twai/main/CMakeLists.txt @@ -1,9 +1,9 @@ -set(srcs "test_app_main.c" - "test_twai_loop_back.c" - "test_twai_interactive.c") +set(srcs "test_app_main.cpp" + "test_twai_loop_back.cpp" + "test_twai_interactive.cpp") # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity driver + PRIV_REQUIRES unity driver esp_driver_gpio esp_hw_support WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/legacy_twai/main/test_app_main.c b/components/driver/test_apps/legacy_twai/main/test_app_main.cpp similarity index 97% rename from components/driver/test_apps/legacy_twai/main/test_app_main.c rename to components/driver/test_apps/legacy_twai/main/test_app_main.cpp index f581eec3c3..02bfd78581 100644 --- a/components/driver/test_apps/legacy_twai/main/test_app_main.c +++ b/components/driver/test_apps/legacy_twai/main/test_app_main.cpp @@ -23,7 +23,7 @@ void tearDown(void) unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD); } -void app_main(void) +extern "C" void app_main(void) { // _______ ___ ___ _____ _ // |_ _\ \ / / \ |_ _| |_ _|__ ___| |_ diff --git a/components/driver/test_apps/legacy_twai/main/test_twai_interactive.c b/components/driver/test_apps/legacy_twai/main/test_twai_interactive.cpp similarity index 84% rename from components/driver/test_apps/legacy_twai/main/test_twai_interactive.c rename to components/driver/test_apps/legacy_twai/main/test_twai_interactive.cpp index b7f7e52bb2..883acfa6bc 100644 --- a/components/driver/test_apps/legacy_twai/main/test_twai_interactive.c +++ b/components/driver/test_apps/legacy_twai/main/test_twai_interactive.cpp @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -16,10 +16,10 @@ #include "soc/soc_caps.h" #include "esp_log.h" -#define TEST_TWAI_TX_PIN 4 -#define TEST_TWAI_RX_PIN 5 +#define TEST_TWAI_TX_PIN GPIO_NUM_4 +#define TEST_TWAI_RX_PIN GPIO_NUM_5 -#if CONFIG_TWAI_ISR_IN_IRAM +#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM static void IRAM_ATTR test_delay_post_cache_disable(void *args) { esp_rom_delay_us(1000); @@ -31,7 +31,7 @@ TEST_CASE("twai_listen_only", "[twai]") twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(TEST_TWAI_TX_PIN, TEST_TWAI_RX_PIN, TWAI_MODE_LISTEN_ONLY); -#if CONFIG_TWAI_ISR_IN_IRAM +#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM g_config.intr_flags |= ESP_INTR_FLAG_IRAM; #endif // listen only mode doesn't need a tx queue @@ -39,7 +39,7 @@ TEST_CASE("twai_listen_only", "[twai]") TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config)); TEST_ESP_OK(twai_start()); -#if CONFIG_TWAI_ISR_IN_IRAM +#if CONFIG_TWAI_ISR_IN_IRAM_LEGACY || CONFIG_TWAI_ISR_IN_IRAM printf("disable flash cache and check if we can still receive the frame\n"); for (int i = 0; i < 100; i++) { unity_utils_run_cache_disable_stub(test_delay_post_cache_disable, NULL); @@ -70,12 +70,12 @@ TEST_CASE("twai_remote_request", "[twai]") TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &bus_handle)); TEST_ESP_OK(twai_start_v2(bus_handle)); - twai_message_t req_msg = { - .identifier = 0x6688, - .data_length_code = 8, - .rtr = true, // remote request - .extd = true,// extended ID - }; + twai_message_t req_msg{}; + req_msg.identifier = 0x6688; + req_msg.data_length_code = 8; + req_msg.rtr = true; // remote request + req_msg.extd = true; // extended ID + TEST_ESP_OK(twai_transmit_v2(bus_handle, &req_msg, portMAX_DELAY)); ESP_LOGI("TWAI", "send remote frame"); diff --git a/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.c b/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp similarity index 82% rename from components/driver/test_apps/legacy_twai/main/test_twai_loop_back.c rename to components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp index 8f2fe4e109..b4192e5f3b 100644 --- a/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.c +++ b/components/driver/test_apps/legacy_twai/main/test_twai_loop_back.cpp @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ +#include #include #include "sdkconfig.h" #include "freertos/FreeRTOS.h" @@ -20,7 +21,7 @@ TEST_CASE("driver_life_cycle", "[twai-loop-back]") { twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK); + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK); printf("install driver\r\n"); TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config)); // can't install the driver multiple times @@ -42,13 +43,13 @@ TEST_CASE("driver_life_cycle", "[twai-loop-back]") TEST_CASE("twai_bit_timing", "[twai-loop-back]") { twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK); - twai_timing_config_t t_config = { - .quanta_resolution_hz = 33333, // invalid resolution - .tseg_1 = 15, - .tseg_2 = 4, - .sjw = 1, - }; + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK); + twai_timing_config_t t_config{}; + t_config.quanta_resolution_hz = 33333; // invalid resolution + t_config.tseg_1 = 15; + t_config.tseg_2 = 4; + t_config.sjw = 1; + TEST_ESP_ERR(ESP_ERR_INVALID_ARG, twai_driver_install(&g_config, &t_config, &f_config)); t_config.quanta_resolution_hz = 2000000; @@ -61,16 +62,17 @@ TEST_CASE("twai_mode_std_no_ack_25kbps", "[twai-loop-back]") twai_timing_config_t t_config = TWAI_TIMING_CONFIG_25KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); // bind the TX and RX to the same GPIO to act like a loopback - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK); + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK); printf("install twai driver\r\n"); TEST_ESP_OK(twai_driver_install(&g_config, &t_config, &f_config)); TEST_ESP_OK(twai_start()); - twai_message_t tx_msg = { - .identifier = 0x123, - .data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}, - .self = true, // Transmitted message will also received by the same node - }; + twai_message_t tx_msg{}; + tx_msg.identifier = 0x123; + uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88}; + memcpy(tx_msg.data, data, sizeof(data)); + tx_msg.self = true; // Transmitted message will also received by the same node + for (int len = 0; len <= 8; len++) { tx_msg.data_length_code = len; printf("TX id %lx len %d\r\n", tx_msg.identifier, tx_msg.data_length_code); @@ -95,19 +97,19 @@ TEST_CASE("twai_mode_ext_no_ack_250kbps", "[twai-loop-back]") twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); // bind the TX and RX to the same GPIO to act like a loopback - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK); - twai_message_t tx_msg = { - .identifier = 0x12345, - .data_length_code = 6, - .data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, - .self = true, // Transmitted message will also received by the same node - .extd = true, // Extended Frame Format (29bit ID) - }; + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK); + twai_message_t tx_msg{}; + tx_msg.identifier = 0x12345; + tx_msg.data_length_code = 6; + uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; + memcpy(tx_msg.data, data, sizeof(data)); + tx_msg.self = true; // Transmitted message will also received by the same node + tx_msg.extd = true; // Extended Frame Format (29bit ID) for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) { g_config.controller_id = i; - g_config.tx_io = i; - g_config.rx_io = i; + g_config.tx_io = static_cast(i); + g_config.rx_io = static_cast(i); printf("install twai driver %d\r\n", g_config.controller_id); TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i])); TEST_ESP_OK(twai_start_v2(twai_buses[i])); @@ -151,20 +153,20 @@ static void s_test_sleep_retention(bool allow_pd) twai_timing_config_t t_config = TWAI_TIMING_CONFIG_250KBITS(); twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); // bind the TX and RX to the same GPIO to act like a loopback - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(0, 0, TWAI_MODE_NO_ACK); + twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_0, TWAI_MODE_NO_ACK); g_config.general_flags.sleep_allow_pd = allow_pd; - twai_message_t tx_msg = { - .identifier = 0x12345, - .data_length_code = 6, - .data = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}, - .self = true, // Transmitted message will also received by the same node - .extd = true, // Extended Frame Format (29bit ID) - }; + twai_message_t tx_msg{}; + tx_msg.identifier = 0x12345; + tx_msg.data_length_code = 6; + uint8_t data[] = {0x11, 0x22, 0x33, 0x44, 0x55, 0x66}; + memcpy(tx_msg.data, data, sizeof(data)); + tx_msg.self = true; // Transmitted message will also received by the same node + tx_msg.extd = true; // Extended Frame Format (29bit ID) for (int i = 0; i < SOC_TWAI_CONTROLLER_NUM; i++) { g_config.controller_id = i; - g_config.tx_io = i; - g_config.rx_io = i; + g_config.tx_io = static_cast(i); + g_config.rx_io = static_cast(i); printf("install twai driver %d\r\n", g_config.controller_id); TEST_ESP_OK(twai_driver_install_v2(&g_config, &t_config, &f_config, &twai_buses[i])); } diff --git a/components/driver/test_apps/legacy_twai/sdkconfig.ci.iram_safe b/components/driver/test_apps/legacy_twai/sdkconfig.ci.iram_safe index bb8cdac9a0..5b3ab1cf58 100644 --- a/components/driver/test_apps/legacy_twai/sdkconfig.ci.iram_safe +++ b/components/driver/test_apps/legacy_twai/sdkconfig.ci.iram_safe @@ -1,5 +1,5 @@ CONFIG_COMPILER_DUMP_RTL_FILES=y -CONFIG_TWAI_ISR_IN_IRAM=y +CONFIG_TWAI_ISR_IN_IRAM_LEGACY=y CONFIG_COMPILER_OPTIMIZATION_NONE=y # silent the error check, as the error string are stored in rodata, causing RTL check failure diff --git a/components/driver/test_apps/touch_sensor_v1/main/CMakeLists.txt b/components/driver/test_apps/touch_sensor_v1/main/CMakeLists.txt index f690e20fa9..44bdedfad4 100644 --- a/components/driver/test_apps/touch_sensor_v1/main/CMakeLists.txt +++ b/components/driver/test_apps/touch_sensor_v1/main/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "test_app_main.c" "test_touch_v1.c" - PRIV_REQUIRES unity driver + PRIV_REQUIRES unity driver esp_pm WHOLE_ARCHIVE ) diff --git a/components/driver/test_apps/touch_sensor_v2/main/CMakeLists.txt b/components/driver/test_apps/touch_sensor_v2/main/CMakeLists.txt index cb731f845f..0eaf4d17eb 100644 --- a/components/driver/test_apps/touch_sensor_v2/main/CMakeLists.txt +++ b/components/driver/test_apps/touch_sensor_v2/main/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "test_app_main.c" "test_touch_v2.c" "touch_scope.c" - PRIV_REQUIRES unity driver + PRIV_REQUIRES unity driver esp_driver_gpio esp_driver_uart WHOLE_ARCHIVE ) diff --git a/components/driver/twai/Kconfig.twai b/components/driver/twai/Kconfig.twai index b825162948..8bcfebe087 100644 --- a/components/driver/twai/Kconfig.twai +++ b/components/driver/twai/Kconfig.twai @@ -1,6 +1,12 @@ menu "Legacy TWAI Driver Configurations" depends on SOC_TWAI_SUPPORTED + config TWAI_ISR_IN_IRAM_LEGACY + bool "Place TWAI ISR function in IRAM" + default n + help + Place the TWAI ISR in to IRAM to reduce latency and increase performance + config TWAI_SKIP_LEGACY_CONFLICT_CHECK bool "Skip legacy driver conflict check" default n diff --git a/components/driver/twai/include/driver/twai.h b/components/driver/twai/include/driver/twai.h index 84a5ecfa5d..a484f95312 100644 --- a/components/driver/twai/include/driver/twai.h +++ b/components/driver/twai/include/driver/twai.h @@ -73,7 +73,7 @@ extern "C" { #define TWAI_ALERT_PERIPH_RESET 0x00010000 /**< Alert(65536): The TWAI controller was reset */ #define TWAI_ALERT_ALL 0x0001FFFF /**< Bit mask to enable all alerts during configuration */ #define TWAI_ALERT_NONE 0x00000000 /**< Bit mask to disable all alerts during configuration */ -#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur. Note that logging from the ISR is disabled if CONFIG_TWAI_ISR_IN_IRAM is enabled (see docs). */ +#define TWAI_ALERT_AND_LOG 0x00020000 /**< Bit mask to enable alerts to also be logged when they occur */ /** @endcond */ diff --git a/components/driver/twai/linker.lf b/components/driver/twai/linker.lf index 4d48d08f3d..2d0c47b0b9 100644 --- a/components/driver/twai/linker.lf +++ b/components/driver/twai/linker.lf @@ -1,7 +1,7 @@ [mapping:twai_driver] archive: libdriver.a entries: - if TWAI_ISR_IN_IRAM = y: + if TWAI_ISR_IN_IRAM = y || TWAI_ISR_IN_IRAM_LEGACY = y: twai: twai_alert_handler (noflash) twai: twai_handle_rx_buffer_frames (noflash) twai: twai_handle_tx_buffer_frame (noflash) @@ -10,7 +10,7 @@ entries: [mapping:twai_hal_legacy] archive: libhal.a entries: - if TWAI_ISR_IN_IRAM = y: + if TWAI_ISR_IN_IRAM = y || TWAI_ISR_IN_IRAM_LEGACY = y: twai_hal_v1: twai_hal_decode_interrupt (noflash) twai_hal_v1: twai_hal_get_events (noflash) twai_hal_v1: twai_hal_format_frame (noflash) @@ -19,6 +19,9 @@ entries: twai_hal_v1: twai_hal_get_rx_msg_count (noflash) twai_hal_v1: twai_hal_read_rx_fifo (noflash) twai_hal_v1: twai_hal_check_state_flags (noflash) + twai_hal_v1: twai_hal_read_rx_fifo (noflash) + twai_hal_v1: twai_hal_check_state_flags (noflash) + twai_hal_v1: twai_hal_clear_rx_fifo_overrun (noflash) if TWAI_ERRATA_FIX_RX_FRAME_INVALID = y || TWAI_ERRATA_FIX_RX_FIFO_CORRUPT = y: twai_hal_v1: twai_hal_prepare_for_reset (noflash) diff --git a/components/driver/twai/twai.c b/components/driver/twai/twai.c index ce23be6b89..dbaba376d1 100644 --- a/components/driver/twai/twai.c +++ b/components/driver/twai/twai.c @@ -47,11 +47,11 @@ #define TWAI_SET_FLAG(var, mask) ((var) |= (mask)) #define TWAI_RESET_FLAG(var, mask) ((var) &= ~(mask)) -#ifdef CONFIG_TWAI_ISR_IN_IRAM +#if defined(CONFIG_TWAI_ISR_IN_IRAM) || defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY) #define TWAI_MALLOC_CAPS (MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT) #else #define TWAI_MALLOC_CAPS MALLOC_CAP_DEFAULT -#endif //CONFIG_TWAI_ISR_IN_IRAM +#endif // CONFIG_TWAI_ISR_IN_IRAM || CONFIG_TWAI_ISR_IN_IRAM_LEGACY #define DRIVER_DEFAULT_INTERRUPTS 0xE7 //Exclude data overrun (bit[3]) and brp_div (bit[4]) @@ -123,7 +123,7 @@ static void twai_alert_handler(twai_obj_t *p_twai_obj, uint32_t alert_code, int //Signify alert has occurred TWAI_SET_FLAG(p_twai_obj->alerts_triggered, alert_code); *alert_req = 1; -#ifndef CONFIG_TWAI_ISR_IN_IRAM //Only log if ISR is not in IRAM +#if !defined(CONFIG_TWAI_ISR_IN_IRAM) && !defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY) //Only log if ISR is not in IRAM if (p_twai_obj->alerts_enabled & TWAI_ALERT_AND_LOG) { if (alert_code >= ALERT_LOG_LEVEL_ERROR) { ESP_EARLY_LOGE(TWAI_TAG, "Alert %" PRIu32, alert_code); @@ -133,7 +133,7 @@ static void twai_alert_handler(twai_obj_t *p_twai_obj, uint32_t alert_code, int ESP_EARLY_LOGI(TWAI_TAG, "Alert %" PRIu32, alert_code); } } -#endif //CONFIG_TWAI_ISR_IN_IRAM +#endif // !CONFIG_TWAI_ISR_IN_IRAM && !CONFIG_TWAI_ISR_IN_IRAM_LEGACY } } @@ -486,7 +486,7 @@ esp_err_t twai_driver_install_v2(const twai_general_config_t *g_config, const tw // 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 +#if !defined(CONFIG_TWAI_ISR_IN_IRAM) && !defined(CONFIG_TWAI_ISR_IN_IRAM_LEGACY) TWAI_CHECK(!(g_config->intr_flags & ESP_INTR_FLAG_IRAM), ESP_ERR_INVALID_ARG); #endif int controller_id = g_config->controller_id; diff --git a/components/esp_driver_cam/test_apps/dvp/main/CMakeLists.txt b/components/esp_driver_cam/test_apps/dvp/main/CMakeLists.txt index 52d18a433b..69ed5c3507 100644 --- a/components/esp_driver_cam/test_apps/dvp/main/CMakeLists.txt +++ b/components/esp_driver_cam/test_apps/dvp/main/CMakeLists.txt @@ -11,6 +11,7 @@ set(priv_requires unity esp_driver_cam esp_psram + esp_driver_ledc ) idf_component_register(SRCS ${srcs} diff --git a/components/esp_driver_gptimer/src/gptimer.c b/components/esp_driver_gptimer/src/gptimer.c index 8913ff04ef..bd47680aed 100644 --- a/components/esp_driver_gptimer/src/gptimer.c +++ b/components/esp_driver_gptimer/src/gptimer.c @@ -76,7 +76,7 @@ static esp_err_t gptimer_register_to_group(gptimer_t *timer) .depends = RETENTION_MODULE_BITMAP_INIT(CLOCK_SYSTEM) }; if (sleep_retention_module_init(module, &init_param) != ESP_OK) { - // even though the sleep retention module init failed, RMT driver should still work, so just warning here + // even though the sleep retention module init failed, gptimer driver should still work, so just warning here ESP_LOGW(TAG, "init sleep retention failed on TimerGroup%d Timer%d, power domain may be turned off during sleep", group->group_id, timer_id); } #endif // GPTIMER_USE_RETENTION_LINK diff --git a/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/CMakeLists.txt b/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/CMakeLists.txt index b6f45ab7cb..2d0609bc41 100644 --- a/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/CMakeLists.txt +++ b/components/esp_driver_i2s/test_apps/i2s_multi_dev/main/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRCS "test_app_main.c" "test_i2s_multi_dev.c" - PRIV_REQUIRES unity driver test_utils + PRIV_REQUIRES unity test_utils esp_driver_gpio esp_driver_i2s INCLUDE_DIRS "." WHOLE_ARCHIVE ) diff --git a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/CMakeLists.txt b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/CMakeLists.txt index 28932ca2ce..78a3742fed 100644 --- a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/CMakeLists.txt +++ b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/CMakeLists.txt @@ -2,5 +2,5 @@ set(srcs "test_app_main.c" "test_sdio_sdhost.c") idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity test_driver_utils driver esp_serial_slave_link sdmmc test_utils esp_timer + PRIV_REQUIRES unity esp_serial_slave_link test_utils esp_timer esp_driver_sdmmc WHOLE_ARCHIVE) diff --git a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/idf_component.yml b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/idf_component.yml index 3939983aa9..8014719218 100644 --- a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/idf_component.yml +++ b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/host_sdmmc/main/idf_component.yml @@ -1,3 +1,5 @@ dependencies: ccomp_timer: "^1.0.0" espressif/esp_serial_slave_link: "^1.1.0" + test_driver_utils: + path: ${IDF_PATH}/components/driver/test_apps/components/test_driver_utils diff --git a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/sdio/main/CMakeLists.txt b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/sdio/main/CMakeLists.txt index 0822f3336a..2576cb3e98 100644 --- a/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/sdio/main/CMakeLists.txt +++ b/components/esp_driver_sdio/test_apps/sdio/sdio_common_tests/sdio/main/CMakeLists.txt @@ -2,5 +2,5 @@ set(srcs "test_app_main.c" "test_sdio_slave.c") idf_component_register(SRCS ${srcs} - PRIV_REQUIRES test_driver_utils driver esp_hw_support + PRIV_REQUIRES test_driver_utils esp_hw_support esp_driver_sdio WHOLE_ARCHIVE) diff --git a/components/esp_driver_spi/test_apps/master/main/CMakeLists.txt b/components/esp_driver_spi/test_apps/master/main/CMakeLists.txt index cc99e1467a..f0d824d614 100644 --- a/components/esp_driver_spi/test_apps/master/main/CMakeLists.txt +++ b/components/esp_driver_spi/test_apps/master/main/CMakeLists.txt @@ -16,6 +16,6 @@ endif() # the component can be registered as WHOLE_ARCHIVE idf_component_register( SRCS ${srcs} - PRIV_REQUIRES esp_driver_spi spi_flash esp_timer + PRIV_REQUIRES esp_driver_spi spi_flash esp_timer esp_driver_gpio WHOLE_ARCHIVE ) diff --git a/components/esp_driver_spi/test_apps/slave/main/CMakeLists.txt b/components/esp_driver_spi/test_apps/slave/main/CMakeLists.txt index 3c0adce084..1d2292e4f9 100644 --- a/components/esp_driver_spi/test_apps/slave/main/CMakeLists.txt +++ b/components/esp_driver_spi/test_apps/slave/main/CMakeLists.txt @@ -10,6 +10,6 @@ set(srcs # the component can be registered as WHOLE_ARCHIVE idf_component_register( SRCS ${srcs} - PRIV_REQUIRES esp_driver_spi spi_flash + PRIV_REQUIRES esp_driver_spi spi_flash esp_driver_gpio WHOLE_ARCHIVE ) diff --git a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/CMakeLists.txt b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/CMakeLists.txt index eb0652f6ac..b1736844e1 100644 --- a/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/CMakeLists.txt +++ b/components/esp_driver_usb_serial_jtag/test_apps/usb_serial_jtag/main/CMakeLists.txt @@ -2,6 +2,6 @@ # the component can be registered as WHOLE_ARCHIVE idf_component_register( SRCS "test_app_main.c" "test_usb_serial_jtag.c" - REQUIRES driver unity vfs esp_timer + REQUIRES unity vfs esp_timer esp_driver_usb_serial_jtag WHOLE_ARCHIVE ) diff --git a/components/esp_event/test_apps/main/CMakeLists.txt b/components/esp_event/test_apps/main/CMakeLists.txt index 2db0197b0f..655140a972 100644 --- a/components/esp_event/test_apps/main/CMakeLists.txt +++ b/components/esp_event/test_apps/main/CMakeLists.txt @@ -8,7 +8,7 @@ if(NOT ${target} STREQUAL "linux") "test_event_target.c") list(APPEND priv_requires - "driver" + "esp_driver_gptimer" "esp_timer" "test_utils") endif() diff --git a/components/esp_hw_support/test_apps/rtc_power_modes/main/CMakeLists.txt b/components/esp_hw_support/test_apps/rtc_power_modes/main/CMakeLists.txt index ae51e0fd58..cd7902d5e1 100644 --- a/components/esp_hw_support/test_apps/rtc_power_modes/main/CMakeLists.txt +++ b/components/esp_hw_support/test_apps/rtc_power_modes/main/CMakeLists.txt @@ -4,5 +4,5 @@ set(srcs "test_app_main.c" # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity esp_driver_uart driver + PRIV_REQUIRES unity esp_driver_uart esp_driver_ledc WHOLE_ARCHIVE) diff --git a/components/esp_lcd/test_apps/i80_lcd/main/CMakeLists.txt b/components/esp_lcd/test_apps/i80_lcd/main/CMakeLists.txt index 2a3cea972d..dbbd5aa92d 100644 --- a/components/esp_lcd/test_apps/i80_lcd/main/CMakeLists.txt +++ b/components/esp_lcd/test_apps/i80_lcd/main/CMakeLists.txt @@ -4,5 +4,5 @@ set(srcs "test_app_main.c" # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES esp_lcd unity driver esp_driver_i2s + PRIV_REQUIRES esp_lcd unity esp_driver_i2s WHOLE_ARCHIVE) diff --git a/components/esp_lcd/test_apps/parlio_lcd/main/CMakeLists.txt b/components/esp_lcd/test_apps/parlio_lcd/main/CMakeLists.txt index cf9b3cc0c7..39be772011 100644 --- a/components/esp_lcd/test_apps/parlio_lcd/main/CMakeLists.txt +++ b/components/esp_lcd/test_apps/parlio_lcd/main/CMakeLists.txt @@ -4,5 +4,5 @@ set(srcs "test_app_main.c" # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES esp_lcd unity driver esp_driver_parlio + PRIV_REQUIRES esp_lcd unity esp_driver_parlio WHOLE_ARCHIVE) diff --git a/components/esp_lcd/test_apps/rgb_lcd/main/CMakeLists.txt b/components/esp_lcd/test_apps/rgb_lcd/main/CMakeLists.txt index 084940a1c2..a91450ae34 100644 --- a/components/esp_lcd/test_apps/rgb_lcd/main/CMakeLists.txt +++ b/components/esp_lcd/test_apps/rgb_lcd/main/CMakeLists.txt @@ -8,5 +8,5 @@ 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} - PRIV_REQUIRES esp_lcd unity driver esp_timer spi_flash + PRIV_REQUIRES esp_lcd unity esp_timer spi_flash WHOLE_ARCHIVE) diff --git a/components/esp_libc/test_apps/newlib/main/CMakeLists.txt b/components/esp_libc/test_apps/newlib/main/CMakeLists.txt index 474b1050f9..09ead453fc 100644 --- a/components/esp_libc/test_apps/newlib/main/CMakeLists.txt +++ b/components/esp_libc/test_apps/newlib/main/CMakeLists.txt @@ -22,5 +22,5 @@ if(CONFIG_LIBC_OPTIMIZED_MISALIGNED_ACCESS) endif() idf_component_register(SRCS "${srcs}" - PRIV_REQUIRES unity vfs cmock driver esp_timer spi_flash test_utils pthread esp_psram + PRIV_REQUIRES unity vfs cmock esp_timer spi_flash test_utils pthread esp_psram WHOLE_ARCHIVE) diff --git a/components/esp_mm/test_apps/mm/main/CMakeLists.txt b/components/esp_mm/test_apps/mm/main/CMakeLists.txt index abf19b3ad3..c3ffe7631f 100644 --- a/components/esp_mm/test_apps/mm/main/CMakeLists.txt +++ b/components/esp_mm/test_apps/mm/main/CMakeLists.txt @@ -13,5 +13,5 @@ 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} - PRIV_REQUIRES unity esp_partition spi_flash esp_mm driver esp_timer test_mm_utils test_utils + PRIV_REQUIRES unity esp_partition spi_flash esp_mm esp_timer test_mm_utils test_utils WHOLE_ARCHIVE) diff --git a/components/esp_netif/test_apps/test_app_vfs_l2tap/main/CMakeLists.txt b/components/esp_netif/test_apps/test_app_vfs_l2tap/main/CMakeLists.txt index d36d43f5fb..9d6acb33ac 100644 --- a/components/esp_netif/test_apps/test_app_vfs_l2tap/main/CMakeLists.txt +++ b/components/esp_netif/test_apps/test_app_vfs_l2tap/main/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRC_DIRS "." PRIV_INCLUDE_DIRS "." - PRIV_REQUIRES cmock test_utils esp_netif driver esp_eth) + PRIV_REQUIRES cmock test_utils esp_netif esp_eth esp_driver_gpio) diff --git a/components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt b/components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt index 48c7ad8ed7..c55abb96b0 100644 --- a/components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt +++ b/components/esp_pm/test_apps/esp_pm/main/CMakeLists.txt @@ -5,5 +5,5 @@ set(sources "test_app_main.c" # the component must be registered as a WHOLE_ARCHIVE idf_component_register(SRCS ${sources} INCLUDE_DIRS "." - PRIV_REQUIRES unity esp_pm ulp driver esp_timer esp_psram + PRIV_REQUIRES unity esp_pm ulp esp_timer esp_psram esp_driver_gptimer WHOLE_ARCHIVE) diff --git a/components/esp_psram/test_apps/psram/main/CMakeLists.txt b/components/esp_psram/test_apps/psram/main/CMakeLists.txt index 4bf51e380b..a200c1105e 100644 --- a/components/esp_psram/test_apps/psram/main/CMakeLists.txt +++ b/components/esp_psram/test_apps/psram/main/CMakeLists.txt @@ -15,5 +15,5 @@ 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} - PRIV_REQUIRES unity esp_psram spi_flash driver esp_partition + PRIV_REQUIRES unity esp_psram spi_flash esp_partition esp_driver_spi esp_driver_gptimer WHOLE_ARCHIVE) diff --git a/components/fatfs/test_apps/sdcard/main/CMakeLists.txt b/components/fatfs/test_apps/sdcard/main/CMakeLists.txt index e4a519cb39..f6bd337523 100644 --- a/components/fatfs/test_apps/sdcard/main/CMakeLists.txt +++ b/components/fatfs/test_apps/sdcard/main/CMakeLists.txt @@ -1,6 +1,6 @@ idf_component_register(SRCS "test_fatfs_sdcard_main.c" "test_fatfs_sdspi.c" INCLUDE_DIRS "." - PRIV_REQUIRES unity fatfs vfs sdmmc driver test_fatfs_common esp_timer + PRIV_REQUIRES unity fatfs vfs sdmmc test_fatfs_common esp_timer WHOLE_ARCHIVE) if(CONFIG_SOC_SDMMC_HOST_SUPPORTED) diff --git a/components/freertos/test_apps/freertos/kernel/CMakeLists.txt b/components/freertos/test_apps/freertos/kernel/CMakeLists.txt index f8ab455c50..ac17ddcf9e 100644 --- a/components/freertos/test_apps/freertos/kernel/CMakeLists.txt +++ b/components/freertos/test_apps/freertos/kernel/CMakeLists.txt @@ -19,5 +19,5 @@ set(priv_include_dirs # the final elf, the component can be registered as WHOLE_ARCHIVE idf_component_register(SRC_DIRS ${src_dirs} PRIV_INCLUDE_DIRS ${priv_include_dirs} - PRIV_REQUIRES test_utils driver + PRIV_REQUIRES test_utils esp_driver_gptimer WHOLE_ARCHIVE) diff --git a/components/hal/test_apps/tee/components/pms_and_cpu_intr/CMakeLists.txt b/components/hal/test_apps/tee/components/pms_and_cpu_intr/CMakeLists.txt index 26e0306b41..ea655ee657 100644 --- a/components/hal/test_apps/tee/components/pms_and_cpu_intr/CMakeLists.txt +++ b/components/hal/test_apps/tee/components/pms_and_cpu_intr/CMakeLists.txt @@ -22,6 +22,7 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "include" "priv_include" PRIV_INCLUDE_DIRS "priv_include/${target}" REQUIRES ulp unity + PRIV_REQUIRES esp_hal_timg LDFRAGMENTS linker.lf) if(CONFIG_ULP_COPROC_ENABLED) diff --git a/components/openthread/CMakeLists.txt b/components/openthread/CMakeLists.txt index 54e8f99d8a..26770f273a 100644 --- a/components/openthread/CMakeLists.txt +++ b/components/openthread/CMakeLists.txt @@ -277,7 +277,7 @@ idf_component_register(SRC_DIRS "${src_dirs}" EXCLUDE_SRCS "${exclude_srcs}" INCLUDE_DIRS "${public_include_dirs}" PRIV_INCLUDE_DIRS "${private_include_dirs}" - REQUIRES esp_netif lwip esp_driver_uart driver + REQUIRES esp_netif lwip esp_driver_uart esp_driver_gpio esp_driver_spi esp_driver_usb_serial_jtag LDFRAGMENTS linker.lf PRIV_REQUIRES console esp_coex esp_event esp_partition esp_timer ieee802154 mbedtls nvs_flash) diff --git a/components/spi_flash/test_apps/esp_flash/main/CMakeLists.txt b/components/spi_flash/test_apps/esp_flash/main/CMakeLists.txt index 9e4bf2b015..2ce0e78672 100644 --- a/components/spi_flash/test_apps/esp_flash/main/CMakeLists.txt +++ b/components/spi_flash/test_apps/esp_flash/main/CMakeLists.txt @@ -5,5 +5,6 @@ set(srcs "test_app_main.c" # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity test_utils spi_flash esp_timer driver bootloader_support + PRIV_REQUIRES unity test_utils spi_flash esp_timer esp_driver_gpio esp_driver_spi + bootloader_support WHOLE_ARCHIVE) diff --git a/components/spi_flash/test_apps/flash_suspend/main/CMakeLists.txt b/components/spi_flash/test_apps/flash_suspend/main/CMakeLists.txt index 5589773e47..797abc6094 100644 --- a/components/spi_flash/test_apps/flash_suspend/main/CMakeLists.txt +++ b/components/spi_flash/test_apps/flash_suspend/main/CMakeLists.txt @@ -4,5 +4,5 @@ set(srcs "test_app_main.c" # In order for the cases defined by `TEST_CASE` to be linked into the final elf, # the component can be registered as WHOLE_ARCHIVE idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity test_utils spi_flash driver esp_partition esp_driver_i2c esp_driver_gptimer + PRIV_REQUIRES unity test_utils spi_flash esp_partition esp_driver_i2c esp_driver_gptimer WHOLE_ARCHIVE) diff --git a/components/spi_flash/test_apps/mspi_test/main/CMakeLists.txt b/components/spi_flash/test_apps/mspi_test/main/CMakeLists.txt index 10af23bbe6..78836bc116 100644 --- a/components/spi_flash/test_apps/mspi_test/main/CMakeLists.txt +++ b/components/spi_flash/test_apps/mspi_test/main/CMakeLists.txt @@ -4,5 +4,5 @@ set(srcs "test_out_of_bounds_write.c" "test_app_main.c") idf_component_register(SRCS ${srcs} - PRIV_REQUIRES unity spi_flash driver esp_partition bootloader_support app_update + PRIV_REQUIRES unity spi_flash esp_partition bootloader_support app_update esp_hal_timg WHOLE_ARCHIVE) diff --git a/components/ulp/CMakeLists.txt b/components/ulp/CMakeLists.txt index 6678dece66..53bbed2899 100644 --- a/components/ulp/CMakeLists.txt +++ b/components/ulp/CMakeLists.txt @@ -96,4 +96,4 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} - REQUIRES driver esp_adc) + REQUIRES esp_adc esp_driver_gpio esp_driver_uart esp_driver_i2s esp_hal_i2c) diff --git a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/CMakeLists.txt b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/CMakeLists.txt index 2c9e9222f2..2c631e90b5 100644 --- a/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/CMakeLists.txt +++ b/components/ulp/test_apps/lp_core/lp_core_basic_tests/main/CMakeLists.txt @@ -61,6 +61,7 @@ endif() idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "lp_core" REQUIRES ulp unity esp_timer test_utils + PRIV_REQUIRES driver esp_driver_gptimer esp_driver_tsens WHOLE_ARCHIVE EMBED_FILES "test_vad_8k.pcm") diff --git a/components/ulp/test_apps/ulp_riscv/main/CMakeLists.txt b/components/ulp/test_apps/ulp_riscv/main/CMakeLists.txt index ff7fe44941..b7b4be9ee3 100644 --- a/components/ulp/test_apps/ulp_riscv/main/CMakeLists.txt +++ b/components/ulp/test_apps/ulp_riscv/main/CMakeLists.txt @@ -6,7 +6,7 @@ set(ulp_sources4 "ulp/test_main_i2c.c") idf_component_register(SRCS ${app_sources} INCLUDE_DIRS "ulp" - REQUIRES ulp unity test_utils + REQUIRES ulp unity test_utils driver WHOLE_ARCHIVE) set(ulp_app_name ulp_test_app) diff --git a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst index bc110cb187..ef7f96aa31 100644 --- a/docs/en/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/en/migration-guides/release-6.x/6.0/peripherals.rst @@ -6,6 +6,37 @@ Peripherals Common Changes -------------- +Legacy Driver Dependencies Removal +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The legacy driver component :component:`driver` has been deprecated and no longer contains public dependencies on the following driver components: + +.. list:: + :class: no-bullet + + - :component:`esp_driver_ana_cmpr` + - :component:`esp_driver_dac` + - :component:`esp_driver_gptimer` + - :component:`esp_driver_i2s` + - :component:`esp_driver_ledc` + - :component:`esp_driver_mcpwm` + - :component:`esp_driver_parlio` + - :component:`esp_driver_pcnt` + - :component:`esp_driver_rmt` + - :component:`esp_driver_sdio` + - :component:`esp_driver_sdm` + - :component:`esp_driver_sdmmc` + - :component:`esp_driver_sdspi` + - :component:`esp_driver_spi` + - :component:`esp_driver_tsens` + - :component:`esp_driver_twai` + - :component:`esp_driver_uart` + - :component:`esp_driver_usb_serial_jtag` + +If your project uses legacy :component:`driver` component, it is strongly recommended to remove :component:`driver` component dependencies, and add new driver component (usually ``esp_driver_xxx``) dependencies to your project. + +If you still need to keep legacy :component:`driver` component (e.g. your project depends on the legacy ``i2c`` driver), please keep the :component:`driver` component remaining in the dependency list of your project (usually ``/main/CMakeLists.txt``), and manually add component dependencies that are no longer included in :component:`driver` as needed. + All drivers' ``io_loop_back`` configuration have been removed ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/docs/zh_CN/migration-guides/release-5.x/5.0/build-system.rst b/docs/zh_CN/migration-guides/release-5.x/5.0/build-system.rst index 43ee713096..4ffa392f6b 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.0/build-system.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.0/build-system.rst @@ -1,4 +1,4 @@ -迁移构建系统至 ESP-IDF v5.0 +构建系统 =================================== 从 GNU Make 构建系统迁移至 ESP-IDF v5.0 diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/build-system.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/build-system.rst index da868d84d4..5456d5cadb 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/build-system.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/build-system.rst @@ -1,4 +1,4 @@ -迁移构建系统至 ESP-IDF v6.0 +构建系统 =================================== :link_to_translation:`en:[English]` diff --git a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst index ff0b656d7e..991dfc530f 100644 --- a/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-6.x/6.0/peripherals.rst @@ -6,6 +6,37 @@ 公共变化 -------- +旧版驱动依赖移除 +~~~~~~~~~~~~~~~~ + +旧版驱动组件 :component:`driver` 已被弃用,不再包含对以下驱动组件的公共依赖: + +.. list:: + :class: no-bullet + + - :component:`esp_driver_ana_cmpr` + - :component:`esp_driver_dac` + - :component:`esp_driver_gptimer` + - :component:`esp_driver_i2s` + - :component:`esp_driver_ledc` + - :component:`esp_driver_mcpwm` + - :component:`esp_driver_parlio` + - :component:`esp_driver_pcnt` + - :component:`esp_driver_rmt` + - :component:`esp_driver_sdio` + - :component:`esp_driver_sdm` + - :component:`esp_driver_sdmmc` + - :component:`esp_driver_sdspi` + - :component:`esp_driver_spi` + - :component:`esp_driver_tsens` + - :component:`esp_driver_twai` + - :component:`esp_driver_uart` + - :component:`esp_driver_usb_serial_jtag` + +如果您的项目使用了老旧的 :component:`driver` 驱动组件,强烈建议移除对 :component:`driver` 驱动组件的依赖,并为项目添加新驱动组件(通常是 ``esp_driver_xxx``)的依赖。 + +如仍需保留老旧的 :component:`driver` 驱动组件(例如您的项目依赖旧版 ``i2c`` 驱动),请将 :component:`driver` 组件保留在项目的组件依赖列表文件中(通常是 ``/main/CMakeLists.txt`` ),并根据项目需要手动添加 :component:`driver` 中不再包含的驱动组件依赖。 + 所有驱动的 ``io_loop_back`` 配置已被移除 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/examples/bluetooth/nimble/ble_cte/common_components/cte_config/CMakeLists.txt b/examples/bluetooth/nimble/ble_cte/common_components/cte_config/CMakeLists.txt index add8078385..d277fe081b 100644 --- a/examples/bluetooth/nimble/ble_cte/common_components/cte_config/CMakeLists.txt +++ b/examples/bluetooth/nimble/ble_cte/common_components/cte_config/CMakeLists.txt @@ -1,4 +1,3 @@ idf_component_register(SRCS "cte_config.c" - INCLUDE_DIRS . - PRIV_REQUIRES driver bt - ) + INCLUDE_DIRS . + PRIV_REQUIRES bt esp_driver_gpio) diff --git a/examples/peripherals/camera/dvp_spi_lcd/main/CMakeLists.txt b/examples/peripherals/camera/dvp_spi_lcd/main/CMakeLists.txt index e863a9baee..526570d89c 100644 --- a/examples/peripherals/camera/dvp_spi_lcd/main/CMakeLists.txt +++ b/examples/peripherals/camera/dvp_spi_lcd/main/CMakeLists.txt @@ -1,4 +1,5 @@ idf_component_register(SRCS "dvp_spi_lcd_main.c" INCLUDE_DIRS "." - REQUIRES esp_mm esp_driver_cam esp_driver_i2c esp_lcd sensor_init + REQUIRES esp_mm esp_driver_cam esp_driver_i2c esp_lcd + PRIV_REQUIRES esp_driver_ledc ) diff --git a/examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm/main/idf_component.yml b/examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm/main/idf_component.yml index 61347b9475..af877bcec3 100644 --- a/examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm/main/idf_component.yml +++ b/examples/peripherals/i2s/i2s_codec/i2s_es7210_tdm/main/idf_component.yml @@ -1,5 +1,5 @@ ## IDF Component Manager Manifest File dependencies: - espressif/esp_codec_dev: ">=1.4.0,<1.5.0" + espressif/esp_codec_dev: ">=1.5.0" i2s_examples_common: path: ${IDF_PATH}/examples/peripherals/i2s/i2s_examples_common diff --git a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml index 4beea621a6..aaa5f704b6 100644 --- a/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml +++ b/examples/peripherals/mcpwm/mcpwm_bdc_speed_control/main/idf_component.yml @@ -1,3 +1,3 @@ dependencies: pid_ctrl: "^0.1.1" - bdc_motor: "^0.1.0" + bdc_motor: "^0.2.0" diff --git a/examples/system/ulp/lp_core/gpio_wakeup/main/CMakeLists.txt b/examples/system/ulp/lp_core/gpio_wakeup/main/CMakeLists.txt index 9970ae3eff..b74511c65f 100644 --- a/examples/system/ulp/lp_core/gpio_wakeup/main/CMakeLists.txt +++ b/examples/system/ulp/lp_core/gpio_wakeup/main/CMakeLists.txt @@ -1,7 +1,7 @@ # Set usual component variables set(COMPONENT_SRCS "lp_core_gpio_wake_up_example_main.c") set(COMPONENT_ADD_INCLUDEDIRS "") -set(COMPONENT_REQUIRES ulp driver) +set(COMPONENT_REQUIRES ulp) register_component() diff --git a/examples/system/ulp/ulp_riscv/touch/main/CMakeLists.txt b/examples/system/ulp/ulp_riscv/touch/main/CMakeLists.txt index ce6913430e..8cea317d7b 100644 --- a/examples/system/ulp/ulp_riscv/touch/main/CMakeLists.txt +++ b/examples/system/ulp/ulp_riscv/touch/main/CMakeLists.txt @@ -1,6 +1,7 @@ # Register the component idf_component_register(SRCS "ulp_riscv_touch_example_main.c" INCLUDE_DIRS "" + PRIV_REQUIRES driver REQUIRES ulp) # diff --git a/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml b/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml index bfdc772840..b025d290a5 100644 --- a/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml +++ b/examples/zigbee/light_sample/HA_on_off_light/main/idf_component.yml @@ -2,7 +2,7 @@ dependencies: espressif/esp-zboss-lib: "~1.6.0" espressif/esp-zigbee-lib: "~1.6.0" - espressif/led_strip: "~2.0.0" + espressif/led_strip: "~3.0.0" ## Required IDF version idf: version: ">=5.0.0" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index 4cbbd9778d..2ed364c1ed 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -945,7 +945,6 @@ tools/ldgen/test/data/linker_script.ld tools/test_apps/build_system/embed_test/main/test_main.c tools/test_apps/build_system/ldgen_test/main/src1.c tools/test_apps/build_system/ldgen_test/main/src2.c -tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c tools/test_apps/protocols/esp_netif/build_config/main/init_macro.h tools/test_apps/protocols/esp_netif/build_config/main/main.cpp tools/test_apps/protocols/esp_netif/build_config/main/netif_init_c99.c diff --git a/tools/test_apps/peripherals/.build-test-rules.yml b/tools/test_apps/peripherals/.build-test-rules.yml deleted file mode 100644 index 4519409689..0000000000 --- a/tools/test_apps/peripherals/.build-test-rules.yml +++ /dev/null @@ -1,8 +0,0 @@ -# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps - -tools/test_apps/peripherals/i2c_wifi: - disable: - - if: SOC_I2C_SUPPORTED != 1 or SOC_WIFI_SUPPORTED != 1 - disable_test: - - if: IDF_TARGET == "esp32c61" - reason: lack of runner diff --git a/tools/test_apps/peripherals/i2c_wifi/CMakeLists.txt b/tools/test_apps/peripherals/i2c_wifi/CMakeLists.txt deleted file mode 100644 index a4cf5b78c6..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/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.22) - -include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(i2c_wifi_main) diff --git a/tools/test_apps/peripherals/i2c_wifi/README.md b/tools/test_apps/peripherals/i2c_wifi/README.md deleted file mode 100644 index fd5ce5dc51..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/README.md +++ /dev/null @@ -1,161 +0,0 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C5 | ESP32-C6 | ESP32-C61 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | --------- | -------- | -------- | - -# I2C-WIFI Test - -## Overview - -This test demonstrates basic usage of I2C driver with wifi softAP. - -### I2C MASTER - -1. Switch on wifi softAP, and connect to your personal device, like your mobile phone. -2. Send data to slave board. - -### I2C SLAVE - -1. Receive data from master board. - -## How to use test - -### Hardware Required - -To run this test, you should have at least one ESP development board for master. But to make this test convenient, we also use a ESP development board for slave. (You can change your slave device, but don't forget to change code as well if necessary.) - -#### Pin Assignment - -**Note:** The following pin assignments are used by default, you can change these in the `menuconfig` . - -| | SDA | SCL | -| ------------------ | ------ | ------ | -| ESP32/ESP32-S2 I2C | GPIO18 | GPIO19 | -| ESP32-S3 I2C | GPIO1 | GPIO2 | -| ESP32-C3 I2C | GPIO5 | GPIO9 | - -**Note:** It is recommended to add external pull-up resistors for SDA/SCL pins to make the communication more stable, though the driver will enable internal pull-up resistors. - -### Configure the project - -Open the project configuration menu (`idf.py menuconfig`). Then go into `Test Configuration` menu. - -#### I2C MASTER configuration - -- In the `I2C working mode select` menu, you can set the working mode of i2c, choose `i2c master mode`. -- In the `I2C Configuration` menu, you can set the pin number of SDA/SCL. Also you can modify the I2C port number and frequency of the master. And you can set the slave address here as well. -- Enable `WIFI AP` if you need it. -- In the `WIFI softAP Configuration` menu, you can set the wifi information here. - -#### I2C SLAVE configuration - -- In the `I2C working mode select` menu, you can set the working mode of i2c, choose `i2c slave mode`. -- In the `I2C Configuration` menu, you can set the pin number of SDA/SCL. Also you can modify the I2C port number and address of the slave. - -### Build and Flash - -Enter `idf.py -p PORT flash monitor` to build, flash and monitor the project. - -(To exit the serial monitor, type ``Ctrl-]``.) - -See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/latest/get-started/index.html) for full steps to configure and use ESP-IDF to build projects. - -## Test Output - -### MASTER - -```bash -I (339) cpu_start: Starting scheduler. -I (359) I2C-wifi test: ESP_WIFI_MODE_AP -I (359) pp: pp rom version: 9387209 -I (359) net80211: net80211 rom version: 9387209 -I (369) wifi:wifi driver task: 3fc9def0, prio:23, stack:6656, core=0 -I (369) system_api: Base MAC address is not set -I (379) system_api: read default base MAC address from EFUSE -I (379) wifi:wifi firmware version: d062fdb -I (389) wifi:wifi certification version: v7.0 -I (389) wifi:config NVS flash: enabled -I (389) wifi:config nano formatting: disabled -I (399) wifi:Init data frame dynamic rx buffer num: 32 -I (399) wifi:Init management frame dynamic rx buffer num: 32 -I (409) wifi:Init management short buffer num: 32 -I (409) wifi:Init dynamic tx buffer num: 32 -I (419) wifi:Init static tx FG buffer num: 2 -I (419) wifi:Init static rx buffer size: 1600 -I (419) wifi:Init static rx buffer num: 10 -I (429) wifi:Init dynamic rx buffer num: 32 -I (429) wifi_init: rx ba win: 6 -I (439) wifi_init: tcpip mbox: 32 -I (439) wifi_init: udp mbox: 6 -I (439) wifi_init: tcp mbox: 6 -I (449) wifi_init: tcp tx win: 5744 -I (449) wifi_init: tcp rx win: 5744 -I (459) wifi_init: tcp mss: 1440 -I (459) wifi_init: WiFi IRAM OP enabled -I (459) wifi_init: WiFi RX IRAM OP enabled -I (469) phy_init: phy_version 500,985899c,Apr 19 2021,16:05:08 -I (589) wifi:set rx active PTI: 0, rx ack PTI: 0, and default PTI: 0 -I (599) wifi:mode : softAP (7c:df:a1:86:d8:a9) -I (599) wifi:Total power save buffer number: 16 -I (599) wifi:Init max length of beacon: 752/752 -I (599) wifi:Init max length of beacon: 752/752 -I (609) I2C-wifi test: wifi_init_softap finished. SSID:myssid password:mypassword channel:1 -``` - -### SLAVE - -```bash -I (277) cpu_start: Starting scheduler. -the clk config is 0, speed is 0 -slave mode.read thread start... -I (23609) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23619) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23629) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23639) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23649) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23659) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23669) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23679) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23689) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23699) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23709) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23719) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23729) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23739) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23749) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23759) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23769) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23779) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23789) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23799) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23809) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23819) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23829) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23839) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23849) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23859) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23869) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23879) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23889) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23899) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23909) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23919) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23929) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23939) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23949) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23959) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23969) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23979) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23989) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (23999) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24009) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24019) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24029) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24039) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24049) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24059) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24069) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24079) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24089) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24099) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24109) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -I (24119) I2C-wifi test: 6a 1b 05 1f 1f 08 01 20 19 03 27 -``` \ No newline at end of file diff --git a/tools/test_apps/peripherals/i2c_wifi/main/CMakeLists.txt b/tools/test_apps/peripherals/i2c_wifi/main/CMakeLists.txt deleted file mode 100644 index 54d401929f..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/main/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -idf_component_register(SRCS "i2c_wifi_main.c" - INCLUDE_DIRS "") diff --git a/tools/test_apps/peripherals/i2c_wifi/main/Kconfig.projbuild b/tools/test_apps/peripherals/i2c_wifi/main/Kconfig.projbuild deleted file mode 100644 index 773a0ed916..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/main/Kconfig.projbuild +++ /dev/null @@ -1,89 +0,0 @@ -menu "Test Configuration" - - choice TEST_I2C_WORK_MODE - prompt "I2C working mode select" - default TEST_I2C_MASTER_MODE - - config TEST_I2C_MASTER_MODE - bool "i2c master mode" - config TEST_I2C_SLAVE_MODE - bool "I2C slave mode" - endchoice - - menu "I2C Configuration" - - orsource "$IDF_PATH/examples/common_components/env_caps/$IDF_TARGET/Kconfig.env_caps" - - config TEST_I2C_SCL_NUM - int "SCL GPIO Num" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 2 if IDF_TARGET_ESP32S3 - default 19 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 - default 9 - help - GPIO number for I2C Master clock line. - - config TEST_I2C_SDA_NUM - int "SDA GPIO Num" - range ENV_GPIO_RANGE_MIN ENV_GPIO_OUT_RANGE_MAX - default 1 if IDF_TARGET_ESP32S3 - default 18 if IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 - default 5 - help - GPIO number for I2C Master data line. - - config TEST_I2C_PORT_NUM - int "Port Number" - default 0 - help - Port number for I2C Master device. - - config TEST_I2C_MASTER_FREQUENCY - int "Master Frequency" - default 400000 - depends on TEST_I2C_MASTER_MODE - help - I2C Speed of Master device. - - config TEST_I2C_SLAVE_ADDR - hex "ESP Slave Address" - default 0x58 - help - Hardware Address of I2C Slave Port. - endmenu - - config TEST_I2C_WIFI_AP_ENABLE - bool "Enable WIFI AP" - default y - # C6 has not supported WIFI yet. - depends on TEST_I2C_MASTER_MODE && !IDF_TARGET_ESP32C6 - - menu "WiFi softAP Configuration" - depends on TEST_I2C_WIFI_AP_ENABLE - - config TEST_WIFI_SSID - string "WiFi SSID" - default "myssid" - help - SSID (network name) for the test to connect to. - - config TEST_WIFI_PASSWORD - string "WiFi Password" - default "mypassword" - help - WiFi password (WPA or WPA2) for the test to use. - config TEST_WIFI_CHANNEL - int "WiFi Channel" - range 1 13 - default 1 - help - WiFi channel (network channel) for the test to use. - - config TEST_MAX_STA_CONN - int "Maximal STA connections" - default 4 - help - Max number of the STA connects to AP. - endmenu - -endmenu diff --git a/tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c b/tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c deleted file mode 100644 index 0467a5374d..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/main/i2c_wifi_main.c +++ /dev/null @@ -1,247 +0,0 @@ -/* I2C-WIFI - Test*/ - -#include -#include -#include -#include "freertos/FreeRTOS.h" -#include "freertos/task.h" -#include "esp_mac.h" -#include "esp_wifi.h" -#include "esp_event.h" -#include "esp_log.h" -#include "nvs_flash.h" - -#include "esp_timer.h" -#include "driver/i2c.h" - -#define WAIT_TIMER_PERIOD (1 * 1000) - -#define I2C_SDA_GPIO CONFIG_TEST_I2C_SDA_NUM -#define I2C_SCL_GPIO CONFIG_TEST_I2C_SCL_NUM -#define I2C_SLAVE_ADDR CONFIG_TEST_I2C_SLAVE_ADDR - -#if CONFIG_TEST_I2C_MASTER_MODE -#define I2C_TEST_WIFI_AP_ENABLE CONFIG_TEST_I2C_WIFI_AP_ENABLE -#define I2C_CLK_FREQUENCY CONFIG_TEST_I2C_MASTER_FREQUENCY -#define I2C_MASTER_NUM_PORT CONFIG_TEST_I2C_PORT_NUM -#define I2C_MASTER_TX_BUF_DISABLE 0 -#define I2C_MASTER_RX_BUF_DISABLE 0 -#define I2C_ACK_CHECK_EN 0x1 -#define I2C_ACK_CHECK_DIS 0x0 -#else -#define I2C_SLAVE_NUM_PORT CONFIG_TEST_I2C_PORT_NUM -#define I2C_SLAVE_TX_BUF_LEN 256 -#define I2C_SLAVE_RX_BUF_LEN 256 -#endif - -/* The tests use WiFi configuration that you can set via project configuration menu. - - If you'd rather not, just change the below entries to strings with - the config you want - ie #define TEST_WIFI_SSID "mywifissid" -*/ -static const char* TAG = "I2C-wifi test"; - -#if I2C_TEST_WIFI_AP_ENABLE -#define TEST_ESP_WIFI_SSID CONFIG_TEST_WIFI_SSID -#define TEST_ESP_WIFI_PASS CONFIG_TEST_WIFI_PASSWORD -#define TEST_ESP_WIFI_CHANNEL CONFIG_TEST_WIFI_CHANNEL -#define TEST_MAX_STA_CONN CONFIG_TEST_MAX_STA_CONN - - -static void wifi_event_handler(void *arg, esp_event_base_t event_base, - int32_t event_id, void *event_data) -{ - if (event_id == WIFI_EVENT_AP_STACONNECTED) { - wifi_event_ap_staconnected_t *event = (wifi_event_ap_staconnected_t *) event_data; - ESP_LOGI(TAG, "station "MACSTR" join, AID=%d", MAC2STR(event->mac), event->aid); - } else if (event_id == WIFI_EVENT_AP_STADISCONNECTED) { - wifi_event_ap_stadisconnected_t *event = (wifi_event_ap_stadisconnected_t *) event_data; - ESP_LOGI(TAG, "station "MACSTR" leave, AID=%d, reason=%d", MAC2STR(event->mac), event->aid, event->reason); - } -} - -void wifi_init_softap(void) -{ - ESP_ERROR_CHECK(esp_netif_init()); - ESP_ERROR_CHECK(esp_event_loop_create_default()); - esp_netif_create_default_wifi_ap(); - - wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); - ESP_ERROR_CHECK(esp_wifi_init(&cfg)); - - ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL, NULL)); - - wifi_config_t wifi_config = { - .ap = { - .ssid = TEST_ESP_WIFI_SSID, - .ssid_len = strlen(TEST_ESP_WIFI_SSID), - .channel = TEST_ESP_WIFI_CHANNEL, - .password = TEST_ESP_WIFI_PASS, - .max_connection = TEST_MAX_STA_CONN, - .authmode = WIFI_AUTH_WPA_WPA2_PSK - }, - }; - if (strlen(TEST_ESP_WIFI_PASS) == 0) { - wifi_config.ap.authmode = WIFI_AUTH_OPEN; - } - - ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_AP)); - ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_AP, &wifi_config)); - ESP_ERROR_CHECK(esp_wifi_start()); - - ESP_LOGI(TAG, "wifi_init_softap finished. SSID:%s password:%s channel:%d", TEST_ESP_WIFI_SSID, TEST_ESP_WIFI_PASS, TEST_ESP_WIFI_CHANNEL); -} - -#endif //I2C_TEST_WIFI_AP_ENABLE - -#if CONFIG_TEST_I2C_MASTER_MODE - -static esp_timer_handle_t wait_timer; -static uint32_t timer_count = 1000 * 1000; - -static esp_err_t i2c_master_init(void) -{ - i2c_port_t i2c_master_port = I2C_MASTER_NUM_PORT; - - i2c_config_t conf_master = { - .mode = I2C_MODE_MASTER, - .sda_io_num = I2C_SDA_GPIO, - .sda_pullup_en = true, - .scl_io_num = I2C_SCL_GPIO, - .scl_pullup_en = true, - .master.clk_speed = I2C_CLK_FREQUENCY, - }; - - esp_err_t err = i2c_param_config(i2c_master_port, &conf_master); - if (err != ESP_OK) { - return err; - } - - return i2c_driver_install(i2c_master_port, conf_master.mode, I2C_MASTER_RX_BUF_DISABLE, I2C_MASTER_TX_BUF_DISABLE, 0); -} - -// i2c master write -static esp_err_t i2c_master_write_to_slave(uint8_t *data, uint32_t size) -{ - i2c_cmd_handle_t cmd = i2c_cmd_link_create(); - i2c_master_start(cmd); - i2c_master_write_byte(cmd, (I2C_SLAVE_ADDR << 1) | I2C_MASTER_WRITE, I2C_ACK_CHECK_DIS); - i2c_master_write(cmd, data, size, I2C_ACK_CHECK_DIS); - - i2c_master_stop(cmd); - esp_err_t ret = i2c_master_cmd_begin(I2C_MASTER_NUM_PORT, cmd, 1000 / portTICK_PERIOD_MS); - i2c_cmd_link_delete(cmd); - return ret; -} - -static esp_err_t i2c_data_write(void) -{ - uint8_t data[] = {0x6a, 0x1b, 0x05, 0x1f, 0x1f, 0x08, 0x01, 0x20, 0x19, 0x03, 0x27}; - - esp_err_t ret = i2c_master_write_to_slave(data, sizeof(data)); - if(ret != ESP_OK) { - ESP_LOGW(TAG,"I2C timeout"); - } - - return ret; -} - -static void wait_timer_callback(void *arg) -{ - // i2c write - i2c_data_write(); - /* For local test, please remove this part and give long time testing. */ - timer_count--; - if (timer_count == 0) { - esp_timer_stop(wait_timer); - return; - } - - // restart timer - esp_timer_start_once(wait_timer, WAIT_TIMER_PERIOD); -} - -static const esp_timer_create_args_t wait_timer_args = { - .callback = &wait_timer_callback, - .arg = NULL, - .name = "wait_timer", -}; - -#else - -static esp_err_t i2c_slave_init(void) -{ - i2c_port_t i2c_slave_port = I2C_SLAVE_NUM_PORT; - - i2c_config_t conf_slave = { - .mode = I2C_MODE_SLAVE, - .sda_io_num = I2C_SDA_GPIO, - .sda_pullup_en = GPIO_PULLUP_ENABLE, - .scl_io_num = I2C_SCL_GPIO, - .scl_pullup_en = GPIO_PULLUP_ENABLE, - .slave.addr_10bit_en = 0, - .slave.slave_addr = I2C_SLAVE_ADDR, - - }; - - i2c_param_config(i2c_slave_port, &conf_slave); - return i2c_driver_install(i2c_slave_port, conf_slave.mode, I2C_SLAVE_RX_BUF_LEN, I2C_SLAVE_TX_BUF_LEN, 0); -} - -static void i2c_data_read(void *arg) -{ - printf("slave mode.read thread start...\r\n"); - while (1) { - uint8_t data[11] = {0}; - i2c_slave_read_buffer(I2C_SLAVE_NUM_PORT, data, sizeof(data), 1000 / portTICK_PERIOD_MS); - ESP_LOG_BUFFER_HEX(TAG, data, sizeof(data)); - vTaskDelay(1); - } -} -#endif - -// i2c init function -static esp_err_t i2c_init(void) -{ - esp_err_t err = ESP_OK; -#if CONFIG_TEST_I2C_MASTER_MODE - err = i2c_master_init(); -#else - err = i2c_slave_init(); -#endif - return err; -} - -void app_main(void) -{ - esp_err_t ret = i2c_init(); - -#if I2C_TEST_WIFI_AP_ENABLE - //Initialize NVS - ret = nvs_flash_init(); - if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) { - ESP_ERROR_CHECK(nvs_flash_erase()); - ret = nvs_flash_init(); - } - ESP_ERROR_CHECK(ret); - - ESP_LOGI(TAG, "ESP_WIFI_MODE_AP"); - wifi_init_softap(); -#endif - -#if CONFIG_TEST_I2C_MASTER_MODE - ret = esp_timer_create(&wait_timer_args, &wait_timer); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "esp_timer_create fail!"); - } - - ret = esp_timer_start_once(wait_timer, WAIT_TIMER_PERIOD); - if (ret != ESP_OK) { - ESP_LOGE(TAG, "esp_timer_start_once fail!"); - } -#else - xTaskCreatePinnedToCore(i2c_data_read, "i2c_data_read", (3 * 1024), NULL, 1, NULL, 1); -#endif - ESP_ERROR_CHECK(ret); - printf("I2C-WIFI test success\n"); -} diff --git a/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py b/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py deleted file mode 100644 index e57717bd24..0000000000 --- a/tools/test_apps/peripherals/i2c_wifi/pytest_i2c_wifi.py +++ /dev/null @@ -1,13 +0,0 @@ -# SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD -# SPDX-License-Identifier: CC0-1.0 -import pytest -from pytest_embedded_idf.dut import IdfDut -from pytest_embedded_idf.utils import idf_parametrize - - -@pytest.mark.generic -@idf_parametrize( - 'target', ['esp32', 'esp32c2', 'esp32c3', 'esp32c6', 'esp32s2', 'esp32s3', 'esp32c5'], indirect=['target'] -) -def test_i2c_wifi_startup(dut: IdfDut) -> None: - dut.expect_exact('I2C-WIFI test success') diff --git a/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt b/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt index e46267f762..0bc4156918 100644 --- a/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt +++ b/tools/test_apps/system/cxx_build_test/main/CMakeLists.txt @@ -7,10 +7,6 @@ if(CONFIG_SOC_I2S_SUPPORTED) list(APPEND srcs test_i2s.cpp) endif() -if(CONFIG_SOC_TWAI_SUPPORTED) - list(APPEND srcs test_twai.cpp) -endif() - idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "." - PRIV_REQUIRES driver esp_driver_i2s) + PRIV_REQUIRES esp_driver_i2s esp_driver_mcpwm esp_driver_sdmmc esp_driver_sdspi) diff --git a/tools/test_apps/system/cxx_build_test/main/test_twai.cpp b/tools/test_apps/system/cxx_build_test/main/test_twai.cpp deleted file mode 100644 index c337bf289b..0000000000 --- a/tools/test_apps/system/cxx_build_test/main/test_twai.cpp +++ /dev/null @@ -1,15 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD - * - * SPDX-License-Identifier: Unlicense OR CC0-1.0 - */ -#include "driver/twai.h" - -void test_twai_apis(void) -{ - twai_filter_config_t f_config = TWAI_FILTER_CONFIG_ACCEPT_ALL(); - twai_general_config_t g_config = TWAI_GENERAL_CONFIG_DEFAULT(GPIO_NUM_0, GPIO_NUM_1, TWAI_MODE_NO_ACK); - twai_timing_config_t t_config = TWAI_TIMING_CONFIG_100KBITS(); - twai_driver_install(&g_config, &t_config, &f_config); - twai_driver_uninstall(); -}