1idf_build_get_property(target IDF_TARGET) 2 3# On Linux, there is currently no HAL, hence this simple component registration 4if(${target} STREQUAL "linux") 5 idf_component_register() 6 return() 7endif() 8 9set(srcs "mpu_hal.c" 10 "efuse_hal.c" 11 "${target}/efuse_hal.c") 12 13 14set(includes "${target}/include" "include" "platform_port/include") 15 16if(NOT CONFIG_HAL_WDT_USE_ROM_IMPL) 17 list(APPEND srcs "wdt_hal_iram.c") 18endif() 19 20if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) 21 list(APPEND srcs "mmu_hal.c") 22 23 # We wrap Cache ROM APIs as Cache HAL APIs for: 1. internal ram ; 2. unified APIs 24 # ESP32 cache structure / ROM APIs are different and we have a patch `cache_hal_esp32.c` for it. 25 if(${target} STREQUAL "esp32") 26 list(APPEND srcs "esp32/cache_hal_esp32.c") 27 else() 28 list(APPEND srcs "cache_hal.c") 29 endif() 30endif() 31 32if(CONFIG_SOC_LP_TIMER_SUPPORTED) 33 list(APPEND srcs "lp_timer_hal.c") 34endif() 35 36if(NOT BOOTLOADER_BUILD) 37 list(APPEND srcs 38 "rtc_io_hal.c" 39 "gpio_hal.c" 40 "uart_hal.c" 41 "uart_hal_iram.c" 42 "adc_hal_common.c" 43 "adc_oneshot_hal.c" 44 "${target}/clk_tree_hal.c") 45 46 if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP) 47 list(APPEND srcs 48 "spi_flash_hal.c" 49 "spi_flash_hal_iram.c" 50 ) 51 if(CONFIG_SOC_FLASH_ENC_SUPPORTED) 52 list(APPEND srcs "spi_flash_encrypt_hal_iram.c") 53 endif() 54 endif() 55 56 if(CONFIG_SOC_SYSTIMER_SUPPORTED AND NOT CONFIG_HAL_SYSTIMER_USE_ROM_IMPL) 57 list(APPEND srcs "systimer_hal.c") 58 endif() 59 60 if(CONFIG_SOC_GPTIMER_SUPPORTED) 61 list(APPEND srcs "timer_hal.c") 62 endif() 63 64 if(CONFIG_SOC_LEDC_SUPPORTED) 65 list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c") 66 endif() 67 68 if(CONFIG_SOC_I2C_SUPPORTED) 69 list(APPEND srcs "i2c_hal.c" "i2c_hal_iram.c") 70 endif() 71 72 if(CONFIG_SOC_RMT_SUPPORTED) 73 list(APPEND srcs "rmt_hal.c") 74 endif() 75 76 if(CONFIG_SOC_PCNT_SUPPORTED) 77 list(APPEND srcs "pcnt_hal.c") 78 endif() 79 80 if(CONFIG_SOC_MCPWM_SUPPORTED) 81 list(APPEND srcs "mcpwm_hal.c") 82 endif() 83 84 if(CONFIG_SOC_TWAI_SUPPORTED) 85 list(APPEND srcs "twai_hal.c" "twai_hal_iram.c") 86 endif() 87 88 if(CONFIG_SOC_GDMA_SUPPORTED) 89 list(APPEND srcs "gdma_hal.c") 90 endif() 91 92 if(CONFIG_SOC_I2S_SUPPORTED) 93 list(APPEND srcs "i2s_hal.c") 94 endif() 95 96 if(CONFIG_SOC_SDM_SUPPORTED) 97 list(APPEND srcs "sdm_hal.c") 98 endif() 99 100 if(CONFIG_ETH_USE_ESP32_EMAC) 101 list(APPEND srcs "emac_hal.c") 102 endif() 103 104 if(CONFIG_SOC_ETM_SUPPORTED) 105 list(APPEND srcs "etm_hal.c") 106 endif() 107 108 if(CONFIG_SOC_PARLIO_SUPPORTED) 109 list(APPEND srcs "parlio_hal.c") 110 endif() 111 112 if(CONFIG_SOC_ADC_DMA_SUPPORTED) 113 list(APPEND srcs "adc_hal.c") 114 endif() 115 116 if(CONFIG_SOC_LCDCAM_SUPPORTED) 117 list(APPEND srcs "lcd_hal.c") 118 endif() 119 120 if(CONFIG_SOC_ECC_SUPPORTED) 121 list(APPEND srcs "ecc_hal.c") 122 endif() 123 124 if(CONFIG_SOC_ECDSA_SUPPORTED) 125 list(APPEND srcs "ecdsa_hal.c") 126 endif() 127 128 if(CONFIG_SOC_SHA_SUPPORTED) 129 list(APPEND srcs "sha_hal.c") 130 endif() 131 132 if(CONFIG_SOC_AES_SUPPORTED) 133 list(APPEND srcs "aes_hal.c") 134 endif() 135 136 if(CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT) 137 list(APPEND srcs "${target}/modem_clock_hal.c") 138 endif() 139 140 if(CONFIG_SOC_PAU_SUPPORTED) 141 list(APPEND srcs "${target}/pau_hal.c") 142 endif() 143 144 if(CONFIG_SOC_BOD_SUPPORTED) 145 list(APPEND srcs "brownout_hal.c") 146 endif() 147 148 if(CONFIG_SOC_GPSPI_SUPPORTED) 149 list(APPEND srcs 150 "spi_hal.c" 151 "spi_hal_iram.c" 152 "spi_slave_hal.c" 153 "spi_slave_hal_iram.c") 154 endif() 155 156 if(CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2) 157 list(APPEND srcs "spi_slave_hd_hal.c") 158 endif() 159 160 if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED) 161 list(APPEND srcs "sdio_slave_hal.c") 162 endif() 163 164 if(CONFIG_SOC_PMU_SUPPORTED) 165 list(APPEND srcs "${target}/pmu_hal.c") 166 endif() 167 168 if(CONFIG_SOC_APM_SUPPORTED) 169 list(APPEND srcs "apm_hal.c") 170 endif() 171 172 if(CONFIG_SOC_HMAC_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2) 173 # For ESP32-S2 we do not have HMAC HAL layer implementation yet 174 list(APPEND srcs "hmac_hal.c") 175 endif() 176 177 if(CONFIG_SOC_DIG_SIGN_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2) 178 # For ESP32-S2 we do not have DS HAL layer implementation yet 179 list(APPEND srcs "ds_hal.c") 180 endif() 181 182 if(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED) 183 list(APPEND srcs "usb_serial_jtag_hal.c") 184 endif() 185 186 if(CONFIG_SOC_USB_OTG_SUPPORTED) 187 list(APPEND srcs 188 "usb_dwc_hal.c" 189 "usb_wrap_hal.c") 190 endif() 191 192 if(${target} STREQUAL "esp32") 193 list(APPEND srcs 194 "touch_sensor_hal.c" 195 "esp32/touch_sensor_hal.c" 196 "esp32/gpio_hal_workaround.c") 197 endif() 198 199 if(${target} STREQUAL "esp32s2") 200 list(APPEND srcs 201 "spi_flash_hal_gpspi.c" 202 "touch_sensor_hal.c" 203 "xt_wdt_hal.c" 204 "esp32s2/cp_dma_hal.c" 205 "esp32s2/touch_sensor_hal.c") 206 endif() 207 208 if(${target} STREQUAL "esp32s3") 209 list(APPEND srcs 210 "spi_flash_hal_gpspi.c" 211 "touch_sensor_hal.c" 212 "xt_wdt_hal.c" 213 "esp32s3/touch_sensor_hal.c" 214 "esp32s3/rtc_cntl_hal.c") 215 endif() 216 217 if(${target} STREQUAL "esp32c3") 218 list(APPEND srcs 219 "spi_flash_hal_gpspi.c" 220 "xt_wdt_hal.c" 221 "esp32c3/rtc_cntl_hal.c") 222 endif() 223 224 if(${target} STREQUAL "esp32c2") 225 list(APPEND srcs 226 "spi_flash_hal_gpspi.c" 227 "esp32c2/rtc_cntl_hal.c") 228 endif() 229 230 if(${target} STREQUAL "esp32c6") 231 list(APPEND srcs 232 "spi_flash_hal_gpspi.c") 233 234 endif() 235 236 if(${target} STREQUAL "esp32h2") 237 list(APPEND srcs 238 "spi_flash_hal_gpspi.c" 239 ) 240 241 list(REMOVE_ITEM srcs 242 "esp32h2/rtc_cntl_hal.c" 243 ) 244 endif() 245endif() 246 247idf_component_register(SRCS ${srcs} 248 INCLUDE_DIRS ${includes} 249 PRIV_INCLUDE_DIRS ${priv_include} 250 REQUIRES soc esp_rom 251 LDFRAGMENTS linker.lf) 252target_compile_options(${COMPONENT_LIB} PRIVATE "-Wno-format") 253 254if(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 1) 255 target_link_libraries(${COMPONENT_LIB} INTERFACE "-u abort") 256elseif(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 2) 257 target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __assert_func") 258endif() 259