Fork from inav at github. Modified for some special functions needs.
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.

155 lines
4.0 KiB

  1. include(cortex-m4f)
  2. include(stm32-stdperiph)
  3. include(stm32f4-usb)
  4. set(STM32F4_STDPERIPH_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/STM32F4xx_StdPeriph_Driver")
  5. set(STM32F4_CMSIS_DEVICE_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/CMSIS/Device/ST/STM32F4xx")
  6. set(STM32F4_CMSIS_DRIVERS_DIR "${MAIN_LIB_DIR}/main/STM32F4/Drivers/CMSIS")
  7. set(STM32F4_VCP_DIR "${MAIN_SRC_DIR}/vcpf4")
  8. set(STM32F4_STDPERIPH_SRC_EXCLUDES
  9. stm32f4xx_can.c
  10. stm32f4xx_cec.c
  11. stm32f4xx_crc.c
  12. stm32f4xx_cryp.c
  13. stm32f4xx_cryp_aes.c
  14. stm32f4xx_cryp_des.c
  15. stm32f4xx_cryp_tdes.c
  16. stm32f4xx_dbgmcu.c
  17. stm32f4xx_dsi.c
  18. stm32f4xx_flash_ramfunc.c
  19. stm32f4xx_fmpi2c.c
  20. stm32f4xx_fmc.c
  21. stm32f4xx_hash.c
  22. stm32f4xx_hash_md5.c
  23. stm32f4xx_hash_sha1.c
  24. stm32f4xx_lptim.c
  25. stm32f4xx_qspi.c
  26. stm32f4xx_sai.c
  27. stm32f4xx_spdifrx.c
  28. )
  29. set(STM32F4_STDPERIPH_SRC_DIR "${STM32F4_STDPERIPH_DIR}/src")
  30. glob_except(STM32F4_STDPERIPH_SRC "${STM32F4_STDPERIPH_SRC_DIR}/*.c" "${STM32F4_STDPERIPH_SRC_EXCLUDES}")
  31. main_sources(STM32F4_SRC
  32. target/system_stm32f4xx.c
  33. config/config_streamer_stm32f4.c
  34. drivers/adc_stm32f4xx.c
  35. drivers/adc_stm32f4xx.c
  36. drivers/bus_i2c_stm32f40x.c
  37. drivers/serial_uart_stm32f4xx.c
  38. drivers/system_stm32f4xx.c
  39. drivers/timer.c
  40. drivers/timer_impl_stdperiph.c
  41. drivers/timer_stm32f4xx.c
  42. drivers/uart_inverter.c
  43. drivers/dma_stm32f4xx.c
  44. drivers/sdcard/sdmmc_sdio_f4xx.c
  45. )
  46. set(STM32F4_VCP_SRC
  47. stm32f4xx_it.c
  48. usb_bsp.c
  49. usbd_desc.c
  50. usbd_usr.c
  51. usbd_cdc_vcp.c
  52. )
  53. list(TRANSFORM STM32F4_VCP_SRC PREPEND "${STM32F4_VCP_DIR}/")
  54. main_sources(STM32F4_MSC_SRC
  55. drivers/usb_msc_f4xx.c
  56. )
  57. set(STM32F4_INCLUDE_DIRS
  58. "${CMSIS_INCLUDE_DIR}"
  59. "${CMSIS_DSP_INCLUDE_DIR}"
  60. "${STM32F4_STDPERIPH_DIR}/inc"
  61. "${STM32F4_CMSIS_DEVICE_DIR}"
  62. "${STM32F4_CMSIS_DRIVERS_DIR}"
  63. "${STM32F4_VCP_DIR}"
  64. )
  65. set(STM32F4_DEFINITIONS
  66. ${CORTEX_M4F_DEFINITIONS}
  67. STM32F4
  68. USE_STDPERIPH_DRIVER
  69. )
  70. function(target_stm32f4xx)
  71. target_stm32(
  72. SOURCES ${STM32_STDPERIPH_SRC} ${STM32F4_SRC}
  73. COMPILE_DEFINITIONS ${STM32F4_DEFINITIONS}
  74. COMPILE_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_COMPILE_OPTIONS}
  75. INCLUDE_DIRECTORIES ${STM32F4_INCLUDE_DIRS}
  76. LINK_OPTIONS ${CORTEX_M4F_COMMON_OPTIONS} ${CORTEX_M4F_LINK_OPTIONS}
  77. MSC_SOURCES ${STM32F4_USBMSC_SRC} ${STM32F4_MSC_SRC}
  78. VCP_SOURCES ${STM32F4_USB_SRC} ${STM32F4_VCP_SRC}
  79. VCP_INCLUDE_DIRECTORIES ${STM32F4_USB_INCLUDE_DIRS}
  80. OPTIMIZATION -O2
  81. OPENOCD_TARGET stm32f4x
  82. ${ARGN}
  83. )
  84. endfunction()
  85. set(STM32F405_COMPILE_DEFINITIONS
  86. STM32F40_41xxx
  87. STM32F405xx
  88. MCU_FLASH_SIZE=1024
  89. )
  90. function(target_stm32f405xg name)
  91. target_stm32f4xx(
  92. NAME ${name}
  93. STARTUP startup_stm32f40xx.s
  94. SOURCES ${STM32F4_STDPERIPH_SRC}
  95. COMPILE_DEFINITIONS ${STM32F405_COMPILE_DEFINITIONS}
  96. LINKER_SCRIPT stm32_flash_f405xg
  97. SVD STM32F405
  98. BOOTLOADER
  99. ${ARGN}
  100. )
  101. endfunction()
  102. set(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F4_STDPERIPH_SRC})
  103. set(STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES "stm32f4xx_fsmc.c")
  104. exclude_basenames(STM32F411_OR_F427_STDPERIPH_SRC ${STM32F411_OR_F427_STDPERIPH_SRC_EXCLUDES})
  105. set(STM32F411_COMPILE_DEFINITIONS
  106. STM32F411xE
  107. MCU_FLASH_SIZE=512
  108. )
  109. function(target_stm32f411xe name)
  110. target_stm32f4xx(
  111. NAME ${name}
  112. STARTUP startup_stm32f411xe.s
  113. SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
  114. COMPILE_DEFINITIONS ${STM32F411_COMPILE_DEFINITIONS}
  115. LINKER_SCRIPT stm32_flash_f411xe
  116. SVD STM32F411
  117. ${ARGN}
  118. )
  119. endfunction()
  120. set(STM32F427_COMPILE_DEFINITIONS
  121. STM32F427_437xx
  122. MCU_FLASH_SIZE=1024
  123. )
  124. function(target_stm32f427xg name)
  125. target_stm32f4xx(
  126. NAME ${name}
  127. STARTUP startup_stm32f427xx.s
  128. SOURCES ${STM32F411_OR_F427_STDPERIPH_SRC}
  129. COMPILE_DEFINITIONS ${STM32F427_COMPILE_DEFINITIONS}
  130. LINKER_SCRIPT stm32_flash_f427xg
  131. SVD STM32F411
  132. ${ARGN}
  133. )
  134. endfunction()