diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index 5e36070359..2a185d544d 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -64,7 +64,7 @@ idf_component_register(SRCS "${srcs}" INCLUDE_DIRS "${include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}" # Requires "driver" for GPTimer in "SEGGER_SYSVIEW_Config_FreeRTOS.c" - PRIV_REQUIRES soc driver + PRIV_REQUIRES soc driver esp_driver_gpio REQUIRES esp_timer LDFRAGMENTS linker.lf) diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index d263857117..a4f4f3eb87 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -6,9 +6,6 @@ endif() # Always compiled source files set(srcs - "gpio/gpio.c" - "gpio/gpio_glitch_filter_ops.c" - "gpio/rtc_io.c" "spi/spi_bus_lock.c") # Always included headers @@ -16,7 +13,6 @@ set(includes "include" "deprecated" "analog_comparator/include" "dac/include" - "gpio/include" "gptimer/include" "i2c/include" "i2s/include" @@ -35,8 +31,7 @@ set(includes "include" "usb_serial_jtag/include") # Always included linker fragments -set(ldfragments "linker.lf" - "gpio/linker.lf") +set(ldfragments "linker.lf") # ADC related source files (dprecated) if(CONFIG_SOC_ADC_SUPPORTED) @@ -71,23 +66,6 @@ if(CONFIG_SOC_PARLIO_SUPPORTED) list(APPEND srcs "parlio/parlio_common.c" "parlio/parlio_tx.c") endif() -# GPIO related source files -if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED) - list(APPEND srcs "gpio/dedic_gpio.c") -endif() - -if(CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER) - list(APPEND srcs "gpio/gpio_pin_glitch_filter.c") -endif() - -if(CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM GREATER 0) - list(APPEND srcs "gpio/gpio_flex_glitch_filter.c") -endif() - -if(CONFIG_SOC_GPIO_SUPPORT_ETM) - list(APPEND srcs "gpio/gpio_etm.c") -endif() - # GPTimer related source files if(CONFIG_SOC_GPTIMER_SUPPORTED) list(APPEND srcs "gptimer/gptimer.c" @@ -248,7 +226,7 @@ else() 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_pcnt + esp_driver_gpio esp_driver_pcnt LDFRAGMENTS ${ldfragments} ) endif() diff --git a/components/driver/Kconfig b/components/driver/Kconfig index 0394f99569..5de2715b0f 100644 --- a/components/driver/Kconfig +++ b/components/driver/Kconfig @@ -156,24 +156,6 @@ menu "Driver Configurations" orsource "./uart/Kconfig.uart" - menu "GPIO Configuration" - config GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL - bool "Support light sleep GPIO pullup/pulldown configuration for ESP32" - depends on IDF_TARGET_ESP32 - help - This option is intended to fix the bug that ESP32 is not able to switch to configured - pullup/pulldown mode in sleep. - If this option is selected, chip will automatically emulate the behaviour of switching, - and about 450B of source codes would be placed into IRAM. - - config GPIO_CTRL_FUNC_IN_IRAM - bool "Place GPIO control functions into IRAM" - default n - help - Place GPIO control functions (like intr_disable/set_level) into IRAM, - so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context. - endmenu # GPIO Configuration - menu "Sigma Delta Modulator Configuration" depends on SOC_SDM_SUPPORTED config SDM_CTRL_FUNC_IN_IRAM diff --git a/components/driver/test_apps/.build-test-rules.yml b/components/driver/test_apps/.build-test-rules.yml index 23f308bc54..b8ed1bf804 100644 --- a/components/driver/test_apps/.build-test-rules.yml +++ b/components/driver/test_apps/.build-test-rules.yml @@ -16,12 +16,6 @@ components/driver/test_apps/dac_test_apps/legacy_dac_driver: disable: - if: SOC_DAC_SUPPORTED != 1 -components/driver/test_apps/gpio_extensions: - disable: - - if: IDF_TARGET == "esp32p4" - temporary: true - reason: not supported yet # TODO: IDF-7551 - components/driver/test_apps/gptimer: disable: - if: SOC_GPTIMER_SUPPORTED != 1 @@ -97,6 +91,14 @@ components/driver/test_apps/legacy_rtc_temp_driver: disable: - if: SOC_TEMP_SENSOR_SUPPORTED != 1 +components/driver/test_apps/legacy_sigma_delta_driver: + disable: + - if: SOC_SDM_SUPPORTED != 1 + depends_filepatterns: + - components/driver/deprecated/**/* + depends_components: + - esp_driver_gpio + components/driver/test_apps/legacy_timer_driver: disable: - if: SOC_GPTIMER_SUPPORTED != 1 @@ -119,9 +121,7 @@ components/driver/test_apps/rmt: components/driver/test_apps/rs485: disable: - - if: IDF_TARGET in ["esp32p4"] - temporary: true - reason: target(s) is not supported yet # TODO: IDF-6511 + - if: SOC_UART_SUPPORTED != 1 disable_test: - if: IDF_TARGET != "esp32" temporary: true @@ -135,6 +135,14 @@ components/driver/test_apps/sdio: 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/spi/master: disable: - if: SOC_GPSPI_SUPPORTED != 1 @@ -174,17 +182,14 @@ components/driver/test_apps/twai: components/driver/test_apps/uart: disable: - if: SOC_UART_SUPPORTED != 1 - - if: IDF_TARGET in ["esp32p4"] - temporary: true - reason: target(s) is not supported yet # TODO: IDF-6511 components/driver/test_apps/usb_serial_jtag: disable: - if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1 depends_filepatterns: - - components/driver/gpio/**/* - components/driver/usb_serial_jtag/**/* depends_components: - hal - esp_hw_support # for clock - vfs + - esp_driver_gpio diff --git a/components/driver/test_apps/gpio_extensions/README.md b/components/driver/test_apps/gpio_extensions/README.md deleted file mode 100644 index a8b7833fa3..0000000000 --- a/components/driver/test_apps/gpio_extensions/README.md +++ /dev/null @@ -1,2 +0,0 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/legacy_sigma_delta_driver/CMakeLists.txt b/components/driver/test_apps/legacy_sigma_delta_driver/CMakeLists.txt new file mode 100644 index 0000000000..23e05b8a32 --- /dev/null +++ b/components/driver/test_apps/legacy_sigma_delta_driver/CMakeLists.txt @@ -0,0 +1,8 @@ +# This is the project CMakeLists.txt file for the test subproject +cmake_minimum_required(VERSION 3.16) + +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(legacy_sigma_delta_driver_test) diff --git a/components/driver/test_apps/legacy_sigma_delta_driver/README.md b/components/driver/test_apps/legacy_sigma_delta_driver/README.md new file mode 100644 index 0000000000..19f1d19a54 --- /dev/null +++ b/components/driver/test_apps/legacy_sigma_delta_driver/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/legacy_sigma_delta_driver/main/CMakeLists.txt b/components/driver/test_apps/legacy_sigma_delta_driver/main/CMakeLists.txt new file mode 100644 index 0000000000..85392372b9 --- /dev/null +++ b/components/driver/test_apps/legacy_sigma_delta_driver/main/CMakeLists.txt @@ -0,0 +1,11 @@ +set(srcs "test_app_main.c") + +if(CONFIG_SOC_SDM_SUPPORTED) + list(APPEND srcs "test_sigma_delta_legacy.c") +endif() + +# In order for the cases defined by `TEST_CASE` to be linked into the final elf, +# the component can be registered as WHOLE_ARCHIVE +idf_component_register(SRCS ${srcs} + PRIV_REQUIRES unity driver esp_driver_gpio + WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/gpio/main/test_app_main.c b/components/driver/test_apps/legacy_sigma_delta_driver/main/test_app_main.c similarity index 100% rename from components/driver/test_apps/gpio/main/test_app_main.c rename to components/driver/test_apps/legacy_sigma_delta_driver/main/test_app_main.c diff --git a/components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c b/components/driver/test_apps/legacy_sigma_delta_driver/main/test_sigma_delta_legacy.c similarity index 100% rename from components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c rename to components/driver/test_apps/legacy_sigma_delta_driver/main/test_sigma_delta_legacy.c diff --git a/components/driver/test_apps/legacy_sigma_delta_driver/pytest_legacy_sigma_delta.py b/components/driver/test_apps/legacy_sigma_delta_driver/pytest_legacy_sigma_delta.py new file mode 100644 index 0000000000..cba1b0ab00 --- /dev/null +++ b/components/driver/test_apps/legacy_sigma_delta_driver/pytest_legacy_sigma_delta.py @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded_idf import IdfDut + + +@pytest.mark.esp32 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32h2 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.generic +@pytest.mark.parametrize( + 'config', + [ + 'release', + ], + indirect=True) +def test_legacy_sigma_delta(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='sigma_delta') diff --git a/components/driver/test_apps/gpio/sdkconfig.ci.release b/components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.ci.release similarity index 100% rename from components/driver/test_apps/gpio/sdkconfig.ci.release rename to components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.ci.release diff --git a/components/driver/test_apps/gpio/sdkconfig.defaults b/components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.defaults similarity index 100% rename from components/driver/test_apps/gpio/sdkconfig.defaults rename to components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.defaults diff --git a/components/driver/test_apps/rs485/README.md b/components/driver/test_apps/rs485/README.md index a8b7833fa3..bf47d80ec6 100644 --- a/components/driver/test_apps/rs485/README.md +++ b/components/driver/test_apps/rs485/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/gpio/CMakeLists.txt b/components/driver/test_apps/sigma_delta/CMakeLists.txt similarity index 88% rename from components/driver/test_apps/gpio/CMakeLists.txt rename to components/driver/test_apps/sigma_delta/CMakeLists.txt index 7ba8cc2d2c..2150ef0e3a 100644 --- a/components/driver/test_apps/gpio/CMakeLists.txt +++ b/components/driver/test_apps/sigma_delta/CMakeLists.txt @@ -5,13 +5,13 @@ cmake_minimum_required(VERSION 3.16) set(COMPONENTS main) include($ENV{IDF_PATH}/tools/cmake/project.cmake) -project(gpio_test) +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/ - --elf-file ${CMAKE_BINARY_DIR}/gpio_test.elf + --elf-file ${CMAKE_BINARY_DIR}/sigma_delta_test.elf find-refs --from-sections=.iram0.text --to-sections=.flash.text,.flash.rodata diff --git a/components/driver/test_apps/sigma_delta/README.md b/components/driver/test_apps/sigma_delta/README.md new file mode 100644 index 0000000000..19f1d19a54 --- /dev/null +++ b/components/driver/test_apps/sigma_delta/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/sigma_delta/main/CMakeLists.txt b/components/driver/test_apps/sigma_delta/main/CMakeLists.txt new file mode 100644 index 0000000000..29c6893034 --- /dev/null +++ b/components/driver/test_apps/sigma_delta/main/CMakeLists.txt @@ -0,0 +1,11 @@ +set(srcs "test_app_main.c") + +if(CONFIG_SOC_SDM_SUPPORTED) + list(APPEND srcs "test_sdm.c") +endif() + +# In order for the cases defined by `TEST_CASE` to be linked into the final elf, +# the component can be registered as WHOLE_ARCHIVE +idf_component_register(SRCS ${srcs} + PRIV_REQUIRES unity driver + WHOLE_ARCHIVE) diff --git a/components/driver/test_apps/gpio_extensions/main/test_app_main.c b/components/driver/test_apps/sigma_delta/main/test_app_main.c similarity index 100% rename from components/driver/test_apps/gpio_extensions/main/test_app_main.c rename to components/driver/test_apps/sigma_delta/main/test_app_main.c diff --git a/components/driver/test_apps/gpio_extensions/main/test_sdm.c b/components/driver/test_apps/sigma_delta/main/test_sdm.c similarity index 100% rename from components/driver/test_apps/gpio_extensions/main/test_sdm.c rename to components/driver/test_apps/sigma_delta/main/test_sdm.c diff --git a/components/driver/test_apps/sigma_delta/pytest_sigma_delta.py b/components/driver/test_apps/sigma_delta/pytest_sigma_delta.py new file mode 100644 index 0000000000..6f5763207d --- /dev/null +++ b/components/driver/test_apps/sigma_delta/pytest_sigma_delta.py @@ -0,0 +1,23 @@ +# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD +# SPDX-License-Identifier: CC0-1.0 + +import pytest +from pytest_embedded_idf import IdfDut + +CONFIGS = [ + 'iram_safe', + 'release', +] + + +@pytest.mark.esp32 +@pytest.mark.esp32c3 +@pytest.mark.esp32c6 +@pytest.mark.esp32h2 +@pytest.mark.esp32s2 +@pytest.mark.esp32s3 +@pytest.mark.esp32h2 +@pytest.mark.generic +@pytest.mark.parametrize('config', CONFIGS, indirect=True) +def test_sdm(dut: IdfDut) -> None: + dut.run_all_single_board_cases(group='sdm') diff --git a/components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe b/components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe similarity index 100% rename from components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe rename to components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe diff --git a/components/driver/test_apps/gpio_extensions/sdkconfig.ci.release b/components/driver/test_apps/sigma_delta/sdkconfig.ci.release similarity index 100% rename from components/driver/test_apps/gpio_extensions/sdkconfig.ci.release rename to components/driver/test_apps/sigma_delta/sdkconfig.ci.release diff --git a/components/driver/test_apps/gpio_extensions/sdkconfig.defaults b/components/driver/test_apps/sigma_delta/sdkconfig.defaults similarity index 100% rename from components/driver/test_apps/gpio_extensions/sdkconfig.defaults rename to components/driver/test_apps/sigma_delta/sdkconfig.defaults diff --git a/components/driver/test_apps/uart/README.md b/components/driver/test_apps/uart/README.md index a8b7833fa3..bf47d80ec6 100644 --- a/components/driver/test_apps/uart/README.md +++ b/components/driver/test_apps/uart/README.md @@ -1,2 +1,2 @@ -| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | -| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | +| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-P4 | ESP32-S2 | ESP32-S3 | +| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/esp_adc/CMakeLists.txt b/components/esp_adc/CMakeLists.txt index bef8434a40..180ef6e8cf 100644 --- a/components/esp_adc/CMakeLists.txt +++ b/components/esp_adc/CMakeLists.txt @@ -42,5 +42,5 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} - PRIV_REQUIRES driver efuse + PRIV_REQUIRES driver esp_driver_gpio efuse esp_pm esp_ringbuf LDFRAGMENTS linker.lf) diff --git a/components/esp_adc/test_apps/.build-test-rules.yml b/components/esp_adc/test_apps/.build-test-rules.yml index 4b1b071e72..ab0728836d 100644 --- a/components/esp_adc/test_apps/.build-test-rules.yml +++ b/components/esp_adc/test_apps/.build-test-rules.yml @@ -6,8 +6,8 @@ components/esp_adc/test_apps/adc: - if: CONFIG_NAME == "gdma_iram_safe" and IDF_TARGET in ["esp32", "esp32s2", "esp32c2"] depends_components: - esp_adc + - esp_driver_gpio - efuse depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* # ADC continuous driver relies on SPI on ESP32S2 - components/driver/i2s/**/* # ADC continuous driver relies on I2S on ESP32 diff --git a/components/esp_driver_gpio/CMakeLists.txt b/components/esp_driver_gpio/CMakeLists.txt new file mode 100644 index 0000000000..dce1295124 --- /dev/null +++ b/components/esp_driver_gpio/CMakeLists.txt @@ -0,0 +1,33 @@ +idf_build_get_property(target IDF_TARGET) + +if(${target} STREQUAL "linux") + return() # This component is not supported by the POSIX/Linux simulator +endif() + +set(srcs "src/gpio.c" + "src/gpio_glitch_filter_ops.c" + "src/rtc_io.c" + ) +set(public_include "include") + +if(CONFIG_SOC_DEDICATED_GPIO_SUPPORTED) + list(APPEND srcs "src/dedic_gpio.c") +endif() + +if(CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER) + list(APPEND srcs "src/gpio_pin_glitch_filter.c") +endif() + +if(CONFIG_SOC_GPIO_FLEX_GLITCH_FILTER_NUM GREATER 0) + list(APPEND srcs "src/gpio_flex_glitch_filter.c") +endif() + +if(CONFIG_SOC_GPIO_SUPPORT_ETM) + list(APPEND srcs "src/gpio_etm.c") +endif() + +idf_component_register(SRCS ${srcs} + INCLUDE_DIRS ${public_include} + PRIV_REQUIRES esp_pm + LDFRAGMENTS "linker.lf" + ) diff --git a/components/esp_driver_gpio/Kconfig b/components/esp_driver_gpio/Kconfig new file mode 100644 index 0000000000..36d2b13794 --- /dev/null +++ b/components/esp_driver_gpio/Kconfig @@ -0,0 +1,17 @@ +menu "ESP-Driver:GPIO Configurations" + config GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL + bool "Support light sleep GPIO pullup/pulldown configuration for ESP32" + depends on IDF_TARGET_ESP32 + help + This option is intended to fix the bug that ESP32 is not able to switch to configured + pullup/pulldown mode in sleep. + If this option is selected, chip will automatically emulate the behaviour of switching, + and about 450B of source codes would be placed into IRAM. + + config GPIO_CTRL_FUNC_IN_IRAM + bool "Place GPIO control functions into IRAM" + default n + help + Place GPIO control functions (like intr_disable/set_level) into IRAM, + so that these functions can be IRAM-safe and able to be called in the other IRAM interrupt context. +endmenu diff --git a/components/driver/gpio/include/driver/dedic_gpio.h b/components/esp_driver_gpio/include/driver/dedic_gpio.h similarity index 100% rename from components/driver/gpio/include/driver/dedic_gpio.h rename to components/esp_driver_gpio/include/driver/dedic_gpio.h diff --git a/components/driver/gpio/include/driver/gpio.h b/components/esp_driver_gpio/include/driver/gpio.h similarity index 100% rename from components/driver/gpio/include/driver/gpio.h rename to components/esp_driver_gpio/include/driver/gpio.h diff --git a/components/driver/gpio/include/driver/gpio_etm.h b/components/esp_driver_gpio/include/driver/gpio_etm.h similarity index 100% rename from components/driver/gpio/include/driver/gpio_etm.h rename to components/esp_driver_gpio/include/driver/gpio_etm.h diff --git a/components/driver/gpio/include/driver/gpio_filter.h b/components/esp_driver_gpio/include/driver/gpio_filter.h similarity index 100% rename from components/driver/gpio/include/driver/gpio_filter.h rename to components/esp_driver_gpio/include/driver/gpio_filter.h diff --git a/components/driver/gpio/include/driver/lp_io.h b/components/esp_driver_gpio/include/driver/lp_io.h similarity index 100% rename from components/driver/gpio/include/driver/lp_io.h rename to components/esp_driver_gpio/include/driver/lp_io.h diff --git a/components/driver/gpio/include/driver/rtc_io.h b/components/esp_driver_gpio/include/driver/rtc_io.h similarity index 99% rename from components/driver/gpio/include/driver/rtc_io.h rename to components/esp_driver_gpio/include/driver/rtc_io.h index 4e9c2d0e3c..27a161d655 100644 --- a/components/driver/gpio/include/driver/rtc_io.h +++ b/components/esp_driver_gpio/include/driver/rtc_io.h @@ -13,7 +13,6 @@ #include "hal/rtc_io_types.h" #include "driver/gpio.h" - #ifdef __cplusplus extern "C" { #endif diff --git a/components/driver/gpio/glitch_filter_priv.h b/components/esp_driver_gpio/include/esp_private/glitch_filter_priv.h similarity index 100% rename from components/driver/gpio/glitch_filter_priv.h rename to components/esp_driver_gpio/include/esp_private/glitch_filter_priv.h diff --git a/components/driver/include/esp_private/gpio.h b/components/esp_driver_gpio/include/esp_private/gpio.h similarity index 100% rename from components/driver/include/esp_private/gpio.h rename to components/esp_driver_gpio/include/esp_private/gpio.h diff --git a/components/driver/gpio/linker.lf b/components/esp_driver_gpio/linker.lf similarity index 80% rename from components/driver/gpio/linker.lf rename to components/esp_driver_gpio/linker.lf index 4ca65040df..46d901a627 100644 --- a/components/driver/gpio/linker.lf +++ b/components/esp_driver_gpio/linker.lf @@ -1,9 +1,10 @@ [mapping:gpio_driver] -archive: libdriver.a +archive: libesp_driver_gpio.a entries: if GPIO_CTRL_FUNC_IN_IRAM = y: gpio: gpio_set_level (noflash) gpio: gpio_intr_disable (noflash) + gpio: gpio_get_level (noflash) [mapping:gpio_hal] archive: libhal.a diff --git a/components/driver/gpio/dedic_gpio.c b/components/esp_driver_gpio/src/dedic_gpio.c similarity index 99% rename from components/driver/gpio/dedic_gpio.c rename to components/esp_driver_gpio/src/dedic_gpio.c index b6ddc8e6d1..077efff88e 100644 --- a/components/driver/gpio/dedic_gpio.c +++ b/components/esp_driver_gpio/src/dedic_gpio.c @@ -31,7 +31,6 @@ #include "hal/dedic_gpio_ll.h" #endif - static const char *TAG = "dedic_gpio"; typedef struct dedic_gpio_platform_t dedic_gpio_platform_t; @@ -313,7 +312,7 @@ esp_err_t dedic_gpio_del_bundle(dedic_gpio_bundle_handle_t bundle) s_platform[core_id]->out_occupied_mask &= ~(bundle->out_mask); s_platform[core_id]->in_occupied_mask &= ~(bundle->in_mask); if (s_platform[core_id]->in_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_IN_CHANNELS_NUM) - 1)) && - s_platform[core_id]->out_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_OUT_CHANNELS_NUM) - 1))) { + s_platform[core_id]->out_occupied_mask == (UINT32_MAX & ~((1 << SOC_DEDIC_GPIO_OUT_CHANNELS_NUM) - 1))) { recycle_all = true; } portEXIT_CRITICAL(&s_platform[core_id]->spinlock); @@ -349,7 +348,6 @@ err: return ret; } - esp_err_t dedic_gpio_get_out_offset(dedic_gpio_bundle_handle_t bundle, uint32_t *offset) { esp_err_t ret = ESP_OK; diff --git a/components/driver/gpio/gpio.c b/components/esp_driver_gpio/src/gpio.c similarity index 94% rename from components/driver/gpio/gpio.c rename to components/esp_driver_gpio/src/gpio.c index e1d81a2b3e..3e09f30a60 100644 --- a/components/driver/gpio/gpio.c +++ b/components/esp_driver_gpio/src/gpio.c @@ -10,8 +10,7 @@ #include "esp_heap_caps.h" #include "driver/gpio.h" #include "driver/rtc_io.h" -#include "soc/soc.h" -#include "soc/periph_defs.h" +#include "soc/interrupts.h" #if !CONFIG_FREERTOS_UNICORE #include "esp_ipc.h" #endif @@ -166,7 +165,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type) return ESP_OK; } -static esp_err_t gpio_intr_enable_on_core(gpio_num_t gpio_num, uint32_t core_id) +static inline esp_err_t gpio_intr_enable_on_core(gpio_num_t gpio_num, uint32_t core_id) { gpio_hal_intr_enable_on_core(gpio_context.gpio_hal, gpio_num, core_id); return ESP_OK; @@ -176,11 +175,11 @@ esp_err_t gpio_intr_enable(gpio_num_t gpio_num) { GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG); portENTER_CRITICAL(&gpio_context.gpio_spinlock); - if(gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) { + if (gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) { gpio_context.isr_core_id = xPortGetCoreID(); } portEXIT_CRITICAL(&gpio_context.gpio_spinlock); - return gpio_intr_enable_on_core (gpio_num, gpio_context.isr_core_id); + return gpio_intr_enable_on_core(gpio_num, gpio_context.isr_core_id); } esp_err_t gpio_intr_disable(gpio_num_t gpio_num) @@ -274,30 +273,30 @@ esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull) esp_err_t ret = ESP_OK; switch (pull) { - case GPIO_PULLUP_ONLY: - gpio_pulldown_dis(gpio_num); - gpio_pullup_en(gpio_num); - break; + case GPIO_PULLUP_ONLY: + gpio_pulldown_dis(gpio_num); + gpio_pullup_en(gpio_num); + break; - case GPIO_PULLDOWN_ONLY: - gpio_pulldown_en(gpio_num); - gpio_pullup_dis(gpio_num); - break; + case GPIO_PULLDOWN_ONLY: + gpio_pulldown_en(gpio_num); + gpio_pullup_dis(gpio_num); + break; - case GPIO_PULLUP_PULLDOWN: - gpio_pulldown_en(gpio_num); - gpio_pullup_en(gpio_num); - break; + case GPIO_PULLUP_PULLDOWN: + gpio_pulldown_en(gpio_num); + gpio_pullup_en(gpio_num); + break; - case GPIO_FLOATING: - gpio_pulldown_dis(gpio_num); - gpio_pullup_dis(gpio_num); - break; + case GPIO_FLOATING: + gpio_pulldown_dis(gpio_num); + gpio_pullup_dis(gpio_num); + break; - default: - ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull); - ret = ESP_ERR_INVALID_ARG; - break; + default: + ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull); + ret = ESP_ERR_INVALID_ARG; + break; } return ret; @@ -347,13 +346,13 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig) uint8_t pd_en = 0; if (pGPIOConfig->pin_bit_mask == 0 || - pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_GPIO_MASK) { + pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_GPIO_MASK) { ESP_LOGE(GPIO_TAG, "GPIO_PIN mask error "); return ESP_ERR_INVALID_ARG; } if (pGPIOConfig->mode & GPIO_MODE_DEF_OUTPUT && - pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_OUTPUT_GPIO_MASK) { + pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_OUTPUT_GPIO_MASK) { ESP_LOGE(GPIO_TAG, "GPIO can only be used as input mode"); return ESP_ERR_INVALID_ARG; } @@ -538,7 +537,7 @@ esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void gpio_context.gpio_isr_func[gpio_num].fn = isr_handler; gpio_context.gpio_isr_func[gpio_num].args = args; } - gpio_intr_enable_on_core (gpio_num, esp_intr_get_cpu(gpio_context.gpio_isr_handle)); + gpio_intr_enable_on_core(gpio_num, esp_intr_get_cpu(gpio_context.gpio_isr_handle)); portEXIT_CRITICAL(&gpio_context.gpio_spinlock); return ESP_OK; } @@ -577,7 +576,6 @@ void gpio_uninstall_isr_service(void) return; } - static void gpio_isr_register_on_core_static(void *param) { gpio_isr_alloc_t *p = (gpio_isr_alloc_t *)param; @@ -602,7 +600,7 @@ esp_err_t gpio_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags, p.arg = arg; p.handle = handle; portENTER_CRITICAL(&gpio_context.gpio_spinlock); - if(gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) { + if (gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) { gpio_context.isr_core_id = xPortGetCoreID(); } portEXIT_CRITICAL(&gpio_context.gpio_spinlock); @@ -739,7 +737,7 @@ esp_err_t gpio_hold_dis(gpio_num_t gpio_num) #if SOC_RTCIO_HOLD_SUPPORTED ret = rtc_gpio_hold_dis(gpio_num); #endif - }else if (GPIO_HOLD_MASK[gpio_num]) { + } else if (GPIO_HOLD_MASK[gpio_num]) { portENTER_CRITICAL(&gpio_context.gpio_spinlock); gpio_hal_hold_dis(gpio_context.gpio_hal, gpio_num); portEXIT_CRITICAL(&gpio_context.gpio_spinlock); @@ -905,30 +903,30 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull) esp_err_t ret = ESP_OK; switch (pull) { - case GPIO_PULLUP_ONLY: - gpio_sleep_pulldown_dis(gpio_num); - gpio_sleep_pullup_en(gpio_num); - break; + case GPIO_PULLUP_ONLY: + gpio_sleep_pulldown_dis(gpio_num); + gpio_sleep_pullup_en(gpio_num); + break; - case GPIO_PULLDOWN_ONLY: - gpio_sleep_pulldown_en(gpio_num); - gpio_sleep_pullup_dis(gpio_num); - break; + case GPIO_PULLDOWN_ONLY: + gpio_sleep_pulldown_en(gpio_num); + gpio_sleep_pullup_dis(gpio_num); + break; - case GPIO_PULLUP_PULLDOWN: - gpio_sleep_pulldown_en(gpio_num); - gpio_sleep_pullup_en(gpio_num); - break; + case GPIO_PULLUP_PULLDOWN: + gpio_sleep_pulldown_en(gpio_num); + gpio_sleep_pullup_en(gpio_num); + break; - case GPIO_FLOATING: - gpio_sleep_pulldown_dis(gpio_num); - gpio_sleep_pullup_dis(gpio_num); - break; + case GPIO_FLOATING: + gpio_sleep_pulldown_dis(gpio_num); + gpio_sleep_pullup_dis(gpio_num); + break; - default: - ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull); - ret = ESP_ERR_INVALID_ARG; - break; + default: + ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull); + ret = ESP_ERR_INVALID_ARG; + break; } return ret; diff --git a/components/driver/gpio/gpio_etm.c b/components/esp_driver_gpio/src/gpio_etm.c similarity index 100% rename from components/driver/gpio/gpio_etm.c rename to components/esp_driver_gpio/src/gpio_etm.c diff --git a/components/driver/gpio/gpio_flex_glitch_filter.c b/components/esp_driver_gpio/src/gpio_flex_glitch_filter.c similarity index 99% rename from components/driver/gpio/gpio_flex_glitch_filter.c rename to components/esp_driver_gpio/src/gpio_flex_glitch_filter.c index 8a0138e46f..1c16b10094 100644 --- a/components/driver/gpio/gpio_flex_glitch_filter.c +++ b/components/esp_driver_gpio/src/gpio_flex_glitch_filter.c @@ -7,7 +7,7 @@ #include #include "freertos/FreeRTOS.h" #include "esp_check.h" -#include "glitch_filter_priv.h" +#include "esp_private/glitch_filter_priv.h" #include "esp_private/io_mux.h" #include "soc/soc_caps.h" #include "hal/gpio_glitch_filter_ll.h" diff --git a/components/driver/gpio/gpio_glitch_filter_ops.c b/components/esp_driver_gpio/src/gpio_glitch_filter_ops.c similarity index 94% rename from components/driver/gpio/gpio_glitch_filter_ops.c rename to components/esp_driver_gpio/src/gpio_glitch_filter_ops.c index 841d095326..001968575d 100644 --- a/components/driver/gpio/gpio_glitch_filter_ops.c +++ b/components/esp_driver_gpio/src/gpio_glitch_filter_ops.c @@ -5,7 +5,7 @@ */ #include "esp_check.h" -#include "glitch_filter_priv.h" +#include "esp_private/glitch_filter_priv.h" static const char *TAG = "gpio-filter"; diff --git a/components/driver/gpio/gpio_pin_glitch_filter.c b/components/esp_driver_gpio/src/gpio_pin_glitch_filter.c similarity index 98% rename from components/driver/gpio/gpio_pin_glitch_filter.c rename to components/esp_driver_gpio/src/gpio_pin_glitch_filter.c index 877f345e4f..3778becfe7 100644 --- a/components/driver/gpio/gpio_pin_glitch_filter.c +++ b/components/esp_driver_gpio/src/gpio_pin_glitch_filter.c @@ -8,7 +8,7 @@ #include "freertos/FreeRTOS.h" #include "esp_check.h" #include "esp_pm.h" -#include "glitch_filter_priv.h" +#include "esp_private/glitch_filter_priv.h" #include "hal/gpio_ll.h" #include "esp_clk_tree.h" #include "esp_private/io_mux.h" diff --git a/components/driver/gpio/rtc_io.c b/components/esp_driver_gpio/src/rtc_io.c similarity index 100% rename from components/driver/gpio/rtc_io.c rename to components/esp_driver_gpio/src/rtc_io.c diff --git a/components/esp_driver_gpio/test_apps/.build-test-rules.yml b/components/esp_driver_gpio/test_apps/.build-test-rules.yml new file mode 100644 index 0000000000..13e104d9c9 --- /dev/null +++ b/components/esp_driver_gpio/test_apps/.build-test-rules.yml @@ -0,0 +1,10 @@ +# Documentation: .gitlab/ci/README.md#manifest-file-to-control-the-buildtest-apps + +components/esp_driver_gpio/test_apps: + depends_components: + - esp_driver_gpio + +components/esp_driver_gpio/test_apps/gpio_extensions: + enable: + - if: SOC_DEDICATED_GPIO_SUPPORTED == 1 + - if: SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER == 1 or SOC_GPIO_FLEX_GLITCH_FILTER_NUM > 0 diff --git a/components/esp_driver_gpio/test_apps/gpio/CMakeLists.txt b/components/esp_driver_gpio/test_apps/gpio/CMakeLists.txt new file mode 100644 index 0000000000..886e85131a --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio/CMakeLists.txt @@ -0,0 +1,21 @@ +# This is the project CMakeLists.txt file for the test subproject +cmake_minimum_required(VERSION 3.16) + +# "Trim" the build. Include the minimal set of components, main, and anything it depends on. +set(COMPONENTS main) + +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(gpio_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/esp_driver_gpio/,${CMAKE_BINARY_DIR}/esp-idf/hal/ + --elf-file ${CMAKE_BINARY_DIR}/gpio_test.elf + find-refs + --from-sections=.iram0.text + --to-sections=.flash.text,.flash.rodata + --exit-code + DEPENDS ${elf} + ) +endif() diff --git a/components/driver/test_apps/gpio/README.md b/components/esp_driver_gpio/test_apps/gpio/README.md similarity index 100% rename from components/driver/test_apps/gpio/README.md rename to components/esp_driver_gpio/test_apps/gpio/README.md diff --git a/components/driver/test_apps/gpio/main/CMakeLists.txt b/components/esp_driver_gpio/test_apps/gpio/main/CMakeLists.txt similarity index 69% rename from components/driver/test_apps/gpio/main/CMakeLists.txt rename to components/esp_driver_gpio/test_apps/gpio/main/CMakeLists.txt index de29a112f9..54bda14eae 100644 --- a/components/driver/test_apps/gpio/main/CMakeLists.txt +++ b/components/esp_driver_gpio/test_apps/gpio/main/CMakeLists.txt @@ -1,10 +1,6 @@ set(srcs "test_app_main.c" "test_gpio.c") -if(CONFIG_SOC_SDM_SUPPORTED) - list(APPEND srcs "test_sigma_delta_legacy.c") -endif() - if(CONFIG_SOC_RTCIO_PIN_COUNT GREATER 0) list(APPEND srcs "test_rtcio.c") endif() @@ -12,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 unity driver spi_flash + PRIV_REQUIRES unity esp_driver_gpio spi_flash WHOLE_ARCHIVE) diff --git a/components/esp_driver_gpio/test_apps/gpio/main/test_app_main.c b/components/esp_driver_gpio/test_apps/gpio/main/test_app_main.c new file mode 100644 index 0000000000..bb65240ed5 --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio/main/test_app_main.c @@ -0,0 +1,29 @@ +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "unity.h" +#include "unity_test_runner.h" +#include "unity_test_utils.h" +#include "esp_heap_caps.h" + +// Some resources are lazy allocated in gpio/rtcio driver, the threshold is left for that case +#define TEST_MEMORY_LEAK_THRESHOLD (100) + +void setUp(void) +{ + unity_utils_record_free_mem(); +} + +void tearDown(void) +{ + esp_reent_cleanup(); //clean up some of the newlib's lazy allocations + unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD); +} + +void app_main(void) +{ + unity_run_menu(); +} diff --git a/components/driver/test_apps/gpio/main/test_gpio.c b/components/esp_driver_gpio/test_apps/gpio/main/test_gpio.c similarity index 100% rename from components/driver/test_apps/gpio/main/test_gpio.c rename to components/esp_driver_gpio/test_apps/gpio/main/test_gpio.c diff --git a/components/driver/test_apps/gpio/main/test_gpio.h b/components/esp_driver_gpio/test_apps/gpio/main/test_gpio.h similarity index 100% rename from components/driver/test_apps/gpio/main/test_gpio.h rename to components/esp_driver_gpio/test_apps/gpio/main/test_gpio.h diff --git a/components/driver/test_apps/gpio/main/test_rtcio.c b/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c similarity index 80% rename from components/driver/test_apps/gpio/main/test_rtcio.c rename to components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c index 346d774b13..fcc12b8a97 100644 --- a/components/driver/test_apps/gpio/main/test_rtcio.c +++ b/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c @@ -36,10 +36,10 @@ TEST_CASE("RTCIO_input/output_test", "[rtcio]") // init rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_init(i) ); - RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT) ); - RTCIO_CHECK( rtc_gpio_pullup_dis(i) ); - RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); + RTCIO_CHECK(rtc_gpio_init(i)); + RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT)); + RTCIO_CHECK(rtc_gpio_pullup_dis(i)); + RTCIO_CHECK(rtc_gpio_pulldown_dis(i)); ESP_LOGI(TAG, "gpio %d init", i); } } @@ -49,7 +49,7 @@ TEST_CASE("RTCIO_input/output_test", "[rtcio]") ESP_LOGI(TAG, "RTCIO output level %d", level); for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_set_level(i, level) ); + RTCIO_CHECK(rtc_gpio_set_level(i, level)); vTaskDelay(10 / portTICK_PERIOD_MS); if (rtc_gpio_get_level(i) != level) { ESP_LOGE(TAG, "RTCIO input/output test err, gpio%d", i); @@ -63,7 +63,7 @@ TEST_CASE("RTCIO_input/output_test", "[rtcio]") // Deinit rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_deinit(i) ); + RTCIO_CHECK(rtc_gpio_deinit(i)); } } ESP_LOGI(TAG, "RTCIO input/output test over"); @@ -81,10 +81,10 @@ TEST_CASE("RTCIO_pullup/pulldown_test", "[rtcio]") for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) { int num = rtc_io_number_get(s_test_map[i]); if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && RTCIO_SUPPORT_PU_PD(num)) { - RTCIO_CHECK( rtc_gpio_init(s_test_map[i]) ); - RTCIO_CHECK( rtc_gpio_set_direction(s_test_map[i], RTC_GPIO_MODE_INPUT_ONLY) ); - RTCIO_CHECK( rtc_gpio_pullup_dis(s_test_map[i]) ); - RTCIO_CHECK( rtc_gpio_pulldown_dis(s_test_map[i]) ); + RTCIO_CHECK(rtc_gpio_init(s_test_map[i])); + RTCIO_CHECK(rtc_gpio_set_direction(s_test_map[i], RTC_GPIO_MODE_INPUT_ONLY)); + RTCIO_CHECK(rtc_gpio_pullup_dis(s_test_map[i])); + RTCIO_CHECK(rtc_gpio_pulldown_dis(s_test_map[i])); ESP_LOGI(TAG, "gpio %d init", s_test_map[i]); } } @@ -96,11 +96,11 @@ TEST_CASE("RTCIO_pullup/pulldown_test", "[rtcio]") int num = rtc_io_number_get(s_test_map[i]); if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && RTCIO_SUPPORT_PU_PD(num)) { if (level) { - RTCIO_CHECK( rtc_gpio_pulldown_dis(s_test_map[i]) ); - RTCIO_CHECK( rtc_gpio_pullup_en(s_test_map[i]) ); + RTCIO_CHECK(rtc_gpio_pulldown_dis(s_test_map[i])); + RTCIO_CHECK(rtc_gpio_pullup_en(s_test_map[i])); } else { - RTCIO_CHECK( rtc_gpio_pullup_dis(s_test_map[i]) ); - RTCIO_CHECK( rtc_gpio_pulldown_en(s_test_map[i]) ); + RTCIO_CHECK(rtc_gpio_pullup_dis(s_test_map[i])); + RTCIO_CHECK(rtc_gpio_pulldown_en(s_test_map[i])); } vTaskDelay(20 / portTICK_PERIOD_MS); if (rtc_gpio_get_level(s_test_map[i]) != level) { @@ -116,7 +116,7 @@ TEST_CASE("RTCIO_pullup/pulldown_test", "[rtcio]") for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) { int num = rtc_io_number_get(s_test_map[i]); if (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && RTCIO_SUPPORT_PU_PD(num)) { - RTCIO_CHECK( rtc_gpio_deinit(s_test_map[i]) ); + RTCIO_CHECK(rtc_gpio_deinit(s_test_map[i])); } } ESP_LOGI(TAG, "RTCIO pullup/pulldown test over"); @@ -132,10 +132,10 @@ TEST_CASE("RTCIO_output_OD_test", "[rtcio]") // init rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_init(i) ); - RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD) ); - RTCIO_CHECK( rtc_gpio_pullup_en(i) ); - RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); + RTCIO_CHECK(rtc_gpio_init(i)); + RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD)); + RTCIO_CHECK(rtc_gpio_pullup_en(i)); + RTCIO_CHECK(rtc_gpio_pulldown_dis(i)); ESP_LOGI(TAG, "gpio %d init", i); } } @@ -145,7 +145,7 @@ TEST_CASE("RTCIO_output_OD_test", "[rtcio]") ESP_LOGI(TAG, "RTCIO output level %d", level); for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_set_level(i, level) ); + RTCIO_CHECK(rtc_gpio_set_level(i, level)); vTaskDelay(10 / portTICK_PERIOD_MS); if (rtc_gpio_get_level(i) != level) { ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i); @@ -159,7 +159,7 @@ TEST_CASE("RTCIO_output_OD_test", "[rtcio]") // Deinit rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_deinit(i) ); + RTCIO_CHECK(rtc_gpio_deinit(i)); } } ESP_LOGI(TAG, "RTCIO output OD test over"); @@ -176,11 +176,11 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") // init rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_init(i) ); - RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD) ); - RTCIO_CHECK( rtc_gpio_pullup_en(i) ); - RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); - RTCIO_CHECK( rtc_gpio_set_level(i, 1) ); + RTCIO_CHECK(rtc_gpio_init(i)); + RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD)); + RTCIO_CHECK(rtc_gpio_pullup_en(i)); + RTCIO_CHECK(rtc_gpio_pulldown_dis(i)); + RTCIO_CHECK(rtc_gpio_set_level(i, 1)); ESP_LOGI(TAG, "gpio %d init, level 1", i); } } @@ -188,9 +188,9 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") // hold all output rtcio. for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_hold_en(i) ); + RTCIO_CHECK(rtc_gpio_hold_en(i)); vTaskDelay(10 / portTICK_PERIOD_MS); - RTCIO_CHECK( rtc_gpio_set_level(i, 0) ); + RTCIO_CHECK(rtc_gpio_set_level(i, 0)); ESP_LOGI(TAG, "RTCIO output pin hold, then set level 0"); vTaskDelay(10 / portTICK_PERIOD_MS); if (rtc_gpio_get_level(i) == 0) { @@ -203,7 +203,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") // unhold all rtcio. for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_hold_dis(i) ); + RTCIO_CHECK(rtc_gpio_hold_dis(i)); } } @@ -213,7 +213,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") ESP_LOGI(TAG, "RTCIO output level %d", level); for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_set_level(i, level) ); + RTCIO_CHECK(rtc_gpio_set_level(i, level)); vTaskDelay(10 / portTICK_PERIOD_MS); if (rtc_gpio_get_level(i) != level) { ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i); @@ -227,7 +227,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]") // Deinit rtcio for (int i = 0; i < GPIO_PIN_COUNT; i++) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { - RTCIO_CHECK( rtc_gpio_deinit(i) ); + RTCIO_CHECK(rtc_gpio_deinit(i)); } } ESP_LOGI(TAG, "RTCIO hold test over"); @@ -282,6 +282,6 @@ static void rtcio_deep_sleep_hold_test_second_stage(void) * please use logic analyzer or oscilloscope */ TEST_CASE_MULTIPLE_STAGES("RTCIO_deep_sleep_output_hold_test", "[rtcio]", - rtcio_deep_sleep_hold_test_first_stage, - rtcio_deep_sleep_hold_test_second_stage) + rtcio_deep_sleep_hold_test_first_stage, + rtcio_deep_sleep_hold_test_second_stage) #endif // !TEMPORARY_DISABLED_FOR_TARGETS(ESP32P4) diff --git a/components/driver/test_apps/gpio/main/test_rtcio.h b/components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.h similarity index 100% rename from components/driver/test_apps/gpio/main/test_rtcio.h rename to components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.h diff --git a/components/driver/test_apps/gpio/pytest_gpio.py b/components/esp_driver_gpio/test_apps/gpio/pytest_gpio.py similarity index 69% rename from components/driver/test_apps/gpio/pytest_gpio.py rename to components/esp_driver_gpio/test_apps/gpio/pytest_gpio.py index f0682a007d..09cba42044 100644 --- a/components/driver/test_apps/gpio/pytest_gpio.py +++ b/components/esp_driver_gpio/test_apps/gpio/pytest_gpio.py @@ -17,18 +17,6 @@ def test_gpio(dut: IdfDut) -> None: dut.run_all_single_board_cases(group='gpio') -@pytest.mark.esp32 -@pytest.mark.esp32c3 -@pytest.mark.esp32c6 -@pytest.mark.esp32h2 -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.generic -@pytest.mark.parametrize('config', CONFIGS, indirect=True) -def test_legacy_sigma_delta(dut: IdfDut) -> None: - dut.run_all_single_board_cases(group='sigma_delta') - - @pytest.mark.esp32 @pytest.mark.esp32s2 @pytest.mark.esp32s3 diff --git a/components/driver/test_apps/gpio/sdkconfig.ci.iram_safe b/components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.iram_safe similarity index 100% rename from components/driver/test_apps/gpio/sdkconfig.ci.iram_safe rename to components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.iram_safe diff --git a/components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.release b/components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.release new file mode 100644 index 0000000000..91d93f163e --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.release @@ -0,0 +1,5 @@ +CONFIG_PM_ENABLE=y +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/components/esp_driver_gpio/test_apps/gpio/sdkconfig.defaults b/components/esp_driver_gpio/test_apps/gpio/sdkconfig.defaults new file mode 100644 index 0000000000..fa8ac618b9 --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/driver/test_apps/gpio_extensions/CMakeLists.txt b/components/esp_driver_gpio/test_apps/gpio_extensions/CMakeLists.txt similarity index 87% rename from components/driver/test_apps/gpio_extensions/CMakeLists.txt rename to components/esp_driver_gpio/test_apps/gpio_extensions/CMakeLists.txt index 42d10a8553..fb191523e9 100644 --- a/components/driver/test_apps/gpio_extensions/CMakeLists.txt +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/CMakeLists.txt @@ -10,7 +10,7 @@ project(gpio_extension_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_gpio/,${CMAKE_BINARY_DIR}/esp-idf/hal/ --elf-file ${CMAKE_BINARY_DIR}/gpio_extension_test.elf find-refs --from-sections=.iram0.text diff --git a/components/esp_driver_gpio/test_apps/gpio_extensions/README.md b/components/esp_driver_gpio/test_apps/gpio_extensions/README.md new file mode 100644 index 0000000000..d2553ff6db --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/README.md @@ -0,0 +1,2 @@ +| Supported Targets | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 | +| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- | diff --git a/components/driver/test_apps/gpio_extensions/main/CMakeLists.txt b/components/esp_driver_gpio/test_apps/gpio_extensions/main/CMakeLists.txt similarity index 82% rename from components/driver/test_apps/gpio_extensions/main/CMakeLists.txt rename to components/esp_driver_gpio/test_apps/gpio_extensions/main/CMakeLists.txt index 81700812a4..3b4bd6d620 100644 --- a/components/driver/test_apps/gpio_extensions/main/CMakeLists.txt +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/main/CMakeLists.txt @@ -8,10 +8,6 @@ if(CONFIG_SOC_GPIO_SUPPORT_PIN_GLITCH_FILTER OR (CONFIG_SOC_GPIO_FLEX_GLITCH_FIL list(APPEND srcs "test_gpio_filter.c") endif() -if(CONFIG_SOC_SDM_SUPPORTED) - list(APPEND srcs "test_sdm.c") -endif() - if(CONFIG_SOC_GPIO_SUPPORT_PIN_HYS_FILTER) list(APPEND srcs "test_hysteresis.c") endif() @@ -19,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 driver + PRIV_REQUIRES unity esp_driver_gpio WHOLE_ARCHIVE) diff --git a/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_app_main.c b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_app_main.c new file mode 100644 index 0000000000..60becdb1e9 --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_app_main.c @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ + +#include "unity.h" +#include "unity_test_utils.h" +#include "esp_heap_caps.h" + +// Some resources are lazy allocated in the driver, the threshold is left for that case +#define TEST_MEMORY_LEAK_THRESHOLD (300) + +void setUp(void) +{ + unity_utils_record_free_mem(); +} + +void tearDown(void) +{ + esp_reent_cleanup(); //clean up some of the newlib's lazy allocations + unity_utils_evaluate_leaks_direct(TEST_MEMORY_LEAK_THRESHOLD); +} + +void app_main(void) +{ + // ____ ____ ___ ___ _____ _ _____ _ + // / ___| _ \_ _/ _ \ | ____|_ _| |_ |_ _|__ ___| |_ + // | | _| |_) | | | | | | _| \ \/ / __| | |/ _ \/ __| __| + // | |_| | __/| | |_| | | |___ > <| |_ | | __/\__ \ |_ + // \____|_| |___\___/ |_____/_/\_\\__| |_|\___||___/\__| + printf(" ____ ____ ___ ___ _____ _ _____ _\r\n"); + printf(" / ___| _ \\_ _/ _ \\ | ____|_ _| |_ |_ _|__ ___| |_\r\n"); + printf("| | _| |_) | | | | | | _| \\ \\/ / __| | |/ _ \\/ __| __|\r\n"); + printf("| |_| | __/| | |_| | | |___ > <| |_ | | __/\\__ \\ |_\r\n"); + printf(" \\____|_| |___\\___/ |_____/_/\\_\\\\__| |_|\\___||___/\\__|\r\n"); + unity_run_menu(); +} diff --git a/components/driver/test_apps/gpio_extensions/main/test_dedicated_gpio.c b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_dedicated_gpio.c similarity index 100% rename from components/driver/test_apps/gpio_extensions/main/test_dedicated_gpio.c rename to components/esp_driver_gpio/test_apps/gpio_extensions/main/test_dedicated_gpio.c diff --git a/components/driver/test_apps/gpio_extensions/main/test_gpio_filter.c b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_gpio_filter.c similarity index 100% rename from components/driver/test_apps/gpio_extensions/main/test_gpio_filter.c rename to components/esp_driver_gpio/test_apps/gpio_extensions/main/test_gpio_filter.c diff --git a/components/driver/test_apps/gpio_extensions/main/test_hysteresis.c b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_hysteresis.c similarity index 93% rename from components/driver/test_apps/gpio_extensions/main/test_hysteresis.c rename to components/esp_driver_gpio/test_apps/gpio_extensions/main/test_hysteresis.c index e3acf87b92..d75594d2a9 100644 --- a/components/driver/test_apps/gpio_extensions/main/test_hysteresis.c +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/main/test_hysteresis.c @@ -9,7 +9,6 @@ #include "unity.h" #include "driver/gpio.h" - /** * NOTE: To run this special feature test case, a slope analog signal is needed. * A simple RC circuit used here to formate pin switches to continuos slop signal. @@ -29,10 +28,9 @@ * which enabled the hysteresis feature directly to have a test. **/ - static void test_gpio_hysteresis_intr_handler(void *args) { - esp_rom_printf("%d\n", ++*((uint32_t *)args)); + esp_rom_printf("%d\n", ++ * ((uint32_t *)args)); } // This case is now tested only manually @@ -40,10 +38,10 @@ TEST_CASE("GPIO Input hysteresis filter", "[gpio_filter][timeout=50][ignore]") { const gpio_num_t TEST_HYS_IO = 26; const gpio_num_t TEST_WAVE_IO = 27; - uint32_t intr_cnt=0; + uint32_t intr_cnt = 0; gpio_config_t gpio_cfg = { - .pin_bit_mask = 1 << TEST_WAVE_IO, + .pin_bit_mask = (1 << TEST_WAVE_IO), .mode = GPIO_MODE_OUTPUT, .pull_down_en = GPIO_PULLDOWN_ENABLE, }; @@ -59,7 +57,7 @@ TEST_CASE("GPIO Input hysteresis filter", "[gpio_filter][timeout=50][ignore]") gpio_isr_handler_add(TEST_HYS_IO, test_gpio_hysteresis_intr_handler, &intr_cnt); // generate 5 rising and falling slopes to test gpio interrupt - for (uint8_t i=0; i<5; i++) { + for (uint8_t i = 0; i < 5; i++) { printf("----falling %dth\n", i); gpio_set_level(TEST_WAVE_IO, 0); vTaskDelay(1500); diff --git a/components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py b/components/esp_driver_gpio/test_apps/gpio_extensions/pytest_gpio_extensions.py similarity index 72% rename from components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py rename to components/esp_driver_gpio/test_apps/gpio_extensions/pytest_gpio_extensions.py index 7da5ce3c9d..a51ae5e89d 100644 --- a/components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/pytest_gpio_extensions.py @@ -10,19 +10,6 @@ CONFIGS = [ ] -@pytest.mark.esp32 -@pytest.mark.esp32c3 -@pytest.mark.esp32c6 -@pytest.mark.esp32h2 -@pytest.mark.esp32s2 -@pytest.mark.esp32s3 -@pytest.mark.esp32h2 -@pytest.mark.generic -@pytest.mark.parametrize('config', CONFIGS, indirect=True) -def test_sdm(dut: IdfDut) -> None: - dut.run_all_single_board_cases(group='sdm') - - @pytest.mark.esp32c2 @pytest.mark.esp32c3 @pytest.mark.esp32c6 diff --git a/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.iram_safe b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.iram_safe new file mode 100644 index 0000000000..9eb666b35b --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.iram_safe @@ -0,0 +1,9 @@ +CONFIG_COMPILER_DUMP_RTL_FILES=y +CONFIG_COMPILER_OPTIMIZATION_NONE=y +# place non-ISR FreeRTOS functions in Flash +CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y +# silent the error check, as the error string are stored in rodata, causing RTL check failure +CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y +# GPIO test uses IPC call, the default stack size of IPC task can satisfy the -O0 optimization +CONFIG_ESP_IPC_TASK_STACK_SIZE=2048 diff --git a/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.release b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.release new file mode 100644 index 0000000000..91d93f163e --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.release @@ -0,0 +1,5 @@ +CONFIG_PM_ENABLE=y +CONFIG_FREERTOS_USE_TICKLESS_IDLE=y +CONFIG_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT=y diff --git a/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.defaults b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.defaults new file mode 100644 index 0000000000..fa8ac618b9 --- /dev/null +++ b/components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.defaults @@ -0,0 +1,2 @@ +CONFIG_FREERTOS_HZ=1000 +CONFIG_ESP_TASK_WDT_EN=n diff --git a/components/esp_driver_pcnt/CMakeLists.txt b/components/esp_driver_pcnt/CMakeLists.txt index fa3864076f..d146afbab4 100644 --- a/components/esp_driver_pcnt/CMakeLists.txt +++ b/components/esp_driver_pcnt/CMakeLists.txt @@ -11,7 +11,7 @@ else() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${public_include} PRIV_REQUIRES "esp_pm" - "driver" # will be replaced by esp_driver_gpio + "esp_driver_gpio" LDFRAGMENTS "linker.lf" ) endif() diff --git a/components/esp_eth/CMakeLists.txt b/components/esp_eth/CMakeLists.txt index 55f0fc0937..439180e557 100644 --- a/components/esp_eth/CMakeLists.txt +++ b/components/esp_eth/CMakeLists.txt @@ -67,7 +67,7 @@ endif() if(CONFIG_ETH_ENABLED) if(CONFIG_ETH_USE_SPI_ETHERNET) - idf_component_optional_requires(PUBLIC driver) + idf_component_optional_requires(PUBLIC driver esp_driver_gpio) endif() idf_component_optional_requires(PRIVATE esp_netif esp_pm) endif() diff --git a/components/esp_hw_support/CMakeLists.txt b/components/esp_hw_support/CMakeLists.txt index ad5e37ad64..f996e17e52 100644 --- a/components/esp_hw_support/CMakeLists.txt +++ b/components/esp_hw_support/CMakeLists.txt @@ -50,8 +50,11 @@ if(NOT BOOTLOADER_BUILD) list(APPEND srcs "sleep_retention.c" "sleep_system_peripheral.c" "sleep_clock.c") endif() - # [refactor-todo]: requires "driver" for GPIO and RTC (by sleep_gpio and sleep_modes) - list(APPEND priv_requires driver esp_timer) + # [refactor-todo] + list(APPEND priv_requires driver # for UART (by sleep_modes) + esp_driver_gpio # for GPIO and RTC (by sleep_gpio and sleep_modes) + esp_timer + esp_pm) list(APPEND priv_requires esp_mm) diff --git a/components/esp_lcd/CMakeLists.txt b/components/esp_lcd/CMakeLists.txt index 9e1c10b137..aa0595a54d 100644 --- a/components/esp_lcd/CMakeLists.txt +++ b/components/esp_lcd/CMakeLists.txt @@ -27,5 +27,5 @@ endif() idf_component_register(SRCS ${srcs} INCLUDE_DIRS ${includes} PRIV_REQUIRES ${priv_requires} - REQUIRES driver + REQUIRES driver esp_driver_gpio LDFRAGMENTS linker.lf) diff --git a/components/esp_pm/CMakeLists.txt b/components/esp_pm/CMakeLists.txt index 72c9742371..a4b414e99b 100644 --- a/components/esp_pm/CMakeLists.txt +++ b/components/esp_pm/CMakeLists.txt @@ -6,5 +6,5 @@ endif() idf_component_register(SRCS "pm_locks.c" "pm_trace.c" "pm_impl.c" INCLUDE_DIRS include - PRIV_REQUIRES esp_system driver esp_timer + PRIV_REQUIRES esp_system driver esp_driver_gpio esp_timer LDFRAGMENTS linker.lf) diff --git a/components/esp_pm/linker.lf b/components/esp_pm/linker.lf index ea712c420c..b1809a422a 100644 --- a/components/esp_pm/linker.lf +++ b/components/esp_pm/linker.lf @@ -77,7 +77,7 @@ entries: esp_time_impl:esp_set_time_from_rtc (noflash) [mapping:driver_pm] -archive: libdriver.a +archive: libesp_driver_gpio.a entries: if GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL = y: gpio:gpio_sleep_pupd_config_unapply (noflash) diff --git a/components/espcoredump/CMakeLists.txt b/components/espcoredump/CMakeLists.txt index 3b1e88fce3..32eb401208 100644 --- a/components/espcoredump/CMakeLists.txt +++ b/components/espcoredump/CMakeLists.txt @@ -27,10 +27,14 @@ elseif(CONFIG_IDF_TARGET_ARCH_RISCV) endif() idf_component_register(SRCS ${srcs} - INCLUDE_DIRS ${includes} - PRIV_INCLUDE_DIRS ${priv_includes} - LDFRAGMENTS linker.lf - PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system driver) + INCLUDE_DIRS ${includes} + PRIV_INCLUDE_DIRS ${priv_includes} + LDFRAGMENTS linker.lf + PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system + esp_driver_gpio + # [refactor-todo] esp_flash_internal.h -> spi_common_internal.h requires cleanup + driver + ) if(CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF) target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format) diff --git a/components/fatfs/CMakeLists.txt b/components/fatfs/CMakeLists.txt index b6a288e0d0..e9ae1f8874 100644 --- a/components/fatfs/CMakeLists.txt +++ b/components/fatfs/CMakeLists.txt @@ -24,7 +24,7 @@ else() list(APPEND requires "sdmmc") - list(APPEND priv_requires "vfs") + list(APPEND priv_requires "vfs" "esp_driver_gpio") endif() idf_component_register(SRCS ${srcs} diff --git a/components/hal/esp32/include/hal/gpio_ll.h b/components/hal/esp32/include/hal/gpio_ll.h index 3a5963f26c..c78ec7d112 100644 --- a/components/hal/esp32/include/hal/gpio_ll.h +++ b/components/hal/esp32/include/hal/gpio_ll.h @@ -508,6 +508,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { if (gpio_num < 32) { diff --git a/components/hal/esp32c2/include/hal/gpio_ll.h b/components/hal/esp32c2/include/hal/gpio_ll.h index ad70573110..d9ae5c07ed 100644 --- a/components/hal/esp32c2/include/hal/gpio_ll.h +++ b/components/hal/esp32c2/include/hal/gpio_ll.h @@ -332,6 +332,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { return (hw->in.in_data_next >> gpio_num) & 0x1; diff --git a/components/hal/esp32c3/include/hal/gpio_ll.h b/components/hal/esp32c3/include/hal/gpio_ll.h index 75e9e82c60..6ff4bf6492 100644 --- a/components/hal/esp32c3/include/hal/gpio_ll.h +++ b/components/hal/esp32c3/include/hal/gpio_ll.h @@ -344,6 +344,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { return (hw->in.data >> gpio_num) & 0x1; diff --git a/components/hal/esp32c6/include/hal/gpio_ll.h b/components/hal/esp32c6/include/hal/gpio_ll.h index 5bd7ea1178..a2aab0341b 100644 --- a/components/hal/esp32c6/include/hal/gpio_ll.h +++ b/components/hal/esp32c6/include/hal/gpio_ll.h @@ -338,6 +338,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { return (hw->in.in_data_next >> gpio_num) & 0x1; diff --git a/components/hal/esp32h2/include/hal/gpio_ll.h b/components/hal/esp32h2/include/hal/gpio_ll.h index df08c857be..f9090a6fa3 100644 --- a/components/hal/esp32h2/include/hal/gpio_ll.h +++ b/components/hal/esp32h2/include/hal/gpio_ll.h @@ -380,6 +380,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, gpio_num_t gpio_num, uint32 * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, gpio_num_t gpio_num) { return (hw->in.in_data_next >> gpio_num) & 0x1; diff --git a/components/hal/esp32p4/include/hal/gpio_ll.h b/components/hal/esp32p4/include/hal/gpio_ll.h index b3c41a5faa..986edcdacc 100644 --- a/components/hal/esp32p4/include/hal/gpio_ll.h +++ b/components/hal/esp32p4/include/hal/gpio_ll.h @@ -411,6 +411,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { if (gpio_num < 32) { diff --git a/components/hal/esp32s2/include/hal/gpio_ll.h b/components/hal/esp32s2/include/hal/gpio_ll.h index 80de859887..8eaf403644 100644 --- a/components/hal/esp32s2/include/hal/gpio_ll.h +++ b/components/hal/esp32s2/include/hal/gpio_ll.h @@ -351,6 +351,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { if (gpio_num < 32) { diff --git a/components/hal/esp32s3/include/hal/gpio_ll.h b/components/hal/esp32s3/include/hal/gpio_ll.h index 394d7681d1..9fe90040f4 100644 --- a/components/hal/esp32s3/include/hal/gpio_ll.h +++ b/components/hal/esp32s3/include/hal/gpio_ll.h @@ -367,6 +367,7 @@ static inline void gpio_ll_set_level(gpio_dev_t *hw, uint32_t gpio_num, uint32_t * - 0 the GPIO input level is 0 * - 1 the GPIO input level is 1 */ +__attribute__((always_inline)) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num) { if (gpio_num < 32) { diff --git a/components/soc/include/soc/rtc_io_periph.h b/components/soc/include/soc/rtc_io_periph.h index 95315e064b..3eadcfda1a 100644 --- a/components/soc/include/soc/rtc_io_periph.h +++ b/components/soc/include/soc/rtc_io_periph.h @@ -6,8 +6,7 @@ #pragma once - -#include "soc/soc.h" +#include //include soc related (generated) definitions #include "soc/soc_caps.h" diff --git a/components/spi_flash/CMakeLists.txt b/components/spi_flash/CMakeLists.txt index 75879f1bd3..0133cf45aa 100644 --- a/components/spi_flash/CMakeLists.txt +++ b/components/spi_flash/CMakeLists.txt @@ -48,7 +48,9 @@ else() "spi_flash_os_func_noos.c") list(APPEND srcs ${cache_srcs}) - set(priv_requires bootloader_support app_update soc driver esp_mm) + set(priv_requires bootloader_support app_update soc esp_mm + driver esp_driver_gpio # TODO: IDF-8503 move spi_bus_lock to esp_hw_support component + ) endif() idf_component_register(SRCS "${srcs}" diff --git a/components/spi_flash/test_apps/.build-test-rules.yml b/components/spi_flash/test_apps/.build-test-rules.yml index a348aed09f..1c73293f31 100644 --- a/components/spi_flash/test_apps/.build-test-rules.yml +++ b/components/spi_flash/test_apps/.build-test-rules.yml @@ -6,13 +6,13 @@ components/spi_flash/test_apps/esp_flash: temporary: true reason: target esp32p4 is not supported yet # TODO: IDF-7499 depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* - components/bootloader_support/bootloader_flash/**/* depends_components: - esp_mm - esp_psram - spi_flash + - esp_driver_gpio - esptool_py # Some flash related kconfigs are listed here. components/spi_flash/test_apps/flash_encryption: @@ -54,11 +54,11 @@ components/spi_flash/test_apps/mspi_test: temporary: true reason: not supported yet #TODO: IDF-7556 for p4 depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* - components/bootloader_support/bootloader_flash/**/* depends_components: - esp_mm - esp_psram - spi_flash + - esp_driver_gpio - esptool_py # Some flash related kconfigs are listed here. diff --git a/components/usb/CMakeLists.txt b/components/usb/CMakeLists.txt index aef5ea50ac..84fdacccc9 100644 --- a/components/usb/CMakeLists.txt +++ b/components/usb/CMakeLists.txt @@ -10,7 +10,7 @@ set(priv_include) # As CONFIG_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet # when components are being registered. # Thus, always add the (private) requirements, regardless of Kconfig -set(priv_require driver) # usb_phy driver relies on gpio driver API +set(priv_require esp_driver_gpio) # usb_phy driver relies on gpio driver API if(CONFIG_USB_OTG_SUPPORTED) list(APPEND srcs "hcd_dwc.c" diff --git a/docs/doxygen/Doxyfile b/docs/doxygen/Doxyfile index 06df821f1a..516a1cf013 100644 --- a/docs/doxygen/Doxyfile +++ b/docs/doxygen/Doxyfile @@ -79,12 +79,6 @@ INPUT = \ $(PROJECT_PATH)/components/driver/dac/include/driver/dac_cosine.h \ $(PROJECT_PATH)/components/driver/dac/include/driver/dac_oneshot.h \ $(PROJECT_PATH)/components/driver/dac/include/driver/dac_types.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/dedic_gpio.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/gpio.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/gpio_etm.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/gpio_filter.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/lp_io.h \ - $(PROJECT_PATH)/components/driver/gpio/include/driver/rtc_io.h \ $(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer.h \ $(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_etm.h \ $(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_types.h \ @@ -139,6 +133,12 @@ INPUT = \ $(PROJECT_PATH)/components/esp_common/include/esp_check.h \ $(PROJECT_PATH)/components/esp_common/include/esp_err.h \ $(PROJECT_PATH)/components/esp_common/include/esp_idf_version.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/dedic_gpio.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_etm.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/gpio_filter.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/lp_io.h \ + $(PROJECT_PATH)/components/esp_driver_gpio/include/driver/rtc_io.h \ $(PROJECT_PATH)/components/esp_driver_pcnt/include/driver/pulse_cnt.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_com.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \ diff --git a/docs/en/api-guides/jtag-debugging/debugging-examples.rst b/docs/en/api-guides/jtag-debugging/debugging-examples.rst index 4b09aa1ac9..34f1cfea4f 100644 --- a/docs/en/api-guides/jtag-debugging/debugging-examples.rst +++ b/docs/en/api-guides/jtag-debugging/debugging-examples.rst @@ -497,7 +497,7 @@ If you enter ``s`` instead, then debugger will step inside subroutine calls:: Target halted. PRO_CPU: PC=0x400DB74B (active) APP_CPU: PC=0x400D1128 Target halted. PRO_CPU: PC=0x400DC04C (active) APP_CPU: PC=0x400D1128 Target halted. PRO_CPU: PC=0x400DC04F (active) APP_CPU: PC=0x400D1128 - gpio_set_level (gpio_num=GPIO_NUM_4, level=0) at /home/user-name/esp/esp-idf/components/driver/gpio/gpio.c:183 + gpio_set_level (gpio_num=GPIO_NUM_4, level=0) at /home/user-name/esp/esp-idf/components/esp_driver_gpio/src/gpio.c:183 183 GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG); (gdb) diff --git a/docs/en/contribute/documenting-code.rst b/docs/en/contribute/documenting-code.rst index aa5fcd73e3..5fc2c77252 100644 --- a/docs/en/contribute/documenting-code.rst +++ b/docs/en/contribute/documenting-code.rst @@ -123,7 +123,7 @@ When writing code, please follow the guidelines below: For practical example see :component_file:`nvs_flash/include/nvs.h`. -4. You may want to go even further and skip some code like repetitive defines or enumerations. In such case, enclose the code within ``/** @cond */`` and ``/** @endcond */`` commands. Example of such implementation is provided in :component_file:`driver/gpio/include/driver/gpio.h`. +4. You may want to go even further and skip some code like repetitive defines or enumerations. In such case, enclose the code within ``/** @cond */`` and ``/** @endcond */`` commands. Example of such implementation is provided in :component_file:`esp_driver_gpio/include/driver/gpio.h`. 5. Use markdown to make your documentation even more readable. You will add headers, links, tables and more. :: diff --git a/docs/zh_CN/api-guides/jtag-debugging/debugging-examples.rst b/docs/zh_CN/api-guides/jtag-debugging/debugging-examples.rst index dbfa846cf0..c15f8c50e4 100644 --- a/docs/zh_CN/api-guides/jtag-debugging/debugging-examples.rst +++ b/docs/zh_CN/api-guides/jtag-debugging/debugging-examples.rst @@ -497,7 +497,7 @@ Target halted. PRO_CPU: PC=0x400DB74B (active) APP_CPU: PC=0x400D1128 Target halted. PRO_CPU: PC=0x400DC04C (active) APP_CPU: PC=0x400D1128 Target halted. PRO_CPU: PC=0x400DC04F (active) APP_CPU: PC=0x400D1128 - gpio_set_level (gpio_num=GPIO_NUM_4, level=0) at /home/user-name/esp/esp-idf/components/driver/gpio/gpio.c:183 + gpio_set_level (gpio_num=GPIO_NUM_4, level=0) at /home/user-name/esp/esp-idf/components/esp_driver_gpio/src/gpio.c:183 183 GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG); (gdb) diff --git a/docs/zh_CN/contribute/documenting-code.rst b/docs/zh_CN/contribute/documenting-code.rst index 0568aaa1b1..a048b29849 100644 --- a/docs/zh_CN/contribute/documenting-code.rst +++ b/docs/zh_CN/contribute/documenting-code.rst @@ -123,7 +123,7 @@ Doxygen 支持多种格式,并支持文档内部的多个详情级别,具有 如需更多应用示例,请参考 :component_file:`nvs_flash/include/nvs.h`。 -4. 如需进一步跳过重复定义或枚举等代码,可使用 ``/** @cond */`` 和 ``/** @endcond */`` 命令附上该代码。相关应用实例,请参考 :component_file:`driver/gpio/include/driver/gpio.h`。 +4. 如需进一步跳过重复定义或枚举等代码,可使用 ``/** @cond */`` 和 ``/** @endcond */`` 命令附上该代码。相关应用实例,请参考 :component_file:`esp_driver_gpio/include/driver/gpio.h`。 5. 使用 markdown 添加标题、链接和表格等,增强文档的可读性。 :: diff --git a/examples/bluetooth/.build-test-rules.yml b/examples/bluetooth/.build-test-rules.yml index 0da95ba304..279c3bed76 100644 --- a/examples/bluetooth/.build-test-rules.yml +++ b/examples/bluetooth/.build-test-rules.yml @@ -24,8 +24,8 @@ examples/bluetooth/bluedroid/ble: examples/bluetooth/bluedroid/ble/ble_hid_device_demo: disable: - if: SOC_BT_SUPPORTED != 1 - depends_filepatterns: - - components/driver/gpio/**/* + depends_components: + - esp_driver_gpio examples/bluetooth/bluedroid/ble_50: disable: @@ -41,11 +41,11 @@ examples/bluetooth/bluedroid/classic_bt: - esp_log - esp_console - vfs + - esp_driver_gpio depends_filepatterns: - components/driver/dac/**/* - components/driver/i2s/**/* - components/driver/uart/**/* - - components/driver/gpio/**/* examples/bluetooth/bluedroid/coex/a2dp_gatts_coex: <<: *bt_default_depends @@ -84,9 +84,9 @@ examples/bluetooth/esp_ble_mesh: - vfs - mbedtls - touch_element + - esp_driver_gpio depends_filepatterns: - examples/bluetooth/esp_ble_mesh/common_components/**/* - - components/driver/gpio/**/* examples/bluetooth/esp_ble_mesh/aligenie_demo: enable: @@ -99,9 +99,9 @@ examples/bluetooth/esp_ble_mesh/aligenie_demo: - vfs - mbedtls - driver + - esp_driver_gpio depends_filepatterns: - examples/bluetooth/esp_ble_mesh/common_components/**/* - - components/driver/gpio/**/* examples/bluetooth/esp_ble_mesh/coex_test: enable: @@ -117,9 +117,9 @@ examples/bluetooth/esp_ble_mesh/coex_test: - esp_coex - esp_wifi - esp_netif + - esp_driver_gpio depends_filepatterns: - examples/bluetooth/esp_ble_mesh/common_components/**/* - - components/driver/gpio/**/* examples/bluetooth/esp_ble_mesh/wifi_coexist: disable: @@ -134,9 +134,9 @@ examples/bluetooth/esp_ble_mesh/wifi_coexist: - esp_coex - esp_wifi - esp_netif + - esp_driver_gpio depends_filepatterns: - examples/bluetooth/esp_ble_mesh/common_components/**/* - - components/driver/gpio/**/* examples/bluetooth/hci: <<: *bt_default_depends @@ -271,8 +271,9 @@ examples/bluetooth/nimble/throughput_app: <<: *bt_default_depends disable: - if: SOC_BLE_SUPPORTED != 1 + depends_components: + - esp_driver_gpio depends_filepatterns: - examples/bluetooth/nimble/common/**/* - examples/bluetooth/nimble/throughput_app/blecent_throughput/components/**/* - components/driver/uart/**/* - - components/driver/gpio/**/* diff --git a/examples/bluetooth/esp_ble_mesh/common_components/button/CMakeLists.txt b/examples/bluetooth/esp_ble_mesh/common_components/button/CMakeLists.txt index f9b07dafe5..24adc8d5b3 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/button/CMakeLists.txt +++ b/examples/bluetooth/esp_ble_mesh/common_components/button/CMakeLists.txt @@ -1,3 +1,3 @@ idf_component_register(SRCS "button.c" "button_obj.cpp" INCLUDE_DIRS "." "include" - PRIV_REQUIRES driver esp_timer) + PRIV_REQUIRES esp_driver_gpio esp_timer) diff --git a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/CMakeLists.txt b/examples/bluetooth/esp_ble_mesh/common_components/light_driver/CMakeLists.txt index 6dc16c7094..fe06e61668 100644 --- a/examples/bluetooth/esp_ble_mesh/common_components/light_driver/CMakeLists.txt +++ b/examples/bluetooth/esp_ble_mesh/common_components/light_driver/CMakeLists.txt @@ -7,6 +7,6 @@ set(COMPONENT_SRCS set(COMPONENT_ADD_INCLUDEDIRS ". include") # requirements can't depend on config -set(COMPONENT_REQUIRES example_nvs driver) +set(COMPONENT_REQUIRES example_nvs driver esp_driver_gpio) register_component() diff --git a/examples/ethernet/.build-test-rules.yml b/examples/ethernet/.build-test-rules.yml index af1670d1c6..c0e129ef80 100644 --- a/examples/ethernet/.build-test-rules.yml +++ b/examples/ethernet/.build-test-rules.yml @@ -8,8 +8,8 @@ examples/ethernet/basic: - esp_netif - lwip - esp_event + - esp_driver_gpio depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* examples/ethernet/enc28j60: @@ -22,8 +22,8 @@ examples/ethernet/enc28j60: - esp_netif - lwip - esp_event + - esp_driver_gpio depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* examples/ethernet/iperf: @@ -37,8 +37,8 @@ examples/ethernet/iperf: - lwip - esp_event - console + - esp_driver_gpio depends_filepatterns: - - components/driver/gpio/**/* - components/driver/spi/**/* - examples/common_components/iperf/**/* - examples/common_components/protocol_examples_common/**/* diff --git a/examples/peripherals/.build-test-rules.yml b/examples/peripherals/.build-test-rules.yml index e8c40bd359..834340c6e1 100644 --- a/examples/peripherals/.build-test-rules.yml +++ b/examples/peripherals/.build-test-rules.yml @@ -27,6 +27,10 @@ examples/peripherals/dac: disable: - if: SOC_DAC_SUPPORTED != 1 +examples/peripherals/gpio: + depends_components: + - esp_driver_gpio + examples/peripherals/gpio/matrix_keyboard: enable: - if: IDF_TARGET == "esp32s2" diff --git a/examples/peripherals/spi_master/hd_eeprom/components/eeprom/linker.lf b/examples/peripherals/spi_master/hd_eeprom/components/eeprom/linker.lf index b0d89b8d77..e9b6befe51 100644 --- a/examples/peripherals/spi_master/hd_eeprom/components/eeprom/linker.lf +++ b/examples/peripherals/spi_master/hd_eeprom/components/eeprom/linker.lf @@ -5,20 +5,23 @@ [mapping:eeprom] archive: libeeprom.a entries: - * (noflash) + if EXAMPLE_USE_SPI1_PINS = y: + * (noflash) [mapping:ext_driver] -archive: libdriver.a +archive: libesp_driver_gpio.a entries: - # gpio_set_level, gpio_get_level, gpio_context, _gpio_hal, etc... - gpio (noflash) + if EXAMPLE_USE_SPI1_PINS = y: + gpio: gpio_intr_enable (noflash) [mapping:ext_soc] archive: libhal.a entries: - gpio_hal (noflash) + if EXAMPLE_USE_SPI1_PINS = y: + gpio_hal: gpio_hal_intr_enable_on_core (noflash) [mapping:ext_newlib] archive: libnewlib.a entries: - time:usleep (noflash) + if EXAMPLE_USE_SPI1_PINS = y: + time:usleep (noflash) diff --git a/examples/peripherals/spi_master/hd_eeprom/components/eeprom/spi_eeprom.c b/examples/peripherals/spi_master/hd_eeprom/components/eeprom/spi_eeprom.c index 4d01482397..4e57ba6e64 100644 --- a/examples/peripherals/spi_master/hd_eeprom/components/eeprom/spi_eeprom.c +++ b/examples/peripherals/spi_master/hd_eeprom/components/eeprom/spi_eeprom.c @@ -51,16 +51,6 @@ typedef struct eeprom_context_t eeprom_context_t; static const char TAG[] = "eeprom"; -// Workaround: The driver depends on some data in the flash and cannot be placed to DRAM easily for -// now. Using the version in LL instead. -#define gpio_set_level gpio_set_level_patch -#include "hal/gpio_ll.h" -static inline esp_err_t gpio_set_level_patch(gpio_num_t gpio_num, uint32_t level) -{ - gpio_ll_set_level(&GPIO, gpio_num, level); - return ESP_OK; -} - static esp_err_t eeprom_simple_cmd(eeprom_context_t *ctx, uint16_t cmd) { spi_transaction_t t = { diff --git a/examples/peripherals/spi_master/hd_eeprom/main/Kconfig.projbuild b/examples/peripherals/spi_master/hd_eeprom/main/Kconfig.projbuild index e48344e2fc..4bee4e1381 100644 --- a/examples/peripherals/spi_master/hd_eeprom/main/Kconfig.projbuild +++ b/examples/peripherals/spi_master/hd_eeprom/main/Kconfig.projbuild @@ -4,9 +4,12 @@ menu "Example Configuration" bool "The example uses SPI1 shared pins for EEPROM connection" default n depends on SPI_FLASH_SHARE_SPI1_BUS + select GPIO_CTRL_FUNC_IN_IRAM + select COMPILER_OPTIMIZATION_CHECKS_SILENT # silent the error check, as the error string are stored in rodata help Enable this option will make the EEPROM use SPI1 pins, which is shared with the main - flash chip. + flash chip. Therefore, when doing transaction on SPI1 bus, data cannot be fetched + from the flash, so all the data used during this time should be put into the internal RAM. Currently this example hasn't supported SPI1 pins on other chips yet. diff --git a/examples/system/console/advanced/components/cmd_system/CMakeLists.txt b/examples/system/console/advanced/components/cmd_system/CMakeLists.txt index 4c0eae43a7..4fa5d30b91 100644 --- a/examples/system/console/advanced/components/cmd_system/CMakeLists.txt +++ b/examples/system/console/advanced/components/cmd_system/CMakeLists.txt @@ -1,5 +1,5 @@ idf_component_register(SRCS "cmd_system.c" "cmd_system_common.c" INCLUDE_DIRS . - REQUIRES console spi_flash driver) + REQUIRES console spi_flash driver esp_driver_gpio) target_sources(${COMPONENT_LIB} PRIVATE cmd_system_sleep.c) diff --git a/tools/mocks/driver/CMakeLists.txt b/tools/mocks/driver/CMakeLists.txt index 7460356fef..5733e1b34c 100644 --- a/tools/mocks/driver/CMakeLists.txt +++ b/tools/mocks/driver/CMakeLists.txt @@ -5,14 +5,14 @@ message(STATUS "building DRIVER MOCKS (only SPI master, I2C, RMT, USB-serial and idf_component_get_property(original_driver_dir driver COMPONENT_OVERRIDEN_DIR) set(include_dirs + "${IDF_PATH}/components/esp_driver_gpio/include/driver" + "${IDF_PATH}/components/esp_driver_gpio/include" "${original_driver_dir}/i2c/include/driver" "${original_driver_dir}/spi/include/driver" - "${original_driver_dir}/gpio/include/driver" "${original_driver_dir}/rmt/include/driver" "${original_driver_dir}/usb_serial_jtag/include/driver" "${original_driver_dir}/i2c/include" "${original_driver_dir}/spi/include" - "${original_driver_dir}/gpio/include" "${original_driver_dir}/rmt/include" "${original_driver_dir}/usb_serial_jtag/include" "${CMAKE_CURRENT_SOURCE_DIR}/../hal/include") @@ -20,10 +20,10 @@ set(include_dirs idf_component_mock(INCLUDE_DIRS ${include_dirs} REQUIRES freertos MOCK_HEADER_FILES + ${IDF_PATH}/components/esp_driver_gpio/include/driver/gpio.h ${original_driver_dir}/spi/include/driver/spi_master.h ${original_driver_dir}/spi/include/driver/spi_common.h ${original_driver_dir}/i2c/include/driver/i2c.h - ${original_driver_dir}/gpio/include/driver/gpio.h ${original_driver_dir}/rmt/include/driver/rmt_rx.h ${original_driver_dir}/rmt/include/driver/rmt_tx.h ${original_driver_dir}/rmt/include/driver/rmt_common.h diff --git a/tools/test_apps/system/g1_components/CMakeLists.txt b/tools/test_apps/system/g1_components/CMakeLists.txt index 204005e1cd..ceb1b6512e 100644 --- a/tools/test_apps/system/g1_components/CMakeLists.txt +++ b/tools/test_apps/system/g1_components/CMakeLists.txt @@ -35,7 +35,7 @@ set(extra_components_which_shouldnt_be_included cxx # [refactor-todo]: driver is a dependency of esp_pm, spi_flash, vfs, esp_wifi # all of these should be removed from G1 except for spi_flash. - driver esp_driver_pcnt + driver esp_driver_gpio esp_driver_pcnt # esp_app_format is dependency of bootloader_support, app_update esp_app_format # esp_bootloader_format is dependency of bootloader_support, app_update