Skip to content

Commit

Permalink
STM32WL is supported
Browse files Browse the repository at this point in the history
  • Loading branch information
atsju committed Jul 22, 2021
1 parent 5d93332 commit 5f25416
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmake/FindBSP.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ foreach(COMP ${BSP_FIND_COMPONENTS})
string(TOLOWER ${COMP} COMP_L)
string(TOUPPER ${COMP} COMP_U)

string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M[47])?.*$" COMP_U ${COMP_U})
string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
if(NOT CMAKE_MATCH_1)
message(FATAL_ERROR "Unknown BSP component: ${COMP}")
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/FindCMSIS.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ foreach(COMP ${CMSIS_FIND_COMPONENTS})
string(TOLOWER ${COMP} COMP_L)
string(TOUPPER ${COMP} COMP)

string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M[47])?.*$" COMP ${COMP})
string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP ${COMP})
# CMAKE_MATCH_<n> contains n'th subexpression
# CMAKE_MATCH_0 contains full match

Expand Down
18 changes: 16 additions & 2 deletions cmake/FindHAL.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,20 @@ set(HAL_LL_DRIVERS_WB
rng rtc spi tim usart usb utils
)

set(HAL_DRIVERS_WL
adc comp cortex crc cryp dac def dma exti flash gpio gtzc hsem
i2c i2s ipcc irda iwdg lptim pka pwr rcc
rng rtc smartcard smbus spi subghz tim uart usart wwdg
)
set(HAL_EX_DRIVERS_WL
adc crc cryp dma flash i2c pwr rcc
rng rtc smartcard spi tim uart usart
)
set(HAL_LL_DRIVERS_WL
adc bus comp cortex crc dac dma dmamux exti gpio hsem i2c ipcc iwdg lptim lpuart pka pwr rcc
rng rtc spi system tim usart utils wwdg
)

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}})
Expand All @@ -198,7 +212,7 @@ foreach(COMP ${HAL_FIND_COMPONENTS})
string(TOLOWER ${COMP} COMP_L)
string(TOUPPER ${COMP} COMP_U)

string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M[47])?.*$" COMP_U ${COMP_U})
string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
if(CMAKE_MATCH_1)
list(APPEND HAL_FIND_COMPONENTS_FAMILIES ${COMP})
message(TRACE "FindHAL: append COMP ${COMP} to HAL_FIND_COMPONENTS_FAMILIES")
Expand Down Expand Up @@ -244,7 +258,7 @@ message(STATUS "Search for HAL LL drivers: ${HAL_FIND_COMPONENTS_DRIVERS_LL}")
foreach(COMP ${HAL_FIND_COMPONENTS_FAMILIES})
string(TOUPPER ${COMP} COMP_U)

string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M[47])?.*$" COMP_U ${COMP_U})
string(REGEX MATCH "^STM32([FGHLW][0-9BL])([0-9A-Z][0-9M][A-Z][0-9A-Z])?_?(M0PLUS|M4|M7)?.*$" COMP_U ${COMP_U})
if(CMAKE_MATCH_3)
set(CORE ${CMAKE_MATCH_3})
set(CORE_C "::${CORE}")
Expand Down
7 changes: 3 additions & 4 deletions cmake/stm32/common.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(STM32_SUPPORTED_FAMILIES_LONG_NAME

foreach(FAMILY ${STM32_SUPPORTED_FAMILIES_LONG_NAME})
# append short names (F0, F1, H7_M4, ...) to STM32_SUPPORTED_FAMILIES_SHORT_NAME
string(REGEX MATCH "^STM32([FGHLW][0-9BL])_?(M[47])?" FAMILY ${FAMILY})
string(REGEX MATCH "^STM32([FGHLW][0-9BL])_?(M0PLUS|M4|M7)?" FAMILY ${FAMILY})
list(APPEND STM32_SUPPORTED_FAMILIES_SHORT_NAME ${CMAKE_MATCH_1})
endforeach()
list(REMOVE_DUPLICATES STM32_SUPPORTED_FAMILIES_SHORT_NAME)
Expand Down Expand Up @@ -153,8 +153,7 @@ function(stm32_get_cores CORES)
# note STM32WB have an M0 core but in current state of the art it runs ST stacks and is not needed/allowed to build for customer
set(CORE_LIST M4)
elseif(${ARG_FAMILY} STREQUAL "WL")
message(WARNING "common: WL family stm32_get_cores has not been tested")
set(CORE_LIST M4 M0)
stm32wl_get_device_cores(${ARG_DEVICE} ${ARG_TYPE} CORE_LIST)
endif()
set(${CORES} "${CORE_LIST}" PARENT_SCOPE)
endfunction()
Expand Down Expand Up @@ -329,4 +328,4 @@ include(stm32/l1)
include(stm32/l4)
include(stm32/l5)
include(stm32/wb)
#include(stm32/wl) #TODO
include(stm32/wl)
43 changes: 43 additions & 0 deletions cmake/stm32/wl.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
set(STM32_WL_TYPES
WL54xx WL55xx WLE4xx WLE5xx WLE4xx WLE5xx WLE4xx WLE5xx
)
set(STM32_WL_TYPE_MATCH
"WL54.." "WL55.." "WLE4.8" "WLE5.8" "WLE4.B" "WLE5.B" "WLE4.C" "WLE5.C"
)

set(STM32_WL_RAM_SIZES
64K 64K 20K 20K 48K 48K 64K 64K
)
set(STM32_WL_CCRAM_SIZES
0K 0K 0K 0K 0K 0K 0K 0K
)

set(STM32_WL_DUAL_CORE
WL54xx WL55xx
)

stm32_util_create_family_targets(WL M4)

target_compile_options(STM32::WL::M4 INTERFACE
-mcpu=cortex-m4 -mfloat-abi=soft
)
target_link_options(STM32::WL::M4 INTERFACE
-mcpu=cortex-m4 -mfloat-abi=soft
)

stm32_util_create_family_targets(WL M0PLUS)

target_compile_options(STM32::WL::M0PLUS INTERFACE
-mcpu=cortex-m0plus -mfloat-abi=soft
)
target_link_options(STM32::WL::M0PLUS INTERFACE
-mcpu=cortex-m0plus -mfloat-abi=soft
)

function(stm32wl_get_device_cores DEVICE TYPE CORES)
if(${TYPE} IN_LIST STM32_WL_DUAL_CORE)
set(${CORES} M4 M0PLUS PARENT_SCOPE)
else()
set(${CORES} M4 PARENT_SCOPE)
endif()
endfunction()

0 comments on commit 5f25416

Please sign in to comment.