Explorar o código

Changes from code review

1. include for device print function not necessary anymore
2. Improved component convention for H7 example
3. Fixed possible bug in F4 example component logic, is also
   consistent now
4. Some clarifications and form improvements for FreeRTOS section in
   README
Robin Mueller %!s(int64=4) %!d(string=hai) anos
pai
achega
750cce6427
Modificáronse 3 ficheiros con 21 adicións e 20 borrados
  1. 13 9
      README.md
  2. 1 5
      cmake/FindFreeRTOS.cmake
  3. 7 6
      examples/freertos/CMakeLists.txt

+ 13 - 9
README.md

@@ -211,17 +211,20 @@ stm32-cmake contains additional CMake modules for finding and configuring variou
 `FREERTOS_PATH` can be either the path to the whole
 [FreeRTOS/FreeRTOS](https://github.com/FreeRTOS/FreeRTOS) github repo, or the path to
 FreeRTOS-Kernel (usually located in the subfolder `FreeRTOS` on a downloaded release).
-You can supply `FREERTOS_PATH` as an environmental variable as well.
+`FREERTOS_PATH` can be supplied as an environmental variable as well.
 
-You can either use the FreeRTOS kernel provided in the Cube repositories, or a separate
+It is possible to either use the FreeRTOS kernel provided in the Cube repositories, or a separate
 FreeRTOS kernel. The Cube repository also provides the CMSIS RTOS and CMSIS RTOS V2 implementations.
-If you like to use the CMSIS implementations, it is recommended to also use the FreeRTOS sources
+If the CMSIS implementations is used, it is recommended to also use the FreeRTOS sources
 provided in the Cube repository because the CMSIS port might be incompatible to newer kernel
-versions.
+versions. The FreeRTOS port to use is specified as a `FreeRTOS` component. A list of available
+ports can be found below. If the FreeRTOS sources provided in the Cube repository are used, the
+device family also has to be specified as a component for the `FreeRTOS` package.
 
-You can specify to use CMSIS with a `CMSIS` target and by finding the CMSIS `RTOS` package.
-To select which FreeRTOS to use, you can find the package for a specific FreeRTOS port and then
-link against that port target within a specific namespace.
+CMSIS RTOS can be used by specifying a `CMSIS` target and by finding the CMSIS `RTOS` package.
+The following section will show a few example configurations for the H7 and F4 family.
+You can also find example code for the `H743ZI` and `F407VG` devices in the `examples`
+folder.
 
 Typical usage for a H7 device when using the M7 core, using an external kernel without CMSIS
 support. The FreeRTOS namespace is set to `FreeRTOS` and the `ARM_CM7` port is used:
@@ -247,7 +250,8 @@ target_link_libraries(${TARGET_NAME} PRIVATE
 ```
 
 Another typical usage using the FreeRTOS provided in the Cube repository and the CMSIS support.
-The FreeRTOS namespace is set to `FreeRTOS::STM32::<FAMILY>` and the `ARM_CM7` port is used:
+The FreeRTOS namespace is set to `FreeRTOS::STM32::<FAMILY>`, the `ARM_CM7` port is used and
+the device family is specified as a `FreeRTOS` component with `STM32H7`:
 
 ```cmake
 find_package(CMSIS COMPONENTS STM32H743ZI STM32H7_M7 RTOS REQUIRED)
@@ -269,7 +273,7 @@ in the Cube repository
 
 * `FreeRTOS::STM32::<Family>`
 
-For the multi-core architectures, you have to specify both family and core like specified in the
+For the multi-core architectures, both family and core need to be specified like shown in the
 example above.
 
 The following FreeRTOS ports are supported in general: `ARM_CM0`, `ARM_CM3`, `ARM_CM4F`, `ARM_CM7`,

+ 1 - 5
cmake/FindFreeRTOS.cmake

@@ -17,7 +17,7 @@ if(NOT FREERTOS_PATH)
     else()
         message(STATUS
             "No FreeRTOS folder found at default location ${DEFAULT_FREERTOS_PATH}. "
-            "Leaving empty"
+            "Leaving empty.."
         )
     endif()
 endif()
@@ -156,10 +156,6 @@ endmacro()
 message(STATUS "Search for FreeRTOS ports: ${FreeRTOS_FIND_COMPONENTS_PORTS}")
 
 if(NOT FreeRTOS_FIND_COMPONENTS_FAMILIES)
-    if(NOT FREERTOS_PATH)
-        set(FREERTOS_PATH /opt/FreeRTOS CACHE PATH "Path to FreeRTOS")
-        message(STATUS "No FREERTOS_PATH specified, using default: ${FREERTOS_PATH}")
-    endif()
     stm32_find_freertos(FreeRTOS ${FREERTOS_PATH})
 else()
     message(STATUS "Search for FreeRTOS families: ${FreeRTOS_FIND_COMPONENTS_FAMILIES}")

+ 7 - 6
examples/freertos/CMakeLists.txt

@@ -30,8 +30,7 @@ set(CMAKE_TOOLCHAIN_FILE ${STM32_CMAKE_PATH}/cmake/stm32_gcc.cmake)
 project(${PROJ_NAME} CXX C ASM)
 set(CMAKE_INCLUDE_CURRENT_DIR TRUE)
 
-# Can be used to print out all devices for the H7 family
-# include(${STM32_CMAKE_PATH}/cmake/stm32/devices.cmake)
+# Can be used to print out all devices for the H7 or/and the F4 family
 # stm32_print_devices_by_family(FAMILY H7)
 # stm32_print_devices_by_family(FAMILY F4)
 
@@ -59,11 +58,12 @@ if(USE_CMSIS_RTOS_V2)
 endif()
 
 if(FREERTOS_H743ZI_EXAMPLE)
-    list(APPEND CMSIS_COMP_LIST STM32H743ZI STM32H7_M7)
-    list(APPEND HAL_COMP_LIST STM32H7M7 STM32H743ZI)
+    list(APPEND CMSIS_COMP_LIST STM32H743ZI_M7)
+    list(APPEND HAL_COMP_LIST STM32H7M7)
     list(APPEND FREERTOS_COMP_LIST ARM_CM7)
-    list(APPEND FREERTOS_COMP_LIST STM32H7)
     if(USE_CUBE_FREERTOS)
+        # The device family needs to be supplied as a component to use the Cube FreeRTOS sources
+        list(APPEND FREERTOS_COMP_LIST STM32H7)
         set(FREERTOS_H7_NAMESPACE ${FREERTOS_NAMESPACE}::STM32::H7::M7)
     else()
         set(FREERTOS_H7_NAMESPACE ${FREERTOS_NAMESPACE})
@@ -74,7 +74,8 @@ if(FREERTOS_F407VG_EXAMPLE)
     list(APPEND CMSIS_COMP_LIST STM32F407VG)
     list(APPEND HAL_COMP_LIST STM32F407VG)
     list(APPEND FREERTOS_COMP_LIST ARM_CM4F)
-    if(USE_CMSIS_RTOS OR USE_CMSIS_RTOS_V2)
+    if(USE_CUBE_FREERTOS)
+        # The device family needs to be supplied as a component to use the Cube FreeRTOS sources
         list(APPEND FREERTOS_COMP_LIST STM32F4)
         set(FREERTOS_F4_NAMESPACE ${FREERTOS_NAMESPACE}::STM32::F4)
      else()