1# Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
2#
3# SPDX-License-Identifier: BSD-3-Clause
4
5# Called after the Raspberry Pi Pico SDK has been initialized to add our libraries
6
7add_library(FreeRTOS-Kernel-Core INTERFACE)
8target_sources(FreeRTOS-Kernel-Core INTERFACE
9        ${FREERTOS_KERNEL_PATH}/croutine.c
10        ${FREERTOS_KERNEL_PATH}/event_groups.c
11        ${FREERTOS_KERNEL_PATH}/list.c
12        ${FREERTOS_KERNEL_PATH}/queue.c
13        ${FREERTOS_KERNEL_PATH}/stream_buffer.c
14        ${FREERTOS_KERNEL_PATH}/tasks.c
15        ${FREERTOS_KERNEL_PATH}/timers.c
16        )
17target_include_directories(FreeRTOS-Kernel-Core INTERFACE ${FREERTOS_KERNEL_PATH}/include)
18
19if (PICO_SDK_VERSION_STRING VERSION_GREATER_EQUAL "1.3.2")
20    target_compile_definitions(FreeRTOS-Kernel-Core INTERFACE
21            PICO_CONFIG_RTOS_ADAPTER_HEADER=${CMAKE_CURRENT_LIST_DIR}/include/freertos_sdk_config.h)
22endif()
23
24add_library(FreeRTOS-Kernel INTERFACE)
25target_sources(FreeRTOS-Kernel INTERFACE
26        ${CMAKE_CURRENT_LIST_DIR}/port.c
27)
28
29target_include_directories(FreeRTOS-Kernel INTERFACE
30        ${CMAKE_CURRENT_LIST_DIR}/include
31        ${FREERTOS_CONFIG_FILE_DIRECTORY})
32
33target_link_libraries(FreeRTOS-Kernel INTERFACE
34        FreeRTOS-Kernel-Core
35        pico_base_headers
36        hardware_clocks
37        hardware_exception
38        pico_multicore
39)
40
41target_compile_definitions(FreeRTOS-Kernel INTERFACE
42        LIB_FREERTOS_KERNEL=1
43        FREE_RTOS_KERNEL_SMP=1
44)
45
46add_library(FreeRTOS-Kernel-Static INTERFACE)
47target_compile_definitions(FreeRTOS-Kernel-Static INTERFACE
48        configSUPPORT_STATIC_ALLOCATION=1
49        configKERNEL_PROVIDED_STATIC_MEMORY=1
50        )
51
52target_link_libraries(FreeRTOS-Kernel-Static INTERFACE FreeRTOS-Kernel)
53
54add_library(FreeRTOS-Kernel-Heap1 INTERFACE)
55target_sources(FreeRTOS-Kernel-Heap1 INTERFACE ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_1.c)
56target_link_libraries(FreeRTOS-Kernel-Heap1 INTERFACE FreeRTOS-Kernel)
57
58add_library(FreeRTOS-Kernel-Heap2 INTERFACE)
59target_sources(FreeRTOS-Kernel-Heap2 INTERFACE ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_2.c)
60target_link_libraries(FreeRTOS-Kernel-Heap2 INTERFACE FreeRTOS-Kernel)
61
62add_library(FreeRTOS-Kernel-Heap3 INTERFACE)
63target_sources(FreeRTOS-Kernel-Heap3 INTERFACE ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_3.c)
64target_link_libraries(FreeRTOS-Kernel-Heap3 INTERFACE FreeRTOS-Kernel)
65
66add_library(FreeRTOS-Kernel-Heap4 INTERFACE)
67target_sources(FreeRTOS-Kernel-Heap4 INTERFACE ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_4.c)
68target_link_libraries(FreeRTOS-Kernel-Heap4 INTERFACE FreeRTOS-Kernel)
69
70add_library(FreeRTOS-Kernel-Heap5 INTERFACE)
71target_sources(FreeRTOS-Kernel-Heap5 INTERFACE ${FREERTOS_KERNEL_PATH}/portable/MemMang/heap_5.c)
72target_link_libraries(FreeRTOS-Kernel-Heap5 INTERFACE FreeRTOS-Kernel)
73