You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

219 lines
5.7 KiB

  1. include(cortex-m7)
  2. include(stm32h7-usb)
  3. set(STM32H7_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32H7/Drivers/CMSIS/Device/ST/STM32H7xx")
  4. set(STM32H7_HAL_DIR "${MAIN_LIB_DIR}/main/STM32H7/Drivers/STM32H7xx_HAL_Driver")
  5. set(STM32H7_HAL_SRC
  6. stm32h7xx_hal.c
  7. stm32h7xx_hal_adc.c
  8. stm32h7xx_hal_adc_ex.c
  9. # stm32h7xx_hal_cec.c
  10. # stm32h7xx_hal_comp.c
  11. stm32h7xx_hal_cortex.c
  12. # stm32h7xx_hal_crc.c
  13. # stm32h7xx_hal_crc_ex.c
  14. # stm32h7xx_hal_cryp.c
  15. # stm32h7xx_hal_cryp_ex.c
  16. stm32h7xx_hal_dac.c
  17. stm32h7xx_hal_dac_ex.c
  18. # stm32h7xx_hal_dcmi.c
  19. # stm32h7xx_hal_dfsdm.c
  20. # stm32h7xx_hal_dfsdm_ex.c
  21. stm32h7xx_hal_dma.c
  22. # stm32h7xx_hal_dma2d.c
  23. stm32h7xx_hal_dma_ex.c
  24. # stm32h7xx_hal_dsi.c
  25. stm32h7xx_hal_dts.c
  26. # stm32h7xx_hal_eth.c
  27. # stm32h7xx_hal_eth_ex.c
  28. stm32h7xx_hal_exti.c
  29. # stm32h7xx_hal_fdcan.c
  30. stm32h7xx_hal_flash.c
  31. stm32h7xx_hal_flash_ex.c
  32. stm32h7xx_hal_gfxmmu.c
  33. stm32h7xx_hal_gpio.c
  34. # stm32h7xx_hal_hash.c
  35. # stm32h7xx_hal_hash_ex.c
  36. # stm32h7xx_hal_hcd.c
  37. # stm32h7xx_hal_hrtim.c
  38. # stm32h7xx_hal_hsem.c
  39. stm32h7xx_hal_i2c.c
  40. stm32h7xx_hal_i2c_ex.c
  41. # stm32h7xx_hal_i2s.c
  42. # stm32h7xx_hal_i2s_ex.c
  43. # stm32h7xx_hal_irda.c
  44. # stm32h7xx_hal_iwdg.c
  45. # stm32h7xx_hal_jpeg.c
  46. # stm32h7xx_hal_lptim.c
  47. # stm32h7xx_hal_ltdc.c
  48. # stm32h7xx_hal_ltdc_ex.c
  49. # stm32h7xx_hal_mdios.c
  50. # stm32h7xx_hal_mdma.c
  51. # stm32h7xx_hal_mmc.c
  52. # stm32h7xx_hal_mmc_ex.c
  53. # stm32h7xx_hal_nand.c
  54. # stm32h7xx_hal_nor.c
  55. # stm32h7xx_hal_opamp.c
  56. # stm32h7xx_hal_opamp_ex.c
  57. stm32h7xx_hal_ospi.c
  58. stm32h7xx_hal_otfdec.c
  59. stm32h7xx_hal_pcd.c
  60. stm32h7xx_hal_pcd_ex.c
  61. stm32h7xx_hal_pssi.c
  62. stm32h7xx_hal_pwr.c
  63. stm32h7xx_hal_pwr_ex.c
  64. stm32h7xx_hal_qspi.c
  65. # stm32h7xx_hal_ramecc.c
  66. stm32h7xx_hal_rcc.c
  67. stm32h7xx_hal_rcc_ex.c
  68. # stm32h7xx_hal_rng.c
  69. # stm32h7xx_hal_rng_ex.c
  70. stm32h7xx_hal_rtc.c
  71. stm32h7xx_hal_rtc_ex.c
  72. # stm32h7xx_hal_sai.c
  73. # stm32h7xx_hal_sai_ex.c
  74. stm32h7xx_hal_sd.c
  75. stm32h7xx_hal_sd_ex.c
  76. # stm32h7xx_hal_sdram.c
  77. # stm32h7xx_hal_smartcard.c
  78. # stm32h7xx_hal_smartcard_ex.c
  79. # stm32h7xx_hal_smbus.c
  80. # stm32h7xx_hal_spdifrx.c
  81. stm32h7xx_hal_spi.c
  82. stm32h7xx_hal_spi_ex.c
  83. # stm32h7xx_hal_sram.c
  84. # stm32h7xx_hal_swpmi.c
  85. stm32h7xx_hal_tim.c
  86. stm32h7xx_hal_tim_ex.c
  87. stm32h7xx_hal_uart.c
  88. stm32h7xx_hal_uart_ex.c
  89. # stm32h7xx_hal_usart.c
  90. # stm32h7xx_hal_usart_ex.c
  91. # stm32h7xx_hal_wwdg.c
  92. # stm32h7xx_ll_adc.c
  93. # stm32h7xx_ll_bdma.c
  94. # stm32h7xx_ll_comp.c
  95. # stm32h7xx_ll_crc.c
  96. stm32h7xx_ll_crs.c
  97. # stm32h7xx_ll_dac.c
  98. # stm32h7xx_ll_delayblock.c
  99. stm32h7xx_ll_dma.c
  100. # stm32h7xx_ll_dma2d.c
  101. stm32h7xx_ll_exti.c
  102. # stm32h7xx_ll_fmc.c
  103. # stm32h7xx_ll_gpio.c
  104. # stm32h7xx_ll_hrtim.c
  105. stm32h7xx_ll_i2c.c
  106. # stm32h7xx_ll_lptim.c
  107. # stm32h7xx_ll_lpuart.c
  108. # stm32h7xx_ll_mdma.c
  109. # stm32h7xx_ll_opamp.c
  110. # stm32h7xx_ll_pwr.c
  111. # stm32h7xx_ll_rcc.c
  112. # stm32h7xx_ll_rng.c
  113. # stm32h7xx_ll_rtc.c
  114. stm32h7xx_ll_sdmmc.c
  115. # stm32h7xx_ll_spi.c
  116. # stm32h7xx_ll_swpmi.c
  117. stm32h7xx_ll_tim.c
  118. # stm32h7xx_ll_usart.c
  119. stm32h7xx_ll_usb.c
  120. # stm32h7xx_ll_utils.c
  121. )
  122. list(TRANSFORM STM32H7_HAL_SRC PREPEND "${STM32H7_HAL_DIR}/Src/")
  123. set(STM32H7_VCP_DIR "${MAIN_SRC_DIR}/vcp_hal")
  124. set(STM32H7_VCP_SRC
  125. usbd_desc.c
  126. usbd_conf_stm32h7xx.c
  127. usbd_cdc_interface.c
  128. )
  129. list(TRANSFORM STM32H7_VCP_SRC PREPEND "${STM32H7_VCP_DIR}/")
  130. set(STM32H7_INCLUDE_DIRS
  131. ${STM32H7_HAL_DIR}/Inc
  132. ${STM32H7_CMSIS_DEVICE_DIR}/Include
  133. )
  134. main_sources(STM32H7_SRC
  135. target/system_stm32h7xx.c
  136. config/config_streamer_stm32h7.c
  137. drivers/adc_stm32h7xx.c
  138. drivers/bus_i2c_hal.c
  139. drivers/dma_stm32h7xx.c
  140. drivers/bus_spi_hal.c
  141. drivers/memprot.h
  142. drivers/memprot_hal.c
  143. drivers/memprot_stm32h7xx.c
  144. drivers/timer.c
  145. drivers/timer_impl_hal.c
  146. drivers/timer_stm32h7xx.c
  147. drivers/system_stm32h7xx.c
  148. drivers/serial_uart_stm32h7xx.c
  149. drivers/serial_uart_hal.c
  150. # drivers/sdcard/sdmmc_sdio_h7xx.c
  151. )
  152. main_sources(STM32H7_MSC_SRC
  153. drivers/usb_msc_h7xx.c
  154. )
  155. set(STM32H7_DEFINITIONS
  156. ${CORTEX_M7_DEFINITIONS}
  157. USE_HAL_DRIVER
  158. USE_FULL_LL_DRIVER
  159. MAX_MPU_REGIONS=16
  160. )
  161. function(target_stm32h7xx)
  162. target_stm32(
  163. SOURCES ${STM32H7_HAL_SRC} ${STM32H7_SRC}
  164. COMPILE_DEFINITIONS ${STM32H7_DEFINITIONS}
  165. COMPILE_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_COMPILE_OPTIONS}
  166. INCLUDE_DIRECTORIES ${STM32H7_INCLUDE_DIRS}
  167. LINK_OPTIONS ${CORTEX_M7_COMMON_OPTIONS} ${CORTEX_M7_LINK_OPTIONS}
  168. MSC_SOURCES ${STM32H7_USBMSC_SRC} ${STM32H7_MSC_SRC}
  169. VCP_SOURCES ${STM32H7_USB_SRC} ${STM32H7_VCP_SRC}
  170. VCP_INCLUDE_DIRECTORIES ${STM32H7_USB_INCLUDE_DIRS} ${STM32H7_VCP_DIR}
  171. OPTIMIZATION -O2
  172. OPENOCD_TARGET stm32h7x
  173. DISABLE_MSC # This should be temporary
  174. # BOOTLOADER
  175. ${ARGN}
  176. )
  177. endfunction()
  178. macro(define_target_stm32h7 subfamily size)
  179. function(target_stm32h7${subfamily}x${size} name)
  180. set(func_ARGV ARGV)
  181. string(TOUPPER ${size} upper_size)
  182. get_stm32_flash_size(flash_size ${size})
  183. set(definitions
  184. STM32H7
  185. STM32H7${subfamily}xx
  186. STM32H7${subfamily}x${upper_size}
  187. # stm32h743xx.h defined FLASH_SIZE, used by HAL, but in bytes
  188. # use MCU_FLASH_SIZE since we use KiB in our code
  189. MCU_FLASH_SIZE=${flash_size}
  190. )
  191. target_stm32h7xx(
  192. NAME ${name}
  193. STARTUP startup_stm32h7${subfamily}xx.s
  194. COMPILE_DEFINITIONS ${definitions}
  195. LINKER_SCRIPT stm32_flash_h7${subfamily}x${size}
  196. ${${func_ARGV}}
  197. )
  198. endfunction()
  199. endmacro()
  200. define_target_stm32h7(43 i)