You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Here is a proposition for a single place regex function:
function(stm32_extract_info identifier)
set(ARG_OPTIONS "")
set(ARG_SINGLE FAMILY DEVICE FLASH_CODE CORE)
set(ARG_MULTIPLE "")
cmake_parse_arguments(PARSE_ARGV 1 INFO "${ARG_OPTIONS}" "${ARG_SINGLE}" "${ARG_MULTIPLE}")
string(REGEX MATCH "^(STM32)?([CFGHLU][0123457]|MP[12]|WL|WB[0A]?)([0-9A-Z][0-9M]?)?([A-Z135])?([3468ABCDEFGHIJYZ])?_?(M0PLUS|M4|M7)?.*$" ID ${identifier})
set(FAMILY ${CMAKE_MATCH_2})
set(SUB_FAMILY ${CMAKE_MATCH_3})
set(PIN_COUNT ${CMAKE_MATCH_4})
set(FLASH_SIZE ${CMAKE_MATCH_5})
set(CORE ${CMAKE_MATCH_6})
# message(STATUS "Parsed ${identifier} and got F ${FAMILY} S ${SUB_FAMILY} P ${PIN_COUNT} R ${FLASH_SIZE} C ${CORE}")
if (INFO_FAMILY AND FAMILY)
set(${INFO_FAMILY} ${FAMILY} PARENT_SCOPE)
endif()
if (INFO_DEVICE AND FAMILY AND SUB_FAMILY AND PIN_COUNT AND FLASH_SIZE)
set(${INFO_DEVICE} ${FAMILY}${SUB_FAMILY}${PIN_COUNT}${FLASH_SIZE} PARENT_SCOPE)
endif()
if (INFO_FLASH_CODE AND FLASH_SIZE)
set(${INFO_FLASH_CODE} ${FLASH_SIZE} PARENT_SCOPE)
endif()
if (INFO_CORE AND CORE)
set(${INFO_CORE} ${CORE} PARENT_SCOPE)
endif()
endfunction()
I changed a bit the original Regex to allow future support for MP2, WBA and WB0 families.
You should notice that devices which were 6 characters long (eg F100C4) can be 7 with family WBA (eg WBA52KE)
several regex to find STM families are reused at many places. It's complex to maintain.
We should create some functions to have regex at one place and easier to reuse.
The text was updated successfully, but these errors were encountered: