Bladeren bron

hal: use systimer HAL IMPL in ESP32C2 ROM

wuzhenghui 3 jaren geleden
bovenliggende
commit
17b3d139d5

+ 6 - 5
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()

+ 16 - 0
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

+ 2 - 1
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:

+ 1 - 1
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
  */

+ 4 - 0
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

+ 1 - 0
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

+ 4 - 0
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

+ 1 - 0
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

+ 4 - 0
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

+ 1 - 0
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

+ 4 - 0
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

+ 1 - 0
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)

+ 5 - 1
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

+ 2 - 1
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. */