Przeglądaj źródła

Merge branch 'refactor/esp_driver_gpio' into 'master'

refactor(gpio): make gpio driver as component

See merge request espressif/esp-idf!26509
Song Ruo Jing 2 lat temu
rodzic
commit
8029946cba
100 zmienionych plików z 455 dodań i 265 usunięć
  1. 1 1
      components/app_trace/CMakeLists.txt
  2. 2 24
      components/driver/CMakeLists.txt
  3. 0 18
      components/driver/Kconfig
  4. 18 13
      components/driver/test_apps/.build-test-rules.yml
  5. 0 2
      components/driver/test_apps/gpio_extensions/README.md
  6. 8 0
      components/driver/test_apps/legacy_sigma_delta_driver/CMakeLists.txt
  7. 2 0
      components/driver/test_apps/legacy_sigma_delta_driver/README.md
  8. 11 0
      components/driver/test_apps/legacy_sigma_delta_driver/main/CMakeLists.txt
  9. 0 0
      components/driver/test_apps/legacy_sigma_delta_driver/main/test_app_main.c
  10. 0 0
      components/driver/test_apps/legacy_sigma_delta_driver/main/test_sigma_delta_legacy.c
  11. 22 0
      components/driver/test_apps/legacy_sigma_delta_driver/pytest_legacy_sigma_delta.py
  12. 0 0
      components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.ci.release
  13. 0 0
      components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.defaults
  14. 2 2
      components/driver/test_apps/rs485/README.md
  15. 2 2
      components/driver/test_apps/sigma_delta/CMakeLists.txt
  16. 2 0
      components/driver/test_apps/sigma_delta/README.md
  17. 11 0
      components/driver/test_apps/sigma_delta/main/CMakeLists.txt
  18. 0 0
      components/driver/test_apps/sigma_delta/main/test_app_main.c
  19. 0 0
      components/driver/test_apps/sigma_delta/main/test_sdm.c
  20. 23 0
      components/driver/test_apps/sigma_delta/pytest_sigma_delta.py
  21. 0 0
      components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe
  22. 0 0
      components/driver/test_apps/sigma_delta/sdkconfig.ci.release
  23. 0 0
      components/driver/test_apps/sigma_delta/sdkconfig.defaults
  24. 2 2
      components/driver/test_apps/uart/README.md
  25. 1 1
      components/esp_adc/CMakeLists.txt
  26. 1 1
      components/esp_adc/test_apps/.build-test-rules.yml
  27. 33 0
      components/esp_driver_gpio/CMakeLists.txt
  28. 17 0
      components/esp_driver_gpio/Kconfig
  29. 0 0
      components/esp_driver_gpio/include/driver/dedic_gpio.h
  30. 0 0
      components/esp_driver_gpio/include/driver/gpio.h
  31. 0 0
      components/esp_driver_gpio/include/driver/gpio_etm.h
  32. 0 0
      components/esp_driver_gpio/include/driver/gpio_filter.h
  33. 0 0
      components/esp_driver_gpio/include/driver/lp_io.h
  34. 0 1
      components/esp_driver_gpio/include/driver/rtc_io.h
  35. 0 0
      components/esp_driver_gpio/include/esp_private/glitch_filter_priv.h
  36. 0 0
      components/esp_driver_gpio/include/esp_private/gpio.h
  37. 2 1
      components/esp_driver_gpio/linker.lf
  38. 1 3
      components/esp_driver_gpio/src/dedic_gpio.c
  39. 57 59
      components/esp_driver_gpio/src/gpio.c
  40. 0 0
      components/esp_driver_gpio/src/gpio_etm.c
  41. 1 1
      components/esp_driver_gpio/src/gpio_flex_glitch_filter.c
  42. 1 1
      components/esp_driver_gpio/src/gpio_glitch_filter_ops.c
  43. 1 1
      components/esp_driver_gpio/src/gpio_pin_glitch_filter.c
  44. 0 0
      components/esp_driver_gpio/src/rtc_io.c
  45. 10 0
      components/esp_driver_gpio/test_apps/.build-test-rules.yml
  46. 21 0
      components/esp_driver_gpio/test_apps/gpio/CMakeLists.txt
  47. 0 0
      components/esp_driver_gpio/test_apps/gpio/README.md
  48. 1 5
      components/esp_driver_gpio/test_apps/gpio/main/CMakeLists.txt
  49. 29 0
      components/esp_driver_gpio/test_apps/gpio/main/test_app_main.c
  50. 0 0
      components/esp_driver_gpio/test_apps/gpio/main/test_gpio.c
  51. 0 0
      components/esp_driver_gpio/test_apps/gpio/main/test_gpio.h
  52. 33 33
      components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.c
  53. 0 0
      components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.h
  54. 0 12
      components/esp_driver_gpio/test_apps/gpio/pytest_gpio.py
  55. 0 0
      components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.iram_safe
  56. 5 0
      components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.release
  57. 2 0
      components/esp_driver_gpio/test_apps/gpio/sdkconfig.defaults
  58. 1 1
      components/esp_driver_gpio/test_apps/gpio_extensions/CMakeLists.txt
  59. 2 0
      components/esp_driver_gpio/test_apps/gpio_extensions/README.md
  60. 1 5
      components/esp_driver_gpio/test_apps/gpio_extensions/main/CMakeLists.txt
  61. 38 0
      components/esp_driver_gpio/test_apps/gpio_extensions/main/test_app_main.c
  62. 0 0
      components/esp_driver_gpio/test_apps/gpio_extensions/main/test_dedicated_gpio.c
  63. 0 0
      components/esp_driver_gpio/test_apps/gpio_extensions/main/test_gpio_filter.c
  64. 4 6
      components/esp_driver_gpio/test_apps/gpio_extensions/main/test_hysteresis.c
  65. 0 13
      components/esp_driver_gpio/test_apps/gpio_extensions/pytest_gpio_extensions.py
  66. 9 0
      components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.iram_safe
  67. 5 0
      components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.ci.release
  68. 2 0
      components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.defaults
  69. 1 1
      components/esp_driver_pcnt/CMakeLists.txt
  70. 1 1
      components/esp_eth/CMakeLists.txt
  71. 5 2
      components/esp_hw_support/CMakeLists.txt
  72. 1 1
      components/esp_lcd/CMakeLists.txt
  73. 1 1
      components/esp_pm/CMakeLists.txt
  74. 1 1
      components/esp_pm/linker.lf
  75. 8 4
      components/espcoredump/CMakeLists.txt
  76. 1 1
      components/fatfs/CMakeLists.txt
  77. 1 0
      components/hal/esp32/include/hal/gpio_ll.h
  78. 1 0
      components/hal/esp32c2/include/hal/gpio_ll.h
  79. 1 0
      components/hal/esp32c3/include/hal/gpio_ll.h
  80. 1 0
      components/hal/esp32c6/include/hal/gpio_ll.h
  81. 1 0
      components/hal/esp32h2/include/hal/gpio_ll.h
  82. 1 0
      components/hal/esp32p4/include/hal/gpio_ll.h
  83. 1 0
      components/hal/esp32s2/include/hal/gpio_ll.h
  84. 1 0
      components/hal/esp32s3/include/hal/gpio_ll.h
  85. 1 2
      components/soc/include/soc/rtc_io_periph.h
  86. 3 1
      components/spi_flash/CMakeLists.txt
  87. 2 2
      components/spi_flash/test_apps/.build-test-rules.yml
  88. 1 1
      components/usb/CMakeLists.txt
  89. 6 6
      docs/doxygen/Doxyfile
  90. 1 1
      docs/en/api-guides/jtag-debugging/debugging-examples.rst
  91. 1 1
      docs/en/contribute/documenting-code.rst
  92. 1 1
      docs/zh_CN/api-guides/jtag-debugging/debugging-examples.rst
  93. 1 1
      docs/zh_CN/contribute/documenting-code.rst
  94. 9 8
      examples/bluetooth/.build-test-rules.yml
  95. 1 1
      examples/bluetooth/esp_ble_mesh/common_components/button/CMakeLists.txt
  96. 1 1
      examples/bluetooth/esp_ble_mesh/common_components/light_driver/CMakeLists.txt
  97. 3 3
      examples/ethernet/.build-test-rules.yml
  98. 4 0
      examples/peripherals/.build-test-rules.yml
  99. 9 6
      examples/peripherals/spi_master/hd_eeprom/components/eeprom/linker.lf
  100. 0 10
      examples/peripherals/spi_master/hd_eeprom/components/eeprom/spi_eeprom.c

+ 1 - 1
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)
 

+ 2 - 24
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()

+ 0 - 18
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

+ 18 - 13
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

+ 0 - 2
components/driver/test_apps/gpio_extensions/README.md

@@ -1,2 +0,0 @@
-| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-C6 | ESP32-H2 | ESP32-S2 | ESP32-S3 |
-| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- |

+ 8 - 0
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)

+ 2 - 0
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 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |

+ 11 - 0
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)

+ 0 - 0
components/driver/test_apps/gpio/main/test_app_main.c → components/driver/test_apps/legacy_sigma_delta_driver/main/test_app_main.c


+ 0 - 0
components/driver/test_apps/gpio/main/test_sigma_delta_legacy.c → components/driver/test_apps/legacy_sigma_delta_driver/main/test_sigma_delta_legacy.c


+ 22 - 0
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')

+ 0 - 0
components/driver/test_apps/gpio/sdkconfig.ci.release → components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.ci.release


+ 0 - 0
components/driver/test_apps/gpio/sdkconfig.defaults → components/driver/test_apps/legacy_sigma_delta_driver/sdkconfig.defaults


+ 2 - 2
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 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

+ 2 - 2
components/driver/test_apps/gpio/CMakeLists.txt → 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

+ 2 - 0
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 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- |

+ 11 - 0
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)

+ 0 - 0
components/driver/test_apps/gpio_extensions/main/test_app_main.c → components/driver/test_apps/sigma_delta/main/test_app_main.c


+ 0 - 0
components/driver/test_apps/gpio_extensions/main/test_sdm.c → components/driver/test_apps/sigma_delta/main/test_sdm.c


+ 23 - 0
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')

+ 0 - 0
components/driver/test_apps/gpio_extensions/sdkconfig.ci.iram_safe → components/driver/test_apps/sigma_delta/sdkconfig.ci.iram_safe


+ 0 - 0
components/driver/test_apps/gpio_extensions/sdkconfig.ci.release → components/driver/test_apps/sigma_delta/sdkconfig.ci.release


+ 0 - 0
components/driver/test_apps/gpio_extensions/sdkconfig.defaults → components/driver/test_apps/sigma_delta/sdkconfig.defaults


+ 2 - 2
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 |
+| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

+ 1 - 1
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)

+ 1 - 1
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

+ 33 - 0
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"
+                      )

+ 17 - 0
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

+ 0 - 0
components/driver/gpio/include/driver/dedic_gpio.h → components/esp_driver_gpio/include/driver/dedic_gpio.h


+ 0 - 0
components/driver/gpio/include/driver/gpio.h → components/esp_driver_gpio/include/driver/gpio.h


+ 0 - 0
components/driver/gpio/include/driver/gpio_etm.h → components/esp_driver_gpio/include/driver/gpio_etm.h


+ 0 - 0
components/driver/gpio/include/driver/gpio_filter.h → components/esp_driver_gpio/include/driver/gpio_filter.h


+ 0 - 0
components/driver/gpio/include/driver/lp_io.h → components/esp_driver_gpio/include/driver/lp_io.h


+ 0 - 1
components/driver/gpio/include/driver/rtc_io.h → 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

+ 0 - 0
components/driver/gpio/glitch_filter_priv.h → components/esp_driver_gpio/include/esp_private/glitch_filter_priv.h


+ 0 - 0
components/driver/include/esp_private/gpio.h → components/esp_driver_gpio/include/esp_private/gpio.h


+ 2 - 1
components/driver/gpio/linker.lf → 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

+ 1 - 3
components/driver/gpio/dedic_gpio.c → 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;

+ 57 - 59
components/driver/gpio/gpio.c → 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_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_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;
+    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_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;
+
+    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_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_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;
+    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_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;
+
+    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;

+ 0 - 0
components/driver/gpio/gpio_etm.c → components/esp_driver_gpio/src/gpio_etm.c


+ 1 - 1
components/driver/gpio/gpio_flex_glitch_filter.c → components/esp_driver_gpio/src/gpio_flex_glitch_filter.c

@@ -7,7 +7,7 @@
 #include <sys/cdefs.h>
 #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"

+ 1 - 1
components/driver/gpio/gpio_glitch_filter_ops.c → 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";
 

+ 1 - 1
components/driver/gpio/gpio_pin_glitch_filter.c → 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"

+ 0 - 0
components/driver/gpio/rtc_io.c → components/esp_driver_gpio/src/rtc_io.c


+ 10 - 0
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

+ 21 - 0
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()

+ 0 - 0
components/driver/test_apps/gpio/README.md → components/esp_driver_gpio/test_apps/gpio/README.md


+ 1 - 5
components/driver/test_apps/gpio/main/CMakeLists.txt → 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)

+ 29 - 0
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();
+}

+ 0 - 0
components/driver/test_apps/gpio/main/test_gpio.c → components/esp_driver_gpio/test_apps/gpio/main/test_gpio.c


+ 0 - 0
components/driver/test_apps/gpio/main/test_gpio.h → components/esp_driver_gpio/test_apps/gpio/main/test_gpio.h


+ 33 - 33
components/driver/test_apps/gpio/main/test_rtcio.c → 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)

+ 0 - 0
components/driver/test_apps/gpio/main/test_rtcio.h → components/esp_driver_gpio/test_apps/gpio/main/test_rtcio.h


+ 0 - 12
components/driver/test_apps/gpio/pytest_gpio.py → 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

+ 0 - 0
components/driver/test_apps/gpio/sdkconfig.ci.iram_safe → components/esp_driver_gpio/test_apps/gpio/sdkconfig.ci.iram_safe


+ 5 - 0
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

+ 2 - 0
components/esp_driver_gpio/test_apps/gpio/sdkconfig.defaults

@@ -0,0 +1,2 @@
+CONFIG_FREERTOS_HZ=1000
+CONFIG_ESP_TASK_WDT_EN=n

+ 1 - 1
components/driver/test_apps/gpio_extensions/CMakeLists.txt → 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

+ 2 - 0
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 |
+| ----------------- | -------- | -------- | -------- | -------- | -------- | -------- |

+ 1 - 5
components/driver/test_apps/gpio_extensions/main/CMakeLists.txt → 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)

+ 38 - 0
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();
+}

+ 0 - 0
components/driver/test_apps/gpio_extensions/main/test_dedicated_gpio.c → components/esp_driver_gpio/test_apps/gpio_extensions/main/test_dedicated_gpio.c


+ 0 - 0
components/driver/test_apps/gpio_extensions/main/test_gpio_filter.c → components/esp_driver_gpio/test_apps/gpio_extensions/main/test_gpio_filter.c


+ 4 - 6
components/driver/test_apps/gpio_extensions/main/test_hysteresis.c → 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);

+ 0 - 13
components/driver/test_apps/gpio_extensions/pytest_gpio_extensions.py → 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

+ 9 - 0
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

+ 5 - 0
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

+ 2 - 0
components/esp_driver_gpio/test_apps/gpio_extensions/sdkconfig.defaults

@@ -0,0 +1,2 @@
+CONFIG_FREERTOS_HZ=1000
+CONFIG_ESP_TASK_WDT_EN=n

+ 1 - 1
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()

+ 1 - 1
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()

+ 5 - 2
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)
 

+ 1 - 1
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)

+ 1 - 1
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)

+ 1 - 1
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)

+ 8 - 4
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)

+ 1 - 1
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}

+ 1 - 0
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) {

+ 1 - 0
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;

+ 1 - 0
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;

+ 1 - 0
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;

+ 1 - 0
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;

+ 1 - 0
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) {

+ 1 - 0
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) {

+ 1 - 0
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) {

+ 1 - 2
components/soc/include/soc/rtc_io_periph.h

@@ -6,8 +6,7 @@
 
 #pragma once
 
-
-#include "soc/soc.h"
+#include <stdint.h>
 //include soc related (generated) definitions
 #include "soc/soc_caps.h"
 

+ 3 - 1
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}"

+ 2 - 2
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.

+ 1 - 1
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"

+ 6 - 6
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 \

+ 1 - 1
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)
 

+ 1 - 1
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. ::
 

+ 1 - 1
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)
 

+ 1 - 1
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 添加标题、链接和表格等,增强文档的可读性。 ::
 

+ 9 - 8
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/**/*

+ 1 - 1
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)

+ 1 - 1
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()

+ 3 - 3
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/**/*

+ 4 - 0
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"

+ 9 - 6
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)

+ 0 - 10
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 = {

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików