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

pull/12525/head
Song Ruo Jing 2023-10-17 12:11:42 +08:00
rodzic 342535f47c
commit 9461993ec5
104 zmienionych plików z 456 dodań i 263 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

@ -10,8 +10,7 @@
#include "esp_heap_caps.h"
#include "driver/gpio.h"
#include "driver/rtc_io.h"
#include "soc/soc.h"
#include "soc/periph_defs.h"
#include "soc/interrupts.h"
#if !CONFIG_FREERTOS_UNICORE
#include "esp_ipc.h"
#endif
@ -166,7 +165,7 @@ esp_err_t gpio_set_intr_type(gpio_num_t gpio_num, gpio_int_type_t intr_type)
return ESP_OK;
}
static esp_err_t gpio_intr_enable_on_core(gpio_num_t gpio_num, uint32_t core_id)
static inline esp_err_t gpio_intr_enable_on_core(gpio_num_t gpio_num, uint32_t core_id)
{
gpio_hal_intr_enable_on_core(gpio_context.gpio_hal, gpio_num, core_id);
return ESP_OK;
@ -176,11 +175,11 @@ esp_err_t gpio_intr_enable(gpio_num_t gpio_num)
{
GPIO_CHECK(GPIO_IS_VALID_GPIO(gpio_num), "GPIO number error", ESP_ERR_INVALID_ARG);
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
if(gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) {
if (gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) {
gpio_context.isr_core_id = xPortGetCoreID();
}
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
return gpio_intr_enable_on_core (gpio_num, gpio_context.isr_core_id);
return gpio_intr_enable_on_core(gpio_num, gpio_context.isr_core_id);
}
esp_err_t gpio_intr_disable(gpio_num_t gpio_num)
@ -274,30 +273,30 @@ esp_err_t gpio_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull)
esp_err_t ret = ESP_OK;
switch (pull) {
case GPIO_PULLUP_ONLY:
gpio_pulldown_dis(gpio_num);
gpio_pullup_en(gpio_num);
break;
case GPIO_PULLUP_ONLY:
gpio_pulldown_dis(gpio_num);
gpio_pullup_en(gpio_num);
break;
case GPIO_PULLDOWN_ONLY:
gpio_pulldown_en(gpio_num);
gpio_pullup_dis(gpio_num);
break;
case GPIO_PULLDOWN_ONLY:
gpio_pulldown_en(gpio_num);
gpio_pullup_dis(gpio_num);
break;
case GPIO_PULLUP_PULLDOWN:
gpio_pulldown_en(gpio_num);
gpio_pullup_en(gpio_num);
break;
case GPIO_PULLUP_PULLDOWN:
gpio_pulldown_en(gpio_num);
gpio_pullup_en(gpio_num);
break;
case GPIO_FLOATING:
gpio_pulldown_dis(gpio_num);
gpio_pullup_dis(gpio_num);
break;
case GPIO_FLOATING:
gpio_pulldown_dis(gpio_num);
gpio_pullup_dis(gpio_num);
break;
default:
ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull);
ret = ESP_ERR_INVALID_ARG;
break;
default:
ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull);
ret = ESP_ERR_INVALID_ARG;
break;
}
return ret;
@ -347,13 +346,13 @@ esp_err_t gpio_config(const gpio_config_t *pGPIOConfig)
uint8_t pd_en = 0;
if (pGPIOConfig->pin_bit_mask == 0 ||
pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_GPIO_MASK) {
pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_GPIO_MASK) {
ESP_LOGE(GPIO_TAG, "GPIO_PIN mask error ");
return ESP_ERR_INVALID_ARG;
}
if (pGPIOConfig->mode & GPIO_MODE_DEF_OUTPUT &&
pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_OUTPUT_GPIO_MASK) {
pGPIOConfig->pin_bit_mask & ~SOC_GPIO_VALID_OUTPUT_GPIO_MASK) {
ESP_LOGE(GPIO_TAG, "GPIO can only be used as input mode");
return ESP_ERR_INVALID_ARG;
}
@ -538,7 +537,7 @@ esp_err_t gpio_isr_handler_add(gpio_num_t gpio_num, gpio_isr_t isr_handler, void
gpio_context.gpio_isr_func[gpio_num].fn = isr_handler;
gpio_context.gpio_isr_func[gpio_num].args = args;
}
gpio_intr_enable_on_core (gpio_num, esp_intr_get_cpu(gpio_context.gpio_isr_handle));
gpio_intr_enable_on_core(gpio_num, esp_intr_get_cpu(gpio_context.gpio_isr_handle));
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
return ESP_OK;
}
@ -577,7 +576,6 @@ void gpio_uninstall_isr_service(void)
return;
}
static void gpio_isr_register_on_core_static(void *param)
{
gpio_isr_alloc_t *p = (gpio_isr_alloc_t *)param;
@ -602,7 +600,7 @@ esp_err_t gpio_isr_register(void (*fn)(void *), void *arg, int intr_alloc_flags,
p.arg = arg;
p.handle = handle;
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
if(gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) {
if (gpio_context.isr_core_id == GPIO_ISR_CORE_ID_UNINIT) {
gpio_context.isr_core_id = xPortGetCoreID();
}
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@ -739,7 +737,7 @@ esp_err_t gpio_hold_dis(gpio_num_t gpio_num)
#if SOC_RTCIO_HOLD_SUPPORTED
ret = rtc_gpio_hold_dis(gpio_num);
#endif
}else if (GPIO_HOLD_MASK[gpio_num]) {
} else if (GPIO_HOLD_MASK[gpio_num]) {
portENTER_CRITICAL(&gpio_context.gpio_spinlock);
gpio_hal_hold_dis(gpio_context.gpio_hal, gpio_num);
portEXIT_CRITICAL(&gpio_context.gpio_spinlock);
@ -905,30 +903,30 @@ esp_err_t gpio_sleep_set_pull_mode(gpio_num_t gpio_num, gpio_pull_mode_t pull)
esp_err_t ret = ESP_OK;
switch (pull) {
case GPIO_PULLUP_ONLY:
gpio_sleep_pulldown_dis(gpio_num);
gpio_sleep_pullup_en(gpio_num);
break;
case GPIO_PULLUP_ONLY:
gpio_sleep_pulldown_dis(gpio_num);
gpio_sleep_pullup_en(gpio_num);
break;
case GPIO_PULLDOWN_ONLY:
gpio_sleep_pulldown_en(gpio_num);
gpio_sleep_pullup_dis(gpio_num);
break;
case GPIO_PULLDOWN_ONLY:
gpio_sleep_pulldown_en(gpio_num);
gpio_sleep_pullup_dis(gpio_num);
break;
case GPIO_PULLUP_PULLDOWN:
gpio_sleep_pulldown_en(gpio_num);
gpio_sleep_pullup_en(gpio_num);
break;
case GPIO_PULLUP_PULLDOWN:
gpio_sleep_pulldown_en(gpio_num);
gpio_sleep_pullup_en(gpio_num);
break;
case GPIO_FLOATING:
gpio_sleep_pulldown_dis(gpio_num);
gpio_sleep_pullup_dis(gpio_num);
break;
case GPIO_FLOATING:
gpio_sleep_pulldown_dis(gpio_num);
gpio_sleep_pullup_dis(gpio_num);
break;
default:
ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull);
ret = ESP_ERR_INVALID_ARG;
break;
default:
ESP_LOGE(GPIO_TAG, "Unknown pull up/down mode,gpio_num=%u,pull=%u", gpio_num, pull);
ret = ESP_ERR_INVALID_ARG;
break;
}
return ret;

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

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