FindSTM32HAL.cmake 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244
  1. IF(STM32_FAMILY STREQUAL "F1")
  2. SET(STDPERIPH_HEADERS
  3. stm32f10x_adc.h
  4. stm32f10x_bkp.h
  5. stm32f10x_can.h
  6. stm32f10x_cec.h
  7. stm32f10x_crc.h
  8. stm32f10x_dac.h
  9. stm32f10x_dbgmcu.h
  10. stm32f10x_dma.h
  11. stm32f10x_exti.h
  12. stm32f10x_flash.h
  13. stm32f10x_fsmc.h
  14. stm32f10x_gpio.h
  15. stm32f10x_i2c.h
  16. stm32f10x_iwdg.h
  17. stm32f10x_pwr.h
  18. stm32f10x_rcc.h
  19. stm32f10x_rtc.h
  20. stm32f10x_sdio.h
  21. stm32f10x_spi.h
  22. stm32f10x_tim.h
  23. stm32f10x_usart.h
  24. stm32f10x_wwdg.h
  25. stm32f10x_misc.h
  26. )
  27. SET(STDPERIPH_SRCS
  28. misc.c
  29. stm32f10x_adc.c
  30. stm32f10x_bkp.c
  31. stm32f10x_can.c
  32. stm32f10x_cec.c
  33. stm32f10x_crc.c
  34. stm32f10x_dac.c
  35. stm32f10x_dbgmcu.c
  36. stm32f10x_dma.c
  37. stm32f10x_exti.c
  38. stm32f10x_flash.c
  39. stm32f10x_fsmc.c
  40. stm32f10x_gpio.c
  41. stm32f10x_i2c.c
  42. stm32f10x_iwdg.c
  43. stm32f10x_pwr.c
  44. stm32f10x_rcc.c
  45. stm32f10x_rtc.c
  46. stm32f10x_sdio.c
  47. stm32f10x_spi.c
  48. stm32f10x_tim.c
  49. stm32f10x_usart.c
  50. stm32f10x_wwdg.c
  51. )
  52. ELSEIF(STM32_FAMILY STREQUAL "F4")
  53. SET(HAL_HEADERS
  54. stm32f4xx_hal.h
  55. stm32f4xx_hal_adc.h
  56. stm32f4xx_hal_adc_ex.h
  57. stm32f4xx_hal_can.h
  58. stm32f4xx_hal_cec.h
  59. stm32f4xx_hal_conf_template.h
  60. stm32f4xx_hal_cortex.h
  61. stm32f4xx_hal_crc.h
  62. stm32f4xx_hal_cryp.h
  63. stm32f4xx_hal_cryp_ex.h
  64. stm32f4xx_hal_dac.h
  65. stm32f4xx_hal_dac_ex.h
  66. stm32f4xx_hal_dcmi.h
  67. stm32f4xx_hal_dcmi_ex.h
  68. stm32f4xx_hal_def.h
  69. stm32f4xx_hal_dma.h
  70. stm32f4xx_hal_dma2d.h
  71. stm32f4xx_hal_dma_ex.h
  72. stm32f4xx_hal_eth.h
  73. stm32f4xx_hal_flash.h
  74. stm32f4xx_hal_flash_ex.h
  75. stm32f4xx_hal_flash_ramfunc.h
  76. stm32f4xx_hal_fmpi2c.h
  77. stm32f4xx_hal_fmpi2c_ex.h
  78. stm32f4xx_hal_gpio.h
  79. stm32f4xx_hal_gpio_ex.h
  80. stm32f4xx_hal_hash.h
  81. stm32f4xx_hal_hash_ex.h
  82. stm32f4xx_hal_hcd.h
  83. stm32f4xx_hal_i2c.h
  84. stm32f4xx_hal_i2c_ex.h
  85. stm32f4xx_hal_i2s.h
  86. stm32f4xx_hal_i2s_ex.h
  87. stm32f4xx_hal_irda.h
  88. stm32f4xx_hal_iwdg.h
  89. stm32f4xx_hal_ltdc.h
  90. stm32f4xx_hal_nand.h
  91. stm32f4xx_hal_nor.h
  92. stm32f4xx_hal_pccard.h
  93. stm32f4xx_hal_pcd.h
  94. stm32f4xx_hal_pcd_ex.h
  95. stm32f4xx_hal_pwr.h
  96. stm32f4xx_hal_pwr_ex.h
  97. stm32f4xx_hal_qspi.h
  98. stm32f4xx_hal_rcc.h
  99. stm32f4xx_hal_rcc_ex.h
  100. stm32f4xx_hal_rng.h
  101. stm32f4xx_hal_rtc.h
  102. stm32f4xx_hal_rtc_ex.h
  103. stm32f4xx_hal_sai.h
  104. stm32f4xx_hal_sai_ex.h
  105. stm32f4xx_hal_sd.h
  106. stm32f4xx_hal_sdram.h
  107. stm32f4xx_hal_smartcard.h
  108. stm32f4xx_hal_spdifrx.h
  109. stm32f4xx_hal_spi.h
  110. stm32f4xx_hal_sram.h
  111. stm32f4xx_hal_tim.h
  112. stm32f4xx_hal_tim_ex.h
  113. stm32f4xx_hal_uart.h
  114. stm32f4xx_hal_usart.h
  115. stm32f4xx_hal_wwdg.h
  116. stm32f4xx_ll_fmc.h
  117. stm32f4xx_ll_fsmc.h
  118. stm32f4xx_ll_sdmmc.h
  119. stm32f4xx_ll_usb.h
  120. )
  121. SET(HAL_SRCS
  122. stm32f4xx_hal.c
  123. stm32f4xx_hal_adc.c
  124. stm32f4xx_hal_adc_ex.c
  125. stm32f4xx_hal_can.c
  126. stm32f4xx_hal_cec.c
  127. stm32f4xx_hal_cortex.c
  128. stm32f4xx_hal_crc.c
  129. stm32f4xx_hal_cryp.c
  130. stm32f4xx_hal_cryp_ex.c
  131. stm32f4xx_hal_dac.c
  132. stm32f4xx_hal_dac_ex.c
  133. stm32f4xx_hal_dcmi.c
  134. stm32f4xx_hal_dcmi_ex.c
  135. stm32f4xx_hal_dma.c
  136. stm32f4xx_hal_dma2d.c
  137. stm32f4xx_hal_dma_ex.c
  138. stm32f4xx_hal_eth.c
  139. stm32f4xx_hal_flash.c
  140. stm32f4xx_hal_flash_ex.c
  141. stm32f4xx_hal_flash_ramfunc.c
  142. stm32f4xx_hal_fmpi2c.c
  143. stm32f4xx_hal_fmpi2c_ex.c
  144. stm32f4xx_hal_gpio.c
  145. stm32f4xx_hal_hash.c
  146. stm32f4xx_hal_hash_ex.c
  147. stm32f4xx_hal_hcd.c
  148. stm32f4xx_hal_i2c.c
  149. stm32f4xx_hal_i2c_ex.c
  150. stm32f4xx_hal_i2s.c
  151. stm32f4xx_hal_i2s_ex.c
  152. stm32f4xx_hal_irda.c
  153. stm32f4xx_hal_iwdg.c
  154. stm32f4xx_hal_ltdc.c
  155. stm32f4xx_hal_msp_template.c
  156. stm32f4xx_hal_nand.c
  157. stm32f4xx_hal_nor.c
  158. stm32f4xx_hal_pccard.c
  159. stm32f4xx_hal_pcd.c
  160. stm32f4xx_hal_pcd_ex.c
  161. stm32f4xx_hal_pwr.c
  162. stm32f4xx_hal_pwr_ex.c
  163. stm32f4xx_hal_qspi.c
  164. stm32f4xx_hal_rcc.c
  165. stm32f4xx_hal_rcc_ex.c
  166. stm32f4xx_hal_rng.c
  167. stm32f4xx_hal_rtc.c
  168. stm32f4xx_hal_rtc_ex.c
  169. stm32f4xx_hal_sai.c
  170. stm32f4xx_hal_sai_ex.c
  171. stm32f4xx_hal_sd.c
  172. stm32f4xx_hal_sdram.c
  173. stm32f4xx_hal_smartcard.c
  174. stm32f4xx_hal_spdifrx.c
  175. stm32f4xx_hal_spi.c
  176. stm32f4xx_hal_sram.c
  177. stm32f4xx_hal_tim.c
  178. stm32f4xx_hal_tim_ex.c
  179. stm32f4xx_hal_uart.c
  180. stm32f4xx_hal_usart.c
  181. stm32f4xx_hal_wwdg.c
  182. stm32f4xx_ll_fmc.c
  183. stm32f4xx_ll_fsmc.c
  184. stm32f4xx_ll_sdmmc.c
  185. stm32f4xx_ll_usb.c
  186. )
  187. # SET(STDPERIPH_SRCS_40_41xxx
  188. # stm32f4xx_fsmc.c
  189. # )
  190. # SET(STDPERIPH_SRCS_427_437xx
  191. # stm32f4xx_fmc.c
  192. # )
  193. # SET(STDPERIPH_SRCS_429_439xx
  194. # stm32f4xx_fmc.c
  195. # )
  196. ENDIF()
  197. STRING(TOLOWER ${STM32_FAMILY} STM32_FAMILY_LOWER)
  198. FIND_PATH(STM32HAL_INCLUDE_DIR ${HAL_HEADERS}
  199. PATH_SUFFIXES include stm32${STM32_FAMILY_LOWER}
  200. )
  201. FOREACH(HAL_SRC ${HAL_SRCS})
  202. SET(HAL_SRC_FILE HAL_SRC_FILE-NOTFOUND)
  203. FIND_FILE(HAL_SRC_FILE NAMES ${HAL_SRC} PATHS ${CMAKE_FIND_ROOT_PATH} PATH_SUFFIXES share/stm32hal/${STM32_FAMILY_LOWER} stm32hal/${STM32_FAMILY_LOWER})
  204. LIST(APPEND STM32HAL_SOURCES ${HAL_SRC_FILE})
  205. ENDFOREACH()
  206. # IF(NOT STM32_CHIP_TYPE)
  207. # FOREACH(CHIP_TYPE ${STM32_CHIP_TYPES})
  208. # IF(STDPERIPH_SRCS_${CHIP_TYPE})
  209. # FOREACH(STDPERIPH_SRC ${STDPERIPH_SRCS_${CHIP_TYPE}})
  210. # SET(STDPERIPH_SRC_FILE STDPERIPH_SRC_FILE-NOTFOUND)
  211. # FIND_FILE(STDPERIPH_SRC_FILE NAMES ${STDPERIPH_SRC} PATHS ${CMAKE_FIND_ROOT_PATH} PATH_SUFFIXES share/stdperiph/stm32${STM32_FAMILY_LOWER} stdperiph/stm32${STM32_FAMILY_LOWER})
  212. # LIST(APPEND StdPeriphLib_SOURCES_${CHIP_TYPE} ${STDPERIPH_SRC_FILE})
  213. # LIST(APPEND STDPERIPH_SRCSRC StdPeriphLib_SOURCES_${CHIP_TYPE})
  214. # ENDFOREACH()
  215. # ENDIF()
  216. # ENDFOREACH()
  217. # ELSE()
  218. # IF(STDPERIPH_SRCS_${STM32_CHIP_TYPE})
  219. # FOREACH(STDPERIPH_SRC ${STDPERIPH_SRCS_${STM32_CHIP_TYPE}})
  220. # SET(STDPERIPH_SRC_FILE STDPERIPH_SRC_FILE-NOTFOUND)
  221. # FIND_FILE(STDPERIPH_SRC_FILE NAMES ${STDPERIPH_SRC} PATHS ${CMAKE_FIND_ROOT_PATH} PATH_SUFFIXES share/stdperiph/stm32${STM32_FAMILY_LOWER} stdperiph/stm32${STM32_FAMILY_LOWER})
  222. # LIST(APPEND StdPeriphLib_SOURCES ${STDPERIPH_SRC_FILE})
  223. # ENDFOREACH()
  224. # ENDIF()
  225. # ENDIF()
  226. # IF(STDPERIPH_USE_ASSERT)
  227. # ADD_DEFINITIONS("-D\"assert_param(expr)\"=\"((expr) ? (void)0 : assert_failed((uint8_t *)__FILE__, __LINE__))\"")
  228. # ELSE()
  229. # ADD_DEFINITIONS("-D\"assert_param(expr)\"=\"((void)0)\"")
  230. # ENDIF()
  231. INCLUDE(FindPackageHandleStandardArgs)
  232. FIND_PACKAGE_HANDLE_STANDARD_ARGS(STM32HAL DEFAULT_MSG STM32HAL_INCLUDE_DIR STM32HAL_SOURCES)
  233. #SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_STDPERIPH_DRIVER")
  234. #SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DUSE_STDPERIPH_DRIVER")