Skip to content

Commit

Permalink
Work on making it so this cmake file can be included from anywhere, n…
Browse files Browse the repository at this point in the history
…ot just if it's used from this directoy
  • Loading branch information
Skptak committed Sep 21, 2023
1 parent 8c9b032 commit 2aff1a1
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 47 deletions.
31 changes: 16 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -273,25 +273,26 @@ target_compile_options(freertos_kernel PRIVATE


########################################################################
add_subdirectory(include)
add_subdirectory(portable)
include(${CMAKE_CURRENT_LIST_DIR}/include/CMakeLists.txt)
include(${CMAKE_CURRENT_LIST_DIR}/portable/CMakeLists.txt)

target_sources(freertos_kernel PRIVATE
croutine.c
event_groups.c
list.c
queue.c
stream_buffer.c
tasks.c
timers.c

# Check if user requested to not include a heap implementation
if(NOT DEFINED FREERTOS_DO_NOT_INCLUDE_HEAP)
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
endif()
${CMAKE_CURRENT_LIST_DIR}/croutine.c
${CMAKE_CURRENT_LIST_DIR}/event_groups.c
${CMAKE_CURRENT_LIST_DIR}/list.c
${CMAKE_CURRENT_LIST_DIR}/queue.c
${CMAKE_CURRENT_LIST_DIR}/stream_buffer.c
${CMAKE_CURRENT_LIST_DIR}/tasks.c
${CMAKE_CURRENT_LIST_DIR}/timers.c
)

# Check if user requested to not include a heap implementation
if(NOT DEFINED FREERTOS_DO_NOT_INCLUDE_HEAP)
target_sources(freertos_kernel PRIVATE
# If FREERTOS_HEAP is digit between 1 .. 5 - it is heap number, otherwise - it is path to custom heap source file
$<IF:$<BOOL:$<FILTER:${FREERTOS_HEAP},EXCLUDE,^[1-5]$>>,${FREERTOS_HEAP},portable/MemMang/heap_${FREERTOS_HEAP}.c>
)
endif()

target_link_libraries(freertos_kernel
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ add_library(freertos_kernel_include INTERFACE)

target_include_directories(freertos_kernel_include
INTERFACE
.
${CMAKE_CURRENT_LIST_DIR}/.
# Note: DEPRECATED but still supported, may be removed in a future release.
$<$<NOT:$<TARGET_EXISTS:freertos_config>>:${FREERTOS_CONFIG_FILE_DIRECTORY}>
)
Expand Down
63 changes: 32 additions & 31 deletions include/portable.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,15 +135,15 @@
/* Only include heap related functions and structs if using dynamic allocation */
#if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )

/* Used by heap_5.c to define the start address and size of each memory region
* that together comprise the total FreeRTOS heap space. */
/* Used by heap_5.c to define the start address and size of each memory region
* that together comprise the total FreeRTOS heap space. */
typedef struct HeapRegion
{
uint8_t * pucStartAddress;
size_t xSizeInBytes;
} HeapRegion_t;

/* Used to pass information about the heap out of vPortGetHeapStats(). */
/* Used to pass information about the heap out of vPortGetHeapStats(). */
typedef struct xHeapStats
{
size_t xAvailableHeapSpaceInBytes; /* The total heap size currently available - this is the sum of all the free blocks, not the largest block that can be allocated. */
Expand All @@ -155,31 +155,31 @@
size_t xNumberOfSuccessfulFrees; /* The number of calls to vPortFree() that has successfully freed a block of memory. */
} HeapStats_t;

/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
* pvPortMalloc being called.
*
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
* defines a region of memory that can be used as the heap. The array is
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
/*
* Used to define multiple heap regions for use by heap_5.c. This function
* must be called before any calls to pvPortMalloc() - not creating a task,
* queue, semaphore, mutex, software timer, event group, etc. will result in
* pvPortMalloc being called.
*
* pxHeapRegions passes in an array of HeapRegion_t structures - each of which
* defines a region of memory that can be used as the heap. The array is
* terminated by a HeapRegions_t structure that has a size of 0. The region
* with the lowest start address must appear first in the array.
*/
void vPortDefineHeapRegions( const HeapRegion_t * const pxHeapRegions ) PRIVILEGED_FUNCTION;

/*
* Returns a HeapStats_t structure filled with information about the current
* heap state.
*/
/*
* Returns a HeapStats_t structure filled with information about the current
* heap state.
*/
void vPortGetHeapStats( HeapStats_t * pxHeapStats );

/*
* Map to the memory management routines required for the port.
*/
/*
* Map to the memory management routines required for the port.
*/
void * pvPortMalloc( size_t xSize ) PRIVILEGED_FUNCTION;
void * pvPortCalloc( size_t xNum,
size_t xSize ) PRIVILEGED_FUNCTION;
size_t xSize ) PRIVILEGED_FUNCTION;
void vPortFree( void * pv ) PRIVILEGED_FUNCTION;
void vPortInitialiseBlocks( void ) PRIVILEGED_FUNCTION;
size_t xPortGetFreeHeapSize( void ) PRIVILEGED_FUNCTION;
Expand All @@ -194,15 +194,16 @@
#endif

#if ( configUSE_MALLOC_FAILED_HOOK == 1 )
/**
* task.h
* @code{c}
* void vApplicationMallocFailedHook( void )
* @endcode
*
* This hook function is called when allocation failed.
*/
void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */

/**
* task.h
* @code{c}
* void vApplicationMallocFailedHook( void )
* @endcode
*
* This hook function is called when allocation failed.
*/
void vApplicationMallocFailedHook( void ); /*lint !e526 Symbol not defined as it is an application callback. */
#endif /* ( configUSE_MALLOC_FAILED_HOOK == 1 ) */

#endif /* if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) */
Expand Down

0 comments on commit 2aff1a1

Please sign in to comment.