Merge branch 'refactor/gpio_valid_2_soc' into 'master'

refactor(gpio): Move valid gpio_caps macro from driver layer to soc layer

Closes IDF-13564

See merge request espressif/esp-idf!40521
This commit is contained in:
C.S.M
2025-07-18 13:18:46 +08:00
6 changed files with 40 additions and 31 deletions

View File

@@ -20,17 +20,6 @@
extern "C" {
#endif
#define GPIO_PIN_COUNT (SOC_GPIO_PIN_COUNT)
/// Check whether it is a valid GPIO number
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
/// Check whether it can be a valid GPIO number of output mode
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
/// Check whether it can be a valid digital I/O pad
#define GPIO_IS_VALID_DIGITAL_IO_PAD(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK) != 0))
typedef intr_handle_t gpio_isr_handle_t;
/**

View File

@@ -20,13 +20,6 @@
#include "hal/gpio_ll.h"
#include "soc/soc_caps.h"
/// Check whether it is a valid GPIO number
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
/// Check whether it can be a valid GPIO number of output mode
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
#if SOC_USB_UTMI_PHY_NO_POWER_OFF_ISO
#include "esp_private/sleep_usb.h"
#include "esp_sleep.h"

View File

@@ -16,6 +16,17 @@
extern "C" {
#endif
#define GPIO_PIN_COUNT (SOC_GPIO_PIN_COUNT)
/// Check whether it is a valid GPIO number
#define GPIO_IS_VALID_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_GPIO_MASK) != 0))
/// Check whether it can be a valid GPIO number of output mode
#define GPIO_IS_VALID_OUTPUT_GPIO(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_OUTPUT_GPIO_MASK) != 0))
/// Check whether it can be a valid digital I/O pad
#define GPIO_IS_VALID_DIGITAL_IO_PAD(gpio_num) ((gpio_num >= 0) && \
(((1ULL << (gpio_num)) & SOC_GPIO_VALID_DIGITAL_IO_PAD_MASK) != 0))
typedef enum {
GPIO_PORT_0 = 0,
GPIO_PORT_MAX,

View File

@@ -52,9 +52,7 @@ else()
"spi_flash_os_func_noos.c")
list(APPEND srcs ${cache_srcs})
set(priv_requires bootloader_support app_update soc esp_mm
esp_driver_gpio
)
set(priv_requires bootloader_support soc esp_mm)
endif()
idf_component_register(SRCS "${srcs}"

View File

@@ -8,7 +8,6 @@
#include "esp_flash.h"
#include "memspi_host_driver.h"
#include "esp_flash_spi_init.h"
#include "driver/gpio.h"
#include "esp_rom_gpio.h"
#include "esp_rom_efuse.h"
#include "esp_log.h"

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2024-2025 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Unlicense OR CC0-1.0
import argparse
import logging
@@ -6,13 +6,30 @@ from typing import Dict
from typing import List
from typing import Tuple
g1_g0_components = ['hal', 'cxx', 'newlib', 'freertos', 'esp_hw_support', 'heap', 'log', 'soc', 'esp_rom',
'esp_common', 'esp_system', 'xtensa', 'riscv', 'spi_flash', 'esp_mm']
g1_g0_components = [
'hal',
'cxx',
'newlib',
'freertos',
'esp_hw_support',
'heap',
'log',
'soc',
'esp_rom',
'esp_common',
'esp_system',
'xtensa',
'riscv',
'spi_flash',
'esp_mm',
]
expected_dep_violations = {'esp_system': ['esp_timer', 'bootloader_support', 'esp_pm'],
'spi_flash': ['bootloader_support', 'app_update', 'esp_driver_gpio'],
'esp_hw_support': ['efuse', 'bootloader_support', 'esp_driver_gpio', 'esp_timer', 'esp_pm', 'esp_security'],
'cxx': ['pthread']}
expected_dep_violations = {
'esp_system': ['esp_timer', 'bootloader_support', 'esp_pm'],
'spi_flash': ['bootloader_support'],
'esp_hw_support': ['efuse', 'bootloader_support', 'esp_driver_gpio', 'esp_timer', 'esp_pm', 'esp_security'],
'cxx': ['pthread'],
}
def parse_dependencies(file_path: str) -> Tuple[Dict[str, List[str]], List[str]]:
@@ -25,7 +42,7 @@ def parse_dependencies(file_path: str) -> Tuple[Dict[str, List[str]], List[str]]
if line:
parts = line.split(' -> ')
if (len(parts) >= 2):
if len(parts) >= 2:
source = parts[0]
target = parts[1].split()[0] # Extracting the target component
logging.debug(f'Parsed dependency: {source} -> {target}')
@@ -48,7 +65,9 @@ def parse_dependencies(file_path: str) -> Tuple[Dict[str, List[str]], List[str]]
if __name__ == '__main__':
parser = argparse.ArgumentParser(description='Check G1 dependencies')
parser.add_argument('--component_deps_file', required=True, type=str, help='The path to the component_deps.dot file')
parser.add_argument(
'--component_deps_file', required=True, type=str, help='The path to the component_deps.dot file'
)
args = parser.parse_args()