From d171a7b958fa2726ecdef8277ff857d7d30cecaf Mon Sep 17 00:00:00 2001 From: morris Date: Thu, 30 Nov 2023 20:57:54 +0800 Subject: [PATCH] change(sdm): move driver to a new component: esp_driver_sdm --- components/driver/CMakeLists.txt | 10 +++---- components/driver/Kconfig | 26 ------------------- .../driver/test_apps/.build-test-rules.yml | 10 +------ components/esp_driver_sdm/CMakeLists.txt | 11 ++++++++ components/esp_driver_sdm/Kconfig | 25 ++++++++++++++++++ .../include/driver/sdm.h | 0 .../{driver => esp_driver_sdm}/linker.lf | 4 +-- .../sigma_delta => esp_driver_sdm/src}/sdm.c | 2 +- .../test_apps/.build-test-rules.yml | 8 ++++++ .../test_apps/sigma_delta/CMakeLists.txt | 2 +- .../test_apps/sigma_delta/README.md | 0 .../test_apps/sigma_delta/main/CMakeLists.txt | 2 +- .../sigma_delta/main/test_app_main.c | 0 .../test_apps/sigma_delta/main/test_sdm.c | 0 .../sigma_delta/pytest_sigma_delta.py | 0 .../sigma_delta/sdkconfig.ci.iram_safe | 0 .../sigma_delta/sdkconfig.ci.release | 0 .../test_apps/sigma_delta/sdkconfig.defaults | 0 docs/doxygen/Doxyfile | 2 +- .../release-5.x/5.3/peripherals.rst | 1 + .../release-5.x/5.3/peripherals.rst | 1 + examples/peripherals/.build-test-rules.yml | 2 ++ 22 files changed, 59 insertions(+), 47 deletions(-) create mode 100644 components/esp_driver_sdm/CMakeLists.txt create mode 100644 components/esp_driver_sdm/Kconfig rename components/{driver/sigma_delta => esp_driver_sdm}/include/driver/sdm.h (100%) rename components/{driver => esp_driver_sdm}/linker.lf (65%) rename components/{driver/sigma_delta => esp_driver_sdm/src}/sdm.c (98%) create mode 100644 components/esp_driver_sdm/test_apps/.build-test-rules.yml rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/CMakeLists.txt (87%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/README.md (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/main/CMakeLists.txt (84%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/main/test_app_main.c (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/main/test_sdm.c (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/pytest_sigma_delta.py (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/sdkconfig.ci.iram_safe (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/sdkconfig.ci.release (100%) rename components/{driver => esp_driver_sdm}/test_apps/sigma_delta/sdkconfig.defaults (100%) diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 92ba27f0d1..2d9e3c31ae 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -12,14 +12,13 @@ set(includes "deprecated" "i2c/include" "ledc/include" "parlio/include" - "sigma_delta/include" "touch_sensor/include" "twai/include" "uart/include" "usb_serial_jtag/include") # Always included linker fragments -set(ldfragments "linker.lf") +set(ldfragments "") # ADC related source files (dprecated) if(CONFIG_SOC_ADC_SUPPORTED) @@ -86,10 +85,9 @@ if(CONFIG_SOC_RMT_SUPPORTED) list(APPEND srcs "deprecated/rmt_legacy.c") endif() -# Sigma-Delta Modulation related source files +# Sigma-Delta Modulation legacy driver if(CONFIG_SOC_SDM_SUPPORTED) - list(APPEND srcs "sigma_delta/sdm.c" - "deprecated/sigma_delta_legacy.c") + list(APPEND srcs "deprecated/sigma_delta_legacy.c") endif() # Temperature Sensor related source files @@ -144,7 +142,7 @@ else() # 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_dac esp_driver_rmt esp_driver_tsens esp_driver_sdm LDFRAGMENTS ${ldfragments} ) endif() diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 6111c9b69d..343532ca1c 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -66,32 +66,6 @@ menu "Driver Configurations" orsource "./uart/Kconfig.uart" - menu "Sigma Delta Modulator Configuration" - depends on SOC_SDM_SUPPORTED - config SDM_CTRL_FUNC_IN_IRAM - bool "Place SDM control functions into IRAM" - default n - help - Place SDM control functions (like set_duty) into IRAM, - so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context. - Enabling this option can improve driver performance as well. - - config SDM_SUPPRESS_DEPRECATE_WARN - bool "Suppress legacy driver deprecated warning" - default n - help - Wether to suppress the deprecation warnings when using legacy sigma delta driver. - If you want to continue using the legacy driver, and don't want to see related deprecation warnings, - you can enable this option. - - config SDM_ENABLE_DEBUG_LOG - bool "Enable debug log" - default n - help - Wether to enable the debug log message for SDM driver. - Note that, this option only controls the SDM driver log, won't affect other drivers. - endmenu # Sigma Delta Modulator Configuration - menu "USB Serial/JTAG Configuration" depends on SOC_USB_SERIAL_JTAG_SUPPORTED config USJ_NO_AUTO_LS_ON_CONNECTION diff --git a/components/driver/test_apps/.build-test-rules.yml b/components/driver/test_apps/.build-test-rules.yml index b8b294f6d4..4987875f1c 100644 --- a/components/driver/test_apps/.build-test-rules.yml +++ b/components/driver/test_apps/.build-test-rules.yml @@ -62,7 +62,7 @@ components/driver/test_apps/legacy_sigma_delta_driver: disable: - if: SOC_SDM_SUPPORTED != 1 depends_filepatterns: - - components/driver/deprecated/**/* + - components/driver/deprecated/**/*sigma* depends_components: - esp_driver_gpio @@ -88,14 +88,6 @@ components/driver/test_apps/rs485: temporary: true reason: lack of runners -components/driver/test_apps/sigma_delta: - disable: - - if: SOC_SDM_SUPPORTED != 1 - depends_filepatterns: - - components/driver/sigma_delta/**/* - depends_components: - - esp_driver_gpio - components/driver/test_apps/touch_sensor_v1: disable: - if: SOC_TOUCH_SENSOR_VERSION != 1 diff --git a/components/esp_driver_sdm/CMakeLists.txt b/components/esp_driver_sdm/CMakeLists.txt new file mode 100644 index 0000000000..b7d5031dc8 --- /dev/null +++ b/components/esp_driver_sdm/CMakeLists.txt @@ -0,0 +1,11 @@ +set(srcs) +set(public_include "include") +if(CONFIG_SOC_SDM_SUPPORTED) + list(APPEND srcs "src/sdm.c") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${public_include} + PRIV_REQUIRES "esp_pm" "esp_driver_gpio" + LDFRAGMENTS "linker.lf" + ) diff --git a/components/esp_driver_sdm/Kconfig b/components/esp_driver_sdm/Kconfig new file mode 100644 index 0000000000..b572c4ab9f --- /dev/null +++ b/components/esp_driver_sdm/Kconfig @@ -0,0 +1,25 @@ +menu "ESP-Driver:Sigma Delta Modulator Configurations" + depends on SOC_SDM_SUPPORTED + config SDM_CTRL_FUNC_IN_IRAM + bool "Place SDM control functions into IRAM" + default n + help + Place SDM control functions (like set_duty) into IRAM, + so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context. + Enabling this option can improve driver performance as well. + + config SDM_SUPPRESS_DEPRECATE_WARN + bool "Suppress legacy driver deprecated warning" + default n + help + Wether to suppress the deprecation warnings when using legacy sigma delta driver. + If you want to continue using the legacy driver, and don't want to see related deprecation warnings, + you can enable this option. + + config SDM_ENABLE_DEBUG_LOG + bool "Enable debug log" + default n + help + Wether to enable the debug log message for SDM driver. + Note that, this option only controls the SDM driver log, won't affect other drivers. +endmenu # Sigma Delta Modulator Configurations diff --git a/components/driver/sigma_delta/include/driver/sdm.h b/components/esp_driver_sdm/include/driver/sdm.h similarity index 100% rename from components/driver/sigma_delta/include/driver/sdm.h rename to components/esp_driver_sdm/include/driver/sdm.h diff --git a/components/driver/linker.lf b/components/esp_driver_sdm/linker.lf similarity index 65% rename from components/driver/linker.lf rename to components/esp_driver_sdm/linker.lf index 728e2c34d1..37812f1e53 100644 --- a/components/driver/linker.lf +++ b/components/esp_driver_sdm/linker.lf @@ -1,5 +1,5 @@ -[mapping:driver] -archive: libdriver.a +[mapping:sdm_driver] +archive: libesp_driver_sdm.a entries: if SDM_CTRL_FUNC_IN_IRAM = y: sdm: sdm_channel_set_pulse_density (noflash) diff --git a/components/driver/sigma_delta/sdm.c b/components/esp_driver_sdm/src/sdm.c similarity index 98% rename from components/driver/sigma_delta/sdm.c rename to components/esp_driver_sdm/src/sdm.c index 2ad46375bb..2856604f46 100644 --- a/components/driver/sigma_delta/sdm.c +++ b/components/esp_driver_sdm/src/sdm.c @@ -210,7 +210,7 @@ esp_err_t sdm_new_channel(const sdm_config_t *config, sdm_channel_handle_t *ret_ ESP_GOTO_ON_FALSE(group->clk_src == 0 || group->clk_src == config->clk_src, ESP_ERR_INVALID_ARG, err, TAG, "clock source conflict"); uint32_t src_clk_hz = 0; ESP_GOTO_ON_ERROR(esp_clk_tree_src_get_freq_hz((soc_module_clk_t)config->clk_src, - ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_hz), err, TAG, "get source clock frequency failed"); + ESP_CLK_TREE_SRC_FREQ_PRECISION_CACHED, &src_clk_hz), err, TAG, "get source clock frequency failed"); #if CONFIG_PM_ENABLE esp_pm_lock_type_t pm_type = ESP_PM_NO_LIGHT_SLEEP; diff --git a/components/esp_driver_sdm/test_apps/.build-test-rules.yml b/components/esp_driver_sdm/test_apps/.build-test-rules.yml new file mode 100644 index 0000000000..77a14a9575 --- /dev/null +++ b/components/esp_driver_sdm/test_apps/.build-test-rules.yml @@ -0,0 +1,8 @@ +# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps + +components/esp_driver_sdm/test_apps/sigma_delta: + disable: + - if: SOC_SDM_SUPPORTED != 1 + depends_components: + - esp_driver_gpio + - esp_driver_sdm diff --git a/components/driver/test_apps/sigma_delta/CMakeLists.txt b/components/esp_driver_sdm/test_apps/sigma_delta/CMakeLists.txt similarity index 87% rename from components/driver/test_apps/sigma_delta/CMakeLists.txt rename to components/esp_driver_sdm/test_apps/sigma_delta/CMakeLists.txt index 2150ef0e3a..7ad2bd49ba 100644 --- a/components/driver/test_apps/sigma_delta/CMakeLists.txt +++ b/components/esp_driver_sdm/test_apps/sigma_delta/CMakeLists.txt @@ -10,7 +10,7 @@ project(sigma_delta_test) if(CONFIG_COMPILER_DUMP_RTL_FILES) add_custom_target(check_test_app_sections ALL COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py - --rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/driver/,${CMAKE_BINARY_DIR}/esp-idf/hal/ + --rtl-dirs ${CMAKE_BINARY_DIR}/esp-idf/esp_driver_sdm/,${CMAKE_BINARY_DIR}/esp-idf/hal/ --elf-file ${CMAKE_BINARY_DIR}/sigma_delta_test.elf find-refs --from-sections=.iram0.text diff --git a/components/driver/test_apps/sigma_delta/README.md b/components/esp_driver_sdm/test_apps/sigma_delta/README.md similarity index 100% rename from components/driver/test_apps/sigma_delta/README.md rename to components/esp_driver_sdm/test_apps/sigma_delta/README.md diff --git a/components/driver/test_apps/sigma_delta/main/CMakeLists.txt b/components/esp_driver_sdm/test_apps/sigma_delta/main/CMakeLists.txt similarity index 84% rename from components/driver/test_apps/sigma_delta/main/CMakeLists.txt rename to components/esp_driver_sdm/test_apps/sigma_delta/main/CMakeLists.txt index 29c6893034..5484720431 100644 --- a/components/driver/test_apps/sigma_delta/main/CMakeLists.txt +++ b/components/esp_driver_sdm/test_apps/sigma_delta/main/CMakeLists.txt @@ -7,5 +7,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 driver + PRIV_REQUIRES unity esp_driver_sdm WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/sigma_delta/main/test_app_main.c b/components/esp_driver_sdm/test_apps/sigma_delta/main/test_app_main.c similarity index 100% rename from components/driver/test_apps/sigma_delta/main/test_app_main.c rename to components/esp_driver_sdm/test_apps/sigma_delta/main/test_app_main.c diff --git a/components/driver/test_apps/sigma_delta/main/test_sdm.c b/components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm.c similarity index 100% rename from components/driver/test_apps/sigma_delta/main/test_sdm.c rename to components/esp_driver_sdm/test_apps/sigma_delta/main/test_sdm.c diff --git a/components/driver/test_apps/sigma_delta/pytest_sigma_delta.py b/components/esp_driver_sdm/test_apps/sigma_delta/pytest_sigma_delta.py similarity index 100% rename from components/driver/test_apps/sigma_delta/pytest_sigma_delta.py rename to components/esp_driver_sdm/test_apps/sigma_delta/pytest_sigma_delta.py diff --git a/components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe b/components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.ci.iram_safe similarity index 100% rename from components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe rename to components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.ci.iram_safe diff --git a/components/driver/test_apps/sigma_delta/sdkconfig.ci.release b/components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.ci.release similarity index 100% rename from components/driver/test_apps/sigma_delta/sdkconfig.ci.release rename to components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.ci.release diff --git a/components/driver/test_apps/sigma_delta/sdkconfig.defaults b/components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.defaults similarity index 100% rename from components/driver/test_apps/sigma_delta/sdkconfig.defaults rename to components/esp_driver_sdm/test_apps/sigma_delta/sdkconfig.defaults diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index cd92581893..dee2b659a2 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -79,7 +79,6 @@ INPUT = \ $(PROJECT_PATH)/components/driver/ledc/include/driver/ledc.h \ $(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_tx.h \ $(PROJECT_PATH)/components/driver/parlio/include/driver/parlio_types.h \ - $(PROJECT_PATH)/components/driver/sigma_delta/include/driver/sdm.h \ $(PROJECT_PATH)/components/driver/touch_sensor/include/driver/touch_sensor_common.h \ $(PROJECT_PATH)/components/driver/twai/include/driver/twai.h \ $(PROJECT_PATH)/components/driver/uart/include/driver/uart.h \ @@ -134,6 +133,7 @@ INPUT = \ $(PROJECT_PATH)/components/esp_driver_rmt/include/driver/rmt_tx.h \ $(PROJECT_PATH)/components/esp_driver_rmt/include/driver/rmt_types.h \ $(PROJECT_PATH)/components/esp_driver_sdio/include/driver/sdio_slave.h \ + $(PROJECT_PATH)/components/esp_driver_sdm/include/driver/sdm.h \ $(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_default_configs.h \ $(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_host.h \ $(PROJECT_PATH)/components/esp_driver_sdmmc/include/driver/sdmmc_types.h \ diff --git a/docs/en/migration-guides/release-5.x/5.3/peripherals.rst b/docs/en/migration-guides/release-5.x/5.3/peripherals.rst index eaf5159e28..9c3275f0f1 100644 --- a/docs/en/migration-guides/release-5.x/5.3/peripherals.rst +++ b/docs/en/migration-guides/release-5.x/5.3/peripherals.rst @@ -18,6 +18,7 @@ In order to control the dependence of other components on drivers at a smaller g - `esp_driver_dac` - Driver for DAC - `esp_driver_rmt` - Driver for RMT - `esp_driver_tsens` - Driver for Temperature Sensor +- `esp_driver_sdm` - Driver for Sigma-Delta Modulator For compatibility, the original `driver`` component is still treated as an all-in-one component by registering these `esp_driver_xyz`` components as its public dependencies. In other words, you do not need to modify the CMake file of an existing project, but you now have a way to specify the specific peripheral driver that your project depends on. diff --git a/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst b/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst index 609d04e99c..ee48673a6b 100644 --- a/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst +++ b/docs/zh_CN/migration-guides/release-5.x/5.3/peripherals.rst @@ -18,6 +18,7 @@ - `esp_driver_dac` - DAC 驱动 - `esp_driver_rmt` - RMT 驱动 - `esp_driver_tsens` - 温度传感器驱动 +- `esp_driver_sdm` - Sigma-Delta 调制器驱动 为了兼容性,原来的 `driver` 组件仍然存在,并作为一个 “all-in-one" 的组件,将以上这些 `esp_driver_xyz` 组件注册成自己的公共依赖。换句话说,你无需修改既有项目的 CMake 文件,但是你现在多了一个途径去指定你项目依赖的具体的外设驱动。 diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index 8372892050..c5e13dbc95 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -290,6 +290,8 @@ examples/peripherals/secure_element/atecc608_ecdsa: examples/peripherals/sigma_delta: disable: - if: SOC_SDM_SUPPORTED != 1 + depends_components: + - esp_driver_sdm examples/peripherals/spi_master/hd_eeprom: disable: