refactor(gpio): make gpio driver as component, and fix astyle

This commit is contained in:
Song Ruo Jing 2023-10-17 12:11:42 +08:00
parent 342535f47c
commit 9461993ec5
104 changed files with 456 additions and 263 deletions

View File

@ -64,7 +64,7 @@ idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}" INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS "${priv_include_dirs}" PRIV_INCLUDE_DIRS "${priv_include_dirs}"
# Requires "driver" for GPTimer in "SEGGER_SYSVIEW_Config_FreeRTOS.c" # Requires "driver" for GPTimer in "SEGGER_SYSVIEW_Config_FreeRTOS.c"
PRIV_REQUIRES soc driver PRIV_REQUIRES soc driver esp_driver_gpio
REQUIRES esp_timer REQUIRES esp_timer
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@ -6,9 +6,6 @@ endif()
# Always compiled source files # Always compiled source files
set(srcs set(srcs
"gpio/gpio.c"
"gpio/gpio_glitch_filter_ops.c"
"gpio/rtc_io.c"
"spi/spi_bus_lock.c") "spi/spi_bus_lock.c")
# Always included headers # Always included headers
@ -16,7 +13,6 @@ set(includes "include"
"deprecated" "deprecated"
"analog_comparator/include" "analog_comparator/include"
"dac/include" "dac/include"
"gpio/include"
"gptimer/include" "gptimer/include"
"i2c/include" "i2c/include"
"i2s/include" "i2s/include"
@ -35,8 +31,7 @@ set(includes "include"
"usb_serial_jtag/include") "usb_serial_jtag/include")
# Always included linker fragments # Always included linker fragments
set(ldfragments "linker.lf" set(ldfragments "linker.lf")
"gpio/linker.lf")
# ADC related source files (dprecated) # ADC related source files (dprecated)
if(CONFIG_SOC_ADC_SUPPORTED) 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") list(APPEND srcs "parlio/parlio_common.c" "parlio/parlio_tx.c")
endif() 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 # GPTimer related source files
if(CONFIG_SOC_GPTIMER_SUPPORTED) if(CONFIG_SOC_GPTIMER_SUPPORTED)
list(APPEND srcs "gptimer/gptimer.c" list(APPEND srcs "gptimer/gptimer.c"
@ -248,7 +226,7 @@ else()
REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support REQUIRES esp_pm esp_ringbuf freertos soc hal esp_hw_support
# for backward compatibility, the driver component needs to # for backward compatibility, the driver component needs to
# have a public dependency on other "esp_driver_foo" components # have a public dependency on other "esp_driver_foo" components
esp_driver_pcnt esp_driver_gpio esp_driver_pcnt
LDFRAGMENTS ${ldfragments} LDFRAGMENTS ${ldfragments}
) )
endif() endif()

View File

@ -156,24 +156,6 @@ menu "Driver Configurations"
orsource "./uart/Kconfig.uart" 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" menu "Sigma Delta Modulator Configuration"
depends on SOC_SDM_SUPPORTED depends on SOC_SDM_SUPPORTED
config SDM_CTRL_FUNC_IN_IRAM config SDM_CTRL_FUNC_IN_IRAM

View File

@ -16,12 +16,6 @@ components/driver/test_apps/dac_test_apps/legacy_dac_driver:
disable: disable:
- if: SOC_DAC_SUPPORTED != 1 - 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: components/driver/test_apps/gptimer:
disable: disable:
- if: SOC_GPTIMER_SUPPORTED != 1 - if: SOC_GPTIMER_SUPPORTED != 1
@ -97,6 +91,14 @@ components/driver/test_apps/legacy_rtc_temp_driver:
disable: disable:
- if: SOC_TEMP_SENSOR_SUPPORTED != 1 - 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: components/driver/test_apps/legacy_timer_driver:
disable: disable:
- if: SOC_GPTIMER_SUPPORTED != 1 - if: SOC_GPTIMER_SUPPORTED != 1
@ -119,9 +121,7 @@ components/driver/test_apps/rmt:
components/driver/test_apps/rs485: components/driver/test_apps/rs485:
disable: disable:
- if: IDF_TARGET in ["esp32p4"] - if: SOC_UART_SUPPORTED != 1
temporary: true
reason: target(s) is not supported yet # TODO: IDF-6511
disable_test: disable_test:
- if: IDF_TARGET != "esp32" - if: IDF_TARGET != "esp32"
temporary: true temporary: true
@ -135,6 +135,14 @@ components/driver/test_apps/sdio:
temporary: true temporary: true
reason: lack of runners 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: components/driver/test_apps/spi/master:
disable: disable:
- if: SOC_GPSPI_SUPPORTED != 1 - if: SOC_GPSPI_SUPPORTED != 1
@ -174,17 +182,14 @@ components/driver/test_apps/twai:
components/driver/test_apps/uart: components/driver/test_apps/uart:
disable: disable:
- if: SOC_UART_SUPPORTED != 1 - 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: components/driver/test_apps/usb_serial_jtag:
disable: disable:
- if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1 - if: SOC_USB_SERIAL_JTAG_SUPPORTED != 1
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/usb_serial_jtag/**/* - components/driver/usb_serial_jtag/**/*
depends_components: depends_components:
- hal - hal
- esp_hw_support # for clock - esp_hw_support # for clock
- vfs - vfs
- esp_driver_gpio

View File

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

View File

@ -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)

View File

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

View File

@ -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)

View File

@ -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')

View File

@ -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 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | | ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -5,13 +5,13 @@ cmake_minimum_required(VERSION 3.16)
set(COMPONENTS main) set(COMPONENTS main)
include($ENV{IDF_PATH}/tools/cmake/project.cmake) include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(gpio_test) project(sigma_delta_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES) if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py 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/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 find-refs
--from-sections=.iram0.text --from-sections=.iram0.text
--to-sections=.flash.text,.flash.rodata --to-sections=.flash.text,.flash.rodata

View File

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

View File

@ -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)

View File

@ -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')

View File

@ -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 |
| ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | | ----------------- | ----- | -------- | -------- | -------- | -------- | -------- | -------- | -------- |

View File

@ -42,5 +42,5 @@ endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes} INCLUDE_DIRS ${includes}
PRIV_REQUIRES driver efuse PRIV_REQUIRES driver esp_driver_gpio efuse esp_pm esp_ringbuf
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@ -6,8 +6,8 @@ components/esp_adc/test_apps/adc:
- if: CONFIG_NAME == "gdma_iram_safe" and IDF_TARGET in ["esp32", "esp32s2", "esp32c2"] - if: CONFIG_NAME == "gdma_iram_safe" and IDF_TARGET in ["esp32", "esp32s2", "esp32c2"]
depends_components: depends_components:
- esp_adc - esp_adc
- esp_driver_gpio
- efuse - efuse
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* # ADC continuous driver relies on SPI on ESP32S2 - components/driver/spi/**/* # ADC continuous driver relies on SPI on ESP32S2
- components/driver/i2s/**/* # ADC continuous driver relies on I2S on ESP32 - components/driver/i2s/**/* # ADC continuous driver relies on I2S on ESP32

View File

@ -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"
)

View File

@ -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

View File

@ -13,7 +13,6 @@
#include "hal/rtc_io_types.h" #include "hal/rtc_io_types.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif

View File

@ -1,9 +1,10 @@
[mapping:gpio_driver] [mapping:gpio_driver]
archive: libdriver.a archive: libesp_driver_gpio.a
entries: entries:
if GPIO_CTRL_FUNC_IN_IRAM = y: if GPIO_CTRL_FUNC_IN_IRAM = y:
gpio: gpio_set_level (noflash) gpio: gpio_set_level (noflash)
gpio: gpio_intr_disable (noflash) gpio: gpio_intr_disable (noflash)
gpio: gpio_get_level (noflash)
[mapping:gpio_hal] [mapping:gpio_hal]
archive: libhal.a archive: libhal.a

View File

@ -31,7 +31,6 @@
#include "hal/dedic_gpio_ll.h" #include "hal/dedic_gpio_ll.h"
#endif #endif
static const char *TAG = "dedic_gpio"; static const char *TAG = "dedic_gpio";
typedef struct dedic_gpio_platform_t dedic_gpio_platform_t; typedef struct dedic_gpio_platform_t dedic_gpio_platform_t;
@ -349,7 +348,6 @@ err:
return ret; return ret;
} }
esp_err_t dedic_gpio_get_out_offset(dedic_gpio_bundle_handle_t bundle, uint32_t *offset) esp_err_t dedic_gpio_get_out_offset(dedic_gpio_bundle_handle_t bundle, uint32_t *offset)
{ {
esp_err_t ret = ESP_OK; esp_err_t ret = ESP_OK;

View File

@ -10,8 +10,7 @@
#include "esp_heap_caps.h" #include "esp_heap_caps.h"
#include "driver/gpio.h" #include "driver/gpio.h"
#include "driver/rtc_io.h" #include "driver/rtc_io.h"
#include "soc/soc.h" #include "soc/interrupts.h"
#include "soc/periph_defs.h"
#if !CONFIG_FREERTOS_UNICORE #if !CONFIG_FREERTOS_UNICORE
#include "esp_ipc.h" #include "esp_ipc.h"
#endif #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; 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); gpio_hal_intr_enable_on_core(gpio_context.gpio_hal, gpio_num, core_id);
return ESP_OK; 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); GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&gpio_context.gpio_spinlock); 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(); gpio_context.isr_core_id = xPortGetCoreID();
} }
portEXIT_CRITICAL(&gpio_context.gpio_spinlock); 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) esp_err_t gpio_intr_disable(gpio_num_t gpio_num)
@ -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].fn = isr_handler;
gpio_context.gpio_isr_func[gpio_num].args = args; 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); portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
return ESP_OK; return ESP_OK;
} }
@ -577,7 +576,6 @@ void gpio_uninstall_isr_service(void)
return; return;
} }
static void gpio_isr_register_on_core_static(void *param) static void gpio_isr_register_on_core_static(void *param)
{ {
gpio_isr_alloc_t *p = (gpio_isr_alloc_t *)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.arg = arg;
p.handle = handle; p.handle = handle;
portENTER_CRITICAL(&gpio_context.gpio_spinlock); 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(); gpio_context.isr_core_id = xPortGetCoreID();
} }
portEXIT_CRITICAL(&gpio_context.gpio_spinlock); 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 #if SOC_RTCIO_HOLD_SUPPORTED
ret = rtc_gpio_hold_dis(gpio_num); ret = rtc_gpio_hold_dis(gpio_num);
#endif #endif
}else if (GPIO_HOLD_MASK[gpio_num]) { } else if (GPIO_HOLD_MASK[gpio_num]) {
portENTER_CRITICAL(&gpio_context.gpio_spinlock); portENTER_CRITICAL(&gpio_context.gpio_spinlock);
gpio_hal_hold_dis(gpio_context.gpio_hal, gpio_num); gpio_hal_hold_dis(gpio_context.gpio_hal, gpio_num);
portEXIT_CRITICAL(&gpio_context.gpio_spinlock); portEXIT_CRITICAL(&gpio_context.gpio_spinlock);

View File

@ -7,7 +7,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "esp_check.h" #include "esp_check.h"
#include "glitch_filter_priv.h" #include "esp_private/glitch_filter_priv.h"
#include "esp_private/io_mux.h" #include "esp_private/io_mux.h"
#include "soc/soc_caps.h" #include "soc/soc_caps.h"
#include "hal/gpio_glitch_filter_ll.h" #include "hal/gpio_glitch_filter_ll.h"

View File

@ -5,7 +5,7 @@
*/ */
#include "esp_check.h" #include "esp_check.h"
#include "glitch_filter_priv.h" #include "esp_private/glitch_filter_priv.h"
static const char *TAG = "gpio-filter"; static const char *TAG = "gpio-filter";

View File

@ -8,7 +8,7 @@
#include "freertos/FreeRTOS.h" #include "freertos/FreeRTOS.h"
#include "esp_check.h" #include "esp_check.h"
#include "esp_pm.h" #include "esp_pm.h"
#include "glitch_filter_priv.h" #include "esp_private/glitch_filter_priv.h"
#include "hal/gpio_ll.h" #include "hal/gpio_ll.h"
#include "esp_clk_tree.h" #include "esp_clk_tree.h"
#include "esp_private/io_mux.h" #include "esp_private/io_mux.h"

View File

@ -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

View File

@ -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()

View File

@ -1,10 +1,6 @@
set(srcs "test_app_main.c" set(srcs "test_app_main.c"
"test_gpio.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) if(CONFIG_SOC_RTCIO_PIN_COUNT GREATER 0)
list(APPEND srcs "test_rtcio.c") list(APPEND srcs "test_rtcio.c")
endif() endif()
@ -12,5 +8,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver spi_flash PRIV_REQUIRES unity esp_driver_gpio spi_flash
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -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();
}

View File

@ -36,10 +36,10 @@ TEST_CASE("RTCIO_input/output_test", "[rtcio]")
// init rtcio // init rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) {
RTCIO_CHECK( rtc_gpio_init(i) ); RTCIO_CHECK(rtc_gpio_init(i));
RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT) ); RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT));
RTCIO_CHECK( rtc_gpio_pullup_dis(i) ); RTCIO_CHECK(rtc_gpio_pullup_dis(i));
RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); RTCIO_CHECK(rtc_gpio_pulldown_dis(i));
ESP_LOGI(TAG, "gpio %d init", 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); ESP_LOGI(TAG, "RTCIO output level %d", level);
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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); vTaskDelay(10 / portTICK_PERIOD_MS);
if (rtc_gpio_get_level(i) != level) { if (rtc_gpio_get_level(i) != level) {
ESP_LOGE(TAG, "RTCIO input/output test err, gpio%d", i); ESP_LOGE(TAG, "RTCIO input/output test err, gpio%d", i);
@ -63,7 +63,7 @@ TEST_CASE("RTCIO_input/output_test", "[rtcio]")
// Deinit rtcio // Deinit rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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"); 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++) { for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) {
int num = rtc_io_number_get(s_test_map[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)) { 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_init(s_test_map[i]));
RTCIO_CHECK( rtc_gpio_set_direction(s_test_map[i], RTC_GPIO_MODE_INPUT_ONLY) ); 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_pullup_dis(s_test_map[i]));
RTCIO_CHECK( rtc_gpio_pulldown_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]); 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]); 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 (rtc_gpio_is_valid_gpio(s_test_map[i]) && num > 0 && RTCIO_SUPPORT_PU_PD(num)) {
if (level) { if (level) {
RTCIO_CHECK( rtc_gpio_pulldown_dis(s_test_map[i]) ); RTCIO_CHECK(rtc_gpio_pulldown_dis(s_test_map[i]));
RTCIO_CHECK( rtc_gpio_pullup_en(s_test_map[i]) ); RTCIO_CHECK(rtc_gpio_pullup_en(s_test_map[i]));
} else { } else {
RTCIO_CHECK( rtc_gpio_pullup_dis(s_test_map[i]) ); RTCIO_CHECK(rtc_gpio_pullup_dis(s_test_map[i]));
RTCIO_CHECK( rtc_gpio_pulldown_en(s_test_map[i]) ); RTCIO_CHECK(rtc_gpio_pulldown_en(s_test_map[i]));
} }
vTaskDelay(20 / portTICK_PERIOD_MS); vTaskDelay(20 / portTICK_PERIOD_MS);
if (rtc_gpio_get_level(s_test_map[i]) != level) { 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++) { for (int i = 0; i < TEST_GPIO_PIN_COUNT; i++) {
int num = rtc_io_number_get(s_test_map[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)) { 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"); ESP_LOGI(TAG, "RTCIO pullup/pulldown test over");
@ -132,10 +132,10 @@ TEST_CASE("RTCIO_output_OD_test", "[rtcio]")
// init rtcio // init rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) {
RTCIO_CHECK( rtc_gpio_init(i) ); RTCIO_CHECK(rtc_gpio_init(i));
RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD) ); RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD));
RTCIO_CHECK( rtc_gpio_pullup_en(i) ); RTCIO_CHECK(rtc_gpio_pullup_en(i));
RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); RTCIO_CHECK(rtc_gpio_pulldown_dis(i));
ESP_LOGI(TAG, "gpio %d init", 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); ESP_LOGI(TAG, "RTCIO output level %d", level);
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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); vTaskDelay(10 / portTICK_PERIOD_MS);
if (rtc_gpio_get_level(i) != level) { if (rtc_gpio_get_level(i) != level) {
ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i); ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i);
@ -159,7 +159,7 @@ TEST_CASE("RTCIO_output_OD_test", "[rtcio]")
// Deinit rtcio // Deinit rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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"); ESP_LOGI(TAG, "RTCIO output OD test over");
@ -176,11 +176,11 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]")
// init rtcio // init rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) { if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(i)) {
RTCIO_CHECK( rtc_gpio_init(i) ); RTCIO_CHECK(rtc_gpio_init(i));
RTCIO_CHECK( rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD) ); RTCIO_CHECK(rtc_gpio_set_direction(i, RTC_GPIO_MODE_INPUT_OUTPUT_OD));
RTCIO_CHECK( rtc_gpio_pullup_en(i) ); RTCIO_CHECK(rtc_gpio_pullup_en(i));
RTCIO_CHECK( rtc_gpio_pulldown_dis(i) ); RTCIO_CHECK(rtc_gpio_pulldown_dis(i));
RTCIO_CHECK( rtc_gpio_set_level(i, 1) ); RTCIO_CHECK(rtc_gpio_set_level(i, 1));
ESP_LOGI(TAG, "gpio %d init, level 1", i); ESP_LOGI(TAG, "gpio %d init, level 1", i);
} }
} }
@ -188,9 +188,9 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]")
// hold all output rtcio. // hold all output rtcio.
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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); 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"); ESP_LOGI(TAG, "RTCIO output pin hold, then set level 0");
vTaskDelay(10 / portTICK_PERIOD_MS); vTaskDelay(10 / portTICK_PERIOD_MS);
if (rtc_gpio_get_level(i) == 0) { if (rtc_gpio_get_level(i) == 0) {
@ -203,7 +203,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]")
// unhold all rtcio. // unhold all rtcio.
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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); ESP_LOGI(TAG, "RTCIO output level %d", level);
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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); vTaskDelay(10 / portTICK_PERIOD_MS);
if (rtc_gpio_get_level(i) != level) { if (rtc_gpio_get_level(i) != level) {
ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i); ESP_LOGE(TAG, "RTCIO output OD test err, gpio%d", i);
@ -227,7 +227,7 @@ TEST_CASE("RTCIO_output_hold_test", "[rtcio]")
// Deinit rtcio // Deinit rtcio
for (int i = 0; i < GPIO_PIN_COUNT; i++) { for (int i = 0; i < GPIO_PIN_COUNT; i++) {
if (GPIO_IS_VALID_OUTPUT_GPIO(i) && rtc_gpio_is_valid_gpio(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"); ESP_LOGI(TAG, "RTCIO hold test over");

View File

@ -17,18 +17,6 @@ def test_gpio(dut: IdfDut) -> None:
dut.run_all_single_board_cases(group='gpio') 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.esp32
@pytest.mark.esp32s2 @pytest.mark.esp32s2
@pytest.mark.esp32s3 @pytest.mark.esp32s3

View File

@ -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

View File

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

View File

@ -10,7 +10,7 @@ project(gpio_extension_test)
if(CONFIG_COMPILER_DUMP_RTL_FILES) if(CONFIG_COMPILER_DUMP_RTL_FILES)
add_custom_target(check_test_app_sections ALL add_custom_target(check_test_app_sections ALL
COMMAND ${PYTHON} $ENV{IDF_PATH}/tools/ci/check_callgraph.py 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 --elf-file ${CMAKE_BINARY_DIR}/gpio_extension_test.elf
find-refs find-refs
--from-sections=.iram0.text --from-sections=.iram0.text

View File

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

View File

@ -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") list(APPEND srcs "test_gpio_filter.c")
endif() endif()
if(CONFIG_SOC_SDM_SUPPORTED)
list(APPEND srcs "test_sdm.c")
endif()
if(CONFIG_SOC_GPIO_SUPPORT_PIN_HYS_FILTER) if(CONFIG_SOC_GPIO_SUPPORT_PIN_HYS_FILTER)
list(APPEND srcs "test_hysteresis.c") list(APPEND srcs "test_hysteresis.c")
endif() endif()
@ -19,5 +15,5 @@ endif()
# In order for the cases defined by `TEST_CASE` to be linked into the final elf, # In order for the cases defined by `TEST_CASE` to be linked into the final elf,
# the component can be registered as WHOLE_ARCHIVE # the component can be registered as WHOLE_ARCHIVE
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
PRIV_REQUIRES unity driver PRIV_REQUIRES unity esp_driver_gpio
WHOLE_ARCHIVE) WHOLE_ARCHIVE)

View File

@ -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();
}

View File

@ -9,7 +9,6 @@
#include "unity.h" #include "unity.h"
#include "driver/gpio.h" #include "driver/gpio.h"
/** /**
* NOTE: To run this special feature test case, a slope analog signal is needed. * 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. * 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. * which enabled the hysteresis feature directly to have a test.
**/ **/
static void test_gpio_hysteresis_intr_handler(void *args) 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 // 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_HYS_IO = 26;
const gpio_num_t TEST_WAVE_IO = 27; const gpio_num_t TEST_WAVE_IO = 27;
uint32_t intr_cnt=0; uint32_t intr_cnt = 0;
gpio_config_t gpio_cfg = { gpio_config_t gpio_cfg = {
.pin_bit_mask = 1 << TEST_WAVE_IO, .pin_bit_mask = (1 << TEST_WAVE_IO),
.mode = GPIO_MODE_OUTPUT, .mode = GPIO_MODE_OUTPUT,
.pull_down_en = GPIO_PULLDOWN_ENABLE, .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); gpio_isr_handler_add(TEST_HYS_IO, test_gpio_hysteresis_intr_handler, &intr_cnt);
// generate 5 rising and falling slopes to test gpio interrupt // 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); printf("----falling %dth\n", i);
gpio_set_level(TEST_WAVE_IO, 0); gpio_set_level(TEST_WAVE_IO, 0);
vTaskDelay(1500); vTaskDelay(1500);

View File

@ -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.esp32c2
@pytest.mark.esp32c3 @pytest.mark.esp32c3
@pytest.mark.esp32c6 @pytest.mark.esp32c6

View File

@ -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

View File

@ -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

View File

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

View File

@ -11,7 +11,7 @@ else()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${public_include} INCLUDE_DIRS ${public_include}
PRIV_REQUIRES "esp_pm" PRIV_REQUIRES "esp_pm"
"driver" # will be replaced by esp_driver_gpio "esp_driver_gpio"
LDFRAGMENTS "linker.lf" LDFRAGMENTS "linker.lf"
) )
endif() endif()

View File

@ -67,7 +67,7 @@ endif()
if(CONFIG_ETH_ENABLED) if(CONFIG_ETH_ENABLED)
if(CONFIG_ETH_USE_SPI_ETHERNET) if(CONFIG_ETH_USE_SPI_ETHERNET)
idf_component_optional_requires(PUBLIC driver) idf_component_optional_requires(PUBLIC driver esp_driver_gpio)
endif() endif()
idf_component_optional_requires(PRIVATE esp_netif esp_pm) idf_component_optional_requires(PRIVATE esp_netif esp_pm)
endif() endif()

View File

@ -50,8 +50,11 @@ if(NOT BOOTLOADER_BUILD)
list(APPEND srcs "sleep_retention.c" "sleep_system_peripheral.c" "sleep_clock.c") list(APPEND srcs "sleep_retention.c" "sleep_system_peripheral.c" "sleep_clock.c")
endif() endif()
# [refactor-todo]: requires "driver" for GPIO and RTC (by sleep_gpio and sleep_modes) # [refactor-todo]
list(APPEND priv_requires driver esp_timer) 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) list(APPEND priv_requires esp_mm)

View File

@ -27,5 +27,5 @@ endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes} INCLUDE_DIRS ${includes}
PRIV_REQUIRES ${priv_requires} PRIV_REQUIRES ${priv_requires}
REQUIRES driver REQUIRES driver esp_driver_gpio
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@ -6,5 +6,5 @@ endif()
idf_component_register(SRCS "pm_locks.c" "pm_trace.c" "pm_impl.c" idf_component_register(SRCS "pm_locks.c" "pm_trace.c" "pm_impl.c"
INCLUDE_DIRS include INCLUDE_DIRS include
PRIV_REQUIRES esp_system driver esp_timer PRIV_REQUIRES esp_system driver esp_driver_gpio esp_timer
LDFRAGMENTS linker.lf) LDFRAGMENTS linker.lf)

View File

@ -77,7 +77,7 @@ entries:
esp_time_impl:esp_set_time_from_rtc (noflash) esp_time_impl:esp_set_time_from_rtc (noflash)
[mapping:driver_pm] [mapping:driver_pm]
archive: libdriver.a archive: libesp_driver_gpio.a
entries: entries:
if GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL = y: if GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL = y:
gpio:gpio_sleep_pupd_config_unapply (noflash) gpio:gpio_sleep_pupd_config_unapply (noflash)

View File

@ -30,7 +30,11 @@ idf_component_register(SRCS ${srcs}
INCLUDE_DIRS ${includes} INCLUDE_DIRS ${includes}
PRIV_INCLUDE_DIRS ${priv_includes} PRIV_INCLUDE_DIRS ${priv_includes}
LDFRAGMENTS linker.lf LDFRAGMENTS linker.lf
PRIV_REQUIRES esp_partition spi_flash bootloader_support mbedtls esp_rom soc esp_system driver) 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) if(CONFIG_ESP_COREDUMP_DATA_FORMAT_ELF)
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format) target_link_libraries(${COMPONENT_LIB} PRIVATE idf::esp_app_format)

View File

@ -24,7 +24,7 @@ else()
list(APPEND requires "sdmmc") list(APPEND requires "sdmmc")
list(APPEND priv_requires "vfs") list(APPEND priv_requires "vfs" "esp_driver_gpio")
endif() endif()
idf_component_register(SRCS ${srcs} idf_component_register(SRCS ${srcs}

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
if (gpio_num < 32) { if (gpio_num < 32) {

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
return (hw->in.in_data_next >> gpio_num) & 0x1; return (hw->in.in_data_next >> gpio_num) & 0x1;

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
return (hw->in.data >> gpio_num) & 0x1; return (hw->in.data >> gpio_num) & 0x1;

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
return (hw->in.in_data_next >> gpio_num) & 0x1; return (hw->in.in_data_next >> gpio_num) & 0x1;

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) 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; return (hw->in.in_data_next >> gpio_num) & 0x1;

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
if (gpio_num < 32) { if (gpio_num < 32) {

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
if (gpio_num < 32) { if (gpio_num < 32) {

View File

@ -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 * - 0 the GPIO input level is 0
* - 1 the GPIO input level is 1 * - 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) static inline int gpio_ll_get_level(gpio_dev_t *hw, uint32_t gpio_num)
{ {
if (gpio_num < 32) { if (gpio_num < 32) {

View File

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

View File

@ -48,7 +48,9 @@ else()
"spi_flash_os_func_noos.c") "spi_flash_os_func_noos.c")
list(APPEND srcs ${cache_srcs}) 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() endif()
idf_component_register(SRCS "${srcs}" idf_component_register(SRCS "${srcs}"

View File

@ -6,13 +6,13 @@ components/spi_flash/test_apps/esp_flash:
temporary: true temporary: true
reason: target esp32p4 is not supported yet # TODO: IDF-7499 reason: target esp32p4 is not supported yet # TODO: IDF-7499
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* - components/driver/spi/**/*
- components/bootloader_support/bootloader_flash/**/* - components/bootloader_support/bootloader_flash/**/*
depends_components: depends_components:
- esp_mm - esp_mm
- esp_psram - esp_psram
- spi_flash - spi_flash
- esp_driver_gpio
- esptool_py # Some flash related kconfigs are listed here. - esptool_py # Some flash related kconfigs are listed here.
components/spi_flash/test_apps/flash_encryption: components/spi_flash/test_apps/flash_encryption:
@ -54,11 +54,11 @@ components/spi_flash/test_apps/mspi_test:
temporary: true temporary: true
reason: not supported yet #TODO: IDF-7556 for p4 reason: not supported yet #TODO: IDF-7556 for p4
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* - components/driver/spi/**/*
- components/bootloader_support/bootloader_flash/**/* - components/bootloader_support/bootloader_flash/**/*
depends_components: depends_components:
- esp_mm - esp_mm
- esp_psram - esp_psram
- spi_flash - spi_flash
- esp_driver_gpio
- esptool_py # Some flash related kconfigs are listed here. - esptool_py # Some flash related kconfigs are listed here.

View File

@ -10,7 +10,7 @@ set(priv_include)
# As CONFIG_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet # As CONFIG_USB_OTG_SUPPORTED comes from Kconfig, it is not evaluated yet
# when components are being registered. # when components are being registered.
# Thus, always add the (private) requirements, regardless of Kconfig # 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) if(CONFIG_USB_OTG_SUPPORTED)
list(APPEND srcs "hcd_dwc.c" list(APPEND srcs "hcd_dwc.c"

View File

@ -79,12 +79,6 @@ INPUT = \
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_cosine.h \ $(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_oneshot.h \
$(PROJECT_PATH)/components/driver/dac/include/driver/dac_types.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.h \
$(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_etm.h \ $(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_etm.h \
$(PROJECT_PATH)/components/driver/gptimer/include/driver/gptimer_types.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_check.h \
$(PROJECT_PATH)/components/esp_common/include/esp_err.h \ $(PROJECT_PATH)/components/esp_common/include/esp_err.h \
$(PROJECT_PATH)/components/esp_common/include/esp_idf_version.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_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_com.h \
$(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \ $(PROJECT_PATH)/components/esp_eth/include/esp_eth_driver.h \

View File

@ -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=0x400DB74B (active) APP_CPU: PC=0x400D1128
Target halted. PRO_CPU: PC=0x400DC04C (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 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); 183 GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
(gdb) (gdb)

View File

@ -123,7 +123,7 @@ When writing code, please follow the guidelines below:
For practical example see :component_file:`nvs_flash/include/nvs.h`. 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. :: 5. Use markdown to make your documentation even more readable. You will add headers, links, tables and more. ::

View File

@ -497,7 +497,7 @@
Target halted. PRO_CPU: PC=0x400DB74B (active) APP_CPU: PC=0x400D1128 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=0x400DC04C (active) APP_CPU: PC=0x400D1128
Target halted. PRO_CPU: PC=0x400DC04F (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); 183 GPIO_CHECK(GPIO_IS_VALID_OUTPUT_GPIO(gpio_num), "GPIO output gpio_num error", ESP_ERR_INVALID_ARG);
(gdb) (gdb)

View File

@ -123,7 +123,7 @@ Doxygen 支持多种格式,并支持文档内部的多个详情级别,具有
如需更多应用示例,请参考 :component_file:`nvs_flash/include/nvs.h` 如需更多应用示例,请参考 :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 添加标题、链接和表格等,增强文档的可读性。 :: 5. 使用 markdown 添加标题、链接和表格等,增强文档的可读性。 ::

View File

@ -24,8 +24,8 @@ examples/bluetooth/bluedroid/ble:
examples/bluetooth/bluedroid/ble/ble_hid_device_demo: examples/bluetooth/bluedroid/ble/ble_hid_device_demo:
disable: disable:
- if: SOC_BT_SUPPORTED != 1 - if: SOC_BT_SUPPORTED != 1
depends_filepatterns: depends_components:
- components/driver/gpio/**/* - esp_driver_gpio
examples/bluetooth/bluedroid/ble_50: examples/bluetooth/bluedroid/ble_50:
disable: disable:
@ -41,11 +41,11 @@ examples/bluetooth/bluedroid/classic_bt:
- esp_log - esp_log
- esp_console - esp_console
- vfs - vfs
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- components/driver/dac/**/* - components/driver/dac/**/*
- components/driver/i2s/**/* - components/driver/i2s/**/*
- components/driver/uart/**/* - components/driver/uart/**/*
- components/driver/gpio/**/*
examples/bluetooth/bluedroid/coex/a2dp_gatts_coex: examples/bluetooth/bluedroid/coex/a2dp_gatts_coex:
<<: *bt_default_depends <<: *bt_default_depends
@ -84,9 +84,9 @@ examples/bluetooth/esp_ble_mesh:
- vfs - vfs
- mbedtls - mbedtls
- touch_element - touch_element
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- examples/bluetooth/esp_ble_mesh/common_components/**/* - examples/bluetooth/esp_ble_mesh/common_components/**/*
- components/driver/gpio/**/*
examples/bluetooth/esp_ble_mesh/aligenie_demo: examples/bluetooth/esp_ble_mesh/aligenie_demo:
enable: enable:
@ -99,9 +99,9 @@ examples/bluetooth/esp_ble_mesh/aligenie_demo:
- vfs - vfs
- mbedtls - mbedtls
- driver - driver
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- examples/bluetooth/esp_ble_mesh/common_components/**/* - examples/bluetooth/esp_ble_mesh/common_components/**/*
- components/driver/gpio/**/*
examples/bluetooth/esp_ble_mesh/coex_test: examples/bluetooth/esp_ble_mesh/coex_test:
enable: enable:
@ -117,9 +117,9 @@ examples/bluetooth/esp_ble_mesh/coex_test:
- esp_coex - esp_coex
- esp_wifi - esp_wifi
- esp_netif - esp_netif
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- examples/bluetooth/esp_ble_mesh/common_components/**/* - examples/bluetooth/esp_ble_mesh/common_components/**/*
- components/driver/gpio/**/*
examples/bluetooth/esp_ble_mesh/wifi_coexist: examples/bluetooth/esp_ble_mesh/wifi_coexist:
disable: disable:
@ -134,9 +134,9 @@ examples/bluetooth/esp_ble_mesh/wifi_coexist:
- esp_coex - esp_coex
- esp_wifi - esp_wifi
- esp_netif - esp_netif
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- examples/bluetooth/esp_ble_mesh/common_components/**/* - examples/bluetooth/esp_ble_mesh/common_components/**/*
- components/driver/gpio/**/*
examples/bluetooth/hci: examples/bluetooth/hci:
<<: *bt_default_depends <<: *bt_default_depends
@ -271,8 +271,9 @@ examples/bluetooth/nimble/throughput_app:
<<: *bt_default_depends <<: *bt_default_depends
disable: disable:
- if: SOC_BLE_SUPPORTED != 1 - if: SOC_BLE_SUPPORTED != 1
depends_components:
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- examples/bluetooth/nimble/common/**/* - examples/bluetooth/nimble/common/**/*
- examples/bluetooth/nimble/throughput_app/blecent_throughput/components/**/* - examples/bluetooth/nimble/throughput_app/blecent_throughput/components/**/*
- components/driver/uart/**/* - components/driver/uart/**/*
- components/driver/gpio/**/*

View File

@ -1,3 +1,3 @@
idf_component_register(SRCS "button.c" "button_obj.cpp" idf_component_register(SRCS "button.c" "button_obj.cpp"
INCLUDE_DIRS "." "include" INCLUDE_DIRS "." "include"
PRIV_REQUIRES driver esp_timer) PRIV_REQUIRES esp_driver_gpio esp_timer)

View File

@ -7,6 +7,6 @@ set(COMPONENT_SRCS
set(COMPONENT_ADD_INCLUDEDIRS ". include") set(COMPONENT_ADD_INCLUDEDIRS ". include")
# requirements can't depend on config # requirements can't depend on config
set(COMPONENT_REQUIRES example_nvs driver) set(COMPONENT_REQUIRES example_nvs driver esp_driver_gpio)
register_component() register_component()

View File

@ -8,8 +8,8 @@ examples/ethernet/basic:
- esp_netif - esp_netif
- lwip - lwip
- esp_event - esp_event
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* - components/driver/spi/**/*
examples/ethernet/enc28j60: examples/ethernet/enc28j60:
@ -22,8 +22,8 @@ examples/ethernet/enc28j60:
- esp_netif - esp_netif
- lwip - lwip
- esp_event - esp_event
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* - components/driver/spi/**/*
examples/ethernet/iperf: examples/ethernet/iperf:
@ -37,8 +37,8 @@ examples/ethernet/iperf:
- lwip - lwip
- esp_event - esp_event
- console - console
- esp_driver_gpio
depends_filepatterns: depends_filepatterns:
- components/driver/gpio/**/*
- components/driver/spi/**/* - components/driver/spi/**/*
- examples/common_components/iperf/**/* - examples/common_components/iperf/**/*
- examples/common_components/protocol_examples_common/**/* - examples/common_components/protocol_examples_common/**/*

View File

@ -27,6 +27,10 @@ examples/peripherals/dac:
disable: disable:
- if: SOC_DAC_SUPPORTED != 1 - if: SOC_DAC_SUPPORTED != 1
examples/peripherals/gpio:
depends_components:
- esp_driver_gpio
examples/peripherals/gpio/matrix_keyboard: examples/peripherals/gpio/matrix_keyboard:
enable: enable:
- if: IDF_TARGET == "esp32s2" - if: IDF_TARGET == "esp32s2"

View File

@ -5,20 +5,23 @@
[mapping:eeprom] [mapping:eeprom]
archive: libeeprom.a archive: libeeprom.a
entries: entries:
if EXAMPLE_USE_SPI1_PINS = y:
* (noflash) * (noflash)
[mapping:ext_driver] [mapping:ext_driver]
archive: libdriver.a archive: libesp_driver_gpio.a
entries: entries:
# gpio_set_level, gpio_get_level, gpio_context, _gpio_hal, etc... if EXAMPLE_USE_SPI1_PINS = y:
gpio (noflash) gpio: gpio_intr_enable (noflash)
[mapping:ext_soc] [mapping:ext_soc]
archive: libhal.a archive: libhal.a
entries: entries:
gpio_hal (noflash) if EXAMPLE_USE_SPI1_PINS = y:
gpio_hal: gpio_hal_intr_enable_on_core (noflash)
[mapping:ext_newlib] [mapping:ext_newlib]
archive: libnewlib.a archive: libnewlib.a
entries: entries:
if EXAMPLE_USE_SPI1_PINS = y:
time:usleep (noflash) time:usleep (noflash)

View File

@ -51,16 +51,6 @@ typedef struct eeprom_context_t eeprom_context_t;
static const char TAG[] = "eeprom"; 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) static esp_err_t eeprom_simple_cmd(eeprom_context_t *ctx, uint16_t cmd)
{ {
spi_transaction_t t = { spi_transaction_t t = {

Some files were not shown because too many files have changed in this diff Show More