From 6a60ecf780ae3f2afecbf5f9248465b84533df77 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Wed, 31 Aug 2022 20:12:24 +0800 Subject: [PATCH] soc_caps: Introduce SOC_LEDC_SUPPORTED and SOC_I2C_SUPPORTED caps to IDF Wrap the ledc, i2c source files with the new caps in CMakeLists and linker.lf. This could avoid potential source file not found warning during linking time. --- components/driver/CMakeLists.txt | 10 ++++++++-- components/hal/CMakeLists.txt | 12 ++++++++---- components/hal/linker.lf | 6 ++++-- components/soc/esp32/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32/include/soc/soc_caps.h | 2 ++ .../soc/esp32c2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32c2/include/soc/soc_caps.h | 2 ++ .../soc/esp32c3/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32c3/include/soc/soc_caps.h | 2 ++ .../soc/esp32h2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32h2/include/soc/soc_caps.h | 2 ++ .../soc/esp32s2/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32s2/include/soc/soc_caps.h | 2 ++ .../soc/esp32s3/include/soc/Kconfig.soc_caps.in | 8 ++++++++ components/soc/esp32s3/include/soc/soc_caps.h | 2 ++ 15 files changed, 80 insertions(+), 8 deletions(-) diff --git a/components/driver/CMakeLists.txt b/components/driver/CMakeLists.txt index 4e65c15274a..6315559855e 100644 --- a/components/driver/CMakeLists.txt +++ b/components/driver/CMakeLists.txt @@ -4,8 +4,6 @@ set(srcs "gpio/gpio.c" "gpio/rtc_io.c" "gptimer.c" - "i2c.c" - "ledc.c" "sdspi_crc.c" "sdspi_host.c" "sdspi_transaction.c" @@ -23,6 +21,14 @@ if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${target}/include") list(APPEND includes "${target}/include") endif() +if(CONFIG_SOC_LEDC_SUPPORTED) + list(APPEND srcs "ledc.c") +endif() + +if(CONFIG_SOC_I2C_SUPPORTED) + list(APPEND srcs "i2c.c") +endif() + if(CONFIG_SOC_ADC_SUPPORTED) list(APPEND srcs "deprecated/adc_legacy.c") endif() diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index 0c212433256..a8746eeab2e 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -32,10 +32,6 @@ if(NOT BOOTLOADER_BUILD) "spi_slave_hal_iram.c" "timer_hal.c" "timer_hal_iram.c" - "ledc_hal.c" - "ledc_hal_iram.c" - "i2c_hal.c" - "i2c_hal_iram.c" "gpio_hal.c" "uart_hal.c" "uart_hal_iram.c" @@ -50,6 +46,14 @@ if(NOT BOOTLOADER_BUILD) list(APPEND srcs "systimer_hal.c") endif() + if(CONFIG_SOC_LEDC_SUPPORTED) + list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c") + endif() + + if(CONFIG_SOC_I2C_SUPPORTED) + list(APPEND srcs "i2c_hal.c" "i2c_hal_iram.c") + endif() + if(CONFIG_SOC_RMT_SUPPORTED) list(APPEND srcs "rmt_hal.c") endif() diff --git a/components/hal/linker.lf b/components/hal/linker.lf index c8178e04eba..2f906cc62ad 100644 --- a/components/hal/linker.lf +++ b/components/hal/linker.lf @@ -12,8 +12,10 @@ entries: uart_hal_iram (default) spi_flash_hal_iram (noflash) spi_flash_encrypt_hal_iram (noflash) - ledc_hal_iram (noflash) - i2c_hal_iram (noflash) + if SOC_LEDC_SUPPORTED = y: + ledc_hal_iram (noflash) + if SOC_I2C_SUPPORTED = y: + i2c_hal_iram (noflash) if HAL_WDT_USE_ROM_IMPL = n: wdt_hal_iram (noflash) if SOC_SYSTIMER_SUPPORTED = y && HAL_SYSTIMER_USE_ROM_IMPL = n: diff --git a/components/soc/esp32/include/soc/Kconfig.soc_caps.in b/components/soc/esp32/include/soc/Kconfig.soc_caps.in index f404d34c6d0..4bffb262192 100644 --- a/components/soc/esp32/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32/include/soc/Kconfig.soc_caps.in @@ -91,6 +91,14 @@ config SOC_SDM_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SUPPORT_COEXISTENCE bool default y diff --git a/components/soc/esp32/include/soc/soc_caps.h b/components/soc/esp32/include/soc/soc_caps.h index cf07867ed3b..8deb85def88 100644 --- a/components/soc/esp32/include/soc/soc_caps.h +++ b/components/soc/esp32/include/soc/soc_caps.h @@ -82,6 +82,8 @@ #define SOC_I2S_SUPPORTED 1 #define SOC_RMT_SUPPORTED 1 #define SOC_SDM_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SUPPORT_COEXISTENCE 1 #define SOC_AES_SUPPORTED 1 #define SOC_MPI_SUPPORTED 1 diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index 177dc74bdcf..f49f0c56290 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -43,6 +43,14 @@ config SOC_TEMP_SENSOR_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SHA_SUPPORTED bool default y diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index 98d6674a1f7..76f4e335be2 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -35,6 +35,8 @@ #define SOC_EFUSE_KEY_PURPOSE_FIELD 0 #define SOC_EFUSE_CONSISTS_OF_ONE_KEY_BLOCK 1 #define SOC_TEMP_SENSOR_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SHA_SUPPORTED 1 #define SOC_ECC_SUPPORTED 1 #define SOC_FLASH_ENC_SUPPORTED 1 diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index b7ef94e4b3c..8a7a123ccfa 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -75,6 +75,14 @@ config SOC_SDM_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SYSTIMER_SUPPORTED bool default y diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index 57d9172c4b4..df5d6d5dfc1 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -43,6 +43,8 @@ #define SOC_I2S_SUPPORTED 1 #define SOC_RMT_SUPPORTED 1 #define SOC_SDM_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SUPPORT_COEXISTENCE 1 #define SOC_AES_SUPPORTED 1 diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index 6b24c9e14d2..b195751b16a 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -63,6 +63,14 @@ config SOC_SDM_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SYSTIMER_SUPPORTED bool default y diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index 98f1917bc98..063250f5113 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -48,6 +48,8 @@ #define SOC_I2S_SUPPORTED 1 #define SOC_RMT_SUPPORTED 1 #define SOC_SDM_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SYSTIMER_SUPPORTED 1 #define SOC_AES_SUPPORTED 1 #define SOC_MPI_SUPPORTED 1 diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index e2b4af74430..bddac7ec46a 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -99,6 +99,14 @@ config SOC_SDM_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SYSTIMER_SUPPORTED bool default y diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index 2389502267d..0c9a2e7d8b1 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -63,6 +63,8 @@ #define SOC_I2S_SUPPORTED 1 #define SOC_RMT_SUPPORTED 1 #define SOC_SDM_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SUPPORT_COEXISTENCE 0 #define SOC_AES_SUPPORTED 1 diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index d0f53f18f2d..89523746f6c 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -151,6 +151,14 @@ config SOC_SDM_SUPPORTED bool default y +config SOC_LEDC_SUPPORTED + bool + default y + +config SOC_I2C_SUPPORTED + bool + default y + config SOC_SYSTIMER_SUPPORTED bool default y diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index 9c844d12a0a..349f409f2ce 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -52,6 +52,8 @@ #define SOC_I2S_SUPPORTED 1 #define SOC_RMT_SUPPORTED 1 #define SOC_SDM_SUPPORTED 1 +#define SOC_LEDC_SUPPORTED 1 +#define SOC_I2C_SUPPORTED 1 #define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SUPPORT_COEXISTENCE 1 #define SOC_TEMP_SENSOR_SUPPORTED 1