|
1 | 1 | # Example running FreeRTOS on 1 core |
2 | | -set(TARGET_NAME hello_freertos1) |
3 | | -add_executable(${TARGET_NAME} |
| 2 | +add_executable(hello_freertos_one_core |
4 | 3 | hello_freertos.c |
5 | 4 | ) |
6 | | -target_include_directories(${TARGET_NAME} PRIVATE |
| 5 | +target_include_directories(hello_freertos_one_core PRIVATE |
7 | 6 | ${CMAKE_CURRENT_LIST_DIR}/.. |
8 | 7 | ) |
9 | | -target_link_libraries(${TARGET_NAME} PRIVATE |
| 8 | +# Linking to FreeRTOS-Kernel-Heap4 means we use a dynamic heap for allocations |
| 9 | +target_link_libraries(hello_freertos_one_core PRIVATE |
10 | 10 | pico_async_context_freertos |
11 | 11 | FreeRTOS-Kernel-Heap4 |
12 | 12 | pico_stdlib |
13 | 13 | ) |
| 14 | +# Set the nunber of cores to 1. |
| 15 | +# This defaults to 2 in FreeRTOSConfig_examples_common.h if not defined in here |
| 16 | +target_compile_definitions(hello_freertos_one_core PRIVATE |
| 17 | + configNUMBER_OF_CORES=1 |
| 18 | + ) |
14 | 19 | if(PICO_CYW43_SUPPORTED) |
15 | 20 | # For led support on pico_w |
16 | | - target_link_libraries(${TARGET_NAME} PRIVATE |
| 21 | + target_link_libraries(hello_freertos_one_core PRIVATE |
17 | 22 | pico_cyw43_arch_none |
18 | 23 | ) |
19 | 24 | endif() |
20 | | -target_compile_definitions(${TARGET_NAME} PRIVATE |
21 | | - configNUMBER_OF_CORES=1 |
22 | | - ) |
23 | | -pico_add_extra_outputs(${TARGET_NAME}) |
| 25 | +pico_add_extra_outputs(hello_freertos_one_core) |
24 | 26 |
|
25 | 27 | # Example running FreeRTOS on 2 cores |
26 | | -set(TARGET_NAME hello_freertos2) |
27 | | -add_executable(${TARGET_NAME} |
| 28 | +add_executable(hello_freertos_two_cores |
28 | 29 | hello_freertos.c |
29 | 30 | ) |
30 | | -target_include_directories(${TARGET_NAME} PRIVATE |
| 31 | +target_include_directories(hello_freertos_two_cores PRIVATE |
31 | 32 | ${CMAKE_CURRENT_LIST_DIR}/.. |
32 | 33 | ) |
33 | | -target_link_libraries(${TARGET_NAME} PRIVATE |
| 34 | +# Linking to FreeRTOS-Kernel-Heap4 to use a dynamic heap for allocations |
| 35 | +target_link_libraries(hello_freertos_two_cores PRIVATE |
34 | 36 | pico_async_context_freertos |
35 | 37 | FreeRTOS-Kernel-Heap4 |
36 | 38 | pico_stdlib |
37 | 39 | ) |
38 | 40 | if(PICO_CYW43_SUPPORTED) |
39 | 41 | # For led support on pico_w |
40 | | - target_link_libraries(${TARGET_NAME} PRIVATE |
| 42 | + target_link_libraries(hello_freertos_two_cores PRIVATE |
41 | 43 | pico_cyw43_arch_none |
42 | 44 | ) |
43 | 45 | endif() |
44 | | -pico_add_extra_outputs(${TARGET_NAME}) |
| 46 | +pico_add_extra_outputs(hello_freertos_two_cores) |
45 | 47 |
|
46 | 48 | # Example running FreeRTOS on 2 cores with static RAM allocation |
47 | | -set(TARGET_NAME hello_freertos_static) |
48 | | -add_executable(${TARGET_NAME} |
| 49 | +add_executable(hello_freertos_static_allocation |
49 | 50 | hello_freertos.c |
50 | 51 | ) |
51 | | -target_include_directories(${TARGET_NAME} PRIVATE |
| 52 | +target_include_directories(hello_freertos_static_allocation PRIVATE |
52 | 53 | ${CMAKE_CURRENT_LIST_DIR}/.. |
53 | 54 | ) |
54 | | -target_link_libraries(${TARGET_NAME} PRIVATE |
| 55 | +# Linking to FreeRTOS-Kernel-Static to use static memory instead of a dynamic heap for allocations |
| 56 | +target_link_libraries(hello_freertos_static_allocation PRIVATE |
55 | 57 | pico_async_context_freertos |
56 | 58 | FreeRTOS-Kernel-Static |
57 | 59 | pico_stdlib |
58 | 60 | ) |
59 | | -target_compile_definitions(${TARGET_NAME} PRIVATE |
| 61 | +# Change the configuration to just use static RAM allocation |
| 62 | +# If configSUPPORT_DYNAMIC_ALLOCATION is left undefined it will default to 1 |
| 63 | +# If configSUPPORT_STATIC_ALLOCATION is left undefined it will default to 0 |
| 64 | +target_compile_definitions(hello_freertos_static_allocation PRIVATE |
60 | 65 | configSUPPORT_STATIC_ALLOCATION=1 |
61 | 66 | configSUPPORT_DYNAMIC_ALLOCATION=0 |
62 | 67 | ) |
63 | 68 | if(PICO_CYW43_SUPPORTED) |
64 | 69 | # For led support on pico_w |
65 | | - target_link_libraries(${TARGET_NAME} PRIVATE |
| 70 | + target_link_libraries(hello_freertos_static_allocation PRIVATE |
66 | 71 | pico_cyw43_arch_none |
67 | 72 | ) |
68 | 73 | endif() |
69 | | -pico_add_extra_outputs(${TARGET_NAME}) |
| 74 | +pico_add_extra_outputs(hello_freertos_static_allocation) |
0 commit comments