CMakeLists.txt 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. idf_build_get_property(target IDF_TARGET)
  2. set(srcs "hal_utils.c")
  3. set(includes "platform_port/include")
  4. # target specific include must be added before the generic one
  5. # becuase of the "include_next" directive used by the efuse_hal.h
  6. if(NOT ${target} STREQUAL "linux")
  7. list(APPEND includes "${target}/include")
  8. endif()
  9. list(APPEND includes "include")
  10. if(CONFIG_SOC_MPU_SUPPORTED)
  11. list(APPEND srcs "mpu_hal.c")
  12. endif()
  13. if(CONFIG_SOC_EFUSE_SUPPORTED)
  14. list(APPEND srcs "efuse_hal.c" "${target}/efuse_hal.c")
  15. endif()
  16. if(CONFIG_SOC_LP_TIMER_SUPPORTED)
  17. list(APPEND srcs "lp_timer_hal.c")
  18. endif()
  19. if(CONFIG_SOC_WDT_SUPPORTED AND NOT CONFIG_HAL_WDT_USE_ROM_IMPL)
  20. list(APPEND srcs "wdt_hal_iram.c")
  21. endif()
  22. if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  23. if(CONFIG_SOC_MMU_PERIPH_NUM)
  24. list(APPEND srcs "mmu_hal.c")
  25. endif()
  26. # We wrap Cache ROM APIs as Cache HAL APIs for: 1. internal ram ; 2. unified APIs
  27. # ESP32 cache structure / ROM APIs are different and we have a patch `cache_hal_esp32.c` for it.
  28. if(${target} STREQUAL "esp32")
  29. list(APPEND srcs "esp32/cache_hal_esp32.c")
  30. elseif(NOT ${target} STREQUAL "linux")
  31. list(APPEND srcs "cache_hal.c")
  32. endif()
  33. endif()
  34. if(NOT BOOTLOADER_BUILD)
  35. if(NOT CONFIG_APP_BUILD_TYPE_PURE_RAM_APP)
  36. if(CONFIG_SOC_SPI_FLASH_SUPPORTED)
  37. list(APPEND srcs "spi_flash_hal.c" "spi_flash_hal_iram.c")
  38. endif()
  39. if(CONFIG_SOC_FLASH_ENC_SUPPORTED)
  40. list(APPEND srcs "spi_flash_encrypt_hal_iram.c")
  41. endif()
  42. endif()
  43. if(CONFIG_SOC_CLK_TREE_SUPPORTED)
  44. list(APPEND srcs "${target}/clk_tree_hal.c")
  45. endif()
  46. if(CONFIG_SOC_SYSTIMER_SUPPORTED AND NOT CONFIG_HAL_SYSTIMER_USE_ROM_IMPL)
  47. list(APPEND srcs "systimer_hal.c")
  48. endif()
  49. if(CONFIG_SOC_UART_SUPPORTED)
  50. list(APPEND srcs "uart_hal.c" "uart_hal_iram.c")
  51. endif()
  52. if(CONFIG_SOC_GPIO_PORT)
  53. list(APPEND srcs "gpio_hal.c")
  54. endif()
  55. if(CONFIG_SOC_RTCIO_PIN_COUNT)
  56. list(APPEND srcs "rtc_io_hal.c")
  57. endif()
  58. if(CONFIG_SOC_GPTIMER_SUPPORTED)
  59. list(APPEND srcs "timer_hal.c")
  60. endif()
  61. if(CONFIG_SOC_LEDC_SUPPORTED)
  62. list(APPEND srcs "ledc_hal.c" "ledc_hal_iram.c")
  63. endif()
  64. if(CONFIG_SOC_I2C_SUPPORTED)
  65. list(APPEND srcs "i2c_hal.c" "i2c_hal_iram.c")
  66. endif()
  67. if(CONFIG_SOC_ISP_SUPPORTED)
  68. list(APPEND srcs "isp_hal.c")
  69. endif()
  70. if(CONFIG_SOC_RMT_SUPPORTED)
  71. list(APPEND srcs "rmt_hal.c")
  72. endif()
  73. if(CONFIG_SOC_PCNT_SUPPORTED)
  74. list(APPEND srcs "pcnt_hal.c")
  75. endif()
  76. if(CONFIG_SOC_MCPWM_SUPPORTED)
  77. list(APPEND srcs "mcpwm_hal.c")
  78. endif()
  79. if(CONFIG_SOC_TWAI_SUPPORTED)
  80. list(APPEND srcs "twai_hal.c" "twai_hal_iram.c")
  81. endif()
  82. if(CONFIG_SOC_GDMA_SUPPORTED)
  83. list(APPEND srcs "gdma_hal_top.c")
  84. endif()
  85. if(CONFIG_SOC_GDMA_SUPPORT_CRC)
  86. list(APPEND srcs "gdma_hal_crc_gen.c")
  87. endif()
  88. if(CONFIG_SOC_AHB_GDMA_VERSION EQUAL 1)
  89. list(APPEND srcs "gdma_hal_ahb_v1.c")
  90. endif()
  91. if(CONFIG_SOC_AHB_GDMA_VERSION EQUAL 2)
  92. list(APPEND srcs "gdma_hal_ahb_v2.c")
  93. endif()
  94. if(CONFIG_SOC_AXI_GDMA_SUPPORTED)
  95. list(APPEND srcs "gdma_hal_axi.c")
  96. endif()
  97. if(CONFIG_SOC_DW_GDMA_SUPPORTED)
  98. list(APPEND srcs "dw_gdma_hal.c")
  99. endif()
  100. if(CONFIG_SOC_I2S_SUPPORTED)
  101. list(APPEND srcs "i2s_hal.c")
  102. endif()
  103. if(CONFIG_SOC_SDM_SUPPORTED)
  104. list(APPEND srcs "sdm_hal.c")
  105. endif()
  106. if(CONFIG_SOC_SDMMC_HOST_SUPPORTED)
  107. list(APPEND srcs "sdmmc_hal.c")
  108. endif()
  109. if(CONFIG_ETH_USE_ESP32_EMAC)
  110. list(APPEND srcs "emac_hal.c")
  111. endif()
  112. if(CONFIG_SOC_ETM_SUPPORTED)
  113. list(APPEND srcs "etm_hal.c")
  114. endif()
  115. if(CONFIG_SOC_PARLIO_SUPPORTED)
  116. list(APPEND srcs "parlio_hal.c")
  117. endif()
  118. if(CONFIG_SOC_ADC_SUPPORTED)
  119. list(APPEND srcs "adc_hal_common.c" "adc_oneshot_hal.c")
  120. endif()
  121. if(CONFIG_SOC_ADC_DMA_SUPPORTED)
  122. list(APPEND srcs "adc_hal.c")
  123. endif()
  124. if(CONFIG_SOC_LCDCAM_SUPPORTED)
  125. list(APPEND srcs "lcd_hal.c")
  126. endif()
  127. if(CONFIG_SOC_ECC_SUPPORTED)
  128. list(APPEND srcs "ecc_hal.c")
  129. endif()
  130. if(CONFIG_SOC_ECDSA_SUPPORTED)
  131. list(APPEND srcs "ecdsa_hal.c")
  132. endif()
  133. if(CONFIG_SOC_MPI_SUPPORTED)
  134. list(APPEND srcs "mpi_hal.c")
  135. endif()
  136. if(CONFIG_SOC_SHA_SUPPORTED)
  137. list(APPEND srcs "sha_hal.c")
  138. endif()
  139. if(CONFIG_SOC_AES_SUPPORTED)
  140. list(APPEND srcs "aes_hal.c")
  141. endif()
  142. if(CONFIG_SOC_MODEM_CLOCK_IS_INDEPENDENT)
  143. list(APPEND srcs "${target}/modem_clock_hal.c")
  144. endif()
  145. if(CONFIG_SOC_PAU_SUPPORTED)
  146. list(APPEND srcs "${target}/pau_hal.c")
  147. endif()
  148. if(CONFIG_SOC_BOD_SUPPORTED)
  149. list(APPEND srcs "brownout_hal.c")
  150. endif()
  151. if(CONFIG_SOC_GPSPI_SUPPORTED)
  152. list(APPEND srcs
  153. "spi_hal.c"
  154. "spi_hal_iram.c"
  155. "spi_slave_hal.c"
  156. "spi_slave_hal_iram.c")
  157. endif()
  158. if(CONFIG_SOC_SPI_SUPPORT_SLAVE_HD_VER2)
  159. list(APPEND srcs "spi_slave_hd_hal.c")
  160. endif()
  161. if(CONFIG_SOC_GPSPI_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32)
  162. list(APPEND srcs "spi_flash_hal_gpspi.c")
  163. endif()
  164. if(CONFIG_SOC_SDIO_SLAVE_SUPPORTED)
  165. list(APPEND srcs "sdio_slave_hal.c")
  166. endif()
  167. if(CONFIG_SOC_PMU_SUPPORTED)
  168. list(APPEND srcs "${target}/pmu_hal.c")
  169. endif()
  170. if(CONFIG_SOC_APM_SUPPORTED)
  171. list(APPEND srcs "apm_hal.c")
  172. endif()
  173. if(CONFIG_SOC_HMAC_SUPPORTED AND NOT CONFIG_IDF_TARGET_ESP32S2)
  174. # For ESP32-S2 we do not have HMAC HAL layer implementation yet
  175. list(APPEND srcs "hmac_hal.c")
  176. endif()
  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. if(CONFIG_SOC_KEY_MANAGER_SUPPORTED)
  182. list(APPEND srcs "key_mgr_hal.c")
  183. list(APPEND srcs "huk_hal.c")
  184. endif()
  185. if(${target} STREQUAL "esp32")
  186. list(APPEND srcs
  187. "touch_sensor_hal.c"
  188. "esp32/touch_sensor_hal.c"
  189. "esp32/gpio_hal_workaround.c")
  190. endif()
  191. if(${target} STREQUAL "esp32s2")
  192. list(APPEND srcs
  193. "touch_sensor_hal.c"
  194. "usb_hal.c"
  195. "usb_phy_hal.c"
  196. "xt_wdt_hal.c"
  197. "esp32s2/cp_dma_hal.c"
  198. "esp32s2/touch_sensor_hal.c"
  199. "usb_dwc_hal.c")
  200. endif()
  201. if(${target} STREQUAL "esp32s3")
  202. list(APPEND srcs
  203. "touch_sensor_hal.c"
  204. "usb_hal.c"
  205. "usb_phy_hal.c"
  206. "xt_wdt_hal.c"
  207. "esp32s3/touch_sensor_hal.c"
  208. "esp32s3/rtc_cntl_hal.c"
  209. "usb_dwc_hal.c")
  210. endif()
  211. if(${target} STREQUAL "esp32c3")
  212. list(APPEND srcs
  213. "xt_wdt_hal.c"
  214. "esp32c3/rtc_cntl_hal.c")
  215. endif()
  216. if(${target} STREQUAL "esp32c2")
  217. list(APPEND srcs
  218. "esp32c2/rtc_cntl_hal.c")
  219. endif()
  220. if(${target} STREQUAL "esp32h2")
  221. list(REMOVE_ITEM srcs
  222. "esp32h2/rtc_cntl_hal.c"
  223. )
  224. endif()
  225. endif()
  226. idf_component_register(SRCS ${srcs}
  227. INCLUDE_DIRS ${includes}
  228. PRIV_INCLUDE_DIRS ${priv_include}
  229. REQUIRES soc esp_rom
  230. LDFRAGMENTS linker.lf)
  231. if(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 1)
  232. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u abort")
  233. elseif(CONFIG_HAL_DEFAULT_ASSERTION_LEVEL EQUAL 2)
  234. target_link_libraries(${COMPONENT_LIB} INTERFACE "-u __assert_func")
  235. endif()