Skip to content

Commit

Permalink
Merge pull request #161 from Hish15/UsingSTM32_SUPPORTED_FAMILIES
Browse files Browse the repository at this point in the history
Code refactor
  • Loading branch information
ObKo authored Dec 18, 2020
2 parents aad7562 + 18e0c8a commit 092961b
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 26 deletions.
7 changes: 1 addition & 6 deletions cmake/FindBSP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,7 @@ set(BSP_L4_DEVICE_STM32L476G_Discovery L476VG)
set(BSP_L4_DEVICE_STM32L496G_Discovery L496AG)

if(NOT BSP_FIND_COMPONENTS)
set(BSP_FIND_COMPONENTS
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
STM32G0 STM32G4
STM32H7_M7 STM32H7_M4
STM32L0 STM32L1 STM32L4
)
set(BSP_FIND_COMPONENTS ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
endif()

if(STM32H7 IN_LIST BSP_FIND_COMPONENTS)
Expand Down
8 changes: 1 addition & 7 deletions cmake/FindCMSIS.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
if(NOT CMSIS_FIND_COMPONENTS)
set(CMSIS_FIND_COMPONENTS
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
STM32G0 STM32G4
STM32H7_M7 STM32H7_M4
STM32L0 STM32L1 STM32L4
)
set(CMSIS_FIND_COMPONENTS ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
endif()

if(STM32H7 IN_LIST CMSIS_FIND_COMPONENTS)
list(REMOVE_ITEM CMSIS_FIND_COMPONENTS STM32H7)
list(APPEND CMSIS_FIND_COMPONENTS STM32H7_M7 STM32H7_M4)
Expand Down
14 changes: 5 additions & 9 deletions cmake/FindHAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ set(HAL_LL_DRIVERS_L4
rcc rng rtc sdmmc spi swpmi tim usart usb utils
)

foreach(FAMILY ${STM32_SUPPORTED_FAMILIES})
list(APPEND HAL_DRIVERS ${HAL_DRIVERS_${FAMILY}})
list(APPEND HAL_LL_DRIVERS ${HAL_LL_DRIVERS_${FAMILY}})
foreach(FAMILY_SUFFIX ${STM32_SUPPORTED_FAMILIES_SHORT_NAME})
list(APPEND HAL_DRIVERS ${HAL_DRIVERS_${FAMILY_SUFFIX}})
list(APPEND HAL_LL_DRIVERS ${HAL_LL_DRIVERS_${FAMILY_SUFFIX}})
endforeach()
list(REMOVE_DUPLICATES HAL_DRIVERS)
list(REMOVE_DUPLICATES HAL_LL_DRIVERS)
Expand All @@ -186,13 +186,9 @@ foreach(COMP ${HAL_FIND_COMPONENTS})
endforeach()

if(NOT HAL_FIND_COMPONENTS_FAMILIES)
set(HAL_FIND_COMPONENTS_FAMILIES
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
STM32G0 STM32G4
STM32H7_M7 STM32H7_M4
STM32L0 STM32L1 STM32L4
)
set(HAL_FIND_COMPONENTS_FAMILIES ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
endif()

if(STM32H7 IN_LIST HAL_FIND_COMPONENTS_FAMILIES)
list(REMOVE_ITEM HAL_FIND_COMPONENTS_FAMILIES STM32H7)
list(APPEND HAL_FIND_COMPONENTS_FAMILIES STM32H7_M7 STM32H7_M4)
Expand Down
18 changes: 14 additions & 4 deletions cmake/stm32/common.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
set(STM32_SUPPORTED_FAMILIES F0 F1 F2 F3 F4 F7 G0 G4 H7 L0 L1 L4)
set(STM32_SUPPORTED_FAMILIES_LONG_NAME
STM32F0 STM32F1 STM32F2 STM32F3 STM32F4 STM32F7
STM32G0 STM32G4
STM32H7_M4 STM32H7_M7
STM32L0 STM32L1 STM32L4)

foreach(FAMILY ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
string(REGEX MATCH "^STM32([A-Z][0-9])_?(M[47])?" FAMILY ${FAMILY})
list(APPEND STM32_SUPPORTED_FAMILIES_SHORT_NAME ${CMAKE_MATCH_1})
endforeach()
list(REMOVE_DUPLICATES STM32_SUPPORTED_FAMILIES_SHORT_NAME)

if(NOT STM32_TOOLCHAIN_PATH)
set(STM32_TOOLCHAIN_PATH "/usr")
Expand Down Expand Up @@ -57,9 +67,9 @@ function(stm32_get_chip_info CHIP)

set(STM32_FAMILY ${CMAKE_MATCH_1})
set(STM32_DEVICE "${CMAKE_MATCH_1}${CMAKE_MATCH_2}")
list(FIND STM32_SUPPORTED_FAMILIES ${STM32_FAMILY} STM32_FAMILY_INDEX)
if (STM32_FAMILY_INDEX EQUAL -1)


if(NOT (${STM32_FAMILY} IN_LIST STM32_SUPPORTED_FAMILIES_SHORT_NAME))
message(FATAL_ERROR "Unsupported family ${STM32_FAMILY} for device ${CHIP}")
endif()

Expand Down

0 comments on commit 092961b

Please sign in to comment.