diff --git a/components/hal/CMakeLists.txt b/components/hal/CMakeLists.txt index f16780d5f7..c202595de2 100644 --- a/components/hal/CMakeLists.txt +++ b/components/hal/CMakeLists.txt @@ -45,6 +45,12 @@ if(NOT BOOTLOADER_BUILD) "sha_hal.c" "adc_hal.c") + if(CONFIG_SOC_SYSTIMER_SUPPORTED) + if(NOT CONFIG_HAL_SYSTIMER_ROM_IMPL) + list(APPEND srcs "systimer_hal.c") + endif() + endif() + if(${target} STREQUAL "esp32") list(APPEND srcs "dac_hal.c" @@ -76,7 +82,6 @@ if(NOT BOOTLOADER_BUILD) "pcnt_hal.c" "spi_flash_hal_gpspi.c" "spi_slave_hd_hal.c" - "systimer_hal.c" "touch_sensor_hal.c" "usb_hal.c" "usb_phy_hal.c" @@ -104,7 +109,6 @@ if(NOT BOOTLOADER_BUILD) "pcnt_hal.c" "spi_flash_hal_gpspi.c" "spi_slave_hd_hal.c" - "systimer_hal.c" "touch_sensor_hal.c" "usb_hal.c" "usb_phy_hal.c" @@ -129,7 +133,6 @@ if(NOT BOOTLOADER_BUILD) "sigmadelta_hal.c" "spi_flash_hal_gpspi.c" "spi_slave_hd_hal.c" - "systimer_hal.c" "xt_wdt_hal.c" "i2s_hal.c" "twai_hal.c" @@ -149,7 +152,6 @@ if(NOT BOOTLOADER_BUILD) "sigmadelta_hal.c" "spi_flash_hal_gpspi.c" "spi_slave_hd_hal.c" - "systimer_hal.c" "i2s_hal.c" "twai_hal.c" "twai_hal_iram.c" @@ -165,7 +167,6 @@ if(NOT BOOTLOADER_BUILD) "gdma_hal.c" "spi_flash_hal_gpspi.c" "spi_slave_hd_hal.c" - "systimer_hal.c" "esp32c2/brownout_hal.c" "esp32c2/rtc_cntl_hal.c") endif() diff --git a/components/hal/Kconfig b/components/hal/Kconfig index 5c1cd4ab3f..3ab4a6e2e3 100644 --- a/components/hal/Kconfig +++ b/components/hal/Kconfig @@ -65,4 +65,20 @@ menu "Hardware Abstraction Layer (HAL) and Low Level (LL)" default 4 if HAL_LOG_LEVEL_DEBUG default 5 if HAL_LOG_LEVEL_VERBOSE + config HAL_SYSTIMER_HAS_ROM_IMPL + bool + default y if IDF_TARGET_ESP32C2 + + config HAL_SYSTIMER_ROM_IMPL + bool "Use systimer HAL implementation in ROM" + depends on HAL_SYSTIMER_HAS_ROM_IMPL + default y + help + Enable this flag to use HAL functions from ROM instead of ESP-IDF. + + If keeping this as "n" in your project, you will have less free IRAM. + If making this as "y" in your project, you will increase free IRAM, + but you will lose the possibility to debug this module, and some new + features will be added and bugs will be fixed in the IDF source + but cannot be synced to ROM. endmenu diff --git a/components/hal/linker.lf b/components/hal/linker.lf index 695b7be44f..cb80110cbb 100644 --- a/components/hal/linker.lf +++ b/components/hal/linker.lf @@ -21,7 +21,8 @@ entries: twai_hal_iram (noflash) if IDF_TARGET_ESP32 = n: spi_flash_hal_gpspi (noflash) - systimer_hal (noflash) + if HAL_SYSTIMER_HAS_ROM_IMPL = n || HAL_SYSTIMER_ROM_IMPL = n: + systimer_hal (noflash) if GPTIMER_CTRL_FUNC_IN_IRAM = y: timer_hal_iram (noflash) if GPIO_CTRL_FUNC_IN_IRAM = y: diff --git a/components/hal/systimer_hal.c b/components/hal/systimer_hal.c index c96b3b5589..b280c98a53 100644 --- a/components/hal/systimer_hal.c +++ b/components/hal/systimer_hal.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2021 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ diff --git a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in index d908620039..7ad69152c7 100644 --- a/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c2/include/soc/Kconfig.soc_caps.in @@ -387,6 +387,10 @@ config SOC_MEMSPI_SRC_FREQ_15M_SUPPORTED bool default y +config SOC_SYSTIMER_SUPPORTED + bool + default y + config SOC_SYSTIMER_COUNTER_NUM int default 2 diff --git a/components/soc/esp32c2/include/soc/soc_caps.h b/components/soc/esp32c2/include/soc/soc_caps.h index a14b3a466d..042c163da2 100644 --- a/components/soc/esp32c2/include/soc/soc_caps.h +++ b/components/soc/esp32c2/include/soc/soc_caps.h @@ -207,6 +207,7 @@ #define SOC_MEMSPI_SRC_FREQ_15M_SUPPORTED 1 /*-------------------------- SYSTIMER CAPS ----------------------------------*/ +#define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SYSTIMER_COUNTER_NUM (2) // Number of counter units #define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units #define SOC_SYSTIMER_BIT_WIDTH_LO (32) // Bit width of systimer low part diff --git a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in index 4305b5cb4a..be70fa39b5 100644 --- a/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32c3/include/soc/Kconfig.soc_caps.in @@ -563,6 +563,10 @@ config SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED bool default y +config SOC_SYSTIMER_SUPPORTED + bool + default y + config SOC_SYSTIMER_COUNTER_NUM int default 2 diff --git a/components/soc/esp32c3/include/soc/soc_caps.h b/components/soc/esp32c3/include/soc/soc_caps.h index cf72b8ef60..6d4aac29d8 100644 --- a/components/soc/esp32c3/include/soc/soc_caps.h +++ b/components/soc/esp32c3/include/soc/soc_caps.h @@ -276,6 +276,7 @@ #define SOC_MEMSPI_SRC_FREQ_20M_SUPPORTED 1 /*-------------------------- SYSTIMER CAPS ----------------------------------*/ +#define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SYSTIMER_COUNTER_NUM (2) // Number of counter units #define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units #define SOC_SYSTIMER_BIT_WIDTH_LO (32) // Bit width of systimer low part diff --git a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in index cdc218cb03..4f3e97e1bf 100644 --- a/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32h2/include/soc/Kconfig.soc_caps.in @@ -555,6 +555,10 @@ config SOC_MEMSPI_SRC_FREQ_12M_SUPPORTED bool default y +config SOC_SYSTIMER_SUPPORTED + bool + default y + config SOC_SYSTIMER_COUNTER_NUM int default 2 diff --git a/components/soc/esp32h2/include/soc/soc_caps.h b/components/soc/esp32h2/include/soc/soc_caps.h index d2a705471d..137e14e75e 100644 --- a/components/soc/esp32h2/include/soc/soc_caps.h +++ b/components/soc/esp32h2/include/soc/soc_caps.h @@ -287,6 +287,7 @@ #define SOC_MEMSPI_SRC_FREQ_12M_SUPPORTED 1 /*-------------------------- SYSTIMER CAPS ----------------------------------*/ +#define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SYSTIMER_COUNTER_NUM (2) // Number of counter units #define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units #define SOC_SYSTIMER_BIT_WIDTH_LO (32) // Bit width of systimer low part diff --git a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in index 24bd84157e..3ff3427296 100644 --- a/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s2/include/soc/Kconfig.soc_caps.in @@ -579,6 +579,10 @@ config SOC_SYSTIMER_BIT_WIDTH_HI int default 32 +config SOC_SYSTIMER_SUPPORTED + bool + default y + config SOC_TIMER_GROUPS int default 2 diff --git a/components/soc/esp32s2/include/soc/soc_caps.h b/components/soc/esp32s2/include/soc/soc_caps.h index aa5bf0be76..9a36a8c60c 100644 --- a/components/soc/esp32s2/include/soc/soc_caps.h +++ b/components/soc/esp32s2/include/soc/soc_caps.h @@ -269,6 +269,7 @@ #define SOC_SYSTIMER_BIT_WIDTH_HI (32) // Bit width of systimer high part /*-------------------------- TIMER GROUP CAPS --------------------------------*/ +#define SOC_SYSTIMER_SUPPORTED 1 #define SOC_TIMER_GROUPS (2) #define SOC_TIMER_GROUP_TIMERS_PER_GROUP (2) #define SOC_TIMER_GROUP_COUNTER_BIT_WIDTH (64) diff --git a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in index 01078f8bd8..dace7b6c1b 100644 --- a/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in +++ b/components/soc/esp32s3/include/soc/Kconfig.soc_caps.in @@ -651,7 +651,7 @@ config SOC_SPIRAM_SUPPORTED bool default y -config SOC_TOUCH_VERSION_2 +config SOC_SYSTIMER_SUPPORTED bool default y @@ -707,6 +707,10 @@ config SOC_TIMER_GROUP_TOTAL_TIMERS int default 4 +config SOC_TOUCH_VERSION_2 + bool + default y + config SOC_TOUCH_SENSOR_NUM int default 15 diff --git a/components/soc/esp32s3/include/soc/soc_caps.h b/components/soc/esp32s3/include/soc/soc_caps.h index c1f40c899d..9207011d4f 100644 --- a/components/soc/esp32s3/include/soc/soc_caps.h +++ b/components/soc/esp32s3/include/soc/soc_caps.h @@ -271,7 +271,7 @@ #define SOC_SPIRAM_SUPPORTED 1 /*-------------------------- SYS TIMER CAPS ----------------------------------*/ -#define SOC_TOUCH_VERSION_2 (1) // Hardware version of touch sensor +#define SOC_SYSTIMER_SUPPORTED 1 #define SOC_SYSTIMER_COUNTER_NUM (2) // Number of counter units #define SOC_SYSTIMER_ALARM_NUM (3) // Number of alarm units #define SOC_SYSTIMER_BIT_WIDTH_LO (32) // Bit width of systimer low part @@ -289,6 +289,7 @@ #define SOC_TIMER_GROUP_TOTAL_TIMERS (4) /*-------------------------- TOUCH SENSOR CAPS -------------------------------*/ +#define SOC_TOUCH_VERSION_2 (1) // Hardware version of touch sensor #define SOC_TOUCH_SENSOR_NUM (15) /*! 15 Touch channels */ #define SOC_TOUCH_PROXIMITY_CHANNEL_NUM (3) /* Sopport touch proximity channel number. */ #define SOC_TOUCH_PROXIMITY_MEAS_DONE_SUPPORTED (1) /*Sopport touch proximity channel measure done interrupt type. */